public static IEnumerable <HistoryLogReport> AddMissing(HistoryLogSpecification specification, IList <HistoryLogReport> items) { var n = Convert.ToInt32(Math.Abs(specification.DateRange.To.Date .Subtract(specification.DateRange.From.Date).TotalDays) + 1); if (items.Count == n) { return(items); } var date = specification.DateRange.To.Date; for (int i = 0; i < n; i++, date = date.AddDays(-1)) { if (i >= items.Count || items[i].Timestamp != date) { items.Insert(i, new HistoryLogReport() { Timestamp = date }); } } return(items); }
public static string Specification(HistoryLogSpecification spec) { var buffer = new StringBuilder(Prefix + "s:"); buffer.Append(spec.Username.NullSafe()); buffer.Append(':'); buffer.Append(spec.DateRange.From.ToString("yyyyMMddHHmm", CultureInfo.InvariantCulture)); buffer.Append(':'); buffer.Append(spec.DateRange.To.ToString("yyyyMMddHHmm", CultureInfo.InvariantCulture)); buffer.Append(':'); if (spec.EventId != 0) { buffer.Append(spec.EventId); } buffer.Append(':'); buffer.Append(",".Join(spec.Events.Translate(e => e.ToString(CultureInfo.InvariantCulture)))); buffer.Append(':'); buffer.Append(spec.RelatedTo.NullSafe()); return(buffer.ToString()); }