private void ReOutput() { ClearStatusMessage(); try { var filePath = string.Empty; var fileName = $"再出力請求仕訳_{DateTime.Now:yyyyMMdd_HHmmss}.csv"; if (!ShowSaveFileDialog(GetDirectory(), fileName, out filePath, confirmMessagging: () => ShowConfirmDialog(MsgQstConfirmStartXXX, "再出力"), cancellationMessaging: () => DispStatusMessage(MsgInfProcessCanceled))) { return; } var outputAtArr = grdBilling.Rows .Where(x => Convert.ToBoolean(x[CellName("SelectFlag")].Value)) .Select(x => x.DataBoundItem as JournalizingSummary).Select(x => x.OutputAt).ToArray(); DateTime[] outputAts = outputAtArr.Cast <DateTime>().ToArray(); List <BillingJournalizing> reOutputList = GetBillingJournalizing(outputAts); var definition = new BillingJournalizingFileDefinition(new DataExpression(ApplicationControl)); if (definition.CurrencyCodeField.Ignored = (!UseForeignCurrency)) { definition.CurrencyCodeField.FieldName = null; } var decimalFormat = "0" + ((Precision == 0) ? string.Empty : "." + new string('0', Precision)); definition.BillingAmountField.Format = value => value.ToString(decimalFormat); var exporter = definition.CreateExporter(); exporter.UserId = Login.UserId; exporter.UserCode = Login.UserCode; exporter.CompanyId = CompanyId; exporter.CompanyCode = Login.CompanyCode; ProgressDialog.Start(ParentForm, (cancel, progress) => { return(exporter.ExportAsync(filePath, reOutputList, cancel, progress)); }, true, SessionKey); if (exporter.Exception != null) { NLogHandler.WriteErrorLog(this, exporter.Exception, SessionKey); ShowWarningDialog(MsgErrSomethingError, "出力"); return; } DispStatusMessage(MsgInfFinishedSuccessReOutputProcess); Settings.SavePath <Web.Models.BillingJournalizing>(Login, filePath); } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); ShowWarningDialog(MsgErrSomethingError, "出力"); } }
private void Output() { try { if (!CheckData()) { return; } string filePath = Path.Combine(txtWriteFile.Text); var definition = new BillingJournalizingFileDefinition(new DataExpression(ApplicationControl)); if (definition.CurrencyCodeField.Ignored = (!UseForeignCurrency)) { definition.CurrencyCodeField.FieldName = null; } var decimalFormat = "0" + ((Precision == 0) ? string.Empty : "." + new string('0', Precision)); definition.BillingAmountField.Format = value => value.ToString(decimalFormat); var exporter = definition.CreateExporter(); exporter.UserId = Login.UserId; exporter.UserCode = Login.UserCode; exporter.CompanyId = CompanyId; exporter.CompanyCode = Login.CompanyCode; ProgressDialog.Start(ParentForm, (cancel, progress) => { return(exporter.ExportAsync(filePath, ExtractList, cancel, progress)); }, true, SessionKey); if (exporter.Exception != null) { if (exporter.Exception.HResult == new UnauthorizedAccessException().HResult) { ShowWarningDialog(MsgErrUnauthorizedAccess); return; } else if (string.IsNullOrEmpty(Path.GetFileName(txtWriteFile.Text))) { ShowWarningDialog(MsgWngInputRequired, "書込ファイル"); return; } else { NLogHandler.WriteErrorLog(this, exporter.Exception, SessionKey); ShowWarningDialog(MsgErrSomethingError, "出力"); return; } } UpdateOutputAt(); List <JournalizingSummary> billingJournalizingList = LoadGridData(0); grdBilling.DataSource = new BindingSource(billingJournalizingList, null); var extractBillingAmount = ExtractList.Sum(x => x.BillingAmount); lblOutputNumber.Text = ExtractList.Count.ToString(DisplayFormat); lblOutputAmount.Text = GetExtractBillingPrecision(extractBillingAmount); DispStatusMessage(MsgInfFinishDataExtracting); BaseContext.SetFunction04Enabled(false); BaseContext.SetFunction06Enabled(false); BaseContext.SetFunction07Enabled(false); BaseContext.SetFunction08Enabled(false); } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); ShowWarningDialog(MsgErrSomethingError, "出力"); } }