コード例 #1
0
        /// <summary>
        /// 外发
        /// </summary>
        public void Send()
        {
            CSConversationBLL conversationBll = new CSConversationBLL(loggingSessionInfo);
            var conversations = conversationBll.Query(new IWhereCondition[]
            {
                new DirectCondition("IsPush=0 or IsPush is NULL")
            }, new[]
            {
                new OrderBy
                {
                    FieldName = "CreateTime",
                    Direction = OrderByDirections.Desc
                }
            });

            foreach (var conversationEntity in conversations)
            {
                CSMessageBLL    messageBll    = new CSMessageBLL(loggingSessionInfo);
                CSMessageEntity messageEntity = messageBll.GetByID(conversationEntity.CSMessageID);
                try
                {
                    switch (messageEntity.CSPipelineID)
                    {
                    //微信
                    case 1:
                        IPushMessage pushWXMessage = new PushWeiXinMessage(loggingSessionInfo);
                        pushWXMessage.PushMessage(conversationEntity.PersonID, conversationEntity.Content);
                        break;

                    //短信
                    case 2:
                        IPushMessage pushSMSMessage = new PushSMSMessage(loggingSessionInfo);
                        pushSMSMessage.PushMessage(conversationEntity.PersonID, conversationEntity.Content);
                        break;

                    //IOS
                    case 3:
                        IPushMessage pusIOSMessage = new PushIOSMessage(loggingSessionInfo);
                        pusIOSMessage.PushMessage(conversationEntity.PersonID, conversationEntity.Content);
                        break;

                    //Android
                    case 4:
                        IPushMessage pusAndroidMessage = new PushAndroidMessage(loggingSessionInfo);
                        pusAndroidMessage.PushMessage(conversationEntity.PersonID, conversationEntity.Content);
                        break;
                    }
                    //更新已经推送
                    conversationEntity.IsPush = 1;
                    conversationBll.Update(conversationEntity);
                }
                catch (Exception ex)
                {
                    Loggers.DEFAULT.Debug(new DebugLogInfo
                    {
                        Message = "离线消息推送错误:" + ex.Message + "|" + conversationEntity.PersonID + "/" + messageEntity.CSPipelineID + "/" + conversationEntity.ToJSON()
                    });
                }
            }
        }
コード例 #2
0
        public void PushMessage(LoggingSessionInfo loggingSessionInfo, dynamic paramter)
        {
            DynamicInterfaceBLL dynamicInterfaceBLL = new DynamicInterfaceBLL(loggingSessionInfo);
            var eventList = dynamicInterfaceBLL.getEventList(new ReqData <getActivityListEntity>()
            {
                common = new ReqCommonData()
                {
                    customerId = loggingSessionInfo.ClientID
                }, special = new getActivityListEntity()
                {
                    type = "new", page = 1, pageSize = 5
                }
            });

            if (eventList.ItemList != null && eventList.ItemList.Length > 0)
            {
                int    channelID = 0;
                string message   = "";

                PrepareMessage(loggingSessionInfo, paramter, out channelID, out message);

                if (channelID > 0 && !string.IsNullOrEmpty(message))
                {
                    string method = "Process";
                    //Android消息推送
                    //  string url = "http://121.199.42.125:9000/PushService.svc";
                    string url = System.Configuration.ConfigurationManager.AppSettings["pushMessageUrl"];
                    //string url = "http://localhost:1475/PushService.svc";

                    //3488619   为中欧校友汇在百度推送中的ID
                    message += "#http://url.cn/TzrnuO"; //短链接
                    //http://dev.o2omarketing.cn:9004/HtmlApps/html/public/xiehuibao/activity.html?customerId=75a232c2cf064b45b1b6393823d2431e&type=new";
                    PushRequest pRequest2 = RequestBuilder.CreateAndroidUnicastMessageRequest(1, channelID, "", "3488619", message, PushTypes.Broadcast);

                    var json      = "{\"pRequest\":" + pRequest2.ToJSON() + "}";
                    var response2 = PushIOSMessage.SendHttpRequest(url, method, json);
                }
            }
            else
            {
                SendMarketingMessageBLL.log.WriteEntry("无新活动", System.Diagnostics.EventLogEntryType.Information);
            }
        }
コード例 #3
0
        public void PushMessage(string memberID, string messageContent)
        {
            PushAndroidBasicBLL pushBll = new PushAndroidBasicBLL(loggingSessionInfo);
            var userBasic = pushBll.GetByID(memberID);

            if (userBasic != null)
            {
                if (!string.IsNullOrEmpty(userBasic.UserIDBaiDu) && !string.IsNullOrEmpty(userBasic.ChannelIDBaiDu))
                {
                    string method = "Process";
                    //Android消息推送
                    //string url = "http://121.199.42.125:9000/PushService.svc";
                    string url       = System.Configuration.ConfigurationManager.AppSettings["pushMessageUrl"];
                    int    channelId = 1;
                    if (!string.IsNullOrEmpty(userBasic.Channel))
                    {
                        channelId = Convert.ToInt32(userBasic.Channel);
                    }
                    PushRequest pRequest2 = RequestBuilder.CreateAndroidUnicastNotificationRequest(2, channelId, userBasic.UserIDBaiDu, userBasic.ChannelIDBaiDu, "消息", messageContent);
                    var         json      = "{\"pRequest\":" + pRequest2.ToJSON() + "}";
                    var         response2 = PushIOSMessage.SendHttpRequest(url, method, json);
                    var         msg       = "会员ID:" + memberID + " DeviceToken:" + userBasic.DeviceToken;
                    Loggers.DEFAULT.Debug(new DebugLogInfo
                    {
                        Message = msg + "  消息发送Android结果: " + response2
                    });
                }
                else
                {
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = string.Format("PushMessage: {0}", "VipID:" + memberID + "没有保存百度推送消息参数")
                    });
                }
            }
        }