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(); }
protected void PersistGroupByFields(JsonOperationContext context, AbstractBlittableJsonTextWriter writer) { writer.WritePropertyName((nameof(GroupByFields))); writer.WriteStartArray(); var first = true; foreach (var field in GroupByFields.Values) { if (first == false) { writer.WriteComma(); } writer.WriteStartObject(); writer.WritePropertyName(nameof(field.Name)); writer.WriteString(field.Name); writer.WriteComma(); writer.WritePropertyName(nameof(field.Indexing)); writer.WriteString(field.Indexing.ToString()); writer.WriteComma(); writer.WritePropertyName(nameof(field.GroupByArrayBehavior)); writer.WriteString(field.GroupByArrayBehavior.ToString()); writer.WriteEndObject(); first = false; } writer.WriteEndArray(); }
internal void WriteTo(AbstractBlittableJsonTextWriter writer) { writer.WriteStartObject(); writer.WritePropertyName(nameof(AssemblyName)); writer.WriteString(AssemblyName); writer.WriteComma(); writer.WritePropertyName(nameof(AssemblyPath)); writer.WriteString(AssemblyPath); writer.WriteComma(); writer.WritePropertyName(nameof(PackageName)); writer.WriteString(PackageName); writer.WriteComma(); writer.WritePropertyName(nameof(PackageVersion)); writer.WriteString(PackageVersion); writer.WriteComma(); writer.WritePropertyName(nameof(PackageSourceUrl)); writer.WriteString(PackageSourceUrl); writer.WriteComma(); writer.WriteArray(nameof(Usings), Usings); writer.WriteEndObject(); }
protected override void PersistMapFields(JsonOperationContext context, AbstractBlittableJsonTextWriter writer) { writer.WritePropertyName(nameof(MapFields)); writer.WriteStartArray(); var first = true; foreach (var field in MapFields.Values.Select(x => x.As <IndexField>())) { if (first == false) { writer.WriteComma(); } writer.WriteStartObject(); writer.WritePropertyName(nameof(field.Name)); writer.WriteString(field.Name); writer.WriteComma(); writer.WritePropertyName(nameof(field.Indexing)); writer.WriteString(field.Indexing.ToString()); writer.WriteEndObject(); first = false; } writer.WriteEndArray(); }
protected override void PersistMapFields(JsonOperationContext context, AbstractBlittableJsonTextWriter writer) { writer.WritePropertyName(nameof(MapFields)); writer.WriteStartArray(); var first = true; foreach (var field in MapFields.Values.Select(x => x.As <AutoIndexField>())) { if (first == false) { writer.WriteComma(); } writer.WriteStartObject(); writer.WritePropertyName(nameof(field.Name)); writer.WriteString(field.Name); writer.WriteComma(); writer.WritePropertyName(nameof(field.Indexing)); writer.WriteString(field.Indexing.ToString()); writer.WriteComma(); writer.WritePropertyName(nameof(field.Aggregation)); writer.WriteInteger((int)field.Aggregation); writer.WriteComma(); writer.WritePropertyName(nameof(field.Spatial)); if (field.Spatial == null) { writer.WriteNull(); } else { writer.WriteObject(DocumentConventions.DefaultForServer.Serialization.DefaultConverter.ToBlittable(field.Spatial, context)); } writer.WriteComma(); writer.WritePropertyName(nameof(field.HasSuggestions)); writer.WriteBool(field.HasSuggestions); writer.WriteEndObject(); first = false; } 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 WriteEndOfTimers(AbstractBlittableJsonTextWriter writer, int count) { writer.WriteEndArray(); writer.WriteComma(); writer.WritePropertyName("TimersCount"); writer.WriteInteger(count); writer.WriteEndObject(); }
protected override void PersistFields(JsonOperationContext context, AbstractBlittableJsonTextWriter writer) { PersistMapFields(context, writer); writer.WriteComma(); PersistGroupByFields(context, writer); }
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++; } }
public void Write(JsonOperationContext context, AbstractBlittableJsonTextWriter writer) { writer.WriteStartObject(); writer.WritePropertyName(nameof(Id)); writer.WriteString(Id); writer.WriteComma(); writer.WritePropertyName(nameof(Description)); writer.WriteString(Description); writer.WriteComma(); writer.WritePropertyName(nameof(Type)); writer.WriteString(Type.ToString()); writer.WriteComma(); writer.WriteArray(context, nameof(Performance), Performance, (w, c, p) => { var djv = (DynamicJsonValue)TypeConverter.ToBlittableSupportedType(p); w.WriteObject(c.ReadObject(djv, "incoming/replication/performance")); }); writer.WriteEndObject(); }
public void Persist(JsonOperationContext context, AbstractBlittableJsonTextWriter writer) { writer.WriteStartObject(); writer.WritePropertyName(nameof(Name)); writer.WriteString(Name); writer.WriteComma(); writer.WritePropertyName(nameof(Version)); writer.WriteInteger(Version); writer.WriteComma(); writer.WritePropertyName(nameof(Collections)); writer.WriteStartArray(); var isFirst = true; foreach (var collection in Collections) { if (isFirst == false) { writer.WriteComma(); } isFirst = false; writer.WriteString(collection); } writer.WriteEndArray(); writer.WriteComma(); writer.WritePropertyName(nameof(LockMode)); writer.WriteInteger((int)LockMode); writer.WriteComma(); writer.WritePropertyName(nameof(Priority)); writer.WriteInteger((int)Priority); writer.WriteComma(); writer.WritePropertyName(nameof(State)); writer.WriteInteger((int)State); writer.WriteComma(); PersistFields(context, writer); writer.WriteEndObject(); }
public static void WriteIndexQuery(this AbstractBlittableJsonTextWriter writer, DocumentConventions conventions, JsonOperationContext context, IndexQuery query) { writer.WriteStartObject(); writer.WritePropertyName(nameof(query.Query)); writer.WriteString(query.Query); writer.WriteComma(); #pragma warning disable 618 if (query.PageSizeSet && query.PageSize >= 0) { writer.WritePropertyName(nameof(query.PageSize)); writer.WriteInteger(query.PageSize); writer.WriteComma(); } #pragma warning restore 618 if (query.WaitForNonStaleResults) { writer.WritePropertyName(nameof(query.WaitForNonStaleResults)); writer.WriteBool(query.WaitForNonStaleResults); writer.WriteComma(); } #pragma warning disable 618 if (query.Start > 0) { writer.WritePropertyName(nameof(query.Start)); writer.WriteInteger(query.Start); writer.WriteComma(); } #pragma warning restore 618 if (query.WaitForNonStaleResultsTimeout.HasValue) { writer.WritePropertyName(nameof(query.WaitForNonStaleResultsTimeout)); writer.WriteString(query.WaitForNonStaleResultsTimeout.Value.ToInvariantString()); writer.WriteComma(); } if (query.DisableCaching) { writer.WritePropertyName(nameof(query.DisableCaching)); writer.WriteBool(query.DisableCaching); writer.WriteComma(); } if (query.SkipDuplicateChecking) { writer.WritePropertyName(nameof(query.SkipDuplicateChecking)); writer.WriteBool(query.SkipDuplicateChecking); writer.WriteComma(); } writer.WritePropertyName(nameof(query.QueryParameters)); if (query.QueryParameters != null) { writer.WriteObject(conventions.Serialization.DefaultConverter.ToBlittable(query.QueryParameters, context)); } else { writer.WriteNull(); } if (query.ProjectionBehavior.HasValue && query.ProjectionBehavior.Value != ProjectionBehavior.Default) { writer.WriteComma(); writer.WritePropertyName(nameof(query.ProjectionBehavior)); writer.WriteString(query.ProjectionBehavior.ToString()); } writer.WriteEndObject(); }