Esempio n. 1
0
 public static void LegworkMessageBuy(long orderID)
 {
     try
     {
         var orderModel = OrderServices.GetLegworkOrder(orderID);
         var model      = UserServices.GetWorkerAccount(orderModel.WorkerID.HasValue ? orderModel.WorkerID.Value : 0);
         var pushRedis  = PushSettingFactory.Settings[PushType.LegworkMessageBuy];
         if (null != orderModel)
         {
             if (null != pushRedis)
             {
                 var msgContent = new MessageBuyPushContent()
                 {
                     OrderID    = orderModel.OrderID,
                     OrderCode  = orderModel.OrderCode,
                     PushCode   = model.PushCode,
                     CreateTime = DateTime.Now
                 };
                 pushRedis.Database.ListRightPush <MessageBuyPushContent>(pushRedis.Key, msgContent);
             }
         }
     }
     catch
     {
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 执行
        /// </summary>
        public override void Execute()
        {
            var ServiceTime = DateTime.Now;

            while (true)
            {
                try
                {
                    //从预约订单推送消息数据链表左边起获取一条数据
                    MessageBuyPushContent content = RedisDB.ListLeftPop <MessageBuyPushContent>(LegworkConfig.RedisKey.LegworkMessageBuy);

                    //不存在,则休眠1秒钟,避免CPU空转
                    if (null == content)
                    {
                        Thread.Sleep(100);
                        continue;
                    }

                    //获取预约订单推送接口配置信息
                    var apiConfig = PushApiConfigManager.GetApiConfig(SysEnums.PushType.LegworkMessageBuy);

                    if (null == apiConfig)
                    {
                        continue;
                    }

                    //将订单数据转换成为字典以便参与接口加密
                    var dic = content.ToMap();

                    if (apiConfig.Method == "get")
                    {
                        DefaultClient.DoGet(apiConfig.Url, dic, PushApiConfigManager.Config.ModuleID, PushApiConfigManager.Config.Secret);
                    }
                    else if (apiConfig.Method == "post")
                    {
                        DefaultClient.DoPost(apiConfig.Url, dic, PushApiConfigManager.Config.ModuleID, PushApiConfigManager.Config.Secret);
                        ExceptionLoger loger = new ExceptionLoger(@"/logs/Sccess" + DateTime.Now.ToString("yyyyMMdd") + ".txt");
                        loger.Success("提醒购买,推送给工作端推送时", "推送结果:订单编号为“" + content.OrderCode + "”");
                    }
                }
                catch (Exception ex)
                {
                    if (ServiceTime.AddHours(1) <= DateTime.Now)
                    {
                        ServiceTime = DateTime.Now;
                        //异常处理
                        ExceptionLoger loger = new ExceptionLoger(@"/logs/Error" + DateTime.Now.ToString("yyyyMMdd") + ".txt");
                        loger.Write("提醒购买,推送给工作端推送时异常", ex);
                    }
                    Thread.Sleep(100);
                    continue;
                }
            }
        }