Exemplo n.º 1
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 + "没有保存百度推送消息参数")
                    });
                }
            }
        }
Exemplo n.º 2
0
        protected override RemoveAndriodMessageBindRD ProcessRequest(DTO.Base.APIRequest <RemoveAndriodMessageBindRP> pRequest)
        {
            RemoveAndriodMessageBindRD rd = new RemoveAndriodMessageBindRD();

            string userId     = pRequest.Parameters.UserId;
            string customerId = pRequest.CustomerID;

            PushAndroidBasicBLL    service   = new PushAndroidBasicBLL(this.CurrentUserInfo);
            PushAndroidBasicEntity basicInfo = new PushAndroidBasicEntity();

            basicInfo = service.GetByID(userId);
            if (basicInfo == null)
            {
                throw new APIException("用户ID无效")
                      {
                          ErrorCode = 103
                      };
            }
            else
            {
                service.DeletePushAndroidBasicByUserId(userId);
            }
            return(rd);
        }
Exemplo n.º 3
0
        public string setAndroidBasic(string reqContent)
        {
            string content  = string.Empty;
            var    respData = new setAndroidBasicRespData();

            try
            {
                #region
                //解析请求字符串
                var rp = reqContent.DeserializeJSONTo <APIRequest <setAndroidBasicReqData> >();

                //判断客户ID是否传递
                string customerId = string.Empty;
                if (!string.IsNullOrEmpty(rp.CustomerID))
                {
                    customerId = rp.CustomerID;
                }
                var loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1");

                if (rp.Parameters.special == null)
                {
                    rp.Parameters.special = new setAndroidBasicReqSpecialData();
                }
                if (rp.Parameters.special == null)
                {
                    respData.code        = "102";
                    respData.description = "没有特殊参数";
                    return(respData.ToJSON().ToString());
                }

                if (rp.Parameters.special.channelId == null || rp.Parameters.special.channelId.Equals(""))
                {
                    respData.code        = "2201";
                    respData.description = "channelId不能为空";
                    return(respData.ToJSON().ToString());
                }
                if (rp.Parameters.special.appId == null || rp.Parameters.special.appId.Equals(""))
                {
                    respData.code        = "2201";
                    respData.description = "appId不能为空";
                    return(respData.ToJSON().ToString());
                }
                if (rp.Parameters.special.userId == null || rp.Parameters.special.userId.Equals(""))
                {
                    respData.code        = "2201";
                    respData.description = "百度的userId不能为空";
                    return(respData.ToJSON().ToString());
                }
                if (rp.UserID == null || rp.UserID.Equals(""))
                {
                    respData.code        = "2202";
                    respData.description = "userId不能为空";
                    return(respData.ToJSON().ToString());
                }
                #endregion

                PushAndroidBasicBLL    service   = new PushAndroidBasicBLL(loggingSessionInfo);
                PushAndroidBasicEntity basicInfo = new PushAndroidBasicEntity();
                basicInfo = service.GetByID(ToStr(rp.UserID));
                if (basicInfo == null)
                {
                    PushAndroidBasicEntity basicInfo1 = new PushAndroidBasicEntity();
                    basicInfo1.UserID         = ToStr(rp.UserID);
                    basicInfo1.Channel        = "1";
                    basicInfo1.ChannelIDBaiDu = ToStr(rp.Parameters.special.channelId);
                    basicInfo1.CustomerId     = ToStr(customerId);
                    basicInfo1.BaiduPushAppID = ToStr(rp.Parameters.special.appId);
                    basicInfo1.UserIDBaiDu    = ToStr(rp.Parameters.special.userId);
                    service.Create(basicInfo1);
                }
                else
                {
                    basicInfo.ChannelIDBaiDu = ToStr(rp.Parameters.special.channelId);
                    basicInfo.BaiduPushAppID = ToStr(rp.Parameters.special.appId);
                    basicInfo.UserIDBaiDu    = ToStr(rp.Parameters.special.userId);
                    service.Update(basicInfo, false);
                }
            }
            catch (Exception ex)
            {
                respData.code        = "103";
                respData.description = ex.ToString();
                respData.exception   = ex.ToString();
            }
            content = respData.ToJSON();

            Loggers.Debug(new DebugLogInfo()
            {
                Message = string.Format("setSignUp content: {0}", content)
            });
            return(content);
        }