public async void Can_Import_Config() { var model = Scaffold.ReadFromJsonFile <ImportExportModel>(@"Config.json"); bool import = await _importExportService.Import(model); Assert.True(import); }
public void ImportSucceedsWhenRecipeContainsImportSteps() { Assert.DoesNotThrow(() => _importExportService.Import( @"<Orchard> <Recipe> <Name>MyModuleInstaller</Name> </Recipe> <Settings /> </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...")); }
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")); }
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); }
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); }
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))); } }
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); }
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); }
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...")); }
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")); }