Пример #1
0
        protected void bthAddFile_Click(object sender, EventArgs e)
        {
            lblErrorFile.Text = string.Empty;

            if (!FileLoad.HasFile)
            {
                return;
            }

            try
            {
                if (!FileHelpers.CheckFileExtension(FileLoad.FileName, FileHelpers.eAdvantShopFileTypes.FileInRootFolder))
                {
                    lblErrorFile.Text = Resource.Admin_RootFiles_ErrorWrongFileExtesion;
                    return;
                }
                using (var file = FileLoad.PostedFile.InputStream)
                {
                    FileHelpers.SaveFile(SettingsGeneral.AbsolutePath + FileLoad.FileName, file);
                }
            }
            catch (Exception ex)
            {
                lblErrorFile.Text = ex.Message;
                Debug.LogError(ex, "at loading file in root directory");
                return;
            }

            Response.Redirect(UrlService.GetAdminAbsoluteLink("RootFiles.aspx"));
        }
Пример #2
0
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            if (!fuIcon.HasFile)
            {
                return;
            }
            if (!FileHelpers.CheckFileExtension(fuIcon.FileName, FileHelpers.eAdvantShopFileTypes.Image))
            {
                OnErr(new ErrorEventArgs {
                    Message = Resource.Admin_ErrorMessage_WrongImageExtension
                });
                return;
            }
            PhotoService.DeletePhotos(PaymentMethodID, PhotoType.Payment);
            var tempName = PhotoService.AddPhoto(new Photo(0, PaymentMethodID, PhotoType.Payment)
            {
                OriginName = fuIcon.FileName
            });

            if (string.IsNullOrWhiteSpace(tempName))
            {
                return;
            }
            using (System.Drawing.Image image = System.Drawing.Image.FromStream(fuIcon.FileContent))
            {
                FileHelpers.SaveResizePhotoFile(FoldersHelper.GetPathAbsolut(FolderType.PaymentLogo, tempName), SettingsPictureSize.PaymentIconWidth, SettingsPictureSize.PaymentIconHeight, image);
            }
            imgIcon.ImageUrl = FoldersHelper.GetPath(FolderType.PaymentLogo, tempName, true);
            imgIcon.Visible  = true;
        }
Пример #3
0
        protected bool Valid()
        {
            txtURL.Text = txtURL.Text.Replace("\'", "");
            if (string.IsNullOrEmpty(txtURL.Text))
            {
                MsgErr(Resource.Admin_m_News_NoID);
                return(false);
            }
            if (!UrlService.IsAvailableUrl(BrandId, ParamType.Brand, txtURL.Text))
            {
                MsgErr(Resource.Admin_SynonymExist);
                return(false);
            }
            if (string.IsNullOrEmpty(txtName.Text))
            {
                MsgErr(Resource.Admin_m_News_NoTitle);
                return(false);
            }

            int sort = 0;

            if (!int.TryParse(txtSortOrder.Text, out sort))
            {
                MsgErr(Resource.Admin_m_Brand_WrongSorting);
                return(false);
            }
            if (FileUpload1.HasFile && !FileHelpers.CheckFileExtension(FileUpload1.FileName, FileHelpers.eAdvantShopFileTypes.Image))
            {
                MsgErr(Resource.Admin_ErrorMessage_WrongImageExtension);
                return(false);
            }
            MsgErr(true); // Clean
            return(true);
        }
Пример #4
0
        public new bool Validate()
        {
            if (!(Demo.IsDemoEnabled || TrialService.IsTrialEnabled || SaasDataService.IsSaasEnabled))
            {
                try
                {
                    ActiveLic = PermissionAccsess.ActiveLic(txtKey.Text, txtUrl.Text, txtShopName.Text,
                                                            SettingsGeneral.SiteVersion, SettingsGeneral.SiteVersionDev);
                    SettingsLic.ActiveLic = ActiveLic;
                }
                catch (Exception ex)
                {
                    Debug.LogError(ex, "Error at license check at installer");
                }
                if (!ActiveLic)
                {
                    lblError.Text = Resources.Resource.Install_UserContols_ShopinfoView_Err_WrongKey;
                }
            }

            if (fuLogo.HasFile)
            {
                if (!FileHelpers.CheckFileExtension(Path.GetExtension(fuLogo.FileName), FileHelpers.eAdvantShopFileTypes.Image))
                {
                    lblError.Text = Resource.Admin_CommonSettings_InvalidLogoFormat;
                    return(false);
                }
            }

            if (fuFavicon.HasFile)
            {
                if (!FileHelpers.CheckFileExtension(Path.GetExtension(fuFavicon.FileName), FileHelpers.eAdvantShopFileTypes.Favicon))
                {
                    lblError.Text = Resource.Admin_CommonSettings_InvalidFaviconFormat;
                    return(false);
                }
            }


            var validList = new List <ValidElement>
            {
                new ValidElement()
                {
                    Control    = txtShopName,
                    ErrContent = ErrContent,
                    ValidType  = ValidType.Required,
                    Message    = Resources.Resource.Install_UserContols_ShopinfoView_Err_NeedName
                },
                new ValidElement()
                {
                    Control    = txtUrl,
                    ErrContent = ErrContent,
                    ValidType  = ValidType.Required,
                    Message    = Resources.Resource.Install_UserContols_ShopinfoView_Err_NeedUrl
                }
            };

            return(ValidationHelper.Validate(validList));
        }
