Ejemplo n.º 1
0
        private void callbackset_button_Click(object sender, EventArgs e)
        {
            callbackset_button.Text = "Setting Callback...";
            XmlElement result_status = null;

            XmlNode[] output             = null;
            ms.voip.VoIPms_Service soap  = new ms.voip.VoIPms_Service();
            ms.voip.setSMSInput    input = new ms.voip.setSMSInput();

            input.api_password        = activeSettings.Password;
            input.api_username        = activeSettings.Username;
            input.did                 = activeSettings.ActiveDID;
            input.enable              = "1";
            input.url_callback_enable = "1";
            input.url_callback        = callbackUrl_text.Text;
            input.url_callback_retry  = "0";

            output        = (XmlNode[])soap.setSMS(input);
            result_status = (XmlElement)output.GetValue(1);


            if (result_status.ChildNodes[1].InnerText == "success")
            {
                //result_id = (XmlElement)output.GetValue(2);
                callbackset_button.Text = "Success!";
            }
            else
            {
                callbackset_button.Text = result_status.ChildNodes[1].InnerText;
            }
        }
Ejemplo n.º 2
0
        public static object getSMS(string username, string password, string did, string dateBegin, string dateEnd = "", string type = "", string contact = "", string limit = "2000", string timezone = "")
        {
            //minimum required information otherwise fail
            if (username == "" || password == "" || did == "" || dateBegin == "")
            {
                Console.WriteLine("getSMS Failed. Cannot have empty values.");
                return("failed_emptyvalues");
            }

            //Check date ranges
            if (dateEnd.Length > 0)
            {
                double days = (DateTime.Parse(dateEnd + " 23:59:59") - DateTime.Parse(dateBegin + " 00:00:00")).TotalDays;
                if (days > 90 | days <= 0)
                {
                    Console.WriteLine("getSMS Failed. Date range must be with 1-90 days");
                    return("failed_baddate");
                }
            }

            if (!utilities.isNumber(did))

            {
                Console.WriteLine("getSMS Failed. DID must be numeric value");
                return("failed_didnotnumeric");
            }

            Console.WriteLine("Updating Messages from " + dateBegin);
            Console.WriteLine("Current time: " + DateTime.Now.ToShortTimeString());

            ms.voip.VoIPms_Service soap  = new ms.voip.VoIPms_Service();
            ms.voip.getSMSInput    input = new ms.voip.getSMSInput();
            string status = null;

            //Fill Input Object
            input.api_username = username;
            input.api_password = password;
            input.did          = did;
            input.from         = dateBegin;
            input.to           = dateEnd;
            input.type         = type;
            input.contact      = contact;
            input.limit        = limit;
            input.timezone     = timezone;

            //Request Info
            XmlNode[]  output        = (XmlNode[])soap.getSMS(input);
            XmlElement result_status = (XmlElement)output.GetValue(1);

            status = result_status.ChildNodes[1].InnerText;
            if (status == "success")
            {
                XmlElement messages = (XmlElement)output.GetValue(2);
                Console.WriteLine("getSMS Successful. SMS Count: " + messages.ChildNodes[1].ChildNodes.Count.ToString());
                return((XmlElement)messages.ChildNodes[1]);
            }
            return(status);
        }
Ejemplo n.º 3
0
        private void TestConnection_Click(object sender, EventArgs e)
        {
            TestConnection.Text    = "Testing...";
            username_text.Enabled  = false;
            password_text.Enabled  = false;
            TestConnection.Enabled = false;
            ms.voip.VoIPms_Service   soap  = new ms.voip.VoIPms_Service();
            ms.voip.getDIDsInfoInput input = new ms.voip.getDIDsInfoInput();
            XmlNode[]  output;
            XmlElement result_status = null;
            string     status        = null;

            input.api_username  = username_text.Text;
            input.api_password  = password_text.Text;
            input.client        = ""; // Set to nothing so we can get all the account DID's
            input.did           = ""; // Same thing. need all the DID's
            output              = (XmlNode[])soap.getDIDsInfo(input);
            result_status       = (XmlElement)output.GetValue(1);
            status              = result_status.ChildNodes[1].InnerText;
            TestConnection.Text = status;
            if (status == "success")
            {
                XmlElement result_dids = null;
                XmlElement dids        = null;
                XmlElement did         = null;
                result_dids = (XmlElement)output.GetValue(2);
                dids        = (XmlElement)result_dids.ChildNodes[1];
                for (int i = 0; i <= dids.ChildNodes.Count - 1; i++)
                {
                    did = (XmlElement)dids.ChildNodes[i];
                    if (did.ChildNodes[21].ChildNodes[1].InnerText == "1")
                    {
                        comboBox1.Items.Add(did.ChildNodes[0].ChildNodes[1].InnerText);
                    }
                    //callbackUrl_text.Text = did.ChildNodes[26].ChildNodes[1].InnerText;
                }
                if (comboBox1.Items.Count > 0)
                {
                    comboBox1.SelectedIndex = 0;
                    comboBox1.Enabled       = true;
                    dateTimePicker1.Enabled = true;
                    saveOpen_button.Enabled = true;
                }
            }
            else
            {
                comboBox1.Items.Clear();
                comboBox1.Enabled       = false;
                dateTimePicker1.Enabled = false;
                saveOpen_button.Enabled = false;
            }
            username_text.Enabled  = true;
            password_text.Enabled  = true;
            TestConnection.Enabled = true;
        }
