public static int UnActive_SendMail(string product, ViewRenderService viewRender, ref int countFailed) { if (isSendMailRunning) { return(-1000); } try { isSendMailRunning = true; int countSucceed = 0; List <D2unactiveInfo> sccga = D2unactive.GetUnSend(product, (int)EUAS.未发送, 100); foreach (D2unactiveInfo gua in sccga) { bool rc = Func_SendMail(gua, viewRender); if (rc) { countSucceed++; } else { countFailed++; } } return(countSucceed); } finally { isSendMailRunning = false; } return(-1); }
public IActionResult func_active(string aid, string ip) { string uavGUID = aid; Hashtable htb = new Hashtable(); if (uavGUID.IsNullOrEmpty() || uavGUID.Length != 32) { htb.Add("gate", "sw"); return(this.FuncResult(new APIReturn(10302, "帐号格式错误", htb))); } D2unactiveInfo gua = D2unactive.GetItem(uavGUID); if (gua == null) { htb.Add("gate", "sw"); return(this.FuncResult(new APIReturn(10300, "帐号不存在", htb))); } TimeSpan ts1 = DateTime.Now - gua.UavTime1.Value; if (ts1.TotalHours >= 48) { htb.Add("gate", gua.UavGate); return(this.FuncResult(new APIReturn(10354, "超过48小时未激活", htb))); } string gateSrc; bool rc = this.Func_SetAV2(gua, out gateSrc); string gatesrcurl = string.Empty; try { if (rc && !string.IsNullOrEmpty(gateSrc)) { string gatesrc = gateSrc; gatesrcurl = DC2Conf.GetGateSrcUrl(gateSrc); if (gatesrc == "025") { gatesrcurl += (gatesrcurl.IndexOf("?") == -1 ? "?" : "&") + string.Format("{0}={1}&tid={2}", "email", gua.UavEMail, gua.UavGUID); } gatesrcurl = gatesrcurl.Replace("=", "%3d"); gatesrcurl = gatesrcurl.Replace("&", "%26"); } } catch (Exception e) { gatesrcurl = null; } htb.Add("gate", gua.UavGate); htb.Add("gatesrcurl", gatesrcurl); if (rc) { return(this.FuncResult(new APIReturn(0, string.Empty, htb))); } else { return(this.FuncResult(new APIReturn(0, "激活帐号失败", htb))); } }
private bool Func_SetAV2(D2unactiveInfo gua, out string retMsg) { retMsg = string.Empty; if (gua.UavState == (int)EUAS.已激活2) { string gatesrc = gua.UavGateSrc; if (gatesrc.Length > 1) { retMsg = gatesrc; } return(true); } D2unactive.Func_SetState(gua.UavGUID, (int)EUAS.已激活1); //object[] objs = { "active_setav.php", "number", gua.UavNumber }; //ReturnMessageDC2 rmdc = new DCClass(Operator, this.UAV_Gate, "W").Func_GetRet2(objs); //ReturnMessageDC rmdc = DCClass.DC_GetRet(Operator, this.UAV_Gate, "W", objs); object[] objs = { "number", gua.UavNumber }; //DCRequest dcr = new DCRequest(gua.UavGate, DCMethodTypes.W); //ReturnMsgDC rmdc = dcr.ExecRequest("active_setav.php", objs); DCResult dcr = DCInvoker.HttpInvoke(gua.UavGate, DCMethodTypes.W, "active_setav", objs.ToArray()); DicDCValue rmdc = dcr.GetDicDCValue(); if (rmdc.Code == 0) { string gatesrc = rmdc["gatesrc"]; bool rc = gatesrc.Length > 0 ? D2unactive.Func_SetState(gua.UavGUID, (int)EUAS.已激活2, gatesrc) : D2unactive.Func_SetState(gua.UavGUID, (int)EUAS.已激活2); if (rc) { string gatesrc2 = rmdc["gatesrc"]; if (gatesrc2.Length > 1) { retMsg = gatesrc2; } } return(rc); } else { return(false); } }
public IActionResult func_resendActiveMail(string gate, string email) { if (string.IsNullOrEmpty(gate) || string.IsNullOrEmpty(email)) { return(this.FuncResult(new APIReturn(10000, $"参数不正确gate={gate},email={email}"))); } if (email.Length < 5 || gate.Length > 4) { return(this.FuncResult(new APIReturn(10000, $"参数不正确gate={gate},email={email}"))); } List <D2unactiveInfo> scc = D2unactive.GetByEmail(gate, email); if (scc.Count() == 0) { //没有可供重发的信息 return(this.FuncResult(new APIReturn(10353, "帐号已激活或72小时内未注册"))); } D2unactiveInfo gua = (D2unactiveInfo)scc[0]; TimeSpan ts = DateTime.Now - gua.UavTime1.Value; if (ts.TotalHours >= 48) { return(this.FuncResult(new APIReturn(10354, "超过48小时未激活"))); } bool rc = Job.Func_SendMail(gua, _viewRender); if (rc) { return(this.FuncResult(new APIReturn(0))); } else { //发送激活邮件失败 return(this.FuncResult(new APIReturn(10501, "重发激活邮件失败"))); } }
public static int UnActive_GetList(string product, StringBuilder sbout) { if (isSendMailRunning) { return(-1000); } try { isGetListRunning = true; DateTime time1 = D2unactive.GetLast(product); object[] objs = { "state", 1, "time1", time1.ToString("yyyy-MM-dd HH:mm:ss") }; //DCRequest dcr = new DCRequest(product, DCMethodTypes.R); //ReturnMsgListDC rmdc = dcr.ExecRequestList("active_getlist.php", objs); ListDCValue dcValue = DCInvoker.HttpInvoke(product, DCMethodTypes.R, "active_getlist", objs).GetListDCValue(); sbout.Append(string.Format("\r\ngetlist返回原文,{0}", dcValue.Content)); if (dcValue.Code != 0) { return(-2); } if (dcValue.ListDatas.Count <= 1) { return(-3); } int count = 0; for (int i = 1; i < dcValue.ListDatas.Count; i++) { int data_number = dcValue.ListDatas[i][0].ToInt(); string data_email = dcValue.ListDatas[i][1]; DateTime data_time1 = DateTime.Parse(dcValue.ListDatas[i][2]); string UAV_GateSrc = ""; int data_flag = 0;//比如nopass if (dcValue.ListDatas[i].Length >= 4) { UAV_GateSrc = dcValue.ListDatas[i][3]; } if (dcValue.ListDatas[i].Length >= 5) { data_flag = dcValue.ListDatas[i][4].ToInt(); } D2unactiveInfo ga = product == "dw" ? D2unactive.initWithUIDForURSUpgrade(product, data_number) : D2unactive.initWithUID(product, data_number); if (ga == null)//已存在,不处理 { ga = new D2unactiveInfo() { UavGUID = Guid.NewGuid().ToString("N"), UavState = (int)EUAS.未发送, UavGate = product, UavGateSrc = UAV_GateSrc, UavNumber = data_number, UavEMail = data_email, UavTime1 = data_time1, UavFlag = data_flag }; D2unactive.Insert(ga); sbout.Append(string.Format("\r\n成功导入,{0}", data_number)); count++; } else { sbout.Append(string.Format("\r\n这个帐号已存在,不必导入{0}", data_number)); } } return(count); } catch (Exception es) { sbout.Append(string.Format("\r\n发生了异常{0}", es.Message)); } finally { isGetListRunning = false; } return(-1); }
public static bool Func_SendMail(D2unactiveInfo unactiveInfo, ViewRenderService viewRender) { string pName = DC2Conf.GetPName(unactiveInfo.UavGate); string srcname = DC2Conf.GetGateSrcUrl(unactiveInfo.UavGateSrc); string title = string.Format("请确认您的{0}帐号", pName); string url = string.Format(DC2Conf.AvUrlFormat, unactiveInfo.UavGUID, unactiveInfo.UavGate); if (unactiveInfo.UavFlag == 11 || unactiveInfo.UavFlag == 12) { url = string.Format(DC2Conf.AvNPUrlFormat, unactiveInfo.UavGUID, unactiveInfo.UavGate); } Hashtable cht_data = new Hashtable(); cht_data["来源产品名"] = srcname; if (!string.IsNullOrWhiteSpace(srcname) && srcname.IndexOf("多益通") == -1) { title += string.Format("[{0}]", srcname); } cht_data["产品名"] = pName; cht_data["用户帐号名"] = unactiveInfo.UavEMail; cht_data["链接地址"] = url; string viewName = "letter_active"; string fromName = "多益网络"; if (IsTW(unactiveInfo.UavFlag ?? 0) && unactiveInfo.UavGateSrc == "dw") { title = string.Format("请确认您的{0}帐号[夢想帝王]", "英雄通行證"); cht_data["来源产品名"] = "夢想帝王"; cht_data["产品名"] = "英雄通行證"; viewName = "letter_active_tw"; fromName = "英雄網路"; string urltw = url.Replace("hi.duoyi.com", "hi.herojoys.com"); cht_data["链接地址"] = urltw; } if (DC2Conf.IsHerojoys) { title = title.Replace("多益", "英雄"); cht_data["产品名"] = "英雄通行证"; cht_data["来源产品名"] = cht_data["来源产品名"].ToString().Replace("多益", "英雄"); fromName = "英雄网络"; } if (unactiveInfo.UavGate.ToLower() == "dw" || unactiveInfo.UavGate.ToLower() == "mx")//这些是确认邮件 { viewName = "letter_confirmemail"; title = string.Format("请确认您在[{0}]使用的邮箱帐号", pName); } string viewPath = UrsHelper.GetTPLViewPath(viewName); string content = viewRender.Render <Hashtable>(viewPath, cht_data); //this.EndFor(sw.ToString()); bool rc = false; try { rc = D2lib.SendMail_Henhaoji(unactiveInfo, fromName, unactiveInfo.UavEMail, unactiveInfo.UavEMail, title, content, true); if (rc) { D2unactive.Func_SetState(unactiveInfo.UavGUID, (int)EUAS.已发送); } } catch (Exception es) { if (es is FormatException) { rc = true; D2unactive.Func_SetState(unactiveInfo.UavGUID, (int)EUAS.异常); } } return(rc); }
public IActionResult func_IsExistAcct(string account, int checkactive) { if (account.IsNullOrEmpty() || !this.IsMobile(account) && !Utilities.IsValidEmail(account)) { return(this.FuncResult(new APIReturn(10000, "参数错误(account)"))); } #region 2980帐号 Hashtable htb = new Hashtable(); if (this.IsMobile(account) || account.EndsWith("@2980.com")) { string checkType; string phoneUserName; if (this.IsMobile(account)) { checkType = "phone"; phoneUserName = account; } else { checkType = "name"; phoneUserName = account.Substring(0, account.LastIndexOf('@')); } Dictionary <string, object> argus = new Dictionary <string, object>(); argus.Add("act", "dy_gs_checknamephone"); argus.Add("portkey", DC2Conf.Passport2980); argus.Add("checktype", checkType); argus.Add("phoneUserName", phoneUserName); ReturnMsg2980 ret = P2980Invoker.InvokeHttp("funswregister", argus); #region 返回码处理 int code; string msg; if (ret.Code == 250) { code = 0; msg = "帐号不存在"; } else if (ret.Code == 625) { if (checkactive == 1) { htb.Add("isActive", true); } return(this.FuncResult(new APIReturn(10303, "帐号已存在", htb))); } else if (ret.Code == 609) { //参数不能为空、重要参数长度不足 code = 10000; msg = "部分参数缺失"; } else if (ret.Code == 611) { //检测超出规定次数 code = 19902; msg = "操作太频繁"; } else if (ret.Code == 500) { //服务器错误 code = -98; msg = "未知系统错误"; } else if (ret.Code == 614) { //你不具备访问权限 code = -97; msg = "IP没有权限"; } else if (ret.Code == 583) { //无任何执行动作 code = 10000; msg = "部分参数缺失"; } else { code = 19801; msg = $"参数或其它错误({ret.Code},{ret.Message})"; } #endregion return(this.FuncResult(new APIReturn(code, msg))); } #endregion bool isActive = false; UrsacctInfo acctInfo = Ursacct.GetItem(account); if (acctInfo != null) { UrsuserInfo userInfo = Ursuser.GetItem(acctInfo.AcctNumber); if (userInfo.UrsTime.HasValue && userInfo.UrsTime.HasValue && userInfo.UrsTime.Value.Year > 2000 && (DateTime.Now - userInfo.UrsTime.Value).TotalDays > 3)//兼容之前没写日期的 { isActive = true; } if (checkactive == 1) { D2unactiveInfo activeInfo = D2unactive.GetItemByNumber(acctInfo.AcctNumber.Value); isActive = activeInfo != null && activeInfo.UavState == (int)EUAS.已激活2; htb.Add("isActive", isActive); } return(this.FuncResult(new APIReturn(10303, "帐号已存在", htb))); } //请求DC验证 //DCRequest dcr = new DCRequest(DCProdTypes.URS, DCMethodTypes.R); List <object> listobj = new List <object>(); listobj.AddRange(new object[] { "email", account }); //ReturnMsgDC rc = dcr.ExecRequest("acct_getinfoforupgrade.php", listobj.ToArray()); DCResult dcr = DCInvoker.HttpInvoke(DCProdTypes.URS, DCMethodTypes.R, "acct_getinfoforupgrade", listobj.ToArray()); DicDCValue rc = dcr.GetDicDCValue(); if (rc.Code == 23) { //帐号不存在 return(this.FuncResult(new APIReturn(0, "帐号不存在"))); } else if (rc.Code == 99) { //帐号未激活 isActive = false; } else { //帐号已存在 isActive = true; int number = rc["number"].ToInt(); } if (checkactive == 1) { htb.Add("isActive", isActive); } return(this.FuncResult(new APIReturn(10303, "帐号已存在", htb))); }