コード例 #1
0
        public async void Can_Import_Config()
        {
            var  model  = Scaffold.ReadFromJsonFile <ImportExportModel>(@"Config.json");
            bool import = await _importExportService.Import(model);

            Assert.True(import);
        }
コード例 #2
0
        public void ImportSucceedsWhenRecipeContainsImportSteps()
        {
            Assert.DoesNotThrow(() => _importExportService.Import(
                                    @"<Orchard>
    <Recipe>
    <Name>MyModuleInstaller</Name>
    </Recipe>
    <Settings />
</Orchard>"));
        }
コード例 #3
0
ファイル: ImportExportCommands.cs プロジェクト: itc20/orchard
        public void ImportFile()
        {
            if (String.IsNullOrEmpty(Filename))
            {
                Context.Output.WriteLine(T("Invalid file path"));
                return;
            }

            if (!File.Exists(Filename))
            {
                Context.Output.WriteLine(T("File not found."));
                return;
            }

            // Impersonate the Site owner.
            ImpersonateSuperUser();

            // Read config file if specified.
            var configurationDocument = ReadImportConfigurationFile(ConfigFilename);

            // Configure any steps based on the configuration.
            _importExportService.ConfigureImportActions(new ConfigureImportActionsContext(configurationDocument));

            // Import the file.
            _importExportService.Import(File.ReadAllText(Filename));

            Context.Output.WriteLine(T("Import running..."));
        }
コード例 #4
0
        public ActionResult ImportPOST()
        {
            if (!Services.Authorizer.Authorize(Permissions.Import, T("Not allowed to import.")))
            {
                return(new HttpUnauthorizedResult());
            }

            var actions   = _importActions.OrderByDescending(x => x.Priority).ToList();
            var viewModel = new ImportViewModel {
                Actions = actions.Select(x => new ImportActionViewModel {
                    Editor = x.UpdateEditor(Services.New, this)
                }).Where(x => x != null).ToList()
            };

            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            var context     = new ImportActionContext();
            var executionId = _importExportService.Import(context, actions);

            return(!String.IsNullOrEmpty(executionId)
                ? RedirectToAction("ImportResult", new { executionId = context.ExecutionId })
                : RedirectToAction("Import"));
        }
コード例 #5
0
        public MigrationExectutionSummary ExecuteMigrations(IList <string> migrationNames)
        {
            var result = new MigrationExectutionSummary();

            foreach (var recipeFile in GetAvailableRecipeFiles())
            {
                var migrationName = GetMigrationNameFromFileName(recipeFile);
                if (migrationNames.Contains(migrationName))
                {
                    var mappedPath  = _virtualPathProvider.MapPath(recipeFile);
                    var executionId = _importExportService.Import(File.ReadAllText(mappedPath));
                    //var recipeJournal = _recipeJournal.GetRecipeJournal(executionId);

                    //result.Messages.AddRange(recipeJournal.Messages.Select(m=>string.Format("Recipe Content Migration Provider: Migration: {0}. {1}", migrationName, m)));

                    //if (recipeJournal.Status == RecipeStatus.Complete) {
                    //    result.SuccessfulMigrations.Add(migrationName);
                    //}
                    //else{
                    //    result.FailedMigrations.Add(migrationName);
                    //}
                }
            }

            return(result);
        }
コード例 #6
0
        public static string Import(this IImportExportService service, string recipeText)
        {
            var context = new ImportActionContext {
                RecipeDocument = XDocument.Parse(recipeText, LoadOptions.PreserveWhitespace)
            };

            service.Import(context);
            return(context.ExecutionId);
        }
コード例 #7
0
        public async Task <IHttpActionResult> Post([FromBody] ImportExportModel model)
        {
            try
            {
                bool success = await _exportService.Import(model);

                return(Ok(success));
            }
            catch (Exception ex)
            {
                const string error = "Error importing workflow configuration";
                Log.Error(error, ex);
                return(Content(HttpStatusCode.InternalServerError, ViewHelpers.ApiException(ex, error)));
            }
        }
コード例 #8
0
ファイル: CompanyEmployeeService.cs プロジェクト: junlu3/CMS
        public ImportResultModel ImportCompanyEmployees(Stream stream, bool isCoverData)
        {
            var companyEmployeeSheet = new ImportSheetModel()
            {
                SheetName      = "员工信息",
                HeaderRowIndex = 1,
                StartRowIndex  = 2,
                ColCount       = 24,
                ParseMain      = ParseToEntity,
            };

            var result = _importExportService.Import(stream, companyEmployeeSheet, isCoverData);

            result.Title = "员工信息";

            return(result);
        }
コード例 #9
0
        public ImportResultModel ImportEmployeeWorkHistories(Stream stream)
        {
            var sheet = new ImportSheetModel()
            {
                SheetName      = "职业史",
                HeaderRowIndex = 1,
                StartRowIndex  = 2,
                ColCount       = 11,
                ParseMain      = ParseToEntity,
            };

            var result = _importExportService.Import(stream, sheet, false);

            result.Title = "职业史";

            return(result);
        }
コード例 #10
0
        public void ImportFile()
        {
            if (String.IsNullOrEmpty(Filename))
            {
                Context.Output.WriteLine(T("Invalid file path"));
                return;
            }

            if (!File.Exists(Filename))
            {
                Context.Output.WriteLine(T("File not found."));
                return;
            }

            _importExportService.Import(File.ReadAllText(Filename));

            Context.Output.WriteLine(T("Import running..."));
        }
コード例 #11
0
        public ActionResult ImportPOST()
        {
            if (!Services.Authorizer.Authorize(Permissions.Import, T("Not allowed to import.")))
            {
                return(new HttpUnauthorizedResult());
            }

            if (String.IsNullOrEmpty(Request.Files["RecipeFile"].FileName))
            {
                ModelState.AddModelError("RecipeFile", T("Please choose a recipe file to import.").Text);
                Services.Notifier.Error(T("Please choose a recipe file to import."));
            }

            if (ModelState.IsValid)
            {
                _importExportService.Import(new StreamReader(Request.Files["RecipeFile"].InputStream).ReadToEnd());
                Services.Notifier.Information(T("Your recipe has been imported."));
            }

            return(RedirectToAction("Import"));
        }