Esempio n. 1
0
File: User.cs Progetto: qdjx/C5
        //获取用户修改信息
        public static UserInfo GetModifyInfo(long UserID, out AlertMessage alertMessage)
        {
            alertMessage = null;

            if (Login.GetLoginInfo() == null)
            {
                //登录检查
                alertMessage = new AlertMessage { Message = "未登录不允许更新用户信息", Type = AlertType.warning };
                return null;
            }
            else if (UserID == 0)
            {
                //权限检查
                if (!AUTH.PermissionCheck(ModuleInfo, ActionInfos.Where(i => i.Name == "Create").FirstOrDefault(), out string Message))
                {
                    alertMessage = new AlertMessage { Message = Message, Type = AlertType.warning };
                    return null;
                }
            }
            else if (UserID != Login.GetLoginInfo().UserInfo.ID)
            {
                //权限检查
                if (!AUTH.PermissionCheck(ModuleInfo, ActionInfos.Where(i => i.Name == "Modify").FirstOrDefault(), out string Message))
                {
                    alertMessage = new AlertMessage { Message = Message, Type = AlertType.warning };
                    return null;
                }
            }

            return GetUserInfo(UserID);
        }
Esempio n. 2
0
File: User.cs Progetto: qdjx/C5
        //获取用户角色指定信息
        public static List<UserRoleAssign> GetRoleUserAssignList(long UserID, out AlertMessage alertMessage)
        {
            alertMessage = null;

            //权限检查
            if (!AUTH.PermissionCheck(ModuleInfo, ActionInfos.Where(i => i.Name == "RoleAssign").FirstOrDefault(), out string Message))
            {
                alertMessage = new AlertMessage { Message = Message, Type = AlertType.warning };
                return null;
            }

            using (var EF = new EF())
            {
                return (from roleInfo in EF.RoleInfos
                        join userRole in (EF.UserRoles.Where(i => i.UserID == UserID)) on roleInfo.ID equals userRole.RoleID into temp1
                        from userRole in temp1.DefaultIfEmpty()
                        where roleInfo.Enabled == true
                        orderby roleInfo.ID
                        select new UserRoleAssign
                        {
                            ID = roleInfo.ID,
                            IconFont = roleInfo.IconFont,
                            Name = roleInfo.Name,
                            Title = roleInfo.Title,
                            Enabled = roleInfo.Enabled,
                            UserID = userRole == null ? 0 : userRole.UserID,
                            UserAssign = userRole == null ? false : true
                        }).ToList();
            }
        }
Esempio n. 3
0
        //更新菜单信息
        public static MenuInfo MenuInfoUpload(MenuInfo menuInfo, out AlertMessage alertMessage)
        {
            alertMessage = null;

            //权限检查
            if (!AUTH.PermissionCheck(ModuleInfo, ActionInfos.Where(i => i.Name == "Modify").FirstOrDefault(), out string Message))
            {
                alertMessage = new AlertMessage {
                    Message = Message, Type = AlertType.warning
                };
                return(null);
            }

            using (var EF = new EF())
            {
                var menu_exist = EF.MenuInfos.Where(i => i.ID == menuInfo.ID).FirstOrDefault();
                if (menu_exist == null)
                {
                    return(null);
                }
                menu_exist.Name     = menuInfo.Name;
                menu_exist.Title    = menuInfo.Title;
                menu_exist.URL      = menuInfo.URL;
                menu_exist.OrderBy  = menuInfo.OrderBy;
                menu_exist.IconFont = menuInfo.IconFont;
                EF.SaveChanges();
                return(menu_exist);
            }
        }
Esempio n. 4
0
        //获取菜单组列表
        public static List <MenuGroupInfo> GetMenuGroupInfos(out AlertMessage alertMessage)
        {
            alertMessage = null;

            //权限检查
            if (!AUTH.PermissionCheck(ModuleInfo, ActionInfos.Where(i => i.Name == "List").FirstOrDefault(), out string Message))
            {
                alertMessage = new AlertMessage {
                    Message = Message, Type = AlertType.warning
                };
                return(null);
            }

            var menuGroupList = new List <MenuGroupInfo>();

            string[] EnumText  = Enum.GetNames(typeof(MenuGroupType));
            int[]    EnumValue = (int[])Enum.GetValues(typeof(MenuGroupType));
            for (int i = 0; i < EnumText.Length; i++)
            {
                menuGroupList.Add(new MenuGroupInfo
                {
                    GroupID    = EnumValue[i],
                    GroupName  = EnumText[i],
                    GroupTitle = GetMenuGroupTitle(EnumValue[i])
                });
            }
            return(menuGroupList);
        }
