private void Import() { ClearStatusMessage(); try { ImportSetting importSetting = null; var task = Util.GetMasterImportSettingAsync(Login, ImportFileType.HolidayCalendar); ProgressDialog.Start(ParentForm, task, false, SessionKey); importSetting = task.Result; var definition = new HolidayCalendarFileDefinition(new DataExpression(ApplicationControl)); var importer = definition.CreateImporter(m => m.Holiday); importer.UserId = Login.UserId; importer.UserCode = Login.UserCode; importer.CompanyId = CompanyId; importer.CompanyCode = Login.CompanyCode; importer.LoadAsync = async() => await GetHolidayCalendarAsync(); importer.RegisterAsync = async unitOfWork => await RegisterForImportAsync(unitOfWork); DoImport(importer, importSetting, Clear); } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); ShowWarningDialog(MsgErrImportErrorWithoutLog); } }
public NameValueCollection GetSourceStructure(ImportSetting importSetting) { var list = GetData(importSetting, true); if (list == null || list.Count == 0) return null; return list.First(); }
public void Import(ImportSetting importSetting) { var stared = DateTime.Now; var importSettingsService = new ImportSettingsService(); importSetting.SetLastStartedAt(DateTime.Now); var folder = importSetting.ContentTypeFolder; var textfolder = ServiceFactory.TextFolderManager.Get(Repository.Current, folder); var dataToImport = GetDataToImport(importSetting); var totalCountStart = dataToImport.Count; var elapsedCount = dataToImport.Count; var importProcessService = new ImportProcessService(); foreach (var data in dataToImport) { var settingNow = importSettingsService.Get(importSetting.UUID); if (!settingNow.Enabled) break; importProcessService.SetProcess(new ImportProcessModel(importSetting.UUID, elapsedCount, totalCountStart, true)); IntegrationProgress.Send(new Progress { Uuid = importSetting.UUID, TotalCount = totalCountStart, ElapsedCount = elapsedCount, StartDate = stared.ToString("HH:mm:ss"), ElapsedTime = (DateTime.Now - stared).ToString(@"hh\:mm\:ss"), Active = true }); ServiceFactory.TextContentManager.Add(Repository.Current, textfolder, data, null, null); elapsedCount--; } importProcessService.SetProcess(new ImportProcessModel(importSetting.UUID)); IntegrationProgress.Send(new Progress { Uuid = importSetting.UUID, TotalCount = totalCountStart, ElapsedCount = elapsedCount, StartDate = stared.ToString("HH:mm:ss"), ElapsedTime = (DateTime.Now - stared).ToString(@"hh\:mm\:ss"), Active = false }); // Remove the thread. importProcessService.GetThreads().Remove(importSetting.UUID); }
public Task <ImportSetting> SaveAsync(ImportSetting ImportSetting, CancellationToken token = default(CancellationToken)) { var query = @" MERGE INTO MasterImportSetting AS target USING ( SELECT @CompanyId AS CompanyId ,@ImportFileType AS ImportFileType ) AS source ON ( target.CompanyId = source.CompanyId AND target.ImportFileType = source.ImportFileType ) WHEN MATCHED THEN UPDATE SET ImportFileName = @ImportFileName , ImportMode = @ImportMode , ExportErrorLog = @ExportErrorLog , ErrorLogDestination = @ErrorLogDestination , Confirm = @Confirm , UpdateBy = @UpdateBy , UpdateAt = GETDATE() WHEN NOT MATCHED THEN INSERT ( CompanyId, ImportFileType, ImportFileName, ImportMode, ExportErrorLog, ErrorLogDestination, Confirm, CreateBy, CreateAt, UpdateBy, UpdateAt) VALUES (@CompanyId, @ImportFileType, @ImportFileName, @ImportMode, @ExportErrorLog, @ErrorLogDestination, @Confirm, @UpdateBy, GETDATE(), @UpdateBy, GETDATE()) OUTPUT inserted.*; "; return(dbHelper.ExecuteAsync <ImportSetting>(query, ImportSetting, token)); }
static ImportSettingData() { // 加载配置文件 Setting = AssetDatabase.LoadAssetAtPath <ImportSetting>(EditorDefine.ImporterSettingFilePath); if (Setting == null) { Debug.LogWarning($"Create new ImportSetting.asset : {EditorDefine.ImporterSettingFilePath}"); Setting = ScriptableObject.CreateInstance <ImportSetting>(); EditorTools.CreateFileDirectory(EditorDefine.ImporterSettingFilePath); AssetDatabase.CreateAsset(Setting, EditorDefine.ImporterSettingFilePath); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } else { Debug.Log("Load ImportSetting.asset ok"); } // Clear CacheTypes.Clear(); CacheProcessor.Clear(); // 获取所有资源处理器类型 List <Type> result = AssemblyUtility.GetAssignableTypes(typeof(IAssetProcessor)); for (int i = 0; i < result.Count; i++) { Type type = result[i]; if (CacheTypes.ContainsKey(type.Name) == false) { CacheTypes.Add(type.Name, type); } } }
public CSVFileProcessor(ImportSetting importSetting, IMarketRRepo Repo) { setting = importSetting; marketRRepo = Repo; csvValidateService = new CsvValidateService(); csvParseService = new CsvParseService <DAL.Models.Condor.KONDOR_DATA>(TypeConverter.GetConvertSettings()); }
public IActionResult AddOrEditImportSetting(int?id) { ImportSetting importSetting = id.HasValue ? _expirationReminderService.GetImportSetting(User.GetUserId(), id.Value) : _expirationReminderService.GetImportSettingDefault(User.GetUserId()); ImportSettingViewModel viewModel = Mapper.Map <ImportSettingViewModel>(importSetting); return(View(viewModel)); }
/// <summary>インポート共通処理</summary> /// <typeparam name="TModel">Model</typeparam> /// <typeparam name="TIdentity">Id特定方法</typeparam> /// <param name="importer">インポーター</param> /// <param name="setting">取込設定</param> /// <param name="importSuccessPostAction">取込成功後のクリア処理など メッセージ表示より前に実施する項目</param> /// <returns></returns> protected bool DoImport <TModel, TIdentity>(Import.CsvImporter <TModel, TIdentity> importer, ImportSetting setting, Action importSuccessPostAction = null) where TModel : class, new() { using (var form = ApplicationContext.Create(nameof(PH9907))) { var screen = form.GetAll <PH9907>().First(); var result = screen.ConfirmImportSetting(ParentForm, importer, setting); if (result != DialogResult.OK) { DispStatusMessage(Constants.MsgInfCancelProcess, "インポート"); return(false); } importer.ErrorLogPath = setting.GetErrorLogPath(); } ImportResult res = null; DialogResult pgres = DialogResult.None; NLogHandler.WriteDebug(this, $"{typeof(TModel).Name}:インポート処理開始"); try { pgres = ProgressDialog.Start(ParentForm, async(cancel, progress) => res = await importer.ImportAsync(setting.ImportFileName, (Import.ImportMethod)setting.ImportMode, cancel, progress), true, SessionKey); } catch (Exception ex) { NLogHandler.WriteErrorLog(this, ex.InnerException, SessionKey); } NLogHandler.WriteDebug(this, $"{typeof(TModel).Name}:インポート処理終了"); var importResult = false; if (pgres == DialogResult.Cancel) { DispStatusMessage(Constants.MsgInfCancelProcess, "インポート"); } else if (pgres == DialogResult.Abort) { DispStatusMessage(Constants.MsgErrImportErrorWithoutLog); } else if (res != null) { var message = XmlMessenger.GetMessageInfo(res.GetMessageId()); if (message.Category == MessageCategory.Information) { importSuccessPostAction?.Invoke(); DispStatusMessage(message); importResult = true; } else { ShowWarningDialog(message.ID); } } return(importResult); }
private void Import() { ClearStatusMessage(); try { ImportSetting importSetting = null; var task = Util.GetMasterImportSettingAsync(Login, ImportFileType.IgnoreKana); ProgressDialog.Start(ParentForm, task, false, SessionKey); importSetting = task.Result; var definition = new IgnoreKanaFileDefinition(new DataExpression(ApplicationControl)); definition.ExcludeCategoryIdField.GetModelsByCode = val => { CategoriesResult result = null; ServiceProxyFactory.LifeTime(factory => { var categoryMaster = factory.Create <CategoryMasterClient>(); result = categoryMaster.GetByCode(SessionKey, CompanyId, ExcludeCategoryType, val); }); if (result.ProcessResult.Result) { return(result.Categories .ToDictionary(c => c.Code)); } return(new Dictionary <string, Category>()); }; var importer = definition.CreateImporter(m => m.Kana); importer.UserId = Login.UserId; importer.UserCode = Login.UserCode; importer.CompanyId = CompanyId; importer.CompanyCode = Login.CompanyCode; importer.LoadAsync = async() => await GetListAsync(); importer.RegisterAsync = async unitOfWork => await RegisterForImportAsync(unitOfWork); var importResult = DoImport(importer, importSetting); if (!importResult) { return; } IgnoreKanaList.Clear(); Task <List <IgnoreKana> > loadTask = GetListAsync(); Clear(true, false); ProgressDialog.Start(ParentForm, loadTask, false, SessionKey); IgnoreKanaList.AddRange(loadTask.Result); grdExcludeKanaList.DataSource = new BindingSource(IgnoreKanaList, null); } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); ShowWarningDialog(MsgErrImportErrorWithoutLog); } }
public FileProcesser(ImportSetting setting, IMarketRRepo Repo) { switch (setting.FileType) { case (int)fileType.Csv: processer = new CSVFileProcessor(setting, Repo); break; case (int)fileType.Excel: processer = new ExcelFileProcessor(setting, Repo); break; } }
public DialogResult ConfirmImportSetting <TModel, TIdentity>(IWin32Window owner, CsvImporter <TModel, TIdentity> importer, ImportSetting setting) where TModel : class, new() { SaveFilePathCallback = SaveFilePath <TModel>; // 初期設定 var fileName = $"{importer.RowDef.FileNameToken}{DateTime.Today:yyyyMMdd}.csv"; var filePath = GetFullPath <TModel>(fileName); setting.ImportFileName = filePath; return(ConfirmImportSettingInner(owner, setting)); }
public NameValueCollection GetSourceStructure(ImportSetting setting) { var sqlService = new SqlService(); var xmlService = new XmlService(); switch (setting.SourceType) { case SourceTypeEnum.XML: return xmlService.GetSourceStructure(setting); case SourceTypeEnum.SQL: case SourceTypeEnum.SQLQUERY: return sqlService.GetSourceStructure(setting); } return new NameValueCollection(); }
private void ImportKanaHistoryCustomer() { ImportSetting importSetting = null; var task = Util.GetMasterImportSettingAsync(Login, ImportFileType.KanaHistory); // 取込設定取得 ProgressDialog.Start(ParentForm, task, false, SessionKey); importSetting = task.Result; var definition = new KanaHistoryCustomerFileDefinition(new DataExpression(ApplicationControl)); definition.CustomerIdField.GetModelsByCode = val => { Dictionary <string, Customer> product = null; ServiceProxyFactory.LifeTime(factory => { var customerMaster = factory.Create <CustomerMasterClient>(); CustomersResult result = customerMaster.GetByCode( Login.SessionKey, Login.CompanyId, val); if (result.ProcessResult.Result) { product = result.Customers .ToDictionary(c => c.Code); } }); return(product ?? new Dictionary <string, Customer>()); }; var importer = definition.CreateImporter(m => new { m.PayerName, m.SourceBankName, m.SourceBranchName, m.CustomerId }); importer.UserId = Login.UserId; importer.UserCode = Login.UserCode; importer.CompanyId = Login.CompanyId; importer.CompanyCode = Login.CompanyCode; importer.LoadAsync = async() => await GetKanaHistoryCustomerAsync(); importer.RegisterAsync = async unitOfWork => await RegisterForCustomerImportAsync(unitOfWork); importer.InitializeWorker = async worker => worker.SetLegalPersonalities(await GetLegalPersonalitiesAsync()); var importResult = DoImport(importer, importSetting); if (!importResult) { return; } grdKanaHistoryCustomer.Rows.Clear(); }
public List<ImportSetting> GetAll() { var list = new List<ImportSetting>(); // Get KooBooFolders var folder = GetImportSettingsFolder(); if (folder != null) { foreach (var importSetting in folder.CreateQuery()) { var setting = new ImportSetting(); setting.Populate(importSetting); list.Add(setting); } } return list; }
private DataTable GetSqlData(ImportSetting setting, bool onlyStructure = false) { string command = ""; var con = new SqlConnection(setting.ConnectionString); switch (setting.SourceType) { case SourceTypeEnum.SQL: command = string.Format(onlyStructure ? "SELECT TOP 1 * FROM {0} WHERE Deleted = 0" : "SELECT * FROM {0} WHERE Deleted = 0", setting.DatabaseTable); break; case SourceTypeEnum.SQLQUERY: command = setting.Query; break; } var data = new DataTable(); var da = new SqlDataAdapter(command, con); da.Fill(data); return data; }
private void Import() { ClearStatusMessage(); try { var customerGroupList = new List <CustomerGroup>(); ImportSetting importSetting = null; var task = Util.GetMasterImportSettingAsync(Login, ImportFileType.CustomerGroup); ProgressDialog.Start(ParentForm, task, false, SessionKey); importSetting = task.Result; var definition = new CustomerGroupFileDefinition(new DataExpression(ApplicationControl)); definition.GetCustomerDictionary = val => Util.ConvertToDictionary(Util.GetCustomerList(Login, val), x => x.Code); definition.GetDbCsutomerGroups = () => Task.Run(async() => await LoadListAsync()).Result; var importer = definition.CreateImporter(m => new { m.ParentCustomerId, m.ChildCustomerId }); importer.UserId = Login.UserId; importer.UserCode = Login.UserCode; importer.CompanyId = Login.CompanyId; importer.CompanyCode = Login.CompanyCode; importer.LoadAsync = async() => await LoadListAsync(); importer.RegisterAsync = async unitOfWork => await RegisterForImportAsync(unitOfWork); var importResult = DoImport(importer, importSetting, ClearControlValues); if (!importResult) { return; } Modified = false; Task <List <CustomerGroup> > loadTask = LoadListAsync(); ProgressDialog.Start(ParentForm, loadTask, false, SessionKey); customerGroupList.AddRange(loadTask.Result); } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); ShowWarningDialog(MsgErrImportErrorWithoutLog); } }
private void ImportJuridicalPersonality() { ClearStatusMessage(); try { ImportSetting importSetting = null; var task = Util.GetMasterImportSettingAsync(Login, ImportFileType.JuridicalPersonality); ProgressDialog.Start(ParentForm, task, false, SessionKey); importSetting = task.Result; var definition = new JuridicalPersonalityFileDefinition(new DataExpression(ApplicationControl)); var importer = definition.CreateImporter(m => m.Kana); importer.UserId = Login.UserId; importer.UserCode = Login.UserCode; importer.CompanyId = CompanyId; importer.CompanyCode = Login.CompanyCode; importer.LoadAsync = async() => await LoadJuridicalPersonalityAsync(); importer.RegisterAsync = async unitOfWork => await RegisterForImportAsync(unitOfWork); var importResult = DoImport(importer, importSetting); if (!importResult) { return; } txtKana.Clear(); this.ActiveControl = txtKana; Modified = false; JuridicalPersonalityList.Clear(); var loadTask = LoadJuridicalPersonalityAsync(); ProgressDialog.Start(ParentForm, loadTask, false, SessionKey); JuridicalPersonalityList.AddRange(loadTask.Result); grdRemoveJuridicalPersonality.DataSource = new BindingSource(JuridicalPersonalityList, null); } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); ShowWarningDialog(MsgErrImportErrorWithoutLog); } }
private DialogResult ConfirmImportSettingInner(IWin32Window owner, ImportSetting setting) { this.setting = setting; if (setting.Confirm == 1) { InitializeParentForm("インポート方法の選択"); return(ApplicationContext.ShowDialog(owner, ParentForm, true)); } else { var path = GetSelectedFile(owner, setting.ImportFileName); if (string.IsNullOrEmpty(path)) { return(DialogResult.Cancel); } setting.ImportFileName = path; return(DialogResult.OK); } }
private async Task <bool> Save() { var a = grdImportSetting.DataSource as BindingSource; var list = a.DataSource as List <ImportSetting>; int count = grdImportSetting.Rows.Count; var importSettingTemp = new ImportSetting[count]; ImportSettingResult result = null; for (int i = 0; i < count; i++) { var importsetting = new ImportSetting(); importsetting.CompanyId = CompanyId; importsetting.ImportFileName = list[i].ImportFileName; importsetting.ImportMode = list[i].ImportMode; importsetting.ExportErrorLog = list[i].ExportErrorLog; importsetting.ErrorLogDestination = list[i].ErrorLogDestination; importsetting.Confirm = list[i].Confirm; importsetting.ImportFileType = list[i].ImportFileType; importsetting.CreateAt = list[i].CreateAt; list[i].CreateBy = Login.UserId; importsetting.CreateBy = list[i].CreateBy; list[i].UpdateBy = Login.UserId; importsetting.UpdateBy = list[i].UpdateBy; importsetting.UpdateAt = list[i].UpdateAt; importSettingTemp[i] = importsetting; } await ServiceProxyFactory.LifeTime(async factory => { var service = factory.Create <ImportSettingMasterClient>(); result = await service.SaveAsync(SessionKey, importSettingTemp); if (result.ProcessResult.Result) { await LoadImportingSettingGrid(); } }); return(result.ProcessResult.Result); }
public List<NameValueCollection> GetData(ImportSetting importSetting, bool onlyStructure = false) { var objects = new List<NameValueCollection>(); try { var data = GetSqlData(importSetting, onlyStructure); foreach (DataRow item in data.Rows) { var o = new NameValueCollection(); foreach (DataColumn col in data.Columns) o.Add(col.ColumnName, item[col.ColumnName].ToString()); objects.Add(o); } } catch (Exception ex) { return objects; } return objects; }
public List<NameValueCollection> GetDataToImport(ImportSetting importSetting) { var objectsToImport = new List<NameValueCollection>(); var sqlService = new SqlService(); var xmlService = new XmlService(); var dataToImport = new List<NameValueCollection>(); switch (importSetting.SourceType) { case SourceTypeEnum.XML: dataToImport = xmlService.GetData(importSetting); break; case SourceTypeEnum.SQL: case SourceTypeEnum.SQLQUERY: dataToImport = sqlService.GetData(importSetting); break; } foreach (var row in dataToImport) { var objectToImport = new NameValueCollection(); foreach (var mappedField in importSetting.MappedFields) { if (!string.IsNullOrEmpty(row[mappedField.SourceField])) { if (!mappedField.IsDefault) objectToImport.Add(mappedField.KoobooField, row[mappedField.SourceField]); else objectToImport.Add(mappedField.KoobooField, mappedField.DefaultValue); } } if (objectToImport.Count > 0) objectsToImport.Add(objectToImport); } return objectsToImport; }
private void Import() { ClearStatusMessage(); try { ImportSetting importSetting = null; var task = Util.GetMasterImportSettingAsync(Login, ImportFileType.Staff); ProgressDialog.Start(ParentForm, task, false, SessionKey); importSetting = task.Result; if (importSetting == null) { return; } var definition = new StaffFileDefinition(new DataExpression(ApplicationControl)); definition.MailField.Required = UseDistribution; definition.DepartmentIdField.GetModelsByCode = val => { Dictionary <string, Department> product = null; ServiceProxyFactory.LifeTime(factory => { var departmentMaster = factory.Create <DepartmentMasterClient>(); DepartmentsResult result = departmentMaster.GetByCode(SessionKey, CompanyId, val); if (result.ProcessResult.Result) { product = result.Departments.ToDictionary(c => c.Code); } }); return(product ?? new Dictionary <string, Department>()); }; //その他 definition.StaffCodeField.ValidateAdditional = (val, param) => { var reports = new List <WorkingReport>(); if (((ImportMethod)param) != ImportMethod.Replace) { return(reports); } var codes = val.Values.Where(x => !string.IsNullOrEmpty(x.Code)).Select(x => x.Code).Distinct().ToArray(); MasterDatasResult resultlogin = null; ServiceProxyFactory.LifeTime(factory => { var staffMaster = factory.Create <StaffMasterClient>(); resultlogin = staffMaster.GetImportItemsLoginUser(SessionKey, CompanyId, codes); }); foreach (MasterData ca in resultlogin.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code))) { reports.Add(new WorkingReport { LineNo = null, FieldNo = definition.StaffCodeField.FieldIndex, FieldName = definition.StaffCodeField.FieldName, Message = $"ログインユーザーマスターに存在する{ca.Code}:{ca.Name}が存在しないため、インポートできません。", }); } MasterDatasResult resultcustomer = null; MasterDatasResult resultbilling = null; ServiceProxyFactory.LifeTime(factory => { var staffMaster = factory.Create <StaffMasterClient>(); resultcustomer = staffMaster.GetImportItemsCustomer(SessionKey, CompanyId, codes); resultbilling = staffMaster.GetImportItemsBilling(SessionKey, CompanyId, codes); }); foreach (MasterData ca in resultcustomer.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code))) { reports.Add(new WorkingReport { LineNo = null, FieldNo = definition.StaffCodeField.FieldIndex, FieldName = definition.StaffCodeField.FieldName, Message = $"得意先マスターに存在する{ca.Code}:{ca.Name}が存在しないため、インポートできません。", }); } foreach (MasterData ca in resultbilling.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code))) { reports.Add(new WorkingReport { LineNo = null, FieldNo = definition.StaffCodeField.FieldIndex, FieldName = definition.StaffCodeField.FieldName, Message = $"請求データに存在する{ca.Code}:{ca.Name}が存在しないため、インポートできません。", }); } return(reports); }; var importer = definition.CreateImporter(m => m.Code); importer.UserId = Login.UserId; importer.UserCode = Login.UserCode; importer.CompanyId = CompanyId; importer.CompanyCode = Login.CompanyCode; importer.LoadAsync = async() => await LoadListAsync(); importer.RegisterAsync = async unitOfWork => await RegisterForImportAsync(unitOfWork); var importResult = DoImport(importer, importSetting, Clear); if (!importResult) { return; } StaffProgress.Clear(); Task <List <Staff> > loadTask = LoadListAsync(); ProgressDialog.Start(ParentForm, loadTask, false, SessionKey); StaffProgress.AddRange(loadTask.Result); grdStaff.DataSource = new BindingSource(StaffProgress, null); } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); ShowWarningDialog(MsgErrImportErrorWithoutLog); } }
public ExcelFileProcessor(ImportSetting importSetting, IMarketRRepo Repo) { setting = importSetting; marketRRepo = Repo; }
private void Import() { ClearStatusMessage(); try { ImportSetting importSetting = null; var task = Util.GetMasterImportSettingAsync(Login, ImportFileType.Section); ProgressDialog.Start(ParentForm, task, false, SessionKey); importSetting = task.Result; var definition = new SectionFileDefinition(new DataExpression(ApplicationControl)); definition.SectionCodeField.ValidateAdditional = (val, param) => { var reports = new List <WorkingReport>(); if (((ImportMethod)param) != ImportMethod.Replace) { return(reports); } if (val.Any(a => a.Value.Code == null)) { return(reports); } if (val.Select(x => x.Value.Code).Distinct().Count() != val.Values.Count) { return(reports); } ServiceProxyFactory.LifeTime(factory => { var section = factory.Create <SectionMasterClient>(); MasterDatasResult resBankAccount = section.GetImportItemsForBankAccount( SessionKey, CompanyId, val.Values.Select(x => x.Code).ToArray()); foreach (MasterData ca in resBankAccount.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code))) { reports.Add(new WorkingReport { LineNo = null, FieldNo = definition.SectionCodeField.FieldIndex, FieldName = definition.SectionCodeField.FieldName, Message = $"銀行口座マスターに存在する{ca.Code}:{ca.Name}が存在しないため、インポートできません。", }); } MasterDatasResult resSectionWithDept = section.GetImportItemsForSectionWithDepartment( SessionKey, CompanyId, val.Values.Select(x => x.Code).ToArray()); foreach (MasterData item in resSectionWithDept.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code))) { reports.Add(new WorkingReport { LineNo = null, FieldNo = definition.SectionCodeField.FieldIndex, FieldName = definition.SectionCodeField.FieldName, Message = $"入金・請求部門対応マスターに存在する{item.Code}:{item.Name}が存在しないため、インポートできません。", }); } MasterDatasResult resSectionWithLoginUser = section.GetImportItemsForSectionWithLoginUser( SessionKey, CompanyId, val.Values.Select(l => l.Code).ToArray()); foreach (MasterData item in resSectionWithLoginUser.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code))) { reports.Add(new WorkingReport { LineNo = null, FieldNo = definition.SectionCodeField.FieldIndex, FieldName = definition.SectionCodeField.FieldName, Message = $"入金部門・担当者対応マスターに存在する{item.Code}:{item.Name}が存在しないため、インポートできません。", }); } MasterDatasResult resReceipt = section.GetImportItemsForReceipt( SessionKey, CompanyId, val.Values.Select(l => l.Code).ToArray()); foreach (MasterData item in resReceipt.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code))) { reports.Add(new WorkingReport { LineNo = null, FieldNo = definition.SectionCodeField.FieldIndex, FieldName = definition.SectionCodeField.FieldName, Message = $"入金データに存在する{item.Code}:{item.Name}が存在しないため、インポートできません。", }); } MasterDatasResult resNetting = section.GetImportItemsForNetting( SessionKey, CompanyId, val.Values.Select(l => l.Code).ToArray()); foreach (MasterData item in resNetting.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code))) { reports.Add(new WorkingReport { LineNo = null, FieldNo = definition.SectionCodeField.FieldIndex, FieldName = definition.SectionCodeField.FieldName, Message = $"相殺データに存在する{item.Code}:{item.Name}が存在しないため、インポートできません。", }); } }); return(reports); }; definition.PayerCodeLeftField.ValidateAdditional = (val, param) => { var reports = new List <WorkingReport>(); var uniqueKeys = new Dictionary <string, int>(); var duplicatedLines = new List <int>(); SectionsResult res = null; ServiceProxyFactory.LifeTime(factory => { var section = factory.Create <SectionMasterClient>(); res = section.GetImportItemsForSection( SessionKey, CompanyId, val.Values.Select(l => l.PayerCodeLeft + l.PayerCodeRight).ToArray()); }); foreach (var pair in val) { var branchCodeIsEmpty = false; var accountNumberIsEmpty = false; if (pair.Value.PayerCodeLeft == "") { branchCodeIsEmpty = true; } if (pair.Value.PayerCodeRight == "") { accountNumberIsEmpty = true; } if ((branchCodeIsEmpty && !accountNumberIsEmpty) || (!branchCodeIsEmpty && accountNumberIsEmpty)) { StringFieldDefinition <Section> field = null; var value = string.Empty; if (branchCodeIsEmpty) { field = definition.PayerCodeLeftField; value = pair.Value.PayerCodeLeft; } else { field = definition.PayerCodeRightField; value = pair.Value.PayerCodeRight; } reports.Add(new WorkingReport { LineNo = pair.Key, FieldNo = field.FieldIndex, FieldName = field.FieldName, Message = "仮想支店コード・仮想口座番号のどちらかが未入力のため、インポートできません。", }); } if (res.Sections.Count != 0) { if (((ImportMethod)param) == ImportMethod.InsertOnly) { reports.Add(new WorkingReport { LineNo = pair.Key, FieldNo = definition.PayerCodeLeftField.FieldIndex, FieldName = "仮想支店コード、仮想口座番号", Message = "既に登録されている仮想支店コード、仮想口座番号のため、インポートできません。", }); } else { if (res.Sections.Any(p => p.Code != pair.Value.Code && p.PayerCode == pair.Value.PayerCodeLeft + pair.Value.PayerCodeRight && p.PayerCode != "")) { reports.Add(new WorkingReport { LineNo = pair.Key, FieldNo = definition.PayerCodeLeftField.FieldIndex, FieldName = "仮想支店コード、仮想口座番号", Message = "既に登録されている仮想支店コード、仮想口座番号のため、インポートできません。", }); } } } string key = pair.Value.PayerCodeLeft + pair.Value.PayerCodeRight; if (key.Length == 10) { if (string.IsNullOrEmpty(key)) { continue; } if (uniqueKeys.ContainsKey(key)) { var duplicated = uniqueKeys[key]; if (uniqueKeys.ContainsKey(key)) { duplicatedLines.Add(duplicated); } duplicatedLines.Add(pair.Key); } else { uniqueKeys.Add(key, pair.Key); } } } duplicatedLines.ForEach(lineNo => { reports.Add(new WorkingReport() // キー重複 { LineNo = lineNo, FieldNo = definition.PayerCodeLeftField.FieldIndex, FieldName = "仮想支店コード、仮想口座番号", Message = "仮想支店コード、仮想口座番号が重複しているため、インポートできません。", Value = val[lineNo].PayerCodeLeft + val[lineNo].PayerCodeRight, }); }); return(reports); }; var importer = definition.CreateImporter(m => new { m.Code }); importer.UserId = Login.UserId; importer.UserCode = Login.UserCode; importer.CompanyId = CompanyId; importer.CompanyCode = Login.CompanyCode; importer.LoadAsync = async() => await LoadGridAsync(); importer.RegisterAsync = async unitOfWork => await RegisterForImportAsync(unitOfWork); var importResult = DoImport(importer, importSetting); if (!importResult) { return; } Clears(); SectionList.Clear(); Task <List <Section> > loadTask = LoadGridAsync(); ProgressDialog.Start(ParentForm, loadTask, false, SessionKey); SectionList.AddRange(loadTask.Result); grdSectionMaster.DataSource = new BindingSource(SectionList, null); } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); ShowWarningDialog(MsgErrImportErrorWithoutLog); } }
public ActionResult CreateSetting(ImportSetting importSetting) { return RedirectToAction("Index"); }
public static Node CreateNodeFromV1NodeData(V1.NodeData v1, NodeData data) { NodeDataImporter imp = null; Node n = null; switch (v1.Kind) { case V1.NodeKind.LOADER_GUI: { var v = new Loader(); imp = v; n = v; } break; case V1.NodeKind.FILTER_GUI: { var v = new Filter(); imp = v; n = v; } break; case V1.NodeKind.IMPORTSETTING_GUI: { var v = new ImportSetting(); imp = v; n = v; } break; case V1.NodeKind.MODIFIER_GUI: { var v = new Modifier(); imp = v; n = v; } break; case V1.NodeKind.GROUPING_GUI: { var v = new Grouping(); imp = v; n = v; } break; case V1.NodeKind.PREFABBUILDER_GUI: { var v = new PrefabBuilder(); imp = v; n = v; } break; case V1.NodeKind.BUNDLECONFIG_GUI: { var v = new BundleConfigurator(); imp = v; n = v; } break; case V1.NodeKind.BUNDLEBUILDER_GUI: { var v = new BundleBuilder(); imp = v; n = v; } break; case V1.NodeKind.EXPORTER_GUI: { var v = new Exporter(); imp = v; n = v; } break; } n.Initialize(data); imp.Import(v1, data); return(n); }
public ActionResult UpdateSetting(ImportSetting importSetting) { if (Request.Form["action"] == "delete") { _importSettingsService.DeleteSetting(importSetting.UUID); return RedirectToAction("Index", new {siteName = Site.Name}); } if (importSetting != null) { var setting = new NameValueCollection(); if (importSetting.ConnectionString != null) setting.Add("ConnectionString", importSetting.ConnectionString); if (importSetting.ContentTypeFolder != null) setting.Add("ContentTypeFolder", importSetting.ContentTypeFolder); if (importSetting.DatabaseTable != null) setting.Add("DatabaseTable", importSetting.DatabaseTable); if (importSetting.Name != null) setting.Add("Name", importSetting.Name); if (importSetting.Query != null) setting.Add("Query", importSetting.Query); if (importSetting.XmlArchiveFolder != null) setting.Add("XmlArchiveFolder", importSetting.XmlArchiveFolder); if (importSetting.XmlReadFolder != null) setting.Add("XmlReadFolder", importSetting.XmlReadFolder); if (importSetting.XmlItemName != null) setting.Add("XmlItemName", importSetting.XmlItemName); setting.Add("Enabled", importSetting.Enabled.ToString()); setting.Add("RunOnApplicationStartup", importSetting.RunOnApplicationStartup.ToString()); setting.Add("SourceType", ((int)importSetting.SourceType).ToString()); setting.Add("RepeatIntervalInMinutes", ((int)importSetting.RepeatIntervalInMinutes).ToString()); _importSettingsService.UpdateImportSettings(importSetting.UUID, setting); } return Redirect(Request.UrlReferrer.ToString()); }
private void Import() { ClearStatusMessage(); try { ImportSetting importSetting = null; var task = Util.GetMasterImportSettingAsync(Login, ImportFileType.SectionWithDepartment); // 取込設定取得 ProgressDialog.Start(ParentForm, task, false, SessionKey); importSetting = task.Result; var definition = new SectionWithDepartmentFileDefinition(new DataExpression(ApplicationControl)); definition.SectionCodeField.GetModelsByCode = val => { Dictionary <string, Section> product = null; ServiceProxyFactory.LifeTime(factory => { var section = factory.Create <SectionMasterClient>(); var result = section.GetByCode(SessionKey, CompanyId, val); if (result.ProcessResult.Result) { product = result.Sections .ToDictionary(c => c.Code); } }); return(product ?? new Dictionary <string, Section>()); }; definition.DepartmentCodeField.GetModelsByCode = val => { Dictionary <string, Department> product = null; ServiceProxyFactory.LifeTime(factory => { var department = factory.Create <DepartmentMasterClient>(); var result = department.GetByCode(SessionKey, CompanyId, val); if (result.ProcessResult.Result) { product = result.Departments.ToDictionary(d => d.Code); } }); return(product ?? new Dictionary <string, Department>()); }; definition.DepartmentCodeField.ValidateAdditional = (val, param) => { var reports = new List <WorkingReport>(); Func <SortedList <int, SectionWithDepartment[]>, int, Func <SectionWithDepartment[], bool>, bool> dupeCheck = (list, key, condition) => { if (!list.ContainsKey(key)) { return(false); } return(condition?.Invoke(list[key]) ?? false); }; List <SectionWithDepartment> dbItems = null; ServiceProxyFactory.LifeTime(factory => { var sectionWithDepartment = factory.Create <SectionWithDepartmentMasterClient>(); var sectionWithDepartmentSearch = new SectionWithDepartmentSearch(); dbItems = sectionWithDepartment .GetItems(SessionKey, CompanyId, sectionWithDepartmentSearch) .SectionDepartments; }); var dbDepartmentCheckList = new SortedList <int, SectionWithDepartment[]>(dbItems.GroupBy(x => x.DepartmentId) .ToDictionary(x => x.Key, x => x.ToArray())); var csvDepartmentCheckList = new SortedList <int, SectionWithDepartment[]>(val.Select(x => x.Value) .GroupBy(x => x.DepartmentId) .ToDictionary(x => x.Key, x => x.ToArray())); foreach (var pair in val) { if (dupeCheck(dbDepartmentCheckList, pair.Value.DepartmentId, g => g.Any(x => x.SectionId != pair.Value.SectionId))) { reports.Add(new WorkingReport(pair.Key, definition.DepartmentCodeField.FieldIndex, definition.DepartmentCodeField.FieldName, "他の入金部門に登録されているため、インポートできません。" )); } if (dupeCheck(csvDepartmentCheckList, pair.Value.DepartmentId, g => g.Any(x => x.SectionId != pair.Value.SectionId && pair.Value.DepartmentId != 0))) { reports.Add(new WorkingReport(pair.Key, definition.DepartmentCodeField.FieldIndex, definition.DepartmentCodeField.FieldName, "他の入金部門に登録されているため、インポートできません。" )); } } return(reports); }; var importer = definition.CreateImporter(m => new { m.SectionId, m.DepartmentId }); importer.UserId = Login.UserId; importer.UserCode = Login.UserCode; importer.CompanyId = CompanyId; importer.CompanyCode = Login.CompanyCode; importer.LoadAsync = async() => await GetSectionWithDepartmentData(); importer.RegisterAsync = async unitOfWork => await RegisterForImportAsync(unitOfWork); var importResult = DoImport(importer, importSetting, Clear); } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); ShowWarningDialog(MsgErrImportErrorWithoutLog); } }
public void SaveImportSetting(string userId, ImportSetting importSetting) { importSetting.ApplicationUser = appRepo.GetUser(userId); expirationRepo.SaveImportSetting(userId, importSetting); expirationRepo.CommitChanges(); }
public IActionResult DeleteImportSetting(int id) { ImportSetting reminder = _expirationReminderService.GetImportSetting(User.GetUserId(), id); return(View(Mapper.Map <ImportSettingViewModel>(reminder))); }
static void Main(string[] args) { string excelFile = null; string dataFile = null; Side side = Side.All; string headModel = null; string dataFormatStr = null; string dataType = "List<Dictionary<string, object>>"; optionSet = new OptionSet() { { "excelFile=", "Excel folder path", s => excelFile = s }, { "dataFile=", "The code out folder", s => dataFile = s }, { "headModel=", "The last export info.", s => headModel = s }, { "side=", "The last export info.", s => side = (Side)Enum.Parse(typeof(Side), s) }, { "dataFormat=", "Data format", s => dataFormatStr = s }, { "dataType=", "Data Type", s => dataType = s }, }; optionSet.Parse(args); if (string.IsNullOrEmpty(excelFile)) { Console.WriteLine("Excel file is null"); return; } if (string.IsNullOrEmpty(dataFile)) { Console.WriteLine("Code out path is null"); return; } if (!Path.IsPathRooted(excelFile)) { excelFile = Path.Combine(Directory.GetCurrentDirectory(), excelFile); } if (!Path.IsPathRooted(dataFile)) { dataFile = Path.Combine(Directory.GetCurrentDirectory(), dataFile); } ImportSetting setting = new ImportSetting(); if (!string.IsNullOrEmpty(headModel)) { switch (headModel) { case "Normal": setting.headModel = HeadModel.CreateNormalModel(); break; case "Simple": setting.headModel = HeadModel.CreateSimpleModel(); break; //use default have side case "All": default: break; } } ExcelImport import = new ExcelImport(setting); import.side = side; DataFormat dataFormat = (DataFormat)Enum.Parse(typeof(DataFormat), dataFormatStr); import.dataFormat = dataFormat; import.dataType = TypeInfo.Parse(dataType).ToSystemType(); import.Import(dataFile, excelFile); }
public void SaveImportSetting(string userId, ImportSetting importSetting) { this.context.Entry(importSetting.ApplicationUser).State = EntityState.Unchanged; this.context.Entry(importSetting).State = importSetting.Id == 0 ? EntityState.Added : EntityState.Modified; }
public void DeleteImportSetting(string userId, ImportSetting importSetting) { var elementsToRemove = this.context.ImportSettings.Where(x => x.ApplicationUser.Id == userId && importSetting.Id == x.Id); this.context.ImportSettings.RemoveRange(elementsToRemove); }
public void StartImport(ImportSetting importSetting) { var threads = GetThreads(); if (!threads.ContainsKey(importSetting.UUID)) { var service = new ImportService(); var process = new ImportProcessModel(importSetting.UUID, 1, 2, true); SetProcess(process); var importThread = new Thread(() => service.Import(importSetting)); importThread.Start(); threads.Add(importSetting.UUID, importThread); SetThreads(threads); } }
private void Import() { ClearStatusMessage(); try { ImportSetting importSetting = null; var task = Util.GetMasterImportSettingAsync(Login, ImportFileType.Currency); // 取込設定取得 ProgressDialog.Start(ParentForm, task, false, SessionKey); importSetting = task.Result; var definition = new CurrencyFileDefinition(new DataExpression(ApplicationControl)); //その他 definition.CurrencyCodeField.ValidateAdditional = (val, param) => { var reports = new List <WorkingReport>(); if (((ImportMethod)param) != ImportMethod.Replace) { return(reports); } MasterDatasResult billResult = null; MasterDatasResult receiptResult = null; MasterDatasResult nettingResult = null; ServiceProxyFactory.LifeTime(factory => { var currencyMaster = factory.Create <CurrencyMasterClient>(); var codes = val.Values.Where(x => !string.IsNullOrEmpty(x.Code)).Select(x => x.Code).Distinct().ToArray(); billResult = currencyMaster.GetImportItemsBilling(SessionKey, CompanyId, codes); receiptResult = currencyMaster.GetImportItemsReceipt(SessionKey, CompanyId, codes); nettingResult = currencyMaster.GetImportItemsNetting(SessionKey, CompanyId, codes); }); foreach (MasterData ca in billResult.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code))) { reports.Add(new WorkingReport { LineNo = null, FieldNo = definition.CurrencyCodeField.FieldIndex, FieldName = definition.CurrencyCodeField.FieldName, Message = $"請求データに存在する{ca.Code}が存在しないため、インポートできません。", }); } foreach (var ca in receiptResult.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code))) { reports.Add(new WorkingReport { LineNo = null, FieldNo = definition.CurrencyCodeField.FieldIndex, FieldName = definition.CurrencyCodeField.FieldName, Message = $"入金データに存在する{ca.Code}が存在しないため、インポートできません。", }); } foreach (var ca in nettingResult.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code))) { reports.Add(new WorkingReport { LineNo = null, FieldNo = definition.CurrencyCodeField.FieldIndex, FieldName = definition.CurrencyCodeField.FieldName, Message = $"入金予定相殺データに存在する{ca.Code}が存在しないため、インポートできません。", }); } return(reports); }; definition.CurrencyToleranceField.ValidateAdditional = (val, param) => { var reports = new List <WorkingReport>(); foreach (var pair in val) { if (pair.Value.Precision < 0) { continue; } var significant = (pair.Value.Tolerance * Amount.Pow10(pair.Value.Precision)); if (Math.Floor(significant) != significant) { reports.Add(new WorkingReport { LineNo = pair.Key, FieldNo = definition.CurrencyToleranceField.FieldIndex, FieldName = definition.CurrencyToleranceField.FieldName, Message = $"手数料誤差金額は小数点以下{pair.Value.Precision}桁までとなるよう入力してください。", }); } } return(reports); }; var importer = definition.CreateImporter(m => m.Code); importer.UserId = Login.UserId; importer.UserCode = Login.UserCode; importer.CompanyId = Login.CompanyId; importer.CompanyCode = Login.CompanyCode; importer.LoadAsync = async() => await LoadListAsync(); importer.RegisterAsync = async unitOfWork => await RegisterForImportAsync(unitOfWork); var importResult = DoImport(importer, importSetting, Clear); if (!importResult) { return; } CurrencyList.Clear(); var loadListTask = LoadListAsync(); ProgressDialog.Start(ParentForm, loadListTask, false, SessionKey); CurrencyList.AddRange(loadListTask.Result); grdCurrencyMaster.DataSource = new BindingSource(CurrencyList, null); } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); ShowWarningDialog(MsgErrImportErrorWithoutLog); } }
private void Import() { try { ImportSetting importSetting = null; var task = Util.GetMasterImportSettingAsync(Login, ImportFileType.BankAccount); ProgressDialog.Start(ParentForm, task, false, SessionKey); importSetting = task.Result; var definition = new BankAccountFileDefinition(new DataExpression(ApplicationControl)); definition.CategoryIdField.GetModelsByCode = val => { Dictionary <string, Category> product = null; ServiceProxyFactory.LifeTime(factory => { var categoryMaster = factory.Create <CategoryMasterClient>(); CategoriesResult result = categoryMaster.GetByCode( Login.SessionKey, Login.CompanyId, 2, val); if (result.ProcessResult.Result) { product = result.Categories .ToDictionary(c => c.Code); } }); return(product ?? new Dictionary <string, Category>()); }; definition.SectionIdField.Ignored = !UseSection; definition.SectionIdField.GetModelsByCode = val => { Dictionary <string, Section> product = null; ServiceProxyFactory.LifeTime(factory => { var sectionMaster = factory.Create <SectionMasterClient>(); SectionsResult result = sectionMaster.GetByCode( Login.SessionKey, Login.CompanyId, val); if (result.ProcessResult.Result) { product = result.Sections .ToDictionary(c => c.Code); } }); return(product ?? new Dictionary <string, Section>()); }; var importer = definition.CreateImporter(m => new { m.BankCode, m.BranchCode, m.AccountTypeId, m.AccountNumber }); importer.UserId = Login.UserId; importer.UserCode = Login.UserCode; importer.CompanyId = Login.CompanyId; importer.CompanyCode = Login.CompanyCode; importer.LoadAsync = async() => await LoadListAsync(); importer.RegisterAsync = async unitOfWork => await RegisterForImportAsync(unitOfWork); var importResult = DoImport(importer, importSetting, ClearAll); if (!importResult) { return; } BankAccountList.Clear(); Task <List <BankAccount> > loadListTask = LoadListAsync(); ProgressDialog.Start(ParentForm, loadListTask, false, SessionKey); BankAccountList.AddRange(loadListTask.Result); grdBankAccount.DataSource = new BindingSource(BankAccountList, null); } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); ShowWarningDialog(MsgErrImportErrorWithoutLog); } }
/// <summary>得意先マスター<see cref="Customer"/>用</summary> /// <param name="owner"></param> /// <param name="setting"></param> /// <returns></returns> /// <remarks>フォルダは ImporterSetting から取得したものを設定</remarks> public DialogResult ConfirmImportSetting(IWin32Window owner, ImportSetting setting) { return(ConfirmImportSettingInner(owner, setting)); }
private void Import() { ClearStatusMessage(); try { ImportSetting importSetting = null; var task = Util.GetMasterImportSettingAsync(Login, ImportFileType.SectionWithLoginUser); ProgressDialog.Start(ParentForm, task, false, SessionKey); importSetting = task.Result; var definition = new SectionWithLoginUserFileDefinition(new DataExpression(ApplicationControl)); definition.SectionCodeField.GetModelsByCode = val => { Dictionary <string, Section> product = null; ServiceProxyFactory.LifeTime(factory => { var section = factory.Create <SectionMasterClient>(); SectionsResult result = section.GetByCode(SessionKey, CompanyId, val); if (result.ProcessResult.Result) { product = result.Sections .ToDictionary(c => c.Code); } }); return(product ?? new Dictionary <string, Section>()); }; definition.LoginUserCodeField.GetModelsByCode = val => { Dictionary <string, LoginUser> product = null; ServiceProxyFactory.LifeTime(factory => { var loginUser = factory.Create <LoginUserMasterClient>(); UsersResult res = loginUser.GetByCode(SessionKey, CompanyId, val); if (res.ProcessResult.Result) { product = res.Users .ToDictionary(c => c.Code); } }); return(product ?? new Dictionary <string, LoginUser>()); }; var importer = definition.CreateImporter(m => new { m.LoginUserId, m.SectionId }); importer.UserId = Login.UserId; importer.UserCode = Login.UserCode; importer.CompanyId = CompanyId; importer.CompanyCode = Login.CompanyCode; importer.LoadAsync = async() => await SectionWithLoginUserData(); importer.RegisterAsync = async unitOfWork => await RegisterForImportAsync(unitOfWork); var importResult = DoImport(importer, importSetting); if (!importResult) { return; } ClearFromTo(); BeforeParentSearch(); txtLoginUserCode.Clear(); lblLoginUserNames.Clear(); grdLoginUserModify.DataSource = null; grdLoginUserOrigin.DataSource = null; txtLoginUserCode.Focus(); Modified = false; } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); ShowWarningDialog(MsgErrImportErrorWithoutLog); } }
private void ImportAccountTitle() { try { ClearStatusMessage(); ImportSetting importSetting = null; // 取込設定取得 var task = Util.GetMasterImportSettingAsync(Login, ImportFileType.AccountTitle); ProgressDialog.Start(ParentForm, task, false, SessionKey); importSetting = task.Result; var definition = new AccountTitleFileDefinition(new DataExpression(ApplicationControl)); definition.AccountTitleCodeField.ValidateAdditional = (val, param) => { var reports = new List <WorkingReport>(); if (((ImportMethod)param) != ImportMethod.Replace) { return(reports); } MasterDatasResult categoryResult = null; MasterDatasResult customerResult = null; MasterDatasResult debitBillingResult = null; MasterDatasResult creditBillingResult = null; ServiceProxyFactory.LifeTime(factory => { var accountTitle = factory.Create <AccountTitleMasterClient>(); var codes = val.Values.Where(x => !string.IsNullOrEmpty(x.Code)).Select(x => x.Code).Distinct().ToArray(); categoryResult = accountTitle.GetImportItemsForCategory(SessionKey, CompanyId, codes); customerResult = accountTitle.GetImportItemsForCustomerDiscount(SessionKey, CompanyId, codes); debitBillingResult = accountTitle.GetImportItemsForDebitBilling(SessionKey, CompanyId, codes); creditBillingResult = accountTitle.GetImportItemsForCreditBilling(SessionKey, CompanyId, codes); }); foreach (MasterData ca in categoryResult.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code))) { reports.Add(new WorkingReport { LineNo = null, FieldNo = definition.AccountTitleCodeField.FieldIndex, FieldName = definition.AccountTitleCodeField.FieldName, Message = $"区分マスターに存在する{ca.Code}:{ca.Name}が存在しないため、インポートできません。", }); } foreach (MasterData ca in customerResult.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code))) { reports.Add(new WorkingReport { LineNo = null, FieldNo = definition.AccountTitleCodeField.FieldIndex, FieldName = definition.AccountTitleCodeField.FieldName, Message = $"得意先マスター歩引設定に存在する{ca.Code}:{ca.Name}が存在しないため、インポートできません。", }); } foreach (MasterData ca in debitBillingResult.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code))) { reports.Add(new WorkingReport { LineNo = null, FieldNo = definition.AccountTitleCodeField.FieldIndex, FieldName = definition.AccountTitleCodeField.FieldName, Message = $"請求データに存在する{ca.Code}:{ca.Name}が存在しないため、インポートできません。", }); } foreach (MasterData ca in creditBillingResult.MasterDatas.Where(p => !val.Any(a => a.Value.Code == p.Code))) { reports.Add(new WorkingReport { LineNo = null, FieldNo = definition.AccountTitleCodeField.FieldIndex, FieldName = definition.AccountTitleCodeField.FieldName, Message = $"請求データに存在する{ca.Code}:{ca.Name}が存在しないため、インポートできません。", }); } return(reports); }; var importer = definition.CreateImporter(m => m.Code); importer.UserId = Login.UserId; importer.UserCode = Login.UserCode; importer.CompanyId = CompanyId; importer.CompanyCode = Login.CompanyCode; importer.LoadAsync = async() => await LoadGridAsync(); importer.RegisterAsync = async unitOfWork => await RegisterForImportAsync(unitOfWork); System.Action clear = () => { AccountTitleList.Clear(); var loadTask = LoadGridAsync(); ProgressDialog.Start(ParentForm, loadTask, false, SessionKey); AccountTitleList.AddRange(loadTask.Result); grdAccountTitleMaster.DataSource = new BindingSource(AccountTitleList, null); }; var importResult = DoImport(importer, importSetting, clear); if (!importResult) { return; } txtCode.Clear(); txtName.Clear(); txtContraAccountCode.Clear(); txtContraAccountName.Clear(); txtContraAccountSubCode.Clear(); AccountTitleId = 0; txtCode.Enabled = true; this.ActiveControl = txtCode; BaseContext.SetFunction03Enabled(false); Modified = false; } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); ShowWarningDialog(MsgErrImportErrorWithoutLog); } }
public void DeleteImportSetting(string userId, ImportSetting importSetting) { expirationRepo.DeleteImportSetting(userId, importSetting); expirationRepo.CommitChanges(); }