Пример #5
0
        private void SaveNews()
        {
            MsgErr(true); // Clean
            try
            {
                var news = new NewsItem
                {
                    NewsID     = NewsId,
                    AddingDate = SQLDataHelper.GetDateTime(txtDate.Text + " " + txtTime.Text),
                    Title      = txtTitle.Text,
                    //Picture = file,
                    TextToPublication = FCKTextToPublication.Text,
                    TextAnnotation    = CKEditorControlAnnatation.Text,
                    TextToEmail       = string.Empty,//rbNo.Checked ? String.Empty : FCKTextToEmail.Text,
                    NewsCategoryID    = dboNewsCategory.SelectedValue.TryParseInt(),
                    ShowOnMainPage    = chkOnMainPage.Checked,
                    UrlPath           = txtStringID.Text,
                    //MetaId = SQLDataHelper.GetInt(hfMetaId.Text),
                    Meta = new MetaInfo
                    {
                        ObjId           = NewsId,
                        Title           = txtHeadTitle.Text,
                        H1              = txtH1.Text,
                        MetaKeywords    = txtMetaKeys.Text,
                        MetaDescription = txtMetaDescription.Text,
                        Type            = MetaType.News
                    }
                };

                news.UrlPath = txtStringID.Text;
                NewsService.UpdateNews(news);
                if (FileUpload1.HasFile)
                {
                    if (!FileHelpers.CheckFileExtension(FileUpload1.FileName, FileHelpers.eAdvantShopFileTypes.Image))
                    {
                        MsgErr(Resource.Admin_ErrorMessage_WrongImageExtension);
                        return;
                    }
                    PhotoService.DeletePhotos(NewsId, PhotoType.News);

                    var tempName = PhotoService.AddPhoto(new Photo(0, NewsId, PhotoType.News)
                    {
                        OriginName = FileUpload1.FileName
                    });
                    if (!string.IsNullOrWhiteSpace(tempName))
                    {
                        using (var image = Image.FromStream(FileUpload1.FileContent))
                            FileHelpers.SaveResizePhotoFile(FoldersHelper.GetPathAbsolut(FolderType.News, tempName), SettingsPictureSize.NewsImageWidth, SettingsPictureSize.NewsImageHeight, image);
                    }
                }
            }
            catch (Exception ex)
            {
                MsgErr(ex.Message + " SaveNews main");
                Debug.LogError(ex);
            }
        }
        private void CreateAction()
        {
            if (!IsValidData())
            {
                return;
            }

            var productId = ProductService.GetProductId(txtProductArtNo.Text);

            try
            {
                var action = new BuyInTimeProductModel()
                {
                    ProductId      = productId,
                    DiscountInTime = txtDiscount.Text.TryParseFloat(),
                    DateStart      = txtDateStart.Text.TryParseDateTime(),
                    DateExpired    = txtDateExpired.Text.TryParseDateTime(),
                    ShowMode       = ddlShowMode.SelectedValue.TryParseInt(),
                    ActionText     = ckeActionText.Text,
                    IsRepeat       = chkIsRepeat.Checked,
                    DaysRepeat     = txtDaysRepeat.Text.TryParseInt(1),
                    SortOrder      = txtSortOrder.Text.TryParseInt(0)
                };

                BuyInTimeService.Add(action);

                txtProductArtNo.Text = txtDiscount.Text = txtDateExpired.Text = txtDateStart.Text = string.Empty;

                if (fuPucture.HasFile)
                {
                    if (!FileHelpers.CheckFileExtension(fuPucture.FileName, FileHelpers.eAdvantShopFileTypes.Image))
                    {
                        MsgErr("Неправильный формат");
                        return;
                    }

                    var fileName = action.Id + Path.GetExtension(fuPucture.FileName);

                    if (!Directory.Exists(BuyInTimeService.PicturePath))
                    {
                        Directory.CreateDirectory(BuyInTimeService.PicturePath);
                    }

                    fuPucture.SaveAs(BuyInTimeService.PicturePath + fileName);
                    BuyInTimeService.UpdatePicture(action.Id, fileName);
                }
            }
            catch (Exception ex)
            {
                MsgErr("cant add" + ex);
            }

            txtProductArtNo.Text = string.Empty;
        }
