Esempio n. 1
0
        //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;
        }
Esempio n. 2
0
        private void NewGroup_Click(object sender, EventArgs e)
        {
            frmGroup fGroup = new frmGroup();

            fGroup.Action  = "NEW";
            fGroup.Profile = new SynapseProfile();
            if (fGroup.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                SynapseProfile _profile = fGroup.Profile;
                olvGroups.AddObject(_profile);
                olvGroups2.AddObject(_profile);

                switch (tabControl1.SelectedIndex)
                {
                case 0:
                    olvGroups.SelectedObject = _profile;
                    break;

                case 1:
                    olvGroups2.SelectedObject = _profile;
                    break;
                }
                AllProfileCollection = SynapseProfile.Load();
            }
        }
Esempio n. 3
0
        private void frmSecurityOverView_Load(object sender, EventArgs e)
        {
            treeListView1.Columns[0].Text = SynapseForm.GetLabel("frmSecurityOverView.olvc_GROUP");
            treeListView1.Columns[1].Text = SynapseForm.GetLabel("frmSecurityOverView.olvc_VISIBLE");
            treeListView1.Columns[2].Text = SynapseForm.GetLabel("frmSecurityOverView.olvc_ACTIVE");
            treeListView1.Columns[3].Text = SynapseForm.GetLabel("frmSecurityOverView.olvc_Text");
            treeListView1.Columns[4].Text = SynapseForm.GetLabel("frmSecurityOverView.olvc_Comment");

            ModuleCollection = SynapseModule.Load();
            myControls       = (from c in ControlSecurityOverview.Load() where c.GROUP != "Everybody" select c).ToList();
            myProfiles       = SynapseProfile.Load();
            myModules        = SynapseModule.Load();
            fillModules();

            foreach (SynapseModule mod in myModules)
            {
                HashMod.Add(mod.TECHNICALNAME, mod.ID);
            }
            List <E_module> modules = new List <E_module>();

            foreach (string str in (from m in myControls select m.MODULE).Distinct())
            {
                modules.Add((E_module)str);
            }

            treeListView1.SetObjects(modules);
        }
Esempio n. 4
0
        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);
            }
        }
Esempio n. 5
0
        public static string GetControlGroups(Int64 ModuleID, string formName, string controlName)
        {
            string query = "SELECT     dbo.Synapse_Security_Profile.ID, dbo.Synapse_Security_Profile.FK_MODULEID, dbo.Synapse_Security_Profile.FK_LABELID, " +
                           "dbo.Synapse_Security_Profile.TECHNICALNAME, dbo.Synapse_Security_Profile.IS_OWNER, dbo.Synapse_Security_Profile.[LEVEL] " +
                           "FROM         dbo.Synapse_Security_Control INNER JOIN " +
                           "dbo.[Synapse_Security_Profile Control] ON dbo.Synapse_Security_Control.ID = dbo.[Synapse_Security_Profile Control].FK_CONTROLID INNER JOIN " +
                           "dbo.Synapse_Security_Profile ON dbo.[Synapse_Security_Profile Control].FK_PROFILEID = dbo.Synapse_Security_Profile.ID";
            string groups = string.Empty;
            IList <SynapseProfile> ctrl_security = SynapseProfile.LoadFromQuery(query + " WHERE FK_MODULE_ID = " + ModuleID + " AND FORM_NAME = '" + formName + "' AND CTRL_NAME = '" + controlName + "'");

            foreach (SynapseProfile P in ctrl_security)
            {
                if (!groups.Contains(P.TECHNICALNAME + "/"))
                {
                    groups += P.TECHNICALNAME + "/";
                }
            }
            if (groups == string.Empty)
            {
                return("Everybody");
            }
            else
            {
                return(groups);
            }
        }
