Beispiel #1
0
        public static D2unactiveInfo GetItem(string UavGUID)
        {
            if (UavGUID == null)
            {
                return(null);
            }
            if (itemCacheTimeout <= 0)
            {
                return(dal.GetItem(UavGUID));
            }
            string key   = string.Concat("DC2016_BLL_D2unactive_", UavGUID);
            string value = RedisHelper.Get(key);

            if (!string.IsNullOrEmpty(value))
            {
                try { return(new D2unactiveInfo(value)); } catch { }
            }
            D2unactiveInfo item = dal.GetItem(UavGUID);

            if (item == null)
            {
                return(null);
            }
            RedisHelper.Set(key, item.Stringify(), itemCacheTimeout);
            return(item);
        }
Beispiel #2
0
 private static void RemoveCache(D2unactiveInfo item)
 {
     if (item == null)
     {
         return;
     }
     RedisHelper.Remove(string.Concat("DC2016_BLL_D2unactive_", item.UavGUID));
 }
Beispiel #3
0
 public static DC2016.DAL.D2unactive.SqlUpdateBuild UpdateDiy(D2unactiveInfo item, string UavGUID)
 {
     if (itemCacheTimeout > 0)
     {
         RemoveCache(item != null ? item : GetItem(UavGUID));
     }
     return(new DC2016.DAL.D2unactive.SqlUpdateBuild(item, UavGUID));
 }
Beispiel #4
0
 public static int Update(D2unactiveInfo item)
 {
     if (itemCacheTimeout > 0)
     {
         RemoveCache(item);
     }
     return(dal.Update(item));
 }
Beispiel #5
0
        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)));
            }
        }
Beispiel #6
0
 public static D2unactiveInfo Insert(D2unactiveInfo item)
 {
     item = dal.Insert(item);
     if (itemCacheTimeout > 0)
     {
         RemoveCache(item);
     }
     return(item);
 }
Beispiel #7
0
 public int Update(D2unactiveInfo item)
 {
     return(new SqlUpdateBuild(null, item.UavGUID)
            .SetUavEMail(item.UavEMail)
            .SetUavFlag(item.UavFlag)
            .SetUavGate(item.UavGate)
            .SetUavGateSrc(item.UavGateSrc)
            .SetUavNumber(item.UavNumber)
            .SetUavState(item.UavState)
            .SetUavTime1(item.UavTime1)
            .SetUavTime2(item.UavTime2).ExecuteNonQuery());
 }
Beispiel #8
0
 protected static MySqlParameter[] GetParameters(D2unactiveInfo item)
 {
     return(new MySqlParameter[] {
         GetParameter("?UavGUID", MySqlDbType.VarChar, 32, item.UavGUID),
         GetParameter("?UavEMail", MySqlDbType.VarChar, 64, item.UavEMail),
         GetParameter("?UavFlag", MySqlDbType.Int32, 11, item.UavFlag),
         GetParameter("?UavGate", MySqlDbType.VarChar, 32, item.UavGate),
         GetParameter("?UavGateSrc", MySqlDbType.VarChar, 8, item.UavGateSrc),
         GetParameter("?UavNumber", MySqlDbType.Int32, 11, item.UavNumber),
         GetParameter("?UavState", MySqlDbType.Int32, 11, item.UavState),
         GetParameter("?UavTime1", MySqlDbType.DateTime, -1, item.UavTime1),
         GetParameter("?UavTime2", MySqlDbType.DateTime, -1, item.UavTime2)
     });
 }
Beispiel #9
0
        public static DateTime GetLast2(string product)
        {
            //AFSQLGetScalar afsql = (AFSQLGetScalar)new AFSQLGetScalar(Operator, tablename).Base.SetTop(1).AddWhere("UAV_Gate", product).SetOrderBy("UAV_Time2 desc").SetFields("UAV_Time2");
            //object rcobj = afsql.Func_GetScalar();
            //if (rcobj != null && rcobj is DBNull == false && rcobj is DateTime)
            //    return (DateTime)rcobj;
            //else
            //    return new DateTime(2000, 1, 1);

            D2unactiveInfo item = Select.WhereUavGate(product).Sort("UavTime2 desc").ToOne();

            if (item != null)
            {
                return(item.UavTime2.Value);
            }
            return(new DateTime(2000, 1, 1));
        }
