/// <summary>
        /// Validate length of required tokens that was present in the received ICOMS Message
        /// </summary>
        /// <param name="objdic"></param>
        /// <param name="str4LookUp"></param>
        /// <returns></returns>
        public string checkRequiredLengthOfTokens(Dictionary<string, string> objdic, ServiceListenerMembers templistenerMembers)
        {
            logger.Info("ServiceBusinessRulesManager::checkRequiredLengthOfTokens() called");

            string strErrCode = string.Empty;
            string strSiteTokenName = templistenerMembers.siteIdTokenName;

            logger.Info(string.Format("ServiceBusinessRulesManager::checkRequiredLengthOfTokens :: siteId TokenName is {0}", strSiteTokenName));

            foreach (KeyValuePair<string, string> pair in objdic)
            {
                using(ServiceTranslationManager trMgr=new ServiceTranslationManager())
                {
                    // Get relavent error code if any mismatch in token length
                    logger.Info(string.Format("ServiceBusinessRulesManager::checkRequiredLengthOfTokens :: Checking length for token \"{0}\" ", pair.ToString()));
                    if (pair.Key.Equals(strSiteTokenName))continue;
                    strErrCode = trMgr.getErrorCode4lengthOfTokens(pair);
                    if (strErrCode != string.Empty)
                    {
                        logger.Info("ServiceBusinessRulesManager::checkRequiredLengthOfTokens() failed");
                        return strErrCode;
                    }
                }

            }
            logger.Info("ServiceBusinessRulesManager::checkRequiredLengthOfTokens() success");
            return string.Empty;
        }
        public void Test_getDataFor4cInterface()
        {
            ServiceTranslationManager transMngr = new ServiceTranslationManager();
            ServiceListenerMembers testListenMember = new ServiceListenerMembers();
            testListenMember.siteIdTokenName = "SI:";
            String InputData = "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";

            Assert.IsInstanceOf(typeof(Dictionary<String, String>), transMngr.getDataFor4cInterface(InputData, ServiceConstantsManager.CONST_CUI, testListenMember), "Invalid data returned");
            Dictionary<String, String> expData = transMngr.getDataFor4cInterface(InputData, ServiceConstantsManager.CONST_CUI, testListenMember);
            Assert.AreEqual(expData.Count, ServiceConstantsManager.CONST_CUI.Length, "Data count is not valid");
        }
        public void Test_formatResponse()
        {
            ServiceTranslationManager transMngr = new ServiceTranslationManager();
            string strFmtTxt = "CUI";
            string strResFmt = "00000V000CUI";
            string strResCode = "100";
            string strTIValue = "000000000000000000";

            string expData = transMngr.formatResponse(strFmtTxt, strResFmt, strResCode, strTIValue);
            string testData = "00043V000CUI,100,TI:000000000000000000.";
            Assert.AreEqual(testData, expData,"Invalid response returned");
        }
        public void Test_getErrorCode4lengthOfTokens()
        {
            ServiceTranslationManager transMngr = new ServiceTranslationManager();

            Assert.AreEqual("0000200", transMngr.getErrorCode4lengthOfTokens(new KeyValuePair<String, String>("TI:", "0000000000000000000")), "Invalid Error code returned.");
            Assert.AreEqual("0000201", transMngr.getErrorCode4lengthOfTokens(new KeyValuePair<String, String>("AN:", "0102030400")), "Invalid Error code returned.");
            Assert.AreEqual("0000202", transMngr.getErrorCode4lengthOfTokens(new KeyValuePair<String, String>("SI:", "0130")), "Invalid Error code returned.");
            Assert.AreEqual("0000214", transMngr.getErrorCode4lengthOfTokens(new KeyValuePair<String, String>("AS:", "A0")), "Invalid Error code returned.");
            Assert.AreEqual("0000216", transMngr.getErrorCode4lengthOfTokens(new KeyValuePair<String, String>("CL:", "0000009950")), "Invalid Error code returned.");
            Assert.AreEqual("0000217", transMngr.getErrorCode4lengthOfTokens(new KeyValuePair<String, String>("ES:", "A0")), "Invalid Error code returned.");
            Assert.AreEqual("0000219", transMngr.getErrorCode4lengthOfTokens(new KeyValuePair<String, String>("EA:", "000029866859300000000000000000000")), "Invalid Error code returned.");
            Assert.AreEqual("0000221", transMngr.getErrorCode4lengthOfTokens(new KeyValuePair<String, String>("AC:", "A0")), "Invalid Error code returned.");
            Assert.AreEqual("0000257", transMngr.getErrorCode4lengthOfTokens(new KeyValuePair<String, String>("SV:", "000123")), "Invalid Error code returned.");
        }
        public void Test_findICOMInputFormat()
        {
            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.findICOMInputFormat(testData);
            Assert.AreEqual( "CUI", expData,"Wrong Input Format");

            testData = "I000CCI,TI:000000000000000000,AN:010203040,SI:013,CA:AB,CL:000000995,CP:0000000.00039V000CCI,0000000,TI:000000000000000000.select CreditLimit from Subscriber where SmsTag='013010203040'995";
            expData = transMngr.findICOMInputFormat(testData);
            Assert.AreEqual("CCI", expData, "Wrong Input Format");

            testData = "I000EQI,TI:000000000000000000,AN:010203040,SI:013,ES:A,EA:00002986685930000000000000000000,S#:ABC45678901234567890123456789012,PA:ABCDEFGH,SV:0001234/0001236/0001237,AC:A.00039V000EQI,0000257,TI:000000000000000000.select * from Settop where MacAddr='000011cd5231'<empty>";
            expData = transMngr.findICOMInputFormat(testData);
            Assert.AreEqual("EQI", expData, "Wrong Input Format");

            testData = "I000DER,TI:000000000000000000,AN:010203040,SI:013,ES:A";
            expData = transMngr.findICOMInputFormat(testData);
            Assert.AreEqual("INVALID", expData, "Problem in resolving the input format");
        }
        public void Test_getErrorCode4MissingTokens()
        {
            ServiceTranslationManager transMngr = new ServiceTranslationManager();

            Assert.AreEqual("0000100", transMngr.getErrorCode4MissingTokens("TI:"), "Invalid Error code returned.");
            Assert.AreEqual("0000101", transMngr.getErrorCode4MissingTokens("AN:"), "Invalid Error code returned.");
            Assert.AreEqual("0000102", transMngr.getErrorCode4MissingTokens("SI:"), "Invalid Error code returned.");
            Assert.AreEqual("0000114", transMngr.getErrorCode4MissingTokens("AS:"), "Invalid Error code returned.");
            Assert.AreEqual("0000116", transMngr.getErrorCode4MissingTokens("CL:"), "Invalid Error code returned.");
            Assert.AreEqual("0000117", transMngr.getErrorCode4MissingTokens("ES:"), "Invalid Error code returned.");
            Assert.AreEqual("0000119", transMngr.getErrorCode4MissingTokens("EA:"), "Invalid Error code returned.");
            Assert.AreEqual("0000121", transMngr.getErrorCode4MissingTokens("AC:"), "Invalid Error code returned.");
        }
 public void Test_ReplaceAtIndex()
 {
     ServiceTranslationManager transMngr = new ServiceTranslationManager();
     String testData = "testEdata";
     String expData = "testAdata";
     Assert.AreEqual(expData, transMngr.ReplaceAtIndex(4,'A', testData),"Invalid character replaced");
 }
        public void Test_getValue4Key()
        {
            ServiceTranslationManager transMngr = new ServiceTranslationManager();
            String InputData = "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 = "010203040";

            Assert.AreEqual(expdata, transMngr.getValue4Key(InputData, "AN"), "Unable to get correct value for key provided");
        }
        public void Test_GetLine()
        {
            ServiceTranslationManager transMngr = new ServiceTranslationManager();
            Dictionary<String, String> testData = new Dictionary<string, string>();
            testData.Add("AN:", "010203040");
            testData.Add("SI:", "013");

            String expData = "AN:010203040,SI:013";
            Assert.AreEqual(expData, transMngr.GetLine(testData),"Invalid data returned");
        }
        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");
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Process ICOMS CUI messages. Messages will be translated in required format to invoke CRM 4c Rest Interface.
        /// </summary>
        /// <param name="strICOMS_CUI_Msg"></param>
        /// <param name="templistenerMembers"></param>
        /// <returns></returns>
        public string processCUIMessage(string strICOMS_CUI_Msg, ServiceListenerMembers templistenerMembers)
        {
            Dictionary<string, string> dictObj4c = new Dictionary<string, string>();
             SyncRequest objSyncReq;
             ServiceTranslationManager trsMgr;
             ServiceBusinessRulesManager busMgr;
             string retMsg2ICOM = "0000901";
             string strResMainFormat=string.Empty;
             string strErrCode = string.Empty;
             trsMgr = new ServiceTranslationManager();
             string[] arrConfigSiteIdName=new string[2];

             try
             {

               logger.Info("ServiceRunTimeManager::processCUIMessage() called");

               busMgr = new ServiceBusinessRulesManager();

               // Create dictionary object with all required tokens(key-value) for CUI
               dictObj4c = trsMgr.getDataFor4cInterface(strICOMS_CUI_Msg, ServiceConstantsManager.CONST_CUI, templistenerMembers);

               logger.Info(string.Format("Required tokens are extracted from CUI message...  {0}", trsMgr.GetLine(dictObj4c)));

               // Validation for missing tokens
               strErrCode = busMgr.checkRequiredTokensPresent(dictObj4c, ServiceConstantsManager.CONST_CUI);
               if (strErrCode != string.Empty)
               {
               logger.Error(string.Format("Please verify all required tokens are present in the CUI message. Required Tokens... \"{0}\"", string.Join(",", ServiceConstantsManager.CONST_CUI)));
               return strErrCode;
               }

               // Validation for token length
               strErrCode = busMgr.checkRequiredLengthOfTokens(dictObj4c,templistenerMembers);
               if (strErrCode != string.Empty)
               {
               logger.Error(string.Format("Length is not matching for one of tokens present in the CUI message(): {0}", string.Join(",", ServiceConstantsManager.CONST_CUI)));
               return strErrCode;
               }

               // update Customerid(AN=AN+SI) based on flag value in config value
               dictObj4c = busMgr.AddSiteId2CustId(dictObj4c, templistenerMembers);

               objSyncReq = new SyncRequest();
               objSyncReq.CustomerId = dictObj4c["AN:"];
               objSyncReq.CustomerStatus = dictObj4c["AS:"];
               objSyncReq.ICOMSMsgFormat = "CUI";

               CustomerInformationRequest crmreq = new CustomerInformationRequest(objSyncReq, objSyncReq);
               // Perform Add customer
               retMsg2ICOM = crmreq.AddCustomer();

               // Get success/failure error code to send to ICOMS
               retMsg2ICOM = transalteResCode2ICOM4m4C(retMsg2ICOM, "AddCustomer");

               logger.Info(string.Format("ServiceRunTimeManager::processCUIMessage() returning value {0}", retMsg2ICOM));
               return retMsg2ICOM;
             }
             catch (Exception ex)
             {
             logger.Error(string.Format("processCUIMessage(): Exception: {0}", ex.Message));
             logger.Error("ServiceRunTimeManager::processCUIMessage() returning error");
             return "0000901";
             }
        }