Ejemplo n.º 4
0
        public static object sendSMS(string username, string password, string did, string destination, string smsContent)
        {
            //minimum required information otherwise fail
            if (username == "" || password == "" || did == "" || destination == "" || smsContent == "")
            {
                Console.WriteLine("sendSMS Failed. Cannot have empty values.");
                return("failed_emptyvalues");
            }

            if (!utilities.isNumber(did) || !utilities.isNumber(destination))

            {
                Console.WriteLine("sendSMS Failed. DID or Destination must be numeric values");
                return("failed_notnumeric");
            }

            ms.voip.VoIPms_Service soap  = new ms.voip.VoIPms_Service();
            ms.voip.sendSMSInput   input = new ms.voip.sendSMSInput();

            input.api_username = username;
            input.api_password = password;
            input.did          = did;
            input.dst          = destination;

            XmlNode[]  output        = null;
            XmlElement result_status = null;
            XmlElement result_id     = null;

            //used to update messageData
            List <TextMessage> smsUpdateList = new List <TextMessage>();
            TextMessage        insertMessage = new TextMessage();

            insertMessage.Type          = "0"; // 0 Sent / 1 Received
            insertMessage.ContactNumber = destination;
            insertMessage.DID           = did;
            insertMessage.Unread        = false;

            string[] smsDataArray = utilities.str_SplitChunk(smsContent, 160); // text messages must be split into 160 character chunks to be valid. voip.ms will return error if sent without splitting

            foreach (string smsString in smsDataArray)
            {
                input.message         = smsString;
                insertMessage.Message = smsString;

                //try and send the message
                output        = (XmlNode[])soap.sendSMS(input);
                result_status = (XmlElement)output.GetValue(1);

                if (result_status.ChildNodes[1].InnerText == "success")
                {
                    // voip.ms generated sms ID
                    result_id               = (XmlElement)output.GetValue(2);
                    insertMessage.ID        = result_id.ChildNodes[1].InnerText; // Set voip.ms ID
                    insertMessage.Timestamp = utilities.getNewDateStr();         // Get the
                }
                else
                {
                    //failed messages need to still be added. They need to be either resent later or deleted.
                    insertMessage.ID        = result_id.ChildNodes[1].InnerText; // Set to failure message right now
                    insertMessage.Timestamp = result_id.ChildNodes[1].InnerText; // Set to failure message right now
                }
                smsUpdateList.Add(insertMessage);
            }
            smsUpdateList.Reverse(); // Messages need to be last sent at the top
            return(smsUpdateList);
        }
Ejemplo n.º 5
0
        private void voipTestConnect_btn_Click(object sender, EventArgs e)
        {
            voipTestConnect_btn.Text = "Testing...";

            voipUsername_input.Enabled  = false;
            voipPassword_input.Enabled  = false;
            voipTestConnect_btn.Enabled = false;

            ms.voip.VoIPms_Service   soap  = new ms.voip.VoIPms_Service();
            ms.voip.getDIDsInfoInput input = new ms.voip.getDIDsInfoInput();
            XmlNode[] output;

            //XML Elements
            XmlElement result_status = null;
            XmlElement result_dids   = null;
            XmlElement dids          = null;
            XmlElement did           = null;

            //String Vars
            string status   = null;
            string str_dids = null;

            //Fill Input Object
            input.api_username = voipUsername_input.Text;
            input.api_password = voipPassword_input.Text;
            input.client       = ""; // Set to nothing so we can get all the account DID's
            input.did          = ""; // Same thing. need all the DID's

            //Request Info
            output        = (XmlNode[])soap.getDIDsInfo(input);
            result_status = (XmlElement)output.GetValue(1);

            //if (output.GetType().ToString() == "System.Xml.XmlNode[]")
            //{
            //Get status
            status = result_status.ChildNodes[1].InnerText;
            //}
            voipTestConnect_btn.Text = status;

            if (status == "success")
            {
                result_dids = (XmlElement)output.GetValue(2);
                dids        = (XmlElement)result_dids.ChildNodes[1];

                for (int i = 0; i <= dids.ChildNodes.Count - 1; i++)
                {
                    //Get DID
                    did = (XmlElement)dids.ChildNodes[i];

                    if (did.ChildNodes[21].ChildNodes[1].InnerText == "1")
                    {
                        activeDID_text.Text = did.ChildNodes[0].ChildNodes[1].InnerText;
                        Properties.Settings.Default.ActiveDID = did.ChildNodes[0].ChildNodes[1].InnerText;
                        Properties.Settings.Default.Save();
                    }

                    callbackUrl_text.Text = did.ChildNodes[26].ChildNodes[1].InnerText;
                    for (int j = 0; j <= did.ChildNodes.Count - 1; j++)
                    {
                        //Get Data from DID
                        str_dids += j.ToString() + ">>" + did.ChildNodes[j].ChildNodes[0].InnerText + " => ";
                        str_dids += did.ChildNodes[j].ChildNodes[1].InnerText + "\n";
                    }

                    str_dids += "\n";
                }
                MessageBox.Show(str_dids, "a bunch of data");
            }

            voipUsername_input.Enabled  = true;
            voipPassword_input.Enabled  = true;
            voipTestConnect_btn.Enabled = true;
        }