Ejemplo n.º 1
0
 public ActionResult SendPeoConfig()
 {
     Utility.XmlHelper helper = new Utility.XmlHelper("OrderFood", "SendPeoConfig");
     ViewBag.Phones     = helper.GetElement("Phones")?.Value ?? "";
     ViewBag.SendHour   = helper.GetElement("SendHour")?.Value ?? "9";
     ViewBag.SendMinute = helper.GetElement("SendMinute")?.Value ?? "0";
     return(PartialView());
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取通知人手机号
        /// </summary>
        /// <returns></returns>
        private List <string> GetSendPeoAdminId()
        {
            Utility.XmlHelper helper = new Utility.XmlHelper("OrderFood", "SendPeoConfig");
            var xmlphones            = helper.GetElement("Phones");
            var listphones           = (xmlphones?.Value ?? "").Split(new string[] { ",", ",", "\n" }, StringSplitOptions.RemoveEmptyEntries).Where(w => w.IsMobileNumber(true)).ToList();

            return(listphones);
        }
Ejemplo n.º 3
0
        private static void SendOrderFoodSms()
        {
            ThreadPool.QueueUserWorkItem((x) =>
            {
                var prevTime = DateTime.Now.Date.AddDays(-1);
                while (true)
                {
                    var now = DateTime.Now;
                    if (prevTime != now.Date)
                    {
                        Utility.XmlHelper helper = new Utility.XmlHelper("OrderFood", "SendPeoConfig");
                        var xmlphones            = helper.GetElement("Phones");
                        int Hour     = 9; int.TryParse(helper.GetElement("SendHour")?.Value ?? "9", out Hour);
                        int Minute   = 0; int.TryParse(helper.GetElement("SendMinute")?.Value ?? "0", out Minute);
                        var sendTime = now.Date.AddHours(Hour).AddMinutes(Minute);

                        if (now >= sendTime)
                        {
                            var listphones = (xmlphones?.Value ?? "").Split(new string[] { ",", ",", "\n" }, StringSplitOptions.RemoveEmptyEntries).Where(w => w.IsMobileNumber(true)).ToList();
                            if (QueueAttribute.SendOrderFoodSms(listphones))
                            {
                                prevTime = now.Date;
                            }
                            else
                            {
                                Thread.Sleep(30000);
                            }
                        }
                        else
                        {
                            Thread.Sleep(30000);
                        }
                    }
                    else
                    {
                        Thread.Sleep(now.Date.AddDays(1) - now);
                    }
                }
            });
        }