Esempio n. 6
0
        private Boolean checkFields()
        {
            synapseErrorProvider1.SetError(cbModule, "");
            synapseErrorProvider1.SetError(txTechnicalName, "");
            synapseErrorProvider1.SetError(txLevel, "");

            IList <SynapseProfile> _profs = SynapseProfile.LoadFromPreparedQuery(@"SELECT * FROM SYNAPSE_SECURITY_PROFILE WHERE TECHNICALNAME=@nvarchar0 AND ID <> @bigint1",
                                                                                 "Default", txTechnicalName.Text, _profile.ID);

            if (_profs.Count > 0)
            {
                synapseErrorProvider1.SetError(txTechnicalName, GetLabel("Err.0004"));
                MessageBox.Show(GetLabel("Err.0004"), GetLabel("Err"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            if (cbModule.SelectedIndex < 0)
            {
                synapseErrorProvider1.SetError(cbModule, GetLabel("Err.0005"));
                MessageBox.Show(GetLabel("Err.0005"), GetLabel("Err"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            txTechnicalName.MandatoryErrorMessage = GetLabel("Err.0006");
            txLevel.MandatoryErrorMessage         = GetLabel("Err.0007");
            txLevel.NotMatchErrorMessage          = GetLabel("Err.0008");

            synapseErrorProvider1.ShowMessageBox = true;
            return(synapseErrorProvider1.ValidateControls());
        }
Esempio n. 7
0
        public override void initForm(SynapseCore.Security.Tools.SecureAndTranslateMode Mode)
        {
            base.initForm(Mode);

            ModuleCollection     = SynapseModule.Load();
            AllUserCollection    = SynapseUser.Load();
            AllProfileCollection = SynapseProfile.Load();
            initTree();
        }
Esempio n. 8
0
 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);
     }
 }
Esempio n. 9
0
 private bool isGroupAlreadyAssociated(SynapseProfile profile)
 {
     foreach (SynapseUser_Profile link in olvUserGroups.Objects)
     {
         if (profile.ID == link.FK_SECURITY_PROFILE)
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 10
0
        void btn_NewGroupClick(object sender, EventArgs e)
        {
            SynapseProfile SProfile      = new SynapseProfile();
            frmGroupEdit   GroupEditForm = new frmGroupEdit(ref SProfile, ModuleCollection);

            if (GroupEditForm.ShowDialog() == DialogResult.OK)
            {
                SProfile.save();
                olv_Groups.AddObject(SProfile);
            }
        }
Esempio n. 11
0
        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();
            }
        }
Esempio n. 12
0
        private void DeleteGroup_Click(object sender, EventArgs e)
        {
            SynapseProfile _profile = new SynapseProfile();

            switch (tabControl1.SelectedIndex)
            {
            case 0:
                _profile = (SynapseProfile)olvGroups.SelectedObject;
                break;

            case 1:
                _profile = (SynapseProfile)olvGroups2.SelectedObject;
                break;
            }

            var users = SynapseUser.LoadFromQuery("SELECT * FROM [SYNAPSE].[dbo].[V_Synapse_UserGroups] WHERE P_TECHNICALNAME = '" + _profile.TECHNICALNAME + "'");

            if (users.Count == 0)
            {
                if (MessageBox.Show(GetLabel("Quest.0002"), GetLabel("Quest"), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                {
                    SynapseCore.Database.DBFunction.StartTransaction();
                    try
                    {
                        foreach (SynapseLabel obj in _profile.Description.Labels)
                        {
                            obj.delete();
                        }
                        _profile.delete();

                        SynapseCore.Database.DBFunction.CommitTransaction();

                        olvGroups.RemoveObject(_profile);
                        olvGroups2.RemoveObject(_profile);
                    }
                    catch (Exception ex)
                    {
                        SynapseCore.Database.DBFunction.RollbackTransaction();
                        MessageBox.Show("Data not deleted from Database:" + ex.Message, "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            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(GetLabel("Err.0003") + text, GetLabel("Err"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Esempio n. 13
0
 public void ReloadModulesAndGroups()
 {
     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 = '" + UserID + "'");
         _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 = '" + UserID + "' OR M_ID=1 ORDER BY MODULECATEGORY");
     }
     // TODO: Catch more specific exception
     catch (Exception ex)
     {
         SynapseForm.SynapseLogger.Error(ex.Message);
     }
 }
Esempio n. 14
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);
                }
            }
        }
Esempio n. 15
0
 public frmGroupEdit(ref SynapseProfile Profile, IList <SynapseModule> ModuleCollection)
 {
     //
     // The InitializeComponent() call is required for Windows Forms designer support.
     //
     InitializeComponent();
     CurrentProfile = Profile;
     //
     // TODO: Add constructor code after the InitializeComponent() call.
     //
     cb_Module.DisplayMember = "TECHNICALNAME";
     cb_Module.ValueMember   = "ID";
     cb_Module.DataSource    = ModuleCollection;
 }
Esempio n. 16
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();
                        }
                    }
                }
            }
        }
Esempio n. 17
0
        private void fillGroups()
        {
            tsbEditGroup.Enabled    = false;
            tsbDeleteGroup.Enabled  = false;
            ctxEditGroup.Enabled    = false;
            ctxDeleteGroup.Enabled  = false;
            mnuEditGroup.Enabled    = false;
            mnuDeleteGroup.Enabled  = false;
            tsbAddUserGroup.Enabled = false;
            ctxAddUserGroup.Enabled = false;
            mnuAddUserGroup.Enabled = false;

            Hashtable LevelForProfile = new Hashtable();

            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;
                    }
                }
            }

            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>();
            }

            olvGroups.SetObjects(ProfileCollection.OrderBy(x => x.TECHNICALNAME.ToString()).ToList());
            olvGroups2.SetObjects(ProfileCollection.OrderBy(x => x.TECHNICALNAME.ToString()).ToList());
        }
