/// <summary> /// Called when an admin report is sent. /// </summary> /// <param name="sender">The task manager reporting the event.</param> /// <param name="e">The event arguments.</param> private void adminReportHandler(Object sender, EventArgs e) { AdminReportEventArgs adminReportArgs = e as AdminReportEventArgs; // Now report the event. InternalService.OnAdminNotification(adminReportArgs.Report, adminReportArgs.SendToAll); }
/// <summary> /// Report progress to the client. /// An updated progress is only sent for new integer percentage values. e.g. 1, 2, 3... /// If there are fewer events than 100 then you will see pecentage reported thus... 1, 4, 7... /// </summary> /// <param name="currentEvent">The current event number.</param> /// <param name="totalEvents">Total events to copy.</param> /// <param name="eventId">The event id of the last event copied.</param> private void reportProgress(long currentEvent, long totalEvents, int eventId) { if (totalEvents == 0) { return; } int thisPercentageComplete = (int)((currentEvent * 100) / totalEvents); if (thisPercentageComplete > m_LastPercentageProgressReported) { StackHashCopyIndexProgressAdminReport progressReport = new StackHashCopyIndexProgressAdminReport(); progressReport.Operation = StackHashAdminOperation.ErrorIndexCopyProgress; progressReport.ClientData = m_TaskParameters.ClientData; progressReport.ContextId = m_TaskParameters.ContextId; progressReport.CurrentEvent = currentEvent; progressReport.TotalEvents = totalEvents; progressReport.CurrentEventId = eventId; progressReport.SourceIndexFolder = m_TaskParameters.SourceIndex.ErrorIndexPath; progressReport.SourceIndexName = m_TaskParameters.SourceIndex.ErrorIndexPath; progressReport.DestinationIndexFolder = m_TaskParameters.DestinationErrorIndexSettings.Folder; progressReport.DestinationIndexName = m_TaskParameters.DestinationErrorIndexSettings.Name; m_LastPercentageProgressReported = thisPercentageComplete; if (Reporter.CurrentReporter != null) { AdminReportEventArgs adminReportArgs = new AdminReportEventArgs(progressReport, false); Reporter.CurrentReporter.ReportEvent(adminReportArgs); } } }
/// <summary> /// Report progress to the client. /// An updated progress is only sent for new integer percentage values. e.g. 1, 2, 3... /// If there are fewer events than 100 then you will see pecentage reported thus... 1, 4, 7... /// </summary> /// <param name="currentEvent">The current event number.</param> /// <param name="totalEvents">Total events to copy.</param> /// <param name="eventId">The event id of the last event copied.</param> private void reportProgress(long currentEvent, long totalEvents, int eventId) { // Don't bother reporting progress if only 1 event - only give progress when reporting products or whole index. if ((totalEvents == 0) || (totalEvents == 1)) { return; } int thisPercentageComplete = (int)((currentEvent * 100) / totalEvents); if (thisPercentageComplete > m_LastPercentageProgressReported) { StackHashBugReportProgressAdminReport progressReport = new StackHashBugReportProgressAdminReport(); progressReport.Operation = StackHashAdminOperation.BugReportProgress; progressReport.ClientData = m_TaskParameters.ClientData; progressReport.ContextId = m_TaskParameters.ContextId; progressReport.CurrentEvent = currentEvent; progressReport.TotalEvents = totalEvents; progressReport.CurrentEventId = eventId; m_LastPercentageProgressReported = thisPercentageComplete; if (Reporter.CurrentReporter != null) { AdminReportEventArgs adminReportArgs = new AdminReportEventArgs(progressReport, false); Reporter.CurrentReporter.ReportEvent(adminReportArgs); } } }
// // You can use the following additional attributes as you write your tests: // // Use ClassInitialize to run code before running the first test in the class // [ClassInitialize()] // public static void MyClassInitialize(TestContext testContext) { } // // Use ClassCleanup to run code after all tests in a class have run // [ClassCleanup()] // public static void MyClassCleanup() { } // // Use TestInitialize to run code before running each test // [TestInitialize()] // public void MyTestInitialize() { } // // Use TestCleanup to run code after each test has run // [TestCleanup()] // public void MyTestCleanup() { } // #endregion /// <summary> /// Called by the contoller context objects to report an admin event /// </summary> /// <param name="sender">The task manager reporting the event.</param> /// <param name="e">The event arguments.</param> public void OnAdminReport(Object sender, EventArgs e) { AdminReportEventArgs args = e as AdminReportEventArgs; if (args.Report.Operation == StackHashAdminOperation.WinQualSyncCompleted) { m_SyncCount++; m_WinQualSyncEvent.Set(); } else if (args.Report.Operation == StackHashAdminOperation.AnalyzeCompleted) { m_AnalyzeCount++; m_AnalyzeEvent.Set(); } }
/// <summary> /// Called by the contoller context objects to report an admin event /// </summary> /// <param name="sender">The task manager reporting the event.</param> /// <param name="e">The event arguments.</param> public void OnAdminReport(Object sender, EventArgs e) { AdminReportEventArgs adminArgs = e as AdminReportEventArgs; if (adminArgs.Report.Operation != StackHashAdminOperation.ContextStateChanged) { m_AdminReports.Add(adminArgs); } if (adminArgs.Report.Operation == StackHashAdminOperation.DownloadCabCompleted) { m_DownloadCompleteEvent.Set(); } }
/// <summary> /// Reports the status of the plug-ins after an error. /// </summary> private void reportPlugInStatus() { StackHashBugTrackerStatusAdminReport statusReport = new StackHashBugTrackerStatusAdminReport(); statusReport.Operation = StackHashAdminOperation.BugTrackerPlugInStatus; statusReport.ClientData = m_TaskParameters.ClientData; statusReport.ContextId = m_TaskParameters.ContextId; statusReport.PlugInDiagnostics = m_TaskParameters.PlugInContext.GetContextDiagnostics(null, true); if (Reporter.CurrentReporter != null) { AdminReportEventArgs adminReportArgs = new AdminReportEventArgs(statusReport, true); Reporter.CurrentReporter.ReportEvent(adminReportArgs); } }
/// <summary> /// Report progress to the client. /// </summary> /// <param name="currentFileName">Current file being copied (or just copied).</param> /// <param name="fileCount">Number of files copied so far.</param> /// <param name="isCopyStart">True - start of a copy. False - end of a copy.</param> private void reportProgress(String currentFileName, int fileCount, bool isCopyStart) { StackHashMoveIndexProgressAdminReport progressReport = new StackHashMoveIndexProgressAdminReport(); progressReport.Operation = StackHashAdminOperation.ErrorIndexMoveProgress; progressReport.ClientData = m_TaskParameters.ClientData; progressReport.ContextId = m_TaskParameters.ContextId; progressReport.CurrentFileName = currentFileName; progressReport.FileCount = fileCount; progressReport.IsCopyStart = isCopyStart; if (Reporter.CurrentReporter != null) { AdminReportEventArgs adminReportArgs = new AdminReportEventArgs(progressReport, false); Reporter.CurrentReporter.ReportEvent(adminReportArgs); } }
/// <summary> /// Called by the contoller context objects to report an admin event /// </summary> /// <param name="sender">The task manager reporting the event.</param> /// <param name="e">The event arguments.</param> public void OnAdminReport(Object sender, EventArgs e) { AdminReportEventArgs args = e as AdminReportEventArgs; m_AllReports.Add(args); if (args.Report.Operation == StackHashAdminOperation.ContextStateChanged) { StackHashContextStateAdminReport contextChangedAdminReport = args.Report as StackHashContextStateAdminReport; if (contextChangedAdminReport.IsActivationAttempt) { m_ActivationAdminEvent.Set(); } else { m_DeactivationAdminEvent.Set(); } } }
// // You can use the following additional attributes as you write your tests: // // Use ClassInitialize to run code before running the first test in the class // [ClassInitialize()] // public static void MyClassInitialize(TestContext testContext) { } // // Use ClassCleanup to run code after all tests in a class have run // [ClassCleanup()] // public static void MyClassCleanup() { } // // Use TestInitialize to run code before running each test // [TestInitialize()] // public void MyTestInitialize() { } // // Use TestCleanup to run code after each test has run // [TestCleanup()] // public void MyTestCleanup() { } // #endregion /// <summary> /// Called by the contoller context objects to report an admin event /// </summary> /// <param name="sender">The task manager reporting the event.</param> /// <param name="e">The event arguments.</param> public void OnAdminReport(Object sender, EventArgs e) { AdminReportEventArgs adminArgs = e as AdminReportEventArgs; if (adminArgs.Report.Operation == StackHashAdminOperation.ErrorIndexMoveCompleted) { m_AdminReports.Add(adminArgs); m_MoveCompletedEvent.Set(); } //else if (adminArgs.Report.Operation == StackHashAdminOperation.ErrorIndexMoveProgress) //{ // m_CopyIndexProgressReports.Add(adminArgs.Report as StackHashCopyIndexProgressAdminReport); // m_MoveProgressEvent.Set(); //} else if (adminArgs.Report.Operation == StackHashAdminOperation.ErrorIndexMoveProgress) { m_MoveAdminReports.Add(adminArgs); } else if (adminArgs.Report.Operation != StackHashAdminOperation.ContextStateChanged) { m_AdminReports.Add(adminArgs); } }
/// <summary> /// Receives progress reports from the WinQualServices when a sync is in progress. /// The data is used to generate a progress report for the client. /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void WinQualSyncEventHandler(Object sender, WinQualProgressEventArgs args) { StackHashSyncProgressAdminReport adminReport = new StackHashSyncProgressAdminReport(); adminReport.ClientData = m_TaskParameters.ClientData; adminReport.ContextId = m_TaskParameters.ContextId; adminReport.LastException = null; adminReport.ResultData = StackHashAsyncOperationResult.Success; adminReport.TotalPages = args.TotalPages; adminReport.CurrentPage = args.CurrentPage; adminReport.IsResync = m_IsResync; adminReport.IsProductsOnlySync = m_TaskParameters.JustSyncProductList; adminReport.Product = args.Product; if (args.Product != null) { adminReport.Description = String.Format(CultureInfo.InvariantCulture, "{0} {1}", args.Product.Product.Name, args.Product.Product.Version); } if (args.File != null) { adminReport.File = (StackHashFile)args.File.Clone(); } if (args.TheEvent != null) { adminReport.TheEvent = (StackHashEvent)args.TheEvent.Clone(); } if (args.Cab != null) { adminReport.Cab = (StackHashCab)args.Cab.Clone(); } bool sendReport = true; switch (args.ProgressType) { case WinQualProgressType.DownloadingProductList: adminReport.Operation = StackHashAdminOperation.WinQualSyncProgressDownloadingProductList; break; case WinQualProgressType.ProductListUpdated: adminReport.Operation = StackHashAdminOperation.WinQualSyncProgressProductListUpdated; break; case WinQualProgressType.DownloadingProductEvents: adminReport.Operation = StackHashAdminOperation.WinQualSyncProgressDownloadingProductEvents; break; case WinQualProgressType.ProductEventsUpdated: adminReport.Operation = StackHashAdminOperation.WinQualSyncProgressProductEventsUpdated; break; case WinQualProgressType.DownloadingProductCabs: adminReport.Operation = StackHashAdminOperation.WinQualSyncProgressDownloadingProductCabs; break; case WinQualProgressType.ProductCabsUpdated: adminReport.Operation = StackHashAdminOperation.WinQualSyncProgressProductCabsUpdated; break; case WinQualProgressType.DownloadingEventPage: adminReport.Operation = StackHashAdminOperation.WinQualSyncProgressDownloadingEventPage; break; case WinQualProgressType.DownloadingCab: adminReport.Operation = StackHashAdminOperation.WinQualSyncProgressDownloadingCab; break; case WinQualProgressType.Complete: adminReport.Operation = StackHashAdminOperation.WinQualSyncCompleted; sendReport = false; break; default: throw new InvalidOperationException("Unexpected progress type"); } if (sendReport) { AdminReportEventArgs adminReportArgs = new AdminReportEventArgs(adminReport, true); if (Reporter.CurrentReporter != null) { Reporter.CurrentReporter.ReportEvent(adminReportArgs); } } }