public async void Can_Export_All()
        {
            Scaffold.Config();

            ImportExportModel export = await _importExportService.Export();

            Assert.NotNull(export);
            Assert.NotEmpty(export.User2UserGroup);
            Assert.NotEmpty(export.UserGroupPermissions);
            Assert.NotEmpty(export.UserGroups);
        }
        public async void Can_Export_All()
        {
            var  model  = Scaffold.ReadFromJsonFile <ImportExportModel>(@"Config.json");
            bool import = await _importExportService.Import(model);

            Assert.True(import);

            ImportExportModel export = await _importExportService.Export();

            Assert.NotNull(export);
            Assert.NotEmpty(export.User2UserGroup);
            Assert.NotEmpty(export.UserGroupPermissions);
            Assert.NotEmpty(export.UserGroups);
        }
Ejemplo n.º 3
0
        public ActionResult ExportPOST()
        {
            if (!Services.Authorizer.Authorize(Permissions.Export, T("Not allowed to export.")))
            {
                return(new HttpUnauthorizedResult());
            }

            var viewModel = new ExportViewModel {
                ContentTypes = new List <ContentTypeEntry>(),
                CustomSteps  = new List <CustomStepEntry>()
            };

            UpdateModel(viewModel);
            var contentTypesToExport = viewModel.ContentTypes.Where(c => c.IsChecked).Select(c => c.ContentTypeName);
            var customSteps          = viewModel.CustomSteps.Where(c => c.IsChecked).Select(c => c.CustomStep);

            var exportOptions = new ExportOptions {
                ExportMetadata     = viewModel.Metadata,
                ExportSiteSettings = viewModel.SiteSettings,
                CustomSteps        = customSteps
            };

            if (viewModel.Data)
            {
                exportOptions.ExportData            = true;
                exportOptions.VersionHistoryOptions = (VersionHistoryOptions)Enum.Parse(typeof(VersionHistoryOptions), viewModel.DataImportChoice, true);
            }
            var exportFilePath = _importExportService.Export(contentTypesToExport, exportOptions);

            return(File(exportFilePath, "text/xml", "export.xml"));
        }
        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));
        }
Ejemplo n.º 5
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));
        }
Ejemplo n.º 6
0
        public async Task <IHttpActionResult> Get()
        {
            try
            {
                ImportExportModel export = await _exportService.Export();

                return(Json(export, ViewHelpers.CamelCase));
            }
            catch (Exception ex)
            {
                const string error = "Error exporting workflow configuration";
                Log.Error(error, ex);
                return(Content(HttpStatusCode.InternalServerError, ViewHelpers.ApiException(ex, error)));
            }
        }
Ejemplo n.º 7
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
            }));
        }
Ejemplo n.º 8
0
        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));
        }