示例#1
0
        public static void UpdateDirectories()
        {
            var pictDirs = new List <string>
            {
                FoldersHelper.GetPathAbsolut(FolderType.Product),
                FoldersHelper.GetPathAbsolut(FolderType.News),
                FoldersHelper.GetPathAbsolut(FolderType.Category),
                FoldersHelper.GetPathAbsolut(FolderType.BrandLogo),
                FoldersHelper.GetPathAbsolut(FolderType.Carousel),
                FoldersHelper.GetPathAbsolut(FolderType.Color),
            };

            pictDirs.AddRange(FoldersHelper.ProductPhotoPrefix.Select(kvp => FoldersHelper.GetImageProductPathAbsolut(kvp.Key, string.Empty)));
            pictDirs.AddRange(FoldersHelper.CategoryPhotoPrefix.Select(kvp => FoldersHelper.GetImageCategoryPathAbsolut(kvp.Key, string.Empty)));
            pictDirs.AddRange(FoldersHelper.ColorPhotoPrefix.Select(kvp => FoldersHelper.GetImageColorPathAbsolut(kvp.Key, string.Empty)));
            foreach (var directory in pictDirs.Where(dir => (!Directory.Exists(dir) && dir.Trim().Length != 0)))
            {
                Directory.CreateDirectory(directory);
            }
        }
示例#2
0
        private static void DeleteFile(PhotoType type, string photoName)
        {
            switch (type)
            {
            case PhotoType.Product:
                FileHelpers.DeleteFile(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Original, photoName));
                FileHelpers.DeleteFile(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Big, photoName));
                FileHelpers.DeleteFile(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Middle, photoName));
                FileHelpers.DeleteFile(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Small, photoName));
                FileHelpers.DeleteFile(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.XSmall, photoName));
                break;

            case PhotoType.Brand:
                FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.BrandLogo, photoName));
                break;

            case PhotoType.CategoryBig:
                FileHelpers.DeleteFile(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Big, photoName));
                break;

            case PhotoType.CategorySmall:
                FileHelpers.DeleteFile(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Small, photoName));
                break;

            case PhotoType.Carousel:
                FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.Carousel, photoName));
                break;

            case PhotoType.News:
                FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.News, photoName));
                break;

            case PhotoType.StaticPage:
                FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.StaticPage, photoName));
                break;
            }
        }
示例#3
0
    protected void btnCleanUpPictureFolder_Click(object sender, EventArgs e)
    {
        var fileNames = new List <string>();

        foreach (var photo in PhotoService.GetNamePhotos(0, PhotoType.Product))
        {
            fileNames.Add(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Big, photo));
            fileNames.Add(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Middle, photo));
            fileNames.Add(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Small, photo));
            fileNames.Add(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.XSmall, photo));
        }

        foreach (string photo in PhotoService.GetNamePhotos(0, PhotoType.CategoryBig))
        {
            fileNames.Add(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Big, photo));
        }

        foreach (string photo in PhotoService.GetNamePhotos(0, PhotoType.CategorySmall))
        {
            fileNames.Add(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Small, photo));
        }

        //Add Logo image in exceptions
        fileNames.Add(SettingsMain.LogoImageName);

        var files = new List <string>();

        files.AddRange(Directory.GetFiles(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Big, string.Empty)));
        files.AddRange(Directory.GetFiles(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Middle, string.Empty)));
        files.AddRange(Directory.GetFiles(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Small, string.Empty)));
        files.AddRange(Directory.GetFiles(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.XSmall, string.Empty)));

        files.AddRange(Directory.GetFiles(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Big, string.Empty)));   // GetImageCategoryPathAbsolut(false)));
        files.AddRange(Directory.GetFiles(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Small, string.Empty))); // GetImageCategoryPathAbsolut(false)));

        var deleted = new List <string>();

        foreach (string file in files)
        {
            if (!fileNames.Contains(file) || (file.Trim().Length == 0))
            {
                if (chboxDeleteFiles.Checked)
                {
                    File.Delete(file);
                }
                deleted.Add(file);
            }
        }

        if (!chboxDeleteFiles.Checked)
        {
            lCompleted.Text = @"Analysis successfully completed";
        }

        lCompleted.Visible = true;

        var res = new StringBuilder();

        foreach (string del in deleted)
        {
            res.Append(del);
            res.Append("<br />");
        }

        if (deleted.Count > 0)
        {
            if (!chboxDeleteFiles.Checked)
            {
                lResultHeader.Text = @"Files to delete";
            }
            lResultHeader.Visible = true;
            lResult.Text          = res.ToString();
        }
        else
        {
            lResultHeader.Text    = @"No unnecessary files";
            lResultHeader.Visible = true;
        }
    }
