Beispiel #1
0
 private void commandLoggingDialog_modifyMaximumRecordToLog(object sender, EventArgs e)
 {
     using (PromptDialog promptDialog = new PromptDialog(true))
     {
         ExchangeSettings exchangeSettings = new ExchangeSettings(new Component());
         exchangeSettings.MaximumRecordCount = CommandLoggingSession.GetInstance().MaximumRecordCount;
         promptDialog.Buttons      = MessageBoxButtons.OKCancel;
         promptDialog.Title        = Strings.MaximumNumberToLogTitle;
         promptDialog.Message      = Strings.MaximumRecordToLogIntroduction;
         promptDialog.ContentLabel = Strings.MaximumRecordToLogText;
         promptDialog.DataSource   = exchangeSettings;
         promptDialog.ValueMember  = "MaximumRecordCount";
         promptDialog.Parse       += delegate(object obj, ConvertEventArgs args)
         {
             int num;
             if (!int.TryParse((string)args.Value, out num) || !CommandLoggingSession.IsValidMaximumRecordCount(num))
             {
                 throw new LocalizedException(Strings.InvalidMaximumRecordNumber(CommandLoggingSession.MaximumRecordCountLimit));
             }
             args.Value = num;
         };
         if (base.ShellUI.ShowDialog(promptDialog) == DialogResult.OK)
         {
             CommandLoggingSession.GetInstance().MaximumRecordCount = exchangeSettings.MaximumRecordCount;
             if (CommandLoggingDialog.GlobalSettings != null)
             {
                 CommandLoggingDialog.GlobalSettings.MaximumRecordCount = exchangeSettings.MaximumRecordCount;
             }
         }
     }
 }
