Example #1
0
        public string UpdateCategoryImages(HttpContext context, string editLangCurrent)
        {
            EditLangCurrent = editLangCurrent;
            //get uploaded params
            var ajaxInfo      = NBrightBuyUtils.GetAjaxFields(context);
            var catitemid     = ajaxInfo.GetXmlPropertyInt("genxml/hidden/selectedcatid");
            var imguploadlist = ajaxInfo.GetXmlProperty("genxml/hidden/imguploadlist");
            var strOut        = "";

            if (catitemid > 0)
            {
                var imgs = imguploadlist.Split(',');
                foreach (var img in imgs)
                {
                    if (ImgUtils.IsImageFile(Path.GetExtension(img)) && img != "")
                    {
                        string fullName = StoreSettings.Current.FolderTempMapPath + "\\" + img;
                        if (File.Exists(fullName))
                        {
                            var imgResize = StoreSettings.Current.GetInt(StoreSettingKeys.productimageresize);
                            if (imgResize == 0)
                            {
                                imgResize = 800;
                            }
                            var productFunctions = new ProductFunctions();
                            var imagepath        = productFunctions.ResizeImage(fullName, imgResize);
                            var imageurl         = StoreSettings.Current.FolderImages.TrimEnd('/') + "/" + Path.GetFileName(imagepath);
                            AddNewImage(catitemid, imageurl, imagepath, EditLangCurrent);
                        }
                    }
                }
            }
            return(CategoryAdminDetail(context, 0, EditLangCurrent));
        }
Example #2
0
        public string UpdateCategoryImages(HttpContext context, string editLangCurrent)
        {
            EditLangCurrent = editLangCurrent;
            //get uploaded params
            var ajaxInfo      = NBrightBuyUtils.GetAjaxFields(context);
            var catitemid     = ajaxInfo.GetXmlPropertyInt("genxml/hidden/selectedcatid");
            var imguploadlist = ajaxInfo.GetXmlProperty("genxml/hidden/imguploadlist");
            var strOut        = "";

            if (catitemid > 0)
            {
                var imgs = imguploadlist.Split(',');
                foreach (var img in imgs)
                {
                    if (ImgUtils.IsImageFile(Path.GetExtension(img)) && img != "")
                    {
                        var extension = Path.GetExtension(img);
                        var fn        = DnnUtils.Encrypt(img, StoreSettings.Current.Get("adminpin"));
                        foreach (char c in System.IO.Path.GetInvalidFileNameChars())
                        {
                            fn = fn.Replace(c, '_');
                        }
                        fn = extension + "-" + fn; // add extension to front, so it cannot be servered but we can add to order data.

                        var fullName = StoreSettings.Current.FolderTempMapPath.TrimEnd(Convert.ToChar("\\")) + "\\" + fn;
                        if (File.Exists(fullName))
                        {
                            // process image provider
                            var imageInfo = new NBrightInfo(true);
                            imageInfo.SetXmlProperty("genxml/uploadedimagemappath", fullName);
                            imageInfo = NBrightBuyUtils.ProcessImageProvider("product", imageInfo);
                            fullName  = imageInfo.GetXmlProperty("genxml/uploadedimagemappath");

                            // deal with image
                            File.Move(fullName, fullName + extension);
                            fullName = fullName + extension;
                            var imgResize = StoreSettings.Current.GetInt(StoreSettingKeys.productimageresize);
                            if (imgResize == 0)
                            {
                                imgResize = 800;
                            }
                            var productFunctions = new ProductFunctions();
                            var imagepath        = productFunctions.ResizeImage(fullName, imgResize);
                            var imageurl         = StoreSettings.Current.FolderImages.TrimEnd('/') + "/" + Path.GetFileName(imagepath);
                            AddNewImage(catitemid, imageurl, imagepath, EditLangCurrent);
                        }
                    }
                }
            }
            return(CategoryAdminDetail(context, 0, EditLangCurrent));
        }