コード例 #1
0
        public HttpResponseMessage Post([FromBody] JObject loadTime)
        {
            var clientSettings = new MessageBusClient();
            var router = clientSettings.GetClientRouter();

            var page = new PageModel
            {
                Id = Guid.NewGuid().ToString("N"),
                Key = Guid.NewGuid().ToString("N"),
                Source = new Dictionary<string, string>
                        {
                            {"Request.ApplicationPath", HttpContext.Current.Request.ApplicationPath},
                            {"Request.PhysicalApplicationPath", HttpContext.Current.Request.PhysicalApplicationPath},
                            {"Request.PhysicalPath", HttpContext.Current.Request.PhysicalPath},
                        },
                Metric = new MetricModel
                {
                    Key = MetricType.LoadTime.ToString(),
                    Value = loadTime.ToString()
                },
                Time = DateTime.UtcNow
            };

            Task.Factory.StartNew(() =>
            {
                var producerusingClient = new JsonProducer(router);
                // todo: topics need to be maintained dynamically
                // todo: we are not specifying the partition
                producerusingClient.Publish("PageLoadTime", new List<PageModel> { page });
            });

            return new HttpResponseMessage(HttpStatusCode.Created);
        }
コード例 #2
0
        public HttpResponseMessage Post([FromBody] JObject loadTime)
        {
            var clientSettings = new MessageBusClient();
            var router         = clientSettings.GetClientRouter();

            var page = new PageModel
            {
                Id     = Guid.NewGuid().ToString("N"),
                Key    = Guid.NewGuid().ToString("N"),
                Source = new Dictionary <string, string>
                {
                    { "Request.ApplicationPath", HttpContext.Current.Request.ApplicationPath },
                    { "Request.PhysicalApplicationPath", HttpContext.Current.Request.PhysicalApplicationPath },
                    { "Request.PhysicalPath", HttpContext.Current.Request.PhysicalPath },
                },
                Metric = new MetricModel
                {
                    Key   = MetricType.LoadTime.ToString(),
                    Value = loadTime.ToString()
                },
                Time = DateTime.UtcNow
            };

            Task.Factory.StartNew(() =>
            {
                var producerusingClient = new JsonProducer(router);
                // todo: topics need to be maintained dynamically
                // todo: we are not specifying the partition
                producerusingClient.Publish("PageLoadTime", new List <PageModel> {
                    page
                });
            });

            return(new HttpResponseMessage(HttpStatusCode.Created));
        }
コード例 #3
0
 public JsonProducerTest()
 {
     _dataAccessFactory = new Mock <IDataAccessFactory>();
     _jsonProducer      = new JsonProducer <User>(_dataAccessFactory.Object);
 }