Ejemplo n.º 1
0
        /// <summary>
        /// 查询门店列表
        /// </summary>
        /// <returns></returns>
        public static List <Warehouse> FetchWhList()
        {
            ResponseModel model = EncryptoPost(WH_LIST, new ExpandoObject());

            string whData = CryptoUtil.AESDecrypt(model.Data, KEY);

            Console.WriteLine(JSONUtil.Prettify(whData));
            model = JsonConvert.DeserializeObject <ResponseModel>(whData);
            if ("0".Equals(model.RtnStatus))
            {
                List <Warehouse> whList = JsonConvert.DeserializeObject <List <Warehouse> >(JsonConvert.SerializeObject(model.Data));
                App.WhList = whList;
                return(whList);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 参数加密Post
        /// </summary>
        /// <param name="url"></param>
        /// <param name="userParam"></param>
        /// <returns></returns>
        private static ResponseModel EncryptoPost(string url, dynamic userParam)
        {
            string        param = CryptoUtil.AESEncrypt(JsonConvert.SerializeObject(userParam), KEY);
            ResponseModel model = new ResponseModel
            {
                RtnStatus = "0"
            };

            try
            {
                string response     = Post(url, param);
                string decryptoText = CryptoUtil.AESDecrypt(response, KEY);
                Console.WriteLine(JSONUtil.Prettify(decryptoText));
                model = JsonConvert.DeserializeObject <ResponseModel>(decryptoText);
            }
            catch (Exception e)
            {
                model.RtnStatus = "1";
                model.RtnMsg    = e.Message;
            }
            return(model);
        }