/// <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); }
public bool ExecuteCMD()//Execute particular action { try { OpenConnection(); CMD.ExecuteNonQuery(); CloseConnection(); return(true); } catch (Exception ex) { string message = ex.Message; CMD.Dispose(); CloseConnection(); } return(false); }