123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- import { AnyObject } from "mongoose";
- import { map, Observable, of, tap } from "rxjs";
- import { BaseMessage, Command, ResponseMessage, Uuid } from "../dependencies/fisappmessagejsutilty/interface/export"
- import { FisCreateMessageUtility } from "../dependencies/fisappmessagejsutilty/interface/export";
- import { LoggingService } from "../dependencies/fisloggingservice/services/logging-service";
- import { LogSetting, MessageLog } from "../dependencies/fisloggingservice/type/datatype";
- import { Acknowledgemeent, AcknowledgementLogSetting } from "../type/acknowledgement.interface";
- export class AcknowledgementService implements Acknowledgemeent {
- private messageUtil: FisCreateMessageUtility = new FisCreateMessageUtility("FisAppID/Name")
- private settings: LogSetting = {
- storage: '',
- setting: {
- appId: '',
- appName: '',
- logLocName: '',
- logLocId: '',
- appLogLocId: '',
- appLocName: '',
- appLogId: ''
- }
- }
- constructor(private logService1?: LoggingService, private logService?: LoggingService) {
- // this.logService1 = new LoggingService()
- this.logService = new LoggingService()
- }
- public async init(settings: AcknowledgementLogSetting) {
- let logSetting: LogSetting = {
- ...settings,
- setting: {
- ...settings.setting,
- logLocName: "locationName2",
- appLocName: "appLocName2"
- }
- }
- this.settings = logSetting
- this.logService.init(logSetting)
- }
- public subscribe(obs: Observable<BaseMessage>): Observable<ResponseMessage> {
- let acknowledgementToken: Observable<ResponseMessage> = obs.pipe(
- map(
- incoming_msg => {
- let emulatedId = "GeneratedFromMessageSync"
- let emulatedRequest = this.messageUtil.getCommandMessage(emulatedId, Command.New, incoming_msg)
- let finalResponse = this.messageUtil.getResponseMessage(emulatedId, { "Acknowledgement": 1 }, emulatedRequest)
- return finalResponse
- }
- ))
- let acknowledgementTokenLogging: Observable<MessageLog> = obs.pipe(
- map(
- incoming_msg => {
- let finalResponse:MessageLog = {
- appLogLocId: new Uuid().generateId(),
- appData: {
- msgId: incoming_msg.header.messageID || new Uuid().generateId(),
- msgLogDateTime: new Date(),
- msgDateTime: new Date(),
- msgTag: ['Acknowledgement'],
- msgPayload: JSON.stringify(incoming_msg)
- }
- }
- return finalResponse
- }
- )
- )
- this.logService.subscribe(acknowledgementTokenLogging)
- return acknowledgementToken
- }
- }
|