/// <summary> /// Called by the proxy when the server reports an admin event. /// </summary> /// <param name="adminReport">The report</param> public void AdminProgressEvent(StackHashAdminReport adminReport) { Debug.Assert(adminReport != null); if (AdminReport != null) { AdminReport(this, new AdminReportEventArgs(adminReport)); } }
/// <summary> /// Checks to see if the specified admin report should be emailed to interested users. /// If so, the email is sent to those registered to receive it. /// </summary> /// <param name="report">Admin report to check.</param> public void SendAdminEmails(StackHashAdminReport report) { if (m_Disposed) { throw new ObjectDisposedException("MailManager"); } if (report == null) { throw new ArgumentNullException("report"); } Monitor.Enter(this); try { // Only send an email if the operation is of interest. if (this.m_MailSettings.OperationsToReport.Contains(report.Operation)) { // Don't report sync started if a retry. if ((report.Operation == StackHashAdminOperation.WinQualSyncStarted) && report.IsRetry) { return; } // Only report retry sync completes if succeeded. if ((report.Operation == StackHashAdminOperation.WinQualSyncCompleted) && report.IsRetry && (report.ServiceErrorCode != StackHashServiceErrorCode.NoError)) { return; } // Send an email as specified. String subject = "StackHash report: " + StackHashAdminOperationCollection.GetFriendlyName(report.Operation); StringBuilder message = new StringBuilder(); message.AppendLine("Service Local Time: " + DateTime.Now.ToString()); message.AppendLine("Service Profile: " + m_ProfileName); message.Append(report.ToString()); if (!String.IsNullOrEmpty(report.Description)) { message.AppendLine(report.Description); } message.AppendLine("---"); message.AppendLine("www.stackhash.com"); sendEmails(subject, message.ToString()); } } finally { Monitor.Exit(this); } }
public void BaseAdminReport() { StackHashAdminReport adminReport = new StackHashAdminReport(); adminReport.Operation = StackHashAdminOperation.WinQualSyncStarted; adminReport.ServiceErrorCode = StackHashServiceErrorCode.WinQualLogOnFailed; adminReport.ClientData = new StackHashClientData(Guid.NewGuid(), "ClientName", 12); adminReport.LastException = "Exception text"; String text = adminReport.ToString(); Assert.AreEqual("Operation: Synchronize with WinQual on-line has started\r\nResult: WinQualLogOnFailed\r\nInitiator: ClientName\r\nError detail: Exception text\r\n", text); }
/// <summary> /// Make sure notification only comes back to the one client. /// Username and password are incorrect so should just fail to login. /// </summary> public void adminReportShouldBeSentToIndividualClient(ErrorIndexType indexType) { m_Utils.RegisterForNotifications(true, Guid.NewGuid()); m_Utils.RegisterForNotifications(true, m_Utils.ApplicationGuid); m_Utils.RegisterForNotifications(true, Guid.NewGuid()); m_Utils.CreateAndSetNewContext(indexType); m_Utils.ActivateContext(0); StackHashTestIndexData indexData = new StackHashTestIndexData(); indexData.NumberOfProducts = 1; indexData.NumberOfFiles = 1; indexData.NumberOfEvents = 1; indexData.NumberOfCabs = 1; indexData.NumberOfEventInfos = 1; m_Utils.CreateTestIndex(0, indexData); try { StackHashProductInfoCollection products = m_Utils.GetProducts(0).Products; StackHashFileCollection files = m_Utils.GetFiles(0, products[0].Product).Files; StackHashEventPackageCollection events = m_Utils.GetProductEventPackages(0, products[0].Product).EventPackages; StackHashCabPackageCollection cabs = events[0].Cabs; DownloadCabResponse resp = m_Utils.DownloadCab(0, products[0].Product, files[0], events[0].EventData, events[0].Cabs[0].Cab, 30000); StackHashAdminReport adminReport = m_Utils.DownloadCabAdminReport; Assert.AreNotEqual(null, adminReport); Assert.AreEqual(m_Utils.LastClientData.ApplicationGuid, adminReport.ClientData.ApplicationGuid); Assert.AreEqual(m_Utils.LastClientData.ClientId, adminReport.ClientData.ClientId); Assert.AreEqual(m_Utils.LastClientData.ClientName, adminReport.ClientData.ClientName); Assert.AreEqual(m_Utils.LastClientData.ClientRequestId, adminReport.ClientData.ClientRequestId); Assert.AreEqual(0, adminReport.ContextId); Assert.AreNotEqual(null, adminReport.LastException); Assert.AreEqual(true, adminReport.LastException.Contains("username and password")); Assert.AreEqual(StackHashAdminOperation.DownloadCabCompleted, adminReport.Operation); Assert.AreEqual(StackHashAsyncOperationResult.Failed, adminReport.ResultData); // Should receive 3 admin register + download started + download completed. Assert.AreEqual(5, m_Utils.AllReports.Count); } finally { m_Utils.DeactivateContext(0); m_Utils.DeleteIndex(0); } }
/// <summary> /// Parameters pass to the AdminReport delegate. /// </summary> /// <param name="report">The report</param> public AdminReportEventArgs(StackHashAdminReport report) { _report = report; }