Example #1
0
        public void ProcessRequest(HttpContext context)
        {
            var    request = context.Request;
            string method  = request.Params["method"];
            //string format = context.Request.QueryString["format"] ?? "json";

            string body;

            try
            {
                var type = GetParamsRequest(method);
                var rsp  = request.GetTopResponse(type);
                body = rsp.ToJson();
            }
            catch (TopException ex)
            {
                LogException(ex);
                body = new TopResponse(ex.ErrorCode, ex.ErrorMsg).ToJson();
            }
            catch (Exception ex)
            {
                LogException(ex);
                body = new TopResponse(1, ex.Message).ToJson();
            }

            context.Response.ContentType = "application/json;charset=utf-8";
            context.Response.Write(body);
            context.Response.End();
        }
Example #2
0
        public void ProcessRequest(HttpContext context)
        {
            var request = context.Request;
            string method = request.Params["method"];
            //string format = context.Request.QueryString["format"] ?? "json";

            string body;

            try
            {
                var type = GetParamsRequest(method);
                var rsp = request.GetTopResponse(type);
                body = rsp.ToJson();
            }
            catch (TopException ex)
            {
                LogException(ex);
                body = new TopResponse(ex.ErrorCode, ex.ErrorMsg).ToJson();
            }
            catch (Exception ex)
            {
                LogException(ex);
                body = new TopResponse(1, ex.Message).ToJson();
            }

            context.Response.ContentType = "application/json;charset=utf-8";
            context.Response.Write(body);
            context.Response.End();
        }
Example #3
0
        /// <summary>
        /// 获取折扣后的价格
        /// </summary>
        /// <param name="numIIDs"></param>
        /// <returns></returns>
        public static List <Top.Api.Domain.NTbkItem> GetZKPice(string numIIDs)
        {
            TBTbk       tkbll    = new TBTbk();
            TopResponse topRsp   = null;
            var         strModel = tkbll.GetItemInfoByID(1, numIIDs.TrimEnd(','), ref topRsp);

            return(strModel);
        }
Example #4
0
 private string GetTopResponseBody(TopResponse x)
 {
     if (!x.IsError)
     {
         return(x.Body);
     }
     return(x.ErrMsg);
 }
Example #5
0
 public static ApiResult AsApiResult(this TopResponse response)
 {
     if (response.IsError)
     {
         return(new ApiResult(false, response.ErrMsg + " " + response.SubErrMsg));
     }
     return(new ApiResult(true, ""));
 }
 private void ShowTop(TopResponse top)
 {
     Console.WriteLine("Top 100:");
     for (var i = 0; i < top.Users.Count; i++)
     {
         Console.WriteLine($"{i + 1}. {top.Users[i].Name}\t{top.Users[i].Starts}★");
     }
 }
Example #7
0
 public static ApiPagedResult <T> AsApiPagedResult <T>(this TopResponse response, T dataList, bool hasMore) where T : new()
 {
     if (response.IsError)
     {
         return(new ApiPagedResult <T>(false, response.ErrMsg + " " + response.SubErrMsg));
     }
     return(new ApiPagedResult <T>(true, "")
     {
         Data = dataList, HasMore = hasMore
     });
 }
Example #8
0
 public static ApiResult <T> AsApiResult <T>(this TopResponse response, Func <T> data)
 {
     if (response.IsError)
     {
         return(new ApiResult <T>(false, response.ErrMsg + " " + response.SubErrMsg));
     }
     return(new ApiResult <T>(true, "")
     {
         Data = data()
     });
 }
        public static TopResponse GetTopResponse()
        {
            var topOutputFileUrl = @"C:\Temp\top-output.txt";//"~/top-output.txt";
            //ExecuteCommandAndSaveOutputToFile("top -n 1 -b", topOutputFileUrl);
            var topOutput = "";

            using (var fileStream = File.OpenText(topOutputFileUrl))
            {
                topOutput = fileStream.ReadToEnd();
            }
            return(TopResponse.FromString(topOutput));
        }
Example #10
0
        public static List <Top.Api.Domain.NTbkItem> GetZKPice(string numIIDs)
        {
            TBTbk       tkbll  = new TBTbk();
            TopResponse topRsp = null;
            //List<string> list = new List<string>();

            var strModel = tkbll.GetItemInfoByID(2, numIIDs.TrimEnd(','), ref topRsp);

            //foreach (var item in strModel)
            //{
            //    list.Add(item.ZkFinalPrice);
            //}

            return(strModel);
        }