Пример #1
0
        private void ImportBlog(WordPressImportData data)
        {
            var    db            = Factory.GetDatabase(data.DatabaseName);
            var    options       = BuildWpImportOptions(data);
            var    postProvider  = new MediaItemBasedProvider(data.DataSourceId, db);
            var    importManager = new WpImportManager(db, postProvider, options);
            string jobHandle     = Context.Job.Handle.ToString();

            LogMessage("Reading import item", jobHandle);

            var templateMappingItem = db.GetItem(data.TemplateMappingItemId);
            var templatesMapping    = new TemplatesMapping(templateMappingItem);

            var blogParent = db.GetItem(data.ParentId);

            if (blogParent != null)
            {
                LogMessage("Creating blog", jobHandle);
                var blogRoot = importManager.CreateBlogRoot(blogParent, data.BlogName, data.BlogEmail, templatesMapping.BlogRootTemplate);

                LogTotal(importManager.Posts.Count, jobHandle);
                LogMessage("Importing posts", jobHandle);
                importManager.ImportPosts(blogRoot, templatesMapping, (itemName, count) =>
                {
                    LogMessage("Importing entry " + itemName, jobHandle);
                    LogProgress(count, jobHandle);
                });
            }
            else
            {
                LogMessage(String.Format("Parent item for blog root could not be found ({0})", data.ParentId), jobHandle);
            }
        }
Пример #2
0
        private WpImportOptions BuildWpImportOptions(WordPressImportData data)
        {
            var options = new WpImportOptions
            {
                IncludeComments   = data.ImportComments,
                IncludeCategories = data.ImportCategories,
                IncludeTags       = data.ImportTags
            };

            return(options);
        }
Пример #3
0
        public string ImportItems(WordPressImportData data)
        {
            var options = new JobOptions("Creating and importing blog", "WeBlog", Context.Site.Name, this, "ImportBlog", new[] { data });

            // Init NVelocity before starting the job, in case something in the job uses it (creates items with a workflow that uses the Extended Email Action)
            Velocity.Init();

            var job = JobManager.Start(options);
            job.Status.Total = 0;
            return job.Handle.ToString();
        }
Пример #4
0
        public string ImportItems(WordPressImportData data)
        {
            var options = new JobOptions("Creating and importing blog", "WeBlog", Context.Site.Name, this, "ImportBlog", new[] { data });

            // Init NVelocity before starting the job, in case something in the job uses it (creates items with a workflow that uses the Extended Email Action)
            Velocity.Init();

            var job = JobManager.Start(options);

            job.Status.Total = 0;
            return(job.Handle.ToString());
        }
Пример #5
0
        public string ImportItems(WordPressImportData data)
        {
            var options = new
#if FEATURE_JOB_ABSTRACTIONS
                          DefaultJobOptions(
#else
                          JobOptions(
#endif
                "Creating and importing blog", "WeBlog", Context.Site.Name, this, "ImportBlog", new[] { data });

            var job = JobManager.Start(options);

            job.Status.Total = 0;
            return(job.Handle.ToString());
        }
Пример #6
0
 private WpImportOptions BuildWpImportOptions(WordPressImportData data)
 {
     var options = new WpImportOptions
     {
         IncludeComments = data.ImportComments,
         IncludeCategories = data.ImportCategories,
         IncludeTags = data.ImportTags
     };
     return options;
 }
Пример #7
0
        private void ImportBlog(WordPressImportData data)
        {
            var db = Factory.GetDatabase(data.DatabaseName);
            var options = BuildWpImportOptions(data);
            var postProvider = new MediaItemBasedProvider(data.DataSourceId, db);
            var importManager = new WpImportManager(db, postProvider, options);
            string jobHandle = Context.Job.Handle.ToString();
            LogMessage("Reading import item", jobHandle);

            var templateMappingItem = db.GetItem(data.TemplateMappingItemId);
            var templatesMapping = new TemplatesMapping(templateMappingItem);

            var blogParent = db.GetItem(data.ParentId);
            if (blogParent != null)
            {
                LogMessage("Creating blog", jobHandle);
                var blogRoot = importManager.CreateBlogRoot(blogParent, data.BlogName, data.BlogEmail, templatesMapping.BlogRootTemplate);

                LogTotal(importManager.Posts.Count, jobHandle);
                LogMessage("Importing posts", jobHandle);
                importManager.ImportPosts(blogRoot, templatesMapping, (itemName, count) =>
                {
                    LogMessage("Importing entry " + itemName, jobHandle);
                    LogProgress(count, jobHandle);
                });
            }
            else
            {
                LogMessage(String.Format("Parent item for blog root could not be found ({0})", data.ParentId), jobHandle);
            }
        }