/// <summary> /// To import the call data into reporting database /// </summary> /// <param name="callId">Call ID from IVR</param> /// <param name="appId">Application ID from IVR</param> /// <param name="callData">IVR Call Data</param> /// <returns></returns> public ValidataionResponse ValidateData(string callId, string sessionId, string appId, string callData, DateTime callDateTime) { ValidataionResponse response = new ValidataionResponse(); string message = string.Empty; try { _log.Info("Inside Method "); if (!HasBasicCallInfo(callData, appId, callId, ref response)) { return(response); } if (!HasAppConfigSetings(callId, appId, ref response)) { return(response); } if (!HasValidCallData(callData, callId, appId, ref response)) { return(response); } if (response.FailureMode == ValidationFailureMode.None) { if (InitailContext._dataConfigSetting.AppConfigSettings[appId].ThreadSleepRequired) { Thread.Sleep(InitailContext.time); _log.InfoFormat("Thread sleep for {0} milliseconds", InitailContext.time); } _log.InfoFormat("Pushing data into queue for callid :{0}", callId); _queueInsert.PutMessageOnMSQ(Convert.ToString(InitailContext._dataConfigSetting.AppConfigSettings[appId].QueueName), callId, callData, appId, ref response); _log.InfoFormat("Enqueued data into queue for callid :{0}", callId); } } catch (Exception ex) { message = string.Format("{0}, Call ID : {1}", ex.Message, callId); response.FailureMode = ValidationFailureMode.ApplicationFailed; response.ErrorCode = (int)ValidationFailureMode.ApplicationFailed; response.ErrorMessage = message; _log.ErrorFormat("ValidateData Error : Failure Code : {0}, Error Code : {1}, Error Desc : {2}", response.FailureMode, response.ErrorCode, response.ErrorMessage); try { delWriteFileIntoRecovery objwriteFile = new delWriteFileIntoRecovery(WriteIntoRecovery); objwriteFile.BeginInvoke(callData, callId, null, null); } catch (Exception exp) { _log.ErrorFormat("Error while writing File :{0}", exp); } } return(response); }
/// <summary> /// To validate the call data received from Msmq Service /// </summary> /// <param name="callData">call data read from Msmq Service</param> /// <returns></returns> public ValidataionResponse Validate(string callData) { ValidataionResponse response = new ValidataionResponse(); string message = string.Empty; string callId = string.Empty; string sessionId = string.Empty; string appId = string.Empty; DateTime callDtTime = System.DateTime.Now; try { _log.Info("Inside Method"); // string regExPattern =string.Empty; //Regex regEx = new Regex(regExPattern, RegexOptions.Multiline); //MatchCollection mc = regEx.Matches(callData); //appId = string.IsNullOrEmpty(ConfigurationManager.AppSettings["ApplicationId"].ToString()) ? "1" : ConfigurationManager.AppSettings["ApplicationId"].ToString(); string regExPattern = @"<APP_ID>(?<APP_ID>.*?)</APP_ID>"; Regex regEx = new Regex(regExPattern, RegexOptions.Multiline); MatchCollection mc = regEx.Matches(callData); if (mc.Count > 0) { appId = mc[0].Groups["APP_ID"].Value.Trim(); } regExPattern = @"<CALLID>(?<CallID>.*?)</CALLID>"; regEx = new Regex(regExPattern, RegexOptions.Multiline); mc = regEx.Matches(callData); if (mc.Count > 0) { callId = mc[0].Groups["CallID"].Value.Trim(); } regExPattern = @"<SESSION_ID>(?<SESSION_ID>.*?)</SESSION_ID>"; regEx = new Regex(regExPattern, RegexOptions.Multiline); mc = regEx.Matches(callData); if (mc.Count > 0) { sessionId = mc[0].Groups["SESSION_ID"].Value.Trim(); } response = ValidateData(callId, sessionId, appId, callData, callDtTime); } catch (Exception ex) { message = string.Format("{0}, Call ID : {1}", ex.Message, callId); response.ErrorCode = (int)ValidationFailureMode.ApplicationFailed; response.FailureMode = ValidationFailureMode.ApplicationFailed; response.ErrorMessage = message; _log.ErrorFormat("Validate Error : Failure Code : {0}, Error Code : {1}, Error Desc : {2}", response.FailureMode, response.ErrorCode, response.ErrorMessage); delWriteFileIntoRecovery objwriteFile = new delWriteFileIntoRecovery(WriteIntoRecovery); objwriteFile.BeginInvoke(callData, callId, null, null); } return(response); }