public INotifyObject[] Compose(AlarmObject alarmObject) { // LogBook.Write("CDYNEIvrNotificationComposer Compose() Method"); List <INotifyObject> notifyList = new List <INotifyObject>(); _alarmObject = alarmObject; /*Get GenStore Information*/ _genStore = GenStoreInfo.GetInstance(); if (alarmObject.IsMissCommNotification) { _logContent = "Missed Communication: " + alarmObject.UTID.ToStr() + " SensorAlarmID: " + alarmObject.SensorAlarmID.ToStr(); } else { _logContent = "SensorID: " + alarmObject.UTID.ToStr() + " SensorAlarmID: " + alarmObject.SensorAlarmID.ToStr(); } /*Write Log: * Started Email Notification * Reached Email Notification Composer*/ LogBook.Write("*** Started Composing VOICE Notification for " + _logContent + "***"); /* Inserting the IVR Notification to database tables TTNotifications and TTIVRNotifications.*/ //if (_alarmObject.AlarmID > 0) RecordIVRNotification(_alarmObject); return(null); }
private void IvrNotification() { Thread.Sleep(5000); //timerIvrNotification.Stop(); while (true) { bool CDYNE_ACCOUNT = GenStoreInfo.GetInstance().CDYNE_ACCOUNT == "" ? false : true; target.ProcessIVRNotification(); //target.DialNumber(); } }
public string[] GetNotifyTypes() { List <string> notifyTypes = new List <string>(); GenStoreInfo genStoreInfo = null; /*Get GenStore Information*/ genStoreInfo = GenStoreInfo.GetInstance(); /* 10/22/15 JH * below 3 lines of code are junk - this will never return NULL */ NotificationProfile notificationProfile = GetActiveNotificationProfile(genStoreInfo.StoreID); /*Check for IsAlertEnabled flag.If the flag is not set return null to stop all notifications*/ if (notificationProfile.IsAlertEnabled) { return(null); } /*get all notification type from configuration file.*/ List <NotificationTypes> notificationTypelist = new NotificationTypes().GetNotificationTypes(); IVRUserID = notificationProfile.IVR_UserID; HasDynamicTypes = false; /* Check for the alarm cleared or Check for the sensor comes to the normal range or the notification type is resumed type * then load only dynamic notification types */ if ((_isProcessCompleted && NotificationSentCount > 0) || _isResumedNotification) { /*Stop notifications for email,popup,script,pager.... and check whether MessageBoard and Relay Switch are active or not */ foreach (NotificationTypes notificationType in notificationTypelist) { if ((notificationProfile.NotifyType & notificationType.Value).ToBoolean() && notificationType.IsDynamicType) { HasDynamicTypes = true; notifyTypes.Add(notificationType.Name); if (notificationType.Name == "MessageBoard") { HasPreviousMessageBoard = true; } if (notificationType.Name == "Switch") { HasPreviousSwitch = true; } } } } else { /* Otherwise load all configured notification types*/ foreach (NotificationTypes notificationType in notificationTypelist) { if ((notificationProfile.NotifyType & notificationType.Value).ToBoolean()) { /*if this is to clear dynamic notification then do not add other types to the notify types*/ if (_isDynamicNotificationCleared == true && _isDynamicNotificationRemoved == false) { if (notificationType.IsDynamicType) { notifyTypes.Add(notificationType.Name); if (notificationType.Name == "MessageBoard") { HasPreviousMessageBoard = true; } if (notificationType.Name == "Switch") { HasPreviousSwitch = true; } } continue; } /* checking whether the notification type is dynamic*/ if (notificationType.IsDynamicType) { HasDynamicTypes = true; if (notificationType.Name == "MessageBoard") { HasPreviousMessageBoard = true; } if (notificationType.Name == "Switch") { HasPreviousSwitch = true; } } /* don't add dynamic types if the user already cleared dynamic in previous escalation*/ if (_isDynamicNotificationRemoved && notificationType.IsDynamicType) { continue; } notifyTypes.Add(notificationType.Name); } } } return(notifyTypes.ToArray()); }
/// <summary> /// Get Notification settings for SNPP /// </summary> /// <param name="alarmObject"></param> /// <param name="notifyPagerAddress"></param> /// <returns></returns> private NotifyObject GetNotifySNPPObject(Interface.Alarm.AlarmObject alarmObject, NotifyPagerAddress notifyPagerAddress) { string snppServer = "", defaultPagerSubject = "", defaultPagerBody = "", defaultSubject = "", defaultBody = ""; string subject = "", body = "", toAddress = ""; int snppPort = 0; int pagerDelay = 0; string pagerMessage = string.Empty; /*Create Notification Style object*/ NotificationStyle notificationStyle = new NotificationStyle(); /*Create notification object */ NotifyObject notifyObject = new NotifyObject(); /*Set Notification Type*/ notifyObject.NotificationType = "Pager"; /*Create hashtable for notification settings*/ Hashtable notificationSettings = new Hashtable(); /*Set Default pager subject*/ defaultPagerSubject = notificationStyle.GetFormatString(alarmObject, 1, "EmailSubjectPager"); /*Set default pager body*/ defaultPagerBody = notificationStyle.GetFormatString(alarmObject, 1, "EmailBodyPager"); /*Set default subject*/ defaultSubject = notificationStyle.GetFormatString(alarmObject, 1, "EmailSubject"); /*Set default body*/ defaultBody = notificationStyle.GetFormatString(alarmObject, 1, "EmailBody"); /*If default pager subject is empty set default subject as default pager subject*/ defaultPagerSubject = (defaultPagerSubject == string.Empty) ? defaultSubject : defaultPagerSubject; /*If default pager body is empty set default body as default pager body*/ defaultPagerBody = (defaultPagerBody == string.Empty) ? defaultBody : defaultPagerBody; /*Set Email Body and Subject format*/ subject = defaultPagerSubject; body = defaultPagerBody; subject = notificationStyle.SubstituteFormatString(subject, alarmObject); body = notificationStyle.SubstituteFormatString(body, alarmObject); /*Pager Body as notification data*/ /*If pager body is empty assign the default pager body from alarm object*/ /*Check this logic in old application*/ /*In case of missed communication assign the custom body and subject*/ if (alarmObject.IsMissCommNotification || body == string.Empty) { body = alarmObject.PagerMessage; } notificationSettings.Add("DeliveryMethod", notifyPagerAddress.DeliveryMethod); /*Get SNPP settings from GenStores*/ GenStoreInfo genStoreInfo = null; /*Get GenStore Information*/ genStoreInfo = GenStoreInfo.GetInstance(); snppServer = genStoreInfo.SNPPServer; snppPort = genStoreInfo.SNPPPort; /*Set PhoneNumber to Pager destination field*/ toAddress = notifyPagerAddress.PhoneNumber; /*Pager Subject*/ notificationSettings.Add("PagerSubject", subject); notificationSettings.Add("Name", notifyPagerAddress.PagerName); /*Pager Destination Address*/ notificationSettings.Add("ToAddress", toAddress); /* if the delivery type is modem*/ if (notifyPagerAddress.DeliveryMethod != 1) { pagerDelay = notifyPagerAddress.PagerDelay; if (alarmObject.PagerMessage.Trim() != string.Empty) { pagerMessage = alarmObject.PagerMessage; } else { pagerMessage = notifyPagerAddress.PagerMessage; } pagerMessage = notificationStyle.SubstituteFormatString(pagerMessage, alarmObject); notificationSettings.Add("PagerDelay", pagerDelay); notificationSettings.Add("PagerMessage", pagerMessage); notificationSettings.Add("AttemptCount", "0"); notificationSettings.Add("LastSentTime", DateTime.Now); } notificationSettings.Add("PagerComPort", genStoreInfo.PagerComPort); notificationSettings.Add("COMportInitString", genStoreInfo.ComPortInitStr); LogBook.Debug("SNPP Server: " + snppServer); LogBook.Debug("SNPP Port: " + snppPort); notificationSettings.Add("NotificationID", alarmObject.NotificationID); if (notifyPagerAddress.DeliveryMethod == 1) { if (snppServer != string.Empty) { /*Set Default SNPP port if not assigned*/ snppPort = (snppPort < 1 || snppPort > 32767) ? 444 : snppPort; /*If pager destination address is empty record notification as fail*/ if (toAddress != string.Empty) { /*SNPP Server or Host*/ notificationSettings.Add("SNPPServer", genStoreInfo.SNPPServer); /*SNPP Port Number*/ notificationSettings.Add("SNPPPort", snppPort); } else { notificationStyle.RecordNotification(ErrorMessages.PagerComposer_SNPPToAddressNotSupplied, alarmObject.NotificationID, 0, NotifyStatus.FAIL, NotifyTypes.PAGER); /*Exit and return empty notification object*/ return(null); } } else { /*Record notification if SNPP settings are not supplied properly*/ notificationStyle.RecordNotification(ErrorMessages.PagerComposer_SNPPParmsNotSupplied, alarmObject.NotificationID, 0, NotifyStatus.FAIL, NotifyTypes.PAGER); /*Exit and return empty notification object*/ return(null); } } /*Set notification setting to notification object*/ notifyObject.NotifierSettings = notificationSettings; /*Pager body*/ notifyObject.NotificationData = body; return(notifyObject); }
public INotifyObject[] Compose(AlarmObject alarmObject) { GenStoreInfo genStoreInfo = null; NotifyMobileList notifyMobileList = null; List <INotifyObject> notifyList = new List <INotifyObject>(); NotificationStyle notificationStyle = new NotificationStyle(); LogBook.Write("Executing Compose method"); /*Get GenStore Information*/ genStoreInfo = GenStoreInfo.GetInstance(); try { //If there's no record in the database, Execute method will return null if (genStoreInfo != null) { /*Record notification if SMTP settings are not supplied properly*/ //if (genStoreInfo.SmtpServer.ToStr() != string.Empty && genStoreInfo.SmtpSendMethod != 0) //if ((genStoreInfo.ToPhoneNumber == string.Empty && genStoreInfo.SmtpAuthDomain == string.Empty) && genStoreInfo.SmtpSendMethod == 0) //{ // /*SMTP server not defined*/ // LogBook.Write("Error: No SMTP Server has been defined"); // /*Record notification if SMTP parameters are not supplied properly*/ // notificationStyle.RecordNotification(ErrorMessages.SmsComposer_SMTPParmsNotSupplied, _alarmObject.NotificationID, NotifyStatus.FAIL, NotifyTypes.SMS); //} //else //{ LogBook.Write("Fetching notify Mobiles List"); /*Get all the sms addresses that are configured for notification*/ notifyMobileList = GetNotifyMoibilesList(alarmObject.NotifyProfileID); LogBook.Write("Notify Mobile List Count: " + notifyMobileList.Count.ToString()); if (notifyMobileList.Count != 0) { LogBook.Write("Constructing notify list objects"); /*Construct a notification object for each sms number and add to the notification list*/ notifyList = GetNotificationList(notifyMobileList, alarmObject, genStoreInfo); for (int index = notifyList.Count - 1; index >= 0; index--) { INotifyObject notifyObject = notifyList[index]; SmsHelper.SmsQueue.Add(notifyObject); notifyList.Remove(notifyObject); new NotificationStyle().RecordNotification("Sms queued: " + notifyObject.NotifierSettings["ToPhoneNumber"].ToStr(), notifyObject.NotifierSettings["NotificationID"].ToInt(), 0, NotifyStatus.STATUS, NotifyTypes.SMS); } LogBook.Write("Notify list objects count: " + notifyList.Count); } else { /*Log when we don't have sms address to notify*/ LogBook.Write("Error: Missing entry in NotifySms/Groups"); } //} } else { /*Record notification if genStore parameters are not supplied properly.*/ notificationStyle.RecordNotification(ErrorMessages.SMSComposer_InvalidSettings, alarmObject.NotificationID, 0, NotifyStatus.FAIL, NotifyTypes.SMS); /*Log if genStore information is empty*/ LogBook.Write("Error: Missing GenStores table record"); } } catch (Exception ex) { /*Write exception log*/ LogBook.Write(ex, "CooperAtkins.NotificationClient.NotificationComposer.SmsNotificationComposer"); } /*Send notification list to notification engine*/ return(notifyList.ToArray()); }
/// <summary> /// Gets all active IVR alarms. /// </summary> /// <param name="criteria"></param> /// <returns></returns> protected override IvrAlarmList LoadList(BaseCriteria criteria) { try { Criteria listCriteria = (Criteria)criteria; //Initialize the CSqlDbCommand for execute the stored procedure CSqlDbCommand cmd = new CSqlDbCommand(DBCommands.USP_NS_GET_IVRALARMLIST, System.Data.CommandType.StoredProcedure); cmd.AddWithValue("numAttempts", NumAttempts); //Execute reader CDAO.ExecReader(cmd); /*fill the object and add to list.*/ while (CDAO.DataReader.Read()) { IvrAlarm alarm = new IvrAlarm(); alarm.IVRPhoneNumber = CDAO.DataReader["PhoneNumber"].ToStr(); alarm.AlarmID = CDAO.DataReader["AlarmID"].ToInt(); alarm.IsSuccess = CDAO.DataReader["isSuccess"].ToBoolean(); alarm.NotificationID = CDAO.DataReader["Notification_RecID"].ToInt(); alarm.AttemptCount = CDAO.DataReader["numAttempts"].ToInt16(); alarm.QueueTime = TypeCommonExtensions.IfNull(CDAO.DataReader["QueueTime"], DateTime.UtcNow).ToDateTime(); alarm.LastAttemptTime = TypeCommonExtensions.IfNull(CDAO.DataReader["LastAttemptTime"], DateTime.UtcNow).ToDateTime(); alarm.IvrAlarmID = CDAO.DataReader["RecID"].ToInt(); alarm.UTID = CDAO.DataReader["UTID"].ToStr(); alarm.Probe = CDAO.DataReader["Probe"].ToInt(); alarm.SensorType = CDAO.DataReader["SensorType"].ToStr(); if (CDAO.DataReader["IVR_SensorName"] != DBNull.Value) { alarm.IVR_SensorName = CDAO.DataReader["IVR_SensorName"].ToStr(); } else { alarm.IVR_SensorName = (CDAO.DataReader["PuckName"].ToStr() == string.Empty ? "Sensor" : CDAO.DataReader["PuckName"].ToStr()); } alarm.Value = CDAO.DataReader["AlarmData"].ToDecimal(); alarm.AlarmMaxValue = CDAO.DataReader["CondMaxValue"].ToDecimal(); alarm.AlarmMinValue = CDAO.DataReader["CondMinValue"].ToDecimal(); alarm.CondThresholdMins = CDAO.DataReader["CondThresholdMins"].ToInt(); alarm.AlarmTime = TypeCommonExtensions.IfNull(CDAO.DataReader["AlarmTime"], DateTime.UtcNow).ToDateTime(); alarm.IVRUserID = CDAO.DataReader["UserID"].ToInt(); alarm.PersonName = CDAO.DataReader["FirstName"].ToString() + " " + CDAO.DataReader["LastName"].ToString(); alarm.LanguageID = (CDAO.DataReader["LanguageID"].ToInt() == 0 ? 1 : CDAO.DataReader["LanguageID"].ToInt()); alarm.IsCelsius = CDAO.DataReader["isCelsius"].ToBoolean(); alarm.StoreName = GenStoreInfo.GetInstance().StoreName; alarm.IvrID = CDAO.DataReader["RecID"].ToInt(); alarm.StoreNumber = GenStoreInfo.GetInstance().StorePhoneNumber.ToString(); alarm.AlarmStartTime = TypeCommonExtensions.IfNull(CDAO.DataReader["AlarmStartTime"], DateTime.UtcNow).ToDateTime(); //if (alarm.AlarmID > 0) this.Add(alarm); } } catch { throw; } finally { CDAO.CloseDataReader(); CDAO.Dispose(); } return(this); }
/// <summary> /// Returns true if the current operation succeeded. /// </summary> /// <param name="data"></param> /// <param name="settings"></param> /// <param name="notificationID"></param> /// <returns></returns> /// public static bool Send(string data, Hashtable settings, int notificationID, int ivrID, int alarmID, AlarmObject alarmObject) { bool retValue = false; bool callConnected = false; string response = string.Empty; string succeeded = string.Empty; string error = string.Empty; Int16 dailAttempts = 1; string DigitsPressed = string.Empty; long QueueID = -1; int TryCount = -1; bool CallAnswered = false; bool Answered = false; bool CallComplete = false; string MachineDetection = string.Empty; int Duration = -1; string IVRServiceResponseText = string.Empty; int TTIVRNotifications_RecID = -1; NotifyObject notifyObject = new NotifyObject(); NotifyComResponse notifyResponse = new NotifyComResponse(); NotifyComResponse notifyComResponse = new NotifyComResponse(); notifyObject.NotificationType = "Voice"; notifyObject.NotificationData = data; //voice message to be played notifyObject.NotifierSettings = settings; //hash table of keys and values NotificationEndPointElement element; string vcElement1; string vcElement2; string vcElement3; string vcElement4; /* get end point for voice composer*/ string method = NotificationClient.GetInstance().WhoAmI("Voice", out element); string arguments = null; LogBook.Write("Sending voice alert...."); switch (method.ToLower()) { case "cooperatkins.notificationclient.notifyengine.ivrnotificationcom": System.Diagnostics.Process process = new System.Diagnostics.Process(); if (element == null) { arguments = @"-m ""<notification ack='true'><notificationData><![CDATA[" + data + @"]]></notificationData><notificationType><![CDATA[Voice]]></notificationType><notificationSettings><PhoneNo><![CDATA[" + settings["PhoneNo"].ToStr() + @"]]></PhoneNo></notificationSettings></notification>"" "; } else { arguments = @"-c " + element.EndpointAddress + @" -m ""<notification ack='true'><notificationData><![CDATA[" + data + @"]]></notificationData><notificationType><![CDATA[Voice]]></notificationType><notificationSettings><PhoneNo><![CDATA[" + settings["PhoneNo"].ToStr() + @"]]></PhoneNo></notificationSettings></notification>"" "; } while (!callConnected) { IvrAlarmStatus ivrAlarmStatus = new IvrAlarmStatus(); try { LogBook.Write("Checking whether alarm is cleared or not"); ivrAlarmStatus.AlarmID = alarmID; ivrAlarmStatus.NotificationID = notificationID; ivrAlarmStatus.StoreID = GenStoreInfo.GetInstance().StoreID; ivrAlarmStatus.Execute(); } catch (Exception ex) { LogBook.Write(ex, "CooperAtkins.NotificationClient.NotificationComposer.IvrClientHelper", ErrorSeverity.High); } finally { ivrAlarmStatus.Dispose(); } if (ivrAlarmStatus.IsAlarmClearedOrBackInRange) { break; } /* analog modem use */ process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; //process.StartInfo.RedirectStandardError = true; process.StartInfo.CreateNoWindow = true; process.StartInfo.FileName = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\Utility.exe"; //process.StartInfo.FileName = @"F:\DEV\CooperAtkins\CooperAtkins.NotificationEngine.Utility\bin\Debug\Utility.exe"; process.StartInfo.Arguments = arguments; // process.StartInfo.WorkingDirectory = ; process.Start(); process.WaitForExit(); response = process.StandardOutput.ReadToEnd(); callConnected = true; if (response.ToLower().Contains("device initialization failed") || response.ToLower().Contains("invalid_device_id") || response.ToLower().Contains("dll_not_found") || response.ToLower().Contains("exception from hresult")) { callConnected = false; } /* end analog modem use */ } break; case "cooperatkins.notificationclient.notificationcomposer.cdyneivrnotificationcomposer": long TransactionID = -1; DateTime StartTime; DateTime EndTime; long AlarmID = -1; string CDYNE_ID = GenStoreInfo.GetInstance().CDYNE_ACCOUNT;//NotificationClient.GetInstance().GetCustomVoiceSettings("CDyneID", out vcElement1); string CDYNE_RETRIES = NotificationClient.GetInstance().GetCustomVoiceSettings("CDyneRetries", out vcElement2); string CDYNE_VOICEID = NotificationClient.GetInstance().GetCustomVoiceSettings("CDyneVoiceID", out vcElement3); string CDYNE_VOLUME = NotificationClient.GetInstance().GetCustomVoiceSettings("CDyneVolume", out vcElement4); notifyObject.NotifierSettings["CDYNE_ID"] = CDYNE_ID; notifyObject.NotifierSettings["CDYNE_RETRIES"] = CDYNE_RETRIES; notifyObject.NotifierSettings["CDYNE_VOICEID"] = CDYNE_VOICEID; notifyObject.NotifierSettings["CDYNE_VOLUME"] = CDYNE_VOLUME; NotificationStyle notificationStyle = new NotificationStyle(); TTIvrNotifications tTIvrNotificationsObject = new TTIvrNotifications(); callConnected = false; while (!callConnected) { notifyComResponse.IsInProcess = true; int QueryCall = 0; int UnivError = 0; //if (!alarmObject.IsFailsafeEscalationNotification) //{ //IvrAlarmStatus ivrAlarmStatus = new IvrAlarmStatus(); //try //{ // LogBook.Write("Checking whether alarm is cleared or not"); // ivrAlarmStatus.AlarmID = alarmID; // ivrAlarmStatus.NotificationID = notificationID; // ivrAlarmStatus.StoreID = GenStoreInfo.GetInstance().StoreID; // ivrAlarmStatus.Execute(); //} //catch (Exception ex) //{ // LogBook.Write(ex, "CooperAtkins.NotificationClient.NotificationComposer.CDYNEIvrClientHelper", ErrorSeverity.High); //} //finally //{ // ivrAlarmStatus.Dispose(); //} //12/9/15 comment start //AlarmStatus alarmStatus = new AlarmStatus(); //try //{ // LogBook.Write("IVR Checking whether alarm [" + alarmObject.NotificationID + "] is cleared or not"); // alarmStatus.NotificationID = alarmObject.NotificationID; // alarmStatus.StoreID = GenStoreInfo.GetInstance().StoreID; // alarmStatus.Execute(); //} //catch (Exception ex) //{ // LogBook.Write(ex, "CooperAtkins.NotificationClient.Alarm.AlarmInitializer", ErrorSeverity.High); //} //finally //{ // alarmStatus.Dispose(); //12/9/15 comment end } int threadID = notifyObject.NotifierSettings["ThreadID"].ToInt(); //12/9/15 comment start //if (alarmStatus.IsAlarmClearedOrBackInRange) //{ // Answered = false; // callConnected = false; // notifyComResponse.IsSucceeded = false; // notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " SUSPENDED (Attempt # " + dailAttempts + " of " + (CDYNE_RETRIES.ToInt() + 1) + ")"; // notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\nALARM WAS CLEARED OR BACK IN RANGE"; // LogBook.Write("CALL SUSPENDED To " + notifyObject.NotifierSettings["PhoneNo"] + IVRServiceResponseText + " for NotificationID: " + notificationID + " [CDyneTransID: " + TransactionID + "] ALARM WAS CLEARED OR SENSOR IS BACK IN RANGE"); // notificationStyle.RecordNotification(notifyComResponse.ResponseContent.ToString(), notificationID, TransactionID.ToInt(), NotifyStatus.FAIL, NotifyTypes.VOICE); // UpdateIVRNotification(ivrID, false, false, dailAttempts, TransactionID, threadID); // break; //12/9/15 comment end } int totalCallAttempts = notifyObject.NotifierSettings["Attempts"].ToInt(); if ((totalCallAttempts + dailAttempts) > (CDYNE_RETRIES.ToInt() + 1)) //also if a notficicationId is in an alert progress state from another thread, //fall into this code to break out OR if cleared or inprogress check to be sure //we made contatc through our maximum attempts value { notifyComResponse.IsInProcess = false; UpdateIVRNotification(ivrID, false, notifyComResponse.IsInProcess, dailAttempts, TransactionID, threadID); break; } //} UpdateIVRNotification(ivrID, false, true, (totalCallAttempts + dailAttempts), TransactionID, threadID); try{ IVRProcessor maketheIVRCall = new IVRProcessor(); notifyResponse = maketheIVRCall.Invoke(notifyObject); // notifyComResponse = new NotifyComResponse(); TransactionID = notifyResponse.TransactionIDReturned; //query for call result Answered = false; PhoneNotify pn2 = new PhoneNotify(); while (!Answered) { if (QueryCall == 0) //on first call, wait 1 minute for call to complete before getting call results { System.Threading.Thread.Sleep(1 * 60 * 1000); } else { System.Threading.Thread.Sleep(5 * 1000); } NotifyReturn nr2 = pn2.GetQueueIDStatus(TransactionID); MachineDetection = nr2.MachineDetection; DigitsPressed = nr2.DigitsPressed; CallAnswered = nr2.CallAnswered; CallComplete = nr2.CallComplete; IVRServiceResponseText = nr2.ResponseText; Duration = nr2.Duration; StartTime = nr2.StartTime; EndTime = nr2.EndTime; if (CallAnswered == true && DigitsPressed.Contains("*")) { Answered = true; callConnected = true; notifyComResponse.IsSucceeded = true; //notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " Connected (Attempt # " + dailAttempts + " of " + (CDYNE_RETRIES.ToInt() + 1) + ")"; notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " Connected. "; notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\nAcknowledgement received, " + "'" + DigitsPressed + "' pressed."; notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\nCall Complete >"; LogBook.Write("Query Call State Try: " + (QueryCall + 1) + ": Phone Call " + (totalCallAttempts + dailAttempts) + " of " + (CDYNE_RETRIES.ToInt() + 1) + " To " + notifyObject.NotifierSettings["PhoneNo"] + " Answered and Digits: " + DigitsPressed + " were pressed: " + IVRServiceResponseText + " for NotificationID: " + notificationID + " [CDyneTransID: " + TransactionID + "]"); break; } else if (CallAnswered == true && !DigitsPressed.Contains("*") && MachineDetection == "HUMAN" && CallComplete) { Answered = true; notifyComResponse.IsSucceeded = false; //notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " Connected (Attempt # " + dailAttempts + " of " + (CDYNE_RETRIES.ToInt() + 1) + ")"; notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " Connected. "; notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\nNo Acknowledgement received, Digits Pressed: " + DigitsPressed + ">"; LogBook.Write("Query Call State Try: " + (QueryCall + 1) + ": Phone Call " + (totalCallAttempts + dailAttempts) + " of " + (CDYNE_RETRIES.ToInt() + 1) + " To " + notifyObject.NotifierSettings["PhoneNo"] + " Answered but no digits were pressed: " + IVRServiceResponseText + " for NotificationID: " + notificationID + " [CDyneTransID: " + TransactionID + "]"); break; } else if (CallAnswered == true && DigitsPressed == "" && MachineDetection == "HUMAN" && !CallComplete) { notifyComResponse.IsSucceeded = false; //notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " Connected (Attempt # " + dailAttempts + " of " + (CDYNE_RETRIES.ToInt() + 1) + ")"; notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " Connected. "; notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\nNo Acknowledgement received >"; LogBook.Write("Query Call State Try: " + (QueryCall + 1) + ": Phone Call " + (totalCallAttempts + dailAttempts) + " of " + (CDYNE_RETRIES.ToInt() + 1) + " To " + notifyObject.NotifierSettings["PhoneNo"] + " Answered but no digits were pressed: " + IVRServiceResponseText + " for NotificationID: " + notificationID + " [CDyneTransID: " + TransactionID + "]"); QueryCall += 1; } else if (CallAnswered == true && DigitsPressed == "" && MachineDetection == "MACHINE") { Answered = false; notifyComResponse.IsSucceeded = false; //notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] +"["+ notifyObject.NotifierSettings["CallerName"]+"]"+ " Connected (Attempt # " + dailAttempts + " of " + (CDYNE_RETRIES.ToInt() + 1) + ")"; notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " Connected. "; notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\nAnswering Machine Detected >"; LogBook.Write("Query Call State Try: " + (QueryCall + 1) + ": Phone Call " + (totalCallAttempts + dailAttempts) + " of " + (CDYNE_RETRIES.ToInt() + 1) + " To " + notifyObject.NotifierSettings["PhoneNo"] + " Answered by MACHINE: " + IVRServiceResponseText + " for NotificationID: " + notificationID + " [CDyneTransID: " + TransactionID + "]"); break; } else if (IVRServiceResponseText == "In Call/Ringing" || IVRServiceResponseText == "Queued" || IVRServiceResponseText == "Universal Error") { notifyComResponse.IsSucceeded = false; notifyComResponse.IsError = true; //if (notifyComResponse.ResponseContent != null) //{ // if ((!notifyComResponse.ResponseContent.ToString().Contains("Call/Ringing (Attempt # " + dailAttempts)) && // (!notifyComResponse.ResponseContent.ToString().Contains("Queued (Attempt # " + dailAttempts)) && // (!notifyComResponse.ResponseContent.ToString().Contains("Universal Error (Attempt # " + dailAttempts))) //only add line if it has not already been logged for this dial attempt // { // notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "] " + IVRServiceResponseText + " (Attempt # " + dailAttempts + " of " + (CDYNE_RETRIES.ToInt() + 1) + ") >"; // } //} //else //{ // notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "] " + IVRServiceResponseText + " (Attempt # " + dailAttempts + " of " + (CDYNE_RETRIES.ToInt() + 1) + ") >"; //} // notifyComResponse.ResponseContent = ""; LogBook.Write("Query Call State Try: " + (QueryCall + 1) + ": Phone Call " + (totalCallAttempts + dailAttempts) + " of " + (CDYNE_RETRIES.ToInt() + 1) + " To " + notifyObject.NotifierSettings["PhoneNo"] + " Current Status: " + IVRServiceResponseText + " for NotificationID: " + notificationID + " [CDyneTransID: " + TransactionID + "]"); if (IVRServiceResponseText == "Universal Error") { UnivError += 1; //if it continues to return Universl Error allow a way to get out } QueryCall += 1; } else { notifyComResponse.IsSucceeded = false; if (notifyComResponse.ResponseContent != null) { if (!notifyComResponse.ResponseContent.ToString().Contains("ERROR")) //only add line if it has not already been logged { //notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " ERROR: " + IVRServiceResponseText + " (Attempt # " + dailAttempts + " of " + (CDYNE_RETRIES.ToInt() + 1) + ") >"; notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " ERROR: " + IVRServiceResponseText + " >"; } } else { //notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " ERROR: " + IVRServiceResponseText + " (Attempt # " + dailAttempts + " of " + (CDYNE_RETRIES.ToInt() + 1) + ") >"; notifyComResponse.ResponseContent += "\r\n\r\n\r\n\r\n < Phone Call To " + notifyObject.NotifierSettings["PhoneNo"] + "[" + notifyObject.NotifierSettings["CallerName"] + "]" + " ERROR: " + IVRServiceResponseText + " >"; } LogBook.Write("Query Call State Try: " + (QueryCall + 1) + ": Phone Call " + (totalCallAttempts + dailAttempts) + " of " + (CDYNE_RETRIES.ToInt() + 1) + " To " + notifyObject.NotifierSettings["PhoneNo"] + " Current Status: " + IVRServiceResponseText + " for NotificationID: " + notificationID + " [CDyneTransID: " + TransactionID + "]"); QueryCall += 1; } if (QueryCall > 2 || Answered || (UnivError > 10)) { break; } } }catch (Exception ex) { LogBook.Write(ex, "CooperAtkins.NotificationClient.NotificationComposer.CDYNEIvrClientHelper MAkeTheCall", ErrorSeverity.High); } if (!callConnected || !Answered) { //write to TTNotificationLog if (notifyComResponse.ResponseContent != null) { if (notifyComResponse.ResponseContent.ToString() != "") { notificationStyle.RecordNotification(notifyComResponse.ResponseContent.ToString(), notificationID, TransactionID.ToInt(), NotifyStatus.FAIL, NotifyTypes.VOICE); } } notifyComResponse.ResponseContent = ""; //write to TTIVRNotifications UpdateIVRNotification(ivrID, notifyComResponse.IsSucceeded, notifyComResponse.IsInProcess, (totalCallAttempts + dailAttempts), TransactionID, threadID); // System.Threading.Thread.Sleep(30 * 1000); //wait and try that number 1 more time before trying next person dailAttempts += 1; retValue = false; if (((totalCallAttempts + dailAttempts.ToInt())) > CDYNE_RETRIES.ToInt16() + 1) { //try each person X times from config LogBook.Write("Exhausted " + (CDYNE_RETRIES.ToInt()) + " Re-Try Attempts To: " + notifyObject.NotifierSettings["PhoneNo"] + " for NotificationID: " + notificationID + " [CDyneTransID: " + TransactionID + "]"); notifyComResponse.IsInProcess = false; if (UnivError >= 10) //reset call counter, so it will re-attempt to call person has CDyne never truly made a call { //4th param in below function UpdateIVRNotification(ivrID, notifyComResponse.IsSucceeded, notifyComResponse.IsInProcess, 0, TransactionID, threadID); } else { UpdateIVRNotification(ivrID, notifyComResponse.IsSucceeded, notifyComResponse.IsInProcess, (totalCallAttempts + dailAttempts), TransactionID, threadID); } retValue = false; alarmObject.IVRSuccess = false; break; } else { LogBook.Write("Trying Retry Call Attempt " + (totalCallAttempts + dailAttempts) + " of " + (CDYNE_RETRIES.ToInt() + 1) + " Attempts To: " + notifyObject.NotifierSettings["PhoneNo"] + " for NotificationID: " + notificationID); } } else { LogBook.Write("Call Complete. Alert Success during call " + (totalCallAttempts + dailAttempts) + " of " + (CDYNE_RETRIES.ToInt() + 1) + " attempts To: " + notifyObject.NotifierSettings["PhoneNo"] + " for NotificationID: " + notificationID + " [CDyneTransID: " + TransactionID + "]"); notifyComResponse.IsInProcess = false; notificationStyle.RecordNotification(notifyComResponse.ResponseContent.ToString(), notificationID, TransactionID.ToInt(), NotifyStatus.PASS, NotifyTypes.VOICE); notifyComResponse.ResponseContent = ""; UpdateIVRNotification(ivrID, notifyComResponse.IsSucceeded, notifyComResponse.IsInProcess, (totalCallAttempts + dailAttempts), TransactionID, threadID); retValue = true; alarmObject.IVRSuccess = true; } } break; //end call attempts default: break; } if (method.ToLower() == "cooperatkins.notificationserver.notifyengine.ivrnotificationcom") { NotificationStyle notificationStyle = new NotificationStyle(); foreach (string responseLine in response.Split(new string[] { "\n" }, StringSplitOptions.None)) { if (responseLine.ToLower().Contains("succeeded")) { succeeded = responseLine.ToLower().Replace("succeeded :", string.Empty); } else if (responseLine.ToLower().Contains("error")) { error = responseLine.ToLower().Replace("error :", string.Empty); } } LogBook.Write("ResponseContent:" + response + ", IsSucceeded:" + succeeded + ", IsError:" + error); /* record the notification information to the database. */ if (succeeded == "no") { notificationStyle.RecordNotification(response.Remove(0, 60).Replace("\n", "\r\n"), notificationID, 0, NotifyStatus.FAIL, NotifyTypes.VOICE); } else { notificationStyle.RecordNotification(response.Remove(0, 60).Replace("\n", "\r\n"), notificationID, 0, NotifyStatus.PASS, NotifyTypes.VOICE); } retValue = succeeded == "yes"; } return(retValue); }
public INotifyObject[] Compose(AlarmObject alarmObject) { GenStoreInfo genStoreInfo = null; NotifyEmailAddressList notifyEmailAddressList = null; List <INotifyObject> notifyList = new List <INotifyObject>(); NotificationStyle notificationStyle = new NotificationStyle(); /*Get GenStore Information*/ genStoreInfo = GenStoreInfo.GetInstance(); if (alarmObject.IsMissCommNotification) { _logContent = "Missed Communication"; } else { _logContent = "SensorID: " + alarmObject.UTID.ToStr() + " SensorAlarmID: " + alarmObject.SensorAlarmID.ToStr(); } /*Write Log: * Started Email Notification * Reached Email Notification Composer*/ LogBook.Write("*** Started Composing E-Mail Notification for " + _logContent + "***"); try { //If there's no record in the database, Execute method will return null if (genStoreInfo != null) { /*Record notification if SMTP settings are not supplied properly*/ if ((genStoreInfo.SmtpServer.ToStr() == string.Empty && genStoreInfo.SmtpAuthDomain == string.Empty) && genStoreInfo.SmtpSendMethod == 0) { /*SMTP server not defined*/ LogBook.Write(_logContent + " Error: No SMTP Server has been defined."); /*Record notification if SMTP parameters are not supplied properly*/ notificationStyle.RecordNotification(ErrorMessages.EmailComposer_SMTPParmsNotSupplied, alarmObject.NotificationID, 0, NotifyStatus.FAIL, NotifyTypes.EMAIL); } else { /*Get all the email addresses that are configured for notification*/ notifyEmailAddressList = GetNotifyEmailAddressList(alarmObject); if (notifyEmailAddressList.Count != 0) { /*Construct a notification object for each email address and add to the notification list*/ notifyList = GetNotificationList(notifyEmailAddressList, alarmObject, genStoreInfo); LogBook.Write("Email Notification count: " + notifyList.Count.ToString()); } else { /*Log when we don't have Email address to notify*/ LogBook.Write(_logContent + " Error: Missing entry in NotifyEmails/Groups."); } } } else { /*Record notification if genStore parameters are not supplied properly.*/ notificationStyle.RecordNotification(ErrorMessages.EmailComposer_GenStoreInvalid, alarmObject.NotificationID, 0, NotifyStatus.FAIL, NotifyTypes.EMAIL); /*Log if genStore information is empty*/ LogBook.Write(_logContent + " Error: Missing GenStores table record."); } } catch (Exception ex) { /*Write exception log*/ //LogBook.Write(_logContent + " " + ex); LogBook.Write(_logContent + " Error: ", ex, "CooperAtkins.NotificationClient.NotificationComposer.EmailNotificationComposer"); //, "CooperAtkins.NotificationClient.NotificationComposer.EmailNotificationComposer"); } //if (notifyList.Count > 0) /*Write Log * Sending Email notification data to Notification Engine*/ LogBook.Write(_logContent + " Sending notification data to Email Notification Engine."); /*Send notification list to notification engine*/ return(notifyList.ToArray()); }