public UpgradeGameApplicationService( DataConnection dataConnection, DataConnectionValidationService dataConnectionValidationService, DataExportService dataExportService, DataImportService dataImportService, DomainModelService domainModelService, DomainModelExportService domainModelExportService, DomainModelImportService domainModelImportService, GameFolderValidator gameFolderValidator, GameExecutableValidator gameExecutableValidator, LanguageFileValidator languageFileValidator, CommentaryFileValidator commentaryFileValidator, EmbeddedResourceDeployer embeddedResourceDeployer, GameExecutableCodePatcher gameExecutableCodePatcher) { _dataConnection = dataConnection ?? throw new ArgumentNullException(nameof(dataConnection)); _dataConnectionValidationService = dataConnectionValidationService ?? throw new ArgumentNullException(nameof(dataConnectionValidationService)); _dataExportService = dataExportService ?? throw new ArgumentNullException(nameof(dataExportService)); _dataImportService = dataImportService ?? throw new ArgumentNullException(nameof(dataImportService)); _domainModelExportService = domainModelExportService ?? throw new ArgumentNullException(nameof(domainModelExportService)); _domainModelImportService = domainModelImportService ?? throw new ArgumentNullException(nameof(domainModelImportService)); _gameFolderValidator = gameFolderValidator ?? throw new ArgumentNullException(nameof(gameFolderValidator)); _gameExecutableValidator = gameExecutableValidator ?? throw new ArgumentNullException(nameof(gameExecutableValidator)); _languageFileValidator = languageFileValidator ?? throw new ArgumentNullException(nameof(languageFileValidator)); _commentaryFileValidator = commentaryFileValidator ?? throw new ArgumentNullException(nameof(commentaryFileValidator)); _embeddedResourceDeployer = embeddedResourceDeployer ?? throw new ArgumentNullException(nameof(embeddedResourceDeployer)); _gameExecutableCodePatcher = gameExecutableCodePatcher ?? throw new ArgumentNullException(nameof(gameExecutableCodePatcher)); DomainModel = domainModelService ?? throw new ArgumentNullException(nameof(domainModelService)); }
public override void ExecuteExtention(MigrateRecordsRequest request, MigrateRecordsResponse response, ServiceRequestController controller) { var exportService = new ExportXmlService(new XrmRecordService(request.SourceConnection)); var exportedEntities = new List <Entity>(); exportService.ProcessExport(request.RecordTypesToMigrate, request.IncludeNotes, request.IncludeNNRelationshipsBetweenEntities, controller.Controller , (entity) => exportedEntities.Add(entity) , (entity) => exportedEntities.Add(entity)); var removeDuplicates = new List <Entity>(); foreach (var entity in exportedEntities) { if (!removeDuplicates.Any(e => e.Id == entity.Id && e.LogicalName == entity.LogicalName)) { removeDuplicates.Add(entity); } } var importService = new DataImportService(new XrmRecordService(request.TargetConnection)); var matchOption = request.MatchByName ? DataImportService.MatchOption.PrimaryKeyThenName : DataImportService.MatchOption.PrimaryKeyOnly; var dataImportResponse = importService.DoImport(removeDuplicates, controller, request.MaskEmails, matchOption: matchOption, includeOwner: request.IncludeOwner); response.ConnectionMigratedInto = request.TargetConnection; response.LoadDataImport(dataImportResponse); response.Message = "The Record Migration Has Completed"; }
public async Task Add_New_Records() { var autoMapperConfig = new MapperConfiguration(cfg => { cfg.AddProfile <DtoProfile>(); }); var mapper = autoMapperConfig.CreateMapper(); var options = new DbContextOptionsBuilder <AppDataContext>() .UseInMemoryDatabase(databaseName: "TestDb") .Options; using (var dataContext = new AppDataContext(options)) { var companyDs = new CompanyDataService(dataContext, mapper); var contactDs = new ContactDataService(dataContext, mapper); var service = new DataImportService(companyDs, contactDs); using (var stringReader = new StringReader(Csv_Contacts_3)) { await service.ImportContactsAsync(stringReader, 1); } var contacts = dataContext.Contacts.ToArray(); var companies = dataContext.Companies.ToArray(); Assert.True(contacts.Length == 3); Assert.True(companies.Length == 3); } }
public async Task ImportFromJsonAsync(string tableName, StreamReader reader) { var logsTable = GetTableReference(DataImportService.TableName); await logsTable.CreateIfNotExistsAsync(); var importer = new DataImportService(this); await importer.ImportFromJsonStreamAsync(tableName, reader); }
public void Then_No_Exception_Should_Be_Thrown() { TagEntity entity = new TagEntity(); IDataImportService <TagEntity> dataImportService = new DataImportService <TagEntity>(databaseRepository.Object, fileRepository.Object, entity); dataImportService.ImportData(); }
public void Then_No_Exception_Should_Be_Thrown() { TagEntity entity = new TagEntity(); IDataImportService<TagEntity> dataImportService = new DataImportService<TagEntity>(databaseRepository.Object, fileRepository.Object, entity); dataImportService.ImportData(); }
public void ImportTagsFromGoodXmlFile() { TagEntity entity = new TagEntity(); IDataImportService <TagEntity> dataImportService = new DataImportService <TagEntity>(databaseRepository.Object, fileRepository.Object, entity); dataImportService.ImportData(); }
public BackupService(StorageContext tableStorageContext, CloudStorageAccount backupStorageAccount, IStorageLogger storageLogger) { this.tableStorageContext = tableStorageContext; this.backupStorageAccount = backupStorageAccount; this.dataExportService = new DataExportService(tableStorageContext); this.dataImportService = new DataImportService(tableStorageContext); this.storageLogger = storageLogger; }
public void ImportTagsFromGoodXmlFile() { TagEntity entity = new TagEntity(); IDataImportService<TagEntity> dataImportService = new DataImportService<TagEntity>(databaseRepository.Object, fileRepository.Object, entity); dataImportService.ImportData(); }
public void ImportXml(string folder, ServiceRequestController controller, ImportXmlResponse response, bool maskEmails = false, bool includeOwner = false, bool matchByName = true) { controller.UpdateProgress(0, 1, "Loading XML Files"); var entities = LoadEntitiesFromXmlFiles(folder, controller.Controller); var matchOption = matchByName ? DataImportService.MatchOption.PrimaryKeyThenName : DataImportService.MatchOption.PrimaryKeyOnly; var importResponse = DataImportService.DoImport(entities, controller, maskEmails, matchOption: matchOption, includeOwner: includeOwner); response.LoadDataImport(importResponse); }
public void ImportXml(IImportXmlRequest request, ServiceRequestController controller, ImportXmlResponse response, bool maskEmails = false, bool includeOwner = false, bool matchByName = true, int?executeMultipleSetSize = null, int?targetCacheLimit = null) { controller.UpdateProgress(0, 1, "Loading XML Files"); var entities = request.GetOrLoadEntitiesForImport(controller.Controller).Values.ToArray(); var matchOption = matchByName ? MatchOption.PrimaryKeyThenName : MatchOption.PrimaryKeyOnly; var importResponse = DataImportService.DoImport(entities, controller, maskEmails, matchOption: matchOption, includeOwner: includeOwner, executeMultipleSetSize: executeMultipleSetSize, targetCacheLimit: targetCacheLimit); response.Connection = XrmRecordService.XrmRecordConfiguration; response.LoadDataImport(importResponse); response.Message = "The Import Process Has Completed"; }
private async Task ImportContactsAsync(DataImportService dataImportService, string csvPath, int userId) { try { using (var reader = File.OpenText(csvPath)) { await dataImportService.ImportContactsAsync(reader, userId); } } catch (Exception e) { Console.WriteLine($"Error occurred when importing contacts: {e}"); } }
string code = String.Empty; // 对象编码 #endregion #region ASP.NET 事件 protected void Page_Load(object sender, EventArgs e) { op = RequestData.Get <string>("op"); code = RequestData.Get <string>("code"); SysDataImportTemplate ent = null; switch (this.RequestAction) { case RequestActionEnum.Custom: if (RequestActionString == "import") { code = FormData.Get <string>("Code"); if (!String.IsNullOrEmpty(code)) { ent = SysDataImportTemplate.FindFirstByProperties("Code", code); string fileFullName = FormData.Get <string>("DataFileID"); if (!String.IsNullOrEmpty(fileFullName)) { DataImportService.ImportData(ent.Config, fileFullName); // 导入完成后删除原文件 FileService.DeleteFileByFullID(fileFullName); } } } else if (RequestActionString == "gettmplid") { // 下载文件模板时用于获取模板文件id(异步) if (IsAsyncRequest && !String.IsNullOrEmpty(code)) { ent = SysDataImportTemplate.FindFirstByProperties("Code", code); // 返回模板文件ID PageState.Add("id", FileService.GetFileIDByFullID(ent.TemplateFileID)); } } break; case RequestActionEnum.Default: if (!String.IsNullOrEmpty(code)) { ent = SysDataImportTemplate.FindFirstByProperties("Code", code); this.SetFormData(ent); } break; } }
public LanguageFileEditorApplicationService( DataConnection dataConnection, DataConnectionValidationService dataConnectionValidationService, DataExportService dataExportService, DataImportService dataImportService, DomainModelService domainModelService, LanguageFileEditorDomainModelExportService domainModelExportService, LanguageFileEditorDomainModelImportService domainModelImportService) { _dataConnection = dataConnection ?? throw new ArgumentNullException(nameof(dataConnection)); _dataConnectionValidationService = dataConnectionValidationService ?? throw new ArgumentNullException(nameof(dataConnectionValidationService)); _dataExportService = dataExportService ?? throw new ArgumentNullException(nameof(dataExportService)); _dataImportService = dataImportService ?? throw new ArgumentNullException(nameof(dataImportService)); _domainModelExportService = domainModelExportService ?? throw new ArgumentNullException(nameof(domainModelExportService)); _domainModelImportService = domainModelImportService ?? throw new ArgumentNullException(nameof(domainModelImportService)); DomainModel = domainModelService ?? throw new ArgumentNullException(nameof(domainModelService)); }
public ConfigureGameApplicationService( DataConnection dataConnection, DataConnectionValidationService dataConnectionValidationService, DataExportService dataExportService, DataImportService dataImportService, DomainModelService domainModelService, DomainModelExportService domainModelExportService, DomainModelImportService domainModelImportService, GameExecutableCodePatcher gameExecutableCodePatcher) { _dataConnection = dataConnection ?? throw new ArgumentNullException(nameof(dataConnection)); _dataConnectionValidationService = dataConnectionValidationService ?? throw new ArgumentNullException(nameof(dataConnectionValidationService)); _dataExportService = dataExportService ?? throw new ArgumentNullException(nameof(dataExportService)); _dataImportService = dataImportService ?? throw new ArgumentNullException(nameof(dataImportService)); _domainModelExportService = domainModelExportService ?? throw new ArgumentNullException(nameof(domainModelExportService)); _domainModelImportService = domainModelImportService ?? throw new ArgumentNullException(nameof(domainModelImportService)); _gameExecutableCodePatcher = gameExecutableCodePatcher ?? throw new ArgumentNullException(nameof(gameExecutableCodePatcher)); DomainModel = domainModelService ?? throw new ArgumentNullException(nameof(domainModelService)); }
public SpreadsheetImportResponse DoImport(Dictionary <IMapSpreadsheetImport, IEnumerable <IRecord> > mappings, bool maskEmails, bool matchByName, bool updateOnly, ServiceRequestController controller, int?executeMultipleSetSize = null, bool useAmericanDates = false, int?targetCacheLimit = null) { var response = new SpreadsheetImportResponse(); var parseResponse = ParseIntoEntities(mappings, useAmericanDates: useAmericanDates); response.LoadParseResponse(parseResponse); var dataImportService = new DataImportService(XrmRecordService); var matchKeyDictionary = new Dictionary <string, IEnumerable <string> >(); foreach (var map in mappings.Keys) { if (map.AltMatchKeys != null && map.AltMatchKeys.Any()) { if (matchKeyDictionary.ContainsKey(map.TargetType)) { throw new NotSupportedException($"Error Type {map.TargetType} Is Defined With Multiple Match Keys"); } matchKeyDictionary.Add(map.TargetType, map.AltMatchKeys.Select(mk => mk.TargetField).ToArray()); } } response.LoadDataImport(dataImportService.DoImport(parseResponse.GetParsedEntities(), controller, maskEmails, matchOption: matchByName ? MatchOption.PrimaryKeyThenName : MatchOption.PrimaryKeyOnly, loadExistingErrorsIntoSummary: response.ResponseItems, altMatchKeyDictionary: matchKeyDictionary, updateOnly: updateOnly, includeOwner: true, containsExportedConfigFields: false, executeMultipleSetSize: executeMultipleSetSize, targetCacheLimit: targetCacheLimit)); return(response); }
public async Task Execute(string csvPath, int userId, string dbProviderName, string connectionString) { // DB Context var optionsBuilder = new DbContextOptionsBuilder <AppDataContext>(); optionsBuilder.ConfigureDbContext(dbProviderName, connectionString); // Automapper var autoMapperConfig = new MapperConfiguration(cfg => { cfg.AddProfile <DtoProfile>(); }); var mapper = autoMapperConfig.CreateMapper(); // Start execution using (var dbContext = new AppDataContext(optionsBuilder.Options)) { var companyDataService = new CompanyDataService(dbContext, mapper); var contactDataService = new ContactDataService(dbContext, mapper); var dataImportService = new DataImportService(companyDataService, contactDataService); Console.WriteLine("Importing data..."); await ImportContactsAsync(dataImportService, csvPath, userId); Console.WriteLine("Done"); } }
string type = String.Empty; // 对象类型 #endregion #region ASP.NET 事件 protected void Page_Load(object sender, EventArgs e) { op = RequestData.Get <string>("op"); id = RequestData.Get <string>("id"); type = RequestData.Get <string>("type"); SysDataImportTemplate ent = null; switch (this.RequestAction) { case RequestActionEnum.Update: ent = this.GetTargetData <SysDataImportTemplate>(); SysDataImportTemplate pent = this.GetPostedData <SysDataImportTemplate>(); bool isTemplateFileChanged = false; if (ent.TemplateFileID != pent.TemplateFileID) { isTemplateFileChanged = true; } DataHelper.MergeData(ent, pent); // 手工合并源数据与提交数据 if (isTemplateFileChanged) { DataImportService.DoImportTemplateFileChanged(ent); // 触发模版文件变化操作 } ent.DoUpdate(); this.SetMessage("修改成功!"); break; case RequestActionEnum.Insert: case RequestActionEnum.Create: ent = this.GetPostedData <SysDataImportTemplate>(); ent.CreaterID = UserInfo.UserID; ent.CreaterName = UserInfo.Name; DataImportService.DoImportTemplateFileChanged(ent); // 触发模版文件变化操作 ent.DoCreate(); this.SetMessage("新建成功!"); break; case RequestActionEnum.Delete: ent = this.GetTargetData <SysDataImportTemplate>(); ent.DoDelete(); this.SetMessage("删除成功!"); return; } if (op != "c" && op != "cs") { if (!String.IsNullOrEmpty(id)) { ent = SysDataImportTemplate.Find(id); } this.SetFormData(ent); } else { PageState.Add("CreaterName", UserInfo.Name); PageState.Add("CreatedDate", DateTime.Now); } }
public ImportXmlService(XrmRecordService xrmRecordService) { DataImportService = new DataImportService(xrmRecordService); XrmRecordService = xrmRecordService; }