예제 #1
0
        // Categories
        private void ImportCategories()
        {
            Header("Importing Categories");

            data.bvc2004Entities oldDatabase = GetOldDatabase();
            foreach (data.bvc_Category old in oldDatabase.bvc_Category.OrderBy(y => y.ParentID).ThenBy(y => y.SortOrder))
            {
                wl("Cat: " + old.Name + " (child of " + old.ParentID + ")");

                CategoryDTO cat = new CategoryDTO();
                cat.BannerImageUrl = System.IO.Path.GetFileName(old.BannerImageURL);
                cat.Bvin = old.ID.ToString();
                cat.Criteria = string.Empty;
                cat.CustomerChangeableSortOrder = false;
                cat.CustomPageId = string.Empty;
                cat.CustomPageLayout = CustomPageLayoutTypeDTO.WithSideBar;
                cat.CustomPageOpenInNewWindow = old.CustomPageNewWindow == 1;
                cat.CustomPageUrl = old.CustomPageURL;
                cat.Description = old.Description;
                switch (old.DisplaySortOrder)
                {
                    case 0:
                        cat.DisplaySortOrder = CategorySortOrderDTO.None;
                        break;
                    case 1:
                        cat.DisplaySortOrder = CategorySortOrderDTO.ManualOrder;
                        break;
                    case 2:
                        cat.DisplaySortOrder = CategorySortOrderDTO.ProductName;
                        break;
                    case 3:
                        cat.DisplaySortOrder = CategorySortOrderDTO.ProductPriceAscending;
                        break;
                    case 4:
                        cat.DisplaySortOrder = CategorySortOrderDTO.ProductPriceDescending;
                        break;
                    case 5:
                        cat.DisplaySortOrder = CategorySortOrderDTO.ManufacturerName;
                        break;
                }
                cat.Hidden = old.Hidden == 1;
                cat.ImageUrl = System.IO.Path.GetFileName(old.ImageURL);
                cat.Keywords = string.Empty;
                cat.LastUpdatedUtc = DateTime.UtcNow;
                cat.LatestProductCount = old.LatestProductCount;
                cat.MetaDescription = old.MetaDescription;
                cat.MetaKeywords = old.MetaKeywords;
                cat.MetaTitle = old.MetaTitle;
                cat.Name = old.Name;
                cat.Operations = new List<ApiOperation>();
                cat.ParentId = old.ParentID.ToString();
                cat.PostContentColumnId = string.Empty;
                cat.PreContentColumnId = string.Empty;
                cat.PreTransformDescription = old.Description;
                cat.RewriteUrl = string.Empty;
                cat.ShowInTopMenu = old.ShowInTopMenu == 1;
                cat.ShowTitle = old.ShowTitle == 1;
                cat.SortOrder = old.SortOrder;
                cat.SourceType = CategorySourceTypeDTO.Manual;
                switch (old.SourceType)
                {
                    case 0:
                        cat.SourceType = CategorySourceTypeDTO.Manual;
                        break;
                    case 1:
                        cat.SourceType = CategorySourceTypeDTO.ByRules;
                        break;
                    case 2:
                        cat.SourceType = CategorySourceTypeDTO.CustomLink;
                        break;
                }
                switch(old.DisplayType)
                {
                    case 1:
                        cat.TemplateName = "Grid";
                        break;
                    case 2:
                        cat.TemplateName = "Simple List";
                        break;
                    case 3:
                        cat.TemplateName = "Detailed List";
                        break;
                    default:
                        cat.TemplateName = "Grid";
                        break;
                }

                Api bv6proxy = GetBV6Proxy();
                var res = bv6proxy.CategoriesCreate(cat);
                if (res != null)
                {
                    if (res.Errors.Count() > 0)
                    {
                        DumpErrors(res.Errors);
                        wl("FAILED");
                    }
                    else
                    {
                        string bannerImageSource = old.BannerImageURL;
                        string imageSource = old.ImageURL;
                        MigrateCategoryBanner(old.ID, bannerImageSource);
                        MigrateCategoryImage(old.ID, imageSource);
                        wl("SUCCESS");
                    }
                }
            }
        }
