Exemplo n.º 1
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);
 }
Exemplo n.º 2
0
Arquivo: DAC.cs Projeto: kcitwm/dova
        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);
        }