Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        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++;
            }
        }
        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();
        }
Ejemplo n.º 4
0
        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();
        }