コード例 #1
0
        public ActionResult ExportPOST(ExportViewModel viewModel)
        {
            if (!Services.Authorizer.Authorize(Permissions.Export, T("Not allowed to export.")))
            {
                return(new HttpUnauthorizedResult());
            }

            var actions = _exportActions.OrderByDescending(x => x.Priority).ToList();

            foreach (var action in actions)
            {
                action.UpdateEditor(Services.New, this);
            }

            var exportActionContext = new ExportActionContext();

            _importExportService.Export(exportActionContext, actions);

            var recipeDocument = exportActionContext.RecipeDocument;
            var exportFilePath = _importExportService.WriteExportFile(recipeDocument);
            var recipe         = _recipeParser.ParseRecipe(recipeDocument);
            var exportFileName = recipe.GetExportFileName();

            return(File(exportFilePath, "text/xml", exportFileName));
        }
コード例 #2
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));
        }
コード例 #3
0
        public string Export(IList <int> contentItemIds)
        {
            var context = new ExportActionContext();

            _specificContentStep.DataContentIds        = contentItemIds;
            _specificContentStep.VersionHistoryOptions = VersionHistoryOptions.Latest;
            context.RecipeDocument = _recipeBuilder.Build(new List <IRecipeBuilderStep> {
                _specificContentStep
            });
            return(_importExportService.WriteExportFile(context.RecipeDocument));
        }
コード例 #4
0
ファイル: ImportExportCommands.cs プロジェクト: itc20/orchard
        public void ExportFile()
        {
            // Impersonate the Site owner.
            ImpersonateSuperUser();

            IEnumerable <IExportAction> actions;

            if (!IsAnySwitchDefined("ConfigFilename", "Types", "Metadata", "Version", "SiteSettings", "Steps"))
            {
                // Get default configured actions.
                actions = GetDefaultConfiguration();
            }
            else
            {
                // Read config file if specified.
                var configurationDocument = UpdateExportConfiguration(ReadExportConfigurationFile(ConfigFilename), Types, Metadata, Data, Version, SiteSettings, Steps);

                // Get all the steps based on the configuration.
                actions = _importExportService.ParseExportActions(configurationDocument);
            }

            Context.Output.WriteLine(T("Export starting..."));
            var exportContext = new ExportActionContext();

            _importExportService.Export(exportContext, actions);
            var exportFilePath = _importExportService.WriteExportFile(exportContext.RecipeDocument);

            if (!String.IsNullOrEmpty(Filename))
            {
                var directory = Path.GetDirectoryName(Filename);
                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }
                File.Copy(exportFilePath, Filename, overwrite: true);
                exportFilePath = Filename;
            }

            Context.Output.WriteLine(T("Export completed at {0}", exportFilePath));
        }