Beispiel #1
0
        private static void MoveTempOldFileToBackupDir(IReplayConfiguration config, string tempOldFile)
        {
            string currentDateString = FileOperations.GetCurrentDateString();
            string text  = Path.Combine(config.E00LogBackupPath, currentDateString + "E00OutOfDate");
            string text2 = EseHelper.MakeLogFilePath(config, 0L, text);

            FileOperations.CreateDirectoryIfNeeded(text);
            LastLogReplacer.Tracer.TraceDebug <string, string, string>(0L, "MoveTempOldFileToBackupDir(): '{0}': Moving temporary old file '{1}' to backup file '{2}'", config.DisplayName, tempOldFile, text2);
            File.Move(tempOldFile, text2);
        }
        // Token: 0x06000A21 RID: 2593 RVA: 0x0002F2C0 File Offset: 0x0002D4C0
        public static void MoveLogFiles(ReplayConfiguration config, FileState fileState, ISetBroken setBroken, long corruptLogGen)
        {
            string    text = Path.Combine(config.E00LogBackupPath, "SkippedLogs");
            Exception ex   = DirectoryOperations.TryCreateDirectory(text);

            if (ex != null)
            {
                setBroken.SetBroken(FailureTag.Configuration, ReplayEventLogConstants.Tuple_FailedToCreateDirectory, ex, new string[]
                {
                    text,
                    ex.ToString()
                });
                return;
            }
            string currentDateString = FileOperations.GetCurrentDateString();
            string text2             = Path.Combine(text, currentDateString);

            ex = DirectoryOperations.TryCreateDirectory(text2);
            if (ex != null)
            {
                setBroken.SetBroken(FailureTag.Configuration, ReplayEventLogConstants.Tuple_FailedToCreateDirectory, ex, new string[]
                {
                    text2,
                    ex.ToString()
                });
                return;
            }
            string destinationLogPath = config.DestinationLogPath;
            string text3 = string.Empty;
            string path  = string.Empty;

            try
            {
                ReplayEventLogConstants.Tuple_MovingFilesToRestartLogStream.LogEvent(null, new object[]
                {
                    config.DatabaseName,
                    EseHelper.MakeLogfileName(config.LogFilePrefix, config.LogFileSuffix, corruptLogGen),
                    text2
                });
                foreach (string text4 in Directory.GetFiles(destinationLogPath, "*." + config.LogExtension))
                {
                    text3 = text4;
                    path  = Path.GetFileName(text4);
                    long logfileGenerationFromFilePath = EseHelper.GetLogfileGenerationFromFilePath(text4, config.LogFilePrefix);
                    if (logfileGenerationFromFilePath >= fileState.LowestGenerationRequired)
                    {
                        ExTraceGlobals.ReplicaInstanceTracer.TraceError <string>(0L, "MoveLogFiles(): Cannot move logfile '{0}' because it is required by the database.", text4);
                    }
                    else
                    {
                        File.Move(text4, Path.Combine(text2, path));
                    }
                }
                foreach (string text5 in Directory.GetFiles(destinationLogPath, "*.jsl"))
                {
                    text3 = text5;
                    path  = Path.GetFileName(text5);
                    File.Move(text5, Path.Combine(text2, path));
                }
                ExTraceGlobals.ReplicaInstanceTracer.TraceError <string>(0L, "Moved log files successfully from '{0}'", config.DestinationLogPath);
            }
            catch (IOException ex2)
            {
                ExTraceGlobals.ReplicaInstanceTracer.TraceError <string, string, IOException>(0L, "Moving file '{0}' to '{1}' failed with exception: {2}", text3, text2, ex2);
                setBroken.SetBroken(ReplicaInstance.IOExceptionToFailureTag(ex2), ReplayEventLogConstants.Tuple_CouldNotDeleteLogFile, ex2, new string[]
                {
                    text3,
                    ex2.ToString()
                });
            }
            catch (UnauthorizedAccessException ex3)
            {
                ExTraceGlobals.ReplicaInstanceTracer.TraceError <string, string, UnauthorizedAccessException>(0L, "Moving file '{0}' to '{1}' failed with exception: {2}", text3, text2, ex3);
                setBroken.SetBroken(FailureTag.AlertOnly, ReplayEventLogConstants.Tuple_CouldNotDeleteLogFile, ex3, new string[]
                {
                    text3,
                    ex3.ToString()
                });
            }
        }