Exemplo n.º 1
0
        private async Task <IDictionary <string, object> > ConvertResultAsync(Storage storage, EventEntity row, bool includeCollectionName)
        {
            var kv = new Dictionary <string, object>();

            if (includeCollectionName)
            {
                kv.Add("Collection", storage.Table.Name);
            }
            if (row.Id != null)
            {
                kv.Add("Id", row.Id);
            }
            if (row.ProgramId != null)
            {
                kv.Add("ProgramId", row.ProgramId);
            }
            if (row.CarrierId != null)
            {
                kv.Add("CarrierId", row.CarrierId);
            }
            if (row.ServiceName != null)
            {
                kv.Add("ServiceName", row.ServiceName);
            }
            if (row.Description != null)
            {
                kv.Add("Description", row.Description);
            }
            kv.Add("Created", row.Created);
            kv.Add("IdPartitionKey", EventEntity.CreatePartitionKey(row.Id ?? row.ProgramId));
            kv.Add("DatePartitionKey", EventEntity.CreatePartitionKey(row.Created));
            kv.Add("RowKey", row.RowKey);
            if (!_querySettings.DoNotLoadContent)
            {
                await row.LoadContentAsync(storage.Table, storage.BlobContainer);

                if (row.Content != null)
                {
                    object contentData;
                    var    contentText = Utils.Unzip(row.Content);
                    try
                    {
                        contentData = JObject.Parse(contentText);
                    }
                    catch
                    {
                        contentData = contentText;
                    }
                    kv.Add("Content", contentData);
                }
            }
            return(kv);
        }