import { eiotAppManagerService } from '../eiot-app-manager.service'; class EIoTTraceService { //#region Initializations //#region Variables private static readonly CONST_CLASSNAME = 'LWAppManager.Common.LWTrace'; private static readonly CONST_TRANS_CLASSNAME = 'LWAppManager.Common.LWTransaction'; private static readonly CONST_KEY = 'Common'; //#endregion Variables //#endregion Initializations //#region Public Methods // public transactionStart( // transactionType: string, // siteID: string, // deviceID: string, // updUserID: string, // transactionBy: string // ) { // try { // var reqParams = { // TransactionType: transactionType, // SiteID: siteID, // DeviceID: deviceID, // UpdUserID: updUserID, // TransactionBy: transactionBy, // }; // return eiotAppManagerService // .callSignalR( // EIoTTraceService.CONST_KEY, // EIoTTraceService.CONST_TRANS_CLASSNAME, // 'Start', // JSON.stringify(reqParams) // ) // .then((result) => { // return result; // }); // } catch (e) {} // } // public transactionDone(transactionType: string) { // try { // var reqParams = { // TransactionType: transactionType, // }; // return eiotAppManagerService // .callSignalR( // EIoTTraceService.CONST_KEY, // EIoTTraceService.CONST_TRANS_CLASSNAME, // 'Done', // JSON.stringify(reqParams) // ) // .then((result) => { // return result; // }); // } catch (e) {} // } async sessionStart() { try { const proxy = await eiotAppManagerService.getSignalRConn(); const reqParams = { IsDoDeviceUserLogIn: true, Invoker: "SessionStart", Severity: "Info", IsUrgentTrace: false, PageName: "Home", }; const ISignalRVM = { Key: EIoTTraceService.CONST_KEY, ClassName: EIoTTraceService.CONST_CLASSNAME, MethodName: 'AppSessionStart', ReqParams: JSON.stringify(reqParams), }; return await new Promise((resolve, reject) => { const execute = async () => { proxy.invoke('action', ISignalRVM).done((response:any) => { resolve(response); }).fail((err:any) => { console.error(JSON.stringify(err)); reject(err); }); } execute() }) } catch (err) { console.error(JSON.stringify(err)); return err; } } async pageNavigateStart() { try { const proxy = await eiotAppManagerService.getSignalRConn(); const methodName = 'PageNavigateStart'; const ISignalRVM = { Key: EIoTTraceService.CONST_KEY, ClassName: EIoTTraceService.CONST_CLASSNAME, MethodName: methodName, ReqParams: JSON.stringify("Home"), }; return await new Promise((resolve, reject) => { proxy.invoke('action', ISignalRVM).done((response:any) => { resolve(response) }).fail((err:any) => { console.error(JSON.stringify(err)); reject(err) }); }) } catch (err) { console.error(JSON.stringify(err)); return err; } } // public pageNavigation( // caption: string, // invoker: string, // severity: string, // pageTitle: string, // navUrl: string, // isUrgentTrace: boolean // ) { // try { // var reqParams = { // Invoker: invoker, // Severity: severity, // IsUrgentTrace: isUrgentTrace, // PageName: pageTitle, // NavUrl: navUrl, // }; // return eiotAppManagerService // .callSignalR( // EIoTTraceService.CONST_KEY, // EIoTTraceService.CONST_CLASSNAME, // 'PageNavigation', // JSON.stringify(reqParams) // ) // .then((result) => { // return result; // }); // } catch (e) {} // } // public userAction( // caption: string, // invoker: string, // severity: string, // pageTitle: string, // isUrgentTrace: boolean, // message: string // ) { // try { // var reqParams = { // Caption: caption, // Invoker: invoker, // Severity: severity, // IsUrgentTrace: isUrgentTrace, // PageName: pageTitle, // Message: message, // }; // return eiotAppManagerService // .callSignalR( // EIoTTraceService.CONST_KEY, // EIoTTraceService.CONST_CLASSNAME, // 'UserAction', // JSON.stringify(reqParams) // ) // .then((result) => { // return result; // }); // } catch (e) {} // } // public deviceCallReq( // device: string, // action: string, // payload: string, // invoker: string, // severity: string, // pageTitle: string, // isUrgentTrace: boolean // ) { // try { // var reqParams = { // Device: device, // Action: action, // Payload: payload, // Invoker: invoker, // Severity: severity, // IsUrgentTrace: isUrgentTrace, // PageName: pageTitle, // }; // return eiotAppManagerService // .callSignalR( // EIoTTraceService.CONST_KEY, // EIoTTraceService.CONST_CLASSNAME, // 'DeviceCallReq', // JSON.stringify(reqParams) // ) // .then((result) => { // return result; // }); // } catch (e) {} // } // public deviceCallRes( // device: string, // action: string, // payload: string, // invoker: string, // severity: string, // pageTitle: string, // isUrgentTrace: boolean // ) { // try { // var reqParams = { // Device: device, // Action: action, // Payload: payload, // Invoker: invoker, // Severity: severity, // IsUrgentTrace: isUrgentTrace, // PageName: pageTitle, // }; // return eiotAppManagerService // .callSignalR( // EIoTTraceService.CONST_KEY, // EIoTTraceService.CONST_CLASSNAME, // 'DeviceCallRes', // JSON.stringify(reqParams) // ) // .then((result) => { // return result; // }); // } catch (e) {} // } // public info( // message: string, // invoker: string, // severity: string, // pageTitle: string, // isUrgentTrace: boolean // ) { // try { // var reqParams = { // Message: message, // Invoker: invoker, // Severity: severity, // IsUrgentTrace: isUrgentTrace, // PageName: pageTitle, // }; // return eiotAppManagerService // .callSignalR( // EIoTTraceService.CONST_KEY, // EIoTTraceService.CONST_CLASSNAME, // 'Info', // JSON.stringify(reqParams) // ) // .then((result) => { // return result; // }); // } catch (e) {} // } // public warning( // message: string, // invoker: string, // severity: string, // pageTitle: string, // isUrgentTrace: boolean, // routeID: string // ) { // try { // var reqParams = { // Message: message, // Invoker: invoker, // Severity: severity, // IsUrgentTrace: isUrgentTrace, // PageName: pageTitle, // RouteID: routeID, // }; // return eiotAppManagerService // .callSignalR( // EIoTTraceService.CONST_KEY, // EIoTTraceService.CONST_CLASSNAME, // 'Warning', // JSON.stringify(reqParams) // ) // .then((result) => { // return result; // }); // } catch (e) {} // } // public error( // message: string, // invoker: string, // severity: string, // pageTitle: string, // isUrgentTrace: boolean // ) { // try { // var reqParams = { // Message: message, // Invoker: invoker, // Severity: severity, // IsUrgentTrace: isUrgentTrace, // PageName: pageTitle, // }; // return eiotAppManagerService // .callSignalR( // EIoTTraceService.CONST_KEY, // EIoTTraceService.CONST_CLASSNAME, // 'Error', // JSON.stringify(reqParams) // ) // .then((result) => { // return result; // }); // } catch (e) {} // } // public sessionEnd( // invoker: string, // severity: string, // pageTitle: string, // isUrgentTrace: boolean // ) { // try { // var reqParams = { // Invoker: invoker, // Severity: severity, // IsUrgentTrace: isUrgentTrace, // PageName: pageTitle, // }; // return eiotAppManagerService // .callSignalR( // EIoTTraceService.CONST_KEY, // EIoTTraceService.CONST_CLASSNAME, // 'SessionEnd', // JSON.stringify(reqParams) // ) // .then((result) => { // return result; // }); // } catch (e) {} // } //#endregion Public Methods } export const eiotTraceService = new EIoTTraceService()