示例#1
0
        /// <summary>
        /// HttpInternalGetCollectionsData() --> Gets all the collections for the table 'customer' for eFlowAppName.
        /// </summary>
        /// <param name="tName">Indicates the name of the table from the Supplier Portal where the data will be read from</param>
        /// <param name="port">Indicates the port to make the HTTP request</param>
        /// <param name="ssl">If SSL is used or not (True or False)</param>
        /// </summary>
        /// <example><code>s.HttpInternalGetCollectionsData("topimagesystems.com_CLS", 80, false);</code></example>
        protected string HttpInternalGetCollectionsData(string tName, int port, bool ssl)
        {
            string response = String.Empty;

            try
            {
                if (tName != String.Empty)
                {
                    Chilkat.HttpRequest req = new Chilkat.HttpRequest();

                    using (Chilkat.Http http = new Chilkat.Http())
                    {
                        http.UnlockComponent(Constants.cStrChilkatHttpLic);
                        req.UseGet();

                        req.Path = Constants.cStrHttpGetBaseCollectionDataUrl + Constants.cStrFlexibleDb + "/"
                                   + tName;

                        Chilkat.HttpResponse resp = http.SynchronousRequest(Constants.cStrDomain, port, ssl, req);
                        response = (resp == null) ? http.LastErrorText : resp.BodyStr;
                    }
                }
            }
            catch (Exception ex)
            {
                response = ex.ToString();
                Logging.WriteLog(response);
            }

            return(response);
        }
