/// <summary> /// Update a record /// </summary> /// <param name="aUserName">Domain/User</param> /// <param name="aMachineName">Yeah</param> /// <param name="aEntryType">Kind of entry to update</param> /// <param name="aModificationDate">Entry time</param> /// <param name="aContent">XML to send</param> public static void Update(string aUserName, string aMachineName, EntryKind aEntryType, DateTime aModificationDate, string aContent) { SQLHistoryDataSetTableAdapters.HistoryTableAdapter TableAdapter = new SQLHistoryDataSetTableAdapters.HistoryTableAdapter(); SQLHistoryDataSet.HistoryDataTable Table = TableAdapter.GetDataBy(aUserName, aMachineName, aEntryType.ToString(), aModificationDate); HistoryRow Row = null; if (Table.Count == 0) Row = Table.AddHistoryRow(aUserName, aMachineName, aEntryType.ToString(), aModificationDate, aContent); else Row = ((HistoryRow)Table.Rows[0]); Row.XmlContent = aContent; TableAdapter.Update(Table); //Console.WriteLine(Row.EntryType + ":" + Row.XmlContent); }
/// <summary> /// Get the time that the last update was done for this user/machine/entryType /// </summary> /// <param name="aEntryKind">Kind to search for</param> /// <returns>Last time or Time.Min if never</returns> public static DateTime Latest(EntryKind aEntryKind) { SQLHistoryDataSetTableAdapters.HistoryTableAdapter TableAdapter = new SQLHistoryDataSetTableAdapters.HistoryTableAdapter(); DateTime? re = TableAdapter.LatestQuery(Duplicati.Scheduler.Utility.User.UserName, Environment.MachineName, aEntryKind.ToString()); if (re == null) return DateTime.MinValue; return (DateTime)re; }