Beispiel #10
0
        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);
            }
        }
Beispiel #11
0
        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, "重发激活邮件失败")));
            }
        }
Beispiel #12
0
        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);
        }
Beispiel #13
0
        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)));
        }
Beispiel #14
0
 public SqlUpdateBuild(D2unactiveInfo item, string UavGUID)
 {
     _item  = item;
     _where = SqlHelper.Addslashes("`UavGUID` = {0}", UavGUID);
 }
Beispiel #15
0
        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);
        }
Beispiel #16
0
        public static bool SendMail_Henhaoji(object obj, string FromName, string ToName, string ToMail, string Subject, string Message, bool Html)
        {
            string[] acctexts = { "e1d0cfb10e", "c6d21323c3", "e3c49491d4", "1a15cb4ff3", "9107e5e628" };
            //2013-01-09 test
            //2013-01-16 10%,暂只用于找回密码,激活未用
            string fromName = FromName;

            if (string.IsNullOrEmpty(fromName))
            {
                fromName = "多益网络";
            }
            string fromMail            = DC2Conf.IsHerojoys ? "*****@*****.**" : "*****@*****.**";
            bool   isModeForceHenhaoji = false;

            if (ToMail.ToLower().EndsWith("@163.com"))
            {
                isModeForceHenhaoji = false;
            }
            bool rand5   = false;
            bool randlet = true;

            if (ToMail.ToLower().EndsWith("@qq.com") || ToMail == "*****@*****.**")
            {
                //isModeForceHenhaoji = true;
                //rand5 = true;
            }
            if (rand5 && fromMail == "*****@*****.**")
            {
                fromMail = string.Format("acctactive_{0}@duoyi.com", acctexts[new Random().Next(0, acctexts.Length)]);
            }
            if (isModeForceHenhaoji == false)
            {
                int port = 0;
                if (randlet && obj is D2unactiveInfo)
                {
                    D2unactiveInfo ua   = (D2unactiveInfo)obj;
                    int            seed = ua.UavNumber.Value % 100;
                    if (ua.UavGUID == "f539815b6cfb47a2b7add3baa5cc441a")//test guid
                    {
                        seed = new Random().Next(0, 7);
                    }
                    if (seed >= 1 && seed <= 6)
                    {
                        port = seed;
                    }
                }
                return(Func_SendMail_SendServer(port, fromName, fromMail, ToName, ToMail, Subject, Message, Html));
            }

            /* 暂不支持
             * NetworkCredential myNetworkCredential = new NetworkCredential("mxsystem", "hhjxt1234");
             * NetworkCredential myNetworkCredential = new NetworkCredential("acctactive", "e1d0cfb10e");
             * SmtpClient mail = new SmtpClient("mail.henhaoji.com");
             * mail.UseDefaultCredentials = false;
             * mail.Credentials = myNetworkCredential;
             * MailMessage mmsg = new MailMessage();
             * mmsg.From = new MailAddress("*****@*****.**", fromName);
             * if (ToMail.ToLower().StartsWith("2241") || new Random().Next(0, 100) <= (DateTime.Now - DateTime.Parse("2012-10-03")).TotalDays * 5 + 20)//某测试帐号或1/10概率,使用@duoyi.com发送
             *  mmsg.From = new MailAddress("*****@*****.**", fromName);
             * //if (ToMail.ToLower().StartsWith("2241"))
             * //    mmsg.From = new MailAddress("*****@*****.**", "多益网络");
             * mmsg.Subject = Subject;
             * mmsg.Body = Message;
             * mmsg.BodyEncoding = Encoding.UTF8;
             * //mmsg.BodyEncoding = Encoding.GetEncoding("gb2312");
             * mmsg.To.Add(new MailAddress(ToMail, ToName));
             * mmsg.IsBodyHtml = Html;
             * mail.Send(mmsg);
             */

            return(true);
        }
Beispiel #17
0
 public D2unactiveInfo Insert(D2unactiveInfo item)
 {
     SqlHelper.ExecuteNonQuery(TSQL.Insert, GetParameters(item));
     return(item);
 }