示例#4
0
        private int CreateCategory()
        {
            // Validation
            MsgErr(true);

            if (string.IsNullOrEmpty(txtName.Text))
            {
                MsgErr(Resource.Admin_m_Category_NoName);
                return(0);
            }
            if (string.IsNullOrEmpty(txtSynonym.Text))
            {
                MsgErr(Resource.Admin_m_Category_NoSynonym);
                return(0);
            }
            var reg = new Regex("^[a-zA-Z0-9_-]*$");

            if (!reg.IsMatch(txtSynonym.Text))
            {
                MsgErr(Resource.Admin_m_Category_SynonymInfo);
                return(0);
            }

            if (!UrlService.IsAvailableUrl(ParamType.Category, txtSynonym.Text))
            {
                MsgErr(Resource.Admin_SynonymExist);
                return(0);
            }

            if ((PictureFileUpload.HasFile && !FileHelpers.CheckFileExtension(PictureFileUpload.FileName, FileHelpers.eAdvantShopFileTypes.Image)) ||
                (MiniPictureFileUpload.HasFile && !FileHelpers.CheckFileExtension(MiniPictureFileUpload.FileName, FileHelpers.eAdvantShopFileTypes.Image)))
            {
                MsgErr(Resource.Admin_ErrorMessage_WrongImageExtension);
                return(0);
            }

            var myCat = new Category
            {
                Name                 = txtName.Text,
                ParentCategoryId     = tree.SelectedValue.TryParseInt(),
                Description          = fckDescription.Text,
                BriefDescription     = fckBriefDescription.Text,
                SortOrder            = txtSortIndex.Text.TryParseInt(),
                Enabled              = ChkEnableCategory.Checked,
                DisplayChildProducts = false,     //ChkDisplayChildProducts.Checked,
                DisplayStyle         = SubCategoryDisplayStyle.SelectedValue,
                UrlPath              = txtSynonym.Text,
                Meta                 = new MetaInfo(0, 0, MetaType.Category, txtTitle.Text, txtMetaKeywords.Text, txtMetaDescription.Text, txtH1.Text),
                Sorting              = (ESortOrder)ddlSorting.SelectedValue.TryParseInt()
            };

            try
            {
                myCat.CategoryId = CategoryService.AddCategory(myCat, true);
                if (myCat.CategoryId == 0)
                {
                    return(0);
                }

                if (PictureFileUpload.HasFile)
                {
                    var tempName = PhotoService.AddPhoto(new Photo(0, myCat.CategoryId, PhotoType.CategoryBig)
                    {
                        OriginName = PictureFileUpload.FileName
                    });
                    if (!string.IsNullOrWhiteSpace(tempName))
                    {
                        using (Image image = Image.FromStream(PictureFileUpload.FileContent))
                            FileHelpers.SaveResizePhotoFile(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Big, tempName), SettingsPictureSize.BigCategoryImageWidth, SettingsPictureSize.BigCategoryImageHeight, image);
                    }
                }


                if (MiniPictureFileUpload.HasFile)
                {
                    var tempName = PhotoService.AddPhoto(new Photo(0, myCat.CategoryId, PhotoType.CategorySmall)
                    {
                        OriginName = MiniPictureFileUpload.FileName
                    });
                    if (!string.IsNullOrWhiteSpace(tempName))
                    {
                        using (Image image = Image.FromStream(MiniPictureFileUpload.FileContent))
                            FileHelpers.SaveResizePhotoFile(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Small, tempName), SettingsPictureSize.SmallCategoryImageWidth, SettingsPictureSize.SmallCategoryImageHeight, image);
                    }
                }

                TrialService.TrackEvent(TrialEvents.AddCategory, "");
                return(myCat.CategoryId);
            }
            catch (Exception ex)
            {
                MsgErr(ex.Message + "at CreateCategory");
                Debug.LogError(ex, false);
            }
            return(0);
        }
