Пример #1
0
        /// <summary>
        /// loads the current menu hierarchy from the ViewState
        /// </summary>
        /// <param name="savedState"></param>
        protected override void LoadViewState(object savedState)
        {
            base.LoadViewState(savedState);
            hierarchyDataset = (DataSet)ViewState["hierarchyDS"];
            hierarchyDataset.Relations.Clear();
            menuHierarchy = new HierarchyNavTable();
            menuHierarchy.Merge(hierarchyDataset.Tables["menuHierarchy"]);
            menuHierarchy.TableName = "menuHierarchy";
            panelsTable             = hierarchyDataset.Tables["panelsTable"];

            hierarchyDataset.Tables.Clear();
            hierarchyDataset.Tables.Add(menuHierarchy);
            hierarchyDataset.Relations.Add(new DataRelation("Hierarchy", menuHierarchy.Columns["Id"], menuHierarchy.Columns["ParentId"], true));
            hierarchyDataset.Tables.Add(panelsTable);
        }
Пример #2
0
        /// <summary>
        /// stores the orinal hierarchy in a dataset that will be saved to viewstatee so that this doesn`t need to be called upon every postback.
        /// </summary>
        /// <param name="hierarchy">The data property of the original menu</param>
        /// <param name="basePanel">the root panel of the architecture</param>
        public void SetInitialState(DataTable hierarchy, MPanel basePanel)
        {
            hierarchyDataset = new DataSet();
            menuHierarchy    = new HierarchyNavTable();
            panelsTable      = new DataTable();
            panelsTable.Columns.Add("Id", typeof(int));
            panelsTable.Columns.Add("Name", typeof(string));
            menuHierarchy.TableName = "menuHierarchy";
            menuHierarchy.Merge(hierarchy);
            hierarchyDataset.Tables.Add(menuHierarchy);
            hierarchyDataset.Relations.Add(new DataRelation("Hierarchy", menuHierarchy.Columns["Id"], menuHierarchy.Columns["ParentId"], true));

            AddPanelToList(basePanel);
            panelsTable.TableName = "panelsTable";
            hierarchyDataset.Tables.Add(panelsTable);
            ViewState["hierarchyDS"] = hierarchyDataset;
        }
Пример #3
0
        public TreeNavigatorControl(HierarchyNavTable hierarchy, List <UserAction> actions)
        {
            this.hierarchy = hierarchy;
            this.actions   = actions;


            tree = new TreeView();

            tree.ShowLines = true;
            WC.TreeNode item;

            foreach (HierarchyRow r in hierarchy.Rows)
            {
                if (r.ParentId == null)
                {
                    item = new WC.TreeNode(r.Caption, r.NavId.ToString());
                    AddSubtreeForItem(r, item);
                    tree.Nodes.Add(item);
                }
            }
            tree.SelectedNodeChanged        += SelectionChanged;
            tree.SelectedNodeStyle.Font.Bold = true;

            radios            = new RadioButtonList();
            radios.DataSource = actions;
            radios.DataBind();

            // if there is only one action option, don`t show the radios at all
            if (actions.Count == 1)
            {
                radios.SelectedIndex = 0;
                radios.Visible       = false;
            }
            radios.SelectedIndexChanged += SelectionChanged;
            radios.AutoPostBack          = true;



            this.Controls.Add(tree);
            this.Controls.Add(radios);
        }
Пример #4
0
        protected void Page_Init(object sender, EventArgs e)
        {
            mm = (MinMaster)Master;

            if (!(Session["Summary"] is DataTable))
            {
                HierarchyNavTable baseNavTable = ((TreeControl)(mm.SysDriver.MainPanel.controls[0])).storedHierarchyData;

                List <string> tables = mm.Stats.Tables;

                // the summary of acessibility/dependency/... is generated at the begining, afterwards it is restroed from the Session
                summary = new DataTable();
                summary.Columns.Add("TableName", typeof(string));
                summary.Columns.Add("Independent", typeof(bool));
                summary.Columns.Add("HasPanels", typeof(bool));
                summary.Columns.Add("Reachable", typeof(bool));

                List <string> unsuitableData = mm.Stats.UnsuitableTables();

                foreach (string tableName in mm.Stats.Tables)
                {
                    if (!mm.Stats.PKs.ContainsKey(tableName))    // exclude the PKLess...
                    {
                        continue;
                    }
                    if (unsuitableData.Contains(tableName))      // ...and the binary
                    {
                        continue;
                    }

                    DataRow r = summary.NewRow();
                    r["TableName"] = tableName;     // get it only once - table is stored in Session and updated

                    // this will take a bit longer as the primary key needs to be determined based on the information schema
                    // A table for which the primary key is at least partly also a foreign key is dependant.
                    r["Independent"] = !(mm.Stats.PKs[tableName].Any(pkCol => mm.Stats.FKs[tableName].Any(fk => fk.myColumn == pkCol)));

                    List <MPanel> tablePanels = (from MPanel p in mm.SysDriver.Panels.Values where p.tableName == tableName select p).ToList <MPanel>();
                    r["HasPanels"] = tablePanels.Count > 0;     // now surely equal to 2 (panels are added/removed in pairs)
                    r["Reachable"] = false;
                    if ((bool)(r["HasPanels"]))
                    {
                        r["Reachable"] = baseNavTable.Select("NavId IN (" + tablePanels[0].panelId + ", " + tablePanels[1].panelId + ")").Length > 0;
                    }
                    summary.Rows.Add(r);
                }

                Session["Summary"] = summary;
            }
            else
            {
                summary = (DataTable)Session["Summary"];
            }



            if (!Page.IsPostBack)
            {
                // the next time grid is set like this will be after panels addition / removal
                TablesGrid.DataSource = summary;
                TablesGrid.DataBind();
                ResetActionClickablility();
            }

            BackButton.PostBackUrl = BackButton.GetRouteUrl("ArchitectShowRoute", new { projectName = _min.Common.Environment.project.Name });
        }