UNPKG

dynamicsmobile

Version:

Allows development of off-line mobile and web business apps over the Dynamics Mobile platform. More info on https://www.dynamicsmobile.com

159 lines 6.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DeviceService = exports.LocationService = exports.LocationServiceInterface = void 0; const tslib_1 = require("tslib"); const app_service_app_1 = require("./app-service-app"); const application_context_service_1 = require("./application-context-service"); const dms_platform_bridge_factory_1 = require("../platform/dms-platform-bridge-factory"); const injectable_1 = require("../ioc/injectable"); const print_service_1 = require("../lib-core/print-service"); const dms_platform_type_1 = require("../platform/dms-platform-type"); const sdkinfo_1 = require("../sdkinfo"); class LocationServiceInterface { } exports.LocationServiceInterface = LocationServiceInterface; let LocationService = exports.LocationService = class LocationService extends app_service_app_1.CoreAppService { get(precision) { return tslib_1.__awaiter(this, void 0, void 0, function* () { if (this.useFakeLocation) { return { accuracy: 9999, latitude: 44.444, longitude: 22.222, speed: 0, }; } else { const obj = yield (0, dms_platform_bridge_factory_1.PlatformBridgeFactory)(this.dms).execute("getLocation", { precision }); if (!obj) { return { accuracy: 0, latitude: 0, longitude: 0, speed: 0, }; } if (!obj.longitude) { obj.longitude = (obj.long ? obj.long : 0); } if (!obj.latitude) { obj.latitude = (obj.lat ? obj.lat : 0); } return obj; } }); } }; exports.LocationService = LocationService = tslib_1.__decorate([ (0, injectable_1.Injectable)() ], LocationService); let DeviceService = exports.DeviceService = class DeviceService { constructor(dms, printManager) { this.dms = dms; this.printManager = printManager; this.location = new LocationService(this.dms, null); } logOut() { return (0, dms_platform_bridge_factory_1.PlatformBridgeFactory)(this.dms).execute("logOut", undefined); } sync() { return tslib_1.__awaiter(this, void 0, void 0, function* () { return (0, dms_platform_bridge_factory_1.PlatformBridgeFactory)(this.dms).execute("sync", undefined); }); } hideOnScreenKeyboard() { const platform = (0, dms_platform_bridge_factory_1.PlatformBridgeFactory)(this.dms); return platform.execute("hideKeyboard", null); } isNFCSupported() { return tslib_1.__awaiter(this, void 0, void 0, function* () { return false; }); } readNFCTag() { return tslib_1.__awaiter(this, void 0, void 0, function* () { return {}; }); } getIPAddress() { return tslib_1.__awaiter(this, void 0, void 0, function* () { return (0, dms_platform_bridge_factory_1.PlatformBridgeFactory)(this.dms).execute("getIPAddress", undefined); }); } barcodeScan() { return tslib_1.__awaiter(this, void 0, void 0, function* () { const b = yield (0, dms_platform_bridge_factory_1.PlatformBridgeFactory)(this.dms).execute("barcodescan", undefined); if (!b) { return { content: null, success: false, message: null, format: null }; } if (typeof b === "string") { return JSON.parse(b); } return b; }); } getPlatformType() { return (0, dms_platform_type_1.getPlatformType)(); } getInfo() { return tslib_1.__awaiter(this, void 0, void 0, function* () { const info = yield (0, dms_platform_bridge_factory_1.PlatformBridgeFactory)(this.dms).execute("getDeviceInfo", undefined); info.sdkDate = sdkinfo_1.sdkInfo.sdkDate; info.sdkVersion = sdkinfo_1.sdkInfo.sdkVersion; return info; }); } openWebBrowser(url) { return tslib_1.__awaiter(this, void 0, void 0, function* () { return (0, dms_platform_bridge_factory_1.PlatformBridgeFactory)(this.dms).execute("openWebBrowser", { url }); }); } shareContent(content, _mime) { return tslib_1.__awaiter(this, void 0, void 0, function* () { throw new Error('not implemented'); }); } sendEmail(recipient, _subject, content, attachment, sender) { return tslib_1.__awaiter(this, void 0, void 0, function* () { return (0, dms_platform_bridge_factory_1.PlatformBridgeFactory)(this.dms).execute("email", { recipient, _subject, content, attachment, sender: sender }); // return this.printManager.print(this.printManager.printerName_Screen, content, 800, 600, 'utf8', true); }); } takePicture() { return tslib_1.__awaiter(this, void 0, void 0, function* () { // return { url: "https://www.dynamicsmobile.com/assets/img/logo/dynamicsmobile.png" }; return (0, dms_platform_bridge_factory_1.PlatformBridgeFactory)(this.dms).execute("takePicture", null); }); } selectPicture() { return tslib_1.__awaiter(this, void 0, void 0, function* () { return (0, dms_platform_bridge_factory_1.PlatformBridgeFactory)(this.dms).execute("selectPicture", null); }); } getBTDevices() { return tslib_1.__awaiter(this, void 0, void 0, function* () { return (0, dms_platform_bridge_factory_1.PlatformBridgeFactory)(this.dms).execute("getbtdevices", undefined); }); } beepOk() { return (0, dms_platform_bridge_factory_1.PlatformBridgeFactory)(this.dms).execute("soundBeepOk", undefined); } beepError() { return (0, dms_platform_bridge_factory_1.PlatformBridgeFactory)(this.dms).execute("soundBeepError", undefined); } beepDoubleOk() { return (0, dms_platform_bridge_factory_1.PlatformBridgeFactory)(this.dms).execute("soundBeepDoubleOk", undefined); } logEvent(level, message, user, metricValue) { if (level == 'INFO' || level == 'WARN') console.log(message); else console.log(`ERROR: ${message}`); } }; exports.DeviceService = DeviceService = tslib_1.__decorate([ (0, injectable_1.Injectable)(), tslib_1.__metadata("design:paramtypes", [application_context_service_1.DmsApplicationService, print_service_1.PrintService]) ], DeviceService); //# sourceMappingURL=device-service.js.map