示例#5
0
        protected void SaveCategory()
        {
            if (_mode == eCategoryMode.Err)
            {
                return;
            }

            int categoryID = _categoryId;

            lblError.Text = string.Empty;
            string synonym = txtSynonym.Text.Trim();

            if (String.IsNullOrEmpty(synonym))
            {
                MsgErr(Resource.Admin_m_Category_NoSynonym);
                return;
            }

            string oldSynonym = UrlService.GetObjUrlFromDb(ParamType.Category, categoryID);

            if (oldSynonym != synonym)
            {
                var reg = new Regex("^[a-zA-Z0-9_-]*$");
                if (!reg.IsMatch(synonym))
                {
                    MsgErr(Resource.Admin_m_Category_SynonymInfo);
                    return;
                }
                if (!UrlService.IsAvailableUrl(categoryID, ParamType.Category, synonym))
                {
                    MsgErr(Resource.Admin_SynonymExist);
                    return;
                }
            }

            var c = new Category
            {
                CategoryId                 = categoryID,
                Name                       = txtName.Text,
                ParentCategoryId           = tree.SelectedValue.TryParseInt(),
                Description                = fckDescription.Text == "<br />" || fckDescription.Text == "&nbsp;" || fckDescription.Text == "\r\n" ? string.Empty : fckDescription.Text,
                BriefDescription           = fckBriefDescription.Text == "<br />" || fckBriefDescription.Text == "&nbsp;" || fckBriefDescription.Text == "\r\n" ? string.Empty : fckBriefDescription.Text,
                Enabled                    = ChkEnableCategory.Checked,
                DisplayStyle               = SubCategoryDisplayStyle.SelectedValue,
                DisplayChildProducts       = false, //ChkDisplayChildProducts.Checked,
                DisplayBrandsInMenu        = ChkDisplayBrands.Checked,
                DisplaySubCategoriesInMenu = ChkDisplaySubCategories.Checked,
                UrlPath                    = synonym,
                SortOrder                  = txtSortIndex.Text.TryParseInt(),
                Sorting                    = (ESortOrder)ddlSorting.SelectedValue.TryParseInt()
            };

            FileHelpers.UpdateDirectories();
            if (PictureFileUpload.HasFile)
            {
                if (!FileHelpers.CheckFileExtension(PictureFileUpload.FileName, FileHelpers.eAdvantShopFileTypes.Image))
                {
                    MsgErr(Resource.Admin_ErrorMessage_WrongImageExtension);
                    return;
                }

                PhotoService.DeletePhotos(_categoryId, PhotoType.CategoryBig);

                var tempName = PhotoService.AddPhoto(new Photo(0, categoryID, PhotoType.CategoryBig)
                {
                    OriginName = PictureFileUpload.FileName
                });
                if (!string.IsNullOrWhiteSpace(tempName))
                {
                    using (Image image = Image.FromStream(PictureFileUpload.FileContent))
                        FileHelpers.SaveResizePhotoFile(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Big, tempName), SettingsPictureSize.BigCategoryImageWidth, SettingsPictureSize.BigCategoryImageHeight, image);
                }
            }


            if (MiniPictureFileUpload.HasFile)
            {
                if (!FileHelpers.CheckFileExtension(MiniPictureFileUpload.FileName, FileHelpers.eAdvantShopFileTypes.Image))
                {
                    MsgErr(Resource.Admin_ErrorMessage_WrongImageExtension);
                    return;
                }

                PhotoService.DeletePhotos(_categoryId, PhotoType.CategorySmall);

                var tempName = PhotoService.AddPhoto(new Photo(0, categoryID, PhotoType.CategorySmall)
                {
                    OriginName = MiniPictureFileUpload.FileName
                });
                if (!string.IsNullOrWhiteSpace(tempName))
                {
                    using (Image image = Image.FromStream(MiniPictureFileUpload.FileContent))
                        FileHelpers.SaveResizePhotoFile(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Small, tempName), SettingsPictureSize.SmallCategoryImageWidth, SettingsPictureSize.SmallCategoryImageHeight, image);
                }
            }

            if (IconFileUpload.HasFile)
            {
                if (!FileHelpers.CheckFileExtension(IconFileUpload.FileName, FileHelpers.eAdvantShopFileTypes.Image))
                {
                    MsgErr(Resource.Admin_ErrorMessage_WrongImageExtension);
                    return;
                }

                PhotoService.DeletePhotos(_categoryId, PhotoType.CategoryIcon);

                var tempName = PhotoService.AddPhoto(new Photo(0, categoryID, PhotoType.CategoryIcon)
                {
                    OriginName = IconFileUpload.FileName
                });
                if (!string.IsNullOrWhiteSpace(tempName))
                {
                    using (Image image = Image.FromStream(IconFileUpload.FileContent))
                        FileHelpers.SaveResizePhotoFile(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Icon, tempName), SettingsPictureSize.IconCategoryImageWidth, SettingsPictureSize.IconCategoryImageHeight, image);
                }
            }


            c.Meta = new MetaInfo(0, c.CategoryId, MetaType.Category, txtTitle.Text, txtMetaKeywords.Text, txtMetaDescription.Text, txtH1.Text);

            var isParentCategoryChanged = CategoryService.GetCategory(_categoryId).ParentCategoryId != c.ParentCategoryId;

            if (!CategoryService.UpdateCategory(c, true))
            {
                MsgErr("Failed to save category");
            }

            if (isParentCategoryChanged)
            {
                CategoryService.RecalculateProductsCountManual();
                CategoryService.ClearCategoryCache();
            }
        }
