예제 #1
0
        public void FillWithChildren()
        {
            try
            {
                var feedOffers = _client.ReadOffersFeedAsync().Result;

                foreach (var sp in feedOffers)
                {
                    var node = new ResourceNode(_client, sp, ResourceType.Offer);
                    Nodes.Add(node);
                }
                Program.GetMain().SetResponseHeaders(feedOffers.ResponseHeaders);
            }
            catch (AggregateException e)
            {
                Program.GetMain().SetResultInBrowser(null, e.InnerException.ToString(), true);
            }
            catch (Exception e)
            {
                Program.GetMain().SetResultInBrowser(null, e.ToString(), true);
            }
        }
예제 #2
0
        public void FillWithChildren()
        {
            try
            {
                var document   = ((Document)Tag);
                var collection = ((DocumentCollection)Parent.Tag);

                var options = new FeedOptions();
                if (collection.PartitionKey != null && collection.PartitionKey.Paths.Count > 0)
                {
                    options.PartitionKey = new PartitionKey(DocumentAnalyzer.ExtractPartitionKeyValue(document, collection.PartitionKey));
                }

                FeedResponse <Attachment> attachments;
                using (PerfStatus.Start("ReadAttachmentFeed"))
                {
                    attachments = _client.ReadAttachmentFeedAsync(document.GetLink(_client), options).Result;
                }

                foreach (var attachment in attachments)
                {
                    var node = new ResourceNode(_client, attachment, ResourceType.Attachment);
                    Nodes.Add(node);
                }

                Program.GetMain().SetResponseHeaders(attachments.ResponseHeaders);
            }
            catch (AggregateException e)
            {
                SetResultInBrowser(null, e.InnerException.ToString(), true);
            }
            catch (Exception e)
            {
                SetResultInBrowser(null, e.ToString(), true);
            }
        }
        public void FillWithChildren()
        {
            try
            {
                List<dynamic> docs = new List<dynamic>();
                NameValueCollection responseHeaders = null;

                using (PerfStatus.Start("ReadDocumentFeed"))
                {
                    ResourceFeedReader<Document> feedReader = this.client.CreateDocumentFeedReader(((DocumentCollection)this.Tag).GetLink(this.client), new FeedOptions { EnableCrossPartitionQuery = true });
                    while (feedReader.HasMoreResults && docs.Count() < 100)
                    {
                        FeedResponse<Document> response = feedReader.ExecuteNextAsync().Result;
                        docs.AddRange(response);

                        responseHeaders = response.ResponseHeaders;
                    }
                }

                foreach (var doc in docs)
                {
                    ResourceNode node = new ResourceNode(client, doc, ResourceType.Document, ((DocumentCollection)this.Tag).PartitionKey);
                    this.Nodes.Add(node);
                }

                Program.GetMain().SetResponseHeaders(responseHeaders);
            }
            catch (AggregateException e)
            {
                Program.GetMain().SetResultInBrowser(null, e.InnerException.ToString(), true);
            }
            catch (Exception e)
            {
                Program.GetMain().SetResultInBrowser(null, e.ToString(), true);
            }
        }
        public void FillWithChildren()
        {
            try
            {
                FeedResponse<Offer> feedOffers = this.client.ReadOffersFeedAsync().Result;

                foreach (var sp in feedOffers)
                {
                    ResourceNode node = new ResourceNode(client, sp, ResourceType.Offer);
                    this.Nodes.Add(node);
                }
                Program.GetMain().SetResponseHeaders(feedOffers.ResponseHeaders);

            }
            catch (AggregateException e)
            {
                Program.GetMain().SetResultInBrowser(null, e.InnerException.ToString(), true);
            }
            catch (Exception e)
            {
                Program.GetMain().SetResultInBrowser(null, e.ToString(), true);
            }
        }
        public void FillWithChildren()
        {
            try
            {
                FeedResponse<Conflict> feedConflicts;
                using (PerfStatus.Start("ReadConflictsFeed"))
                {
                    feedConflicts = this.client.ReadConflictFeedAsync((this.Parent.Tag as DocumentCollection).GetLink(this.client)).Result;
                }

                foreach (var sp in feedConflicts)
                {
                    ResourceNode node = new ResourceNode(client, sp, ResourceType.Conflict);
                    this.Nodes.Add(node);
                }
                Program.GetMain().SetResponseHeaders(feedConflicts.ResponseHeaders);

            }
            catch (AggregateException e)
            {
                Program.GetMain().SetResultInBrowser(null, e.InnerException.ToString(), true);
            }
            catch (Exception e)
            {
                Program.GetMain().SetResultInBrowser(null, e.ToString(), true);
            }

        }
        public void FillWithChildren()
        {
            try
            {
                FeedResponse<Permission> sps;
                using (PerfStatus.Start("ReadPermission"))
                {
                    sps = this.client.ReadPermissionFeedAsync((this.Parent.Tag as User).GetLink(this.client)).Result;
                }

                foreach (var sp in sps)
                {
                    ResourceNode node = new ResourceNode(client, sp, ResourceType.Permission);
                    this.Nodes.Add(node);
                }
                Program.GetMain().SetResponseHeaders(sps.ResponseHeaders);

            }
            catch (AggregateException e)
            {
                Program.GetMain().SetResultInBrowser(null, e.InnerException.ToString(), true);
            }
            catch (Exception e)
            {
                Program.GetMain().SetResultInBrowser(null, e.ToString(), true);
            }

        }
        public void FillWithChildren()
        {
            try
            {
                DocumentCollectionNode collnode = (DocumentCollectionNode)this.Parent;
                FeedResponse<Trigger> sps;
                using (PerfStatus.Start("ReadTriggerFeed"))
                {
                    sps = this.client.ReadTriggerFeedAsync((collnode.Tag as DocumentCollection).GetLink(this.client)).Result;
                }

                foreach (var sp in sps)
                {
                    ResourceNode node = new ResourceNode(client, sp, ResourceType.Trigger);
                    this.Nodes.Add(node);
                }
                Program.GetMain().SetResponseHeaders(sps.ResponseHeaders);

            }
            catch (AggregateException e)
            {
                Program.GetMain().SetResultInBrowser(null, e.InnerException.ToString(), true);
            }
            catch (Exception e)
            {
                Program.GetMain().SetResultInBrowser(null, e.ToString(), true);
            }

        }
        public void FillWithChildren()
        {
            try
            {
                Document document = ((Document)this.Tag);
                DocumentCollection collection = ((DocumentCollection)this.Parent.Tag);

                FeedOptions options = new FeedOptions();
                if (collection.PartitionKey != null && collection.PartitionKey.Paths.Count > 0)
                {
                    options.PartitionKey = new PartitionKey(DocumentAnalyzer.ExtractPartitionKeyValue(document, collection.PartitionKey));
                }

                FeedResponse<Attachment> attachments;
                using (PerfStatus.Start("ReadAttachmentFeed"))
                {
                    attachments = this.client.ReadAttachmentFeedAsync(document.GetLink(this.client), options).Result;
                }

                foreach (var attachment in attachments)
                {
                    ResourceNode node = new ResourceNode(client, attachment, ResourceType.Attachment);
                    this.Nodes.Add(node);
                }

                Program.GetMain().SetResponseHeaders(attachments.ResponseHeaders);
            }
            catch (AggregateException e)
            {
                Program.GetMain().SetResultInBrowser(null, e.InnerException.ToString(), true);
            }
            catch (Exception e)
            {
                Program.GetMain().SetResultInBrowser(null, e.ToString(), true);
            }
        }