Esempio n. 18
0
        private void EditGroup_Click(object sender, EventArgs e)
        {
            if (tsbEditGroup.Visible || tsbEditGroup2.Visible)
            {
                SynapseProfile _profile = new SynapseProfile();
                switch (tabControl1.SelectedIndex)
                {
                case 0:
                    _profile = (SynapseProfile)olvGroups.SelectedObject;
                    break;

                case 1:
                    _profile = (SynapseProfile)olvGroups2.SelectedObject;
                    break;
                }
                if (_profile != null)
                {
                    frmGroup fGroup = new frmGroup();
                    fGroup.Action  = "EDIT";
                    fGroup.Profile = _profile;
                    if (fGroup.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        _profile = fGroup.Profile;
                        olvGroups.RefreshObject(_profile);
                        olvGroups2.RefreshObject(_profile);

                        switch (tabControl1.SelectedIndex)
                        {
                        case 0:
                            olvGroups.SelectedObject  = _profile;
                            olvGroups2.SelectedObject = null;
                            break;

                        case 1:
                            olvGroups.SelectedObject  = null;
                            olvGroups2.SelectedObject = _profile;
                            break;
                        }
                        AllProfileCollection = SynapseProfile.Load();
                    }
                }
            }
        }
Esempio n. 19
0
        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;
        }
Esempio n. 20
0
        public frmAccessTree()
        {
            InitializeComponent();

            #region AspectGetter
            treeMain.CanExpandGetter = delegate(object x)
            {
                if (x is string)
                {
                    return(true);
                }
                if (x is SynapseModule)
                {
                    return(true);
                }
                if (x is SynapseUser)
                {
                    if (treeMain.GetParent(x) is SynapseProfile)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
                if (x is SynapseProfile)
                {
                    if (treeMain.GetParent(x) is UserGroups)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
                if (x is ModuleGroups)
                {
                    return(true);
                }
                if (x is UserGroups)
                {
                    return(true);
                }
                return(false);
            };

            olvColName.AspectGetter = delegate(object x)
            {
                if (x is string)
                {
                    return(((string)x).ToUpperInvariant());
                }

                if (x is SynapseModule)
                {
                    SynapseModule _module = (SynapseModule)x;
                    return(_module.FriendlyName);
                }

                if (x is SynapseProfile)
                {
                    SynapseProfile _profile = (SynapseProfile)x;
                    return(_profile.TECHNICALNAME);
                }

                if (x is SynapseUser)
                {
                    SynapseUser _user = (SynapseUser)x;
                    string      _col  = _user.UserID + " " + _user.LASTNAME + " " + _user.FIRSTNAME;
                    return(_col);
                }

                if (x is ModuleGroups)
                {
                    return("MODULE'S GROUPS");
                }

                if (x is UserGroups)
                {
                    return("USER'S GROUPS");
                }
                return("");
            };

            olvColName.ImageGetter = delegate(object x)
            {
                if (x is string)
                {
                    return(x);
                }
                if (x is ModuleGroups)
                {
                    return("GROUPS");
                }
                if (x is UserGroups)
                {
                    return("GROUPS");
                }

                return("");
            };

            treeMain.ChildrenGetter = delegate(object x)
            {
                if (x is string)
                {
                    string _type = (string)x;
                    switch (_type)
                    {
                    case "MODULES":
                        return(ModuleCollection.OrderBy(n => n.FriendlyName.ToString()).ToList());

                    case "GROUPS":
                        return(getAutorizedGroups(AllProfileCollection).OrderBy(n => n.TECHNICALNAME.ToString()).ToList());

                    case "USERS":
                        return(getUsers(0).OrderBy(n => n.UserID.ToString()).ToList());
                    }
                    return("");
                }
                if (x is SynapseUser)
                {
                    IList <UserGroups> _groupingGroups = new List <UserGroups>();
                    UserGroups         _groups         = new UserGroups();
                    _groups.User = (SynapseUser)x;
                    _groupingGroups.Add(_groups);
                    return(_groupingGroups);
                }
                if (x is SynapseProfile)
                {
                    IList <SynapseUser> userList = new List <SynapseUser>();
                    userList = getUsers(((SynapseProfile)x).ID);
                    //userList = SynapseUser.LoadFromQuery("SELECT dbo.Synapse_Security_User.* FROM dbo.Synapse_Security_User INNER JOIN dbo.[Synapse_Security_User Profile] ON dbo.Synapse_Security_User.ID = dbo.[Synapse_Security_User Profile].FK_SECURITY_USER WHERE dbo.[Synapse_Security_User Profile].FK_SECURITY_PROFILE = " + ((SynapseProfile)x).ID);
                    return(userList.OrderBy(n => n.UserID.ToString()).ToList());
                }

                if (x is UserGroups)
                {
                    IList <SynapseProfile> UserProfiles = SynapseProfile.Load("INNER JOIN [Synapse_Security_User Profile] ON Synapse_Security_Profile.ID=[Synapse_Security_User Profile].FK_SECURITY_PROFILE WHERE [Synapse_Security_User Profile].FK_SECURITY_USER="******"INNER JOIN [Synapse_Module] ON Synapse_Security_Profile.FK_MODULEID=[Synapse_Module].ID WHERE [Synapse_Module].ID=" + ((ModuleGroups)x).Module.ID.ToString());
                    return(getAutorizedGroups(UserProfiles).OrderBy(n => n.TECHNICALNAME.ToString()).ToList());
                }
                return("");
            };
            #endregion
        }
Esempio n. 21
0
        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;
        }
Esempio n. 22
0
        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();
        }
Esempio n. 23
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);
        }