Example #1
0
        private void FillProductInfo(string content)
        {
            CQ  dom         = content;
            var productData = dom["[type='template-data']"];

            _content       = JObject.Parse(productData[0].InnerHTML);
            ProductId      = _content["productId"].ToString();
            ProductGroupId = _content["productGroupId"].ToString();
            DisplayName    = _content["displayName"].ToString();
            ProductTitle   = _content["productTitle"].ToString();
            StartDate      =
                new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(double.Parse(_content["startDate"].ToString()));
            InStock            = bool.Parse(_content["inStock"].ToString());
            PreOrder           = bool.Parse(_content["preOrder"].ToString());
            QuantityLimit      = int.Parse(_content["quantityLimit"].ToString());
            Unlocked           = bool.Parse(_content["unlocked"].ToString());
            ShowBuyingTools    = bool.Parse(_content["showBuyingTools"].ToString());
            ShowSizeAndFitLink = bool.Parse(_content["showSizeAndFitLink"].ToString());
            StyleNumber        = _content["styleNumber"].ToString();
            ColorNumber        = _content["colorNumber"].ToString();
            Url = _content["url"].ToString();
            _content["skuContainer"]["productSkus"].ForEach(jo =>
            {
                ProductSkus.Add(new ProductSku()
                {
                    Product     = this,
                    Id          = jo["id"].ToString(),
                    InStock     = bool.Parse(jo["inStock"].ToString()),
                    DisplaySize = jo["displaySize"].ToString(),
                    Sku         = jo["sku"].ToString(),
                });
            });
        }
Example #2
0
        public HttpResponseMessage ProductPrice(ProductSkus value)
        {
            API_Message message = new API_Message();
            string      restr   = "";

            if (ModelState.IsValid)
            {
                try
                {
                    _logger.WriteLog_Info <OMS商品价格请求>(JsonConvert.SerializeObject(value), null, "请求", null);
                    WebClient client = new WebClient();
                    client.Headers.Add("Content-Type", "application/json;charset=utf8");
                    //IsoDateTimeConverter iso = new IsoDateTimeConverter();
                    //iso.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                    string update     = JsonConvert.SerializeObject(value);
                    byte[] reByte_Api = client.UploadData(_ISetting.ecmall.Base_Url + "/appserver/index.php?m=Api&c=Past&a=paste", "Post", Encoding.UTF8.GetBytes(update));
                    restr = Encoding.UTF8.GetString(reByte_Api);
                    _logger.WriteLog_Info <OMS商品价格请求>(restr, null, "return", null);
                }
                catch (Exception ex)
                {
                    _logger.WriteLog_Error <OMS商品价格请求>(JsonConvert.SerializeObject(value), null, "2", ex);
                    message.MessageCode = ((int)m_Code.Faile).ToString();;
                    message.ErrorMsg    = "ecmall连接错误";
                    restr = JsonConvert.SerializeObject(message);
                }
            }
            else
            {
                var    modelstate = BadRequest(ModelState);
                string returestr  = "";
                foreach (var item in modelstate.ModelState.Keys)
                {
                    returestr += "Key:" + item + "value:" + (modelstate.ModelState?[item].Errors != null ? (modelstate.ModelState?[item].Errors?[0].ErrorMessage + "   " + modelstate.ModelState?[item].Errors?[0].Exception?.Message) : "");// item.Errors != null ? item.Errors[0].ErrorMessage + "\r\n" : "";
                }
                message.ErrorMsg    = returestr;
                message.MessageCode = ((int)m_Code.Faile).ToString();
                restr = JsonConvert.SerializeObject(message);
                _logger.WriteLog_Error <OMS商品价格请求>(JsonConvert.SerializeObject(value), null, "3", null);
                _logger.WriteLog_Error <OMS商品价格请求>(JsonConvert.SerializeObject(message), "4", null, null);
            }
            return(new HttpResponseMessage {
                Content = new StringContent(restr, Encoding.UTF8)
            });
        }