示例#1
0
        /// <summary>
        /// 接待推送
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void bw_DoWorkJd(object sender, DoWorkEventArgs e)
        {
            while (true)
            {
                try
                {
                    ConfigurationManager.RefreshSection("appSettings");
                    var time = ConfigurationManager.AppSettings["Timing"];

                    //支持配置多客户
                    string[] customerIDs = ConfigurationManager.AppSettings["CustomerIDs"].Split(',');
                    foreach (string customerID in customerIDs)
                    {
                        loggingSessionInfo = GetLoggingSession(customerID, "PushService");

                        var       vipBll      = new VipBLL(loggingSessionInfo);       //会员BLL实例化
                        var       orderBll    = new Car_OrderBLL(loggingSessionInfo); //订单BLL实例化
                        var       orderEntity = new Car_OrderEntity();
                        VipEntity vipEntity   = null;

                        //查询参数
                        List <IWhereCondition> complexCondition = new List <IWhereCondition> {
                        };
                        complexCondition.Add(new LessThanCondition()
                        {
                            FieldName        = "ReserveTime",
                            Value            = DateTime.Now.AddMinutes(15),
                            IncludeEquals    = true,
                            DateTimeAccuracy = DateTimeAccuracys.DateTime
                        }); //
                        complexCondition.Add(new MoreThanCondition()
                        {
                            FieldName        = "ReserveTime",
                            Value            = DateTime.Now,
                            IncludeEquals    = true,
                            DateTimeAccuracy = DateTimeAccuracys.DateTime
                        }); //
                        complexCondition.Add(new LessThanCondition()
                        {
                            FieldName = "Status", Value = 3
                        });                                                                                                                          //????
                        complexCondition.Add(new DirectCondition(" ((PushStatus = '1' or (VipID is null or VipID = '')) and PushStatus != '15') ")); //未推送
                        //排序参数
                        List <OrderBy> lstOrder = new List <OrderBy> {
                        };
                        lstOrder.Add(new OrderBy()
                        {
                            FieldName = "ReserveTime", Direction = OrderByDirections.Asc
                        });
                        //orderEntity = orderBll.QueryByEntity(new Car_OrderEntity { ReserveTime > DateTime.Now }, null);
                        var tempOrderList = orderBll.Query(complexCondition.ToArray(), lstOrder.ToArray());
                        if (tempOrderList != null && tempOrderList.Length != 0)
                        {
                            //接待提前15分钟的订单消息推送
                            var orderPush = new InoutService(loggingSessionInfo);
                            orderPush.OrderPushMessage(tempOrderList[0].OrderID.ToString(), "15");

                            orderEntity            = orderBll.GetByID(tempOrderList[0].OrderID);
                            orderEntity.PushStatus = 15;
                            orderBll.Update(orderEntity);
                        }
                    }


                    //MessageDAO dao = new MessageDAO(new BasicUserInfo());
                    //MessageChannelDAO channelDao = new MessageChannelDAO(new BasicUserInfo());
                    //var entitys = dao.GetValidMessage();
                    //foreach (var item in entitys)
                    //{
                    //    try
                    //    {
                    //        var entity = channelDao.GetByID(item.ChannelID);
                    //        if (entity == null)
                    //        {
                    //            throw new Exception(string.Format("未找到相应的ChannelID为:{0}的Channel信息", item.ChannelID));
                    //        }
                    //        switch (entity.MobilePlatform)
                    //        {
                    //            case 1:
                    //                var request = item.GetRequest();
                    //                var baiduResponse = BaiduCloudPush.PushMessage(entity.GetBaiDuChannel(), request);
                    //                if (baiduResponse.IsSuccess)
                    //                {
                    //                    item.SendCount = (item.SendCount ?? 0) + 1;
                    //                    item.Status = 2;
                    //                    Loggers.Debug(new DebugLogInfo() { Message = "【发送成功】:" + item.MessageContent });
                    //                }
                    //                else
                    //                {
                    //                    item.SendCount = (item.SendCount ?? 0) + 1;
                    //                    item.Status = 1;
                    //                    item.FaultReason = baiduResponse.ErrorMessage;
                    //                    Loggers.Debug(new DebugLogInfo() { Message = "【发送失败】:" + item.MessageContent });
                    //                }
                    //                break;
                    //            case 2:
                    //                var IOSChannel = entity.GetIOSChannel();
                    //                var notification = item.GetIOSNotification();
                    //                var IOSResponse = IOSNotificationService.CreateInstance(IOSChannel.SandBox ?? true, IOSChannel.P12, IOSChannel.P12PWD).SendNotification(notification);
                    //                if (IOSResponse)
                    //                {
                    //                    item.SendCount = (item.SendCount ?? 0) + 1;
                    //                    item.Status = 2;
                    //                    Loggers.Debug(new DebugLogInfo() { Message = "【发送到推送服务器成功】:" + item.MessageContent });
                    //                }
                    //                else
                    //                {
                    //                    item.SendCount = (item.SendCount ?? 0) + 1;
                    //                    item.Status = 1;
                    //                    item.FaultReason = "发送到推送服务器失败";
                    //                    Loggers.Debug(new DebugLogInfo() { Message = "【发送到推送服务器成功】:" + item.MessageContent });
                    //                }
                    //                break;
                    //            default:
                    //                throw new Exception("错误的平台类型");
                    //        }


                    //        dao.Update(item);
                    //    }
                    //    catch (Exception ee)
                    //    {
                    //        item.SendCount = (item.SendCount ?? 0) + 1;
                    //        item.FaultReason = ee.Message;
                    //        item.Status = 1;
                    //        dao.Update(item);
                    //        Loggers.Exception(new ExceptionLogInfo(ee));
                    //        throw ee;
                    //    }
                    //}
                    Thread.Sleep(TimeSpan.FromSeconds(Interval));
                }
                catch (Exception ex)
                {
                    Loggers.Exception(new ExceptionLogInfo(ex));
                }
            }
        }
