Esempio n. 1
0
        public static async Task <ResultValue> GetSystemData(Dictionary <string, object> parameterDictionary)
        {
            var systemDataResult = new ResultValue();

            try
            {
                var dateType  = parameterDictionary["DateType"].ToString();
                var brandType = parameterDictionary["BrandType"].ToString();
                var category  = parameterDictionary["Category"] == null ? string.Empty : parameterDictionary["Category"].ToString();
                var category1 = string.Empty;
                var category2 = string.Empty;
                if (!string.IsNullOrEmpty(category))
                {
                    var categorys = category.Split(new[] { "*" }, StringSplitOptions.RemoveEmptyEntries);
                    category1 = categorys[0];
                    category2 = categorys.Count() == 2 ? categorys[1] : string.Empty;
                }

                var dimensions         = parameterDictionary["Dimensions"] == null ? string.Empty : parameterDictionary["Dimensions"].ToString();
                var metrics            = parameterDictionary["Metrics"].ToString();
                var benchmarkDataValue = await BenchmarkService.GetBenchmarkDatas(dateType, brandType, category1, category2, dimensions, metrics);

                if (((RestResponseBase)(benchmarkDataValue)).StatusCode == HttpStatusCode.OK) //200
                {
                    systemDataResult = benchmarkDataValue.Data;
                }
                else if (((RestResponseBase)(benchmarkDataValue)).StatusCode == HttpStatusCode.NotFound) //404
                {
                    ShowMessage.Show("访问404错误");
                }
                else if ((int)benchmarkDataValue.StatusCode == 422)
                {
                    ShowMessage.Show("访问422错误");
                }
                else if (((RestResponseBase)(benchmarkDataValue)).StatusCode == HttpStatusCode.InternalServerError) //500
                {
                    ShowMessage.Show("访问500错误");
                }
                else
                {
                    ShowMessage.Show("未知错误");
                }
            }
            catch (Exception ex)
            {
                ShowMessage.Show("加载数据出错");
                LogHelper.LogMessage(MethodBase.GetCurrentMethod().DeclaringType, LogHelper.LogLevel, "Failed to GetSystemData", ex);
            }
            finally
            {
                if (LogHelper.LogLevel == LogLevelEnum.Debug || LogHelper.LogLevel == LogLevelEnum.Info)
                {
                    LogHelper.LogMessage(MethodBase.GetCurrentMethod().DeclaringType, LogHelper.LogLevel, "GetSystemData", null);
                }
            }

            return(systemDataResult);
        }