private async Task MigrateAsync() { string currentAppDirectory = AppDomain.CurrentDomain.BaseDirectory; string jobFolderName = GetJobFolderName(); string jobFolderPath = Path.Combine(currentAppDirectory, jobFolderName); string xmlDataPath = Path.Combine(jobFolderPath, "data.xml"); string logFilePath = Path.Combine(jobFolderPath, "Logs"); MigrationStatusMessage = "Migration in process..."; string migrationError = null; await Task.Factory.StartNew(() => { try { ExportDataService exportDataService = new ExportDataService(); CreateFolderIfNotExists(jobFolderPath); CrmServiceClient sourceCrmService = GetCrmService(SelectedSourceConnection); exportDataService.ExportData(sourceCrmService, SelectedConfiguration.Name, jobFolderPath); CrmServiceClient targetCrmService = GetCrmService(SelectedTargetConnection); ImportDataService importDataService = new ImportDataService(); CreateFolderIfNotExists(logFilePath); importDataService.ImportData(targetCrmService, xmlDataPath, logFilePath, null); } catch (Exception ex) { migrationError = ex.Message; } }); if (!string.IsNullOrWhiteSpace(migrationError)) { MigrationStatusMessage = "Migration failed. Error:- " + migrationError; } else { MigrationStatusMessage = "Migration complete! Please review the Logs for any errors encountered."; Process.Start(jobFolderPath); } }
//[TestMethod] public void TestExportData() { //Arrange string connectionStr = ConfigurationManager.ConnectionStrings["CRMSource"].ConnectionString; CrmServiceClient crmServiceClient = new CrmServiceClient(connectionStr); string configurationToExport = ConfigurationManager.AppSettings["ConfigurationToExport"]; string exportConfigDataPath = ConfigurationManager.AppSettings["ExportDataFilePath"]; ExportDataService exportDataService = new ExportDataService(); //Act exportDataService.ExportData(crmServiceClient, configurationToExport, exportConfigDataPath); //Assert // Assert.IsTrue(true); }