예제 #2
0
        // DTO
        public void FromDto(CategoryDTO dto)
        {
            if (dto == null) return;

            this.BannerImageUrl = dto.BannerImageUrl ?? string.Empty;
            this.Bvin = dto.Bvin ?? string.Empty;
            this.Criteria = dto.Criteria ?? string.Empty;
            this.CustomerChangeableSortOrder = this.CustomerChangeableSortOrder;
            this.CustomPageId = dto.CustomPageId ?? string.Empty;
            this.CustomPageLayout = (CustomPageLayoutType)((int)dto.CustomPageLayout);
            this.CustomPageOpenInNewWindow = dto.CustomPageOpenInNewWindow;
            this.CustomPageUrl = dto.CustomPageUrl ?? string.Empty;
            this.Description = dto.Description ?? string.Empty;
            this.DisplaySortOrder = (CategorySortOrder)((int)dto.DisplaySortOrder);
            this.Hidden = dto.Hidden;
            this.ImageUrl = dto.ImageUrl ?? string.Empty;
            this.Keywords = dto.Keywords ?? string.Empty;
            this.LastUpdatedUtc = dto.LastUpdatedUtc;
            this.LatestProductCount = dto.LatestProductCount;
            this.MetaDescription = dto.MetaDescription ?? string.Empty;
            this.MetaKeywords = dto.MetaKeywords ?? string.Empty;
            this.MetaTitle = dto.MetaTitle ?? string.Empty;
            this.Name = dto.Name ?? string.Empty;
            this.ParentId = dto.ParentId ?? string.Empty;
            this.PostContentColumnId = dto.PostContentColumnId ?? string.Empty;
            this.PreContentColumnId = dto.PreContentColumnId ?? string.Empty;
            this.PreTransformDescription = dto.PreTransformDescription ?? string.Empty;
            this.RewriteUrl = dto.RewriteUrl ?? string.Empty;
            this.ShowInTopMenu = dto.ShowInTopMenu;
            this.ShowTitle = dto.ShowTitle;
            this.SortOrder = dto.SortOrder;
            this.SourceType = (CategorySourceType)((int)dto.SourceType);
            this.StoreId = dto.StoreId;
            this.TemplateName = dto.TemplateName ?? string.Empty;            
        }
예제 #3
0
        public CategoryDTO ToDto()
        {
            CategoryDTO dto = new CategoryDTO();

            dto.BannerImageUrl = this.BannerImageUrl;
            dto.Bvin = this.Bvin;
            dto.Criteria = this.Criteria;
            dto.CustomerChangeableSortOrder = this.CustomerChangeableSortOrder;
            dto.CustomPageId = this.CustomPageId;
            dto.CustomPageLayout = (CustomPageLayoutTypeDTO)((int)this.CustomPageLayout);
            dto.CustomPageOpenInNewWindow = this.CustomPageOpenInNewWindow;
            dto.CustomPageUrl = this.CustomPageUrl;
            dto.Description = this.Description;
            dto.DisplaySortOrder = (CategorySortOrderDTO)((int)this.DisplaySortOrder);
            dto.Hidden = this.Hidden;
            dto.ImageUrl = this.ImageUrl;
            dto.Keywords = this.Keywords;
            dto.LastUpdatedUtc = this.LastUpdatedUtc;
            dto.LatestProductCount = this.LatestProductCount;
            dto.MetaDescription = this.MetaDescription;
            dto.MetaKeywords = this.MetaKeywords;
            dto.MetaTitle = this.MetaTitle;
            dto.Name = this.Name;
            dto.ParentId = this.ParentId;
            dto.PostContentColumnId = this.PostContentColumnId;
            dto.PreContentColumnId = this.PreContentColumnId;
            dto.PreTransformDescription = this.PreTransformDescription;
            dto.RewriteUrl = this.RewriteUrl;
            dto.ShowInTopMenu = this.ShowInTopMenu;
            dto.ShowTitle = this.ShowTitle;
            dto.SortOrder = this.SortOrder;
            dto.SourceType = (CategorySourceTypeDTO)((int)this.SourceType);
            dto.StoreId = this.StoreId;
            dto.TemplateName = this.TemplateName;            

            return dto;
        }
