Пример #1
0
        /// <summary>
        /// 修改消息状态接口
        /// </summary>
        /// <param name="id">Id</param>
        /// <param name="status">状态</param>
        /// <returns></returns>
        public int UpDateStatus(int id, int status)
        {
            try
            {
                string parameter = GetChangeOutWindowParameter(id, status);
                string res       = RequestHelper.WebRequest(ChangeOutWindow, "post", parameter, "UTF-8", true);
                if (!string.IsNullOrEmpty(res))
                {
                    res = new EncDecUtil().decyptData(res, accesskey);
                }
                Loger.Info("PlanId:" + id + ",修改消息状态接口返回结果:" + res);
                SsoRes listSsoRes = JsonHelper.DeserializeJson <SsoRes>(res);

                if (listSsoRes == null)
                {
                    return(-1);
                }
                return(listSsoRes.error);
            }
            catch (Exception ex)
            {
                Loger.Error(ex, "\r\n=====error=====\r\nPlanId:" + id + ",修改消息状态异常:");
                return(-1);
            }
        }
Пример #2
0
        /// <summary>
        /// SSO接口重推记录更新
        /// </summary>
        /// <param name="userName">此次调用接口用户</param>
        /// <param name="res">SSO接口返回值</param>
        /// <param name="ssoResultID">调用SSO结果表ID</param>
        /// <param name="i">是否第一次标识</param>
        private void UpDataSsoResult(string userName, string res, SSOResult ssoResult, int i)
        {
            SSOResultBLL ssoResultBll = Factory.BusinessFactory.CreateBll <SSOResultBLL>();

            if (string.IsNullOrEmpty(res))//sso接口返回空时,不往下执行了
            {
                return;
            }
            SsoRes ssoRes = JsonHelper.DeserializeJson <SsoRes>(res);

            ssoResult.SuccessUser += UserArryToString(ssoRes.success_user);
            ssoResult.Status       = ssoRes.error;

            //重推首次覆盖错误用户
            if (i == 0 && ssoRes.error == 0)
            {
                ssoResult.ErrorUser     = UserArryToString(ssoRes.error_user);
                ssoResult.RepeatUser    = UserArryToString(ssoRes.repeat_user);
                ssoResult.UndefinedUser = UserArryToString(ssoRes.undefined_user);
            }
            else
            {
                ssoResult.ErrorUser     += UserArryToString(ssoRes.error_user) == "" ? "" : "," + UserArryToString(ssoRes.error_user);
                ssoResult.RepeatUser    += UserArryToString(ssoRes.repeat_user) == "" ? "" : "," + UserArryToString(ssoRes.repeat_user);
                ssoResult.UndefinedUser += UserArryToString(ssoRes.undefined_user) == "" ? "" : "," + UserArryToString(ssoRes.undefined_user);
            }

            ssoResultBll.Update(ssoResult);
        }
Пример #3
0
        /// <summary>
        /// 推送(炒股大赛)
        /// </summary>
        public void SsoPushStockContest(StockContestData scd)
        {
            SsoOutWindowBLL ssoOutWindowBll = Factory.BusinessFactory.CreateBll <SsoOutWindowBLL>();
            string          msgTitle        = string.Format(ConfigurationManager.AppSettings["StockContestMobileMsg"], scd.OperateUserName, scd.OperateType, scd.StockName, scd.Price);

            //pc端推送
            string parameter = GetAddOutWindowParameter(scd);
            string res       = RequestHelper.WebRequest(AddOutWindow, "post", parameter, "UTF-8", false);

            if (!string.IsNullOrEmpty(res))
            {
                res = new EncDecUtil().decyptData(res, accesskey);
                SsoRes ssoRes = JsonHelper.DeserializeJson <SsoRes>(res);

                // 调用接口状态码,0:成功,1:该消息id 已存在,2:链接地址不存在,3:用户群组不存在,4:开始时间与结束时间不匹配,9:其它异常
                if (ssoRes.error != 0)
                {
                    Loger.Error("[炒股大赛]  SSO数据推送返回失败, 返回:" + res + "\r\n相关参数:" + JsonHelper.ToJson(scd));
                }
            }
            else
            {
                Loger.Error("SSO接口调用返回空=====error=====(一般情况不会出现, 出现在超时或者无法调用)");
            }

            Loger.Info("[炒股大赛] id=" + scd.Id + "  SSO数据推送返回结果: " + res + "\r\n相关参数:" + JsonHelper.ToJson(scd) + "\r\n手机推送中...");
            //入手机端推送表
            int num = ssoOutWindowBll.UpDataTB_MOBPUSH_USERINFO_StockContest(scd, msgTitle);

            Loger.Info("[炒股大赛] id=" + scd.Id + "  手机推送表更新数:" + num);
        }
