Beispiel #1
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);
            }
        }
Beispiel #2
0
        private void tsbSave_Click(object sender, EventArgs e)
        {
            if (checkFields())
            {
                SynapseCore.Database.DBFunction.StartTransaction();
                try
                {
                    _profile.FK_ModuleID   = (Int64)cbModule.SelectedValue;
                    _profile.TECHNICALNAME = txTechnicalName.Text;
                    _profile.LEVEL         = Int64.Parse("0" + txLevel.Text);
                    _profile.IS_OWNER      = ckOwner.Checked;

                    Int64 lblid = 0;
                    if (bagDescription.LblBag.Labels[0].LABELID == 0)
                    {
                        lblid = SynapseLabel.GetNextID();
                        for (Int32 x = 0; x < bagDescription.LblBag.Labels.Count; x++)
                        {
                            bagDescription.LblBag.Labels[x].LABELID = lblid;
                        }
                        bagDescription.Save();
                    }
                    else
                    {
                        lblid = bagDescription.LblBag.Labels[0].LABELID;
                        bagDescription.Save();
                    }
                    _profile.FK_LABELID = lblid;
                    _profile.save();

                    SynapseCore.Database.DBFunction.CommitTransaction();

                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    this.Close();
                }
                catch (Exception ex)
                {
                    SynapseCore.Database.DBFunction.RollbackTransaction();
                    MessageBox.Show("Data not saved in Database:" + ex.Message, "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #3
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();
        }