private static void WriteEntries(AbstractBlittableJsonTextWriter writer, TimeSeriesEntry[] entries) { writer.WriteStartArray(); for (var i = 0; i < entries.Length; i++) { if (i > 0) { writer.WriteComma(); } writer.WriteStartObject(); { writer.WritePropertyName(nameof(TimeSeriesEntry.Timestamp)); writer.WriteDateTime(entries[i].Timestamp, true); writer.WriteComma(); writer.WritePropertyName(nameof(TimeSeriesEntry.Tag)); writer.WriteString(entries[i].Tag); writer.WriteComma(); writer.WriteArray(nameof(TimeSeriesEntry.Values), entries[i].Values); writer.WriteComma(); writer.WritePropertyName(nameof(TimeSeriesEntry.IsRollup)); writer.WriteBool(entries[i].IsRollup); } writer.WriteEndObject(); } writer.WriteEndArray(); }
private static void WriteRange(AbstractBlittableJsonTextWriter writer, TimeSeriesRangeResult rangeResult, long?totalCount) { writer.WriteStartObject(); { writer.WritePropertyName(nameof(TimeSeriesRangeResult.From)); if (rangeResult.From == DateTime.MinValue) { writer.WriteNull(); } else { writer.WriteDateTime(rangeResult.From, true); } writer.WriteComma(); writer.WritePropertyName(nameof(TimeSeriesRangeResult.To)); if (rangeResult.To == DateTime.MaxValue) { writer.WriteNull(); } else { writer.WriteDateTime(rangeResult.To, true); } writer.WriteComma(); writer.WritePropertyName(nameof(TimeSeriesRangeResult.Entries)); WriteEntries(writer, rangeResult.Entries); if (totalCount.HasValue) { // add total entries count to the response writer.WriteComma(); writer.WritePropertyName(nameof(TimeSeriesRangeResult.TotalResults)); writer.WriteInteger(totalCount.Value); } if (rangeResult.Includes != null) { // add included documents to the response writer.WriteComma(); writer.WritePropertyName(nameof(TimeSeriesRangeResult.Includes)); writer.WriteObject(rangeResult.Includes); } } writer.WriteEndObject(); }
internal static void WritePeriodicBackups(DocumentDatabase db, AbstractBlittableJsonTextWriter writer, JsonOperationContext context, out int count) { count = 0; var first = true; foreach (var periodicBackup in db.PeriodicBackupRunner.PeriodicBackups) { if (first == false) { writer.WriteComma(); } first = false; writer.WriteStartObject(); writer.WritePropertyName("DatabaseName"); writer.WriteString(db.Name); writer.WriteComma(); writer.WritePropertyName(nameof(periodicBackup.Configuration.TaskId)); writer.WriteInteger(periodicBackup.Configuration.TaskId); writer.WriteComma(); writer.WritePropertyName(nameof(periodicBackup.Configuration.Name)); writer.WriteString(periodicBackup.Configuration.Name); writer.WriteComma(); writer.WritePropertyName(nameof(periodicBackup.Configuration.FullBackupFrequency)); writer.WriteString(periodicBackup.Configuration.FullBackupFrequency); writer.WriteComma(); writer.WritePropertyName(nameof(periodicBackup.Configuration.IncrementalBackupFrequency)); writer.WriteString(periodicBackup.Configuration.IncrementalBackupFrequency); writer.WriteComma(); writer.WritePropertyName(nameof(NextBackup)); using (var nextBackup = context.ReadObject(periodicBackup.GetNextBackup().ToJson(), "nextBackup")) writer.WriteObject(nextBackup); writer.WriteComma(); writer.WritePropertyName(nameof(PeriodicBackup.BackupTimer.CreatedAt)); var createdAt = periodicBackup.GetCreatedAt(); if (createdAt.HasValue == false) { writer.WriteNull(); } else { writer.WriteDateTime(createdAt.Value, isUtc: true); } writer.WriteComma(); writer.WritePropertyName(nameof(PeriodicBackup.Disposed)); writer.WriteBool(periodicBackup.Disposed); writer.WriteEndObject(); count++; } }