Beispiel #1
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 });
        }
Beispiel #2
0
        protected void Page_Init(object sender, EventArgs e)
        {
            ValidationResult.Items.Clear();
            mm = (MinMaster)Master;

            string projectName = Page.RouteData.Values["projectName"] as string;
            int    panelId     = Int32.Parse(Page.RouteData.Values["panelId"] as string);

            actPanel = mm.SysDriver.Panels[panelId];
            DataColumnCollection cols = mm.Stats.ColumnTypes[actPanel.tableName];

            PanelName.Text = actPanel.panelName;
            _min.Models.Control control = actPanel.controls.Where(x => x is NavTableControl || x is TreeControl).First();
            FKs = mm.Stats.FKs[actPanel.tableName];
            List <string> colNames = (from DataColumn col in cols select col.ColumnName).ToList <string>();

            // a M2NControl to select the columns of the table displayed in the GridView - for a tree we take only the first item
            DisplayCols.SetOptions(colNames);
            DisplayCols.SetIncludedOptions(control.displayColumns);

            // what actions can be triggered from the navigation control
            List <string> possibleAcitons = new List <string>(new string[] { UserAction.Insert.ToString(), UserAction.View.ToString(),
                                                                             UserAction.Delete.ToString() });
            List <UserAction> originalActions = new List <UserAction>();

            if (control is NavTableControl)
            {
                foreach (UserAction ua in ((NavTableControl)control).actions)
                {
                    originalActions.Add(ua);
                }
            }
            else
            {
                foreach (UserAction ua in ((TreeControl)control).actions)
                {
                    originalActions.Add(ua);
                }
            }


            // if the panel contains a NavTable or TreeControl, it is the only control of a complex type and other controls therefore must be
            // simple buttons.
            foreach (_min.Models.Control simpleControl in actPanel.controls)
            {
                if (simpleControl == control)
                {
                    continue;
                }
                originalActions.Add(simpleControl.action);
            }

            List <string> originalActionStrings = new List <string>();

            foreach (UserAction a in originalActions)
            {
                originalActionStrings.Add(a.ToString());
            }

            actionsControl.SetOptions(possibleAcitons);
            actionsControl.SetIncludedOptions(originalActionStrings);


            hierarchy = mm.Stats.SelfRefFKs().Find(x => x.myTable == actPanel.tableName);
            string[] CTypeOptions = hierarchy == null ? new string[] { "Navigation Table" } :
            new string[] { "Navigation Table", "Navigation Tree" };
            // a radio button list - contains navtable and maybe treeview option
            NavControlType.DataSource = CTypeOptions;
            NavControlType.DataBind();
            // let the default be the current
            if (control is TreeControl)
            {
                NavControlType.SelectedIndex = 1;
            }
            else
            {
                NavControlType.SelectedIndex = 0;
            }

            BackButton.PostBackUrl = BackButton.GetRouteUrl("ArchitectShowRoute", new { projectName = projectName });
        }