Beispiel #1
0
 public virtual int Regist(LoginReq req)
 {
     long t = DateTime.Now.Ticks;
     int res = -1;
     try
     {
         DAC dac = new DAC(Config.LoginConnectionName);
         res = dac.Regist(req);
     }
     catch (Exception e)
     {
         Log.Write(LogAction.Svc, className, "Regist", "Regist", "Regist", DateTime.Now.Ticks - t, "执行失败:userName,loc,machineKey:" + req.UserName + "," + req.Location + "," + req.MachineKey + ";" + e.Message);
     }
     return res;
 }
Beispiel #2
0
 public virtual string Login(LoginReq req)
 {
     long t = DateTime.Now.Ticks;
     LoginRes res = new LoginRes();
     try
     {
         DAC dac = new DAC(Config.LoginConnectionName);
         res = dac.Login(req);
     }
     catch (Exception e)
     {
         Log.Write(LogAction.Svc, className, "Login", "Login", "Login", DateTime.Now.Ticks - t, "执行失败:userName,loc,machineKey:" + req.UserName + "," + req.Location + "," + req.MachineKey + ";" + e.Message);
     }
     return Newtonsoft.Json.JsonConvert.SerializeObject(res);
 }
Beispiel #3
0
        public virtual int Regist(LoginReq req)
        {
            long t = DateTime.Now.Ticks;
            if (string.IsNullOrEmpty(req.Email))
                req.Email = req.UserName + "@outlook.com";
            MembershipCreateStatus status = MembershipCreateStatus.UserRejected;
            try
            {
                MembershipUser user = Membership.CreateUser(req.UserName, req.Password, req.UserName + "@outlook.com", "qqqqqqqqqqqqqq", "qqqqqqqqqqqqqq", true, out status);

                Log.Write(LogAction.Svc, className, "Regist", "Regist", "CreateUser", DateTime.Now.Ticks - t, "执行成功:userName,loc,machineKey:" + req.UserName + "," + req.Location + "," + req.MachineKey + ";status=" + status);
            }
            catch (Exception e)
            {
                Log.Write(LogAction.Svc, className, "Regist", "Regist", "CreateUser", DateTime.Now.Ticks - t, "执行失败:userName,loc,machineKey:" + req.UserName + "," + req.Location + "," + req.MachineKey + ";" + e.Message);
            }
            return (int)status;
        }
Beispiel #4
0
        public virtual LoginRes Login(LoginReq req)
        {
            long t = DateTime.Now.Ticks;
            string cmdText = "UserLogin";
            LoginRes info = new LoginRes();
            try
            {
                bool status = (this.CheckLogin(req.UserName) == 1);
                if (!status)
                    status = Membership.ValidateUser(req.UserName, req.Password);
                Log.Write(LogAction.Svc, className, "Login", "Membership", cmdText, DateTime.Now.Ticks - t, "执行成功:userName,loc,machineKey:" + req.UserName + "," + req.Location + "," + req.MachineKey + ";status=" + status + " pwd:" + req.Password);
                if (status)
                {
                    info.UserID = req.UserName;
                    info.MachineKey = req.MachineKey == null ? string.Empty : req.MachineKey;
                    info.Location = req.Location == null ? string.Empty : req.Location;
                    //info.Roles = new List<string>(Roles.GetRolesForUser(req.UserName));
                    //DAC dac = new DAC(Config.LoginConnectionName);
                    info.Rights = new List<string>();//根据用户和app获取权限列表.
                    Dova.Cache.CacheManager.Set(Config.LoginCacheServiceName, req.UserName, info, new TimeSpan(24, 0, 0));
                    info.Status = 1;
                }  

            }
            catch (Exception e)
            {
                Log.Write(LogAction.Svc, className, "Login", "Membership", cmdText, DateTime.Now.Ticks - t, "执行失败:userName,loc,machineKey:" + req.UserName + "," + req.Location + "," + req.MachineKey + ";" + e.Message);
            }
            return info;
            //return Newtonsoft.Json.JsonConvert.SerializeObject(info);
        }