Beispiel #2
0
 private void PrepareMenuStripItems()
 {
     this.exportListCommand.Execute += delegate(object param0, EventArgs param1)
     {
         WinformsHelper.ShowExportDialog(this, this.resultListView, base.ShellUI);
     };
     this.closeToolStripMenuItem.Click += delegate(object param0, EventArgs param1)
     {
         base.Close();
     };
     this.switchCommandLoggingToolStripMenuItem.Click += delegate(object param0, EventArgs param1)
     {
         if (CommandLoggingSession.GetInstance().CommandLoggingEnabled)
         {
             CommandLoggingSession.GetInstance().CommandLoggingEnabled = false;
             if (CommandLoggingDialog.GlobalSettings != null)
             {
                 CommandLoggingDialog.GlobalSettings.IsCommandLoggingEnabled = false;
             }
             CommandLoggingDialog.StartDateTime = string.Empty;
             this.startLoggingDate.Text         = Strings.CommandLoggingStopped;
             this.switchCommandLoggingToolStripMenuItem.Text = Strings.StartCommandLogging;
             return;
         }
         CommandLoggingSession.GetInstance().CommandLoggingEnabled = true;
         if (CommandLoggingDialog.GlobalSettings != null)
         {
             CommandLoggingDialog.GlobalSettings.IsCommandLoggingEnabled = true;
         }
         CommandLoggingDialog.StartDateTime = ((DateTime)ExDateTime.Now).ToString();
         this.startLoggingDate.Text         = Strings.StartLoggingDate(CommandLoggingDialog.StartDateTime);
         this.switchCommandLoggingToolStripMenuItem.Text = Strings.StopCommandLogging;
     };
     this.clearLogToolStripMenuItem.Click += delegate(object param0, EventArgs param1)
     {
         if (base.ShellUI.ShowMessage(Strings.ConfirmClearText, UIService.DefaultCaption, MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             CommandLoggingSession.GetInstance().Clear();
         }
     };
     this.copyCommandsToolStripMenuItem.Click += delegate(object param0, EventArgs param1)
     {
         StringBuilder stringBuilder = new StringBuilder();
         foreach (object obj in this.resultListView.SelectedObjects)
         {
             DataRowView row = (DataRowView)obj;
             stringBuilder.AppendLine(this.RetrieveValueFromRow(row, CommandLoggingSession.command));
         }
         Clipboard.SetText(stringBuilder.ToString());
     };
 }
Beispiel #3
0
 internal static void LogError(Guid guid, string error)
 {
     lock (CommandLoggingDialog.mutex)
     {
         if (CommandLoggingDialog.instance != null)
         {
             CommandLoggingDialog.instance.EnsureThreadSafeToLogErrorAndDisplay(guid, error);
         }
         else
         {
             CommandLoggingSession.GetInstance().LogError(guid, error);
         }
     }
 }
Beispiel #4
0
 internal static void LogWarning(Guid guid, string warning)
 {
     lock (CommandLoggingDialog.mutex)
     {
         if (CommandLoggingDialog.instance != null)
         {
             CommandLoggingDialog.instance.EnsureThreadSafeToLogWarningAndDisplay(guid, warning);
         }
         else
         {
             CommandLoggingSession.GetInstance().LogWarning(guid, warning);
         }
     }
 }
Beispiel #5
0
 internal static void LogEnd(Guid guid, DateTime endTime)
 {
     lock (CommandLoggingDialog.mutex)
     {
         if (CommandLoggingDialog.instance != null)
         {
             CommandLoggingDialog.instance.EnsureThreadSafeToLogEndAndDisplay(guid, endTime);
         }
         else
         {
             CommandLoggingSession.GetInstance().LogEnd(guid, endTime);
         }
     }
 }
Beispiel #6
0
 internal static void LogStart(Guid guid, DateTime startTime, string commandText)
 {
     lock (CommandLoggingDialog.mutex)
     {
         if (CommandLoggingDialog.instance != null)
         {
             CommandLoggingDialog.instance.EnsureThreadSafeToLogStartAndDisplay(guid, startTime, commandText);
         }
         else
         {
             CommandLoggingSession.GetInstance().LogStart(guid, startTime, commandText);
         }
     }
 }
Beispiel #7
0
 private void LoadCommandLoggingSettings()
 {
     try
     {
         base.SuspendLayout();
         this.splitContainer.SuspendLayout();
         this.switchCommandLoggingToolStripMenuItem.Text = (CommandLoggingSession.GetInstance().CommandLoggingEnabled ? Strings.StopCommandLogging : Strings.StartCommandLogging);
         base.Size     = ((CommandLoggingDialog.GlobalSettings != null) ? CommandLoggingDialog.GlobalSettings.CommandLoggingDialogSize : CommandLoggingDialog.DefaultDialogSize);
         base.Location = ((CommandLoggingDialog.GlobalSettings != null) ? CommandLoggingDialog.GlobalSettings.CommandLoggingDialogLocation : CommandLoggingDialog.DefaultDialogLocation);
         this.SplitterDistanceScale = ((CommandLoggingDialog.GlobalSettings != null) ? CommandLoggingDialog.GlobalSettings.CommandLoggingDialogSplitterDistanceScale : CommandLoggingDialog.DefaultSplitterDistanceScale);
         this.privateSettings.LoadDataListViewSettings(this.resultListView);
     }
     finally
     {
         this.splitContainer.ResumeLayout(true);
         base.ResumeLayout(true);
     }
 }
Beispiel #8
0
 private void EnsureThreadSafeToLogErrorAndDisplay(Guid guid, string error)
 {
     if (base.InvokeRequired)
     {
         try
         {
             base.Invoke(new CommandLoggingDialog.LogErrorDelegate(this.EnsureThreadSafeToLogErrorAndDisplay), new object[]
             {
                 guid,
                 error
             });
             return;
         }
         catch (InvalidOperationException)
         {
             return;
         }
     }
     CommandLoggingSession.GetInstance().LogError(guid, error);
 }
Beispiel #9
0
 private void EnsureThreadSafeToLogStartAndDisplay(Guid guid, DateTime startTime, string commandText)
 {
     if (base.InvokeRequired)
     {
         try
         {
             base.Invoke(new CommandLoggingDialog.LogStartDelegate(this.EnsureThreadSafeToLogStartAndDisplay), new object[]
             {
                 guid,
                 startTime,
                 commandText
             });
             return;
         }
         catch (InvalidOperationException)
         {
             return;
         }
     }
     CommandLoggingSession.GetInstance().LogStart(guid, startTime, commandText);
 }
Beispiel #10
0
        public CommandLoggingDialog()
        {
            this.InitializeComponent();
            this.fileMenuItem.Text                        = Strings.ObjectPickerFile;
            this.closeToolStripMenuItem.Text              = Strings.ObjectPickerClose;
            this.copyCommandsToolStripMenuItem.Text       = Strings.CopyCommands;
            this.actionMenuItem.Text                      = Strings.CommandLoggingAction;
            this.helpCommandLoggingToolStripMenuItem.Text = Strings.ShowHelpCommand;
            ContextMenuStrip contextMenuStrip = new ContextMenuStrip();

            this.ContextMenuStrip               = contextMenuStrip;
            this.actionMenuItem.DropDown        = contextMenuStrip;
            this.clearLogToolStripMenuItem.Text = Strings.ClearLogText;
            this.exportListCommand.Text         = Strings.ExportListDefaultCommandText;
            this.exportListCommand.Name         = "exportListCommand";
            base.Icon = Icons.CommandLogging;
            this.startLoggingDate.Text = (string.IsNullOrEmpty(CommandLoggingDialog.StartDateTime) ? Strings.CommandLoggingStopped : Strings.StartLoggingDate(CommandLoggingDialog.StartDateTime));
            Command command = new Command();

            command.Text     = Strings.ModifyMaximumRecordToLog;
            command.Name     = "modifyMaximumRecordToLogCommand";
            command.Execute += this.commandLoggingDialog_modifyMaximumRecordToLog;
            this.resultListView.AvailableColumns.Add(CommandLoggingSession.startExecutionTime, Strings.StartExecutionTime, true, string.Empty, null, "G", null);
            this.resultListView.AvailableColumns.Add(CommandLoggingSession.endExecutionTime, Strings.EndExecutionTime, true, string.Empty, null, "G", null);
            this.resultListView.AvailableColumns.Add(CommandLoggingSession.executionStatus, Strings.ExecutionStatus, true, "");
            this.resultListView.AvailableColumns.Add(CommandLoggingSession.command, Strings.Command, true, "");
            this.resultListView.SelectionNameProperty                  = CommandLoggingSession.command;
            this.resultListView.DataSource                             = CommandLoggingSession.GetInstance().LoggingData;
            this.addRemoveColumnsToolStripMenuItem.Command             = this.resultListView.ShowColumnPickerCommand;
            this.addRemoveColumnsToolStripMenuItem.ToolTipText         = "";
            this.exportListToolStripMenuItem.Command                   = this.exportListCommand;
            this.exportListToolStripMenuItem.ToolTipText               = "";
            this.modifyMaximumRecordToLogToolStripMenuItem.Command     = command;
            this.modifyMaximumRecordToLogToolStripMenuItem.ToolTipText = "";
            this.resultListView.SelectionChanged                      += this.resultListView_SelectionChanged;
            if (CommandLoggingDialog.settingsProvider == null)
            {
                CommandLoggingDialog.settingsProvider = new ExchangeSettingsProvider();
                CommandLoggingDialog.settingsProvider.Initialize(null, null);
            }
            this.privateSettings.UpdateProviders(CommandLoggingDialog.settingsProvider);
            this.privateSettings.Reload();
            if (CommandLoggingDialog.GlobalSettings != null && !string.IsNullOrEmpty(CommandLoggingDialog.GlobalSettings.InstanceDisplayName))
            {
                this.Text = Strings.CommandLoggingDialogTitle(CommandLoggingDialog.GlobalSettings.InstanceDisplayName);
            }
            else
            {
                this.Text = Strings.CommandLoggingDialogTitle("");
            }
            this.PrepareMenuStripItems();
            contextMenuStrip.Items.AddRange(new ToolStripItem[]
            {
                this.switchCommandLoggingToolStripMenuItem,
                this.modifyMaximumRecordToLogToolStripMenuItem,
                this.clearLogToolStripMenuItem,
                new ToolStripSeparator(),
                this.addRemoveColumnsToolStripMenuItem,
                new ToolStripSeparator(),
                this.exportListToolStripMenuItem,
                this.separator,
                this.copyCommandsToolStripMenuItem,
                new ToolStripSeparator(),
                this.helpCommandLoggingToolStripMenuItem
            });
            this.PrepareActionMenuStrip();
            base.ResizeEnd += delegate(object param0, EventArgs param1)
            {
                this.SaveCommandLoggingSettings();
            };
            this.splitContainer.SplitterMoved += delegate(object param0, SplitterEventArgs param1)
            {
                this.SaveCommandLoggingSettings();
            };
            base.Load += delegate(object param0, EventArgs param1)
            {
                this.LoadCommandLoggingSettings();
            };
            this.helpCommandLoggingToolStripMenuItem.Click += delegate(object param0, EventArgs param1)
            {
                this.OnHelpRequested(new HelpEventArgs(Point.Empty));
            };
        }