Пример #4
0
        /// <summary>
        /// SSO数据推送
        /// </summary>
        /// <param name="planId">planId</param>
        /// <param name="version">推送版本,金蝴蝶:1000, 严林版:3100, 金牡丹:5100, 渤商版:6100, 所有版本:0</param>
        public void SsoPush(int planId, string version)
        {
            if (string.IsNullOrEmpty(version))
            {
                version = "0";
            }
            try
            {
                PopupMsgPlanBLL opupMsgPlanBll = Factory.BusinessFactory.CreateBll <PopupMsgPlanBLL>();
                PopupMsgPlan    popupMsgPlan   = opupMsgPlanBll.Get("PlanId", planId);
                List <string>   listUserName   = new List <string>();

                if (popupMsgPlan != null)
                {
                    int ssoResultId = 0;
                    List <CustomerGroup> allUserName = new List <CustomerGroup>();

                    //判断是否用户组
                    if (popupMsgPlan.ReceiverType == 0 || popupMsgPlan.ReceiverType == 2)
                    {
                        allUserName = GetUserName(popupMsgPlan.Receiver, version);
                        string versionLog = version == "0" ? "所有" :
                                            (version == "1000" ? "金蝴蝶" :
                                             (version == "3100" ? "严林版" :
                                              (version == "5100" ? "金牡丹" :
                                               (version == "6100" ? "渤商版" : "其它"))));
                        Loger.Info("\r\n=====推送类型: " + popupMsgPlan.DataType
                                   + "\r\n=====推送用户组: " + popupMsgPlan.Receiver
                                   + "\r\n=====推送版本: " + versionLog
                                   + "\r\n=====推送平台: " + popupMsgPlan.PushPlatform
                                   + "\r\n=====planId: " + planId);
                        if (allUserName != null)
                        {
                            listUserName = GetUserNameToGroup(allUserName);
                        }
                        else
                        {
                            Loger.Info("PlanId:" + planId + ", 此用户组, 不存在用户!");
                            return;
                        }
                    }
                    else if (popupMsgPlan.ReceiverType == 1)
                    {
                        allUserName = AddUserName(popupMsgPlan.Receiver);
                        listUserName.Add(popupMsgPlan.Receiver);
                    }

                    //更新计划接收用户数
                    popupMsgPlan.ReceiverCount = allUserName.Count;
                    opupMsgPlanBll.Update(popupMsgPlan);

                    if (popupMsgPlan.DataType == "资讯弹窗")
                    {
                        //包括移动终端推送
                        if (popupMsgPlan.PushPlatform.IndexOf("android") >= 0 || popupMsgPlan.PushPlatform.IndexOf("ios") >= 0)
                        {
                            Thread thOracle = new Thread(new ThreadStart(delegate()
                            {
                                UpDataMoveData(popupMsgPlan, allUserName);
                            }));
                            thOracle.Start();
                        }

                        //不包括PC终端, 返回
                        if (popupMsgPlan.PushPlatform.IndexOf("pc") < 0)
                        {
                            return;
                        }

                        if (popupMsgPlan.ReceiverType == 0 || popupMsgPlan.ReceiverType == 2)   //用户组
                        {
                            Thread th = new Thread(new ThreadStart(delegate()
                            {
                                NewsPopupUserUpdataIn(popupMsgPlan, allUserName, version);
                            }));
                            th.Start();
                        }
                        else if (popupMsgPlan.ReceiverType == 1)    //用户(手动输入)
                        {
                            Thread th = new Thread(new ThreadStart(delegate()
                            {
                                NewsPopupUserUpdata(popupMsgPlan, allUserName);
                            }));
                            th.Start();
                        }
                    }
                    ;
                    //return;
                    string        parameter  = string.Empty;
                    List <SsoRes> listSsoRes = new List <SsoRes>();

                    if (listUserName.Count > 0)
                    {
                        Loger.Info(" [SSO][开始] SSO推送中...");
                    }
                    else
                    {
                        return;
                    }

                    DateTime srb = DateTime.Now;

                    foreach (var userName in listUserName)
                    {
                        parameter = GetAddOutWindowParameter(popupMsgPlan, userName);
                        string res = RequestHelper.WebRequest(AddOutWindow, "post", parameter, "UTF-8", true);
                        if (!string.IsNullOrEmpty(res))
                        {
                            res = new EncDecUtil().decyptData(res, accesskey);
                            SsoRes ssoRes = JsonHelper.DeserializeJson <SsoRes>(res);
                            listSsoRes.Add(ssoRes);

                            // 调用接口状态码,0:成功,1:该消息id 已存在,2:链接地址不存在,3:用户群组不存在,4:开始时间与结束时间不匹配,9:其它异常
                            if (ssoRes.error != 0)//失败部分单独更新
                            {
                                Loger.Info("SSO接口调用返回失败, 此批用户入库<失败用户>");
                                Loger.Info("PlanId:" + planId + ",SSO数据推送返回结果:" + res);
                                ssoResultId = UpDataSsoResult(popupMsgPlan, userName, ssoRes, ssoResultId);
                            }
                            //Loger.Info("PlanId:" + planId + ",SSO数据推送返回结果: ssoRes = " + ssoRes.error);
                        }
                        else
                        {
                            Loger.Info("SSO接口调用返回空=====error=====(一般情况不会出现, 出现在超时或者无法调用)");
                        }
                    }

                    Loger.Info(" [SSO][结束] SSO推送完毕, 用时: " + (int)(DateTime.Now - srb).TotalSeconds + " 秒");
                    UpDataSsoResult(popupMsgPlan, listSsoRes, ssoResultId);

                    //if (popupMsgPlan.DataType == "广告弹窗")
                    //    ReceiveMsgPush(popupMsgPlan, allUserName);
                    //else
                    //if (popupMsgPlan.DataType == "资讯弹窗")
                    //{
                    //    //InformationOfUserPush(popupMsgPlan, allUserName);
                    //    NewsPopupUserUpdata(popupMsgPlan, allUserName);
                    //}
                }
            }
            catch (Exception ex)
            {
                Loger.Error(ex, "\r\n=====error=====\r\nPlanId:" + planId + ",SSO数据推送异常:");
            }
        }
