コード例 #1
0
        public static async Task <ResultValue> GetDataByCategorys1(string categorys1)
        {
            var categorys2ListResult = new ResultValue();

            try
            {
                var benchmarkTypeDataValue = await BenchmarkService.GetCategorys2Datas(categorys1);

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

            return(categorys2ListResult);
        }