public void Test_getFullInputFormatValue() { ServiceTranslationManager transMngr = new ServiceTranslationManager(); String testData = "I000CUI,TI:000000000000000000,AN:010203040,SI:013,HE:C3,ND:B4567,BD:05,TL:Mrs ,LN:Customer ,FN:Test ,MI:E,A1:222 Avenue St. ,A2:Apt#123 ,CT:Greensburg ,ST:PA,ZP:12345 ,HP:213 123 1234,WP:215 123 1234,AS:A,E1:ENG000102030405.00039V000CUI,0000000,TI:000000000000000000.select LastName from Subscriber where SmsTag='013010203040'CUSTOMERselect FirstName from Subscriber where SmsTag='013010203040'TEST"; String expData = transMngr.getFullInputFormatValue(testData); Assert.AreEqual("I000CUI", expData, "Invalid Input format"); }
/// <summary> /// Process ICOMS input messages based on type CUI/CCI/EQI. /// </summary> /// <param name="strICOMS_input_Msg"></param> /// <param name="templistenerMembers"></param> /// <returns></returns> public string processICOMSMessages(string strICOMS_input_Msg, ServiceListenerMembers templistenerMembers) { string strMsgFormat = string.Empty; string retMsg2ICOM = string.Empty; string strResMainFormat = string.Empty; string strGetICOMSMsgTillDot = string.Empty; ServiceTranslationManager trsMgr = new ServiceTranslationManager(); try { logger.Info("ServiceRunTimeManager::processICOMSMessages() called"); // Find dot from last & get message till that dot strGetICOMSMsgTillDot = strICOMS_input_Msg.Substring(0, strICOMS_input_Msg.LastIndexOf(".")); logger.Info("Extracted ICOMS Message for processing from received message..."); logger.Info(string.Format("{0}",strGetICOMSMsgTillDot)); // Find CUI/CCI/EQI strMsgFormat = trsMgr.findICOMInputFormat(strGetICOMSMsgTillDot); logger.Info(string.Format("ICOMS Message Format... {0}", strMsgFormat)); if (strMsgFormat.Equals("ACK")) { // form outgoing message format - xxxxxVyyyACK strResMainFormat = trsMgr.ReplaceAtIndex(strGetICOMSMsgTillDot.IndexOf("I"), 'V', strGetICOMSMsgTillDot); logger.Info(string.Format("ICOMS Full response Format... {0}", strResMainFormat)); return trsMgr.formatResponse(strMsgFormat, strResMainFormat, "0000000", trsMgr.getValue4Key(strGetICOMSMsgTillDot, "TI:")); } // get incoming message format - xxxxxIyyyCUI/xxxxxIyyyCCI/xxxxxIyyyEQI strResMainFormat = trsMgr.getFullInputFormatValue(strGetICOMSMsgTillDot); logger.Info(string.Format("ICOMS Full request Format... {0}", strResMainFormat)); // form outgoing message format - xxxxxVyyyCUI/xxxxxVyyyCCI/xxxxxVyyyEQI strResMainFormat = trsMgr.ReplaceAtIndex(strResMainFormat.IndexOf("I"), 'V', strResMainFormat); logger.Info(string.Format("ICOMS Full response Format... {0}", strResMainFormat)); switch (strMsgFormat) { case "CUI": retMsg2ICOM = processCUIMessage(strGetICOMSMsgTillDot, templistenerMembers); break; case "CCI": retMsg2ICOM = processCCIMessage(strGetICOMSMsgTillDot, templistenerMembers); break; case "EQI": retMsg2ICOM = processEQIMessage(strGetICOMSMsgTillDot, templistenerMembers); break; default: logger.Warn(string.Format("Invalid message format received from ICOMS - {0}. Valid formats CUI/CCI/EQI", strMsgFormat)); retMsg2ICOM = trsMgr.formatResponse("XXX", strResMainFormat, "0000902", trsMgr.getValue4Key(strGetICOMSMsgTillDot, "TI:")); break; } // Format full outgoing response to ICOMS logger.Info("ServiceRunTimeManager::processICOMSMessages() formatting the response "); return trsMgr.formatResponse(strMsgFormat, strResMainFormat, retMsg2ICOM, trsMgr.getValue4Key(strGetICOMSMsgTillDot, "TI:")); } catch (Exception ex) { logger.Error(string.Format("processICOMSMessages(): Exception: {0}", ex.Message)); logger.Error("ServiceRunTimeManager::processICOMSMessages() returning error"); return trsMgr.formatResponse("XXX", strResMainFormat, "0000901", "xxxxxx"); } }