public IActionResult RunAction()
        {
            List <DataAccess.Models.Action> actions = db.Action.ToList();
            var user = db.User.Include(u => u.Template);

            foreach (var action in actions)
            {
                if (action.Type == 1) // call
                {
                    if (action.IsDone == false)
                    {
                        bool actionResult = asterisk.Call(action.PhoneNumber, string.Concat("ActionId=", action.Id)).Result;
                        if (actionResult)
                        {
                            action.IsDone = true;
                            db.SaveChanges();
                        }
                    }
                }
                else if (action.Type == 2) // message
                {
                }
            }
            return(Json(true));
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Asterisk asterisk = new Asterisk("192.168.100.99", 5038, "son", "123456");

            //asterisk.Login().Wait();
            asterisk.Call("SIP/1002", "ActionId=hihi").Wait();
            //ReminderSystemContext test = new ReminderSystemContext();
            //test.User.Add(new User() { UserName = "******", Password = "******" });
            //test.SaveChanges();
        }
Exemplo n.º 3
0
        private void buttonTest_Click(object sender, EventArgs e)
        {
            DataRowView currentDataRowView = (DataRowView)dataGridView1.CurrentRow.DataBoundItem;

            AlarmDataSet.alarm_definitionRow alarm
                = (AlarmDataSet.alarm_definitionRow)currentDataRowView.Row;

            var numbers = m_ds.GetPhoneNumbers(comboBoxTestList.Text);

            Asterisk.Call(alarm.siteid, alarm.parameter,
                          textBoxTest.Text, numbers);
        }
Exemplo n.º 4
0
        public void ProcessAlarms()
        {
            InstanceUtility.TouchProcessFile();

            var    alarmQueue = DB.GetNewAlarms();
            string user       = ConfigurationManager.AppSettings["pbx_username"];
            string pass       = ConfigurationManager.AppSettings["pbx_password"];

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

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

                string[] numbers = DB.GetPhoneNumbers(alarm.list);
                //string[] numbers = new string[] { "5272", "5272" };
                Asterisk.Call(alarm.siteid, alarm.parameter, alarm.value.ToString("F2"),
                              numbers, user, pass);
                Thread.Sleep(2000);
                string prevLog = "";
                do
                {
                    InstanceUtility.TouchProcessFile();
                    Thread.Sleep(2000);
                    UpdatePiscesStatus(alarm);

                    if (Asterisk.Log != prevLog)
                    {
                        prevLog = Asterisk.Log;
                        Logger.WriteLine(" Asterisk: " + Asterisk.LogTime + " : " + Asterisk.Log);
                    }

                    DB.SaveTable(alarmQueue);

                    if (Asterisk.ActiveChannels == 0)
                    {
                        UpdatePiscesStatus(alarm);
                        break;     // someone hungup or other loss of connection
                    }

                    if (Asterisk.MinutesElapsed >= 15)
                    {
                        UpdatePiscesStatus(alarm);
                        break;
                    }
                } while (Asterisk.Status == "unconfirmed");
            }
        }
Exemplo n.º 5
0
        private void buttonTest_Click(object sender, EventArgs e)
        {
            DataRowView currentDataRowView = (DataRowView)dataGridView1.CurrentRow.DataBoundItem;

            AlarmDataSet.alarm_definitionRow alarm
                = (AlarmDataSet.alarm_definitionRow)currentDataRowView.Row;

            var numbers = m_ds.GetPhoneNumbers(comboBoxTestList.Text);

            var login = new Login();

            if (login.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Asterisk.Call(alarm.siteid, alarm.parameter,
                              textBoxTest.Text, numbers, login.Username, login.Password);
            }
        }