public void InitializeUserComponent(int precision, ReminderSummary reminderSummary) { if (reminderSummary != null) { txtCustomerCode.Text = reminderSummary.CustomerCode; txtCustomerName.Text = reminderSummary.CustomerName; nmbRemainAmount.Value = reminderSummary.RemainAmount; nmbReminderAmount.Value = reminderSummary.ReminderAmount; } else { pnlReminder.Visible = false; } pnlStatus.Visible = false; cbxStatus.Checked = false; cbxMemo.Checked = true; FormWidth = formWidth; FormHeight = formHeight - (reminderSummary != null ? 0 : pnlReminder.Height) - pnlStatus.Height; nmbRemainAmount.Fields.DecimalPart.MaxDigits = precision; nmbRemainAmount.Fields.DecimalPart.MinDigits = precision; nmbReminderAmount.Fields.DecimalPart.MaxDigits = precision; nmbReminderAmount.Fields.DecimalPart.MinDigits = precision; SetFunctionKeys(); }
private void Print() { ClearStatusMessage(); if (!ValidateInputValueForPrint()) { return; } try { var path = string.Empty; PdfSetting = GetPdfOutputSetting(); if (!PdfSetting.IsAllInOne) { var serverPath = GetServerPath(); var selectedPath = string.Empty; var rootBrowserPath = new List <string>(); if (!LimitAccessFolder ? !ShowFolderBrowserDialog(serverPath, out selectedPath) : !ShowRootFolderBrowserDialog(ApplicationControl.RootPath, out rootBrowserPath, FolderBrowserType.SelectFolder)) { DispStatusMessage(MsgInfProcessCanceled); return; } path = (!LimitAccessFolder ? selectedPath : rootBrowserPath.First()); } if (!PdfSetting.IsAllInOne && !ShowConfirmDialog(MsgQstConfirmOutput)) { DispStatusMessage(MsgInfProcessCanceled); return; } if (!ReminderSummary.Any()) { ShowWarningDialog(MsgWngPrintDataNotExist, "出力"); return; } grdReminder.CommitEdit(); Task task = null; if (!UseDestinationSummarized) { task = PrintSummarized(path); } else { task = PrintDestinationSummarized(path); } ProgressDialog.Start(ParentForm, task, false, SessionKey); } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); ShowWarningDialog(MsgErrExportError); } }
public async Task <IEnumerable <Reminder> > CreateAsync(int companyId, int loginUserId, int useForeignCurrency, Reminder[] Reminder, ReminderCommonSetting setting, ReminderSummarySetting[] summary, CancellationToken token = default(CancellationToken)) { using (var scope = transactionScopeBuilder.Create()) { //var commonSetting = getReminderCommonSettingQueryProcessor.GetItems(companyId); //if (commonSetting == null || !commonSetting.First().Equals(setting)) // return null; //var summarySetting = reminderSummarySettingQueryProcessor.GetItems(companyId, useForeignCurrency); //if (summarySetting == null || !summarySetting.ToArray().Equals(summary)) // return null; var defaultStatusId = (await statusQueryProcessor.GetAsync(new StatusSearch { CompanyId = companyId, StatusType = 1, Codes = new[] { "00" } }, token)).First().Id; var result = new List <Reminder>(); foreach (var r in Reminder) { r.StatusId = defaultStatusId; var reminderEntity = await addReminderQueryProcessor.AddAsync(r, token); r.Id = reminderEntity.Id; var reminderSummary = new ReminderSummary() { CustomerId = r.CustomerId, CurrencyId = r.CurrencyId, Memo = "", }; await addReminderQueryProcessor.AddSummaryAsync(reminderSummary, token); var billingUpdateResult = (await updateBillingReminderQueryProcessor.UpdateAsync(r, setting, summary)).ToArray(); if (r.DetailCount != billingUpdateResult.Length || r.RemainAmount != billingUpdateResult.Sum(x => x.RemainAmount)) { return(null); } result.Add(reminderEntity); } scope.Complete(); return(result.ToArray()); } }
public async Task <ReminderSummaryHistory> UpdateReminderSummaryHistoryAsync(ReminderSummaryHistory reminderSummaryHistory, CancellationToken token = default(CancellationToken)) { using (var scope = transactionScopeBuilder.Create()) { var result = await updateReminderHistoryQueryProcessor.UpdateReminderSummaryHistoryAsync(reminderSummaryHistory, token); if (reminderSummaryHistory.IsUpdateSummaryMemo) { var rs = new ReminderSummary() { Id = reminderSummaryHistory.ReminderSummaryId, Memo = reminderSummaryHistory.Memo, }; var reminderSummaryResult = await updateReminderQueryProcessor.UpdateSummaryStatusAsync(rs, token); } scope.Complete(); return(result); } }
public async Task <int> DeleteSummaryHistoryAsync(ReminderSummaryHistory reminderSummaryHistory, CancellationToken token = default(CancellationToken)) { using (var scope = transactionScopeBuilder.Create()) { var result = await deleteReminderSummaryHistoryQueryProcessor.DeleteAsync(reminderSummaryHistory.Id, token); if (reminderSummaryHistory.IsUpdateSummaryMemo) { var rsh = (await reminderHistoryQueryProcessor.GetSummaryItemsByReminderSummaryIdAsync(reminderSummaryHistory.ReminderSummaryId, token)).FirstOrDefault(); var rs = new ReminderSummary() { Id = reminderSummaryHistory.ReminderSummaryId, Memo = rsh?.Memo ?? string.Empty, }; var reminderSummaryResult = await updateReminderQueryProcessor.UpdateSummaryStatusAsync(rs, token); } scope.Complete(); return(result); } }
public static Embed FormarReminderInfo(ReminderSummary reminder) { var invoked = reminder .TimeInvoked .ToString("D"); var elapsed = reminder .ElapsedTime .Humanize(_precision); var remaining = reminder .RemainingTime .Humanize(_precision); return new EmbedBuilder() .WithColor(Constants.DefaultEmbedColour) .WithTitle("Reminder Information") .AddField("Id", reminder.Id) .AddField("Message", reminder.Message) .AddField("Invoked", invoked) .AddField("Elapsed", elapsed) .AddField("Remaining", remaining) .Build(); }
public async Task Delete(ReminderSummary reminder) { await _reminderService.DeleteReminderAsync(reminder.Id); await ReplyAsync($"{Context.User.Mention} Deleted reminder with Id {reminder.Id}."); }
public async Task Info(ReminderSummary reminder) { await ReplyAsync(embed : ReminderViews.FormarReminderInfo(reminder)); }
private void grdReminder_CellClick(object sender, CellEventArgs e) { if (e.RowIndex < 0) { return; } if (e.CellName != CellName("Preview")) { return; } grdReminder.CommitEdit(); try { string serverPath = GetServerPath(); var summary = grdReminder.Rows[e.RowIndex].DataBoundItem as ReminderSummary; if (UseDestinationSummarized) { var option = new DestinationSearch(); option.CompanyId = CompanyId; option.CustomerId = summary.CustomerId; var taskDestination = GetDestinationsAsync(option); ProgressDialog.Start(ParentForm, taskDestination, false, SessionKey); var destinations = taskDestination.Result; var destinationIds = new List <ReminderSummary>(); var inputCode = string.Empty; var cell = grdReminder.Rows[e.RowIndex].Cells[CellName(nameof(Web.Models.ReminderSummary.DestinationCode))]; if (IsCellEmpty(cell)) { summary.DestinationIdInput = null; } else { inputCode = cell.Value.ToString().PadLeft(2, '0'); if (!destinations.Any(x => x.Code == inputCode)) { ShowWarningDialog(MsgWngMasterNotExist, "送付先", inputCode); return; } summary.DestinationIdInput = destinations.FirstOrDefault(x => x.Code == inputCode).Id; } var qry = from row in grdReminder.Rows where (string)(row.Cells[CellName(nameof(Web.Models.ReminderSummary.CustomerCode))].Value) == summary.CustomerCode select row; foreach (var row in qry) { var bsd = row.DataBoundItem as ReminderSummary; var code = Convert.ToString(row.Cells[CellName(nameof(Web.Models.ReminderSummary.DestinationCode))].Value); if (code == inputCode) { if (bsd.DestinationId.HasValue) { destinationIds.Add(bsd); } else { summary.NoDestination = true; } } } summary.CompanyId = CompanyId; summary.CustomerIds = new int[] { summary.CustomerId }; summary.DestinationIds = destinationIds.Select(x => x.DestinationId.Value).Distinct().ToArray(); } var summaryList = new List <ReminderSummary>(); summaryList.Add(summary); var task = UseDestinationSummarized ? GetReminderBillingForSummaryPrintByDestinationCodeAsync(summaryList) : GetReminderBillingForSummaryPrintAsync(ReminderSummary.Select(x => x.CustomerId).ToArray()); ProgressDialog.Start(ParentForm, task, false, SessionKey); if (!task.Result.ProcessResult.Result) { ShowWarningDialog(MsgErrCreateReportError); return; } var reminderBillings = task.Result.ReminderBilling; var template = ReminderTemplateSetting.First(x => x.Id == summary.TemplateId); PdfSetting = GetPdfOutputSetting(); var report = UtilReminder.CreateReminderReport(reminderBillings, ReminderCommonSetting, ReminderSummarySetting, template, Company, ColumnNameSettingInfo, DateTime.Now, PdfSetting); ShowDialogPreview(ParentForm, report, serverPath); } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); ShowWarningDialog(MsgErrCreateReportError); } }
private async Task PrintDestinationSummarized(string path) { try { var reminderOutputed = new List <ReminderOutputed>(); var updateResult = new CountResult(); var option = new DestinationSearch(); option.CompanyId = CompanyId; var destinations = await GetDestinationsAsync(option); foreach (var summary in ReminderSummary) { if (summary.DestinationCode == null || string.IsNullOrEmpty(summary.DestinationCode)) { summary.NoDestination = true; summary.DestinationIdInput = null; continue; } var destination = destinations.FirstOrDefault(x => x.CustomerId == summary.CustomerId && x.Code == summary.DestinationCode); if (destination == null) { ShowWarningDialog(MsgWngMasterNotExist, "送付先", summary.DestinationCode); return; } summary.DestinationIdInput = destination.Id; } var summaryList = new List <ReminderSummary>(); var gDestination = ReminderSummary.GroupBy(x => new { x.CustomerCode, x.DestinationCode }).Select(x => x); foreach (var grs in gDestination) { var summary = grs.First(); var destinationIds = new List <ReminderSummary>(); foreach (var item in ReminderSummary.Where(x => x.CustomerId == summary.CustomerId && x.DestinationCode == summary.DestinationCode)) { if (item.DestinationId == null) { summary.NoDestination = true; } else { destinationIds.Add(item); } } summary.CompanyId = CompanyId; summary.CustomerIds = new int[] { summary.CustomerId }; summary.DestinationIds = destinationIds.Select(x => x.DestinationId.Value).Distinct().ToArray(); summaryList.Add(summary); } var reminderBillingResult = await GetReminderBillingForSummaryPrintByDestinationCodeAsync(summaryList); var reminderBilling = reminderBillingResult.ReminderBilling; var outputNo = 1; var countResult = await GetMaxOutputNoAsync(); if (countResult.ProcessResult.Result) { outputNo = countResult.Count + 1; } var reportList = new List <ReminderReport>(); var now = DateTime.Now; ReminderReport allReport = null; foreach (var gdr in gDestination) { var r = gdr.First(); var template = ReminderTemplateSetting.First(x => x.Id == r.TemplateId); var source = reminderBilling.Where(x => x.CustomerId == r.CustomerId && x.DestinationId == r.DestinationIdInput); foreach (var b in source) { var output = new ReminderOutputed(); output.OutputNo = outputNo; output.BillingId = b.Id; output.ReminderId = b.ReminderId; output.RemainAmount = b.RemainAmount; output.BillingAmount = b.BillingAmount; output.ReminderTemplateId = r.TemplateId; output.OutputAt = now; output.DestinationId = r.DestinationIdInput; reminderOutputed.Add(output); b.OutputNo = outputNo; } var report = UtilReminder.CreateReminderReport(source, ReminderCommonSetting, ReminderSummarySetting, template, Company, ColumnNameSettingInfo, now, PdfSetting); if (PdfSetting.IsAllInOne) { if (allReport == null) { allReport = report; } else { allReport.Document.Pages.AddRange((PagesCollection)report.Document.Pages.Clone()); } } else { reportList.Add(report); } outputNo++; } if (PdfSetting.IsAllInOne) { Action <Form> outputHandler = owner => { var taskOutput = SaveOutputAtReminderSummaryAsync(reminderOutputed.ToArray(), ReminderSummary.ToArray()); ProgressDialog.Start(owner, taskOutput, false, SessionKey); updateResult = taskOutput.Result; }; updateResult = null; ShowDialogPreview(ParentForm, allReport, GetServerPath(), outputHandler); } else { var exporter = new PdfReportExporter(); var fileList = new List <string>(); foreach (var rpt in reportList) { var filePath = Util.GetUniqueFileName(Path.Combine(path, $"{rpt.Name}.pdf")); exporter.PdfExport(rpt, filePath); if (PdfSetting.UseZip) { fileList.Add(filePath); } } if (PdfSetting.UseZip) { Util.ArchivesAsZip(fileList, path, $"督促状{now.ToString("yyyyMMdd")}", PdfSetting.MaximumByte); } updateResult = await SaveOutputAtReminderSummaryAsync(reminderOutputed.ToArray(), ReminderSummary.ToArray()); } if (PdfSetting.IsAllInOne && updateResult == null) { return; } else if (!updateResult.ProcessResult.Result || updateResult.Count <= 0) { ShowWarningDialog(MsgErrExportError); } else { ParentForm.DialogResult = DialogResult.OK; } } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); ShowWarningDialog(MsgErrExportError); } }
private async Task PrintSummarized(string path) { try { var reminderOutputed = new List <ReminderOutputed>(); var updateResult = new CountResult(); List <ReminderBilling> reminderBilling = null; var outputNo = 1; var reminderResult = await GetReminderBillingForSummaryPrintAsync(ReminderSummary.Select(x => x.CustomerId).ToArray()); reminderBilling = reminderResult.ReminderBilling; var countResult = await GetMaxOutputNoAsync(); if (countResult.ProcessResult.Result) { outputNo = countResult.Count + 1; } var reportList = new List <ReminderReport>(); var now = DateTime.Now; ReminderReport allReport = null; foreach (var r in ReminderSummary) { var template = ReminderTemplateSetting.First(x => x.Id == r.TemplateId); var source = reminderBilling.Where(x => x.CustomerId == r.CustomerId); foreach (var b in source) { var output = new ReminderOutputed(); output.OutputNo = outputNo; output.BillingId = b.Id; output.ReminderId = b.ReminderId; output.RemainAmount = b.RemainAmount; output.BillingAmount = b.BillingAmount; output.ReminderTemplateId = r.TemplateId; output.OutputAt = now; reminderOutputed.Add(output); b.OutputNo = outputNo; } var report = UtilReminder.CreateReminderReport(source, ReminderCommonSetting, ReminderSummarySetting, template, Company, ColumnNameSettingInfo, now, PdfSetting); if (PdfSetting.IsAllInOne) { if (allReport == null) { allReport = report; } else { allReport.Document.Pages.AddRange((PagesCollection)report.Document.Pages.Clone()); } } else { reportList.Add(report); } outputNo++; } if (PdfSetting.IsAllInOne) { Action <Form> outputHandler = owner => { var taskOutput = SaveOutputAtReminderSummaryAsync(reminderOutputed.ToArray(), ReminderSummary.ToArray()); ProgressDialog.Start(owner, taskOutput, false, SessionKey); updateResult = taskOutput.Result; }; updateResult = null; ShowDialogPreview(ParentForm, allReport, GetServerPath(), outputHandler); } else { var exporter = new PdfReportExporter(); var fileList = new List <string>(); foreach (var rpt in reportList) { var filePath = Util.GetUniqueFileName(Path.Combine(path, $"{rpt.Name}.pdf")); exporter.PdfExport(rpt, filePath); if (PdfSetting.UseZip) { fileList.Add(filePath); } } if (PdfSetting.UseZip) { Util.ArchivesAsZip(fileList, path, $"督促状{now.ToString("yyyyMMdd")}", PdfSetting.MaximumByte); } updateResult = await SaveOutputAtReminderSummaryAsync(reminderOutputed.ToArray(), ReminderSummary.ToArray()); } if (PdfSetting.IsAllInOne && updateResult == null) { return; } else if (!updateResult.ProcessResult.Result || updateResult.Count <= 0) { ShowWarningDialog(MsgErrExportError); } else { ParentForm.DialogResult = DialogResult.OK; } } catch (Exception ex) { Debug.Fail(ex.ToString()); NLogHandler.WriteErrorLog(this, ex, SessionKey); ShowWarningDialog(MsgErrExportError); } }