/// <summary> /// Initializes a new instance of the <see cref="List"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="listId">The list id.</param> /// <param name="name">The name.</param> /// <param name="controlUrl">The control URL.</param> public AdminView(ModuleConfig parent, string listId, string name, string controlUrl) { _Module = parent; _ViewId = listId; _ControlUrl = controlUrl; _Name = name; _Columns = new ViewColumnCollection(); //_Actions = new ViewActionCollection(); _Tabs = new ViewTabCollection(); _Transitions = new ViewTransitionCollection(); }
/// <summary> /// Creates the acl collection. /// </summary> /// <param name="aclNode">The acl node.</param> /// <returns></returns> public static AclGroupCollection CreateAclCollection(ModuleConfig module, XmlNode aclNode) { if (aclNode == null) { return(null); } // Create list AclGroupCollection aclGroupCol = new AclGroupCollection(); AclGroup rootGroup = new AclGroup(module.Name, module.DisplayName); aclGroupCol.Add(rootGroup); XmlNodeList groups = aclNode.SelectNodes("Group"); foreach (XmlNode group in groups) { AclGroup aclGroup = PopulateGroupRecursive(group); aclGroup.ParentGroup = rootGroup; rootGroup.Groups.Add(aclGroup); } return(aclGroupCol); }
/// <summary> /// Creates the view collection. /// </summary> /// <param name="module">The module.</param> /// <param name="viewsNode">The views node.</param> /// <returns></returns> public static ViewCollection CreateViewCollection(ModuleConfig module, XmlNode viewsNode) { if (viewsNode == null) { return(null); } // Create list ViewCollection viewCol = new ViewCollection(); XmlNodeList views = viewsNode.SelectNodes("View"); foreach (XmlNode view in views) { AdminView viewElement = new AdminView(module, view.Attributes["id"].Value, view.Attributes["name"].Value, view.Attributes["controlUrl"].Value); // Bind admin view attributes foreach (XmlAttribute attr in view.Attributes) { viewElement.Attributes[attr.Name] = attr.Value; } if (view.Attributes["isNameDynamic"] != null) { bool boolValue = false; Boolean.TryParse(view.Attributes["isNameDynamic"].Value, out boolValue); viewElement.IsNameDynamic = boolValue; } // Bind columns XmlNodeList columns = view.SelectNodes("Columns/Column"); int columnsCount = 0; int visibleColumnsCount = 0; foreach (XmlNode node in columns) { ViewColumn column = new ViewColumn(); if (node.Attributes["DataField"] != null) { column.DataField = node.Attributes["DataField"].Value; } // assign ColumnType ColumnType type = ColumnType.None; if (node.Attributes["ColumnType"] != null) { try { type = (ColumnType)Enum.Parse(typeof(ColumnType), node.Attributes["ColumnType"].Value, true); } catch { } } column.ColumnType = type; // set template if ((column.ColumnType == ColumnType.CustomTemplate || column.ColumnType == ColumnType.None) && node.HasChildNodes) { column.Template = new ViewColumnTemplate(); // select Template nodes XmlNodeList tmpChildNodes = node.SelectNodes("Template"); if (tmpChildNodes.Count > 0) { // bind template attributes BindColumnTemplateProperties(column.Template, tmpChildNodes[0]); } } // set column actions if (column.ColumnType == ColumnType.Action && node.HasChildNodes) { BindColumnActions(column, node); } // set attributes BindColumnProperties(column, node); column.ColumnIndex = columnsCount++; if (column.Visible) { column.ColumnVisibleIndex = visibleColumnsCount++; } // add column to the collection viewElement.Columns.Add(column); } XmlNodeList tabs = view.SelectNodes("Tabs/Tab"); foreach (XmlNode node in tabs) { ViewTab tab = new ViewTab(); BindTabProperties(tab, node); viewElement.Tabs.Add(tab); } //XmlNodeList actions = view.SelectNodes("Actions/Action"); //foreach (XmlNode node in actions) //{ // viewElement.Actions.Add(PopulateActionRecursive(node)); //} XmlNodeList transitions = view.SelectNodes("Transitions/Transition"); foreach (XmlNode node in transitions) { ViewTransition transition = new ViewTransition(); BindTransitionProperties(transition, node); viewElement.Transitions.Add(transition); } // Check roles security if (viewElement.Attributes.Contains("Roles")) { string roles = viewElement.Attributes.Contains("Roles").ToString(); if (!String.IsNullOrEmpty(roles)) { if (!SecurityManager.CheckPermission(roles.Split(new char[] { ',' }))) { // Skip current record continue; } } } viewCol.Add(viewElement); } return(viewCol); }