示例#6
0
        protected void LoadCategory(int catId)
        {
            try
            {
                Category category = CategoryService.GetCategory(catId);
                txtName.Text = category.Name;
                if (category.Picture != null && File.Exists(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Big, category.Picture.PhotoName)))
                {
                    Label10.Text     = category.Picture.PhotoName;
                    pnlImage.Visible = true;
                    Image1.ImageUrl  = FoldersHelper.GetImageCategoryPath(CategoryImageType.Big, category.Picture.PhotoName, true);
                    Image1.ToolTip   = category.Picture.PhotoName;
                }
                else
                {
                    Label10.Text     = @"No picture";
                    pnlImage.Visible = false;
                }

                if (category.MiniPicture != null && File.Exists(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Small, category.MiniPicture.PhotoName)))
                {
                    lblMiniPictureFileName.Text = category.MiniPicture.PhotoName;
                    pnlMiniImage.Visible        = true;

                    imgMiniPicture.ImageUrl = FoldersHelper.GetImageCategoryPath(CategoryImageType.Small, category.MiniPicture.PhotoName, true);
                    imgMiniPicture.ToolTip  = category.MiniPicture.PhotoName;
                }
                else
                {
                    lblMiniPictureFileName.Text = @"No picture";
                    pnlMiniImage.Visible        = false;
                }

                if (category.Icon != null && File.Exists(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Icon, category.Icon.PhotoName)))
                {
                    lblIconFileName.Text = category.Icon.PhotoName;
                    pnlIcon.Visible      = true;

                    imgIcon.ImageUrl = FoldersHelper.GetImageCategoryPath(CategoryImageType.Icon, category.Icon.PhotoName, true);
                    imgIcon.ToolTip  = category.Icon.PhotoName;
                }
                else
                {
                    lblIconFileName.Text = @"No picture";
                    pnlIcon.Visible      = false;
                }

                SubCategoryDisplayStyle.SelectedValue = category.DisplayStyle;
                //ChkDisplayChildProducts.Checked = category.DisplayChildProducts;
                ChkDisplayBrands.Checked        = category.DisplayBrandsInMenu;
                ChkDisplaySubCategories.Checked = category.DisplaySubCategoriesInMenu;
                fckDescription.Text             = category.Description;
                fckBriefDescription.Text        = category.BriefDescription;
                txtSortIndex.Text         = category.SortOrder.ToString();
                ChkEnableCategory.Checked = category.Enabled;

                txtSynonym.Text = category.UrlPath;

                ddlSorting.SelectedValue = ((int)category.Sorting).ToString();

                var meta = MetaInfoService.GetMetaInfo(catId, MetaType.Category);
                if (meta == null)
                {
                    category.Meta          = new MetaInfo(0, 0, MetaType.Product, string.Empty, string.Empty, string.Empty, string.Empty);
                    chbDefaultMeta.Checked = true;
                }
                else
                {
                    chbDefaultMeta.Checked  = false;
                    category.Meta           = meta;
                    txtTitle.Text           = category.Meta.Title;
                    txtMetaKeywords.Text    = category.Meta.MetaKeywords;
                    txtMetaDescription.Text = category.Meta.MetaDescription;
                    txtH1.Text = category.Meta.H1;
                }
            }
            catch (Exception ex)
            {
                MsgErr(ex.Message + " at LoadCategory");
                Debug.LogError(ex, "at LoadCategory");
            }
        }
