예제 #1
0
파일: FileBackup.cs 프로젝트: radtek/Bummer
 /// <summary>
 ///
 /// </summary>
 /// <param name="file"></param>
 /// <returns></returns>
 private bool Include(FileInfo file)
 {
     if (config.BackupType == BackupTypes.All)
     {
         return(IncludeFiletype(file));
     }
     if (!IncludeFiletype(file))
     {
         return(false);
     }
     CMD.ClearParameters();
     CMD.CommandText = "SELECT ModifiedDate FROM BackupFiles WHERE Filename = @Filename";
     CMD.AddWithValue("@Filename", file.FullName);
     CMD.ExecuteReader();
     if (CMD.Read())
     {
         DateTime md = CMD.GetDateTime(0);
         if (file.LastWriteTime > md)
         {
             CMD.CommandText = "UPDATE BackupFiles SET ModifiedDate = @ModifiedDate WHERE Filename = @Filename";
             CMD.AddWithValue("@ModifiedDate", file.LastWriteTime);
             CMD.ExecuteNonQuery();
             return(true);
         }
         return(false);
     }
     CMD.ClearParameters();
     CMD.CommandText = "INSERT INTO BackupFiles( Filename, ModifiedDate ) VALUES( @Filename, @ModifiedDate )";
     CMD.AddWithValue("@Filename", file.FullName);
     CMD.AddWithValue("@ModifiedDate", file.LastWriteTime);
     CMD.ExecuteNonQuery();
     return(true);
 }