Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
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();
            }
        }