示例#2
0
        /// <summary>
        /// HttpPostInternalCollectionTableQry() --> Performs an HTPP POST (for a CollectionData Table query) request using the Chilkat engine. Returns an HTTP string response.
        /// Basically gets the table name and table data.
        /// </summary>
        /// <param name="tName">Indicates the name of the table from the Supplier Portal where the data will be read from</param>
        /// <param name="port">Indicates the port to make the HTTP request</param>
        /// <param name="ssl">If SSL is used or not (True or False)</param>
        /// <example><code>s.HttpPostInternalCollectionTableQry("topimagesystems.com_CLS", 80, false);</code></example>
        protected string HttpPostInternalCollectionTableQry(string tName, int port, bool ssl)
        {
            string response = String.Empty;

            try
            {
                if (tName != String.Empty)
                {
                    if (tName != String.Empty)
                    {
                        Chilkat.HttpRequest req = new Chilkat.HttpRequest();

                        using (Chilkat.Http http = new Chilkat.Http())
                        {
                            http.UnlockComponent(Constants.cStrChilkatHttpLic);

                            req.UsePost();
                            req.Path = Constants.cStrHttpPostCollectionDataTableUrl;

                            req.AddParam(Constants.cStrHttpPostCollectionDatatName, tName);

                            Chilkat.HttpResponse resp = http.SynchronousRequest(Constants.cStrDomain, port, ssl, req);
                            response = (resp == null) ? http.LastErrorText : resp.BodyStr;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                response = ex.ToString();
                Logging.WriteLog(response);
            }

            return(response);
        }
示例#3
0
        protected string HttpInternalDeleteAllRowsFromTable(string tbl, int port, bool ssl)
        {
            string response = String.Empty;

            try
            {
                Chilkat.HttpRequest req = new Chilkat.HttpRequest();

                using (Chilkat.Http http = new Chilkat.Http())
                {
                    http.UnlockComponent(Constants.cStrChilkatHttpLic);

                    req.UsePost();
                    req.Path = Constants.cStrHttpDeleteAllRowsInTable;

                    req.AddParam("db", Constants.cStrFlexibleDb);
                    req.AddParam("table", tbl);

                    Chilkat.HttpResponse resp = http.SynchronousRequest(Constants.cStrDomain, port, ssl, req);
                    response = (resp == null) ? http.LastErrorText : resp.BodyStr;
                }
            }
            catch (Exception ex)
            {
                response = ex.ToString();
                Logging.WriteLog(response);
            }

            return(response);
        }
示例#4
0
        public string PostFormData(string URL, string postData, string referer)
        {
            string response = string.Empty;

            ChangeProxy();

            //http.SetRequestHeader("Cookie", "PREF=ID=39a7dcb4769a70b5:U=01e856263f78e316:FF=0:TM=1310809062:LM=1311756586:GM=1:S=qiyaqpZc0QJwSHyD;NID=49=Ljnrtc5KZDOFfgRVn1Tt6G6MdaeISmX4vOzE7MSbouPD_4ze6OoSuCMWXlH0Jy7fnAlEYzdYxs4V7JP2DXnKgDxVQMKYY60yWoeCgFIwTL2WWBfmxJZNml5pYdudn5Zw;GAPS=1:tS3_AUBl7WpcKSXAXYMVdDiWuMdX0Q:rAR7mbwZ6PlPnJt-;GALX=7iQKVcsEdN4;GoogleAccountsLocale_session=en_GB;SID=DQAAAIUAAAD1r3xd8mtKrnHFMI4AdB1fuFDSG6YQ98V-_olltRKYgRSHMAgKC9eU88xa6oIay8EgmaV8PRZl1uxi_Q7Hx3etXAUCd42mHJph5YHU015yCzmHUoGdeVpzpFtvPc4xFpnu1Hl2PqXSN4tIlDAY_Qg6vs8I8eoWpiVPPXkLR1WaKcw54W9s1Yx1PxN7C5Nazmc;LSID=blogger|s.IN:DQAAAIYAAACEkfAmZiRHYaawY6Ol0Oguk5C58mprkWFDmf4StK2d_UZDRC6baudw3SoGKkQGBEsB4r2wRrklsK9O1XChX7Pj-UnTPMaDxSz4ADM5O69S-LQhLJx10-1kdeomZSC2NIOWxIpHhoWn1FPrpQrFDgisVLfVsHsjD7l5ASyaLzgzaIxx-XZfuQHaCRgnMRF09vo;[email protected];HSID=AuAY8LSZuG828am_4;SSID=AYAPgLxKQx6efsNxV;APISID=j799BJ0rwj5vK8S3/Aid730sB7T-6RWKbq;SAPISID=BnxZXhygC3cPGeSV/AVHrAqmtZgl16WiOi");

            req.RemoveAllParams();

            req.UsePost();
            //req.Path = "/login.php?login_attempt=1";

            req.AddHeader("Accept-Encoding", "gzip,deflate");
            req.AddHeader("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
            req.AddHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:18.0) Gecko/20100101 Firefox/18.0");
            req.AddHeader("Accept", "application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8, */*");
            req.AddHeader("Connection", "keep-alive");


            //req.AddHeader("Cookie", "PREF=ID=39a7dcb4769a70b5:U=01e856263f78e316:FF=0:TM=1310809062:LM=1311756586:GM=1:S=qiyaqpZc0QJwSHyD;NID=49=Ljnrtc5KZDOFfgRVn1Tt6G6MdaeISmX4vOzE7MSbouPD_4ze6OoSuCMWXlH0Jy7fnAlEYzdYxs4V7JP2DXnKgDxVQMKYY60yWoeCgFIwTL2WWBfmxJZNml5pYdudn5Zw;GAPS=1:tS3_AUBl7WpcKSXAXYMVdDiWuMdX0Q:rAR7mbwZ6PlPnJt-;GALX=7iQKVcsEdN4;GoogleAccountsLocale_session=en_GB;SID=DQAAAIUAAAD1r3xd8mtKrnHFMI4AdB1fuFDSG6YQ98V-_olltRKYgRSHMAgKC9eU88xa6oIay8EgmaV8PRZl1uxi_Q7Hx3etXAUCd42mHJph5YHU015yCzmHUoGdeVpzpFtvPc4xFpnu1Hl2PqXSN4tIlDAY_Qg6vs8I8eoWpiVPPXkLR1WaKcw54W9s1Yx1PxN7C5Nazmc;LSID=blogger|s.IN:DQAAAIYAAACEkfAmZiRHYaawY6Ol0Oguk5C58mprkWFDmf4StK2d_UZDRC6baudw3SoGKkQGBEsB4r2wRrklsK9O1XChX7Pj-UnTPMaDxSz4ADM5O69S-LQhLJx10-1kdeomZSC2NIOWxIpHhoWn1FPrpQrFDgisVLfVsHsjD7l5ASyaLzgzaIxx-XZfuQHaCRgnMRF09vo;[email protected];HSID=AuAY8LSZuG828am_4;SSID=AYAPgLxKQx6efsNxV;APISID=j799BJ0rwj5vK8S3/Aid730sB7T-6RWKbq;SAPISID=BnxZXhygC3cPGeSV/AVHrAqmtZgl16WiOi");

            #region PostData

            string[] arrPostData = Regex.Split(postData, "&");

            postDataDictionary.Clear();

            foreach (string item in arrPostData)
            {
                try
                {
                    postDataDictionary.Add(item.Split('=')[0], item.Split('=')[1]);
                }
                catch (Exception)
                {
                }
            }

            foreach (var item in postDataDictionary)
            {
                req.AddParam(item.Key, item.Value);
            }

            #endregion

            ///Set Referer
            if (!string.IsNullOrEmpty(referer))
            {
                req.AddHeader("Referer", referer);
            }

            Chilkat.HttpResponse respUsingPostURLEncoded = http.PostUrlEncoded(URL, req);
            string ResponseLoginPostURLEncoded           = respUsingPostURLEncoded.BodyStr;

            response = ResponseLoginPostURLEncoded;

            return(response);
        }
示例#5
0
        // Get the request token and verifier.
        private void button1_Click(object sender, EventArgs e)
        {
            Chilkat.OAuth1 oauth = new Chilkat.OAuth1();

            oauth.GenNonce(16);
            oauth.GenTimestamp();

            // The 1st step is to get a request token by sending an HTTP GET like this:
            oauth.OauthVersion    = "1.0";
            oauth.OauthMethod     = "GET";
            oauth.OauthUrl        = "https://api.login.yahoo.com/oauth/v2/get_request_token";
            oauth.ConsumerKey     = ConsumerKey;
            oauth.ConsumerSecret  = ConsumerSecret;
            oauth.SignatureMethod = "HMAC-SHA1";
            oauth.AddParam("oauth_callback", "oob");

            // Generate the OAuth1 signature and URL.
            bool success = oauth.Generate();

            if (success != true)
            {
                textBox1.Text = oauth.LastErrorText;
                return;
            }

            // Properties set by the Generate method:
            //textBox1.Text = "BaseString: " + oauth.BaseString + "\r\n" +
            //    "EncodedSignature : " + oauth.EncodedSignature + "\r\n" +
            //    "HmacKey : " + oauth.HmacKey + "\r\n" +
            //    "GeneratedUrl : " + oauth.GeneratedUrl + "\r\n" +
            //    "QueryString : " + oauth.QueryString + "\r\n" +
            //    "Signature  : " + oauth.Signature + "\r\n" +
            //    "AuthorizationHeader  : " + oauth.AuthorizationHeader + "\r\n"
            //    ;

            string requestTokenUrl = oauth.GeneratedUrl + "&oauth_signature=" + oauth.EncodedSignature;

            Chilkat.Http http = new Chilkat.Http();

            // Get the request token...
            Chilkat.HttpResponse resp = http.QuickGetObj(requestTokenUrl);
            if (resp == null)
            {
                textBox1.Text = http.LastErrorText;
                return;
            }

            // Get User Authorization -- get a request verifier interactively via the embedded web browser:
            string encodedResponseParams = resp.BodyStr;

            OAuthToken       = resp.UrlEncParamValue(encodedResponseParams, "oauth_token");
            OAuthTokenSecret = resp.UrlEncParamValue(encodedResponseParams, "oauth_token_secret");
            string userAuthUrl = "https://api.login.yahoo.com/oauth/v2/request_auth?oauth_token=" + OAuthToken;

            webBrowser1.Navigate(userAuthUrl);

            return;
        }
示例#6
0
        public bool LogoutChilkat(ref Chilkat.Http http)
        {
            try
            {
                string pageSource1 = http.QuickGetStr("http://www.facebook.com/");

                if (pageSource1.Contains("\"h\"") && pageSource1.Contains("post_form_id") && pageSource1.Contains("fb_dtsg"))
                {
                    string h            = string.Empty;
                    string post_form_id = string.Empty;
                    string fb_dtsg      = string.Empty;

                    if (pageSource1.Contains("\"h\""))
                    {
                        string   strTemp = pageSource1.Substring(pageSource1.IndexOf("\"h\""), 200);
                        string[] ArrTemp = strTemp.Split('"');
                        h = ArrTemp[3];
                    }
                    if (pageSource1.Contains("post_form_id") && pageSource1.Contains("fb_dtsg"))
                    {
                        string   strTemp = pageSource1.Substring(pageSource1.IndexOf("post_form_id"), 200);
                        string[] ArrTemp = strTemp.Split('"');
                        post_form_id = ArrTemp[2];
                        fb_dtsg      = ArrTemp[6];
                    }

                    Chilkat.HttpRequest reqLogout = new Chilkat.HttpRequest();
                    reqLogout.UsePost();
                    //req.Path = "/login.php?login_attempt=1";
                    reqLogout.RemoveAllParams();
                    reqLogout.AddHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16");
                    //req.SetFromUrl("http://www.facebook.com/login.php?login_attempt=1");

                    reqLogout.AddParam("post_form_id", post_form_id);
                    reqLogout.AddParam("fb_dtsg", fb_dtsg);
                    reqLogout.AddParam("ref", "mb");
                    reqLogout.AddParam("h", h);

                    Chilkat.HttpResponse respUsingPostURLEncoded = http.PostUrlEncoded("http://www.facebook.com/logout.php", reqLogout);
                    string ResponseLoginPostURLEncoded           = respUsingPostURLEncoded.BodyStr;

                    string pageSource12 = http.QuickGetStr("http://www.facebook.com/");


                    return(true);
                }

                return(false);
            }
            catch (Exception ex)
            {
                return(false);

                Console.WriteLine(ex.Message);
            }
        }
示例#7
0
        // Exchange the Request Token and OAuth Verifier for an Access Token
        private void button2_Click(object sender, EventArgs e)
        {
            Chilkat.OAuth1 oauth = new Chilkat.OAuth1();

            oauth.GenNonce(16);
            oauth.GenTimestamp();

            // The 1st step is to get a request token by sending an HTTP GET like this:
            oauth.OauthVersion    = "1.0";
            oauth.OauthMethod     = "GET";
            oauth.OauthUrl        = "https://api.login.yahoo.com/oauth/v2/get_token";
            oauth.ConsumerKey     = ConsumerKey;
            oauth.ConsumerSecret  = ConsumerSecret;
            oauth.Token           = OAuthToken;
            oauth.TokenSecret     = OAuthTokenSecret;
            oauth.SignatureMethod = "HMAC-SHA1";
            oauth.AddParam("oauth_verifier", txtVerifier.Text);

            // Generate the OAuth1 signature and URL.
            bool success = oauth.Generate();

            if (success != true)
            {
                textBox1.Text = oauth.LastErrorText;
                return;
            }

            string getAccessTokenUrl = oauth.GeneratedUrl + "&oauth_signature=" + oauth.EncodedSignature;

            Chilkat.Http http = new Chilkat.Http();

            // Get the request token...
            Chilkat.HttpResponse resp = http.QuickGetObj(getAccessTokenUrl);
            if (resp == null)
            {
                textBox1.Text = http.LastErrorText;
                return;
            }

            // Get the access token.
            string encodedResponseParams = resp.BodyStr;

            OAuthAccessToken       = resp.UrlEncParamValue(encodedResponseParams, "oauth_token");
            OAuthAccessTokenSecret = resp.UrlEncParamValue(encodedResponseParams, "oauth_token_secret");

            textBox1.Text = "success!\n";

            return;
        }
示例#8
0
        /// <summary>
        /// HttpPostCollectionDataQry() --> Performs an HTPP POST (for a CollectionData query) request using the Chilkat engine.
        /// Returns an HTTP string response.
        /// Basically gets a collection data from a table.
        /// </summary>
        /// <param name="tName">Indicates the name of the table from the Supplier Portal where the data will be read from</param>
        /// <param name="fn">Indicates the name of the field to query.</param>
        /// <param name="fv">Indicates the value of the field to query.</param>
        /// <param name="port">Indicates the port to make the HTTP request</param>
        /// <param name="ssl">If SSL is used or not (True or False)</param>
        /// <example><code>s.HttpPostCollectionDataQry("topimagesystems.com_CLS", "cln", "00000002", 80, false);</code></example>
        protected string HttpPostCollectionDataQry(string tName, string fn, string fv, int port, bool ssl)
        {
            string response = String.Empty;

            try
            {
                if (tName != String.Empty && fn != String.Empty && fv != String.Empty)
                {
                    Chilkat.HttpRequest req = new Chilkat.HttpRequest();

                    using (Chilkat.Http http = new Chilkat.Http())
                    {
                        http.UnlockComponent(Constants.cStrChilkatHttpLic);

                        req.UsePost();
                        req.Path = Constants.cStrHttpPostCollectionDataQuery;

                        req.AddParam(Constants.cStrHttpPostCollectionDatatName, tName);

                        req.AddParam(Constants.cStrHttpPostCollectionDataFn, fn);

                        if (fn == Constants.cStrHttpPostCollectionDatacollectionNameQryCln)
                        {
                            req.AddParam(Constants.cStrHttpPostCollectionDataFv, Constants.cStrCollectionDataNamePrefix + fv);
                        }
                        else
                        {
                            req.AddParam(Constants.cStrHttpPostCollectionDataFv, fv);
                        }

                        Chilkat.HttpResponse resp = http.SynchronousRequest(Constants.cStrDomain, port, ssl, req);
                        response = (resp == null) ? http.LastErrorText : resp.BodyStr;
                    }
                }
            }
            catch (Exception ex)
            {
                response = ex.ToString();
                Logging.WriteLog(response);
            }

            return(response);
        }
示例#9
0
        /// <summary>
        /// HttpPostCollectionDataSimple() --> Performs an HTPP POST (for CollectionData) request using the Chilkat engine. Returns an HTTP string response.
        /// </summary>
        /// <param name="tName">Indicates the name of the table from the Supplier Portal where the data will be written to</param>
        /// <param name="collectionName">Indicates the name of the collection for which the request is valid.</param>
        /// <param name="cVersion">Indicates the version of the collection for which the request is valid.</param>
        /// <param name="users">The users from the domains which are allowed to 'view' the data posted.</param>
        /// <param name="strData">The data to POST in string format.</param>
        /// <param name="port">Indicates the port to make the HTTP request</param>
        /// <param name="ssl">If SSL is used or not (True or False)</param>
        /// <example><code>s.HttpPostCollectionDataSimple("topimagesystems.com_CLS", "00000323", 1, "TEST1|SYSTEM|CLS|00000323|FreeProcess|1|Invoice_Date=|Invoice_Number=|Net_Amount1=|PO_Number=963645|Supplier_Name=|Total_Amount=0.00|VAT_Amount1=|VAT1=|speedyservices.com_CLS-00000323.tif", 80, false);</code></example>
        protected string HttpPostCollectionDataSimple(string tName, string collectionName, int cVersion, string strData, int port, bool ssl)
        {
            string response = String.Empty;

            try
            {
                if (tName != String.Empty && collectionName != String.Empty && strData != String.Empty)
                {
                    Chilkat.HttpRequest req = new Chilkat.HttpRequest();

                    using (Chilkat.Http http = new Chilkat.Http())
                    {
                        http.UnlockComponent(Constants.cStrChilkatHttpLic);

                        req.UsePost();
                        req.Path = Constants.cStrHttpPostCollectionDataUrl;

                        req.AddParam(Constants.cStrHttpPostCollectionDatatName, tName);

                        req.AddParam(Constants.cStrHttpPostCollectionDatacollectionName,
                                     Constants.cStrCollectionDataNamePrefix + collectionName);

                        req.AddParam(Constants.cStrHttpPostCollectionDatacollectionNameQryCln,
                                     Constants.cStrCollectionDataNamePrefix + collectionName);

                        req.AddParam(Constants.cStrHttpPostCollectionDatastrData, strData);

                        Chilkat.HttpResponse resp = http.SynchronousRequest(Constants.cStrDomain, port, ssl, req);
                        response = (resp == null) ? http.LastErrorText : resp.BodyStr;
                    }
                }
            }
            catch (Exception ex)
            {
                response = ex.ToString();
                Logging.WriteLog(response);
            }

            return(response);
        }
        /// <summary>
        /// applica la marca temporale al file
        /// </summary>
        /// <param name="pathFileSign">file firmato</param>
        /// <param name="tsaUrl">url TSA</param>
        /// <param name="pathFileTimeStamped">file tsr da TSA</param>
        /// <param name="lastError">ultimo errore nella funzionalità</param>
        /// <param name="userName">user TSA (opzionale)</param>
        /// <param name="password">password TSA (opzionale)</param>
        /// <returns>true se la funzionalità ha avuto successo</returns>
        /// <example>
        ///  if (Utilities.MarcaTemporale(@"c:\temp\IT01234567890_FPA01.xml.p7m", "https://freetsa.org/tsr", out pathFileTimeStamped, ref lastError, "myUser", "myPassword"))
        ///  {
        ///       pathFileTimeStamped -> c:\temp\IT01234567890_FPA01.xml.p7m.tsr
        ///  }
        /// </example>
        public static bool MarcaTemporale(string pathFileSign, string tsaUrl, out string pathFileTimeStamped, ref string lastError, string userName = null, string password = null)
        {
            bool success = false;

            pathFileTimeStamped = null;
            try
            {
                string fileName = Path.GetFileName(pathFileSign);



                if (Utilities.glob.UnlockStatus == 0)
                {
                    lastError = "Licenza bloccata";
                    return(success);
                }

                Chilkat.Crypt2 crypt = new Chilkat.Crypt2();
                crypt.HashAlgorithm = "sha256";
                crypt.EncodingMode  = "base64";

                string base64Hash = crypt.HashFileENC(pathFileSign);

                Chilkat.Http http = new Chilkat.Http();

                Chilkat.BinData requestToken      = new Chilkat.BinData();
                string          optionalPolicyOid = string.Empty;
                bool            addNonce          = false;
                bool            requestTsaCert    = false;

                if (!string.IsNullOrWhiteSpace(userName) && !string.IsNullOrWhiteSpace(password))
                {
                    http.Login     = userName;
                    http.Password  = password;
                    http.BasicAuth = true;
                }

                //  Create a time-stamp request token
                success = http.CreateTimestampRequest("sha256", base64Hash, optionalPolicyOid, addNonce, requestTsaCert, requestToken);
                if (!success)
                {
                    lastError = http.LastErrorText;
                    return(success);
                }


                Chilkat.HttpResponse resp = http.PBinaryBd("POST", tsaUrl, requestToken, "application/timestamp-query", false, false);
                if (!http.LastMethodSuccess)
                {
                    lastError = http.LastErrorText;
                    return(success);
                }


                Chilkat.BinData timestampReply = new Chilkat.BinData();
                resp.GetBodyBd(timestampReply);
                if (!timestampReply.LastMethodSuccess)
                {
                    return(success);
                }


                string s = Path.ChangeExtension(fileName, $".{Enum.GetName(typeof(EstensioniFile), EstensioniFile.tsr)}");
                success = timestampReply.WriteFile(s);
                if (success)
                {
                    pathFileTimeStamped = s;
                }
            }
            catch
            {
                throw;
            }

            return(success);
        }
示例#11
0
        /// <summary>
        /// HttpPostCollectionDataDeleteAll() --> Performs an HTPP POST (for a CollectionData delete) request using the Chilkat engine. Returns an HTTP string response. ALL instances of collection data matching 'collectionName' WILL BE DELETED!
        /// </summary>
        /// <param name="tName">Indicates the name of the table from the Supplier Portal where the data will be DELETED from</param>
        /// <param name="collectionName">Indicates the name of the collection for which the request is valid.</param>
        /// <param name="port">Indicates the port to make the HTTP request</param>
        /// <param name="ssl">If SSL is used or not (True or False)</param>
        /// <example><code>s.HttpPostCollectionDataDeleteAll("topimagesystems.com_CLS", "00000323", 80, false);</code></example>
        protected string HttpPostCollectionDataDeleteAll(string tName, string collectionName, int port, bool ssl)
        {
            string response = String.Empty;

            try
            {
                if (tName != String.Empty && collectionName != String.Empty)
                {
                    Chilkat.HttpRequest req = new Chilkat.HttpRequest();

                    using (Chilkat.Http http = new Chilkat.Http())
                    {
                        http.UnlockComponent(Constants.cStrChilkatHttpLic);

                        req.UsePost();
                        req.Path = Constants.cStrHttpPostCollectionDataDeleteAll;

                        req.AddParam(Constants.cStrHttpPostCollectionDatatName, tName);
                        req.AddParam(Constants.cStrHttpPostCollectionDatacollectionName,
                                     Constants.cStrCollectionDataNamePrefix + collectionName);

                        Chilkat.HttpResponse resp = null;

                        try
                        {
                            resp = http.SynchronousRequest(Constants.cStrDomain, port, ssl, req);
                        }
                        catch (AccessViolationException exVio)
                        {
                            Logging.WriteLog(exVio.ToString());
                        }
                        catch (Exception ex)
                        {
                            Logging.WriteLog(ex.ToString());
                        }

                        Thread.Sleep(50);

                        if (resp == null)
                        {
                            try
                            {
                                resp = http.SynchronousRequest(Constants.cStrDomain, port, ssl, req);
                            }
                            catch (AccessViolationException exVio)
                            {
                                Logging.WriteLog(exVio.ToString());
                            }
                            catch (Exception ex)
                            {
                                Logging.WriteLog(ex.ToString());
                            }

                            response = (resp == null) ? http.LastErrorText : resp.BodyStr;
                        }
                        else
                        {
                            response = (resp == null) ? http.LastErrorText : resp.BodyStr;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                response = ex.ToString();
                Logging.WriteLog(response);
            }

            return(response);
        }
        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;
            }
            }
        }