private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { if (ctxmenu_Edit.SourceControl == olv_Groups && olv_Groups.SelectedObject != null) { var users = SynapseUser.LoadFromQuery("SELECT * FROM [SYNAPSE].[dbo].[V_Synapse_UserGroups] WHERE P_TECHNICALNAME = '" + ((SynapseProfile)olv_Groups.SelectedObject).TECHNICALNAME + "'"); if (users.Count == 0) { ((SynapseProfile)olv_Groups.SelectedObject).delete(); olv_Groups.RemoveObject(olv_Groups.SelectedObject); } else { string text = string.Empty; foreach (SynapseUser user in users) { text += string.Format("{0} {1} ({2})\n", user.FIRSTNAME, user.LASTNAME, user.UserID); } MessageBox.Show("There are still some users assigned to this group please delete them first\n" + text, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } if (ctxmenu_Edit.SourceControl == olv_Users && olv_Users.SelectedObject != null) { var usergroups = SynapseUser_Profile.Load("WHERE FK_SECURITY_USER = " + ((SynapseUser)olv_Users.SelectedObject).ID); foreach (SynapseUser_Profile sup in usergroups) { sup.delete(); } ((SynapseUser)olv_Users.SelectedObject).delete(); olv_Users.RemoveObject(olv_Users.SelectedObject); olv_GroupsOfUser.Clear(); } }
private bool isActionAuthorized(ObjectListView olv) { if (olv.SelectedObject != null) { SynapseUser_Profile link = (SynapseUser_Profile)olv.SelectedObject; if ((from p in ProfileCollection where p.ID == link.FK_SECURITY_PROFILE select p).ToList().Count >= 1) { mnuDeleteUserGroup.Enabled = true; ctxDeleteUserGroup.Enabled = true; mnuRemoveUserFromGroup.Enabled = true; ctxRemoveUserFromGroup.Enabled = true; return(true); } else { mnuDeleteUserGroup.Enabled = false; ctxDeleteUserGroup.Enabled = false; mnuRemoveUserFromGroup.Enabled = false; ctxRemoveUserFromGroup.Enabled = false; return(false); } } else { return(false); } }
private void DeleteUser_Click(object sender, EventArgs e) { SynapseUser _user = new SynapseUser(); switch (tabControl1.SelectedIndex) { case 0: _user = (SynapseUser)olvUsers.SelectedObject; break; case 1: _user = (SynapseUser)olvUsers2.SelectedObject; break; } if (MessageBox.Show(GetLabel("Quest.0001"), GetLabel("Quest"), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes) { var usergroups = SynapseUser_Profile.Load("WHERE FK_SECURITY_USER = " + _user.ID); foreach (SynapseUser_Profile sup in usergroups) { sup.delete(); } olvUsers.RemoveObject(_user); olvUsers2.RemoveObject(_user); _user.delete(); AllUserCollection = SynapseUser.Load(); olvUserGroups.Items.Clear(); } }
private void tsbRemoveUserFromGroup_Click(object sender, EventArgs e) { SynapseUser_Profile link = (SynapseUser_Profile)olvGroupUsers.SelectedObject; olvGroupUsers.RemoveObject(link); link.delete(); }
void Olv_GroupsOfUserModelDropped(object sender, SynapseAdvancedControls.ModelDropEventArgs e) { if (CurrentUser != 0 && e.SourceModels.Count > 0) { SynapseProfile profile = (SynapseProfile)e.SourceModels[0]; SynapseUser_Profile SUserProfile = new SynapseUser_Profile(); SUserProfile.FK_SECURITY_PROFILE = profile.ID; SUserProfile.FK_SECURITY_USER = CurrentUser; olv_GroupsOfUser.AddObject(SUserProfile); } }
private void btn_RefreshUsers_Click(object sender, EventArgs e) { olv_PRDUSERS.ClearObjects(); olv_ACCUSERS.ClearObjects(); Prd_Users = SynapseUser.Load(); Acc_Users = ACCSynapseUser.Load(); Prd_UserProfiles = SynapseUser_Profile.Load(); Acc_UserProfiles = ACCSynapseUser_Profile.Load(); olv_ACCUSERS.SetObjects(Acc_Users.OrderBy(au => au.UserID)); olv_PRDUSERS.SetObjects(Prd_Users.OrderBy(pu => pu.UserID)); }
private void btn_Prd_Delete_Click(object sender, EventArgs e) { foreach (SynapseUser u in olv_PRDUSERS.CheckedObjects) { IList <SynapseUser_Profile> profiles = SynapseUser_Profile.Load("WHERE [FK_SECURITY_USER] = " + u.ID); foreach (SynapseUser_Profile up in profiles) { up.delete(); } u.delete(); } }
private void addGroupToUser(SynapseProfile profile) { if (!isGroupAlreadyAssociated(profile)) { SynapseUser_Profile link = new SynapseUser_Profile(); link.FK_SECURITY_PROFILE = profile.ID; link.FK_SECURITY_USER = _currentUser; olvUserGroups.AddObject(link); link.save(); } }
private void fillGroupUsers() { tsbRemoveUserFromGroup.Enabled = false; ctxRemoveUserFromGroup.Enabled = false; mnuRemoveUserFromGroup.Enabled = false; IList <SynapseUser_Profile> UserProfiles = new List <SynapseUser_Profile>(); UserProfiles = SynapseUser_Profile.Load("WHERE FK_SECURITY_PROFILE=" + _currentGroup.ToString()); olvGroupUsers.SetObjects(UserProfiles); }
private void addUserToGroup(SynapseUser user) { if (!isUserAlreadyAssociated(user)) { SynapseUser_Profile link = new SynapseUser_Profile(); link.FK_SECURITY_PROFILE = _currentGroup; link.FK_SECURITY_USER = user.ID; link.save(); olvGroupUsers.AddObject(link); } }
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 btn_SyncAcc_Click(object sender, EventArgs e) { SynapseModule mod = SynapseModule.LoadByID((long)comboBox1.SelectedValue); IList <ACCSynapseProfile> Ap = ACCSynapseProfile.Load("WHERE FK_MODULEID = " + mod.ID); IList <SynapseProfile> Pp = SynapseProfile.Load("WHERE FK_MODULEID = " + mod.ID); if (Ap.Count != Pp.Count) { MessageBox.Show("ERROR : Sync before"); return; } IList <ACCTOPRD> links = ACCTOPRD.Load("WHERE OBJECTTYPE = 'ACCSynapseProfile'"); foreach (ACCSynapseProfile aprof in Ap) { if (links.Where(l => l.ACCID == aprof.ID).Count() == 0) { ACCTOPRD atop = new ACCTOPRD(); atop.ACCID = aprof.ID; atop.PRDID = Pp.Where(p => p.TECHNICALNAME == aprof.TECHNICALNAME).FirstOrDefault().ID; atop.OBJECTTYPE = typeof(ACCSynapseProfile).Name; if (atop.ACCID != 0 && atop.PRDID != 0) { atop.save(); } } } links = ACCTOPRD.Load("WHERE OBJECTTYPE = 'ACCSynapseProfile'"); foreach (ACCSynapseUser u in olv_ACCUSERS.CheckedObjects) { SynapseUser pu = SynapseUser.LoadByUserID(u.UserID); IList <ACCSynapseUser_Profile> AccRoles = ACCSynapseUser_Profile.Load("WHERE [FK_SECURITY_USER] = " + u.ID + " AND [FK_SECURITY_PROFILE] in (" + string.Join(",", Ap.Select(a => a.ID.ToString()).ToArray()) + ")"); IList <SynapseUser_Profile> PrdRoles = SynapseUser_Profile.Load("WHERE [FK_SECURITY_USER] = " + pu.ID + " AND [FK_SECURITY_PROFILE] in (" + string.Join(",", Pp.Select(a => a.ID.ToString()).ToArray()) + ")"); foreach (ACCSynapseUser_Profile Aup in AccRoles) { if (PrdRoles.Where(pr => pr.FK_SECURITY_PROFILE == Ap.Where(a => a.ID == Aup.FK_SECURITY_PROFILE).FirstOrDefault().PrdID(links)).Count() == 0) { SynapseUser_Profile pup = new SynapseUser_Profile(); pup.FK_SECURITY_USER = pu.ID; pup.FK_SECURITY_PROFILE = Ap.Where(a => a.ID == Aup.FK_SECURITY_PROFILE).FirstOrDefault().PrdID(links); if (MessageBox.Show("Add Group " + Ap.Where(a => a.ID == Aup.FK_SECURITY_PROFILE).FirstOrDefault().TECHNICALNAME + " to user " + pu.LASTNAME + " " + pu.FIRSTNAME, "Modify ?", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { pup.save(); } } } } }
void menu_RemoveClick(object sender, EventArgs e) { if (olv_GroupsOfUser.SelectedObject != null) { SynapseUser_Profile link = (SynapseUser_Profile)olv_GroupsOfUser.SelectedObject; if (link.ID == 0) { olv_GroupsOfUser.RemoveObject(link); } else { link.delete(); olv_GroupsOfUser.RemoveObject(link); } } //MessageBox.Show(olv_GroupsOfUser.SelectedObject.ToString()); }
private void ctxmenu_Remove_Opening(object sender, System.ComponentModel.CancelEventArgs e) { if (olv_GroupsOfUser.SelectedObject != null) { SynapseUser_Profile link = (SynapseUser_Profile)olv_GroupsOfUser.SelectedObject; if ((from p in ProfileCollection where p.ID == link.FK_SECURITY_PROFILE select p).ToList().Count >= 1) { menu_Remove.Enabled = true; menu_Remove.AutoToolTip = false; } else { menu_Remove.Enabled = false; menu_Remove.ToolTipText = "Not allowed"; menu_Remove.AutoToolTip = true; } } }
void Olv_UsersSelectedIndexChanged(object sender, EventArgs e) { if (olv_Users.SelectedObject != null) { SynapseUser User = ((SynapseUser)olv_Users.SelectedObject); Int64 SelectedUser = User.ID; CurrentUser = SelectedUser; lbl_SelectedUser.Text = User.FIRSTNAME + " " + User.LASTNAME; var UserProfiles = SynapseUser_Profile.Load("WHERE FK_SECURITY_USER="******""; } }
private void fillUserGroups() { tsbDeleteUserGroup.Enabled = false; ctxDeleteUserGroup.Enabled = false; mnuDeleteUserGroup.Enabled = false; IList <SynapseUser_Profile> UserProfiles = new List <SynapseUser_Profile>(); if (cbModules.SelectedItem != null && cbModules.Text != "*") { UserProfiles = SynapseUser_Profile.LoadFromQuery("SELECT * FROM [Synapse_Security_User Profile] INNER JOIN Synapse_Security_Profile ON [Synapse_Security_User Profile].FK_SECURITY_PROFILE=Synapse_Security_Profile.ID WHERE [Synapse_Security_User Profile].FK_SECURITY_USER="******" AND Synapse_Security_Profile.FK_MODULEID=" + ((SynapseModule)cbModules.SelectedItem).ID.ToString()); } else { UserProfiles = SynapseUser_Profile.Load("WHERE FK_SECURITY_USER=" + _currentUser.ToString()); } olvUserGroups.SetObjects(UserProfiles); }
void UserEditLoad(object sender, EventArgs e) { Hashtable LevelForProfile = new Hashtable(); this.ssl_StatusLabel.Text = FormUser.UserID; foreach (SynapseProfile Profile in SynapseForm.FormUser.Groups) { if (Profile.IS_OWNER) { ModuleIdFilter += Profile.FK_ModuleID + ","; if (!LevelForProfile.ContainsKey(Profile.FK_ModuleID)) { LevelForProfile.Add(Profile.FK_ModuleID, Profile.LEVEL); } else if ((Int64)LevelForProfile[Profile.FK_ModuleID] > Profile.LEVEL) { LevelForProfile[Profile.FK_ModuleID] = Profile.LEVEL; } } } var UserCollection = SynapseUser.Load(); if (SynapseForm.FormUser.IsMemberOf("SYNAPSE_SECURITY_ADMIN")) { ProfileCollection = SynapseProfile.Load(); } else if (ModuleIdFilter.Length > 1) { ProfileCollection = (from p in SynapseProfile.Load("WHERE FK_ModuleID in (" + ModuleIdFilter.TrimEnd(',') + ")") where p.LEVEL > (Int64)LevelForProfile[p.FK_ModuleID] select p).ToList(); } else { ProfileCollection = new List <SynapseProfile>(); } IList <SynapseProfile> AllProfileCollection; AllProfileCollection = SynapseProfile.Load(); ModuleCollection = SynapseModule.Load(); olvcGroups.ImageGetter = delegate(object row) { return(0); }; olvcUsers.ImageGetter = delegate(object row) { return(1); }; olvc_GroupName.ImageGetter = delegate(object row) { return(0); }; olvc_GroupName.AspectGetter = delegate(object x) { SynapseUser_Profile SUserProfile = (SynapseUser_Profile)x; foreach (SynapseProfile Sp in AllProfileCollection) { if (Sp.ID == SUserProfile.FK_SECURITY_PROFILE) { return(Sp.TECHNICALNAME); } } return("Unknown"); }; olvc_Module.AspectGetter = delegate(object x) { SynapseUser_Profile SUserProfile = (SynapseUser_Profile)x; foreach (SynapseProfile Sp in AllProfileCollection) { if (Sp.ID == SUserProfile.FK_SECURITY_PROFILE) { foreach (SynapseModule Module in ModuleCollection) { if (Module.ID == Sp.FK_ModuleID) { return(Module.FriendlyName); } } } } return("Unknown"); }; olv_GroupsOfUser.PrimarySortColumn = olvc_Module; olv_Groups.SetObjects(ProfileCollection); olv_Users.SetObjects(UserCollection); cb_Modules.DisplayMember = "FriendlyName"; cb_Modules.ValueMember = "ID"; cb_Modules.Items.Clear(); cb_Modules.Items.Add("ALL"); foreach (SynapseModule Mod in ModuleCollection) { cb_Modules.Items.Add(Mod); } cb_Modules.SelectedIndex = 0; }
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); }
private void btn_Sync_Click(object sender, EventArgs e) { AccToPrdID = ACCTOPRD.Load("WHERE PRDID<>0"); Int64 UsersCount = 0; Int64 ControlsCount = 0; Int64 ProfilesCount = 0; Int64 ProfileControlsCount = 0; Int64 UserAssignmentCount = 0; richTextBox1.Clear(); if (chk_SyncUser.Checked) { // ======= Create user in prod ======== foreach (ACCSynapseUser A_user in from au in Acc_Users where au.PrdID(AccToPrdID) == 0 select au) { if (chk_verbose.Checked) { richTextBox1.AppendText(A_user.GetType().Name + ": " + A_user.UserID + "\n"); } SynapseUser user = new SynapseUser(); CopyProperties(user, A_user); user.ID = 0; if (chk_save.Checked) { user.save(); } UsersCount++; CreateLinkEntry(A_user, A_user.ID, user.ID); } } // ======= Create controls in prod ======== foreach (ACCSynapseControl A_ctrl in from ac in Acc_Controls where ac.PrdID(AccToPrdID) == 0 select ac) { if (chk_verbose.Checked) { richTextBox1.AppendText(A_ctrl.GetType().Name + ": " + A_ctrl.CTRL_NAME + "\n"); } SynapseControl ctrl = new SynapseControl(); CopyProperties(ctrl, A_ctrl); ctrl.ID = 0; if (chk_save.Checked) { ctrl.save(); } ControlsCount++; CreateLinkEntry(A_ctrl, A_ctrl.ID, ctrl.ID); } // ======= Create profiles in prod ======== foreach (ACCSynapseProfile A_prof in from ap in Acc_Profiles where ap.PrdID(AccToPrdID) == 0 select ap) { if (chk_verbose.Checked) { richTextBox1.AppendText(A_prof.GetType().Name + ": " + A_prof.TECHNICALNAME + "\n"); } SynapseProfile prof = new SynapseProfile(); CopyProperties(prof, A_prof); prof.ID = 0; if (chk_save.Checked) { prof.save(); } ProfilesCount++; CreateLinkEntry(A_prof, A_prof.ID, prof.ID); } // ======= Create link control-profile in prod ======== foreach (ACCSynapseProfile_Control A_profControl in from apc in Acc_ProfileControls where apc.PrdID(AccToPrdID) == 0 select apc) { if (chk_verbose.Checked) { richTextBox1.AppendText(A_profControl.GetType().Name + ": " + A_profControl.FK_PROFILEID + "=>" + A_profControl.FK_CONTROLID + "\n"); } SynapseProfile_Control ProfControl = new SynapseProfile_Control(); ProfControl.IS_ACTIVE = A_profControl.IS_ACTIVE; ProfControl.IS_VISIBLE = A_profControl.IS_VISIBLE; try { ProfControl.FK_CONTROLID = AccToPrdID.ConvertID(typeof(ACCSynapseControl), A_profControl.FK_CONTROLID); ProfControl.FK_PROFILEID = AccToPrdID.ConvertID(typeof(ACCSynapseProfile), A_profControl.FK_PROFILEID); if (chk_save.Checked) { ProfControl.save(); } ProfileControlsCount++; CreateLinkEntry(A_profControl, A_profControl.ID, ProfControl.ID); } catch (MissingFieldException ex) { richTextBox1.AppendText("ERROR(" + ex.Message + "): " + A_profControl.GetType().Name + ": " + A_profControl.FK_PROFILEID + "=>" + A_profControl.FK_CONTROLID + "\n", Color.Red); richTextBox1.ScrollToCaret(); } catch (KeyNotFoundException ex) { richTextBox1.AppendText("WARNING(" + ex.Message + "): " + A_profControl.GetType().Name + ": " + A_profControl.FK_PROFILEID + "=>" + A_profControl.FK_CONTROLID + "\n", Color.Orange); richTextBox1.ScrollToCaret(); } } if (chk_UserAssignment.Checked) { // ======= Create link user-profile in prod ======== foreach (ACCSynapseUser_Profile A_userP in from aup in Acc_UserProfiles where aup.PrdID(AccToPrdID) == 0 select aup) { if (chk_verbose.Checked) { richTextBox1.AppendText(A_userP.GetType().Name + ": " + A_userP.FK_SECURITY_PROFILE + "=>" + A_userP.FK_SECURITY_USER + "\n"); } SynapseUser_Profile UserProf = new SynapseUser_Profile(); try { UserProf.FK_SECURITY_PROFILE = AccToPrdID.ConvertID(typeof(ACCSynapseProfile), A_userP.FK_SECURITY_PROFILE); UserProf.FK_SECURITY_USER = AccToPrdID.ConvertID(typeof(ACCSynapseUser), A_userP.FK_SECURITY_USER); if (chk_save.Checked) { UserProf.save(); } UserAssignmentCount++; CreateLinkEntry(A_userP, A_userP.ID, UserProf.ID); } catch (MissingFieldException ex) { richTextBox1.AppendText("ERROR(" + ex.Message + "): " + A_userP.GetType().Name + ": " + A_userP.FK_SECURITY_PROFILE + "=>" + A_userP.FK_SECURITY_USER + "\n", Color.Red); richTextBox1.ScrollToCaret(); } catch (KeyNotFoundException ex) { richTextBox1.AppendText("WARNING(" + ex.Message + "): " + A_userP.GetType().Name + ": " + A_userP.FK_SECURITY_PROFILE + "=>" + A_userP.FK_SECURITY_USER + "\n", Color.Orange); richTextBox1.ScrollToCaret(); } } } if (chk_save.Checked) { foreach (ACCTOPRD atp in from l in AccToPrdID where l.ID == 0 select l) { atp.save(); } } Int64 lnk = 0; richTextBox1.AppendText(UsersCount + " Users will be added", Color.Blue); lnk = AccToPrdID.Where(l => l.ID == 0 && l.OBJECTTYPE == typeof(ACCSynapseUser).Name).Count(); richTextBox1.AppendText(" with " + lnk + " new links\n", UsersCount == lnk ? Color.Blue : Color.Red); richTextBox1.AppendText(ControlsCount + " Controls will be added", Color.Blue); lnk = AccToPrdID.Where(l => l.ID == 0 && l.OBJECTTYPE == typeof(ACCSynapseControl).Name).Count(); richTextBox1.AppendText(" with " + lnk + " new links\n", ControlsCount == lnk ? Color.Blue : Color.Red); richTextBox1.AppendText(ProfilesCount + " Profiles will be added", Color.Blue); lnk = AccToPrdID.Where(l => l.ID == 0 && l.OBJECTTYPE == typeof(ACCSynapseProfile).Name).Count(); richTextBox1.AppendText(" with " + lnk + " new links\n", ProfilesCount == lnk ? Color.Blue : Color.Red); richTextBox1.AppendText(ProfileControlsCount + " Profile-Control link will be added", Color.Blue); lnk = AccToPrdID.Where(l => l.ID == 0 && l.OBJECTTYPE == typeof(ACCSynapseProfile_Control).Name).Count(); richTextBox1.AppendText(" with " + lnk + " new links\n", ProfileControlsCount == lnk ? Color.Blue : Color.Red); richTextBox1.AppendText(UserAssignmentCount + " Users assignments will be added", Color.Blue); lnk = AccToPrdID.Where(l => l.ID == 0 && l.OBJECTTYPE == typeof(ACCSynapseUser_Profile).Name).Count(); richTextBox1.AppendText(" with " + lnk + " new links\n", UserAssignmentCount == lnk ? Color.Blue : Color.Red); richTextBox1.ScrollToCaret(); }
public frmAccessRights() { InitializeComponent(); AllUserCollection = SynapseUser.Load(); AllProfileCollection = SynapseProfile.Load(); ModuleCollection = SynapseModule.Load(); olvUsers_USERID.ImageGetter = delegate(object row) { return(1); }; olvUsers2_USERID.ImageGetter = delegate(object row) { return(1); }; olvGroups_Group.ImageGetter = delegate(object row) { return(0); }; olvGroups_Description.AspectGetter = delegate(object x) { return(((SynapseProfile)x).Description.ToString()); }; olvGroups_Owner.AspectGetter = delegate(object x) { return(((SynapseProfile)x).IS_OWNER); }; olvGroups_Owner.Renderer = new MappedImageRenderer(new Object[] { true, imageList2.Images[0], "x", imageList2.Images[1] }); olvGroup2_Group.ImageGetter = delegate(object row) { return(0); }; olvGroup2_Owner.AspectGetter = delegate(object x) { return(((SynapseProfile)x).IS_OWNER); }; olvGroup2_Owner.Renderer = new MappedImageRenderer(new Object[] { true, imageList2.Images[0], "x", imageList2.Images[1] }); olvUserGroup_GroupName.ImageGetter = delegate(object row) { return(0); }; olvUserGroup_GroupName.AspectGetter = delegate(object x) { SynapseUser_Profile SUserProfile = (SynapseUser_Profile)x; foreach (SynapseProfile Sp in AllProfileCollection) { if (Sp.ID == SUserProfile.FK_SECURITY_PROFILE) { return(Sp.TECHNICALNAME); } } return("Unknown"); }; olvUserGroup_Description.AspectGetter = delegate(object x) { SynapseUser_Profile SUserProfile = (SynapseUser_Profile)x; foreach (SynapseProfile Sp in AllProfileCollection) { if (Sp.ID == SUserProfile.FK_SECURITY_PROFILE) { return(Sp.Description.ToString()); } } return(""); }; olvUserGroup_Module.AspectGetter = delegate(object x) { SynapseUser_Profile SUserProfile = (SynapseUser_Profile)x; foreach (SynapseProfile Sp in AllProfileCollection) { if (Sp.ID == SUserProfile.FK_SECURITY_PROFILE) { foreach (SynapseModule Module in ModuleCollection) { if (Module.ID == Sp.FK_ModuleID) { return(Module.FriendlyName); } } } } return("Unknown"); }; olvUserGroups.PrimarySortColumn = olvUserGroup_Module; olvGroupUsers_USERID.ImageGetter = delegate(object row) { return(1); }; olvGroupUsers_USERID.AspectGetter = delegate(object x) { SynapseUser_Profile SUserProfile = (SynapseUser_Profile)x; foreach (SynapseUser Su in AllUserCollection) { if (Su.ID == SUserProfile.FK_SECURITY_USER) { return(Su.UserID); } } return("Unknown"); }; olvGroupUsers_FIRSTNAME.AspectGetter = delegate(object x) { SynapseUser_Profile SUserProfile = (SynapseUser_Profile)x; foreach (SynapseUser Su in AllUserCollection) { if (Su.ID == SUserProfile.FK_SECURITY_USER) { return(Su.FIRSTNAME); } } return("Unknown"); }; olvGroupUsers_LASTNAME.AspectGetter = delegate(object x) { SynapseUser_Profile SUserProfile = (SynapseUser_Profile)x; foreach (SynapseUser Su in AllUserCollection) { if (Su.ID == SUserProfile.FK_SECURITY_USER) { return(Su.LASTNAME); } } return("Unknown"); }; olvGroupUsers.PrimarySortColumn = olvGroupUsers_USERID; }