Exemplo n.º 1
0
        public virtual void Seed(DefaultObjectContext context)
        {
            Guard.ArgumentNotNull(() => context);

            _ctx = context;
            _data.Initialize(_ctx);

            _ctx.Configuration.AutoDetectChangesEnabled = false;
            _ctx.Configuration.ValidateOnSaveEnabled    = false;
            _ctx.HooksEnabled = false;

            _config.ProgressMessageCallback("Progress.CreatingRequiredData");

            // special mandatory (non-visible) settings
            _ctx.MigrateSettings(x =>
            {
                x.Add("Media.Images.SiteInDB", _config.StoreMediaInDB);
            });
            Populate("PopulatePictures", _data.Pictures());
            Populate("PopulateSites", PopulateSites);
            Populate("PopulateArticleTemplates", _data.ModelTemplates());
            Populate("InstallLanguages", () => PopulateLanguage(_config.Language));
            Populate("PopulateMeasureDimensions", _data.MeasureDimensions());
            Populate("PopulateMeasureWeights", _data.MeasureWeights());
            Populate("PopulateTaxCategories", PopulateTaxCategories);
            Populate("PopulateCountriesAndStates", PopulateCountriesAndStates);
            Populate("PopulateDeliveryTimes", _data.DeliveryTimes());
            Populate("PopulateUsersAndUsers", () => PopulateUsersAndUsers(_config.DefaultUserName, _config.DefaultUserPassword));
            Populate("PopulateEmailAccounts", _data.EmailAccounts());
            Populate("PopulateMessageTemplates", _data.MessageTemplates());
            Populate("PopulateTopics", _data.Topics());
            Populate("PopulateSettings", PopulateSettings);
            Populate("PopulateLocaleResources", PopulateLocaleResources);
            Populate("PopulateActivityLogTypes", _data.ActivityLogTypes());
            Populate("PopulateUsersAndUsers", () => HashDefaultUserPassword(_config.DefaultUserName, _config.DefaultUserPassword));
            Populate("PopulateScheduleTasks", _data.ScheduleTasks());

            if (_config.SeedSampleData)
            {
                _config.ProgressMessageCallback("Progress.CreatingSampleData");
                Populate("PopulateCategories", PopulateCategories);
                Populate("PopulateArticles", PopulateArticles);
                Populate("PopulateForumsGroups", _data.ForumGroups());
                Populate("PopulateForums", _data.Forums());;
                Populate("PopulatePolls", _data.Polls());
            }

            Populate("MovePictures", MovePictures);
        }
Exemplo n.º 2
0
        public virtual void Seed(SmartObjectContext context)
        {
            Guard.NotNull(context, nameof(context));

            _ctx = context;
            _data.Initialize(_ctx);

            _ctx.Configuration.AutoDetectChangesEnabled = false;
            _ctx.Configuration.ValidateOnSaveEnabled    = false;
            _ctx.HooksEnabled = false;

            _config.ProgressMessageCallback("Progress.CreatingRequiredData");

            // special mandatory (non-visible) settings
            _ctx.MigrateSettings(x =>
            {
                x.Add("Media.Storage.Provider", _config.StoreMediaInDB ? DatabaseMediaStorageProvider.SystemName : FileSystemMediaStorageProvider.SystemName);
            });

            Populate("PopulatePictures", _data.Pictures());
            Populate("PopulateCurrencies", PopulateCurrencies);
            Populate("PopulateStores", PopulateStores);
            Populate("InstallLanguages", () => PopulateLanguage(_config.Language));
            Populate("PopulateMeasureDimensions", _data.MeasureDimensions());
            Populate("PopulateMeasureWeights", _data.MeasureWeights());
            Populate("PopulateTaxCategories", PopulateTaxCategories);
            Populate("PopulateCountriesAndStates", PopulateCountriesAndStates);
            Populate("PopulateShippingMethods", PopulateShippingMethods);
            Populate("PopulateMembershipPlans", PopulateMembershipPlans);
            Populate("PopulateDeliveryTimes", _data.DeliveryTimes());
            Populate("PopulateCustomersAndUsers", () => PopulateCustomersAndUsers(_config.DefaultUserName, _config.DefaultUserPassword));
            Populate("PopulateEmailAccounts", _data.EmailAccounts());
            Populate("PopulateMessageTemplates", PopulateMessageTemplates);
            Populate("PopulateTopics", PopulateTopics);
            Populate("PopulateSettings", PopulateSettings);
            Populate("PopulateActivityLogTypes", _data.ActivityLogTypes());
            Populate("PopulateCustomersAndUsers", () => HashDefaultCustomerPassword(_config.DefaultUserName, _config.DefaultUserPassword));
            Populate("PopulateProductTemplates", _data.ProductTemplates());
            Populate("PopulateCategoryTemplates", _data.CategoryTemplates());
            Populate("PopulateManufacturerTemplates", PopulateManufacturerTemplates);
            Populate("PopulateScheduleTasks", _data.ScheduleTasks());
            Populate("PopulateLocaleResources", PopulateLocaleResources);

            if (_config.SeedSampleData)
            {
                _logger.Info("Seeding sample data");

                _config.ProgressMessageCallback("Progress.CreatingSampleData");

                Populate("PopulateSpecificationAttributes", _data.SpecificationAttributes());
                Populate("PopulateProductAttributes", _data.ProductAttributes());
                Populate("PopulateProductAttributeOptionsSets", _data.ProductAttributeOptionsSets());
                Populate("PopulateProductAttributeOptions", _data.ProductAttributeOptions());
                Populate("PopulateCategories", PopulateCategories);
                Populate("PopulateManufacturers", PopulateManufacturers);
                Populate("PopulateProducts", PopulateProducts);
                Populate("PopulateProductBundleItems", _data.ProductBundleItems());
                Populate("PopulateProductVariantAttributes", _data.ProductVariantAttributes());
                Populate("ProductVariantAttributeCombinations", _data.ProductVariantAttributeCombinations());
                Populate("PopulateProductTags", _data.ProductTags());
                Populate("PopulateForumsGroups", _data.ForumGroups());
                Populate("PopulateForums", _data.Forums());
                Populate("PopulateDiscounts", _data.Discounts());
                Populate("PopulateBlogPosts", PopulateBlogPosts);
                Populate("PopulateNews", PopulateNews);
                Populate("PopulatePolls", _data.Polls());
            }

            Populate("MovePictures", MoveMedia);

            // Perf
            _ctx.DetachAll();
        }