Пример #1
0
        private static List <BackupDetail> ServerBackupDetails(BackupDirectory backupDirectory)
        {
            string serverDir = Path.Combine(ServerDir(), backupDirectory.ToString());

            List <BackupDetail> serverBackupDetails = new List <BackupDetail>();

            foreach (string file in Directory.GetFiles(serverDir))
            {
                var fileBackupDetail = new BackupDetail();
                fileBackupDetail.SavedName       = Path.GetFileName(file);
                fileBackupDetail.ActualName      = fileBackupDetail.SavedName;
                fileBackupDetail.FileSystemType  = FileSystemType.File;
                fileBackupDetail.BackupDirectory = backupDirectory;
                fileBackupDetail.MD5CheckSum     = CalculateMD5(file);
                serverBackupDetails.Add(fileBackupDetail);
            }
            foreach (string dir in Directory.GetDirectories(serverDir))
            {
                var directoryBackupDetail = new BackupDetail();
                directoryBackupDetail.SavedName       = Path.GetFileName(dir);
                directoryBackupDetail.ActualName      = directoryBackupDetail.SavedName;
                directoryBackupDetail.FileSystemType  = FileSystemType.Directory;
                directoryBackupDetail.BackupDirectory = backupDirectory;
                serverBackupDetails.Add(directoryBackupDetail);
            }

            return(serverBackupDetails);
        }
Пример #2
0
        public static void UpdateSingle(this List <BackupDetail> list, BackupDetail newBackupDetail)
        {
            var oldBackupDetail = list.Where(sbd => sbd.ID == newBackupDetail.ID).FirstOrDefault();

            if (oldBackupDetail != null)
            {
                var index = list.IndexOf(oldBackupDetail);
                list[index] = newBackupDetail;
            }
        }