public string CancelPlan(int PlanId) { PopupMsgPlan = popupMsgPlanBLL.Get("PlanId", PlanId); PopupMsgPlan.Status = 3; if (SsoServer.UpDateStatus(PlanId, 0) == 0) { if (popupMsgPlanBLL.UpdateReceiveMsg(PlanId)) { popupMsgPlanBLL.Update(PopupMsgPlan).ToString(); } return("000000"); } return("000001"); }
/// <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数据推送异常:"); } }