Esempio n. 1
0
        void SendCallFile(AsteriskCallFile c)
        {
            //C:\TEMP>pscp  -i c:\mykey.ppk -v temp3.call hydromet@pbx:/var/spool/asterisk/outgoing/

            var src  = c.SaveToTempFile();
            var host = ConfigurationManager.AppSettings["pbx_server"];
            var user = ConfigurationManager.AppSettings["pbx_username"];
            var scp  = ConfigurationManager.AppSettings["scp"];
            var key  = ConfigurationManager.AppSettings["pbx_ssh_key"];


            var dest = user + "@" + host + ":/var/spool/asterisk/outgoing/";

            var args = "-i " + key + " " + src + " " + dest;

            Logger.WriteLine(scp + " " + args);
            Process.Start(scp, args);
        }
Esempio n. 2
0
        public void ProcessAlarms()
        {
            var alarmQueue = alarmDS.GetUnconfirmedAlarms();

            Logger.WriteLine("found " + alarmQueue.Rows.Count + " unconfirmed alarms in the queue");

            for (int i = 0; i < alarmQueue.Count; i++)
            {
                var alarm = alarmQueue[i];
                LogDetails(alarm);

                string[] numbers = alarmDS.GetPhoneNumbers(alarm.list);

                if (numbers.Length == 0)
                {
                    Console.WriteLine("Warning: no phone numbers defined ");;
                    continue;
                }

                int minutesBeforeNextPhone = 5;
                if (alarmDS.CurrentActivity(alarm.id, minutesBeforeNextPhone)) // any activity in last x minutes.
                {
                    Logger.WriteLine("waiting on id = " + alarm.id + " it has activity in the last " + minutesBeforeNextPhone + " minutes");
                    continue;
                }

                alarm.current_list_index = UpdateCurrentPhoneIndex(alarm, numbers);

                var c = new AsteriskCallFile(numbers[alarm.current_list_index]);
                c.AddVariable("siteid", alarm.siteid);
                c.AddVariable("parameter", alarm.parameter);
                c.AddVariable("value", alarm.value.ToString());
                c.AddVariable("id", alarm.id.ToString());
                c.AddVariable("phone", numbers[alarm.current_list_index]);

                SendCallFile(c);
                alarmDS.SaveTable(alarmQueue);
            }
        }