Esempio n. 1
0
        private void sms_queue_command_init()
        {
            var sw = Stopwatch.StartNew();

            List <Cache> requests = get_request();

            foreach (Cache cache in requests)
            {
                CMDTransaction cmd = Json.Send(cache.from, cache.command);

                if (EnableReceiverOnly)
                {
                    Logs(200, string.Format("Response: {0} -> {1}", cmd.account, cmd.message));

                    bool delete_cache = MySqlQuery.execute("DELETE FROM ptxt_cache WHERE Id = " + cache.Id + ";");
                }
                else
                {
                    Queued queue = new Queued()
                    {
                        company_uid = cache.company_uid,
                        mobile      = cmd.account,
                        message     = cmd.message,
                        status      = 1
                    };

                    bool save_notification = Notification.Send(queue);

                    bool delete_cache = MySqlQuery.execute("DELETE FROM ptxt_cache WHERE Id = " + cache.Id + ";");

                    total_process++;

                    sw.Stop();

                    decimal total_time_in_seconds = sw.ElapsedMilliseconds / 60;

                    Console.WriteLine("Batch: {0} and Time Executed {1} seconds", total_process, total_time_in_seconds);

                    Logs(200, string.Format("Batch: {0} and Time Executed {1} seconds", total_process, total_time_in_seconds));
                }
            }

            //Logs(200, "Running....");
        }
Esempio n. 2
0
        public static CMDTransaction Send(string account, string command)
        {
            CMDTransaction trans = new CMDTransaction();

            string url_path = ApiUrl + "/api/v1/load/command/sms/" + AccessToken + "?";

            string url = url_path + "account=" + account + "&command=" + command.Replace(" ", "%20");

            if (Request.EnableReceiverOnly)
            {
                url += "&method=1";
            }

            try
            {
                WebClient client = new WebClient();
                string    value  = client.DownloadString(url);
                trans = JsonConvert.DeserializeObject <CMDTransaction>(value);
            }
            catch (Exception ex)
            { }
            return(trans);
        }