/// <summary>「消込仕訳」ファイルをエクスポートする。</summary> private bool ExportMatchingJournalizing(string path, List <MatchingJournalizing> details) { var definition = new MFMatchingJournalizingFileDefinition(new DataExpression(ApplicationControl)); definition.DebitAmountField.Format = value => value.ToString(MoneyFormatPlane); definition.CreditAmountField.Format = value => value.ToString(MoneyFormatPlane); var exporter = definition.CreateExporter(); exporter.UserId = Login.UserId; exporter.UserCode = Login.UserCode; exporter.CompanyId = CompanyId; exporter.CompanyCode = Login.CompanyCode; NLogHandler.WriteDebug(this, "消込仕訳出力 出力開始"); var exportDialogResult = ProgressDialog.Start(ParentForm, (cancel, progress) => { return(exporter.ExportAsync(path, details, cancel, progress)); }, true, SessionKey); NLogHandler.WriteDebug(this, "消込仕訳出力 出力終了"); if (exportDialogResult == DialogResult.Cancel) { DispStatusMessage(MsgInfProcessCanceled); return(false); } if (exporter.Exception != null) { ShowWarningMessageWithExport(exporter.Exception); return(false); } return(true); }
private async Task SaveReceipt() { NLogHandler.WriteDebug(this, "入金フリーインポーター 取込開始"); var importResult = await Importer.ImportAsync(); NLogHandler.WriteDebug(this, "入金フリーインポーター 取込終了"); if (!importResult) { ShowWarningDialog(MsgErrImportErrorWithoutLog); return; } lblNumber.Text = Importer.SaveCount.ToString("#,##0"); lblMoney.Text = Importer.SaveAmount.ToString("#,##0"); var moveResult = Importer.MoveFile(); DispStatusMessage(MsgInfFinishImport); BaseContext.SetFunction04Enabled(false); if (importResult & moveResult) { Modified = false; } }
/// <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 ApprovalSearchData() { ClearStatusMessage(); try { NLogHandler.WriteDebug(this, "消込承認処理 検索開始"); ProgressDialog.Start(ParentForm, SearchMatchedData(true), false, SessionKey); NLogHandler.WriteDebug(this, "消込承認処理 検索終了"); } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); } }
private async Task SaveBillingImport() { NLogHandler.WriteDebug(this, "請求フリーインポーター 取込処理開始"); var result = await Importer.ImportAsync(); NLogHandler.WriteDebug(this, "請求フリーインポーター 取込処理終了"); if (result) { dlblImportAmount.Text = Importer.SaveAmount.ToString("#,##0"); dlblImportCount.Text = Importer.SaveCount.ToString("#,##0"); var fileMoveResult = Importer.MoveFile(); BaseContext.SetFunction04Enabled(false); DispStatusMessage(MsgInfProcessFinish); Modified = false; } else { ShowWarningDialog(MsgErrImportErrorWithoutLog); } }
private void ExportCustomer(CustomerSearch customerData) { List <Customer> list = null; string serverPath = null; var task = ServiceProxyFactory.LifeTime(async factory => { var service = factory.Create <CustomerMasterClient>(); CustomersResult result = await service.GetItemsAsync(SessionKey, CompanyId, customerData); if (result.ProcessResult.Result) { list = result.Customers; } }); Task <string> pathTask = GetServerPath(); ProgressDialog.Start(ParentForm, Task.WhenAll(task, pathTask), false, SessionKey); serverPath = pathTask.Result; if (!list.Any()) { ShowWarningDialog(MsgWngNoExportData); return; } if (!Directory.Exists(serverPath)) { serverPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); } var filePath = string.Empty; var fileName = $"得意先マスター{DateTime.Today:yyyyMMdd}.csv"; if (!ShowSaveExportFileDialog(serverPath, fileName, out filePath)) { return; } var definition = new CustomerFileDefinition(new DataExpression(ApplicationControl)); definition.ExcludeInvoicePublishField.Ignored = !UsePublishInvoice; definition.ExcludeReminderPublishField.Ignored = !UseReminder; var exporter = definition.CreateExporter(); exporter.UserId = Login.UserId; exporter.UserCode = Login.UserCode; exporter.CompanyId = CompanyId; exporter.CompanyCode = Login.CompanyCode; Func <int[], Dictionary <int, Category> > getter = ids => { Dictionary <int, Category> product = null; ServiceProxyFactory.LifeTime(factory => { var categoryservice = factory.Create <CategoryMasterClient>(); CategoriesResult result = categoryservice.Get(SessionKey, ids); if (result.ProcessResult.Result) { product = result.Categories.ToDictionary(c => c.Id); } }); return(product ?? new Dictionary <int, Category>()); }; definition.CollectCategoryIdField.GetModelsById = getter; definition.LessThanCollectCategoryIdField.GetModelsById = getter; definition.GreaterThanCollectCategoryId3Field.GetModelsById = getter; definition.GreaterThanCollectCategoryId2Field.GetModelsById = getter; definition.GreaterThanCollectCategoryId1Field.GetModelsById = getter; NLogHandler.WriteDebug(this, "得意先マスター 出力開始"); ProgressDialog.Start(ParentForm, (cancel, progress) => { return(exporter.ExportAsync(filePath, list, cancel, progress)); }, true, SessionKey); if (exporter.Exception != null) { NLogHandler.WriteErrorLog(this, exporter.Exception, SessionKey); ShowWarningDialog(MsgErrExportError); return; } NLogHandler.WriteDebug(this, "得意先マスター 出力終了"); DispStatusMessage(MsgInfFinishExport); Settings.SavePath <Customer>(Login, filePath); }
private void OutputNewCustomer() { try { List <Customer> list = Importer.GetNewCustomers(); if (!list.Any()) { return; } var serverPath = string.Empty; ProgressDialog.Start(ParentForm, Task.Run(() => { serverPath = Util.GetGeneralSettingServerPathAsync(Login).Result; }), false, SessionKey); if (!Directory.Exists(serverPath)) { serverPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); } var filePath = string.Empty; var fileName = $"新規得意先{DateTime.Today:yyyyMMdd}.csv"; if (!ShowSaveExportFileDialog(serverPath, fileName, out filePath)) { return; } var definition = new CustomerFileDefinition(new DataExpression(ApplicationControl)); var exporter = definition.CreateExporter(); exporter.UserId = Login.UserId; exporter.UserCode = Login.UserCode; exporter.CompanyId = CompanyId; exporter.CompanyCode = Login.CompanyCode; Func <int[], Dictionary <int, Category> > getter = ids => { Dictionary <int, Category> product = null; ServiceProxyFactory.LifeTime(factory => { var categoryservice = factory.Create <CategoryMasterClient>(); CategoriesResult result = categoryservice.Get(SessionKey, ids); if (result.ProcessResult.Result) { product = result.Categories.ToDictionary(c => c.Id); } }); return(product ?? new Dictionary <int, Category>()); }; definition.CollectCategoryIdField.GetModelsById = getter; NLogHandler.WriteDebug(this, "新規得意先 出力開始"); ProgressDialog.Start(ParentForm, (cancel, progress) => { return(exporter.ExportAsync(filePath, list, cancel, progress)); }, true, SessionKey); if (exporter.Exception != null) { NLogHandler.WriteErrorLog(this, exporter.Exception, SessionKey); ShowWarningDialog(MsgErrExportError); return; } NLogHandler.WriteDebug(this, "新規得意先 出力終了"); DispStatusMessage(MsgInfFinishExport); } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); DispStatusMessage(MsgErrExportError); } }
private void ReadCsv() { Importer.FilePath = txtFilePath.Text; Importer.ImporterSettingId = ImporterSetting.Id; NLogHandler.WriteDebug(this, "請求フリーインポーター 読込処理開始"); Exception exOuter = null; var task = Task.Run(async() => { try { await Importer.ReadCsvAsync(); } catch (Exception ex) { exOuter = ex; } }); ProgressDialog.Start(ParentForm, task, false, SessionKey); NLogHandler.WriteDebug(this, "請求フリーインポーター 読込処理終了"); if (exOuter != null) { NLogHandler.WriteErrorLog(this, exOuter, SessionKey); ShowWarningDialog(MsgErrReadingError); return; } dlblReadingCount.Text = Importer.ReadCount.ToString("#,##0"); dlblImportableCount.Text = Importer.ValidCount.ToString("#,##0"); dlblUnImportableCount.Text = Importer.InvalidCount.ToString("#,##0"); dlblNewCustomerCount.Text = Importer.NewCustomerCreationCount.ToString("#,##0"); var hasNewCustomer = Importer.NewCustomerCreationCount > 0; if (Importer.ReadCount == 0) /* 読込件数ゼロ スキップした分は省く */ { ShowWarningDialog(MsgWngNoImportData); } else if (Importer.ValidCount > 0 && Importer.InvalidCount == 0) /* 無効なし、有効のみ 望ましい形 */ { BaseContext.SetFunction01Enabled(false); txtFilePath.Enabled = false; btnFilePath.Enabled = false; BaseContext.SetFunction03Enabled(true); BaseContext.SetFunction04Enabled(true); BaseContext.SetFunction07Enabled(hasNewCustomer); BaseContext.SetFunction08Enabled(hasNewCustomer); rdoPrintPossible.Checked = true; gbxPrint.Enabled = false; } else if (Importer.ValidCount == 0 && Importer.InvalidCount > 0) /* 有効なし、無効のみ */ { BaseContext.SetFunction03Enabled(true); BaseContext.SetFunction06Enabled(true); BaseContext.SetFunction07Enabled(hasNewCustomer); BaseContext.SetFunction08Enabled(hasNewCustomer); rdoPrintImpossible.Checked = true; gbxPrint.Enabled = false; } else if (Importer.ValidCount > 0 && Importer.InvalidCount > 0) /* 有効・無効混在 */ { BaseContext.SetFunction03Enabled(true); BaseContext.SetFunction06Enabled(rdoPrintImpossible.Checked); BaseContext.SetFunction07Enabled(hasNewCustomer); BaseContext.SetFunction08Enabled(hasNewCustomer); gbxPrint.Enabled = true; } else /* すべてスキップなど 読込はしたが、取り込むデータなし エラーもなし */ { ShowWarningDialog(MsgWngNoImportData); gbxPrint.Enabled = false; } }
private void ReadCsv() { Importer.ImporterSettingId = ImporterSetting.Id; Importer.FilePath = txtFilePath.Text; Exception exOuter = null; var task = Task.Run(async() => { try { await Importer.ReadCsvAsync(); } catch (Exception ex) { exOuter = ex; } }); NLogHandler.WriteDebug(this, "入金フリーインポーター 読込開始"); ProgressDialog.Start(ParentForm, task, false, SessionKey); NLogHandler.WriteDebug(this, "入金フリーインポーター 読込終了"); if (exOuter != null) { NLogHandler.WriteErrorLog(this, exOuter, SessionKey); ShowWarningDialog(MsgErrReadingError); return; } lblReadNo.Text = Importer.ReadCount.ToString("#,##0"); lblPossibleNo.Text = Importer.ValidCount.ToString("#,##0"); lblImpossibleNo.Text = Importer.InvalidCount.ToString("#,##0"); //すべて取込可能 if (Importer.ValidCount > 0 && Importer.InvalidCount == 0) { BaseContext.SetFunction01Enabled(false); txtFilePath.Enabled = false; BaseContext.SetFunction03Enabled(true); BaseContext.SetFunction04Enabled(true); BaseContext.SetFunction06Enabled(false); rdoPossible.Checked = true; gbxPrint.Enabled = false; btnPath.Enabled = false; } //すべて取込不可能 else if (Importer.ValidCount == 0 && Importer.InvalidCount > 0) { BaseContext.SetFunction03Enabled(true); BaseContext.SetFunction06Enabled(true); BaseContext.SetFunction04Enabled(false); rdoImpossible.Checked = true; gbxPrint.Enabled = false; } //取込可能、取込不可能が混在 else if (Importer.ValidCount > 0 && Importer.InvalidCount > 0) { gbxPrint.Enabled = true; BaseContext.SetFunction03Enabled(true); BaseContext.SetFunction06Enabled(false); BaseContext.SetFunction04Enabled(false); rdoPossible.Checked = true; } else { ShowWarningDialog(MsgWngNoImportData); gbxPrint.Enabled = false; } }