Ejemplo n.º 12
0
        /// <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");
               }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Process ICOMS EQI messages. Messages will be translated in required format to invoke CRM 4c Rest Interface.
        /// </summary>
        /// <param name="strICOMS_EQI_Msg"></param>
        /// <param name="templistenerMembers"></param>
        /// <returns></returns>
        public string processEQIMessage(string strICOMS_EQI_Msg, ServiceListenerMembers templistenerMembers)
        {
            Dictionary<string, string> dictObj4c = new Dictionary<string, string>();
             SyncRequest objSyncReq;
             EquipmentSyncRequest objCusEqi;
             ServiceTranslationManager trsMgr;
             ServiceBusinessRulesManager busMgr;
             string retMsg2ICOM = "0000901";
             string strResMainFormat = string.Empty;
             string strErrCode = string.Empty;
             trsMgr = new ServiceTranslationManager();

             try
             {
             logger.Info("ServiceRunTimeManager::processEQIMessage() called");
             busMgr = new ServiceBusinessRulesManager();

             // Create dictionary object with all required tokens(key-value) for EQI
             dictObj4c = trsMgr.getDataFor4cInterface(strICOMS_EQI_Msg, ServiceConstantsManager.CONST_EQI, templistenerMembers);
             logger.Info(string.Format("Required tokens are extracted from EQI message...  {0}", trsMgr.GetLine(dictObj4c)));

             // Validation for missing tokens
             strErrCode = busMgr.checkRequiredTokensPresent(dictObj4c, ServiceConstantsManager.CONST_EQI);
             if (strErrCode != string.Empty)
             {
                 logger.Error(string.Format("Please verify all required tokens are present in the EQI message. Required Tokens... \"{0}\"", string.Join(",", ServiceConstantsManager.CONST_EQI)));
                 return strErrCode;
             }

             // Validation for token length
             strErrCode = busMgr.checkRequiredLengthOfTokens(dictObj4c, templistenerMembers);
             if (strErrCode != string.Empty)
             {
                 logger.Error(string.Format("Length is not matching for one of tokens present in the EQI message(): {0}", string.Join(",", ServiceConstantsManager.CONST_EQI)));
                 return strErrCode;
             }

             // update Customerid(AN=AN+SI) based on flag value in config value
             dictObj4c = busMgr.AddSiteId2CustId(dictObj4c, templistenerMembers);

             // Get Native format device id from ICOMS "EA" token based config value of "DeviceIdFormat" & "NativeFormat4cFlag"
             dictObj4c = busMgr.getNativeFormat4cAddress(dictObj4c, templistenerMembers);

             objCusEqi = new EquipmentSyncRequest();
             objCusEqi.CustomerId = dictObj4c["AN:"];
             objCusEqi.macAddress = dictObj4c["EA:"];
             // Create new list for product Ids
             objCusEqi.offeringId = busMgr.getProductIdList(dictObj4c);
             objSyncReq = new SyncRequest();
             objSyncReq.CustomerId = dictObj4c["AN:"];
             objSyncReq.CustomerStatus = string.Empty;
             objSyncReq.ICOMSMsgFormat = "EQI";

             CustomerEquipmentRequest objCusEQIReq = new CustomerEquipmentRequest(objCusEqi, objSyncReq);

             switch (dictObj4c["AC:"])
             {
                 // Add EQI
                 case "A":
                     logger.Info("ADD EQI action called");
                     retMsg2ICOM = objCusEQIReq.AddEQI();
                     // Get success/failure error code to send to ICOMS
                     retMsg2ICOM = transalteResCode2ICOM4m4C(retMsg2ICOM, "AddEQI");
                     break;
                 // Update EQI
                 case "U":
                     logger.Info("Update EQI action called");
                     retMsg2ICOM = objCusEQIReq.UpdateEQI();
                     // Get success/failure error code to send to ICOMS
                     retMsg2ICOM = transalteResCode2ICOM4m4C(retMsg2ICOM, "UpdateEQI");
                     break;
                 // Delete EQI
                 case "R":
                     logger.Info("Delete EQI action called");
                     retMsg2ICOM = objCusEQIReq.DeleteEQI();
                     // Get success/failure error code to send to ICOMS
                     retMsg2ICOM = transalteResCode2ICOM4m4C(retMsg2ICOM, "DeleteEQI");
                     break;
                 default:
                     logger.Warn(string.Format("Invalid token value received from EQI message for AC operation : {0}", dictObj4c["AC:"]));
                     break;
             }
             logger.Info(string.Format("ServiceRunTimeManager::processEQIMessage() returning value {0}", retMsg2ICOM));
             return retMsg2ICOM;
             }
             catch (Exception ex)
             {
             logger.Error(string.Format("processEQIMessage(): Exception: {0}", ex.Message));
             logger.Error("ServiceRunTimeManager::processEQIMessage() returning error");
             return retMsg2ICOM;
             }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Validate required tokens are present in the received ICOMS Message
        /// </summary>
        /// <param name="objdic"></param>
        /// <param name="str4LookUp"></param>
        /// <returns></returns>
        public string checkRequiredTokensPresent(Dictionary<string, string> objdic, string[] str4LookUp)
        {
            logger.Info("ServiceBusinessRulesManager::checkRequiredTokensPresent() called");
            string strErrCode = string.Empty;
            foreach (string str in str4LookUp)
            {
                // Check to verify required tokens are available inthe ICOMS Message
                logger.Info(string.Format("ServiceBusinessRulesManager::checkRequiredTokensPresent :: Checking for token \"{0}\" is missing or not ", str));

                // skip the validation for optional tokens
                if (str == "SV:") continue;

                if (!objdic.ContainsKey(str))
                {
                    using (ServiceTranslationManager trMgr = new ServiceTranslationManager())
                    {
                        // If any of token is missing return error code
                        strErrCode = trMgr.getErrorCode4MissingTokens(str);
                        logger.Info("ServiceBusinessRulesManager::checkRequiredTokensPresent() failed");
                        return strErrCode;
                    }
                }
            }
            logger.Info("ServiceBusinessRulesManager::checkRequiredTokensPresent() success");
            return string.Empty;
        }