public void Test_AddSiteId2CustId()
        {
            ServiceBusinessRulesManager bm = new ServiceBusinessRulesManager();
            ServiceListenerMembers listMem = new ServiceListenerMembers();
            Dictionary<String, String> testData = new Dictionary<string, string>();
            Dictionary<String, String> expData = bm.AddSiteId2CustId(testData, listMem);

            Assert.IsInstanceOf(typeof(Dictionary<String, String>), expData, "Method does not return correct Object Type");
        }
        public void Test_AddSiteId2CustId_FalseValue()
        {
            ServiceBusinessRulesManager bm = new ServiceBusinessRulesManager();
            ServiceListenerMembers listMem = new ServiceListenerMembers();
            listMem.siteid = "siteid1";
            listMem.listenerAddress = "10.203.232.19";

            listMem.CustomerIdFlag = "false";

            listMem.listenerPort = "12000";

            Dictionary<String, String> testData = new Dictionary<string, string>();
            testData.Add("AN:", "010203040");
            testData.Add("AS:", "A");
            testData.Add("SI:", "013");
            testData.Add("TI:", "000000000000000000");

            Dictionary<String, String> expData = bm.AddSiteId2CustId(testData, listMem);

            Assert.IsFalse(expData.ContainsValue("010203040013"), "Site ID should not be added to Customer ID");
        }
 public void Test_checkRequiredTokensPresent()
 {
     ServiceBusinessRulesManager bm = new ServiceBusinessRulesManager();
     Dictionary<String, String> testData = new Dictionary<string, string>();
     testData.Add("AN:", "010203040");
     testData.Add("CL:", "000000995");
     testData.Add("SI:", "013");
     testData.Add("TI:", "000000000000000000");
     String expRes = bm.checkRequiredTokensPresent(testData,ServiceConstantsManager.CONST_CCI);
     Assert.AreEqual("",expRes,"Unable to search Token");
 }
Пример #4
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";
             }
        }
Пример #5
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;
             }
        }