示例#7
0
        private static void DeleteFile(PhotoType type, string photoName)
        {
            bool backup = SettingProvider.GetConfigSettingValue <bool>("BackupPhotosBeforeDeleting");

            switch (type)
            {
            case PhotoType.Product:

                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Original, photoName));
                    FileHelpers.BackupFhoto(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Big, photoName));
                    FileHelpers.BackupFhoto(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Middle, photoName));
                    FileHelpers.BackupFhoto(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Small, photoName));
                    FileHelpers.BackupFhoto(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.XSmall, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Original, photoName));
                    FileHelpers.DeleteFile(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Big, photoName));
                    FileHelpers.DeleteFile(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Middle, photoName));
                    FileHelpers.DeleteFile(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Small, photoName));
                    FileHelpers.DeleteFile(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.XSmall, photoName));
                }
                break;

            case PhotoType.Brand:
                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetPathAbsolut(FolderType.BrandLogo, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.BrandLogo, photoName));
                }
                break;

            case PhotoType.CategoryBig:
                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Big, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Big, photoName));
                }
                break;

            case PhotoType.CategorySmall:
                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Small, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Small, photoName));
                }
                break;

            case PhotoType.CategoryIcon:
                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Icon, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Icon, photoName));
                }
                break;

            case PhotoType.Carousel:
                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetPathAbsolut(FolderType.Carousel, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.Carousel, photoName));
                }
                break;

            case PhotoType.News:
                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetPathAbsolut(FolderType.News, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.News, photoName));
                }
                break;

            case PhotoType.StaticPage:
                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetPathAbsolut(FolderType.StaticPage, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.StaticPage, photoName));
                }
                break;

            case PhotoType.Shipping:
                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetPathAbsolut(FolderType.ShippingLogo, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.ShippingLogo, photoName));
                }
                break;

            case PhotoType.Payment:
                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetPathAbsolut(FolderType.PaymentLogo, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.PaymentLogo, photoName));
                }
                break;

            case PhotoType.MenuIcon:
                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetPathAbsolut(FolderType.MenuIcons, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.MenuIcons, photoName));
                }
                break;

            case PhotoType.Color:
                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetImageColorPathAbsolut(ColorImageType.Catalog, photoName));
                    FileHelpers.BackupFhoto(FoldersHelper.GetImageColorPathAbsolut(ColorImageType.Details, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetImageColorPathAbsolut(ColorImageType.Catalog, photoName));
                    FileHelpers.DeleteFile(FoldersHelper.GetImageColorPathAbsolut(ColorImageType.Details, photoName));
                }
                break;

            default:
                throw new NotImplementedException();
            }
        }
