public User(string UID, Int64 ModuleID) { SUser = SynapseUser.LoadByUserID(UID); UserID = UID; _CurrentModuleID = ModuleID; _UserControls = new Hashtable(); try { _Groups = SynapseProfile.LoadFromQuery("SELECT [P_ID] as ID,[FK_ModuleID],[FK_LABELID],[P_TECHNICALNAME] as TECHNICALNAME,[IS_OWNER],[LEVEL] FROM [V_Synapse_UserGroups] WHERE UserID = '" + UID + "'"); _Modules = SynapseModule.LoadFromQuery("SELECT DISTINCT [M_ID] as ID,[LABELID],[PATH],[M_TECHNICALNAME] as TECHNICALNAME,[VERSION],[MODULECATEGORY],[VERSIONDATE],[DESCLABELID],[DEVSOURCE],[PRODSOURCE],[IS_ACTIVE],[IS_REQUESTABLE] FROM [V_Synapse_UserGroups] WHERE UserID = '" + UID + "' OR M_ID=1 ORDER BY MODULECATEGORY"); CSC = ControlSecurity.Load("WHERE (UserID = '" + UserID + "' OR UserID = 'Everybody') AND (FK_MODULE_ID=" + ModuleID + " OR FK_MODULE_ID=1)"); foreach (ControlSecurity C in CSC) { try { _UserControls.Add(C.FORM_NAME + C.CTRL_NAME, C); } // TODO: Catch more specific exception catch (Exception ex) { SynapseForm.SynapseLogger.Error(ex.Message); } } } // TODO: Catch more specific exception catch (Exception ex) { SynapseForm.SynapseLogger.Error(ex.Message); } }
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(); } } } } }
private void btn_SyncUserDB_Click(object sender, EventArgs e) { foreach (ACCSynapseUser auser in Acc_Users) { SynapseUser puser = SynapseUser.LoadByUserID(auser.UserID); if (puser.UserID != auser.UserID) { puser = new SynapseUser(); puser.CULTURE = auser.CULTURE; puser.FIRSTNAME = auser.FIRSTNAME; puser.LASTNAME = auser.LASTNAME; puser.UserID = auser.UserID; puser.save(); } } foreach (SynapseUser puser in Prd_Users) { ACCSynapseUser auser = ACCSynapseUser.LoadByUserID(puser.UserID); if (puser.UserID != auser.UserID) { auser = new ACCSynapseUser(); auser.CULTURE = puser.CULTURE; auser.FIRSTNAME = puser.FIRSTNAME; auser.LASTNAME = puser.LASTNAME; auser.UserID = puser.UserID; auser.save(); } } AccToPrdID = ACCTOPRD.Load("WHERE PRDID<>0"); foreach (ACCSynapseUser auser in Acc_Users) { SynapseUser puser = SynapseUser.LoadByUserID(auser.UserID); if (puser == null) { ACCTOPRD lnk = AccToPrdID.Where(a => a.ACCID == auser.ID && a.PRDID == puser.ID && a.OBJECTTYPE == typeof(ACCSynapseUser).Name).FirstOrDefault(); if (lnk == null) { lnk = new ACCTOPRD(); lnk.OBJECTTYPE = typeof(ACCSynapseUser).Name; lnk.ACCID = auser.ID; lnk.PRDID = puser.ID; } } } }