private void backworker_DoWork(object sender, DoWorkEventArgs e) { switch (m_process) { case _process.form_loading: { if (m_client != null) { m_phone_count = m_client.PhoneCollection.Count(); } break; } case _process.send_sms: { int demo_count = datam.GetSmsDemoCount(); if (demo_count >= DEMO_MAX) { MessageBox.Show("Your SMS Demo Version Has Expired"); return; } else { //if (m_phone_count > demo_count) //{ // if (m_phone_count > DEMO_MAX) // { // m_phone_count = DEMO_MAX - demo_count; // } // else // { // m_phone_count = m_phone_count - demo_count; // } // MessageBox.Show(string.Format("Your SMS Demo Version Has Almost Over,Only {0} SMS Will Be Sent", m_phone_count)); // m_PhoneCollection = m_PhoneCollection.Take(m_phone_count); //} // m_phone_count = 2; } m_phone_count = 2; #region Webservice Settings // Chilkat.HttpRequest req = new Chilkat.HttpRequest(); Chilkat.Http http = new Chilkat.Http(); bool success; //Any string unlocks the component for the 1st 30-days. success = http.UnlockComponent("30277129240"); if (success != true) { MessageBox.Show("Invalid Use Of The Chilkat Library"); return; } // Build an HTTP POST Request: req.UsePost(); req.Path = "/api.php"; req.AddParam("username", "*****@*****.**"); req.AddParam("password", "prpc2qb7"); req.AddParam("from", m_HEADER); req.AddParam("message", m_MESSAGE); // req.AddParam("recipients", "256772332619,256772508360"); req.AddParam("recipients", "256701871684"); m_PhoneString = GetPhoneString(); // req.AddParam("recipients", m_PhoneString); #region compression //MessageBox.Show(m_PhoneString.Length.ToStringNullable(); //Chilkat.Gzip gzip = new Chilkat.Gzip(); //// Any string unlocks the component for the 1st 30-days. //success = gzip.UnlockComponent("ZIP12345678_4F507D55AD1G"); //if (success != true) //{ // MessageBox.Show(gzip.LastErrorText); // return; //} //string cs; //cs = gzip.DeflateStringENC(m_PhoneString, "windows-1252", "base64"); //MessageBox.Show(cs.Length.ToStringNullable(); //return; #endregion //req.AddParam("recipients", m_PhoneString); req.AddParam("type", "normal"); req.AddParam("token", "c4ca4238a0b923820dcc509a6f75849b"); // Send the HTTP POST and get the response. Note: This is a blocking call. // The method does not return until the full HTTP response is received. string domain; int port; bool ssl; domain = "http://208.111.47.244"; port = 80; ssl = false; Chilkat.HttpResponse resp = null; resp = http.SynchronousRequest(domain, port, ssl, req); if (resp == null) { // MessageBox.Show(http.LastErrorText); MessageBox.Show("There Seems To Be A Problem With Your Internet Connection ,SMS Has Not Been Sent", "SMS Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var _res = resp.BodyStr.Trim(); string error_str = null; if (!string.IsNullOrEmpty(_res)) { int _ret = -1; if (_res.Split(new char[] { ':' }).Length > 1) { _res = _res.Split(new char[] { ':' })[0]; } int.TryParse(_res, out _ret); if (_ret >= 0) { switch ((_sms_status)_ret) { case _sms_status.success: { m_status = _sms_status.success; break; } case _sms_status.insufficientcredit: { error_str = "You Do Not Have Sufficient Credit On Your Account,Please Contact Smart IT Solutions"; m_status = _sms_status.insufficientcredit; break; } case _sms_status.invalid_request: { error_str = "The Http Request You Made Is Not Valid"; m_status = _sms_status.invalid_request; break; } case _sms_status.invalid_user: { m_status = _sms_status.invalid_user; error_str = "Invalid UserName Or Password"; break; } default: { error_str = "Unknown Error,Please Contact Smart IT Solutions"; m_status = _sms_status.unknown; break; } } } } if (!string.IsNullOrEmpty(error_str)) { dbm.ErrorMessage(error_str, "SMS Send ERROR"); } } http.Dispose(); #endregion break; } case _process.test_mode: { m_status = _sms_status.success; break; } } }