Exemplo n.º 1
0
        public string GetContentExportFilePath()
        {
            var settings     = _orchardServices.WorkContext.CurrentSite.As <ContentSyncSettingsPart>();
            var contentTypes = _contentManager.GetContentTypeDefinitions().Select(ctd => ctd.Name).Except(settings.ExcludedContentTypes).ToList();
            var customSteps  = new List <string>();

            _customExportStep.Register(customSteps);
            customSteps = customSteps.Except(settings.ExcludedExportSteps).ToList();

            var exportActionContext = new ExportActionContext();
            var buildRecipeAction   = Resolve <BuildRecipeAction>(action =>
            {
                action.RecipeBuilderSteps = new List <IRecipeBuilderStep>
                {
                    Resolve <ContentStep>(contentStep =>
                    {
                        contentStep.SchemaContentTypes    = contentTypes;
                        contentStep.DataContentTypes      = contentTypes;
                        contentStep.VersionHistoryOptions = Orchard.Recipes.Models.VersionHistoryOptions.Published;
                    }),
                    Resolve <CustomStepsStep>(customStepsStep => customStepsStep.CustomSteps = customSteps),
                    Resolve <SettingsStep>()
                };
            });

            _importExportService.Export(exportActionContext, new IExportAction[] { buildRecipeAction });
            return(_importExportService.WriteExportFile(exportActionContext.RecipeDocument));
        }
Exemplo n.º 2
0
        public override dynamic UpdateEditor(dynamic shapeFactory, IUpdateModel updater)
        {
            var customSteps = new List <string>();

            _customExportStep.Register(customSteps);

            var viewModel = new CustomStepsViewModel {
                CustomSteps = customSteps.Select(x => new CustomStepEntry {
                    CustomStep = x
                }).ToList()
            };

            if (updater != null && updater.TryUpdateModel(viewModel, Prefix, null, null))
            {
                CustomSteps = viewModel.CustomSteps.Where(x => x.IsChecked).Select(x => x.CustomStep).ToList();
            }

            return(shapeFactory.EditorTemplate(TemplateName: "BuilderSteps/CustomSteps", Model: viewModel, Prefix: Prefix));
        }
Exemplo n.º 3
0
        public string GetContentExportFilePath()
        {
            var settings = _orchardServices.WorkContext.CurrentSite.As <ContentSyncSettingsPart>();

            var contentTypes = _contentManager.GetContentTypeDefinitions().Select(ctd => ctd.Name).Except(settings.ExcludedContentTypes).ToList();

            var customSteps = new List <string>();

            _customExportStep.Register(customSteps);
            customSteps = customSteps.Except(settings.ExcludedExportSteps).ToList();

            return(_importExportService.Export(contentTypes, new ExportOptions {
                CustomSteps = customSteps, ExportData = true, ExportMetadata = true, ExportSiteSettings = false, VersionHistoryOptions = VersionHistoryOptions.Published
            }));
        }
Exemplo n.º 4
0
        protected override DriverResult Editor(ContentSyncSettingsPart part, dynamic shapeHelper)
        {
            return(ContentShape("Parts_ContentSyncSettings_Edit",
                                () => {
                var customSteps = new List <string>();
                _customExportSteps.Register(customSteps);

                part.AllContentTypes = _contentManager.GetContentTypeDefinitions().OrderBy(ctd => ctd.Name).Select(ctd => new SelectableItem <string> {
                    Item = ctd.Name, IsSelected = part.ExcludedContentTypes.Contains(ctd.Name)
                }).ToList();
                part.AllExportSteps = customSteps.OrderBy(n => n).Select(cs => new SelectableItem <string> {
                    Item = cs, IsSelected = part.ExcludedExportSteps.Contains(cs)
                }).ToList();
                part.AllSiteSettings = GetExportableSettings().OrderBy(n => n).Select(p => new SelectableItem <string> {
                    Item = p, IsSelected = part.ExcludedSiteSettings.Contains(p)
                }).ToList();

                return shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: part, Prefix: Prefix);
            })
                   .OnGroup("Content Sync"));
        }
Exemplo n.º 5
0
        public ActionResult Export()
        {
            var customSteps = new List <string>();

            _customExportStep.Register(customSteps);

            var viewModel = new ExportViewModel {
                ContentTypes = new List <ContentTypeEntry>(),
                CustomSteps  = customSteps.Select(x => new CustomStepEntry {
                    CustomStep = x
                }).ToList()
            };

            foreach (var contentType in _contentDefinitionManager.ListTypeDefinitions().OrderBy(c => c.Name))
            {
                viewModel.ContentTypes.Add(new ContentTypeEntry {
                    ContentTypeName = contentType.Name
                });
            }

            return(View(viewModel));
        }