dynamicsmobile
Version:
Allows development of off-line mobile and web business apps over the Dynamics Mobile platform. More info on https://www.dynamicsmobile.com
338 lines • 19.8 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LiveLinkQuery = exports.appAreaServiceName = void 0;
const tslib_1 = require("tslib");
const dms_platform_bridge_factory_1 = require("../platform/dms-platform-bridge-factory");
const dms_root_container_1 = require("../ioc/dms-root-container");
const configuration_service_1 = require("./configuration-service");
const livelink_query_apparea_1 = require("./livelink/livelink-query-apparea");
const livelink_query_viacloud_1 = require("./livelink/livelink-query-viacloud");
const livelink_query_legacy_dmsagent_1 = require("./livelink/livelink-query-legacy-dmsagent");
const livelink_query_dmsagent2_1 = require("./livelink/livelink-query-dmsagent2");
const livelinkquery_backendservice_1 = require("../lib-backendservice/livelinkquery-backendservice");
exports.appAreaServiceName = '$$apparea';
class LiveLinkQuery extends livelink_query_apparea_1.LiveLinkQueryAppArea {
// async executeRaw(sql: string, companyName: string): Promise<Array<any>> {
// if (!sql)
// throw new Error('LiveLinkQuery.executeRaw requires argument sql');
// if (!companyName)
// throw new Error('LiveLinkQuery.executeRaw requires argument companyName');
// const cfg = RootDIContainer.inject(ConfigurationService);
// let liveLinkUrl = await cfg.getSetting('liveLinkUrl');
// if (liveLinkUrl && this._serviceName != appAreaServiceName) {
// if (await cfg.getSetting('dmsagent2') == 'true') {
// const q = new LiveLinkQueryDmsAgent2(this.dms, this._serviceName, this._appCode, '', '', '', [], this.customAuthToken, this._isSandbox);
// q.company(companyName);
// const cmdArgs = { sql: sql, company: companyName };
// return q.executeCommand('raw', cmdArgs);
// }
// else {
// const response = await PlatformBridgeFactory(this.dms).execute("selectsql", { query: sql, company: companyName });
// if (response) {
// if (typeof response == 'string') {
// var jsnResponse = JSON.parse(response);
// if (jsnResponse && jsnResponse.response) {
// return jsnResponse.response;
// }
// else {
// return [];
// }
// }
// else {
// return response;
// }
// }
// else {
// throw new Error("Livelink query did not returned response from server!");
// }
// }
// }
// }
executeCommand(parameters) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const cfg = dms_root_container_1.RootDIContainer.inject(configuration_service_1.ConfigurationService);
let liveLinkUrl = yield cfg.getSetting('liveLinkUrl');
if (liveLinkUrl && this._serviceName != exports.appAreaServiceName) {
//execute command via agent
let q;
//if (await cfg.getSetting('dmsagent2') == 'true') {
//agent2 code
q = new livelink_query_dmsagent2_1.LiveLinkQueryDmsAgent2(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
//}
//else {
//legacy agent code
// q = new LiveLinkQueryDmsAgent(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
//}
q.company(this._company);
q.filter(this._filter);
q.expand(this._expand);
q.limit(this._max);
q.sort(this._sort);
q.page(this._page);
q.fields(this._fields);
q.group(this._group);
q.aggregate(this._aggregate);
return q.executeCommand(parameters);
}
else {
let q;
if (typeof window === 'undefined') {
//execute command via backend service, e.g. when app runs in nodejs in the cloud
q = new livelinkquery_backendservice_1.LiveLinkQueryBackendService(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
else {
//execute command against app area, e.g. when app runs in browser
q = new livelink_query_apparea_1.LiveLinkQueryAppArea(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
q.company(this._company);
q.filter(this._filter);
q.expand(this._expand);
q.limit(this._max);
q.sort(this._sort);
q.page(this._page);
q.fields(this._fields);
q.group(this._group);
q.aggregate(this._aggregate);
return q.executeCommand(parameters);
}
});
}
executeMetadata() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
let authToken = this.customAuthToken;
if (!authToken)
authToken = yield (0, dms_platform_bridge_factory_1.PlatformBridgeFactory)(this.dms).execute("getSessionKey", null);
if (this._serviceName != exports.appAreaServiceName) {
const q = new livelink_query_viacloud_1.LiveLinkQueryViaCloud(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, authToken, this._isSandbox);
q.company(this._company);
return q.executeMetadata();
}
else {
let q;
if (typeof window === 'undefined') {
q = new livelinkquery_backendservice_1.LiveLinkQueryBackendService(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
else {
q = new livelink_query_apparea_1.LiveLinkQueryAppArea(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
q.company(this._company);
return q.executeMetadata();
}
});
}
executeSelect() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const cfg = dms_root_container_1.RootDIContainer.inject(configuration_service_1.ConfigurationService);
let liveLinkUrl = yield cfg.getSetting('liveLinkUrl');
if (liveLinkUrl && this._serviceName != exports.appAreaServiceName) {
let q;
if ((yield cfg.getSetting('dmsagent2')) == 'true') {
q = new livelink_query_dmsagent2_1.LiveLinkQueryDmsAgent2(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
else {
q = new livelink_query_legacy_dmsagent_1.LegacyLiveLinkQueryDmsAgent(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
q.company(this._company);
q.filter(this._filter);
q.expand(this._expand);
q.limit(this._max);
q.sort(this._sort);
q.page(this._page);
q.fields(this._fields);
q.group(this._group);
q.aggregate(this._aggregate);
return q.executeSelect();
}
else if (this._serviceName != exports.appAreaServiceName) {
const q = new livelink_query_viacloud_1.LiveLinkQueryViaCloud(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
q.company(this._company);
q.filter(this._filter);
q.expand(this._expand);
q.limit(this._max);
q.sort(this._sort);
q.page(this._page);
q.fields(this._fields);
q.group(this._group);
q.aggregate(this._aggregate);
return q.executeSelect();
}
else {
let q;
if (typeof window === 'undefined') {
q = new livelinkquery_backendservice_1.LiveLinkQueryBackendService(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
else {
q = new livelink_query_apparea_1.LiveLinkQueryAppArea(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
q.company(this._company);
q.filter(this._filter);
q.expand(this._expand);
q.limit(this._max);
q.sort(this._sort);
q.page(this._page);
q.fields(this._fields);
q.group(this._group);
q.aggregate(this._aggregate);
return q.executeSelect();
}
});
}
executeCount() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const cfg = dms_root_container_1.RootDIContainer.inject(configuration_service_1.ConfigurationService);
let liveLinkUrl = yield cfg.getSetting('liveLinkUrl');
if (liveLinkUrl && this._serviceName != exports.appAreaServiceName) {
let q;
if ((yield cfg.getSetting('dmsagent2')) == 'true') {
q = new livelink_query_dmsagent2_1.LiveLinkQueryDmsAgent2(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
else {
q = new livelink_query_legacy_dmsagent_1.LegacyLiveLinkQueryDmsAgent(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
q.company(this._company);
q.filter(this._filter);
q.expand(this._expand);
q.limit(this._max);
q.sort(this._sort);
q.page(this._page);
q.fields(this._fields);
q.group(this._group);
q.aggregate(this._aggregate);
return q.executeCount();
}
else if (this._serviceName != exports.appAreaServiceName) {
const q = new livelink_query_viacloud_1.LiveLinkQueryViaCloud(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
q.company(this._company);
q.filter(this._filter);
q.expand(this._expand);
q.limit(this._max);
q.sort(this._sort);
q.page(this._page);
q.fields(this._fields);
q.group(this._group);
q.aggregate(this._aggregate);
return q.executeCount();
}
else {
let q;
if (typeof window === 'undefined') {
q = new livelinkquery_backendservice_1.LiveLinkQueryBackendService(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
else {
q = new livelink_query_apparea_1.LiveLinkQueryAppArea(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
q.company(this._company);
q.filter(this._filter);
q.expand(this._expand);
q.limit(this._max);
q.sort(this._sort);
q.page(this._page);
q.fields(this._fields);
q.group(this._group);
q.aggregate(this._aggregate);
return q.executeCount();
}
});
}
executeCreate(entity) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const cfg = dms_root_container_1.RootDIContainer.inject(configuration_service_1.ConfigurationService);
let liveLinkUrl = yield cfg.getSetting('liveLinkUrl');
if (liveLinkUrl && this._serviceName != exports.appAreaServiceName) {
let q;
if ((yield cfg.getSetting('dmsagent2')) == 'true') {
q = new livelink_query_dmsagent2_1.LiveLinkQueryDmsAgent2(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
else {
q = new livelink_query_legacy_dmsagent_1.LegacyLiveLinkQueryDmsAgent(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
q.company(this._company);
return q.executeCreate(entity);
}
else if (this._serviceName != exports.appAreaServiceName) {
const q = new livelink_query_viacloud_1.LiveLinkQueryViaCloud(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
q.company(this._company);
return q.executeCreate(entity);
}
else {
let q;
if (typeof window === 'undefined') {
q = new livelinkquery_backendservice_1.LiveLinkQueryBackendService(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
else {
q = new livelink_query_apparea_1.LiveLinkQueryAppArea(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
q.company(this._company);
return q.executeCreate(entity);
}
});
}
executeUpdate(entity, pkValues, pkFields) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const cfg = dms_root_container_1.RootDIContainer.inject(configuration_service_1.ConfigurationService);
let liveLinkUrl = yield cfg.getSetting('liveLinkUrl');
if (liveLinkUrl && this._serviceName != exports.appAreaServiceName) {
let q;
if ((yield cfg.getSetting('dmsagent2')) == 'true') {
q = new livelink_query_dmsagent2_1.LiveLinkQueryDmsAgent2(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
else {
q = new livelink_query_legacy_dmsagent_1.LegacyLiveLinkQueryDmsAgent(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
q.company(this._company);
return q.executeUpdate(entity, pkValues, pkFields);
}
else if (this._serviceName != exports.appAreaServiceName) {
const q = new livelink_query_viacloud_1.LiveLinkQueryViaCloud(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
q.company(this._company);
return q.executeUpdate(entity, pkValues, pkFields);
}
else {
let q;
if (typeof window === 'undefined') {
q = new livelinkquery_backendservice_1.LiveLinkQueryBackendService(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
else {
q = new livelink_query_apparea_1.LiveLinkQueryAppArea(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
q.company(this._company);
return q.executeUpdate(entity, pkValues, pkFields);
}
});
}
executeDelete(entity, pkValues, pkFields) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const cfg = dms_root_container_1.RootDIContainer.inject(configuration_service_1.ConfigurationService);
let liveLinkUrl = yield cfg.getSetting('liveLinkUrl');
if (liveLinkUrl && this._serviceName != exports.appAreaServiceName) {
let q;
if ((yield cfg.getSetting('dmsagent2')) == 'true') {
q = new livelink_query_dmsagent2_1.LiveLinkQueryDmsAgent2(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
else {
q = new livelink_query_legacy_dmsagent_1.LegacyLiveLinkQueryDmsAgent(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
q.company(this._company);
return q.executeDelete(entity, pkValues, pkFields);
}
else if (this._serviceName != exports.appAreaServiceName) {
const q = new livelink_query_viacloud_1.LiveLinkQueryViaCloud(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
q.company(this._company);
return q.executeDelete(entity, pkValues, pkFields);
}
else {
let q;
if (typeof window === 'undefined') {
q = new livelinkquery_backendservice_1.LiveLinkQueryBackendService(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
else {
q = new livelink_query_apparea_1.LiveLinkQueryAppArea(this.dms, this._serviceName, this._appCode, this._entityName, this._entityTable, this._syncTag, this._members, this.customAuthToken, this._isSandbox);
}
q.company(this._company);
return q.executeDelete(entity, pkValues, pkFields);
}
});
}
}
exports.LiveLinkQuery = LiveLinkQuery;
//# sourceMappingURL=livelink-query-service.js.map