コード例 #1
0
        private async Task <Chart[]> GetChartData()
        {
            var commentCount = await _cosmosDBHelper.RetrieveEntityUsingPointQueryAsync(_table, "demo", "CommentCount");

            if (commentCount == null)
            {
                commentCount = new DataEntity("demo", "CommentCount")
                {
                    IntValue = 0
                };
            }

            var noticeCount = await _cosmosDBHelper.RetrieveEntityUsingPointQueryAsync(_table, "demo", "NoticeCount");

            if (noticeCount == null)
            {
                noticeCount = new DataEntity("demo", "NoticeCount")
                {
                    IntValue = 0
                };
            }

            var audienceCount = await _cosmosDBHelper.RetrieveEntityUsingPointQueryAsync(_table, "demo", "AudienceCount");

            if (audienceCount == null)
            {
                audienceCount = new DataEntity("demo", "AudienceCount")
                {
                    StringValue = ""
                };
            }

            return(new Chart[] {
                new Chart {
                    Data = new int[] { commentCount.IntValue }, Label = "Comments"
                },
                new Chart {
                    Data = new int[] { noticeCount.IntValue }, Label = "Notices"
                },
                new Chart {
                    Data = new int[] { audienceCount.IntValue }, Label = "Users"
                },
            });
        }
コード例 #2
0
        public async Task <DataEntity> GetNotice(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequest req,
            [SignalR(HubName = "board")] IAsyncCollector <SignalRMessage> signalRMessages)
        {
            if (req == null || signalRMessages == null)
            {
                return(await Task.FromResult <DataEntity>(null));
            }

            var audienceCount = new DataEntity("demo", "AudienceCount")
            {
                IntValue = 0
            };
            var data = await _cosmosDBHelper.RetrieveEntityUsingPointQueryAsync(_table, "demo", "AudienceCount");

            if (data != null)
            {
                audienceCount.IntValue  = data.IntValue + 1;
                audienceCount.Timestamp = data.Timestamp;
            }

            return(await _cosmosDBHelper.InsertOrMergeEntityAsync(_table, audienceCount));
        }