示例#1
0
 /// <summary>
 /// 获取部门列表
 /// </summary>
 /// <param name="clientid">客户端ID</param>
 /// <returns></returns>
 public static List<Department> GetDepartments(string clientid)
 {
     DataTable dt = new OrganizationDAL().GetDepartments(clientid);
     List<Department> list = new List<Department>();
     foreach (DataRow dr in dt.Rows)
     {
         Department model = new Department();
         model.FillData(dr);
         list.Add(model);
     }
     return list;
 }
示例#2
0
 /// <summary>
 /// 获取角色列表
 /// </summary>
 /// <param name="agentid">代理商ID</param>
 /// <returns></returns>
 public static List<Role> GetRoles(string agentid)
 {
     DataTable dt = new OrganizationDAL().GetRoles(agentid);
     List<Role> list = new List<Role>();
     foreach (DataRow dr in dt.Rows)
     {
         Role model = new Role();
         model.FillData(dr);
         list.Add(model);
     }
     return list;
 }
示例#3
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;
            }
        }
示例#4
0
 /// <summary>
 /// 编辑部门
 /// </summary>
 /// <param name="departid">部门ID</param>
 /// <param name="name">名称</param>
 /// <param name="description">描述</param>
 /// <param name="operateid">操作人</param>
 /// <param name="operateip">操作IP</param>
 /// <returns></returns>
 public bool UpdateDepartment(string departid, string name, string description, string operateid, string operateip, string agentid)
 {
     var dal = new OrganizationDAL();
     bool bl = dal.UpdateDepartment(departid, name, description, agentid);
     if (bl)
     {
         //处理缓存
         var model = GetDepartments(agentid).Where(d => d.DepartID == departid).FirstOrDefault();
         model.Name = name;
         model.Description = description;
     }
     return bl;
 }
示例#5
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;
        }
示例#6
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;
            }
        }
示例#7
0
 /// <summary>
 /// 获取角色列表
 /// </summary>
 /// <param name="agentid">代理商ID</param>
 /// <returns></returns>
 public static List<Role> GetRoles(string agentid)
 {
     if (!Roles.ContainsKey(agentid))
     {
         DataTable dt = new OrganizationDAL().GetRoles(agentid);
         List<Role> list = new List<Role>();
         foreach (DataRow dr in dt.Rows)
         {
             Role model = new Role();
             model.FillData(dr);
             list.Add(model);
         }
         Roles.Add(agentid, list);
         return list;
     }
     return Roles[agentid].Where(m => m.Status == 1).ToList();
 }
示例#8
0
 /// <summary>
 /// 获取部门列表
 /// </summary>
 /// <param name="agentid">代理商ID</param>
 /// <returns></returns>
 public static List<Department> GetDepartments(string agentid)
 {
     if (!Departments.ContainsKey(agentid))
     {
         DataTable dt = new OrganizationDAL().GetDepartments(agentid);
         List<Department> list = new List<Department>();
         foreach (DataRow dr in dt.Rows)
         {
             Department model = new Department();
             model.FillData(dr);
             list.Add(model);
         }
         Departments.Add(agentid, list);
         return list;
     }
     return Departments[agentid].Where(m => m.Status == 1).ToList();
 }
示例#9
0
        /// <summary>
        /// 验证账号密码是否正确
        /// </summary>
        /// <param name="loginname"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public static bool ConfirmLoginPwd(string loginname, string pwd)
        {
            pwd = CloudSalesTool.Encrypt.GetEncryptPwd(pwd, loginname);
            int result;
            DataSet ds = new OrganizationDAL().GetUserByUserName(loginname, pwd,out result);

            if (ds.Tables.Contains("User") && ds.Tables["User"].Rows.Count > 0)
            {
                return true;
            }

            return false;
        }
示例#10
0
 /// <summary>
 /// 编辑部门
 /// </summary>
 /// <param name="departid">部门ID</param>
 /// <param name="name">名称</param>
 /// <param name="description">描述</param>
 /// <param name="operateid">操作人</param>
 /// <param name="operateip">操作IP</param>
 /// <returns></returns>
 public bool UpdateDepartment(string departid, string name, string description, string operateid, string operateip)
 {
     var dal = new OrganizationDAL();
     return dal.UpdateDepartment(departid, name, description);
 }
示例#11
0
 /// <summary>
 /// 添加部门
 /// </summary>
 /// <param name="name">名称</param>
 /// <param name="parentid">上级ID</param>
 /// <param name="description">描述</param>
 /// <param name="operateid">操作人</param>
 /// <param name="clientid">客户端ID</param>
 /// <returns></returns>
 public string AddDepartment(string name, string parentid, string description, string operateid, string clientid)
 {
     var dal = new OrganizationDAL();
     return dal.AddDepartment(name, parentid, description, operateid, clientid);
 }
示例#12
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;
        }
示例#13
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;
        }
        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;
        }
示例#15
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;
        }