예제 #1
0
        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();
                        }
                    }
                }
            }
        }
예제 #2
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);
        }