示例#1
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);
 }
示例#2
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);
 }