public static Module GetDependentModuleObject(this ModuleRule rule) { if (rule == null) { return(null); } return(rule.Module.nHydrateModel.Modules.FirstOrDefault(x => x.Id == rule.DependentModule)); }
public override void InitDataPage() { ModuleRule objModuleRule = new ModuleRule(); dropModuleTypeID.DataSource = objModuleRule.Sys_ModuleType.Where(s => s.IsSystem == true); dropModuleTypeID.DataTextField = "ModuleTypeName"; dropModuleTypeID.DataValueField = "ModuleTypeID"; dropModuleTypeID.DataBind(); }
public override void InitDataPage() { ModuleRule objModuleRule = new ModuleRule(); AuthorizeGroupID.Items.Clear(); AuthorizeGroupID.Items.Add(new ListItem("--全部--", "")); AuthorizeGroupID.Items.Add(new ListItem("平台虚拟授权组", Guid.Empty.ToString())); foreach (sys_authorizegroup objsys_authorizegroup in objUserRule.sys_authorizegroup.Where(s => s.ModuleTypeID == CoteID)) { AuthorizeGroupID.Items.Add(new ListItem(objsys_authorizegroup.AuthorizeGroupName, objsys_authorizegroup.AuthorizeGroupID)); } }
public override void RenderPage() { gdvContent.AlreadySelectedRowKeys = objUserRule.GetRoleUser(RoleID); ModuleRule objModuleRule = new ModuleRule(); string userTypeID = objUserRule.GetRoleModuleTypeUserType(RoleID); if (string.IsNullOrWhiteSpace(userTypeID)) { MessageDialog("此角色平台框架未设置用户类型", "RoleList.aspx"); return; } this.CurrentBindData <Sys_User>(gdvContent, objUserRule.GetUserTypeUser(userTypeID)); }
private bool TestModuleRule(ModuleRule _rule) { int count = 0; foreach (RoomModule mod in m_spawnedModules) { if (mod.moduleCode == _rule.moduleCode) { count++; } } if (count < _rule.minimum) { return(false); } if (count > _rule.maximum) { return(false); } return(false); }
/// <summary> /// Determines if an module rule passes for the current model /// </summary> /// <param name="module"></param> /// <param name="rule"></param> /// <returns></returns> public static bool IsValidRule(this Module module, ModuleRule rule, ref List <string> issueList) { if (module == null || rule == null) { return(false); } var dModule = rule.GetDependentModuleObject(); if (dModule == null) { return(false); } if (rule.Status == ModuleRuleStatusTypeConstants.Outerset) { #region Outerset //Verify that the current module is an outerset of the dependent module var isValid = true; //Tables, there should be no objects in common if (((int)rule.Inclusion & (int)ModuleRuleInclusionTypeConstants.Entity) != 0) { var g1 = dModule.GetEntities().ToList(); var g2 = module.GetEntities().ToList(); var indexListInModule1 = module.nHydrateModel.IndexModules.Where(z => z.ModuleId == dModule.Id).Select(x => x.IndexID); var indexListInModule2 = module.nHydrateModel.IndexModules.Where(z => z.ModuleId == module.Id).Select(x => x.IndexID); var i1 = g1.SelectMany(x => x.Indexes).ToList().Where(x => indexListInModule1.Contains(x.Id)).ToList(); var i2 = g2.SelectMany(x => x.Indexes).ToList().Where(x => indexListInModule2.Contains(x.Id)).ToList(); var intersectGroup = g1.Intersect(g2).ToList(); var intersectGroup2 = i1.Intersect(i2).ToList(); isValid &= intersectGroup.Count == 0; isValid &= intersectGroup2.Count == 0; if (intersectGroup.Count < g2.Count) { issueList.Add("The following entities are in both modules " + dModule.Name + " and " + module.Name + ":" + string.Join(", ", intersectGroup.Select(x => x.Name).ToList())); } if (intersectGroup2.Count < i2.Count) { issueList.Add("The following indexes are in both modules " + dModule.Name + " and " + module.Name + ":" + string.Join(", ", intersectGroup2.Select(x => x.Entity.Name + ".[" + x.ToString() + "]").ToList())); } } //Fields if (isValid && ((int)rule.Inclusion & (int)ModuleRuleInclusionTypeConstants.Entity) != 0) { var g1 = dModule.GetFields().ToList(); var g2 = module.GetFields().ToList(); var intersectGroup = g1.Intersect(g2).ToList(); isValid &= intersectGroup.Count == 0; if (intersectGroup.Count < g2.Count) { issueList.Add("The following fields are in both modules " + dModule.Name + " and " + module.Name + ":" + string.Join(", ", intersectGroup.Select(x => x.Entity.Name + "." + x.Name).ToList())); } } //Stored Procedures if (((int)rule.Inclusion & (int)ModuleRuleInclusionTypeConstants.StoredProcedure) != 0) { var g1 = dModule.GetStoredProcedures().ToList(); var g2 = module.GetStoredProcedures().ToList(); var intersectGroup = g1.Intersect(g2).ToList(); isValid &= intersectGroup.Count == 0; if (intersectGroup.Count < g2.Count) { issueList.Add("The following stored procedures are in both modules " + dModule.Name + " and " + module.Name + ":" + string.Join(", ", intersectGroup.Select(x => x.Name).ToList())); } } //Views if (((int)rule.Inclusion & (int)ModuleRuleInclusionTypeConstants.View) != 0) { var g1 = dModule.GetViews().ToList(); var g2 = module.GetViews().ToList(); var intersectGroup = g1.Intersect(g2).ToList(); isValid &= intersectGroup.Count == 0; if (intersectGroup.Count < g2.Count) { issueList.Add("The following views are in both modules " + dModule.Name + " and " + module.Name + ":" + string.Join(", ", intersectGroup.Select(x => x.Name).ToList())); } } //Functions if (((int)rule.Inclusion & (int)ModuleRuleInclusionTypeConstants.Function) != 0) { var g1 = dModule.GetFunctions().ToList(); var g2 = module.GetFunctions().ToList(); var intersectGroup = g1.Intersect(g2).ToList(); isValid &= intersectGroup.Count == 0; if (intersectGroup.Count < g2.Count) { issueList.Add("The following views are in both modules " + dModule.Name + " and " + module.Name + ":" + string.Join(", ", intersectGroup.Select(x => x.Name).ToList())); } } return(isValid); #endregion } else if (rule.Status == ModuleRuleStatusTypeConstants.Subset) { #region Subset //Verify that the current module is a subset of the dependent module var isValid = true; //Tables, the intersection must be the same size as the module's number of objects if (((int)rule.Inclusion & (int)ModuleRuleInclusionTypeConstants.Entity) != 0) { var g1 = dModule.GetEntities().ToList(); var g2 = module.GetEntities().ToList(); var indexListInModule1 = module.nHydrateModel.IndexModules.Where(z => z.ModuleId == dModule.Id).Select(x => x.IndexID); var indexListInModule2 = module.nHydrateModel.IndexModules.Where(z => z.ModuleId == module.Id).Select(x => x.IndexID); var i1 = g1.SelectMany(x => x.Indexes).ToList().Where(x => indexListInModule1.Contains(x.Id)).ToList(); var i2 = g2.SelectMany(x => x.Indexes).ToList().Where(x => indexListInModule2.Contains(x.Id)).ToList(); var intersectGroup = g1.Intersect(g2).ToList(); var intersectGroup2 = i1.Intersect(i2).ToList(); isValid &= intersectGroup.Count == g2.Count; isValid &= intersectGroup2.Count == i2.Count; if (intersectGroup.Count < g2.Count) { var missing = g2.Except(intersectGroup).ToList(); issueList.Add("The following entities are missing from the " + dModule.Name + " module: " + string.Join(", ", missing.Select(x => x.Name).ToList())); } if (intersectGroup2.Count < i2.Count) { var missing = i2.Except(intersectGroup2).ToList(); issueList.Add("The following indexes are missing from the " + dModule.Name + " module: " + string.Join(", ", missing.Select(x => x.Entity.Name + ".[" + x.ToString() + "]").ToList())); } } //Fields if (isValid && ((int)rule.Inclusion & (int)ModuleRuleInclusionTypeConstants.Entity) != 0) { var g1 = dModule.GetFields().ToList(); var g2 = module.GetFields().ToList(); var intersectGroup = g1.Intersect(g2).ToList(); isValid &= intersectGroup.Count == g2.Count; if (intersectGroup.Count < g2.Count) { var missing = g2.Except(intersectGroup).ToList(); issueList.Add("The following fields are missing from the " + dModule.Name + " module: " + string.Join(", ", missing.Select(x => x.Entity.Name + "." + x.Name).ToList())); } } //Stored Procedures if (((int)rule.Inclusion & (int)ModuleRuleInclusionTypeConstants.StoredProcedure) != 0) { var g1 = dModule.GetStoredProcedures().ToList(); var g2 = module.GetStoredProcedures().ToList(); var intersectGroup = g1.Intersect(g2).ToList(); isValid &= intersectGroup.Count == g2.Count; if (intersectGroup.Count < g2.Count) { var missing = g2.Except(intersectGroup).ToList(); issueList.Add("The following stored procedures are missing from the " + dModule.Name + " module: " + string.Join(", ", missing.Select(x => x.Name).ToList())); } } //Views if (((int)rule.Inclusion & (int)ModuleRuleInclusionTypeConstants.View) != 0) { var g1 = dModule.GetViews().ToList(); var g2 = module.GetViews().ToList(); var intersectGroup = g1.Intersect(g2).ToList(); isValid &= intersectGroup.Count == g2.Count; if (intersectGroup.Count < g2.Count) { var missing = g2.Except(intersectGroup).ToList(); issueList.Add("The following views are missing from the " + dModule.Name + " module: " + string.Join(", ", missing.Select(x => x.Name).ToList())); } } //Functions if (((int)rule.Inclusion & (int)ModuleRuleInclusionTypeConstants.Function) != 0) { var g1 = dModule.GetFunctions().ToList(); var g2 = module.GetFunctions().ToList(); var intersectGroup = g1.Intersect(g2).ToList(); isValid &= intersectGroup.Count == g2.Count; if (intersectGroup.Count < g2.Count) { var missing = g2.Except(intersectGroup).ToList(); issueList.Add("The following functions are missing from the " + dModule.Name + " module: " + string.Join(", ", missing.Select(x => x.Name).ToList())); } } return(isValid); #endregion } return(false); }
private static void LoadFromDisk(IEnumerable<Module> list, nHydrateModel model, string rootFolder, Microsoft.VisualStudio.Modeling.Store store) { var folder = rootFolder; if (!Directory.Exists(folder)) return; #region Load other parameter/field information var fileName = Path.Combine(folder, "modules.configuration.xml"); if (!File.Exists(fileName)) return; XmlDocument document = null; try { document = new XmlDocument(); document.Load(fileName); } catch (Exception ex) { //Do Nothing MessageBox.Show("The file '" + fileName + "' is not valid and could not be loaded!", "Load Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } foreach (XmlNode n in document.DocumentElement.ChildNodes) { var id = XmlHelper.GetAttributeValue(n, "id", Guid.NewGuid()); var item = model.Modules.FirstOrDefault(x => x.Id == id); if (item == null) { item = new Module(model.Partition, new PropertyAssignment[] { new PropertyAssignment(ElementFactory.IdPropertyAssignment, id) }); model.Modules.Add(item); } item.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(FieldParameter_PropertyChanged); item.Name = XmlHelper.GetAttributeValue(n, "name", item.Name); item.Summary = XmlHelper.GetNodeValue(n, "summary", item.Summary); item.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(FieldParameter_PropertyChanged); //Rules var rulesNodes = n.SelectSingleNode("ruleset"); if (rulesNodes != null) { var nameList = new List<string>(); foreach (XmlNode m in rulesNodes.ChildNodes) { var rule = new ModuleRule(item.Partition); item.ModuleRules.Add(rule); rule.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(FieldParameter_PropertyChanged); rule.Name = XmlHelper.GetAttributeValue(m, "name", rule.Name); rule.Status = (ModuleRuleStatusTypeConstants)int.Parse(XmlHelper.GetAttributeValue(m, "status", rule.Status.ToString("d"))); rule.DependentModule = XmlHelper.GetAttributeValue(m, "dependentmodule", rule.DependentModule); rule.Inclusion = XmlHelper.GetAttributeValue(m, "inclusion", rule.Inclusion); rule.Enforced = XmlHelper.GetAttributeValue(m, "enforced", rule.Enforced); rule.Summary = XmlHelper.GetNodeValue(m, "summary", rule.Summary); rule.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(FieldParameter_PropertyChanged); } } } #endregion }