Exemplo n.º 1
0
        public ActionResult Login(string ReturnUrl, int Status = 0)
        {
            if (Session["ClientManager"] != null)
            {
                return(Redirect("/Home/Index"));
            }
            HttpCookie cook = Request.Cookies["cloudsales"];

            if (cook != null)
            {
                if (cook["status"] == "1")
                {
                    string operateip = Common.Common.GetRequestIP();
                    int    result;
                    CloudSalesEntity.Users model = CloudSalesBusiness.OrganizationBusiness.GetUserByUserName(cook["username"], cook["pwd"], out result, operateip);
                    if (model != null)
                    {
                        Session["ClientManager"] = model;
                        return(Redirect("/Home/Index"));
                    }
                }
                else
                {
                    ViewBag.UserName = cook["username"];
                }
            }
            ViewBag.Status    = Status;
            ViewBag.ReturnUrl = ReturnUrl ?? string.Empty;
            return(View());
        }
Exemplo n.º 2
0
 /// <summary>
 /// 返回controllerMenu
 /// </summary>
 /// <param name="httpContext"></param>
 /// <param name="controller"></param>
 /// <returns></returns>
 public static Menu GetController(HttpContext httpContext, string controller)
 {
     if (httpContext.Session["ClientManager"] != null)
     {
         CloudSalesEntity.Users model = (CloudSalesEntity.Users)httpContext.Session["ClientManager"];
         return(model.Menus.Where(m => m.Controller.ToUpper() == controller.ToUpper() && m.Layer == 2).FirstOrDefault());
     }
     return(new Menu());
 }
Exemplo n.º 3
0
 /// <summary>
 /// 是否有权限
 /// </summary>
 public static string IsLimits(HttpContext httpContext, string menucode)
 {
     if (httpContext.Session["ClientManager"] != null)
     {
         CloudSalesEntity.Users model = (CloudSalesEntity.Users)httpContext.Session["ClientManager"];
         if (model.Menus.Where(m => m.MenuCode == menucode).Count() > 0)
         {
             return("");
         }
     }
     return("nolimits");
 }
