Exemplo n.º 1
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            txtLog.Text = string.Empty;
            var url      = string.Empty;
            var response = string.Empty;

            try
            {
                Application.DoEvents();
                Cursor = Cursors.WaitCursor;

                switch (Schedule.MobileProvider.ToLowerInvariant())
                {
                case "magti":
                    Schedule.Ping();

                    url      = MagtiHttpToSMS.GetFormatedURL(Schedule.MagtiUserName, Schedule.MagtiPassword, Schedule.MagtiClientID, txtMobile.Text, txtMessage.Text);
                    response = HttpToSMSBase.SendWebRequest(url);
                    break;
                }
            }
            catch (Exception ex)
            {
                ExceptionHelper.Show(ex);
            }
            finally
            {
                Cursor = Cursors.Default;
            }

            txtLog.Text = @"URL: " + url + @"
Respponse: " + response;
        }
Exemplo n.º 2
0
        public void RunDebtSms()
        {
            if (!Check())
            {
                return;
            }


            using (var ctx = new DBEntities())
            {
                var result = ctx.SP_Debt_GetForSend().ToList();
                Ping();
                EventLogHelper.WriteEntry($"Debt SMS {result.Count} Started");
                var count = 0;
                foreach (var item in result)
                {
                    var url      = string.Empty;
                    var response = string.Empty;
                    var statusID = SMSStatus.None;
                    try
                    {
                        switch (MobileProvider.ToLowerInvariant())
                        {
                        case "magti":
                            url      = MagtiHttpToSMS.GetFormatedURL(MagtiUserName, MagtiPassword, MagtiClientID, item.Mobile, item.Message);
                            response = HttpToSMSBase.SendWebRequest(url);
                            if (response.StartsWith(MagtiHttpToSMS.SmscReturnCodes.Successfull))
                            {
                                count++;
                                statusID = SMSStatus.Sent;
                            }
                            else
                            {
                                statusID = SMSStatus.Error;
                            }

                            ctx.SP_Debt_Save(item.ID, item.MobileID, (byte)statusID);
                            ctx.SP_T_DebtDetailLog_Save(item.ID, item.MobileID, url, response.SafeSubstring(0, 25), string.Empty);
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        if (statusID == SMSStatus.None)//თუ მანამდე მოხდა შეცდომა ვიდრე ჩაწერდა ლოგს ასეთ შემთხვევაში უნდა გაიზარდოს +1 -ით
                        {
                            ctx.SP_Debt_Save(item.ID, item.MobileID, (byte)SMSStatus.Error);
                        }
                        ctx.SP_T_DebtDetailLog_Save(item.ID, item.MobileID, url, response.SafeSubstring(0, 25), ex.ToString());
                    }
                }
                EventLogHelper.WriteEntry($"Debt SMS {count}/{result.Count} Completed");
            }
        }