protected void Page_Load(object sender, EventArgs e) { mm = (MinMaster)Master; projectsTable = mm.SysDriver.GetProjects(); ProjectsGrid.DataSource = projectsTable; ProjectsGrid.DataBind(); }
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 }); }
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 }); }
protected void Page_Init(object sender, EventArgs e) { mm = (MinMaster)Master; if (!Page.IsPostBack) { tbc.SetInitialState(((TreeControl)mm.SysDriver.MainPanel.controls[0]).storedHierarchyData, mm.SysDriver.MainPanel); } }
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; 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)); foreach (string tableName in mm.Stats.Tables) { if(!mm.Stats.PKs.ContainsKey(tableName)) continue; DataRow r = summary.NewRow(); r["TableName"] = tableName; // get it only once - table is stored in Session and updated 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 }); }
protected void Page_Load(object sender, EventArgs e) { mm = (MinMaster)Master; if (Page.RouteData.Values.ContainsKey("projectId") && Int32.Parse(Page.RouteData.Values["projectId"] as string) > 0) { DeleteButton.Visible = true; DetailsView.DefaultMode = DetailsViewMode.Edit; int idProject = Int32.Parse(Page.RouteData.Values["projectId"] as string); project = mm.SysDriver.GetProject(idProject); if (!Page.IsPostBack) { DetailsView.DataSource = new CE.Project[] { project }; DetailsView.DataBind(); } } }
protected void SaveButton_Click(object sender, EventArgs e) { mm = (MinMaster)Master; Errors.Items.Clear(); if (UsernameTextBox.Text == "") { Errors.Items.Add("Please, insert the initial user's name"); return; } if (PasswordTextBox.Text.Length < 7) { Errors.Items.Add("The password must be at least 7 characters long."); return; } if (PasswordTextBox.Text != RetypePasswordTextBox.Text) { Errors.Items.Add("The passwords do not match."); return; } string username = UsernameTextBox.Text; string password = PasswordTextBox.Text; string mail = MailTextBox.Text; MembershipCreateStatus status; Membership.CreateUser(username, password, mail, "Dummy question", "Dummy answer", true, 1, out status); int totalUsers; MembershipUser user = Membership.FindUsersByName(username, 0, 1, out totalUsers)[username]; mm.SysDriver.SetUserRights((user.ProviderUserKey), null, 11110); var config2 = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~"); config2.AppSettings.Settings["FirstRunMono"].Value = "False"; System.Web.Configuration.WebConfigurationManager.AppSettings["FirstRunMono"] = "False"; config2.Save(); Errors.Items.Add("Done."); Response.RedirectToRoute("DefaultRoute"); }
protected void Page_Load(object sender, EventArgs e) { mm = (MinMaster)Master; if (!Page.IsPostBack) { MembershipUserCollection users = Membership.GetAllUsers(); List <CE.Project> projects = mm.SysDriver.GetProjectObjects(); object userId = (Membership.GetUser().ProviderUserKey); int globalAccess = mm.SysDriver.GetUserRights(userId, null); if (globalAccess >= 1000) { projects.Reverse(); projects.Add(new CE.Project(0, "All Projects", DbServer.MsSql, null, null, 0)); projects.Reverse(); } else { List <CE.Project> inaccessible = new List <CE.Project>(); foreach (CE.Project p in projects) { if (mm.SysDriver.GetUserRights(userId, p.Id) < 1000) { inaccessible.Add(p); } } foreach (CE.Project p in inaccessible) { projects.Remove(p); } } UserSelect.DataSource = users; UserSelect.DataValueField = "ProviderUserKey"; UserSelect.DataTextField = "UserName"; UserSelect.DataBind(); ProjectSelect.DataSource = projects; ProjectSelect.DataValueField = "Id"; ProjectSelect.DataTextField = "Name"; ProjectSelect.DataBind(); SetCheckboxes(); } }
/// <summary> /// Takes care of step one - the discovery of tables missing primary kery /// (and possibly more critical errors in future) /// because of which these tables cannot be included in the genereated administration interface. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { mm = (MinMaster)Master; mm.SysDriver.ClearProposal(); if (!Page.IsPostBack) { InitProposalWizard.ActiveStepIndex = 0; } if (InitProposalWizard.ActiveStepIndex == 0) { FirstProblemList.Items.Clear(); List <string> PKless = mm.Stats.TablesMissingPK(); List <string> strangeData = mm.Stats.UnsuitableTables(); if (PKless.Count > 0 || strangeData.Count > 0) { foreach (string table in PKless) { FirstProblemList.Items.Add("Table " + table + " has no primary key defined." + " If you continue, this table will be ommitted from the proposal. You may as well add the PK and check again"); } foreach (string table in strangeData) { FirstProblemList.Items.Add(String.Format("Table {0} contains some binary or other data types that cannot be " + " edited by the means currently available. This table will be excluded from the proposal.", table)); if (!PKless.Contains(table)) { PKless.Add(table); } } } else { FirstProblemList.Items.Add("Seems OK..."); } // fore each step, save the gained information into a separate field in Session Session["PKless"] = PKless; } }
/// <summary> /// each custom field will get a cell in the main table containing a WebControls.Panel, into which it can display its customization form. /// Each customizable field is associated with a factory of corresponding type, which will load its properties and fill the fields of the customization form. /// The factory is also resposible for displaying and validating the form. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Init(object sender, EventArgs e) { mm = (MinMaster)Master; interPanel = (MPanel)Session["interPanel"]; // the custom fields have the basic settings alreadyu saved in the session - now only the custom parts will be configured. customs = (Dictionary <DataColumn, Dictionary <string, object> >)Session["customs"]; backButton.PostBackUrl = backButton.GetRouteUrl("ArchitectEditEditableRoute", new { projectName = mm.ProjectName, panelId = interPanel.panelId }); Table customSettingsTbl = new Table(); foreach (DataColumn customCol in customs.Keys) { TableRow captionRow = new TableRow(); TableCell captionCell = new TableCell(); captionCell.Text = customCol.ColumnName; captionRow.Cells.Add(captionCell); customSettingsTbl.Rows.Add(captionRow); TableRow settingsRow = new TableRow(); TableCell settingsCell = new TableCell(); WPanel container = new WPanel(); var factory = (ICustomizableColumnFieldFactory)customs[customCol]["factory"]; if (!Page.IsPostBack) { MPanel oldPanel = mm.SysDriver.Panels[interPanel.panelId]; IColumnField oldVersion = (IColumnField)(from f in oldPanel.fields where f.GetType() == factory.ProductionType && ((IColumnField)f).ColumnName == customCol.ColumnName select f).FirstOrDefault <IField>(); if (oldVersion != null) { factory.LoadProduct((IColumnField)oldVersion); } } factory.ShowForm(container); settingsCell.Controls.Add(container); settingsRow.Controls.Add(settingsCell); customSettingsTbl.Rows.Add(settingsRow); } MainPanel.Controls.Add(customSettingsTbl); }
protected void Page_Init(object sender, EventArgs e) { mm = (MinMaster)Master; //if (!Page.IsPostBack) //{ interPanel = (MPanel)Session["interPanel"]; customs = (Dictionary<DataColumn, Dictionary<string, object>>)Session["customs"]; backButton.PostBackUrl = backButton.GetRouteUrl("ArchitectEditEditableRoute", new { projectName = mm.ProjectName, panelId = interPanel.panelId }); //} Table customSettingsTbl = new Table(); foreach (DataColumn customCol in customs.Keys) { TableRow captionRow = new TableRow(); TableCell captionCell = new TableCell(); captionCell.Text = customCol.ColumnName; captionRow.Cells.Add(captionCell); customSettingsTbl.Rows.Add(captionRow); TableRow settingsRow = new TableRow(); TableCell settingsCell = new TableCell(); WPanel container = new WPanel(); var factory = (ICustomizableColumnFieldFactory)customs[customCol]["factory"]; if(!Page.IsPostBack){ MPanel oldPanel = mm.SysDriver.Panels[interPanel.panelId]; IColumnField oldVersion = (IColumnField)(from f in oldPanel.fields where f.GetType() == factory.ProductionType && ((IColumnField)f).ColumnName == customCol.ColumnName select f).FirstOrDefault<IField>(); if (oldVersion != null) factory.LoadProduct((IColumnField)oldVersion); } factory.ShowForm(container); settingsCell.Controls.Add(container); settingsRow.Controls.Add(settingsCell); customSettingsTbl.Rows.Add(settingsRow); } MainPanel.Controls.Add(customSettingsTbl); }
protected void Page_Load(object sender, EventArgs e) { mm = (MinMaster)Master; if (!Page.IsPostBack) { MembershipUserCollection users = Membership.GetAllUsers(); List<CE.Project> projects = mm.SysDriver.GetProjectObjects(); object userId = (Membership.GetUser().ProviderUserKey); int globalAccess = mm.SysDriver.GetUserRights(userId, null); if (globalAccess >= 1000) { projects.Reverse(); projects.Add(new CE.Project(0, "All Projects", null, null, null, 0)); projects.Reverse(); } else { List<CE.Project> inaccessible = new List<CE.Project>(); foreach (CE.Project p in projects) { if (mm.SysDriver.GetUserRights(userId, p.Id) < 1000) inaccessible.Add(p); } foreach (CE.Project p in inaccessible) projects.Remove(p); } UserSelect.DataSource = users; UserSelect.DataValueField = "ProviderUserKey"; UserSelect.DataTextField = "UserName"; UserSelect.DataBind(); ProjectSelect.DataSource = projects; ProjectSelect.DataValueField = "Id"; ProjectSelect.DataTextField = "Name"; ProjectSelect.DataBind(); SetCheckboxes(); } }
/// <summary> /// Initializes basic environment - Project, SystemDriver (contains architecture - all the panels linked in a tree), architect, stats, webDriver; /// sets the panel PK (if present), creates basic dropdown menu and lets the WebControls of the wohole rest of the page be created /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Init(object sender, EventArgs e) { mm = (MinMaster)Master; navigator = new Navigator(Page); // whether in a specific panel or not, we need a menu /**/ MenuEventHandler menuHandler = navigator.MenuHandle; ((TreeControl)mm.SysDriver.MainPanel.controls[0]).ToUControl(MainPanel, navigator.MenuHandler); /**/ // get the active panel, if exists if (Page.RouteData.Values.ContainsKey("panelId") && Page.RouteData.Values["panelId"].ToString() == "0") Page.RouteData.Values.Remove("panelId"); if (Page.RouteData.Values.ContainsKey("panelId")) { // the basic panel if (Page.IsPostBack && Session[CC.SESSION_ACTIVE_PANEL] is MPanel) { activePanel = (MPanel)Session[CC.SESSION_ACTIVE_PANEL]; } else { noSessionForActPanel = true; Session[CC.SESSION_ACTIVE_PANEL] = null; activePanel = mm.SysDriver.Panels[Int32.Parse(Page.RouteData.Values["panelId"].ToString())]; } if (activePanel.isBaseNavPanel) { Response.RedirectToRoute( CE.GlobalState == GlobalState.Architect ? "ArchitectShowRoute" : "AdministerBrowseRoute", new { projectName = CE.project.Name }); return; } // panels is focused to a certain item (row in table) if (Request.QueryString.Count > 0) { SetRoutedPKForPanel(activePanel, Request.QueryString); } else { activePanel.PK = null; } // which action on this panel leads where var controlTargetPanels = from _min.Models.Control c in activePanel.controls select c.ActionsDicitionary; Dictionary<UserAction, int> currentPanelActionPanels = new Dictionary<UserAction, int>(); foreach (var x in controlTargetPanels) { foreach (KeyValuePair<UserAction, int> item in x) { if (!currentPanelActionPanels.ContainsKey(item.Key)) // should be done differently currentPanelActionPanels.Add(item.Key, item.Value); } } navigator.setCurrentTableActionPanels(currentPanelActionPanels); CreatePanelHeading(MainPanel); CreateWebControlsForPanel(activePanel, MainPanel); } else { CreatePanelHeading(MainPanel); } }
protected void Page_Load(object sender, EventArgs e) { mm = (MinMaster)Master; if(Page.RouteData.Values.ContainsKey("projectId") && Int32.Parse(Page.RouteData.Values["projectId"] as string) > 0){ DeleteButton.Visible = true; DetailsView.DefaultMode = DetailsViewMode.Edit; int idProject = Int32.Parse(Page.RouteData.Values["projectId"] as string); project = mm.SysDriver.GetProject(idProject); if (!Page.IsPostBack) { DetailsView.DataSource = new CE.Project[] { project }; DetailsView.DataBind(); } } }
protected void Page_Init(object sender, EventArgs e) { mm = (MinMaster)Master; navigator = new Navigator(Page); // whether in a specific panel or not, we need a menu MenuEventHandler menuHandler = navigator.MenuHandle; ((TreeControl)mm.SysDriver.MainPanel.controls[0]).ToUControl(MainPanel, navigator.MenuHandler); // get the active panel, if exists if (Page.RouteData.Values.ContainsKey("panelId") && Page.RouteData.Values["panelId"].ToString() == "0") { Page.RouteData.Values.Remove("panelId"); } if (Page.RouteData.Values.ContainsKey("panelId")) { // the basic panel if (Page.IsPostBack && Session[CC.SESSION_ACTIVE_PANEL] is MPanel) { activePanel = (MPanel)Session[CC.SESSION_ACTIVE_PANEL]; } else { noSessionForActPanel = true; Session[CC.SESSION_ACTIVE_PANEL] = null; activePanel = mm.SysDriver.Panels[Int32.Parse(Page.RouteData.Values["panelId"].ToString())]; } if (activePanel.isBaseNavPanel) { Response.RedirectToRoute( CE.GlobalState == GlobalState.Architect ? "ArchitectShowRoute" : "AdministerBrowseRoute", new { projectName = CE.project.Name }); return; } // panels is focused to a certain item (row in table) if (Request.QueryString.Count > 0) { SetRoutedPKForPanel(activePanel, Request.QueryString); } else { activePanel.PK = null; } // which action on this panel leads where var controlTargetPanels = from _min.Models.Control c in activePanel.controls select c.ActionsDicitionary; Dictionary <UserAction, int> currentPanelActionPanels = new Dictionary <UserAction, int>(); foreach (var x in controlTargetPanels) { foreach (KeyValuePair <UserAction, int> item in x) { if (!currentPanelActionPanels.ContainsKey(item.Key)) // should be done differently { currentPanelActionPanels.Add(item.Key, item.Value); } } } navigator.setCurrentTableActionPanels(currentPanelActionPanels); CreatePanelHeading(MainPanel); CreateWebControlsForPanel(activePanel, MainPanel); } else { CreatePanelHeading(MainPanel); } }
/// <summary> /// Takes care of step one - the discovery of tables missing primary kery /// (and possibly more critical errors in future) /// because of which these tables cannot be included in the genereated administration interface. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { mm = (MinMaster)Master; mm.SysDriver.ClearProposal(); if (!Page.IsPostBack) { InitProposalWizard.ActiveStepIndex = 0; } if (InitProposalWizard.ActiveStepIndex == 0) { FirstProblemList.Items.Clear(); List<string> PKless = mm.Stats.TablesMissingPK(); List<string> strangeData = mm.Stats.UnsuitableTables(); if (PKless.Count > 0 || strangeData.Count > 0) { foreach (string table in PKless) { FirstProblemList.Items.Add("Table " + table + " has no primary key defined." + " If you continue, this table will be ommitted from the proposal. You may as well add the PK and check again"); } foreach (string table in strangeData) { FirstProblemList.Items.Add(String.Format("Table {0} contains some binary or other data types that cannot be " + " edited by the means currently available. This table will be excluded from the proposal.", table)); if (!PKless.Contains(table)) { PKless.Add(table); } } } else { FirstProblemList.Items.Add("Seems OK..."); } // fore each step, save the gained information into a separate field in Session Session["PKless"] = PKless; } }
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 }); }
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 }); }
protected void Page_Load(object sender, EventArgs e) { mm = (MinMaster)Master; mm.SysDriver.ClearProposal(); if (!Page.IsPostBack) { InitProposalWizard.ActiveStepIndex = 0; } if (InitProposalWizard.ActiveStepIndex == 0) { FirstProblemList.Items.Clear(); List<string> PKless = mm.Stats.TablesMissingPK(); if (PKless.Count > 0) { foreach (string table in PKless) { FirstProblemList.Items.Add("Table " + table + " has no primary key defined." + " If you continue, this table will be ommitted from the proposal. You may as well add the PK and check again"); } } else { FirstProblemList.Items.Add("Seems OK..."); } Session["PKless"] = PKless; } }
protected void Page_Init(object sender, EventArgs e) { mm = (MinMaster)Master; factories = (List <IColumnFieldFactory>)Application["ColumnFieldFactories"]; int panelId = Int32.Parse(Page.RouteData.Values["panelId"] as string); actPanel = mm.SysDriver.Panels[panelId]; DataColumnCollection cols = mm.Stats.ColumnTypes[actPanel.tableName]; // the field types - default and special subsets allowed for special data types - i.e. a foereign key cannot be edited via nothing but // a FKFiels string[] fieldTypes = new string[] { FieldTypes.ShortText.ToString(), FieldTypes.Bool.ToString(), FieldTypes.Date.ToString(), FieldTypes.DateTime.ToString(), FieldTypes.Text.ToString() }; string[] EnumType = new string[] { FieldTypes.Enum.ToString() }; string[] FKtype = new string[] { FieldTypes.FK.ToString() }; string[] mappingType = new string[] { FieldTypes.M2NMapping.ToString() }; string[] validationRules = Enum.GetNames(typeof(ValidationRules)); //possible bugpoing (see repo) // a FKField can be only required - let referential integrity take care of the rest string[] requiredRule = new string[] { Enum.GetName(typeof(ValidationRules), ValidationRules.Required) }; FKs = mm.Stats.FKs[actPanel.tableName]; mappings = new List <M2NMapping>(); mappings = mm.Stats.Mappings[actPanel.tableName]; panelName.Text = actPanel.panelName; // create a datarow for each column, specifiing... foreach (DataColumn col in cols) // std. fields (incl. FKs) { IColumnField cf = (IColumnField)actPanel.fields.Find(x => x is IColumnField && ((IColumnField)x).ColumnName == col.ColumnName); TableRow r = new TableRow(); r.ID = col.ColumnName; //...the name,... TableCell nameCell = new TableCell(); Label nameLabel = new Label(); nameLabel.Text = col.ColumnName; nameCell.Controls.Add(nameLabel); r.Cells.Add(nameCell); //...whether the column will be accessible to editation at all,... TableCell presentCell = new TableCell(); CheckBox present = new CheckBox(); present.Checked = cf != null; presentCell.Controls.Add(present); r.Cells.Add(presentCell); FK fk = FKs.Find(x => x.myColumn == col.ColumnName); if (cf != null && cf is FKField) { fk = ((FKField)cf).FK; } //...the FieldType,... TableCell typeCell = new TableCell(); DropDownList dl = new DropDownList(); Dictionary <int, string> typeOptions = new Dictionary <int, string>(); int current = -1; for (int i = 0; i < factories.Count; i++) { if (factories[i].CanHandle(col)) { typeOptions.Add(i, factories[i].UIName); } if (cf != null && cf.GetType() == (factories[i].ProductionType)) { current = typeOptions.Count - 1; } } dl.DataSource = typeOptions; dl.DataValueField = "Key"; dl.DataTextField = "Value"; dl.DataBind(); dl.SelectedIndex = current; typeCell.Controls.Add(dl); r.Cells.Add(typeCell); //...what column of the referred table to display in the dropdown TableCell FKDisplayCell = new TableCell(); // set default value if the field was originally present in the editation form if (fk != null) { DropDownList fkddl = new DropDownList(); fkddl.DataSource = mm.Stats.ColumnsToDisplay[fk.refTable]; fkddl.DataBind(); if (cf != null) { fkddl.SelectedIndex = fkddl.Items.IndexOf(fkddl.Items.FindByValue(((FKField)cf).FK.displayColumn)); } FKDisplayCell.Controls.Add(fkddl); } r.Cells.Add(FKDisplayCell); //PBPR //...the validation rules... TableCell validCell = new TableCell(); CheckBox requiredCb = new CheckBox(); Label requiredlabel = new Label(); requiredlabel.Text = "required "; CheckBox uniCheck = new CheckBox(); Label uniLabel = new Label(); uniLabel.Text = "unique"; if (cf != null) { requiredCb.Checked = cf.Required; uniCheck.Checked = cf.Unique; } if (!(cf is CheckBoxField)) { validCell.Controls.Add(requiredlabel); validCell.Controls.Add(requiredCb); validCell.Controls.Add(uniLabel); validCell.Controls.Add(uniCheck); } r.Cells.Add(validCell); //...and the caption TableCell captionCell = new TableCell(); TextBox caption = new TextBox(); captionCell.Controls.Add(caption); r.Cells.Add(captionCell); if (cf != null) { caption.Text = cf.Caption; } // index 6 tbl.Rows.Add(r); } // mappings will get a similiar table, but some collumns (like validation) will just be left empty foreach (M2NMapping mapping in mappings) { M2NMappingField f = actPanel.fields.Find( x => x is M2NMappingField && ((M2NMappingField)x).Mapping.myColumn == mapping.myColumn) as M2NMappingField; TableRow r = new TableRow(); TableCell nameCell = new TableCell(); Label nameLabel = new Label(); nameLabel.Text = mapping.myTable + " to " + mapping.refTable + " via " + mapping.mapTable; nameCell.Controls.Add(nameLabel); r.Cells.Add(nameCell); TableCell presentCell = new TableCell(); CheckBox present = new CheckBox(); present.Checked = f != null; presentCell.Controls.Add(present); r.Cells.Add(presentCell); TableCell typeCell = new TableCell(); DropDownList dl = new DropDownList(); dl.DataSource = mappingType; dl.DataBind(); typeCell.Controls.Add(dl); r.Cells.Add(typeCell); TableCell displayCell = new TableCell(); DropDownList displayDrop = new DropDownList(); displayDrop.DataSource = mm.Stats.ColumnsToDisplay[mapping.refTable]; displayDrop.DataBind(); if (f != null) { displayDrop.SelectedIndex = displayDrop.Items.IndexOf(displayDrop.Items.FindByValue(f.Mapping.displayColumn)); } displayCell.Controls.Add(displayDrop); r.Cells.Add(displayCell); TableCell validCell = new TableCell(); // leave it empty r.Cells.Add(validCell); TableCell captionCell = new TableCell(); TextBox caption = new TextBox(); captionCell.Controls.Add(caption); r.Cells.Add(captionCell); if (f != null) { caption.Text = f.Caption; } mappingsTbl.Rows.Add(r); } // what can be done with the panel string[] actionTypes = new string[] { UserAction.Insert.ToString(), UserAction.Update.ToString(), UserAction.Delete.ToString() }; // controls List <string> activeActions = (from _min.Models.Control control in actPanel.controls select Enum.GetName(typeof(UserAction), control.action)).ToList <string>(); actions.SetOptions(new List <string>(actionTypes)); actions.SetIncludedOptions(activeActions); backButton.PostBackUrl = backButton.GetRouteUrl("ArchitectShowRoute", new { projectName = mm.ProjectName }); }
protected void Page_Init(object sender, EventArgs e) { mm = (MinMaster)Master; factories = (List<IColumnFieldFactory>)Application["ColumnFieldFactories"]; int panelId = Int32.Parse(Page.RouteData.Values["panelId"] as string); actPanel = mm.SysDriver.Panels[panelId]; DataColumnCollection cols = mm.Stats.ColumnTypes[actPanel.tableName]; // the field types - default and special subsets allowed for special data types - i.e. a foereign key cannot be edited via nothing but // a FKFiels string[] fieldTypes = new string[] { FieldTypes.ShortText.ToString(), FieldTypes.Bool.ToString(), FieldTypes.Date.ToString(), FieldTypes.DateTime.ToString(), FieldTypes.Text.ToString() }; string[] EnumType = new string[] { FieldTypes.Enum.ToString() }; string[] FKtype = new string[] { FieldTypes.FK.ToString() }; string[] mappingType = new string[] { FieldTypes.M2NMapping.ToString() }; string[] validationRules = Enum.GetNames(typeof(ValidationRules)); //possible bugpoing (see repo) // a FKField can be only required - let referential integrity take care of the rest string[] requiredRule = new string[] { Enum.GetName(typeof(ValidationRules), ValidationRules.Required) }; FKs = mm.Stats.FKs[actPanel.tableName]; mappings = new List<M2NMapping>(); mappings = mm.Stats.Mappings[actPanel.tableName]; panelName.Text = actPanel.panelName; // create a datarow for each column, specifiing... foreach (DataColumn col in cols) { // std. fields (incl. FKs) IColumnField cf = (IColumnField)actPanel.fields.Find(x => x is IColumnField && ((IColumnField)x).ColumnName == col.ColumnName); TableRow r = new TableRow(); r.ID = col.ColumnName; //...the name,... TableCell nameCell = new TableCell(); Label nameLabel = new Label(); nameLabel.Text = col.ColumnName; nameCell.Controls.Add(nameLabel); r.Cells.Add(nameCell); //...whether the column will be accessible to editation at all,... TableCell presentCell = new TableCell(); CheckBox present = new CheckBox(); present.Checked = cf != null; presentCell.Controls.Add(present); r.Cells.Add(presentCell); FK fk = FKs.Find(x => x.myColumn == col.ColumnName); if(cf != null && cf is FKField) fk = ((FKField)cf).FK; //...the FieldType,... TableCell typeCell = new TableCell(); DropDownList dl = new DropDownList(); Dictionary<int, string> typeOptions = new Dictionary<int, string>(); int current = -1; for (int i = 0; i < factories.Count; i++) { if (factories[i].CanHandle(col)) typeOptions.Add(i, factories[i].UIName); if(cf != null && cf.GetType() == (factories[i].ProductionType)){ current = typeOptions.Count - 1; } } dl.DataSource = typeOptions; dl.DataValueField = "Key"; dl.DataTextField = "Value"; dl.DataBind(); dl.SelectedIndex = current; typeCell.Controls.Add(dl); r.Cells.Add(typeCell); //...what column of the referred table to display in the dropdown TableCell FKDisplayCell = new TableCell(); // set default value if the field was originally present in the editation form if (fk != null) { DropDownList fkddl = new DropDownList(); fkddl.DataSource = mm.Stats.ColumnsToDisplay[fk.refTable]; fkddl.DataBind(); if(cf != null) fkddl.SelectedIndex = fkddl.Items.IndexOf(fkddl.Items.FindByValue(((FKField)cf).FK.displayColumn)); FKDisplayCell.Controls.Add(fkddl); } r.Cells.Add(FKDisplayCell); //PBPR //...the validation rules... TableCell validCell = new TableCell(); CheckBox requiredCb = new CheckBox(); Label requiredlabel = new Label(); requiredlabel.Text = "required "; CheckBox uniCheck = new CheckBox(); Label uniLabel = new Label(); uniLabel.Text = "unique"; if (cf != null) { requiredCb.Checked = cf.Required; uniCheck.Checked = cf.Unique; } if (!(cf is CheckBoxField)) { validCell.Controls.Add(requiredlabel); validCell.Controls.Add(requiredCb); validCell.Controls.Add(uniLabel); validCell.Controls.Add(uniCheck); } r.Cells.Add(validCell); //...and the caption TableCell captionCell = new TableCell(); TextBox caption = new TextBox(); captionCell.Controls.Add(caption); r.Cells.Add(captionCell); if (cf != null) { caption.Text = cf.Caption; } // index 6 tbl.Rows.Add(r); } // mappings will get a similiar table, but some collumns (like validation) will just be left empty foreach (M2NMapping mapping in mappings) { M2NMappingField f = actPanel.fields.Find( x => x is M2NMappingField && ((M2NMappingField)x).Mapping.myColumn == mapping.myColumn) as M2NMappingField; TableRow r = new TableRow(); TableCell nameCell = new TableCell(); Label nameLabel = new Label(); nameLabel.Text = mapping.myTable + " to " + mapping.refTable + " via " + mapping.mapTable; nameCell.Controls.Add(nameLabel); r.Cells.Add(nameCell); TableCell presentCell = new TableCell(); CheckBox present = new CheckBox(); present.Checked = f != null; presentCell.Controls.Add(present); r.Cells.Add(presentCell); TableCell typeCell = new TableCell(); DropDownList dl = new DropDownList(); dl.DataSource = mappingType; dl.DataBind(); typeCell.Controls.Add(dl); r.Cells.Add(typeCell); TableCell displayCell = new TableCell(); DropDownList displayDrop = new DropDownList(); displayDrop.DataSource = mm.Stats.ColumnsToDisplay[mapping.refTable]; displayDrop.DataBind(); if (f != null) { displayDrop.SelectedIndex = displayDrop.Items.IndexOf(displayDrop.Items.FindByValue(f.Mapping.displayColumn)); } displayCell.Controls.Add(displayDrop); r.Cells.Add(displayCell); TableCell validCell = new TableCell(); // leave it empty r.Cells.Add(validCell); TableCell captionCell = new TableCell(); TextBox caption = new TextBox(); captionCell.Controls.Add(caption); r.Cells.Add(captionCell); if (f != null) { caption.Text = f.Caption; } mappingsTbl.Rows.Add(r); } // what can be done with the panel string[] actionTypes = new string[] { UserAction.Insert.ToString(), UserAction.Update.ToString(), UserAction.Delete.ToString() }; // controls List<string> activeActions = (from _min.Models.Control control in actPanel.controls select Enum.GetName(typeof(UserAction), control.action)).ToList<string>(); actions.SetOptions(new List<string>(actionTypes)); actions.SetIncludedOptions(activeActions); backButton.PostBackUrl = backButton.GetRouteUrl("ArchitectShowRoute", new { projectName = mm.ProjectName }); }