Esempio n. 5
0
        //初始化信息
        public static void InitRoleInfo(out AlertMessage alertMessage)
        {
            alertMessage = null;

            //权限检查
            if (!AUTH.PermissionCheck(ModuleInfo, ActionInfos.Where(i => i.Name == "Init").FirstOrDefault(), out string Message))
            {
                alertMessage = new AlertMessage {
                    Message = Message, Type = AlertType.warning
                };
                return;
            }

            using (var EF = new EF())
            {
                //清除数据表
                var delCount  = EF.Database.ExecuteSqlCommand(@"TRUNCATE TABLE RoleInfo;");
                var roleInfos = new List <RoleInfo> {
                    new RoleInfo {
                        Name = "finance", Title = "财务", IconFont = "", Enabled = true
                    },
                    new RoleInfo {
                        Name = "business", Title = "商务", IconFont = "", Enabled = true
                    },
                };
                EF.RoleInfos.AddRange(roleInfos);
                EF.SaveChanges();
            }
        }
Esempio n. 6
0
File: User.cs Progetto: qdjx/C5
        //用户注册审核
        public static void SetUserChecked(long UserID, long NotificationsID, out AlertMessage alertMessage)
        {
            alertMessage = null;

            //权限检查
            if (!AUTH.PermissionCheck(ModuleInfo, ActionInfos.Where(i => i.Name == "Checked").FirstOrDefault(), out string Message))
            {
                alertMessage = new AlertMessage { Message = Message, Type = AlertType.warning };
                return;
            }

            //更改通知状态为已读
            Notifications.SetHaveRead(NotificationsID);

            //审核用户
            var userInfo = GetUserInfo(UserID);
            if (userInfo == null)
            {
                alertMessage = new AlertMessage { Message = string.Format("用户编号[{0}]不存在!", UserID), Type = AlertType.error };
                return;
            }

            if (userInfo.StateID == (int)UserState.启用)
            {
                alertMessage = new AlertMessage { Message = string.Format("用户[{0}]已[{1}]!", userInfo.Name, Enum.Parse(typeof(UserState), userInfo.StateID.ToString())), Type = AlertType.warning };
                return;
            }

            SetUserState(UserID, UserState.启用);
        }