示例#2
0
        /// <summary>
        /// 微信推送
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void bw_DoWorkWx(object sender, DoWorkEventArgs e)
        {
            while (true)
            {
                try
                {
                    ConfigurationManager.RefreshSection("appSettings");
                    var time = ConfigurationManager.AppSettings["Timing"];

                    //支持配置多客户
                    string[] customerIDs = ConfigurationManager.AppSettings["CustomerIDs"].Split(',');
                    foreach (string customerID in customerIDs)
                    {
                        loggingSessionInfo = GetLoggingSession(customerID, "PushService");


                        //微信推送
                        var       vipBll      = new VipBLL(loggingSessionInfo);           //会员BLL实例化
                        var       orderBll    = new Car_OrderBLL(loggingSessionInfo);     //订单BLL实例化
                        var       orderEntity = new Car_OrderEntity();
                        VipEntity vipEntity   = null;


                        //查询参数
                        List <IWhereCondition> complexCondition = new List <IWhereCondition> {
                        };
                        complexCondition.Add(new LessThanCondition()
                        {
                            FieldName = "ReserveTime", Value = DateTime.Now.AddMinutes(30), IncludeEquals = true, DateTimeAccuracy = DateTimeAccuracys.DateTime
                        });                                                                                                                                                                                   //
                        complexCondition.Add(new MoreThanCondition()
                        {
                            FieldName = "ReserveTime", Value = DateTime.Now, IncludeEquals = true, DateTimeAccuracy = DateTimeAccuracys.DateTime
                        });                                                                                                                                                                    //
                        complexCondition.Add(new LessThanCondition()
                        {
                            FieldName = "Status", Value = 3
                        });                                                                //????
                        complexCondition.Add(new DirectCondition(" (PushStatus = '0') ")); //未推送
                        //排序参数
                        List <OrderBy> lstOrder = new List <OrderBy> {
                        };
                        lstOrder.Add(new OrderBy()
                        {
                            FieldName = "ReserveTime", Direction = OrderByDirections.Asc
                        });
                        //orderEntity = orderBll.QueryByEntity(new Car_OrderEntity { ReserveTime > DateTime.Now }, null);
                        var tempOrderList = orderBll.Query(complexCondition.ToArray(), lstOrder.ToArray());
                        if (tempOrderList != null && tempOrderList.Length != 0)
                        {
                            vipEntity = vipBll.GetByID(tempOrderList[0].VipID);

                            if (!string.IsNullOrEmpty(vipEntity.WeiXinUserId))
                            {
#if DEBUG
                                //var appService = new WApplicationInterfaceBLL(loggingSessionInfo);
                                //var appList = appService.QueryByEntity(new WApplicationInterfaceEntity { CustomerId = customerID }, null);
                                //if (appList != null && appList.Length > 0)
                                //{
                                //    var app = appList.FirstOrDefault();
                                //    if (app != null)
                                //    {
                                //        var commonBll = new CommonBLL();
                                //        commonBll.SendTemplateMessage(app.WeiXinID, "亲,距离您的爱车洗澡时间只有30分钟了,请尽快到店哦!");//模板消息
                                //    }
                                //}
#endif
                                if (tempOrderList[0].ServiceItemID == 1)//为洗车消息
                                {
                                    CommonBLL.SendWeixinMessage("亲,距离您的爱车洗澡时间只有30分钟了,请尽快到店哦!", tempOrderList[0].VipID, loggingSessionInfo, vipEntity);
                                }

                                orderEntity            = orderBll.GetByID(tempOrderList[0].OrderID);
                                orderEntity.PushStatus = 1;
                                orderBll.Update(orderEntity);
                            }
                        }
                    }

                    Thread.Sleep(TimeSpan.FromSeconds(Interval));
                }
                catch (Exception ex)
                {
                    Loggers.Exception(new ExceptionLogInfo(ex));
                }
            }
        }