Exemplo n.º 1
0
        public async Task <string> GetServiceBasicData(QueryRequest request)
        {
            var start = request.Start.ToDateTime();
            var end   = request.End.ToDateTime();

            BasicFilter filter = new BasicFilter {
                Service   = request.Service,
                Instance  = request.Instance,
                StartTime = start,
                EndTime   = end,
                Count     = 6
            };

            var endpoint = _storage.GetGroupData(filter, GroupType.Route);

            var instance = _storage.GetGroupData(filter, GroupType.Instance);

            var range = GetTimeRange(start, end);

            var app = _storage.GetAppStatus(filter, range);

            await Task.WhenAll(endpoint, instance, app);

            var result = new HttpResultEntity(1, "ok", new
            {
                endpoint = endpoint.Result,
                instance = instance.Result,
                range    = range,
                app      = app.Result
            });

            return(Json(result));
        }
Exemplo n.º 2
0
        public async Task <string> GetIndexBasicData(QueryRequest request)
        {
            var start = request.Start.ToDateTime();
            var end   = request.End.ToDateTime();

            BasicFilter filter = new BasicFilter
            {
                Service   = request.Service,
                Instance  = request.Instance,
                StartTime = start,
                EndTime   = end,
                Count     = 6
            };

            var basic = _storage.GetIndexBasicDataAsync(filter);

            var top = _storage.GetGroupData(filter, GroupType.Service);

            var range = GetTimeRange(start, end);

            var trend = _storage.GetServiceTrend(filter, range);

            var heatmap = _storage.GetServiceHeatMap(filter, range);

            await Task.WhenAll(basic, top, trend, heatmap);

            var result = new HttpResultEntity(1, "ok", new
            {
                Total       = basic.Result.Total,
                ServerError = basic.Result.ServerError,
                Service     = basic.Result.Service,
                Instance    = basic.Result.Instance,
                Top         = top.Result,
                Trend       = trend.Result,
                HeatMap     = heatmap.Result
            });

            return(Json(result));
        }
Exemplo n.º 3
0
        public IActionResult GetTimeTag(string start, string end, int TagValue)
        {
            //TODO 将此函数放到前端直接获取
            var result = new HttpResultEntity <int>(1, "ok", 0);

            if (TagValue > 0)
            {
                if (TagValue == 1 && start == DateTime.Now.ToString("yyyy-MM-dd") && end == DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"))
                {
                    return(Json(new HttpResultEntity <int>(1, "ok", -1)));
                }

                if (TagValue == 2 && start == DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") && end == DateTime.Now.ToString("yyyy-MM-dd"))
                {
                    return(Json(new HttpResultEntity <int>(1, "ok", -1)));
                }

                if (TagValue == 3 && start == DateTime.Now.AddDays(-((int)DateTime.Now.DayOfWeek == 0 ? 7 : (int)DateTime.Now.DayOfWeek) + 1).ToString("yyyy-MM-dd") && end == DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"))
                {
                    return(Json(new HttpResultEntity <int>(1, "ok", -1)));
                }

                if (TagValue == 4 && start == DateTime.Now.AddDays(-DateTime.Now.Day + 1).ToString("yyyy-MM-dd") && end == DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"))
                {
                    return(Json(new HttpResultEntity <int>(1, "ok", -1)));
                }
            }

            if (start.IsEmpty() && end.IsEmpty())
            {
                result = new HttpResultEntity <int>(1, "ok", 1);

                return(Json(result));
            }

            if (start == DateTime.Now.ToString("yyyy-MM-dd") && end == DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"))
            {
                result = new HttpResultEntity <int>(1, "ok", 1);

                return(Json(result));
            }

            if (start == DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") && end == DateTime.Now.ToString("yyyy-MM-dd"))
            {
                result = new HttpResultEntity <int>(1, "ok", 2);
                return(Json(result));
            }

            if (start == DateTime.Now.AddDays(-(int)DateTime.Now.DayOfWeek + 1).ToString("yyyy-MM-dd") && end == DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"))
            {
                result = new HttpResultEntity <int>(1, "ok", 3);
                return(Json(result));
            }

            if (start == DateTime.Now.AddDays(-DateTime.Now.Day + 1).ToString("yyyy-MM-dd") && end == DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"))
            {
                result = new HttpResultEntity <int>(1, "ok", 4);
                return(Json(result));
            }

            return(Json(result));
        }