Exemple #1
0
        protected void PublishMonitoringResult(int numberofAttemptsAfterLastSuccess, ExDateTime firstFailedSyncTimeAfterLastSuccess, ExDateTime lastFailedSyncTime)
        {
            TimeSpan t = lastFailedSyncTime - firstFailedSyncTimeAfterLastSuccess;

            if (numberofAttemptsAfterLastSuccess >= FolderTaskLogger.MinNumberOfFailedSyncAttemptsForAlert && t >= FolderTaskLogger.MinDurationOfSyncFailureForAlert)
            {
                string name      = ExchangeComponent.PublicFolders.Name;
                string component = "PublicFolderMailboxSync";
                string empty     = string.Empty;
                EventNotificationItem eventNotificationItem = new EventNotificationItem(name, component, empty, ResultSeverityLevel.Error);
                eventNotificationItem.StateAttribute1 = this.storeSession.MailboxGuid.ToString();
                eventNotificationItem.StateAttribute2 = this.storeSession.MdbGuid.ToString();
                eventNotificationItem.StateAttribute3 = ((this.storeSession.OrganizationId != null && this.storeSession.OrganizationId.OrganizationalUnit != null) ? this.storeSession.OrganizationId.OrganizationalUnit.Name.ToString() : string.Empty);
                if (this.LastError == null)
                {
                    eventNotificationItem.Message = "No LastError but failing for at least this long: " + FolderTaskLogger.MinDurationOfSyncFailureForAlert;
                }
                else
                {
                    eventNotificationItem.Message = FolderTaskLoggerBase.GetExceptionLogString(this.LastError, FolderTaskLoggerBase.ExceptionLogOption.All);
                }
                try
                {
                    eventNotificationItem.Publish(false);
                }
                catch (UnauthorizedAccessException exception)
                {
                    this.LogEvent(LogEventType.Warning, string.Format("PublishMonitoringResult: Failed with exception {0}", FolderTaskLoggerBase.GetExceptionLogString(exception, FolderTaskLoggerBase.ExceptionLogOption.All)));
                }
                catch (EventLogNotFoundException exception2)
                {
                    this.LogEvent(LogEventType.Warning, string.Format("PublishMonitoringResult: Failed with exception {0}", FolderTaskLoggerBase.GetExceptionLogString(exception2, FolderTaskLoggerBase.ExceptionLogOption.All)));
                }
            }
        }
Exemple #2
0
 public virtual void ReportError(string errorContextMessage, Exception syncException)
 {
     this.LogEvent(LogEventType.Error, string.Format(CultureInfo.InvariantCulture, "[ErrorContext:{0}] {1}", new object[]
     {
         errorContextMessage,
         FolderTaskLoggerBase.GetExceptionLogString(syncException, FolderTaskLoggerBase.ExceptionLogOption.All)
     }));
 }
Exemple #3
0
 public bool TrySave()
 {
     try
     {
         this.LogFinalFoldersStats();
         if (this.LastError == null)
         {
             this.SetSyncMetadataValue("NumberofAttemptsAfterLastSuccess", 0);
             this.SetSyncMetadataValue("FirstFailedSyncTimeAfterLastSuccess", null);
             this.LogEvent(LogEventType.Success, "Diagnostics for monitoring is successfully completed");
             this.SetSyncMetadataValue("LastSuccessfulSyncTime", ExDateTime.UtcNow);
         }
         else
         {
             this.SetSyncMetadataValue("LastSyncFailure", FolderTaskLoggerBase.GetExceptionLogString(this.LastError, FolderTaskLoggerBase.ExceptionLogOption.All));
             int num;
             this.TryGetSyncMetadataValue <int>("NumberofAttemptsAfterLastSuccess", out num);
             num++;
             this.SetSyncMetadataValue("NumberofAttemptsAfterLastSuccess", num);
             this.LogEvent(LogEventType.Error, "Diagnostics for monitoring is failed");
             ExDateTime utcNow = ExDateTime.UtcNow;
             this.SetSyncMetadataValue("LastFailedSyncTime", utcNow);
             ExDateTime exDateTime = default(ExDateTime);
             this.TryGetSyncMetadataValue <ExDateTime>("FirstFailedSyncTimeAfterLastSuccess", out exDateTime);
             if (num == 1 || exDateTime == default(ExDateTime))
             {
                 exDateTime = utcNow;
                 this.SetSyncMetadataValue("FirstFailedSyncTimeAfterLastSuccess", exDateTime);
             }
             this.PublishMonitoringResult(num, exDateTime, utcNow);
         }
         this.gZipLoggingStream.Dispose();
         this.gZipLoggingStream = null;
         this.loggingStream.Dispose();
         this.loggingStream = null;
         this.diagnosticsMetadata.Save();
         this.lastCycleLogMetadata.Save();
         return(true);
     }
     catch (StorageTransientException exception)
     {
         FolderTaskLoggerBase.LogOnServer(exception, this.logComponent, this.logSuffixName);
     }
     catch (StoragePermanentException exception2)
     {
         FolderTaskLoggerBase.LogOnServer(exception2, this.logComponent, this.logSuffixName);
     }
     return(false);
 }
Exemple #4
0
 internal static void LogOnServer(Exception exception, string logComponent, string logSuffixName)
 {
     FolderTaskLoggerBase.LogOnServer(FolderTaskLoggerBase.GetExceptionLogString(exception, FolderTaskLoggerBase.ExceptionLogOption.All), LogEventType.Error, logComponent, logSuffixName, FolderTaskLoggerBase.LogType.Folder, null);
 }