Ejemplo n.º 1
0
        /// <summary>
        /// used to send SMS to selected users.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>number of success and failure</returns>
        public string SendSMSHelper(SMSReport obj)
        {
            string result = string.Empty;

            result = _objSMSSender.GetSMSSender(obj);
            return(result);
        }
        protected static void PrintFirstReportDetails(SMSReportResponse response)
        {
            SMSReport report = response.Results[0];

            Console.WriteLine("-------------------------------");
            Console.WriteLine("Message ID: " + report.MessageId);
            Console.WriteLine("Sent at: " + report.SentAt.ToLocalTime());
            Console.WriteLine("Receiver: " + report.To);
            Console.WriteLine("Status: " + report.Status.Name);
            Console.WriteLine("Price: " + report.Price.PricePerMessage + " " + report.Price.Currency);
            Console.WriteLine("-------------------------------");
        }
Ejemplo n.º 3
0
        public bool?SMS_IS_Receive(string snum)
        {
            List <SMSReport> list = GetReceivedReports();
            bool?            res  = null;
            SMSReport        r    = list.FirstOrDefault(s => s.snum == snum);

            if (r != null)
            {
                res = r.IsSuccess();
                RemoveReports(r);
            }
            return(res);
        }
Ejemplo n.º 4
0
        public JsonResult InsertSelectedRecords(SMSReport obj)
        {
            string result          = string.Empty;
            string Mobile_Number   = string.Empty;
            string MessageReceived = string.Empty;

            foreach (var item in obj.lstModel)
            {
                item.Message = item.Message.Replace("</br>", "\n");
            }

            result = SendSMSHelper(obj);
            return(Json(result));
        }
Ejemplo n.º 5
0
        public void sendSmsTest()
        {
            if (string.IsNullOrEmpty(TestConfig.TEST_MOBILE_NUMBER) ||
                string.IsNullOrEmpty(TestConfig.TEST_SMS_MESSAGE))
            {
                return;
            }
            SMSReport report = client.sendSms(TestConfig.TEST_MOBILE_NUMBER, TestConfig.TEST_SMS_MESSAGE);

            Assert.IsNotNull(report.contentResponse);
            Assert.IsTrue(report.isSuccessful());
            Assert.AreEqual(TestConfig.TEST_SMS_MESSAGE, report.getMessage());
            Assert.AreEqual(TestConfig.TEST_MOBILE_NUMBER, report.getRecipient());
            Assert.IsNotNull(report.getCost());
        }
Ejemplo n.º 6
0
        private List <SMSReport> PullSMSReports()
        {
            List <SMSReport> list_tmp = new List <SMSReport>();
            SMSReturnCode    rcode    = SMS_Reports();

            if (rcode.IsSuccess)
            {
                try
                {
                    string[] tmps = rcode.ReturnString.Split('|');
                    if (tmps != null)
                    {
                        for (int i = 0; i < tmps.Length; i++)
                        {
                            string tmp = tmps[i];
                            if (string.IsNullOrWhiteSpace(tmp))
                            {
                                continue;
                            }
                            string[] tmparr = tmp.Split('/');
                            if (tmparr.Length == 5)
                            {
                                SMSReport report = new SMSReport()
                                {
                                    snum  = tmparr[0].Trim(),
                                    uid   = tmparr[1],
                                    phone = tmparr[2],
                                    state = tmparr[3],
                                    time  = DateTime.ParseExact(tmparr[4], "yyyy-M-d H:mm:ss", CultureInfo.InvariantCulture)
                                };
                                list_tmp.Add(report);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Warn(rcode.ReturnString);
                    LogHelper.Error("PullSMSReports", ex);
                }
            }
            return(list_tmp);
        }
Ejemplo n.º 7
0
        public void RemoveReports(params SMSReport[] reports)
        {
            if (reports.Length == 0)
            {
                return;
            }
            List <SMSReport> list = GetReceivedReports(false);

            lock (lockObj)
            {
                try
                {
                    for (int i = 0; i < reports.Length; i++)
                    {
                        SMSReport r = reports[i];
                        if (list.Contains(r))
                        {
                            list.Remove(r);
                        }
                        else
                        {
                            r = list.FirstOrDefault(s => s.snum == r.snum);
                            if (r != null)
                            {
                                list.Remove(r);
                            }
                        }
                    }
                    list.RemoveAll(s => (DateTime.Now - s.time).TotalDays > 100);
                    File.WriteAllText("SMSReport", JsonConvert.SerializeObject(list));
                }
                catch (Exception ex)
                {
                    LogHelper.Error("移除短信报告文件错误", ex);
                }
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// gets the url from GetProviderInfo
 /// sends the url and the list of users to SendSMS
 /// </summary>
 /// <param name="obj"></param>
 /// <returns>sent sms success count and failure count</returns>
 public string GetSMSSender(SMSReport obj)
 {
     return(SendSMS(obj.lstModel));
 }