/// <summary>
        /// Dials the number.
        /// </summary>
        public long DialNumber(INotifyObject _notifyObject)
        {
            long   QueueID          = -1;
            string sensorInfo       = _notifyObject.NotificationData.ToString();
            string phoneNumber      = _notifyObject.NotifierSettings["PhoneNo"].ToString();
            string storePhoneNumber = _notifyObject.NotifierSettings["StorePhoneNo"].ToString();
            string voiceMode        = _notifyObject.NotifierSettings["CDYNE_VOICEID"].ToString();
            string voiceVolume      = _notifyObject.NotifierSettings["CDYNE_VOLUME"].ToString();
            string voiceLicense     = _notifyObject.NotifierSettings["CDYNE_ID"].ToString();
            string voiceRetries     = _notifyObject.NotifierSettings["CDYNE_RETRIES"].ToString();

            LogBook.Write("PhoneNo.: " + _notifyObject.NotifierSettings["PhoneNumber"] + ", Voice Prompt: " + sensorInfo);



            PhoneNotify           notify = new PhoneNotify();
            AdvancedNotifyRequest anr    = new AdvancedNotifyRequest();
            PhoneNotify           pn     = new PhoneNotify();

            anr.CallerIDName         = "TempTrak";
            anr.CallerIDNumber       = storePhoneNumber; //TT registration #, if blank shows as private
            anr.PhoneNumberToDial    = phoneNumber;
            anr.TextToSay            = /*"~\\ActOnFeature(false)~*/ "~\\SetVar(Attempt|1)~ ~\\ActOnDigitPress(false)~   ~\\Label(Menu)~ ~\\AssignDTMF(*|Ack)~ ~\\ActOnDigitPress(true)~ ~\\Beep()~ ~\\PlaySilence(0.1)~" + sensorInfo + " ~\\WaitForDTMF(1)~" + "Press the star key to acknowledge receipt of this alert.  Press 1 to repeat this message. ~\\PlaySilence(0.1)~   ~\\WaitForDTMF(10)~ ~\\IncreaseVariable(Attempt|1)~ ~\\GotoIf(Attempt|1|Menu)~ ~\\GotoIf(Attempt|2|Menu)~ ~\\GotoIf(Attempt|3|AttemptEnd)~ ~\\Label(AttemptEnd)~ Good Bye ~\\EndCall()~ ~\\Label(Ack)~ ~\\PlaySilence(0.1)~ Thank you for acknowledging receipt of this alert. ~\\PlaySilence(0.1)~ Log into TempTrak to take corrective action and officially clear alert. ~\\PlaySilence(0.1)~ Good Bye. ~\\EndCall()~";
            anr.VoiceID              = voiceMode.ToInt();           //store this in config if customer does not like voice
            anr.UTCScheduledDateTime = DateTime.UtcNow;
            anr.LicenseKey           = voiceLicense;                //"54B1B99F-7E7E-40AC-88EB-A91DBE859B82"; //stored in config file for now
            anr.TryCount             = 0;                           //voiceRetries.ToInt();  //controlled by TT not CDyne
            anr.NextTryInSeconds     = 0;                           //controlled by TT
            anr.TTSvolume            = Convert.ToByte(voiceVolume); //also store this in config


            NotifyReturn nr = pn.NotifyPhoneAdvanced(anr);

            LogBook.Write("Info Passed to Notify Phone Advanced: ");
            LogBook.Write("CallerIDName: " + anr.CallerIDName);
            LogBook.Write("CallerIDNumber: " + anr.CallerIDNumber);
            LogBook.Write("PhoneNumberToDial: " + anr.PhoneNumberToDial);
            LogBook.Write("TextToSay: " + anr.TextToSay);
            LogBook.Write("VoiceID: " + anr.VoiceID);
            LogBook.Write("UTCScheduledDateTime: " + anr.UTCScheduledDateTime);
            LogBook.Write("LicenseKey: " + anr.LicenseKey);
            LogBook.Write("NextTryInSeconds: " + anr.NextTryInSeconds);
            LogBook.Write("TTSVolume: " + anr.TTSvolume);

            LogBook.Write("Dialed: " + phoneNumber + " ......... ");

            //final released version will have script uploaded to CDyne so we can say goodbye if user presses key


            QueueID = nr.QueueID;
            LogBook.Write("QueueID: " + nr.QueueID + " ......... ");
            return(QueueID);
        }
