Exemple #1
0
        /// <summary>
        /// 创建单播的消息(消息类型=通知)推送请求
        /// </summary>
        /// <param name="pType">类型:1-直接发送,其它放入数据库轮循</param>
        /// <param name="pChannelID">对应MessageChannel表中的ID</param>
        /// <param name="pBaiduUserID">百度用户ID</param>
        /// <param name="pBaiduChannelID">百度通道ID</param>
        /// <param name="pMessage">百度推送的对象</param>
        /// <returns></returns>
        public static PushRequest CreateAndroidUnicastNotificationRequest(int pType, int pChannelID, string pBaiduUserID
                                                                          , string pBaiduChannelID
                                                                          , BaiduPushNotification pMessage)
        {
            PushRequest mes = new PushRequest();

            mes.PlatForm  = 1;
            mes.Type      = pType;
            mes.ChannelID = pChannelID;
            mes.Request   = PushMsgRequestBuilder.CreateUnicastNotificationRequest(pBaiduUserID, pBaiduChannelID, pMessage).ToJSON();
            return(mes);
        }
Exemple #2
0
        /// <summary>
        /// 创建单播的消息(消息类型=消息)推送请求
        /// </summary>
        /// <param name="pType">类型:1-直接发送,其它放入数据库轮循</param>
        /// <param name="pChannelID">对应MessageChannel表中的ID</param>
        /// <param name="pBaiduUserID">百度用户ID</param>
        /// <param name="pBaiduChannelID">百度通道ID</param>
        /// <param name="pMessage">消息内容</param>
        /// <returns></returns>
        public static PushRequest CreateAndroidUnicastMessageRequest(int pType, int pChannelID, string pBaiduUserID
                                                                     , string pBaiduChannelID
                                                                     , string pMessage
                                                                     , PushTypes pushType = PushTypes.Unicast)
        {
            PushRequest mes = new PushRequest();

            mes.PlatForm  = 1;
            mes.Type      = pType;
            mes.ChannelID = pChannelID;
            mes.Request   = PushMsgRequestBuilder.CreateUnicastMessageRequest(pBaiduUserID, pBaiduChannelID, null, pMessage, null, pushType).ToJSON();
            return(mes);
        }
Exemple #3
0
        void bw_DoWork1(object sender, DoWorkEventArgs e)
        {
            while (true)
            {
                try
                {
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = "审批订单-查询数据库"
                    });
                    MessageDAO        mdao       = new MessageDAO(new BasicUserInfo());
                    OrdersCheckingDAO dao        = new OrdersCheckingDAO(new BasicUserInfo());
                    ClientUserDAO     userDao    = new ClientUserDAO(new BasicUserInfo());
                    MessageChannelDAO channelDao = new MessageChannelDAO(new BasicUserInfo());
                    var entitys = dao.GetValidOrdersChecking();
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = "审批订单-找到" + entitys.Count() + "条数据"
                    });
                    foreach (var item in entitys)
                    {
                        Dictionary <ClientUserEntity, string> messages;
                        var userEntitys = userDao.GetValidUserByStatus0(item, out messages);
                        foreach (var it in userEntitys)
                        {
                            if (!string.IsNullOrEmpty(it.PushChannel))
                            {
                                PushChannel   info     = it.PushChannel.DeserializeJSONTo <PushChannel>();
                                var           pRequest = PushMsgRequestBuilder.CreateUnicastNotificationRequest(info.BaiduUserID, info.BaiduChannelID, "订单审批通知", messages[it]);
                                MessageEntity mEntity  = new MessageEntity();
                                mEntity.MessageID = Guid.NewGuid();
                                mEntity.ChannelID = 1;
                                mEntity.ClientID  = it.ClientID.Value.ToString();
                                mEntity.UserID    = it.ClientUserID.Value.ToString();
                                var request     = pRequest;
                                var messagetype = request.InnerDictionary["message_type"].ToString();
                                //判断消息类型0-消息,1-通知
                                switch (messagetype)
                                {
                                case "0":
                                    mEntity.MessageContent = request.InnerDictionary["messages"].ToString();
                                    break;

                                case "1":
                                    mEntity.MessageContent = request.InnerDictionary["messages"].ToJSON().DeserializeJSONTo <BaiduPushNotification>().Description;
                                    break;
                                }
                                mEntity.MessageParameters = pRequest.InnerDictionary.ToJSON();
                                mEntity.SendCount         = 0;
                                mEntity.Status            = 0;
                                mdao.Create(mEntity);
                                Loggers.Debug(new DebugLogInfo()
                                {
                                    Message = "【保存数据库成功】:" + mEntity.MessageParameters
                                });
                                item.SendStatus = 1;
                                dao.Update(item);
                            }
                            else
                            {
                                Loggers.Debug(new DebugLogInfo()
                                {
                                    Message = string.Format("用户{0}-{1}的PushChanel为空", it.ClientUserID, it.Username)
                                });
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Loggers.Exception(new ExceptionLogInfo(ex));
                }
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("审批订单-轮循结束,等待{0}秒", Interval)
                });
                Thread.Sleep(TimeSpan.FromSeconds(Interval));
            }
        }