/// <summary> /// Execute the specified command /// </summary> /// <param name="controller">The User Interface Controller for the current process</param><param name="commandName">The command that was requested.</param> /// <remarks> /// <para> /// If the command /// was configured to provide its own user interface it will be called on the main UI thread and needs to perform /// its own background processing to keep the user interface responsive. If not, it will be called /// from a background thread and the user interface will be kept responsive by the framework. /// </para> /// <para> /// The controller should not be persisted or accessed between calls, it may change and /// the same object may get calls from multiple controllers. /// </para> /// </remarks> public void Process(IUserInterfaceContext controller, string commandName) { switch (commandName) { case ConfigureCommand: m_Context.EditConfiguration(); break; case OpenSiteCommand: m_Controller.WebSiteOpen(null); break; } }
/// <summary> /// Extract metadata from a session and format it as session export config specifications /// </summary> private void ExtractMetadata(ISession session) { var metrics = session.MetricDefinitions.Select(md => md.FullMetricName()).ToList(); metrics.Sort(); var s = new StringBuilder(); const string indent = " "; // consistent spacing for export specifications s.AppendLine("// This is the application whose logs you will export:"); s.AppendLine(session.Summary.FullApplicationName()); s.AppendLine(); s.AppendLine("// If you wish to export log messages, uncomment one of lines below:"); s.AppendLine("// " + indent + ExportLogMessagesSpecifier + " Summary"); s.AppendLine("// " + indent + ExportLogMessagesSpecifier + " Default"); s.AppendLine("// " + indent + ExportLogMessagesSpecifier + " Detailed"); s.AppendLine(); s.AppendLine("// Uncomment lines below to enable the metrics you wish to export"); foreach (var metric in metrics) { s.AppendLine("// " + indent + metric); } s.AppendLine(); // Add an extra line to space out specifications for multiple applications s.AppendLine("// TIP: To keep you config uncluttered, delete unneeded comment lines"); s.AppendLine("// ...like this one, for example :-)"); // Because we are on a non-STA background thread, we need to create // an STA thread to actually post our string to the clipboard. // http://www.codeproject.com/Articles/2207/Clipboard-handling-with-NET?msg=2572888#xx2572888xx var t = new Thread(() => Clipboard.SetText(s.ToString())); t.SetApartmentState(ApartmentState.STA); // t.ApartmentState is deprecated t.Start(); t.Join(); // so the application wouldn't stop MessageBox.Show( "To configure Session Export, use Ctrl-V to paste metadata into the textbox labeled Data to be Exported. " + "Then delete extraneous lines leaving only what you want to export.", "How to Configure Export", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0x40000); // MB_TOPMOST _addInContext.EditConfiguration(); }
private void btnEditConfig_Click(object sender, EventArgs e) { _context.EditConfiguration(); RefreshUserList(); }