//void ToolStripButton1Click(object sender, EventArgs e) //{ // foreach (SynapseProfile_Control spc in objectListView1.Objects) // { // spc.save(); // } // ComboBox1SelectedIndexChanged(this,e); //} void ComboBox3SelectedIndexChanged(object sender, EventArgs e) { cb_Form.Text = ""; cb_Form.Items.Clear(); foreach (SynapseControl C in AllControls) { if (!cb_Form.Items.Contains(C.FORM_NAME) && C.FK_MODULE_ID == ((SynapseModule)cb_Module.SelectedItem).ID) { cb_Form.Items.Add(C.FORM_NAME); } } if (cb_Form.Items.Count > 0) { cb_Form.SelectedIndex = 0; } var ControlCollection = SynapseControl.Load("WHERE FORM_NAME='" + cb_Form.SelectedItem + "' AND FK_MODULE_ID=" + ((SynapseModule)cb_Module.SelectedItem).ID + " Order by CTRL_NAME"); lst_ListOfControl.DataSource = ControlCollection.OrderBy(x => x.CTRL_NAME).ToList(); var Groups = SynapseProfile.Load("WHERE FK_MODULEID=" + ((SynapseModule)cb_Module.SelectedItem).ID); cb_Profiles.DataSource = Groups.OrderBy(x => x.TECHNICALNAME).ToList(); cb_Profiles.DisplayMember = "TECHNICALNAME"; cb_Profiles.ValueMember = "ID"; cb_Profiles.SelectedIndex = 0; }
private void Delete_Module(object sender, EventArgs e) { if (MessageBox.Show(GetLabel("Quest.0003"), GetLabel("Quest"), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes) { SynapseModule _module = (SynapseModule)olvModules.SelectedObject; IList <SynapseProfile_Control> _profileControl = SynapseProfile_Control.LoadFromQuery("SELECT dbo.[Synapse_Security_Profile Control].* FROM dbo.[Synapse_Security_Profile Control] INNER JOIN dbo.Synapse_Security_Profile ON dbo.[Synapse_Security_Profile Control].FK_PROFILEID = dbo.Synapse_Security_Profile.ID INNER JOIN dbo.Synapse_Module ON dbo.Synapse_Security_Profile.FK_MODULEID = dbo.Synapse_Module.ID WHERE (dbo.Synapse_Module.ID = " + _module.ID + ")"); IList <SynapseUser_Profile> _userProfile = SynapseUser_Profile.LoadFromQuery("SELECT dbo.[Synapse_Security_User Profile].* FROM dbo.[Synapse_Security_User Profile] INNER JOIN dbo.Synapse_Security_Profile ON dbo.[Synapse_Security_User Profile].FK_SECURITY_PROFILE = dbo.Synapse_Security_Profile.ID INNER JOIN dbo.Synapse_Module ON dbo.Synapse_Security_Profile.FK_MODULEID = dbo.Synapse_Module.ID WHERE (dbo.Synapse_Module.ID = " + _module.ID + ")"); IList <SynapseProfile> _profile = SynapseProfile.LoadFromQuery("SELECT dbo.Synapse_Security_Profile.* FROM dbo.Synapse_Security_Profile INNER JOIN dbo.Synapse_Module ON dbo.Synapse_Security_Profile.FK_MODULEID = dbo.Synapse_Module.ID WHERE (dbo.Synapse_Module.ID = " + _module.ID + ")"); IList <SynapseControl> _control = SynapseControl.Load("WHERE FK_MODULE_ID=" + _module.ID); SynapseCore.Database.DBFunction.StartTransaction(); try { foreach (SynapseProfile_Control obj in _profileControl) { obj.delete(); } foreach (SynapseUser_Profile obj in _userProfile) { obj.delete(); } foreach (SynapseProfile obj in _profile) { obj.delete(); } foreach (SynapseControl obj in _control) { obj.delete(); } foreach (SynapseLabel obj in ((SynapseModule)olvModules.SelectedObject).FriendlyName.Labels) { obj.delete(); } foreach (SynapseLabel obj in ((SynapseModule)olvModules.SelectedObject).Description.Labels) { obj.delete(); } _module.delete(); SynapseCore.Database.DBFunction.CommitTransaction(); listModule(); } catch (Exception ex) { SynapseCore.Database.DBFunction.RollbackTransaction(); MessageBox.Show("Data not deleted from Database:" + ex.Message, "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void refreshControls() { var ControlCollection = SynapseControl.Load("WHERE FORM_NAME='" + cb_Form.SelectedItem + "' AND FK_MODULE_ID=" + ((SynapseModule)cb_Module.SelectedItem).ID + " Order by CTRL_NAME"); if (ckNotAttributed.Checked) { foreach (SynapseProfile_Control c in objectListView1.Objects) { // ControlCollection.Remove(SynapseControl.LoadByID(c.FK_CONTROLID)); ControlCollection.Remove(ControlCollection.Where(x => x.ID == c.FK_CONTROLID).FirstOrDefault()); } } lst_ListOfControl.DataSource = ControlCollection.OrderBy(x => x.CTRL_NAME).ToList(); }
void SecurityEditLoad(object sender, EventArgs e) { tsbAddControl.Enabled = false; tsbDeleteControl.Enabled = false; tsbRemoveControl.Enabled = false; AllControls = SynapseControl.Load(); var Modules = SynapseModule.Load(); cb_Module.DataSource = Modules.OrderBy(x => x.FriendlyName.ToString()).ToList(); cb_Module.ValueMember = "ID"; cb_Module.DisplayMember = "FriendlyName"; cb_Module.SelectedIndex = 0; lst_ListOfControl.DisplayMember = "CTRL_NAME"; lst_ListOfControl.ValueMember = "ID"; }
private void btn_analyse_Click(object sender, EventArgs e) { Presentation.Clear(); string[] ids = (from id in olv_Modules.CheckedObjects.Cast <SynapseModule>() select id.ID.ToString()).ToArray(); string str_id = string.Join(",", ids); Prd_Users = SynapseUser.Load(); Acc_Users = ACCSynapseUser.Load(); obj_sync pr = new obj_sync(); pr.Name = typeof(SynapseUser).FullName; pr.PrdCnt = Prd_Users.Count; pr.AccCnt = Acc_Users.Count; pr.Link = (from l in AccToPrdID where l.OBJECTTYPE == typeof(ACCSynapseUser).Name select l).Count(); Presentation.Add(pr); Prd_Profiles = SynapseProfile.Load("WHERE FK_MODULEID in (" + str_id + ")"); Acc_Profiles = ACCSynapseProfile.Load("WHERE FK_MODULEID in (" + str_id + ")"); pr = new obj_sync(); pr.Name = typeof(SynapseProfile).FullName; pr.PrdCnt = Prd_Profiles.Count; pr.AccCnt = Acc_Profiles.Count; IList <Int64> Acc_Profiles_IDs = (from i in Acc_Profiles select i.ID).ToList(); pr.Link = (from l in AccToPrdID where l.OBJECTTYPE == typeof(ACCSynapseProfile).Name && Acc_Profiles_IDs.Contains(l.ACCID) select l).Count(); Presentation.Add(pr); string Prd_ProfilesID = string.Join(",", (from p in Prd_Profiles select p.ID.ToString()).ToArray()); string Acc_ProfilesID = string.Join(",", (from p in Acc_Profiles select p.ID.ToString()).ToArray()); Prd_Controls = SynapseControl.Load("WHERE FK_MODULE_ID in (" + str_id + ")"); Acc_Controls = ACCSynapseControl.Load("WHERE FK_MODULE_ID in (" + str_id + ")"); pr = new obj_sync(); pr.Name = typeof(SynapseControl).FullName; pr.PrdCnt = Prd_Controls.Count; pr.AccCnt = Acc_Controls.Count; IList <Int64> Acc_Controls_IDs = (from i in Acc_Controls select i.ID).ToList(); pr.Link = (from l in AccToPrdID where l.OBJECTTYPE == typeof(ACCSynapseControl).Name && Acc_Controls_IDs.Contains(l.ACCID) select l).Count(); Presentation.Add(pr); string Prd_ControlsID = string.Join(",", (from c in Prd_Controls select c.ID.ToString()).ToArray()); string Acc_ControlsID = string.Join(",", (from c in Acc_Controls select c.ID.ToString()).ToArray()); if (Prd_ControlsID.Length <= 0) { Prd_ProfileControls = new List <SynapseProfile_Control>(); } else { Prd_ProfileControls = SynapseProfile_Control.Load("WHERE FK_CONTROLID in (" + Prd_ControlsID + ")"); } try { Acc_ProfileControls = ACCSynapseProfile_Control.Load("WHERE FK_CONTROLID in (" + Acc_ControlsID + ")"); } catch { Acc_ProfileControls = new List <ACCSynapseProfile_Control>(); } pr = new obj_sync(); pr.Name = typeof(SynapseProfile_Control).FullName; pr.PrdCnt = Prd_ProfileControls.Count; pr.AccCnt = Acc_ProfileControls.Count; IList <Int64> Acc_ProfileControls_IDs = (from i in Acc_ProfileControls select i.ID).ToList(); pr.Link = (from l in AccToPrdID where l.OBJECTTYPE == typeof(ACCSynapseProfile_Control).Name && Acc_ProfileControls_IDs.Contains(l.ACCID) select l).Count(); Presentation.Add(pr); if (Prd_ProfilesID.Length <= 0) { Prd_UserProfiles = new List <SynapseUser_Profile>(); } else { Prd_UserProfiles = SynapseUser_Profile.Load("WHERE FK_SECURITY_PROFILE in (" + Prd_ProfilesID + ")"); } Acc_UserProfiles = ACCSynapseUser_Profile.Load("WHERE FK_SECURITY_PROFILE in (" + Acc_ProfilesID + ")"); pr = new obj_sync(); pr.Name = typeof(SynapseUser_Profile).FullName; pr.PrdCnt = Prd_UserProfiles.Count; pr.AccCnt = Acc_UserProfiles.Count; IList <Int64> Acc_UserProfiles_IDs = (from i in Acc_UserProfiles select i.ID).ToList(); pr.Link = (from l in AccToPrdID where l.OBJECTTYPE == typeof(ACCSynapseUser_Profile).Name && Acc_UserProfiles_IDs.Contains(l.ACCID) select l).Count(); Presentation.Add(pr); olv_analyse.SetObjects(Presentation); }
public static StringBuilder UpdateControlsInDB(System.Windows.Forms.Control.ControlCollection controlCollection, Int64 ModuleID, Hashtable Keys) { StringBuilder SB = new StringBuilder(); if (Keys == null) { if (controlCollection.Count > 0) { SB.AppendLine(controlCollection[0].FindForm().Name + "=" + controlCollection[0].FindForm().Text); } Keys = new Hashtable(); var SControlCollection = SynapseControl.Load("WHERE FK_MODULE_ID = " + ModuleID.ToString()); foreach (SynapseControl SC in SControlCollection) { try { Keys.Add(SC.FORM_NAME + SC.CTRL_NAME + SC.CTRL_TYPE, SC); } // TODO: Catch more specific exception catch (Exception ex) { SynapseForm.SynapseLogger.Error(ex.Message); } } } foreach (Control C in controlCollection) { string formName = C.FindForm().Name; string controlType = C.GetType().ToString(); if (!Keys.ContainsKey(formName + C.Name + controlType)) { CreateControlInDB(ModuleID, formName, C.Name, controlType); } switch (controlType) { case "System.Windows.Forms.Label": SB.AppendLine(C.FindForm().Name + "." + C.Name + "=" + C.Text); break; case "System.Windows.Forms.Button": SB.AppendLine(C.FindForm().Name + "." + C.Name + "=" + C.Text); break; case "System.Windows.Forms.MenuStrip": MenuStrip Menu = (MenuStrip)C; SB.AppendLine(ListMenuStrip(Menu.Items, C.FindForm().Name, ModuleID, Keys).ToString()); break; case "System.Windows.Forms.TextBox": break; case "System.Windows.Forms.FlowLayoutPanel": FlowLayoutPanel FP = (FlowLayoutPanel)C; SB.AppendLine(UpdateControlsInDB(FP.Controls, ModuleID, Keys).ToString()); break; case "System.Windows.Forms.GroupBox": SB.AppendLine(C.FindForm().Name + "." + C.Name + "=" + C.Text); GroupBox group = (GroupBox)C; SB.AppendLine(UpdateControlsInDB(group.Controls, ModuleID, Keys).ToString()); break; case "System.Windows.Forms.CheckedListBox": break; case "System.Windows.Forms.CheckBox": SB.AppendLine(C.FindForm().Name + "." + C.Name + "=" + C.Text); break; case "System.Windows.Forms.ToolStrip": ToolStrip Tool = (ToolStrip)C; SB.AppendLine(ListMenuStrip(Tool.Items, C.FindForm().Name, ModuleID, Keys).ToString()); break; case "System.Windows.Forms.StatusStrip": StatusStrip Status = (StatusStrip)C; SB.AppendLine(ListMenuStrip(Status.Items, C.FindForm().Name, ModuleID, Keys).ToString()); break; case "System.Windows.Forms.ToolStripPanel": ContainerControl mycontainer = (ContainerControl)C; SB.AppendLine(UpdateControlsInDB(mycontainer.Controls, ModuleID, Keys).ToString()); break; case "System.Windows.Forms.TabPage": SB.AppendLine(C.FindForm().Name + "." + C.Name + "=" + C.Text); Panel mytabpage = (Panel)C; SB.AppendLine(UpdateControlsInDB(mytabpage.Controls, ModuleID, Keys).ToString()); break; case "System.Windows.Forms.Panel": case "System.Windows.Forms.SplitterPanel": case "System.Windows.Forms.ToolStripContentPanel": Panel myPanel = (Panel)C; SB.AppendLine(UpdateControlsInDB(myPanel.Controls, ModuleID, Keys).ToString()); break; case "System.Windows.Forms.ToolStripContainer": System.Windows.Forms.ToolStripContainer tscontainer = (System.Windows.Forms.ToolStripContainer)C; SB.AppendLine(UpdateControlsInDB(tscontainer.Controls, ModuleID, Keys).ToString()); break; case "System.Windows.Forms.SplitContainer": System.Windows.Forms.SplitContainer mysplit = (System.Windows.Forms.SplitContainer)C; SB.AppendLine(UpdateControlsInDB(mysplit.Controls, ModuleID, Keys).ToString()); break; case "System.Windows.Forms.TabControl": TabControl tabControl = (TabControl)C; SB.AppendLine(UpdateControlsInDB(tabControl.Controls, ModuleID, Keys).ToString()); break; case "System.Windows.Forms.ListView": ListView liste = (ListView)C; foreach (ColumnHeader Col in liste.Columns) { if (Col.Name != null && Col.Name != "") { SB.AppendLine(C.FindForm().Name + "." + C.Name + "." + Col.Name + "=" + Col.Text); if (!Keys.ContainsKey(formName + C.Name + "." + Col.Name + Col.GetType().ToString())) { CreateControlInDB(ModuleID, formName, C.Name + "." + Col.Name, Col.GetType().ToString()); } } else { SynapseForm.SynapseLogger.Warn("Column with text '" + Col.Text + "' has no name or the default one"); } } break; case "SynapseAdvancedControls.ObjectListView": ObjectListView oliste = (ObjectListView)C; SB.AppendLine("ObjectListView.MenuLabelColumns=" + oliste.MenuLabelColumns); SB.AppendLine("ObjectListView.MenuLabelGroupBy=" + oliste.MenuLabelGroupBy); SB.AppendLine("ObjectListView.MenuLabelLockGroupingOn=" + oliste.MenuLabelLockGroupingOn); SB.AppendLine("ObjectListView.MenuLabelSelectColumns=" + oliste.MenuLabelSelectColumns); SB.AppendLine("ObjectListView.MenuLabelSortAscending=" + oliste.MenuLabelSortAscending); SB.AppendLine("ObjectListView.MenuLabelSortDescending=" + oliste.MenuLabelSortDescending); SB.AppendLine("ObjectListView.MenuLabelTurnOffGroups=" + oliste.MenuLabelTurnOffGroups); SB.AppendLine("ObjectListView.MenuLabelUnlockGroupingOn=" + oliste.MenuLabelUnlockGroupingOn); SB.AppendLine("ObjectListView.MenuLabelUnsort=" + oliste.MenuLabelUnsort); foreach (OLVColumn Col in oliste.AllColumns) { if (Col.Text != null && Col.Text != "") { SB.AppendLine(C.FindForm().Name + "." + C.Name + "." + Col.Text.Replace(' ', '_').ToUpper() + "=" + Col.Text); if (!Keys.ContainsKey(formName + C.Name + "." + Col.Text.Replace(' ', '_').ToUpper() + Col.GetType().ToString())) { CreateControlInDB(ModuleID, formName, C.Name + "." + Col.Text.Replace(' ', '_').ToUpper(), Col.GetType().ToString()); } } else { SynapseForm.SynapseLogger.Warn("Column with text '" + Col.Text + "' has no name or the default one"); } } break; case "SynapseCore.Controls.SynapseGraphic": SynapseGraphic graph = (SynapseGraphic)C; SB.AppendLine("SynapseGraphic.CopyMenu=" + graph.CopyMenu); SB.AppendLine("SynapseGraphic.CurveOnlyMenu=" + graph.CurveOnlyMenu); SB.AppendLine("SynapseGraphic.CurvesMenu=" + graph.CurvesMenu); SB.AppendLine("SynapseGraphic.PageSetupMenu=" + graph.PageSetupMenu); SB.AppendLine("SynapseGraphic.PrintMenu=" + graph.PrintMenu); SB.AppendLine("SynapseGraphic.SaveAsMenu=" + graph.SaveAsMenu); SB.AppendLine("SynapseGraphic.SetDefaultScaleMenu=" + graph.SetDefaultScaleMenu); SB.AppendLine("SynapseGraphic.ShowAllCurvesMenu=" + graph.ShowAllCurvesMenu); SB.AppendLine("SynapseGraphic.ShowHideCurveMenu=" + graph.ShowHideCurveMenu); SB.AppendLine("SynapseGraphic.ShowHideLegendMenu=" + graph.ShowHideLegendMenu); SB.AppendLine("SynapseGraphic.ShowPointValuesMenu=" + graph.ShowPointValuesMenu); SB.AppendLine("SynapseGraphic.UndoAllZoomMenu=" + graph.UndoAllZoomMenu); SB.AppendLine("SynapseGraphic.UnZoomMenu=" + graph.UnZoomMenu); break; default: if (C is UserControl) { } break; } if (C.ContextMenuStrip != null) { SynapseForm.SynapseLogger.Debug("Context menu found for control '" + C.Name + "' with menu name : '" + C.ContextMenuStrip.Name + "'"); controlType = C.ContextMenuStrip.GetType().ToString(); if (!Keys.ContainsKey(formName + C.ContextMenuStrip.Name + controlType)) { CreateControlInDB(ModuleID, formName, C.ContextMenuStrip.Name, controlType); Keys.Add(formName + C.ContextMenuStrip.Name + controlType, null); } SB.AppendLine(ListMenuStrip(C.ContextMenuStrip.Items, C.FindForm().Name, ModuleID, Keys).ToString()); } } return(SB); }