Exemplo n.º 4
0
        /// <summary>
        /// 主动注册客户端
        /// </summary>
        /// <param name="name"></param>
        /// <param name="companyName"></param>
        /// <param name="loginName"></param>
        /// <param name="loginPWD"></param>
        /// <returns></returns>
        public JsonResult RegisterClient(string name, string companyName, string loginName, string loginPWD, string code)
        {
            int result = 0;
            Dictionary <string, object> JsonDictionary = new Dictionary <string, object>();

            bool bl = OrganizationBusiness.IsExistLoginName(loginName);

            if (bl)
            {
                result = 2;
            }
            else
            {
                bl = Common.Common.ValidateMobilePhoneCode(loginName, code);
                if (!bl)
                {
                    result = 3;
                }
                else
                {
                    Clients client = new Clients()
                    {
                        CompanyName = companyName, ContactName = name
                    };
                    ClientBusiness.InsertClient(client, loginName, loginPWD, string.Empty, out result);

                    if (result == 1)
                    {
                        string operateip = Common.Common.GetRequestIP();
                        int    outResult;
                        CloudSalesEntity.Users user = CloudSalesBusiness.OrganizationBusiness.GetUserByUserName(loginName, loginPWD, out outResult, operateip);
                        if (user != null)
                        {
                            Session["ClientManager"] = user;
                        }

                        Common.Common.ClearMobilePhoneCode(loginName);
                    }
                    else
                    {
                        result = 0;
                    }
                }
            }

            JsonDictionary.Add("Result", result);
            return(new JsonResult()
            {
                Data = JsonDictionary,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Exemplo n.º 5
0
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            base.OnAuthorization(filterContext);
            if (filterContext.HttpContext.Response.StatusCode == 401)
            {
                string source = HttpContext.Current.Request.QueryString["source"];
                if (!string.IsNullOrEmpty(source) && source == "md")
                {
                    filterContext.Result = new RedirectResult("/Home/MDLogin?ReturnUrl=" + HttpContext.Current.Request.Url);
                }
                else
                {
                    filterContext.Result = new RedirectResult("/Home/Login?ReturnUrl=" + HttpContext.Current.Request.Url);
                }
                return;
            }
            //else if (filterContext.HttpContext.Response.StatusCode == 402)
            //{
            //    filterContext.Result = new RedirectResult("/Home/Logout?Status=" + (int)EnumLoginStatus.OtherLogin);
            //}

            var controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName.ToLower();
            var action     = filterContext.ActionDescriptor.ActionName.ToLower();
            var menu       = CommonBusiness.ClientMenus.Where(m => m.Controller.ToLower() == controller && m.View.ToLower() == action).FirstOrDefault();

            //需要判断权限
            if (menu != null && menu.IsLimit == 1)
            {
                CloudSalesEntity.Users user = (CloudSalesEntity.Users)filterContext.HttpContext.Session["ClientManager"];
                if (user.Menus.Where(m => m.MenuCode == menu.MenuCode).Count() <= 0)
                {
                    if (filterContext.RequestContext.HttpContext.Request.IsAjaxRequest())
                    {
                        Dictionary <string, string> result = new Dictionary <string, string>();
                        result.Add("result", "10001");
                        filterContext.Result = new JsonResult()
                        {
                            Data = result,
                            JsonRequestBehavior = JsonRequestBehavior.AllowGet
                        };
                    }
                    else
                    {
                        filterContext.RequestContext.HttpContext.Response.Write("<script>alert('您没有权限访问此页面');history.back();</script>");
                        filterContext.RequestContext.HttpContext.Response.End();
                    }
                }
            }
        }
Exemplo n.º 6
0
        //
        // GET: /Home/

        public ActionResult Index()
        {
            if (Session["ClientManager"] == null)
            {
                return(Redirect("/Home/Login"));
            }

            CloudSalesEntity.Users CurrentUser = (CloudSalesEntity.Users)Session["ClientManager"];
            ViewBag.UserCount = OrganizationBusiness.GetUsers(CurrentUser.AgentID).Count;
            var agent = AgentsBusiness.GetAgentDetail(CurrentUser.AgentID);

            ViewBag.RemainderDays = (agent.EndTime - DateTime.Now).Days;
            ViewBag.UserQuantity  = agent.UserQuantity;
            return(View());
        }
Exemplo n.º 7
0
        public JsonResult GetAgentActions()
        {
            CloudSalesEntity.Users CurrentUser = (CloudSalesEntity.Users)Session["ClientManager"];
            var model = LogBusiness.BaseBusiness.GetAgentActions(CurrentUser.AgentID);

            Dictionary <string, object> JsonDictionary = new Dictionary <string, object>();

            JsonDictionary.Add("model", model);

            return(new JsonResult()
            {
                Data = JsonDictionary,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Exemplo n.º 8
0
        /// <summary>
        /// 员工登录
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public JsonResult UserLogin(string userName, string pwd)
        {
            bool bl = false;

            string operateip = string.IsNullOrEmpty(Request.Headers.Get("X-Real-IP")) ? Request.UserHostAddress : Request.Headers["X-Real-IP"];

            CloudSalesEntity.Users model = CloudSalesBusiness.OrganizationBusiness.GetUserByUserName(userName, pwd, operateip);
            if (model != null)
            {
                Session["ClientManager"] = model;
                bl = true;
            }
            return(new JsonResult
            {
                Data = bl,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Exemplo n.º 9
0
        /// <summary>
        /// 员工登录
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public JsonResult UserLogin(string userName, string pwd, string remember)
        {
            int result = 0;
            Dictionary <string, object> resultObj = new Dictionary <string, object>();

            YXERP.Common.PwdErrorUserEntity pwdErrorUser = null;

            if (Common.Common.CachePwdErrorUsers.ContainsKey(userName))
            {
                pwdErrorUser = Common.Common.CachePwdErrorUsers[userName];
            }

            if (pwdErrorUser == null || (pwdErrorUser.ErrorCount < 3 && pwdErrorUser.ForbidTime < DateTime.Now))
            {
                string operateip = string.IsNullOrEmpty(Request.Headers.Get("X-Real-IP")) ? Request.UserHostAddress : Request.Headers["X-Real-IP"];
                int    outResult;
                CloudSalesEntity.Users model = CloudSalesBusiness.OrganizationBusiness.GetUserByUserName(userName, pwd, out outResult, operateip);
                if (model != null)
                {
                    //保持登录状态
                    HttpCookie cook = new HttpCookie("cloudsales");
                    cook["username"] = userName;
                    cook["pwd"]      = pwd;
                    cook["status"]   = remember;
                    cook.Expires     = DateTime.Now.AddDays(7);
                    Response.Cookies.Add(cook);

                    Session["ClientManager"] = model;
                    Common.Common.CachePwdErrorUsers.Remove(userName);
                    result = 1;
                }
                else
                {
                    if (outResult == 3)
                    {
                        if (pwdErrorUser == null)
                        {
                            pwdErrorUser = new Common.PwdErrorUserEntity();
                        }
                        else
                        {
                            if (pwdErrorUser.ErrorCount > 2)
                            {
                                pwdErrorUser.ErrorCount = 0;
                            }
                        }

                        pwdErrorUser.ErrorCount += 1;
                        if (pwdErrorUser.ErrorCount > 2)
                        {
                            pwdErrorUser.ForbidTime = DateTime.Now.AddHours(2);
                            result = 2;
                        }
                        else
                        {
                            result = 3;
                            resultObj.Add("errorCount", pwdErrorUser.ErrorCount);
                        }

                        Common.Common.CachePwdErrorUsers[userName] = pwdErrorUser;
                    }
                }
            }
            else
            {
                int forbidTime = (int)(pwdErrorUser.ForbidTime - DateTime.Now).TotalMinutes;
                resultObj.Add("forbidTime", forbidTime);
                result = -1;
            }


            resultObj.Add("result", result);

            return(new JsonResult
            {
                Data = resultObj,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Exemplo n.º 10
0
        /// <summary>
        /// 根据用户名密码获取会员信息(登录)
        /// </summary>
        /// <param name="loginname">用户名</param>
        /// <param name="pwd">密码</param>
        /// <returns></returns>
        public static Users GetUserByUserName(string loginname, string pwd, string operateip)
        {
            pwd = CloudSalesTool.Encrypt.GetEncryptPwd(pwd, loginname);
            DataSet ds = new OrganizationDAL().GetUserByUserName(loginname, pwd);
            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.Menus = CommonBusiness.ClientMenus;
            }

            //记录登录日志
            LogBusiness.AddLoginLog(loginname, model != null, CloudSalesEnum.EnumSystemType.Client, operateip);

            return model;
        }
Exemplo n.º 11
0
        /// <summary>
        /// 获取用户列表
        /// </summary>
        /// <param name="keyWords"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="totalCount"></param>
        /// <param name="pageCount"></param>
        /// <returns></returns>
        public static List<Users> GetUsers(string keyWords, string departID, string roleID, string agentid, int pageSize, int pageIndex, ref int totalCount, ref int pageCount)
        {
            string whereSql = "AgentID='" + agentid + "' and Status<>9";

            if (!string.IsNullOrEmpty(keyWords))
                whereSql += " and ( Name like '%" + keyWords + "%' or MobilePhone like '%" + keyWords + "%' or Email like '%" + keyWords + "%')";

            if (!string.IsNullOrEmpty(departID))
                whereSql += " and DepartID='" + departID + "'";

            if (!string.IsNullOrEmpty(roleID))
                whereSql += " and RoleID='" + roleID + "'";

            DataTable dt = CommonBusiness.GetPagerData("Users", "*", whereSql, "AutoID", pageSize, pageIndex, out totalCount, out pageCount);
            List<Users> list = new List<Users>();
            Users model;
            foreach (DataRow item in dt.Rows)
            {
                model = new Users();
                model.FillData(item);

                model.CreateUser = GetUserByUserID(model.CreateUserID, model.AgentID);
                model.Department = GetDepartmentByID(model.DepartID, model.AgentID);
                model.Role = GetRoleByIDCache(model.RoleID, model.AgentID);

                list.Add(model);
            }

            return list;
        }
Exemplo n.º 12
0
        /// <summary>
        /// 根据代理商ID获取员工列表(缓存,包含已注销)
        /// </summary>
        /// <param name="agentid">代理商ID</param>
        /// <returns></returns>
        public static List<Users> GetUsers(string agentid)
        {
            if (string.IsNullOrEmpty(agentid))
            {
                return new List<Users>();
            }
            if (!Users.ContainsKey(agentid))
            {
                List<Users> list = new List<CloudSalesEntity.Users>();
                DataTable dt = OrganizationDAL.BaseProvider.GetUsers(agentid);
                foreach (DataRow dr in dt.Rows)
                {
                    Users model = new Users();
                    model.FillData(dr);

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

                    list.Add(model);
                }
                Users.Add(agentid, list);
                return list;
            }
            return Users[agentid].ToList();
        }
Exemplo n.º 13
0
        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="agentid"></param>
        /// <returns></returns>
        public static Users GetUserByUserID(string userid, string agentid)
        {
            if (string.IsNullOrEmpty(userid) || string.IsNullOrEmpty(agentid))
            {
                return null;
            }

            var list = GetUsers(agentid);
            if (list.Where(u => u.UserID == userid).Count() > 0)
            {
                return list.Where(u => u.UserID == userid).FirstOrDefault();
            }
            else
            {
                DataTable dt = new OrganizationDAL().GetUserByUserID(userid);
                Users model = new Users();
                if (dt.Rows.Count > 0)
                {
                    model.FillData(dt.Rows[0]);

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

                    Users[agentid].Add(model);
                }
                return model;
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// 根据用户名密码获取会员信息(登录)
        /// </summary>
        /// <param name="loginname">用户名</param>
        /// <param name="pwd">密码</param>
        /// <param name="result">1:查询正常;2:用户名不存在;3:用户密码有误</param>
        /// <returns></returns>
        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.AgentID);
                model.Role = GetRoleByIDCache(model.RoleID, model.AgentID);

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

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

                //权限
                if (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,Manage.ClientBusiness.GetClientDetail(model.ClientID).AgentID == model.AgentID ? CloudSalesEnum.EnumSystemType.Client : CloudSalesEnum.EnumSystemType.Agent, operateip, model.UserID, model.AgentID, model.ClientID);
            }
            else
            {
                LogBusiness.AddLoginLog(loginname, false, CloudSalesEnum.EnumSystemType.Client, operateip, "", "", "");
            }

            return model;
        }
Exemplo n.º 15
0
        /// <summary>
        /// 添加员工
        /// </summary>
        /// <param name="loginname">登录名</param>
        /// <param name="loginpwd">密码</param>
        /// <param name="name">姓名</param>
        /// <param name="mobile">手机</param>
        /// <param name="email">邮箱</param>
        /// <param name="citycode">城市</param>
        /// <param name="address">地址</param>
        /// <param name="jobs">职位</param>
        /// <param name="roleid">角色ID</param>
        /// <param name="departid">部门ID</param>
        /// <param name="parentid">上级ID</param>
        /// <param name="agentid">代理商ID></param>
        /// <param name="clientid">客户端ID</param>
        /// <param name="mduserid">明道用户ID</param>
        /// <param name="mdprojectid">明道网络ID</param>
        /// <param name="isAppAdmin">是否应用管理员</param>
        /// <param name="operateid">操作人</param>
        /// <param name="result">返回结果 0 失败 1成功 2账号已存在 3人数达到限制</param>
        /// <returns></returns>
        public static Users CreateUser(string loginname, string loginpwd, string name, string mobile, string email, string citycode, string address, string jobs,
                               string roleid, string departid, string parentid, string agentid, string clientid, string mduserid, string mdprojectid, int isAppAdmin, string operateid, out int result)
        {
            string userid = Guid.NewGuid().ToString();

            loginpwd = CloudSalesTool.Encrypt.GetEncryptPwd(loginpwd, loginname);

            Users user = null;

            DataTable dt = OrganizationDAL.BaseProvider.CreateUser(userid, loginname, loginpwd, name, mobile, email, citycode, address, jobs, roleid, departid, parentid, agentid, clientid, mduserid, mdprojectid, isAppAdmin, operateid, out result);
            if (dt.Rows.Count > 0)
            {
                user = new Users();
                user.FillData(dt.Rows[0]);

                var cache = GetUsers(user.AgentID).Where(m => m.UserID == user.UserID).FirstOrDefault();
                if (cache == null || string.IsNullOrEmpty(cache.UserID))
                {
                    user.Role = GetRoleByID(user.RoleID, user.AgentID);
                    user.Department = GetDepartmentByID(user.DepartID, user.AgentID);
                    Users[user.AgentID].Add(user);
                }
                else
                {
                    cache.Status = 1;
                }

                //日志
                LogBusiness.AddActionLog(CloudSalesEnum.EnumSystemType.Client, CloudSalesEnum.EnumLogObjectType.User, EnumLogType.Create, "", operateid, agentid, clientid);
            }
            return user;
        }
Exemplo n.º 16
0
        /// <summary>
        /// 获取用户信息(缓存)
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="clientid"></param>
        /// <returns></returns>
        public static Users GetUserByUserID(string userid, string clientid)
        {
            if (!Users.ContainsKey(clientid))
            {
                Users.Add(clientid, new List<Users>());
            }

            if (Users[clientid].Where(u => u.UserID == userid).Count() > 0)
            {
                return Users[clientid].Where(u => u.UserID == userid).FirstOrDefault();
            }
            else
            {
                DataTable dt = new OrganizationDAL().GetUserByUserID(userid);
                Users model = new Users();
                if (dt.Rows.Count > 0)
                {
                    model.FillData(dt.Rows[0]);
                    Users[clientid].Add(model);
                }
                return model;
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// 根据用户名密码获取会员信息(登录)
        /// </summary>
        /// <param name="loginname">用户名</param>
        /// <param name="pwd">密码</param>
        /// <returns></returns>
        public static Users GetUserByUserName(string loginname, string pwd, string operateip)
        {
            pwd = CloudSalesTool.Encrypt.GetEncryptPwd(pwd, loginname);
            DataSet ds = new OrganizationDAL().GetUserByUserName(loginname, pwd);
            Users model = null;
            if (ds.Tables.Contains("User") && ds.Tables["User"].Rows.Count > 0)
            {
                model = new Users();
                model.FillData(ds.Tables["User"].Rows[0]);

                if (CommonCache.ClientMenus.ContainsKey(model.ClientID))
                {
                    model.Menus = CommonCache.ClientMenus[model.ClientID];
                }
                else if (ds.Tables.Contains("Modules"))
                {
                    List<Menu> list = new List<Menu>();
                    var modules = CommonCache.Modules;
                    foreach (DataRow dr in ds.Tables["Modules"].Rows)
                    {
                        Modules module = new Modules();
                        module.FillData(dr);
                        if (modules.ContainsKey(module.ModulesID))
                        {
                            foreach (var item in modules[module.ModulesID])
                            {
                                if (list.Where(m => m.MenuCode == item.MenuCode).Count() == 0)
                                {
                                    list.Add(item);
                                }
                            }
                        }
                    }
                    list = list.OrderBy(m => m.Sort).ToList();
                    CommonCache.ClientMenus.Add(model.ClientID, list);
                    model.Menus = list;
                }
            }

            //记录登录日志
            LogBusiness.AddLoginLog(loginname, model != null, CloudSalesEnum.EnumSystemType.Client, operateip);

            return model;
        }
Exemplo n.º 18
0
        /// <summary>
        /// 根据明道用户ID和网络ID获取云销用户信息(登录)
        /// </summary>
        /// <param name="mduserid"></param>
        /// <param name="mdprojectid"></param>
        /// <returns></returns>
        public static Users GetUserByMDUserID(string mduserid, string mdprojectid, string operateip)
        {
            DataSet ds = new OrganizationDAL().GetUserByMDUserID(mduserid);
            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.Department = GetDepartmentByID(model.DepartID, model.AgentID);
                model.Role = GetRoleByIDCache(model.RoleID, model.AgentID);

                model.Menus = CommonBusiness.ClientMenus;

                //处理缓存
                if (!Users.ContainsKey(model.AgentID))
                {
                    GetUsers(model.AgentID);
                }
                if (Users[model.AgentID].Where(u => u.MDUserID == mduserid).Count() == 0)
                {
                    Users[model.AgentID].Add(model);
                }
            }
            if (!string.IsNullOrEmpty(operateip))
            {
                //记录登录日志
                LogBusiness.AddLoginLog(mduserid, model != null, CloudSalesEnum.EnumSystemType.Client, operateip);
            }
            return model;
        }
Exemplo n.º 19
0
        public static Users GetUserByMDUserID(string mduserid, string mdprojectid, string operateip)
        {
            DataSet ds = new OrganizationDAL().GetUserByMDUserID(mduserid,mdprojectid);
            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.AgentID);
                model.Role = GetRoleByIDCache(model.RoleID, model.AgentID);

                model.Agents = AgentsBusiness.GetAgentDetail(model.AgentID);
                model.Client = Manage.ClientBusiness.GetClientDetail(model.ClientID);

                //处理缓存
                if (!Users.ContainsKey(model.AgentID))
                {
                    GetUsers(model.AgentID);
                }
                if (Users[model.AgentID].Where(u => u.UserID == model.UserID).Count() == 0)
                {
                    Users[model.AgentID].Add(model);
                }
                else
                {
                    var user = Users[model.AgentID].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(mduserid, true, Manage.ClientBusiness.GetClientDetail(model.ClientID).AgentID == model.AgentID ? CloudSalesEnum.EnumSystemType.Client : CloudSalesEnum.EnumSystemType.Agent, operateip, model.UserID, model.AgentID, model.ClientID);
            }
            else
            {
                LogBusiness.AddLoginLog(mduserid, false, CloudSalesEnum.EnumSystemType.Client, operateip, "", "", "");
            }
            return model;
        }