예제 #9
0
        public void FillWithChildren()
        {
            try
            {
                var docs            = new List <dynamic>();
                var responseHeaders = new List <NameValueCollection>();
                var dc   = (DocumentCollection)Tag;
                var dcId = dc.Id;

                using (PerfStatus.Start("ReadDocumentFeed"))
                {
                    var filteredDocumentId = Program.GetMain().FilteredDocumentId;
                    var feedReader         = CreateDocumentQuery(
                        string.IsNullOrEmpty(filteredDocumentId)
                            ? "Select * from c"
                            : $"Select * from c Where c.id = \"{filteredDocumentId}\"", new FeedOptions {
                        EnableCrossPartitionQuery = true
                    });

                    while (feedReader.HasMoreResults && docs.Count() < Settings.Default.DocumentTreeCount)
                    {
                        var response = feedReader.ExecuteNextAsync <Document>().Result;
                        docs.AddRange(response);
                        responseHeaders.Add(response.ResponseHeaders);
                    }
                }

                var host = _client.ServiceEndpoint.Host;

                string customDocumentDisplayIdentifier;
                string sortField;
                bool   reverseSort;
                var    useCustom = _customDocumentListDisplayManager.GetCustomDocumentDisplayIdentifier(docs, host, dc.Id, _databaseId, out customDocumentDisplayIdentifier, out sortField, out reverseSort);

                DocumentHelper.SortDocuments(useCustom, docs, sortField, reverseSort);

                foreach (var doc in docs)
                {
                    if (useCustom)
                    {
                        var displayText = _customDocumentListDisplayManager.GetDisplayText(true, doc, customDocumentDisplayIdentifier);
                        var node        = new ResourceNode(_client, doc, ResourceType.Document, dc.PartitionKey, displayText, dataBaseId: _databaseId, documentCollectionId: dcId);
                        Nodes.Add(node);
                    }
                    else
                    {
                        var node = new ResourceNode(_client, doc, ResourceType.Document, dc.PartitionKey, dataBaseId: _databaseId, documentCollectionId: dcId);
                        Nodes.Add(node);
                    }
                }

                Program.GetMain().SetResponseHeaders(responseHeaders);
            }
            catch (AggregateException e)
            {
                Program.GetMain().SetResultInBrowser(null, e.InnerException.ToString(), true);
            }
            catch (Exception e)
            {
                Program.GetMain().SetResultInBrowser(null, e.ToString(), true);
            }
        }