Пример #7
0
        protected void bthAddCarousel_Click(object sender, EventArgs e)
        {
            lblErrorImage.Text = string.Empty;
            int sort;

            if (CarouselLoad.HasFile && !FileHelpers.CheckFileExtension(CarouselLoad.FileName, FileHelpers.eAdvantShopFileTypes.Image))
            {
                lblErrorImage.Text = Resource.Admin_ErrorMessage_WrongImageExtension;
                return;
            }

            int.TryParse(txtSortedCarousel.Text, out sort);

            if (string.IsNullOrEmpty(txtURL.Text))
            {
                txtURL.Text = "#";
            }

            var carousel = new Carousel {
                URL = txtURL.Text, SortOrder = sort, Enabled = true
            };
            int id = CarouselService.AddCarousel(carousel);

            try
            {
                if (CarouselLoad.HasFile)
                {
                    var tempName = PhotoService.AddPhoto(new Photo(0, id, PhotoType.Carousel)
                    {
                        OriginName = CarouselLoad.FileName
                    });
                    if (!string.IsNullOrWhiteSpace(tempName))
                    {
                        using (System.Drawing.Image image = System.Drawing.Image.FromStream(CarouselLoad.PostedFile.InputStream))
                        {
                            FileHelpers.SaveResizePhotoFile(FoldersHelper.GetPathAbsolut(FolderType.Carousel, tempName), SettingsPictureSize.CarouselBigWidth, SettingsPictureSize.CarouselBigHeight, image);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.LogError(ex, "Attempt to load not image file");
            }

            txtURL.Text            = string.Empty;
            txtSortedCarousel.Text = string.Empty;
            TrialService.TrackEvent(TrialEvents.AddCarousel, "");
            Response.Redirect(UrlService.GetAdminAbsoluteLink("Carousel.aspx"));
        }
Пример #8
0
        public bool SaveData()
        {
            if (!ValidateData())
            {
                return(false);
            }

            if (SettingsMain.ShopName != txtShopName.Text)
            {
                TrialService.TrackEvent(TrialEvents.ChangeShopName, "");
            }

            if (SettingsMain.Phone != txtPhone.Text)
            {
                TrialService.TrackEvent(TrialEvents.ChangePhoneNumber, "");
            }

            if (SettingsMain.SiteUrl != txtShopURL.Text)
            {
                TrialService.TrackEvent(TrialEvents.ChangeDomain, "");
            }

            SettingsMain.SiteUrl         = txtShopURL.Text.StartsWith("http://") || txtShopURL.Text.StartsWith("https://") ? txtShopURL.Text : "http://" + txtShopURL.Text;
            SettingsMain.ShopName        = txtShopName.Text;
            SettingsMain.LogoImageAlt    = txtImageAlt.Text;
            SettingsMain.AdminDateFormat = txtFormat.Text;
            SettingsMain.ShortDateFormat = txtShortFormat.Text;
            SettingsMain.SellerCountryId = ddlCountry.SelectedValue != string.Empty ? SQLDataHelper.GetInt(ddlCountry.SelectedValue) : 0;
            SettingsMain.Phone           = txtPhone.Text;
            SettingsMain.City            = txtCity.Text;
            SettingsMain.EnableCaptcha   = ckbEnableCheckConfirmCode.Checked;
            SettingsMain.EnableInplace   = ckbEnableInplaceEditor.Checked;

            SettingsDesign.DisplayToolBarBottom = ckbDisplayToolBarBottom.Checked;

            SettingsDesign.DisplayCityInTopPanel = ckbDisplayCityInTopPanel.Checked;
            SettingsDesign.DisplayCityBubble     = ckbDisplayCityBubble.Checked;

            SettingsMain.EnablePhoneMask = ckbEnablePhoneMask.Checked;

            if (ddlRegion.Enabled)
            {
                SettingsMain.SellerRegionId = ddlRegion.SelectedValue != string.Empty ? SQLDataHelper.GetInt(ddlRegion.SelectedValue) : 0;
            }

            if (fuLogoImage.HasFile)
            {
                if (FileHelpers.CheckFileExtension(fuLogoImage.FileName, FileHelpers.eAdvantShopFileTypes.Image))
                {
                    FileHelpers.CreateDirectory(FoldersHelper.GetPathAbsolut(FolderType.ImageTemp));
                    FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.Pictures, SettingsMain.LogoImageName));
                    var newFile = fuLogoImage.FileName.FileNamePlusDate("logo");
                    SettingsMain.LogoImageName = newFile;
                    fuLogoImage.SaveAs(FoldersHelper.GetPathAbsolut(FolderType.Pictures, newFile));
                    TrialService.TrackEvent(TrialEvents.ChangeLogo, "");
                }
                else
                {
                    ErrMessage = Resource.Admin_CommonSettings_InvalidLogoFormat;
                    return(false);
                }
            }

            if (fuFaviconImage.HasFile)
            {
                FileHelpers.CreateDirectory(FoldersHelper.GetPathAbsolut(FolderType.ImageTemp));

                if (FileHelpers.CheckFileExtension(fuFaviconImage.FileName, FileHelpers.eAdvantShopFileTypes.Favicon))
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.Pictures, SettingsMain.FaviconImageName));
                    var newFile = fuFaviconImage.FileName.FileNamePlusDate("favicon");
                    SettingsMain.FaviconImageName = newFile;
                    fuFaviconImage.SaveAs(FoldersHelper.GetPathAbsolut(FolderType.Pictures, newFile));
                }
                else
                {
                    ErrMessage = Resource.Admin_CommonSettings_InvalidFaviconFormat;
                    return(false);
                }
            }

            LoadData();
            return(true);
        }
Пример #9
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);
        }
Пример #10
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();
            }
        }