コード例 #1
0
        /// <summary>
        /// Go through every Product Picture for product with id=productId
        /// If does not exist we add it otherwise we save the PP Id
        /// </summary>
        /// <param name="image"></param>
        /// <param name="productId"></param>
        /// <param name="found"></param>
        /// <param name="pps"></param>
        /// <param name="ppsIds"></param>
        private void SyncPic(string image, JArray pictureLinks, int productId = 0)
        {
            if (String.IsNullOrWhiteSpace(image))
            {
                return;
            }

            JObject json = new JObject();

            try
            {
                Model.Picture pm = GetPicBase64(image);
                if (pm != null)
                {
                    json = ParserJSon.GetPictureJson(pm.Base64, pm.ImageType, pm.Name);

                    string  result     = WebService.Post(ENTITY, json);
                    JObject newPicture = JObject.Parse(result);
                    int     picId      = (int)newPicture["Id"];
                    JObject jsonResult = ParserJSon.getProductPictureJson(picId, productId);

                    pictureLinks.Add(jsonResult);
                }

                return;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Error parsing picture:" + json.ToString());
                Program.log("Error parsing picture:" + json.ToString());
                return;
            }
        }