Пример #5
0
        /// <summary>
        /// SSO接口调用记录更新(失败部分)
        /// </summary>
        /// <param name="popupMsgPlan">弹窗信息计划</param>
        /// <param name="userName">此次调用接口用户</param>
        /// <param name="res">SSO接口返回值</param>
        /// <param name="ssoResultId">调用SSO结果表ID</param>
        /// <returns></returns>
        private int UpDataSsoResult(PopupMsgPlan popupMsgPlan, string userName, SsoRes ssoRes, int ssoResultId)
        {
            SSOResultBLL ssoResultBll = Factory.BusinessFactory.CreateBll <SSOResultBLL>();
            //if(string.IsNullOrEmpty(res))//sso接口返回空时,不往下执行了
            //    return 0;
            //SsoRes ssoRes = JsonHelper.DeserializeJson<SsoRes>(res);

            SSOResult ssoResult;

            if (ssoResultId > 0)
            {
                ssoResult = ssoResultBll.Get("Id", ssoResultId);
            }
            else
            {
                ssoResult = new SSOResult();
            }

            ssoResult.PlanId    = popupMsgPlan.PlanId;
            ssoResult.Url       = OutWindowUrl + popupMsgPlan.PlanId;
            ssoResult.BeginTime = popupMsgPlan.BeginTime;
            ssoResult.EndTime   = popupMsgPlan.EndTime;
            ssoResult.PopupType = popupMsgPlan.PopupType;
            ssoResult.Status    = ssoRes.error;

            //SSO接口返回调用成功
            if (ssoRes.error == 0)
            {
                //数据库已经存在这条数据
                if (ssoResultId > 0)
                {
                    ssoResult.Id             = ssoResultId;
                    ssoResult.SuccessUser   += UserArryToString(ssoRes.success_user) == "" ? "" : "," + UserArryToString(ssoRes.success_user);
                    ssoResult.ErrorUser     += UserArryToString(ssoRes.error_user) == "" ? "" : "," + UserArryToString(ssoRes.error_user);
                    ssoResult.RepeatUser    += UserArryToString(ssoRes.repeat_user) == "" ? "" : "," + UserArryToString(ssoRes.repeat_user);
                    ssoResult.UndefinedUser += UserArryToString(ssoRes.undefined_user) == "" ? "" : "," + UserArryToString(ssoRes.undefined_user);
                    ssoResultBll.Update(ssoResult);
                    return(ssoResultId);
                }
                else
                {
                    ssoResult.SuccessUser   = UserArryToString(ssoRes.success_user);
                    ssoResult.ErrorUser     = UserArryToString(ssoRes.error_user);
                    ssoResult.RepeatUser    = UserArryToString(ssoRes.repeat_user);
                    ssoResult.UndefinedUser = UserArryToString(ssoRes.undefined_user);
                    return(ssoResultBll.Add(ssoResult));
                }
            }
            else //SSO接口调用失败,所有用户加到出错用户字段
            {
                //数据库已经存在这条数据
                if (ssoResultId > 0)
                {
                    ssoResult.Id         = ssoResultId;
                    ssoResult.ErrorUser += ssoResult.ErrorUser == "" ?  "" : "," + userName;
                    ssoResultBll.Update(ssoResult);
                    return(ssoResultId);
                }
                else
                {
                    ssoResult.ErrorUser = userName;
                    return(ssoResultBll.Add(ssoResult));
                }
            }
        }