Пример #1
0
        /// <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);
            }
        }
Пример #2
0
        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);
        }