예제 #4
0
        // Categories
        private void ImportCategories()
        {
            Header("Importing Categories");

            foreach (data.bvc_Category old in oldDatabase.bvc_Category)
            {
                wl("Category: " + old.Name);

                CategoryDTO cat = new CategoryDTO();
                cat.BannerImageUrl = System.IO.Path.GetFileName(old.BannerImageURL);
                cat.Bvin = old.bvin;
                cat.Criteria = old.Criteria;
                cat.CustomerChangeableSortOrder = old.CustomerChangeableSortOrder;
                cat.CustomPageId = old.CustomPageId;
                cat.CustomPageLayout = CustomPageLayoutTypeDTO.WithSideBar;
                cat.CustomPageOpenInNewWindow = old.CustomPageNewWindow == 1;
                cat.CustomPageUrl = old.CustomPageURL;
                cat.Description = old.Description;
                switch (old.DisplaySortOrder)
                {
                    case 0:
                        cat.DisplaySortOrder = CategorySortOrderDTO.None;
                        break;
                    case 1:
                        cat.DisplaySortOrder = CategorySortOrderDTO.ManualOrder;
                        break;
                    case 2:
                        cat.DisplaySortOrder = CategorySortOrderDTO.ProductName;
                        break;
                    case 3:
                        cat.DisplaySortOrder = CategorySortOrderDTO.ProductPriceAscending;
                        break;
                    case 4:
                        cat.DisplaySortOrder = CategorySortOrderDTO.ProductPriceDescending;
                        break;
                    case 5:
                        cat.DisplaySortOrder = CategorySortOrderDTO.ManufacturerName;
                        break;
                }
                cat.Hidden = old.Hidden == 1;
                cat.ImageUrl = System.IO.Path.GetFileName(old.ImageURL);
                cat.Keywords = old.Keywords;
                cat.LastUpdatedUtc = old.LastUpdated;
                cat.LatestProductCount = old.LatestProductCount;
                cat.MetaDescription = old.MetaDescription;
                cat.MetaKeywords = old.MetaKeywords;
                cat.MetaTitle = old.MetaTitle;
                cat.Name = old.Name;
                cat.Operations = new List<ApiOperation>();
                cat.ParentId = old.ParentID;
                cat.PostContentColumnId = old.PostContentColumnId;
                if (cat.PostContentColumnId.Trim() == "-None -") cat.PostContentColumnId = string.Empty;
                cat.PreContentColumnId = old.PreContentColumnId;
                if (cat.PreContentColumnId.Trim() == "-None -") cat.PreContentColumnId = string.Empty;
                cat.PreTransformDescription = old.PreTransformDescription;
                cat.RewriteUrl = old.RewriteUrl;
                cat.ShowInTopMenu = old.ShowInTopMenu == 1;
                cat.ShowTitle = old.ShowTitle == 1;
                cat.SortOrder = old.SortOrder;
                cat.SourceType = CategorySourceTypeDTO.Manual;
                switch (old.SourceType)
                {
                    case 0:
                        cat.SourceType = CategorySourceTypeDTO.Manual;
                        break;
                    case 1:
                        cat.SourceType = CategorySourceTypeDTO.ByRules;
                        break;
                    case 2:
                        cat.SourceType = CategorySourceTypeDTO.CustomLink;
                        break;
                }
                cat.TemplateName = old.TemplateName;

                Api bv6proxy = GetBV6Proxy();
                var res = bv6proxy.CategoriesCreate(cat);
                if (res != null)
                {
                    if (res.Errors.Count() > 0)
                    {
                        DumpErrors(res.Errors);
                        wl("FAILED");
                    }
                    else
                    {
                        string bannerImageSource = old.BannerImageURL;
                        string imageSource = old.ImageURL;
                        MigrateCategoryBanner(old.bvin, bannerImageSource);
                        MigrateCategoryImage(old.bvin, imageSource);
                        wl("SUCCESS");
                    }
                }
            }
        }