Esempio n. 2
0
        /// <summary>
        /// Dials the number.
        /// </summary>
        public long DialNumber()
        {
            LogBook.Write("Dialing the number");
            InitCall();

            LogBook.Write("InitCall() completed");
            LogBook.Write("PhoneNo. : " + phoneNumber + ", Voice Prompt: " + sensorInfo);

            /* reset previous flags */
            isCallConnected           = false;
            IsDone                    = false;
            stopVoicePrompt           = false;
            digitReceived             = false;
            Action["CallConnected"]   = 0;
            Action["SilenceDetected"] = 0;

            notifyComResponse = new NotifyComResponse();



            LogBook.Write("Starting to dial " + phoneNumber);

            PhoneNotify notify = new PhoneNotify();



            AdvancedNotifyRequest anr = new AdvancedNotifyRequest();
            PhoneNotify           pn  = new PhoneNotify();

            anr.CallerIDName      = "TempTrak";
            anr.CallerIDNumber    = fromNumber;              //TT registration #
            anr.PhoneNumberToDial = phoneNumber;
            //  anr.TextToSay = "This is an important message from your "+_alarmObject.StoreName TempTrak Monitoring System, to alert,,"+personName+",,at <say-as type=\"number:digits\">"+phoneNumber+"</say-as>"+",,that device name,"+deviceName+",probe number,"+probe+", is in violation,,, measuring a value of "+value+" for an elapsed time of "+timeOutOfRange+",,,Press any key to acknowlege this call,, Thank You,,,";
            //  string promptMessage = @"This is the " + alarmObject.StoreName + " Temp Track voice notification system, , , , There is an alarm with "
            //   + alarmObject.IVR_SensorName + ", , Last Reading was " + SensorValueToTTS(alarmObject.UTID, alarmObject.Probe, alarmObject.SensorType, (decimal)alarmObject.Value, alarmObject.IsCelsius)
            //   + ", , , , press any key to acknowledge. ";
            anr.TextToSay = "This is the Temp Track voice notification system, , , , There is an alarm with "
                            + deviceName + ", , Last Reading was " + value + ", , , , press any key to acknowledge. ";
            anr.VoiceID = 6;
            anr.UTCScheduledDateTime = DateTime.UtcNow;
            anr.LicenseKey           = "54B1B99F-7E7E-40AC-88EB-A91DBE859B82";       //stored in config file for now
            anr.TryCount             = 5;
            anr.NextTryInSeconds     = 30;
            anr.TTSvolume            = 5;

            NotifyReturn nr = pn.NotifyPhoneAdvanced(anr);

            //store TransactionID into table where
            QueueID = -1;
            QueueID = nr.QueueID;



            Thread.Sleep(30000);
            //now query the webservice and update records
            MachineDetection       = nr.MachineDetection;
            DigitsPressed          = nr.DigitsPressed;
            CallAnswered           = nr.CallAnswered;
            CallComplete           = nr.CallComplete;
            IVRServiceResponseText = nr.ResponseText;
            Duration  = nr.Duration;
            StartTime = nr.StartTime;
            EndTime   = nr.EndTime;

            if (DigitsPressed.Length > 0)
            {
                notifyComResponse.IsSucceeded      = true;
                notifyComResponse.IsError          = false;
                notifyComResponse.ResponseContent += "\r\n Acknowledgement received, " + DigitsPressed + " pressed.";
                notifyComResponse.IsSucceeded      = true;
                LogBook.Write("Digit Received");
                LogBook.Write("\t" + "Digit: " + DigitsPressed);
            }
            else
            {
                notifyComResponse.IsSucceeded = false;
                notifyComResponse.IsError     = true;
                if (MachineDetection == "MACHINE")
                {
                    notifyComResponse.ResponseContent += "\r\n Answering Machine Detected";
                }
                else if (CallAnswered == false)
                {
                    notifyComResponse.ResponseContent += "\r\n No Answer";
                }
                else if ((CallAnswered == true) && (DigitsPressed.Length == 0))
                {
                    notifyComResponse.ResponseContent += "\r\n Call Answerd, No Digits Pressed";
                }
            }

            return(QueueID);
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            if (CommandLineExec(args))
            {
                return;
            }

            string userInput;

            Console.Title = "Cooper Atkins Notification Utility";

            WriteLine("Notification Engine Utility Program\n");
            WriteLine("(C) Cooper Atkins 2015\n");

            bool exitFlag = false;

            while (true)
            {
                Console.Write("\nNotification>");
                string[] commandArray = new string[1];
                if (args.Length > 0)
                {
                    commandArray = args;
                    WriteLine("\r\nNotification>" + args[0], false);
                    args = null;
                }
                else
                {
                    userInput    = Console.ReadLine();
                    commandArray = userInput.Split(' ');
                    WriteLine("\r\nNotification>" + userInput, false);
                }


                IniHelp iniHelp = new IniHelp();

                string settingsXml = string.Empty;
                string inputYN     = "";
                switch (commandArray[0].ToLower())
                {
                case "help":
                    DisplayHelp(commandArray[0].ToLower());
                    break;

                case "removeprocessall":
                    WriteLine("Are you sure you want to stop all the notification process?(Y/N):");
                    inputYN = Console.ReadLine();
                    WriteLine(inputYN, false);

                    if (inputYN.ToUpper() != "Y")
                    {
                        break;
                    }

                    foreach (Process pro in Process.GetProcessesByName("CooperAtkins.NotificationClient.Service"))
                    {
                        try
                        {
                            pro.Kill();
                        }
                        catch { }
                    }
                    break;

                case "removeprocess":

                    //if (commandArray.Length <= 2) {

                    //  WriteLine("Invalid arguments. Syntax: process [-r] [-s][-a] <processid>\n -r  remove \n -s single process or -a all processes");
                    //}

                    //if (commandArray[1].ToLower() == "-r")
                    WriteLine("Are you sure you want to stop notification process?(Y/N):");
                    inputYN = Console.ReadLine();
                    WriteLine(inputYN, false);

                    if (inputYN.ToUpper() != "Y")
                    {
                        break;
                    }

                    int result;
                    if (!int.TryParse(commandArray[1], out result))
                    {
                        WriteLine("Invalid argument. Enter valid process id.");
                        break;
                    }
                    int pid = Convert.ToInt32(result);
                    foreach (Process pro in Process.GetProcessesByName("CooperAtkins.NotificationClient.Service"))
                    {
                        if (pro.Id == pid)
                        {
                            try
                            {
                                pro.Kill();
                            }
                            catch { }
                        }
                    }
                    break;

                case "ping":
                    Send("command ping");
                    break;

                case "exit":
                case "quit":
                    exitFlag = true;
                    break;

                case "testivr":
                    PhoneNotify notify      = new PhoneNotify();
                    string      phoneNumber = "";

                    if (commandArray.Length == 2)
                    {
                        if (commandArray[1].Length != 10)
                        {
                            WriteLine("Please provide valid phone number.\n");
                            DisplayHelp(commandArray[0].ToLower());
                            break;
                        }
                        phoneNumber = commandArray[1].Trim();
                    }
                    else
                    {
                        WriteLine("Invalid notification command.\n");
                        DisplayHelp(commandArray[0].ToLower());
                    }



                    AdvancedNotifyRequest anr = new AdvancedNotifyRequest();
                    PhoneNotify           pn  = new PhoneNotify();

                    anr.CallerIDName      = "TempTrak Alert System";
                    anr.CallerIDNumber    = "888-533-6900";      //TT registration #
                    anr.PhoneNumberToDial = phoneNumber;
                    //anr.TextToSay = "This is a test call from TempTrak for,, <say-as type=\"number:digits\">" + phoneNumber + "</say-as>" + ",,,Press the star key to acknowlege this call,, Thank You,,,This is a test call from TempTrak for,, <say-as type=\"number:digits\">" + phoneNumber + "</say-as>" + ",,,Press the star key to acknowlege this call,, Thank You,,,This is a test call from TempTrak for,, <say-as type=\"number:digits\">" + phoneNumber + "</say-as>" + ",,,Press the star key to acknowlege this call,, Thank You,,,";
                    //anr.TextToSay = /*"~\\ActOnFeature(false)~*/ "~\\SetVar(Attempt|1)~ ~\\ActOnDigitPress(false)~   ~\\Label(Menu)~ ~\\AssignDTMF(*|Ack)~ ~\\ActOnDigitPress(true)~ ~\\Beep()~ ~\\PlaySilence(0.1)~" + sensorInfo + " ~\\WaitForDTMF(1)~" + "Press the star key to acknowledge receipt of this alert.  Press 1 to repeat this message. ~\\PlaySilence(0.1)~   ~\\WaitForDTMF(10)~ ~\\IncreaseVariable(Attempt|1)~ ~\\GotoIf(Attempt|1|Menu)~ ~\\GotoIf(Attempt|2|Menu)~ ~\\GotoIf(Attempt|3|AttemptEnd)~ ~\\Label(AttemptEnd)~ Good Bye ~\\EndCall()~ ~\\Label(Ack)~ ~\\PlaySilence(0.1)~ Thank you for acknowledging receipt of this alert. ~\\PlaySilence(0.1)~ Log into TempTrak to take corrective action and officially clear alert. ~\\PlaySilence(0.1)~ Good Bye. ~\\EndCall()~";
                    string promptMessage = @"This is the Temp Track voice notification system  ~\\PlaySilence(0.2)~ There is an alarm with a sensor named "
                                           + "Research Specimen Freezer 696" + " ~\\PlaySilence(0.2)~ The Last Reading was " + "-5 degrees C"
                                           + " ~\\PlaySilence(0.2)~ Sensor has been operating out of range for  ~\\PlaySilence(0.1)~ " + "30 minutes";

                    anr.TextToSay            = /*"~\\ActOnFeature(false)~*/ "~\\SetVar(Attempt|1)~ ~\\ActOnDigitPress(false)~   ~\\Label(Menu)~ ~\\AssignDTMF(*|Ack)~ ~\\ActOnDigitPress(true)~ ~\\Beep()~ ~\\PlaySilence(0.1)~" + promptMessage + " ~\\WaitForDTMF(1)~" + "Press the star key to acknowledge receipt of this alert.  Press 1 to repeat this message. ~\\PlaySilence(0.1)~   ~\\WaitForDTMF(10)~ ~\\IncreaseVariable(Attempt|1)~ ~\\GotoIf(Attempt|1|Menu)~ ~\\GotoIf(Attempt|2|Menu)~ ~\\GotoIf(Attempt|3|AttemptEnd)~ ~\\Label(AttemptEnd)~ Good Bye ~\\EndCall()~ ~\\Label(Ack)~ ~\\PlaySilence(0.1)~ Thank you for acknowledging receipt of this alert. ~\\PlaySilence(0.1)~ Log into TempTrak to take corrective action and officially clear alert. ~\\PlaySilence(0.1)~ Good Bye. ~\\EndCall()~";
                    anr.VoiceID              = 6;
                    anr.UTCScheduledDateTime = DateTime.UtcNow;
                    anr.LicenseKey           = "b9eec503-0308-46f0-b5f2-01d3ae1182ea"; //stored in config file for now
                    anr.TryCount             = 1;
                    anr.NextTryInSeconds     = 0;
                    anr.TTSvolume            = 5;

                    NotifyReturn nr = pn.NotifyPhoneAdvanced(anr);

                    Console.WriteLine("Call Server Response Text: " + nr.ResponseText);
                    //     Console.WriteLine("Call Server Response Code: " + nr.ResponseCode);
                    Console.WriteLine("Call QueueID: " + nr.QueueID);
                    Console.WriteLine("After Call is Complete: type 'getivrstatus " + nr.QueueID + "' to see call results");

                    for (int f = 0; f < 40; f++)
                    {
                        System.Threading.Thread.Sleep(2000);
                        if (f == 0)
                        {
                            Console.WriteLine("");
                        }
                        else
                        {
                            Console.Write("- ");
                        }
                    }


                    break;

                case "getivrstatus":
                    string commandlineInput = commandArray[1].ToString();
                    long   TransactionID    = Convert.ToInt64(commandlineInput);

                    PhoneNotify  notify2       = new PhoneNotify();
                    NotifyReturn notifyResult2 = notify2.GetQueueIDStatus(TransactionID);
                    Console.WriteLine(notifyResult2.ResponseText);

                    Console.WriteLine("Ans Machine Detection: " + notifyResult2.MachineDetection);
                    Console.WriteLine("Demo: " + notifyResult2.Demo);

                    Console.WriteLine("Digits Pressed: " + notifyResult2.DigitsPressed);
                    Console.WriteLine("Call Duration: " + notifyResult2.Duration);
                    Console.WriteLine("Call Start Time: " + notifyResult2.StartTime);
                    Console.WriteLine("Call End Time: " + notifyResult2.EndTime);
                    Console.WriteLine("Call QueueID: " + notifyResult2.QueueID);
                    Console.WriteLine("Try Count: " + notifyResult2.TryCount);
                    Console.WriteLine("Text To Say: " + notifyResult2.TextToSay);
                    Console.WriteLine("Call Answered: " + notifyResult2.CallAnswered);
                    Console.WriteLine("Call Complete: " + notifyResult2.CallComplete);

                    if ((notifyResult2.MachineDetection == "MACHINE") || (notifyResult2.DigitsPressed == ""))
                    {
                        string[] commandArray2 = new string[] { "testivr" };

                        Main(commandArray2);
                    }
                    break;

                case "report":
                    FileStream logFileStream = File.Create(AppDomain.CurrentDomain.BaseDirectory + "Log.txt");
                    logFileStream.Write(Encoding.ASCII.GetBytes(DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() + "\r\n"), 0, (DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString() + "\r\n").Length);
                    logFileStream.Write(Encoding.ASCII.GetBytes(logBuilder.ToString().Replace("\\n", " ")), 0, logBuilder.ToString().Length);
                    logFileStream.Flush();
                    logFileStream.Close();
                    logFileStream.Dispose();
                    logFileStream = null;
                    Process process1 = new Process();
                    process1.StartInfo = new ProcessStartInfo(AppDomain.CurrentDomain.BaseDirectory + "Log.txt");
                    process1.Start();
                    break;

                case "connect":
                    if (commandArray.Length > 2)
                    {
                        bool flag = ValidateIpPort(commandArray[1].Trim(), commandArray[2].Trim());
                        if (!flag)
                        {
                            WriteLine("Please provide valid IP Address and port.\n");
                            break;
                        }
                        _server = commandArray[1].Trim();
                        _port   = Convert.ToInt32(commandArray[2].Trim());
                        Send("command ping");
                        localNEObj = null;
                    }
                    else
                    {
                        if (localNEObj == null)
                        {
                            //string notificationInstallationPath = Environment.GetEnvironmentVariable("NotifyServerPath", EnvironmentVariableTarget.Machine); ;

                            LoadLocalNotifyEngine();
                        }
                        else
                        {
                            WriteLine("Invalid notification command.\n");
                            DisplayHelp(commandArray[0].ToLower());
                        }
                    }
                    break;

                case "clear":
                case "cls":
                    Console.Clear();
                    break;

                case "open":
                    Process process = new Process();
                    process.StartInfo = new ProcessStartInfo(AppDomain.CurrentDomain.BaseDirectory + "Commands.ini");
                    process.Start();
                    break;

                default:
                    string[] keys = null;

                    if (commandArray[0].ToLower() != "utilitymessageformats")
                    {
                        keys = iniHelp.IniReadKeys(commandArray[0].ToLower());
                    }

                    if (keys != null)
                    {
                        StringBuilder sb = new StringBuilder();

                        if (commandArray.Length == 1)
                        {
                            string[] format = GetMessageFormat(commandArray[0].ToLower());
                            if (!string.IsNullOrEmpty(format[0]) && !string.IsNullOrEmpty(format[1]))
                            {
                                string[] arrayVars = format[1].Split(',');
                                string   message   = format[0];
                                for (int i = 0; i < arrayVars.Length; i++)
                                {
                                    Console.Write("Enter " + arrayVars[i].Trim() + ":");
                                    message = message.Replace("{" + i.ToString() + "}", Console.ReadLine());
                                }
                                if (commandArray[0].ToLower() == "remotepopup" || commandArray[0].ToLower() == "serverpopup")
                                {
                                    string temp      = "00000000";
                                    int    strLength = temp.Length - message.Length.ToString().Length;
                                    message = temp.Substring(0, strLength) + message.Length + message;
                                    sb      = new StringBuilder(message);
                                }
                            }
                            else
                            {
                                Console.WriteLine("\nPlease enter message to send (Press ctrl+z to end the message):\n");
                                string line = string.Empty;
                                do
                                {
                                    line = Console.ReadLine();
                                    sb.Append(line);
                                } while (line != null);
                            }
                        }
                        else
                        {
                            sb = new StringBuilder(string.Join(" ", commandArray, 1, commandArray.Length - 1));
                        }

                        settingsXml = WriteKeyValue(commandArray[0].ToLower(), sb.ToString());
                        if (settingsXml != null)
                        {
                            if (localNEObj == null)
                            {
                                Send(settingsXml);
                            }
                            else
                            {
                                LocalExecution(settingsXml);
                            }
                        }
                    }
                    else
                    {
                        WriteLine("Invalid notification command. \nPlease use open command to check available commands.\nSyntax: open\n\n");
                    }



                    break;
                }
                if (exitFlag)
                {
                    break;
                }
            }
        }