Exemple #1
0
 public static void FileArchiver(FileArchive archive)
 {
     try
     {
         string[] dirs = Directory.GetFiles(archive.FolderPath);
         foreach (string dir in dirs)
         {
             //console.writeLine(dir);
             //console.writeLine(DateTime.Now.ToString("yyyyMMdd"));
             //Directory.Move(@"C:\Test\test", @"c:\test\archive\test" );
             //console.writeLine(archive.FolderPath + @"\" + archive.ArchiveName + @"\" + DateTime.Now.ToString("yyyyMMdd") + @"\" + dir.Replace(archive.FolderPath + @"\", ""));
             string[] FolderCheck = Directory.GetDirectories(archive.FolderPath + @"\" + archive.ArchiveName + @"\");
             FolderValidator(archive.FolderPath + @"\" + archive.ArchiveName + @"\" + DateTime.Now.ToString("yyyyMMdd"), FolderCheck);
             //console.writeLine("Moving " + dir + " to " + archive.FolderPath + @"\" + archive.ArchiveName + @"\" + DateTime.Now.ToString("yyyyMMdd") + @"\" + dir.Replace(archive.FolderPath + @"\", ""));
             Directory.Move(dir, archive.FolderPath + @"\" + archive.ArchiveName + @"\" + DateTime.Now.ToString("yyyyMMdd") + @"\" + dir.Replace(archive.FolderPath + @"\", ""));
             ArchiveLog log = new ArchiveLog();
             log.OriginalPath    = dir;
             log.DestinationPath = archive.FolderPath + @"\" + archive.ArchiveName + @"\" + DateTime.Now.ToString("yyyyMMdd") + @"\" + dir.Replace(archive.FolderPath + @"\", "");
             log.ArchiveDate     = DateTime.Now;
             log.FileArchiveId   = archive.FileArchiveId;
             WriteLog(log);
             //console.writeLine(dir);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("The process failed: {0}", e.ToString());
     }
 }
Exemple #2
0
 public static void WriteLog(ArchiveLog log)
 {
     try
     {
         using (var db = new FileArchiveContext())
         {
             db.Add(log);
             db.SaveChanges();
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("The process failed: {0}", e.ToString());
     }
 }