private static void Import(ImportOptions options) { var crmService = new CrmService(options.CrmConnectionString); var fileService = new FileService(options.Directory); var entityStrategyFactory = new EntityStrategyFactory(crmService); var importer = new EntityImporter(crmService, fileService, entityStrategyFactory); var commandsList = new List <CrmCommandsQueue>(); foreach (var entityLogicalName in options.EntitiesList) { var commands = new CrmCommandsQueue(entityLogicalName); importer.Import(commands, entityLogicalName); if (!commands.IsEmpty) { commandsList.Add(commands); } } using (new DisabledWorkflowsScope(crmService, commandsList.Select(x => x.EntityLogicalName))) { foreach (var commands in commandsList) { commands.ExecuteUpdateSteps(crmService); } foreach (var commands in commandsList.AsEnumerable().Reverse()) { commands.ExecuteDeleteSteps(crmService); } } }
private static void Export(ExportOptions options) { var crmService = new CrmService(options.CrmConnectionString); var fileService = new FileService(options.Directory); var entityStrategyFactory = new EntityStrategyFactory(crmService); var exporter = new EntityExporter(crmService, fileService, entityStrategyFactory); foreach (var entity in options.EntitiesList) { exporter.Export(entity); } }