Ejemplo n.º 1
0
        /// <summary>
        /// 根据账号密码获取信息(登录)
        /// </summary>
        /// <param name="loginname"></param>
        /// <param name="pwd"></param>
        /// <param name="operateip"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public static M_Users GetM_UserByProUserName(string loginname, string pwd, string operateip, out int result)
        {
            pwd = CloudSalesTool.Encrypt.GetEncryptPwd(pwd, loginname);
            DataSet ds    = new M_UsersDAL().GetM_UserByProUserName(loginname, pwd, out result);
            M_Users model = null;

            if (ds.Tables.Contains("M_User") && ds.Tables["M_User"].Rows.Count > 0)
            {
                model = new M_Users();
                model.FillData(ds.Tables["M_User"].Rows[0]);
                if (!string.IsNullOrEmpty(model.RoleID))
                {
                    model.Role = ManageSystemBusiness.GetRoleByIDCache(model.RoleID);
                }
                //权限
                if (model.Role != null && model.Role.IsDefault == 1)
                {
                    model.Menus = CommonBusiness.ManageMenus;
                }
                else if (model.IsAdmin == 1)
                {
                    model.Menus = CommonBusiness.ManageMenus;
                }
                else
                {
                    model.Menus = new List <Menu>();
                    foreach (DataRow dr in ds.Tables["Permission"].Rows)
                    {
                        Menu menu = new Menu();
                        menu.FillData(dr);
                        model.Menus.Add(menu);
                    }
                }
            }
            //记录登录日志
            LogBusiness.AddLoginLog(loginname, model != null, IntFactoryEnum.EnumSystemType.Manage, operateip, "", "");

            return(model);
        }
Ejemplo n.º 2
0
        public static Users GetUserByOtherAccount(EnumAccountType accountType, string account, string operateip, string projectid = "")
        {
            DataSet ds    = new OrganizationDAL().GetUserByOtherAccount((int)accountType, account, projectid);
            Users   model = null;

            if (ds.Tables.Contains("User") && ds.Tables["User"].Rows.Count > 0)
            {
                model = new Users();
                model.FillData(ds.Tables["User"].Rows[0]);

                model.LogGUID = Guid.NewGuid().ToString();

                model.Department = GetDepartmentByID(model.DepartID, model.ClientID);
                model.Role       = GetRoleByIDCache(model.RoleID, model.ClientID);
                model.Client     = Manage.ClientBusiness.GetClientDetail(model.ClientID);
                //处理缓存
                if (!Users.ContainsKey(model.ClientID))
                {
                    GetUsers(model.ClientID);
                }
                if (Users[model.ClientID].Where(u => u.UserID == model.UserID).Count() == 0)
                {
                    Users[model.ClientID].Add(model);
                }
                else
                {
                    var user = Users[model.ClientID].Where(u => u.UserID == model.UserID).FirstOrDefault();
                    user.LogGUID = model.LogGUID;
                }

                //权限
                if (model.Role != null && model.Role.IsDefault == 1)
                {
                    model.Menus = CommonBusiness.ClientMenus;
                }
                else
                {
                    model.Menus = new List <Menu>();
                    foreach (DataRow dr in ds.Tables["Permission"].Rows)
                    {
                        Menu menu = new Menu();
                        menu.FillData(dr);
                        model.Menus.Add(menu);
                    }
                }
            }
            if (string.IsNullOrEmpty(operateip))
            {
                operateip = "";
            }

            //记录登录日志
            if (model != null)
            {
                LogBusiness.AddLoginLog(account, true, IntFactoryEnum.EnumSystemType.Client, operateip, model.UserID, model.ClientID);
            }
            else
            {
                LogBusiness.AddLoginLog(account, false, IntFactoryEnum.EnumSystemType.Client, operateip, "", "");
            }
            return(model);
        }
Ejemplo n.º 3
0
        public static Users GetUserByUserName(string loginname, string pwd, out int result, string operateip)
        {
            pwd = CloudSalesTool.Encrypt.GetEncryptPwd(pwd, loginname);
            DataSet ds    = new OrganizationDAL().GetUserByUserName(loginname, pwd, out result);
            Users   model = null;

            if (ds.Tables.Contains("User") && ds.Tables["User"].Rows.Count > 0)
            {
                model = new Users();
                model.FillData(ds.Tables["User"].Rows[0]);

                model.LogGUID = Guid.NewGuid().ToString();

                model.Department = GetDepartmentByID(model.DepartID, model.ClientID);
                model.Role       = GetRoleByIDCache(model.RoleID, model.ClientID);

                //处理缓存
                if (!Users.ContainsKey(model.ClientID))
                {
                    GetUsers(model.ClientID);
                }
                if (Users[model.ClientID].Where(u => u.UserID == model.UserID).Count() == 0)
                {
                    Users[model.ClientID].Add(model);
                }
                else
                {
                    var user = Users[model.ClientID].Where(u => u.UserID == model.UserID).FirstOrDefault();
                    user.LogGUID = model.LogGUID;
                }

                model.Client = Manage.ClientBusiness.GetClientDetail(model.ClientID);

                //权限
                if (model.Role != null && model.Role.IsDefault == 1)
                {
                    model.Menus = CommonBusiness.ClientMenus;
                }
                else
                {
                    model.Menus = new List <Menu>();
                    foreach (DataRow dr in ds.Tables["Permission"].Rows)
                    {
                        Menu menu = new Menu();
                        menu.FillData(dr);
                        model.Menus.Add(menu);
                    }
                }
            }

            //记录登录日志
            if (model != null)
            {
                LogBusiness.AddLoginLog(loginname, true, IntFactoryEnum.EnumSystemType.Client, operateip, model.UserID, model.ClientID);
            }
            else
            {
                LogBusiness.AddLoginLog(loginname, false, IntFactoryEnum.EnumSystemType.Client, operateip, "", "");
            }

            return(model);
        }