Esempio n. 7
0
File: Module.cs Progetto: qdjx/C5
        //初始化
        public static void InitModuleInfo(out AlertMessage alertMessage)
        {
            alertMessage = null;

            //权限检查
            if (!AUTH.PermissionCheck(ModuleInfo, ActionInfos.Where(i => i.Name == "Init").FirstOrDefault(), out string Message))
            {
                alertMessage = new AlertMessage {
                    Message = Message, Type = AlertType.warning
                };
                return;
            }

            using (var EF = new EF())
            {
                //清除数据表
                var delCount = EF.Database.ExecuteSqlCommand(@"TRUNCATE TABLE ModuleAction; TRUNCATE TABLE ActionInfo; TRUNCATE TABLE ModuleInfo;");

                //反射查询模块信息
                try
                {
                    foreach (Type tClass in Assembly.GetExecutingAssembly().GetTypes())
                    {
                        ModuleInfo        moduleInfo  = null;
                        List <ActionInfo> actionInfos = null;
                        FieldInfo[]       tCFields    = tClass.GetFields();
                        foreach (FieldInfo field in tCFields)
                        {
                            switch (field.Name)
                            {
                            case "ModuleInfo": moduleInfo = field.GetValue(null) as ModuleInfo; break;

                            case "ActionInfos": actionInfos = field.GetValue(null) as List <ActionInfo>; break;
                            }
                            if (moduleInfo != null && actionInfos != null)
                            {
                                EF.ModuleInfos.Add(moduleInfo);
                                EF.ActionInfos.AddRange(actionInfos);
                                EF.SaveChanges();
                                foreach (var item in actionInfos)
                                {
                                    EF.ModuleActions.Add(new ModuleAction
                                    {
                                        ModuleID = moduleInfo.ID,
                                        ActionID = item.ID,
                                    });
                                }
                                EF.SaveChanges();
                                break;
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    //throw;
                }
            }
        }
Esempio n. 8
0
        //获取修改信息
        public static MenuInfo GetModifyInfo(long MenuID, out AlertMessage alertMessage)
        {
            alertMessage = null;

            //权限检查
            if (!AUTH.PermissionCheck(ModuleInfo, ActionInfos.Where(i => i.Name == "Modify").FirstOrDefault(), out string Message))
            {
                alertMessage = new AlertMessage {
                    Message = Message, Type = AlertType.warning
                };
                return(null);
            }
            return(GetMenuInfo(MenuID));
        }
Esempio n. 9
0
File: Module.cs Progetto: qdjx/C5
        //获取模块信息
        private static ModuleInfo GetModuleInfo(long ModuleID, string ActionName, out AlertMessage alertMessage)
        {
            alertMessage = null;

            //权限检查
            if (!AUTH.PermissionCheck(ModuleInfo, ActionInfos.Where(i => i.Name == ActionName).FirstOrDefault(), out string Message))
            {
                alertMessage = new AlertMessage {
                    Message = Message, Type = AlertType.warning
                };
                return(null);
            }

            using (var EF = new EF())
            {
                return(EF.ModuleInfos.Where(i => i.ID == ModuleID).FirstOrDefault());
            }
        }
Esempio n. 10
0
File: User.cs Progetto: qdjx/C5
        //获取用户角色信息
        public static UserInfo GetRoleInfo(long UserID, out AlertMessage alertMessage)
        {
            alertMessage = null;

            if (Login.GetLoginInfo() == null)
            {
                //登录检查
                alertMessage = new AlertMessage { Message = "未登录不允许进行角色指定", Type = AlertType.warning };
                return null;
            }
            //权限检查
            if (!AUTH.PermissionCheck(ModuleInfo, ActionInfos.Where(i => i.Name == "RoleAssign").FirstOrDefault(), out string Message))
            {
                alertMessage = new AlertMessage { Message = Message, Type = AlertType.warning };
                return null;
            }

            return GetUserInfo(UserID);
        }
Esempio n. 11
0
File: User.cs Progetto: qdjx/C5
        //更新用户角色信息
        public static List<UserRole> UserRoleAssignUpload(long[] UsersID, List<UserRole> userRoles, out AlertMessage alertMessage)
        {
            alertMessage = null;

            //权限检查
            if (!AUTH.PermissionCheck(ModuleInfo, ActionInfos.Where(i => i.Name == "RoleAssign").FirstOrDefault(), out string Message))
            {
                alertMessage = new AlertMessage { Message = Message, Type = AlertType.warning };
                return null;
            }

            using (var EF = new EF())
            {
                EF.UserRoles.RemoveRange(EF.UserRoles.Where(i => UsersID.Contains(i.UserID)));
                EF.SaveChanges();
                EF.UserRoles.AddRange(userRoles);
                EF.SaveChanges();
            }
            return userRoles;
        }
Esempio n. 12
0
File: User.cs Progetto: qdjx/C5
        //用户启用
        public static void SetUserEnabled(long UserID, bool Enabled, out AlertMessage alertMessage)
        {
            alertMessage = null;

            //权限检查
            if (!AUTH.PermissionCheck(ModuleInfo, ActionInfos.Where(i => i.Name == (Enabled ? "Enabled" : "Disabled")).FirstOrDefault(), out string Message))
            {
                alertMessage = new AlertMessage { Message = Message, Type = AlertType.warning };
                return;
            }

            //不允许禁用超级管理员
            var userInfo = GetUserInfo(UserID);
            if (!Enabled && userInfo.Name == "admin")
            {
                alertMessage = new AlertMessage { Message = "不允许禁用系统管理员[admin]!", Type = AlertType.error };
                return;
            }

            //启用禁用
            SetUserState(UserID, Enabled ? UserState.启用 : UserState.禁用);
            alertMessage = new AlertMessage { Message = "用户[" + userInfo.Name + "]" + (Enabled ? "启用" : "禁用") + "成功!", Type = AlertType.success };
        }
Esempio n. 13
0
        //设置状态
        public static void SetMenuEnabled(long MenuID, bool Enabled, out AlertMessage alertMessage)
        {
            alertMessage = null;

            //权限检查
            if (!AUTH.PermissionCheck(ModuleInfo, ActionInfos.Where(i => i.Name == (Enabled ? "Enabled" : "Disabled")).FirstOrDefault(), out string Message))
            {
                alertMessage = new AlertMessage {
                    Message = Message, Type = AlertType.warning
                };
                return;
            }

            using (var EF = new EF())
            {
                var menuInfo = EF.MenuInfos.Where(i => i.ID == MenuID).FirstOrDefault();
                menuInfo.Enabled = Enabled;
                EF.SaveChanges();

                alertMessage = new AlertMessage {
                    Message = "菜单[" + menuInfo.Name + "]" + (Enabled ? "启用" : "禁用") + "成功!", Type = AlertType.success
                };
            }
        }
Esempio n. 14
0
        //更新角色信息
        public static RoleInfo RoleInfoUpload(RoleInfo roleInfo, out AlertMessage alertMessage)
        {
            //权限检查
            if (!AUTH.PermissionCheck(ModuleInfo, ActionInfos.Where(i => i.Name == (roleInfo.ID == 0 ? "Create" : "Modify")).FirstOrDefault(), out string Message))
            {
                alertMessage = new AlertMessage {
                    Message = Message, Type = AlertType.warning
                };
                return(null);
            }

            //表单检查
            if (string.IsNullOrWhiteSpace(roleInfo.Name))
            {
                alertMessage = new AlertMessage {
                    Message = "角色代码不能为空。", Type = AlertType.warning
                };
                return(null);
            }
            if (string.IsNullOrWhiteSpace(roleInfo.Title))
            {
                alertMessage = new AlertMessage {
                    Message = "角色名称不能为空。", Type = AlertType.warning
                };
                return(null);
            }

            using (var EF = new EF())
            {
                //修改是否存在?用户名唯一?
                RoleInfo role_exist      = null;
                RoleInfo role_name_exist = null;
                if (roleInfo.ID == 0)
                {
                    role_name_exist = EF.RoleInfos.Where(i => i.Name == roleInfo.Name).FirstOrDefault();
                }
                else
                {
                    role_exist = EF.RoleInfos.Where(i => i.ID == roleInfo.ID).FirstOrDefault();
                    if (role_exist == null)
                    {
                        alertMessage = new AlertMessage {
                            Message = string.Format("角色编号[{0}]不存在。", roleInfo.ID), Type = AlertType.warning
                        };
                        return(null);
                    }
                    role_name_exist = EF.RoleInfos.Where(i => i.ID != roleInfo.ID && i.Name == roleInfo.Name).FirstOrDefault();
                }
                if (role_name_exist != null && role_name_exist.ID > 0)
                {
                    alertMessage = new AlertMessage {
                        Message = string.Format("角色名称[{0}]已被ID[{1}]使用。", roleInfo.Name, role_name_exist.ID), Type = AlertType.warning
                    };
                    return(null);
                }

                //数据保存
                if (roleInfo.ID == 0)
                {
                    role_exist = EF.RoleInfos.Add(new RoleInfo {
                        Enabled = true,
                    });
                }
                role_exist.Name     = roleInfo.Name;
                role_exist.Title    = roleInfo.Title;
                role_exist.IconFont = roleInfo.IconFont;
                EF.SaveChanges();

                //更新完成
                alertMessage = null;
                return(role_exist);
            }
        }
Esempio n. 15
0
File: User.cs Progetto: qdjx/C5
        //更新用户信息
        public static UserInfo UserInfoUpload(UserInfo userInfo, List<FileUploadInfo> fileUploadInfo
            , PersonInfo personInfo, ContactInfo contactInfo, bool isRegisters, out AlertMessage alertMessage)
        {
            if (userInfo.ID == 0 && isRegisters) { userInfo.StateID = (int)UserState.提交; }
            else if (Login.GetLoginInfo() == null)
            {
                //登录检查
                alertMessage = new AlertMessage { Message = "未登录不允许更新用户信息", Type = AlertType.warning };
                return null;
            }
            else if (userInfo.ID != Login.GetLoginInfo().UserInfo.ID)
            {
                //权限检查
                if (!AUTH.PermissionCheck(ModuleInfo, ActionInfos.Where(i => i.Name == (userInfo.ID == 0 ? "Create" : "Modify")).FirstOrDefault(), out string Message))
                {
                    alertMessage = new AlertMessage { Message = Message, Type = AlertType.warning };
                    return null;
                }
            }

            //表单检查
            if (string.IsNullOrWhiteSpace(userInfo.Name))
            {
                alertMessage = new AlertMessage { Message = "用户名不能为空。", Type = AlertType.warning };
                return null;
            }
            if (string.IsNullOrWhiteSpace(userInfo.Password))
            {
                alertMessage = new AlertMessage { Message = "密码不能为空。", Type = AlertType.warning };
                return null;
            }

            using (var EF = new EF())
            {
                //检查用户初始化,可略去
                UserInfo user_admin = EF.UserInfos.Where(i => i.Name == "admin").FirstOrDefault();
                if (user_admin == null) { InitUserInfo(); }

                //修改是否存在?用户名唯一?
                UserInfo user_exist = null;
                UserInfo user_name_exist = null;
                if (userInfo.ID == 0)
                {
                    user_name_exist = EF.UserInfos.Where(i => i.StateID != (int)UserState.删除 && i.Name == userInfo.Name).FirstOrDefault();
                }
                else
                {
                    user_exist = EF.UserInfos.Where(i => i.StateID != (int)UserState.删除 && i.ID == userInfo.ID).FirstOrDefault();
                    if (user_exist == null)
                    {
                        alertMessage = new AlertMessage { Message = string.Format("用户编号[{0}]不存在。", userInfo.ID), Type = AlertType.warning };
                        return null;
                    }
                    user_name_exist = EF.UserInfos.Where(i => i.ID != userInfo.ID && i.StateID != (int)UserState.删除
                        && i.Name == userInfo.Name).FirstOrDefault();
                }
                if (user_name_exist != null && user_name_exist.ID > 0)
                {
                    alertMessage = new AlertMessage { Message = string.Format("用户名[{0}]已被ID[{1}]使用。", userInfo.Name, user_name_exist.ID), Type = AlertType.warning };
                    return null;
                }

                //数据保存
                using (TransactionScope TS = new TransactionScope())
                {
                    //日志信息
                    if (user_exist != null)
                    {
                        UserInfo_log userInfo_Log = new UserInfo_log
                        {
                            UserID = user_exist.ID,
                            GUID = user_exist.GUID,
                            Name = user_exist.Name,
                            Password = user_exist.Password,
                            StateID = user_exist.StateID,
                            UpdateTime = user_exist.UpdateTime
                        };
                        EF.UserInfo_logs.Add(userInfo_Log);
                        EF.SaveChanges();
                        var avatar_log = EF.UserAvatars.Where(i => i.UserID == user_exist.ID && i.LogID == null);
                        foreach (var item in avatar_log) { item.LogID = userInfo_Log.ID; }
                        var person_log = EF.UserPersons.Where(i => i.UserID == user_exist.ID && i.LogID == null);
                        foreach (var item in person_log) { item.LogID = userInfo_Log.ID; }
                        var contact_log = EF.UserContacts.Where(i => i.UserID == user_exist.ID && i.LogID == null);
                        foreach (var item in contact_log) { item.LogID = userInfo_Log.ID; }
                        EF.SaveChanges();
                    }

                    //用户信息
                    if (userInfo.ID == 0)
                    {
                        user_exist = EF.UserInfos.Add(new UserInfo
                        {
                            GUID = Guid.NewGuid().ToString(),
                            StateID = (int)UserState.创建,
                        });
                    }
                    user_exist.Name = userInfo.Name;
                    user_exist.Password = userInfo.Password;
                    user_exist.UpdateTime = DateTime.Now;
                    EF.SaveChanges();
                    //头像信息
                    if (fileUploadInfo != null && fileUploadInfo.Count > 0)
                    {
                        long fileID = fileUploadInfo[0].FileInfo.ID;
                        var userAvatar_exist = EF.UserAvatars.Where(i => i.UserID == user_exist.ID && i.FileID == fileID && i.LogID == null).FirstOrDefault();
                        if (userAvatar_exist == null)
                        {
                            EF.UserAvatars.Add(userAvatar_exist = new UserAvatar
                            {
                                UserID = user_exist.ID,
                                FileID = fileID,
                            });
                            EF.SaveChanges();
                        }
                    }
                    //个人信息
                    var person_exist = EF.PersonInfos.Where(i => i.Name == personInfo.Name
                        && i.GenderTypeID == personInfo.GenderTypeID
                        && i.Birthday == personInfo.Birthday
                        && i.IDCardNO == personInfo.IDCardNO).FirstOrDefault();
                    if (person_exist == null)
                    {
                        EF.PersonInfos.Add(person_exist = new PersonInfo
                        {
                            Name = personInfo.Name,
                            GenderTypeID = personInfo.GenderTypeID,
                            Birthday = personInfo.Birthday,
                            IDCardNO = personInfo.IDCardNO,
                        });
                        EF.SaveChanges();
                    }
                    var userPerson_exist = EF.UserPersons.Where(i => i.UserID == user_exist.ID
                        && i.PersonID == person_exist.ID && i.LogID == null).FirstOrDefault();
                    if (userPerson_exist == null)
                    {
                        EF.UserPersons.Add(userPerson_exist = new UserPerson
                        {
                            UserID = user_exist.ID,
                            PersonID = person_exist.ID
                        });
                        EF.SaveChanges();
                    }
                    //联系信息
                    var contact_exist = EF.ContactInfos.Where(i => i.Phone == contactInfo.Phone
                        && i.Mobile == contactInfo.Mobile
                        && i.EMail == contactInfo.EMail
                        && i.Address == contactInfo.Address).FirstOrDefault();
                    if (contact_exist == null)
                    {
                        EF.ContactInfos.Add(contact_exist = new ContactInfo
                        {
                            Phone = contactInfo.Phone,
                            Mobile = contactInfo.Mobile,
                            EMail = contactInfo.EMail,
                            Address = contactInfo.Address,
                        });
                        EF.SaveChanges();
                    }
                    var userContact = EF.UserContacts.Where(i => i.UserID == user_exist.ID
                        && i.ContactID == contact_exist.ID && i.LogID == null).FirstOrDefault();
                    if (userContact == null)
                    {
                        EF.UserContacts.Add(userContact = new UserContact
                        {
                            UserID = user_exist.ID,
                            ContactID = contact_exist.ID
                        });
                        EF.SaveChanges();
                    }

                    //更新完成
                    TS.Complete();
                    alertMessage = null;
                    return user_exist;
                }
            }
        }
Esempio n. 16
0
        //初始化菜单信息
        public static void InitMenuInfo(out AlertMessage alertMessage)
        {
            alertMessage = null;

            //权限检查
            if (!AUTH.PermissionCheck(ModuleInfo, ActionInfos.Where(i => i.Name == "Init").FirstOrDefault(), out string Message))
            {
                alertMessage = new AlertMessage {
                    Message = Message, Type = AlertType.warning
                };
                return;
            }

            using (var EF = new EF())
            {
                //清除数据表
                var delCount = EF.Database.ExecuteSqlCommand("TRUNCATE TABLE MenuGroup; TRUNCATE TABLE MenuInfo;");

                //左边菜单
                var asideMenuRoots = new List <MenuInfo> {
                    new MenuInfo {
                        ParentID = 0, OrderBy = 1, Name = "BasicInfo", Title = "基础资料", IconFont = "fa fa-database", URL = null, Enabled = true,
                    },
                    new MenuInfo {
                        ParentID = 0, OrderBy = 1, Name = "INV", Title = "存货管理", IconFont = "fa fa-warehouse", URL = null, Enabled = true,
                    },
                    new MenuInfo {
                        ParentID = 0, OrderBy = 1, Name = "RMS", Title = "零售管理", IconFont = "flaticon2-supermarket", URL = null, Enabled = true,
                    },
                    new MenuInfo {
                        ParentID = 0, OrderBy = 1, Name = "OMS", Title = "订单管理", IconFont = "fa fa-money-check-alt", URL = null, Enabled = true,
                    },
                    new MenuInfo {
                        ParentID = 0, OrderBy = 1, Name = "CMS", Title = "客户管理", IconFont = "fa fa-user-friends", URL = null, Enabled = true,
                    },
                };
                EF.MenuInfos.AddRange(asideMenuRoots);
                EF.SaveChanges();
                //根目录
                List <MenuInfo> asideMenuL1 = null;
                List <MenuInfo> asideMenuL2 = null;
                foreach (var rootItem in asideMenuRoots)
                {
                    //菜单组
                    EF.MenuGroups.Add(new MenuGroup {
                        GroupID = (int)MenuGroupType.AsideMenu, MenuID = rootItem.ID
                    });
                    EF.SaveChanges();
                    //一级菜单
                    switch (rootItem.Name)
                    {
                    case "BasicInfo":
                        asideMenuL1 = new List <MenuInfo> {
                            new MenuInfo {
                                ParentID = rootItem.ID, OrderBy = 1, Name = "UserManage", Title = "用户管理", IconFont = "fa fa-users", URL = null, Enabled = true,
                            },
                            new MenuInfo {
                                ParentID = rootItem.ID, OrderBy = 2, Name = "GoodsManage", Title = "商品管理", IconFont = "fa fa-th", URL = null, Enabled = true,
                            },
                        };
                        EF.MenuInfos.AddRange(asideMenuL1);
                        EF.SaveChanges();
                        foreach (var l1Item in asideMenuL1)
                        {
                            //二级菜单
                            switch (l1Item.Name)
                            {
                            case "UserManage":
                                asideMenuL2 = new List <MenuInfo> {
                                    new MenuInfo {
                                        ParentID = l1Item.ID, OrderBy = 1, Name = "UserInfo", Title = "用户信息", IconFont = "fa fa-user", URL = "/MOD/SYS/UserInfo.aspx", Enabled = true,
                                    },
                                    new MenuInfo {
                                        ParentID = l1Item.ID, OrderBy = 2, Name = "UoleInfo", Title = "角色信息", IconFont = "fa fa-user-tie", URL = "/MOD/SYS/RoleInfo.aspx", Enabled = true,
                                    },
                                };
                                EF.MenuInfos.AddRange(asideMenuL2);
                                EF.SaveChanges();
                                break;

                            case "GoodsManage":
                                asideMenuL2 = new List <MenuInfo> {
                                    new MenuInfo {
                                        ParentID = l1Item.ID, OrderBy = 1, Name = "GoodsInfo", Title = "商品信息", IconFont = "fa fa-th-large", URL = "/MOD/ITEM/GoodsInfo.aspx", Enabled = true,
                                    },
                                    new MenuInfo {
                                        ParentID = l1Item.ID, OrderBy = 2, Name = "BrandInfo", Title = "品牌信息", IconFont = "flaticon2-gift", URL = "/MOD/ITEM/BrandInfo.aspx", Enabled = true,
                                    },
                                    new MenuInfo {
                                        ParentID = l1Item.ID, OrderBy = 3, Name = "KindInfo", Title = "品类信息", IconFont = "flaticon2-gift", URL = "/MOD/ITEM/KindInfo.aspx", Enabled = true,
                                    },
                                    new MenuInfo {
                                        ParentID = l1Item.ID, OrderBy = 4, Name = "SpecInfo", Title = "规格信息", IconFont = "flaticon2-gift", URL = "/MOD/ITEM/SpecInfo.aspx", Enabled = true,
                                    },
                                };
                                EF.MenuInfos.AddRange(asideMenuL2);
                                EF.SaveChanges();
                                break;
                            }
                        }
                        break;

                    case "RMS":
                        asideMenuL1 = new List <MenuInfo> {
                            new MenuInfo {
                                ParentID = rootItem.ID, OrderBy = 1, Name = "StoreManage", Title = "门店管理", IconFont = "fa fa-store-alt", URL = null, Enabled = true,
                            },
                            new MenuInfo {
                                ParentID = rootItem.ID, OrderBy = 2, Name = "CashManage", Title = "收银管理", IconFont = "fa fa-solar-panel", URL = null, Enabled = true,
                            },
                        };
                        EF.MenuInfos.AddRange(asideMenuL1);
                        EF.SaveChanges();
                        foreach (var l1Item in asideMenuL1)
                        {
                            //二级菜单
                            switch (l1Item.Name)
                            {
                            case "StoreManage":
                                asideMenuL2 = new List <MenuInfo> {
                                    new MenuInfo {
                                        ParentID = l1Item.ID, OrderBy = 1, Name = "StoreInfo", Title = "门店信息", IconFont = "fa fa-store", URL = "/MOD/RMS/StoreInfo.aspx", Enabled = true,
                                    },
                                    new MenuInfo {
                                        ParentID = l1Item.ID, OrderBy = 2, Name = "SalesInfo", Title = "店员信息", IconFont = "fa fa-user", URL = "/MOD/RMS/SalesInfo.aspx", Enabled = true,
                                    },
                                };
                                EF.MenuInfos.AddRange(asideMenuL2);
                                EF.SaveChanges();
                                break;

                            case "CashManage":
                                asideMenuL2 = new List <MenuInfo> {
                                    new MenuInfo {
                                        ParentID = l1Item.ID, OrderBy = 1, Name = "Receipt", Title = "收银单", IconFont = "fa fa-receipt", URL = "/MOD/RMS/Receipt.aspx", Enabled = true,
                                    },
                                };
                                EF.MenuInfos.AddRange(asideMenuL2);
                                EF.SaveChanges();
                                break;
                            }
                        }
                        break;

                    case "OMS":
                        asideMenuL1 = new List <MenuInfo> {
                            new MenuInfo {
                                ParentID = rootItem.ID, OrderBy = 1, Name = "SOManage", Title = "订单管理", IconFont = "fa fa-money-check-alt", URL = null, Enabled = true,
                            },
                        };
                        EF.MenuInfos.AddRange(asideMenuL1);
                        EF.SaveChanges();
                        foreach (var l1Item in asideMenuL1)
                        {
                            //二级菜单
                            switch (l1Item.Name)
                            {
                            case "SOManage":
                                asideMenuL2 = new List <MenuInfo> {
                                    new MenuInfo {
                                        ParentID = l1Item.ID, OrderBy = 1, Name = "SalesOrder", Title = "销售订单", IconFont = "fa fa-money-check", URL = "/MOD/OMS/SalesOrder.aspx", Enabled = true,
                                    },
                                };
                                EF.MenuInfos.AddRange(asideMenuL2);
                                EF.SaveChanges();
                                break;
                            }
                        }
                        break;

                    case "CMS":
                        asideMenuL1 = new List <MenuInfo> {
                            new MenuInfo {
                                ParentID = rootItem.ID, OrderBy = 1, Name = "CustomerInfo", Title = "客户信息", IconFont = "fa fa-user-friends", URL = null, Enabled = true,
                            },
                        };
                        EF.MenuInfos.AddRange(asideMenuL1);
                        EF.SaveChanges();
                        foreach (var l1Item in asideMenuL1)
                        {
                            //二级菜单
                            switch (l1Item.Name)
                            {
                            case "CustomerInfo":
                                asideMenuL2 = new List <MenuInfo> {
                                    new MenuInfo {
                                        ParentID = l1Item.ID, OrderBy = 1, Name = "WeChatUser", Title = "微信用户", IconFont = "socicon-wechat", URL = "/MOD/CMS/WeChatUser.aspx", Enabled = true,
                                    },
                                };
                                EF.MenuInfos.AddRange(asideMenuL2);
                                EF.SaveChanges();
                                break;
                            }
                        }
                        break;
                    }
                }
            }
        }
Esempio n. 17
0
File: User.cs Progetto: qdjx/C5
        //获取用户列表
        public static List<UserInfoList> GetUserInfos(List<ListFilterField> FilterField, List<ListOrderField> OrderField
            , int PageSize, int PageIndex, out long TotalRowCount, out AlertMessage alertMessage)
        {
            TotalRowCount = 0;
            alertMessage = null;

            //权限检查
            if (!AUTH.PermissionCheck(ModuleInfo, ActionInfos.Where(i => i.Name == "List").FirstOrDefault(), out string Message))
            {
                alertMessage = new AlertMessage { Message = Message, Type = AlertType.warning };
                return null;
            }

            //查询列表
            using (var EF = new EF())
            {
                IEnumerable<UserInfoList> DataList = from userInfos in EF.UserInfos
                               select new UserInfoList
                               {
                                   ID = userInfos.ID,
                                   Name = userInfos.Name,
                                   StateID = userInfos.StateID,
                                   UpdateTime = userInfos.UpdateTime
                               };

                //筛选
                foreach (var item in FilterField)
                {
                    if (item.Name == "Name" && item.Value.Count > 0)
                    {
                        var predicate = PredicateExtensions.False<UserInfoList>();    //设置为False,所有and条件都应该放在or之后,如where (type=1 or type=14) and status==0
                        foreach (var t in item.Value)
                        {
                            var KWPart = t.ToLower();
                            switch (item.CmpareMode)
                            {
                                case FilterCmpareMode.Equal:
                                    predicate = predicate.Or(p => p.Name.ToLower() == KWPart);
                                    break;
                                case FilterCmpareMode.Like:
                                    predicate = predicate.Or(p => p.Name.ToLower().Contains(KWPart));
                                    break;
                            }
                        }
                        DataList = DataList.Where(predicate.Compile());
                    }
                }

                //排序
                if (OrderField.Count == 0) { DataList = DataList.OrderByDescending(i => i.ID); }
                else
                {
                    foreach (var item in OrderField)
                    {
                        switch (item.Mode)
                        {
                            case OrderByMode.Asc:
                                DataList = from list in DataList
                                           orderby OrderBy.GetPropertyValue(list, item.Name)
                                           select list;
                                break;
                            case OrderByMode.Desc:
                                DataList = from list in DataList
                                           orderby OrderBy.GetPropertyValue(list, item.Name) descending
                                           select list;
                                break;
                        }
                    }
                }

                //分页
                TotalRowCount = DataList.Count();
                if (TotalRowCount == 0) { return null; }
                int PageCount = (int)Math.Ceiling((double)TotalRowCount / PageSize);
                if (PageIndex > PageCount) { PageIndex = PageCount; }
                return DataList.Skip((PageIndex - 1) * PageSize).Take(PageSize).ToList();
            }
        }