示例#8
0
        protected void btnCleanUpBD_Click(object sender, EventArgs e)
        {
            var res = new StringBuilder();

            try
            {
                foreach (var photoName in PhotoService.GetNamePhotos(0, PhotoType.Product, true))
                {
                    res.Append(CheckExistingFile(PhotoType.Product, photoName, FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Big, photoName)));
                    res.Append(CheckExistingFile(PhotoType.Product, photoName, FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Middle, photoName)));
                    res.Append(CheckExistingFile(PhotoType.Product, photoName, FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Small, photoName)));
                    res.Append(CheckExistingFile(PhotoType.Product, photoName, FoldersHelper.GetImageProductPathAbsolut(ProductImageType.XSmall, photoName)));
                }

                foreach (var photoName in PhotoService.GetNamePhotos(0, PhotoType.CategoryBig, true))
                {
                    res.Append(CheckExistingFile(PhotoType.CategoryBig, photoName, FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Big, photoName)));
                }

                foreach (var photoName in PhotoService.GetNamePhotos(0, PhotoType.CategorySmall, true))
                {
                    res.Append(CheckExistingFile(PhotoType.CategorySmall,photoName, FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Small, photoName)));
                }


                foreach (var photoName in PhotoService.GetNamePhotos(0, PhotoType.Color, true))
                {
                    res.Append(CheckExistingFile(PhotoType.Color, photoName, FoldersHelper.GetImageColorPathAbsolut(ColorImageType.Catalog, photoName)));
                }


                foreach (var photoName in PhotoService.GetNamePhotos(0, PhotoType.Color, true))
                {
                    res.Append(CheckExistingFile(PhotoType.Color, photoName, FoldersHelper.GetImageColorPathAbsolut(ColorImageType.Details, photoName)));
                }

                foreach (var photoName in PhotoService.GetNamePhotos(0, PhotoType.Brand, true))
                {
                    res.Append(CheckExistingFile(PhotoType.Brand, photoName, FoldersHelper.GetPathAbsolut(FolderType.BrandLogo, photoName)));
                }
                foreach (var photoName in PhotoService.GetNamePhotos(0, PhotoType.Carousel, true))
                {
                    res.Append(CheckExistingFile(PhotoType.Carousel, photoName, FoldersHelper.GetPathAbsolut(FolderType.Carousel, photoName)));
                }
                foreach (var photoName in PhotoService.GetNamePhotos(0, PhotoType.MenuIcon, true))
                {
                    res.Append(CheckExistingFile(PhotoType.MenuIcon, photoName, FoldersHelper.GetPathAbsolut(FolderType.MenuIcons, photoName)));
                }
                foreach (var photoName in PhotoService.GetNamePhotos(0, PhotoType.News, true))
                {
                    res.Append(CheckExistingFile(PhotoType.News, photoName, FoldersHelper.GetPathAbsolut(FolderType.News, photoName)));
                }
                foreach (var photoName in PhotoService.GetNamePhotos(0, PhotoType.Payment, true))
                {
                    res.Append(CheckExistingFile(PhotoType.Payment, photoName, FoldersHelper.GetPathAbsolut(FolderType.PaymentLogo, photoName)));
                }
                foreach (var photoName in PhotoService.GetNamePhotos(0, PhotoType.Shipping, true))
                {
                    res.Append(CheckExistingFile(PhotoType.Shipping, photoName, FoldersHelper.GetPathAbsolut(FolderType.ShippingLogo, photoName)));
                }
            }
            catch (Exception ex)
            {
                Debug.LogError(ex);
            }

            if (!chboxMakeNull.Checked)
            {
                lDBCleanupCompleted.Text = @"Analysis successfully completed";
            }

            lDBCleanupCompleted.Visible = true;

            lDBResult.Text = string.IsNullOrEmpty(res.ToString()) ? @"No items to correct" : res.ToString();
        }