private List <Additionalproduct> GetOtherMockup()
        {
            List <Additionalproduct> moreProductColors = new List <Additionalproduct>();

            foreach (var mockup in Mockup.selectedMockup)
            {
                if (mockup.Name != Mockup.NameDefault)
                {
                    foreach (var color in mockup.colorList)
                    {
                        Additionalproduct addProduct = new Additionalproduct();
                        addProduct.product       = color.product_id;
                        addProduct.color         = color.id;
                        addProduct.hex           = color.hex;
                        addProduct.selling_price = mockup.mockupInfo.Product.suggested_price;
                        addProduct.profit        = "NaN";
                        addProduct.dtg_profit    = "NaN";
                        addProduct.base_price    = 0.0f;
                        addProduct.dtg_price     = 8.5f;
                        moreProductColors.Add(addProduct);
                    }
                }
            }

            return(moreProductColors);
        }
        public void UploadStore(Template template, string logoPath)
        {
            try
            {
                // string token = "tkMyMmQDXpeeLkFaLv5wb3lPx0KdEsNV269PnepU";
                int    tryCount      = 0;
                string uniqueCampUrl = template.CampUrl + "-" + StringUtil.RandomString(8);

                // check url
                //dynamic urlObj = new ExpandoObject();
                //urlObj.url = uniqueCampUrl;
                //string checkResult = web.HttpUploadFileByJson("https://viralstyle.com/design.beta/check-url",
                //    JsonConvert.SerializeObject(urlObj), token, newToken);
                //Console.WriteLine(checkResult);

                //string jsonData = File.ReadAllText(Directory.GetCurrentDirectory() + "\\data3.json");
                //System.Drawing.Image img = System.Drawing.Image.FromFile(logoPath);
                string newPath = Directory.GetCurrentDirectory() + "\\" + Path.GetFileNameWithoutExtension(logoPath)
                                 + "_temp.png";
                Resize(logoPath, newPath, 0.5f);
                string base64String;
                System.Drawing.Image img = System.Drawing.Image.FromFile(newPath);
                using (var ms = new MemoryStream())
                {
                    img.Save(ms, img.RawFormat);
                    base64String = "data:image/png;base64," + Convert.ToBase64String(ms.ToArray());
                }
                //img.Dispose();
                img.Dispose();
                File.Delete(newPath);

                string campId  = uploadAssetResult.data.campaign_identifier;
                string imageId = Path.GetFileNameWithoutExtension(uploadAssetResult.data.original_file.ToString());
                string id      = uploadAssetResult.data.identifier;

                string orgUrl     = uploadAssetResult.data.original_file;
                string resizeUrl  = uploadAssetResult.data.trimmed_image;
                string trimmedUrl = uploadAssetResult.data.resized_image;

                /*
                 * camp time format
                 * \"campaign_end_date\":\"Friday, Nov. 18 2016 - 21 PM\",
                 \"campaign_end_date_obj\":\"2016-11-18T21:18:37.818Z\",\"campaign_end_date_utc\":1479503917819,
                 */
                string jsonData = File.ReadAllText(Directory.GetCurrentDirectory() + "\\" + Settings.Default.SAMPLE_DATA_PATH);
                jsonData = jsonData.Replace("\r\n", "");
                var tempData = JsonConvert.DeserializeObject <ViralStyleRequestJsonData>(jsonData);
                ViralStyleRequestData data = new ViralStyleRequestData();
                data._token        = tempData._token;
                data.campaign_data = JsonConvert.DeserializeObject <Campaign>(tempData.campaign_data);

                string logoName = Path.GetFileNameWithoutExtension(logoPath);
                //string loadedJsonData = File.ReadAllText(Directory.GetCurrentDirectory() + "\\data4.json");
                //    jsonData = jsonData.Replace("\\", "").Replace("\r\n", "");
                //var data = JsonConvert.DeserializeObject<ViralStyleRequestData>(jsonData);
                DateTime now     = DateTime.Now;
                DateTime endDate = now.AddDays(7);
                data.campaign_data.campaign_end_date     = DateTimeUtil.DateToStrCampEndDate(endDate);
                data.campaign_data.campaign_end_date_obj = DateTimeUtil.DateToStrCampEndDateObj(endDate);
                data.campaign_data.campaign_end_date_utc = DateTimeUtil.DateToCampUTC(endDate);
                data.campaign_data.campaignUniqueId      = campId;
                data.campaign_data.imageIdentifier       = id;
                data.campaign_data.mainProduct.front.designerItems[0].value = resizeUrl;
                data.campaign_data.mainProduct.front.designerItems[0].imageData.original_url        = trimmedUrl;
                data.campaign_data.mainProduct.front.designerItems[0].imageData.thumbnail_url       = resizeUrl;
                data.campaign_data.mainProduct.front.designerItems[0].imageData.original_upload_url = orgUrl;
                data.campaign_data.campaign_length      = 7;
                data.campaign_data.campaign_name        = template.Title.Replace("{NAME}", logoName);
                data.campaign_data.campaign_description = template.Description.Replace("{NAME}", logoName);
                data.campaign_data.campaign_url         = uniqueCampUrl.Replace("{NAME}", logoName);
                data.campaign_data.campaign_tags        = template.Tags.Split(',');

                data.campaign_data.campaign_auto_extend       = template.AutoExtend;
                data.campaign_data.campaign_auto_relaunch     = template.AutoRelaunch;
                data.campaign_data.campaign_show_goal         = template.ShowGoal;
                data.campaign_data.campaign_page_timer        = template.CampaignPageTimer;
                data.campaign_data.hide_marketplace           = template.HideMarketPlace;
                data.campaign_data.campaign_show_back_default = template.ShowBackDefault;
                data.campaign_data.goal = template.Goal;

                data._token = newToken;
                data.campaign_data.design.front.upscaled = base64String;


                // update main color
                var mainColor = GetDefaultProductColor();
                data.campaign_data.mainProduct.currentColor.id              = mainColor.id;
                data.campaign_data.mainProduct.currentColor.product_id      = mainColor.product_id;
                data.campaign_data.mainProduct.currentColor.name            = mainColor.name;
                data.campaign_data.mainProduct.currentColor.hex             = mainColor.hex;
                data.campaign_data.mainProduct.currentColor.ab_color        = mainColor.ab_color;
                data.campaign_data.mainProduct.currentColor.common_color_id = mainColor.common_color_id;
                data.campaign_data.mainProduct.currentColor.sm_color        = mainColor.sm_color;
                data.campaign_data.mainProduct.currentColor.created_at      = mainColor.created_at;
                data.campaign_data.mainProduct.currentColor.updated_at      = mainColor.updated_at;
                data.campaign_data.mainProduct.product_id = mainColor.product_id;

                // update main product
                string urlAsset    = "https://assets.viralstyle.com/product-images/";
                var    mainProduct = ViralStyleDataController.Instance.GetProductByName(Mockup.NameDefault);
                data.campaign_data.mainProduct.product.image.front.original    = mainProduct.front_base;
                data.campaign_data.mainProduct.product.image.front.thumbnail   = mainProduct.front_preview;
                data.campaign_data.mainProduct.product.image.front.large       = mainProduct.front_base_large;
                data.campaign_data.mainProduct.product.product_thumbnail_image = urlAsset + mainProduct.front_preview;
                data.campaign_data.mainProduct.product.product_image           = urlAsset + mainProduct.front_base;
                data.campaign_data.pricing.basePrice    = 0.0f;
                data.campaign_data.pricing.dtgPrice     = 8.5f;
                data.campaign_data.pricing.sellingPrice = mainProduct.suggested_price;

                //data.campaign_data.pricing.dtgPrice

                // update other colors's main product
                var colors = GetOtherProductColor();
                List <Additionalproduct> moreProductColors = new List <Additionalproduct>();
                for (int i = 0; i < colors.Count; i++)
                {
                    Additionalproduct addProduct = new Additionalproduct();
                    addProduct.product       = mainProduct.id;
                    addProduct.color         = colors[i].id;
                    addProduct.hex           = colors[i].hex;
                    addProduct.selling_price = mainProduct.suggested_price;
                    addProduct.profit        = "NaN";
                    addProduct.dtg_profit    = "NaN";
                    addProduct.base_price    = 0.0f;
                    addProduct.dtg_price     = 8.5f;
                    moreProductColors.Add(addProduct);
                }
                moreProductColors.AddRange(GetOtherMockup());
                data.campaign_data.additionalProducts = moreProductColors.ToArray();
                //Array.Clear(data.campaign_data.additionalProducts, 0, data.campaign_data.additionalProducts.Length);

                tempData._token        = newToken;
                tempData.campaign_data = JsonConvert.SerializeObject(data.campaign_data);
                string encodeJson = JsonConvert.SerializeObject(tempData);
                //jsonData = jsonData.Replace("\\", "").Replace("\r\n", "");
                //jsonData = jsonData.Replace("\r\n", "");
                //encodeJson = encodeJson.Replace("{CAMP_ID}", campId)
                //    .Replace("{IMAGE_ID}", id)
                //    .Replace("{RESIZE_IMAGE_URL}", resizeUrl)
                //    .Replace("{TRIMMED_IMAGE_URL}", trimmedUrl)
                //    .Replace("{ORG_IMAGE_URL}", orgUrl)
                //    .Replace("{TITLE}", template.Title)
                //    .Replace("{DESCRIPTION}", template.Description)
                //    .Replace("{CAMP_URL}", uniqueCampUrl)
                //    .Replace("{TOKEN}", newToken)
                //    .Replace("{IMAGE_64}", base64String);


                //Console.WriteLine(result);
                string campUrl = "https://viralstyle.com/api/v2/designer/store";
                string result  = web.HttpUploadFileByJson(campUrl, encodeJson, token, newToken);
                Console.WriteLine(result);
                logger.Info("upload result: " + result);
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("Error: {0}, stacktrace: {1}", ex.Message, ex.StackTrace);
            }
        }