Esempio n. 1
0
 private void btn_trace_delete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(this, "Are you sure you want to delete this profile?", "Question",
                         MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         CrmTraceProfile profile = this.trace.Profiles.Profiles.Find(x => x.Name == this.cbb_trace_profiles.SelectedItem.ToString());
         this.trace.Profiles.Profiles.Remove(profile);
         this.trace.SaveProfiles();
         this.LoadProfiles();
         this.FillTraceControls(this.trace.CurrentProfile);
     }
 }
Esempio n. 2
0
        private void cbb_trace_profiles_SelectedIndexChanged(object sender, EventArgs e)
        {
            CrmTraceProfile profile = (CrmTraceProfile)this.cbb_trace_profiles.SelectedItem;

            FillTraceControls(profile);

            if (this.cbb_trace_profiles.SelectedItem.ToString() == "--> Current Server Settings <--")
            {
                this.btn_trace_delete.Enabled = false;
            }
            else
            {
                this.btn_trace_delete.Enabled = true;
            }
        }
Esempio n. 3
0
        private void btn_trace_saveAs_Click(object sender, EventArgs e)
        {
            CrmTraceProfile currentProfile = this.trace.Profiles.Profiles.Find(x => x.Name == this.cbb_trace_profiles.SelectedItem.ToString());

            if (currentProfile == null)
            {
                currentProfile = this.trace.CurrentProfile;
            }

            TraceRenameDialog trd = new TraceRenameDialog(currentProfile.Name);

            trd.StartPosition = FormStartPosition.CenterParent;

            if (trd.ShowDialog() == DialogResult.OK)
            {
                if (this.trace.Profiles.Profiles.Find(x => x.Name == trd.NewName) != null)
                {
                    MessageBox.Show(this, "A Crm trace profile already exists with this name!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                CrmTraceProfile profile = new CrmTraceProfile();
                profile.Name               = trd.NewName;
                profile.TraceCallStack     = this.cb_trace_callstack.Checked;
                profile.TraceDirectory     = this.txt_trace_tracedirectory.Text;
                profile.TraceFileSizeLimit = Convert.ToInt32(this.nud_trace_maxfilesize.Value);

                if (this.chk_trace_allCategories.Checked)
                {
                    profile.TraceCategories = "*:" + this.cbb_level_trace.SelectedItem.ToString();
                }
                else
                {
                    List <string> categories = new List <string>();

                    foreach (string itemText in this.clb_trace_categories.CheckedItems)
                    {
                        categories.Add(itemText.Trim() + ".*:" + this.cbb_level_trace.SelectedItem.ToString());
                    }

                    profile.TraceCategories = string.Join(";", categories);
                }

                this.trace.Profiles.Profiles.Add(profile);
                this.trace.SaveProfiles();
                this.LoadProfiles(profile);
            }
        }
Esempio n. 4
0
        private void LoadProfiles(CrmTraceProfile profile = null)
        {
            this.trace.LoadProfiles();
            this.cbb_trace_profiles.Items.Clear();

            this.trace.CurrentProfile.Name = "--> Current Server Settings <--";
            this.cbb_trace_profiles.Items.Add(this.trace.CurrentProfile);

            foreach (CrmTraceProfile profileItem in this.trace.Profiles.Profiles)
            {
                this.cbb_trace_profiles.Items.Add(profileItem);

                if (profile != null && profile.Name == profileItem.Name)
                {
                    this.cbb_trace_profiles.SelectedItem = profileItem;
                }
            }
        }
Esempio n. 5
0
        private void btn_trace_save_Click(object sender, EventArgs e)
        {
            CrmTraceProfile profile = this.trace.Profiles.Profiles.Find(x => x.Name == this.cbb_trace_profiles.SelectedItem.ToString());

            if (profile == null)
            {
                if (this.cbb_trace_profiles.SelectedItem.ToString() == "--> Current Server Settings <--")
                {
                    if (MessageBox.Show(this, "Are you sure you want to save these settings in the registry?", "Question",
                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }

                    profile = this.trace.CurrentProfile;
                }
                else
                {
                    profile = new CrmTraceProfile();

                    TraceRenameDialog trd = new TraceRenameDialog(profile.Name);

                    if (trd.ShowDialog() == DialogResult.OK)
                    {
                        profile.Name = trd.NewName;
                    }
                    else
                    {
                        return;
                    }

                    this.trace.Profiles.Profiles.Add(profile);
                }
            }

            profile.TraceCallStack     = this.cb_trace_callstack.Checked;
            profile.TraceDirectory     = this.txt_trace_tracedirectory.Text;
            profile.TraceFileSizeLimit = Convert.ToInt32(this.nud_trace_maxfilesize.Value);

            if (this.chk_trace_allCategories.Checked)
            {
                profile.TraceCategories = "*:" + this.cbb_level_trace.SelectedItem.ToString();
            }
            else
            {
                List <string> categories = new List <string>();

                foreach (string itemText in this.clb_trace_categories.CheckedItems)
                {
                    categories.Add(itemText.Trim() + ".*:" + this.cbb_level_trace.SelectedItem.ToString());
                }

                profile.TraceCategories = string.Join(";", categories);
            }

            if (this.cbb_trace_profiles.SelectedItem.ToString() == "--> Current Server Settings <--")
            {
                this.trace.ApplyChanges();
            }
            else
            {
                this.trace.SaveProfiles();
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Fills controls related to Crm trace
        /// </summary>
        private void FillTraceControls(CrmTraceProfile profile = null)
        {
            if (rbRemoteServer.Checked && String.IsNullOrEmpty(txtRemoteServerName.Text))
            {
                return;
            }

            ToolTip tt = new ToolTip();

            tt.SetToolTip(this.btn_trace_save, "Saves the current displayed settings in the selected trace profile.\r\nIf the current selected trace profile is the server one, settings will be saved in the registry");
            tt.SetToolTip(this.btn_trace_saveAs, "Saves the current displayed settings in a new trace profile");
            tt.SetToolTip(this.btn_trace_delete, "Deletes the current selected trace profile and loads current server trace profile.");

            this.trace = new CrmTrace();

            if (profile == null)
            {
                this.LoadProfiles();
                profile = this.trace.CurrentProfile;
            }

            this.cbb_trace_profiles.SelectedItem = profile;

            this.cb_trace_callstack.Checked    = profile.TraceCallStack;
            this.nud_trace_maxfilesize.Value   = profile.TraceFileSizeLimit;
            this.txt_trace_tracedirectory.Text = profile.TraceDirectory;

            string[] categories         = profile.TraceCategories.Split(';');
            string[] firstCategoryParts = categories[0].Split(':');

            this.cbb_level_trace.SelectedItem = firstCategoryParts[1];

            if (firstCategoryParts[0] == "*")
            {
                this.chk_trace_allCategories.Checked = true;
            }

            for (int i = 0; i < this.clb_trace_categories.Items.Count; i++)
            {
                string value = this.clb_trace_categories.Items[i].ToString().Trim() + ".*:" + this.cbb_level_trace.SelectedItem.ToString();

                this.clb_trace_categories.SetItemChecked(i, profile.TraceCategories.IndexOf(value) >= 0 ||
                                                         firstCategoryParts[0] == "*");
            }

            if (this.trace.TraceEnabled)
            {
                this.btn_trace_status.Text = "Disable trace";

                using (Stream myStream = currentAssembly.GetManifestResourceStream("CrmDiagTool2011.Images.bullet_green.png"))
                {
                    this.btn_trace_status.Image = new Bitmap(myStream);
                }

                this.gb_trace_parameters.Enabled      = false;
                this.btn_trace_cleandirectory.Enabled = false;
                this.btn_trace_zipfiles.Enabled       = false;
            }
            else
            {
                this.btn_trace_status.Text = "Enable trace";

                using (Stream myStream = currentAssembly.GetManifestResourceStream("CrmDiagTool2011.Images.bullet_red.png"))
                {
                    this.btn_trace_status.Image = new Bitmap(myStream);
                }
            }

            this.pnlTrace.Enabled = true;
        }