/// <summary>インポート処理 データ登録</summary>
        /// <param name="source"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public async Task <ImportDataResult> ImportAsync(TransactionImportSource source, CancellationToken token = default(CancellationToken))
        {
            var companyTask = companyProcessor.GetAsync(new CompanySearch {
                Id = source.CompanyId,
            }, token);
            var appConTask = applicationControlProcessor.GetAsync(source.CompanyId, token);

            await Task.WhenAll(companyTask, appConTask);

            var company            = companyTask.Result.First();
            var applicationControl = appConTask.Result;

            var importDataId = source.ImportDataId ?? 0;

            var importer = new ReceiptImporterBase(applicationControl)
            {
                CompanyId           = source.CompanyId,
                CompanyCode         = company.Code,
                LoginUserId         = source.LoginUserId,
                ImporterSettingId   = source.ImporterSettingId,
                Deserialize         = bytes => serializer.UnpackSingleObject(bytes),
                LoadImportDataAsync = () => importDataProcessor.GetAsync(importDataId, objectType: 0, token: token),
                SaveInnerAsync      = items => receiptProcessor.SaveAsync(new ReceiptSaveItem {
                    Receipts = items,
                }, token),
            };

            var result = await importer.ImportAsync();

            return(new ImportDataResult {
                SaveCount = importer.SaveCount,
                SaveAmount = importer.SaveAmount,
            });
        }
        /// <summary>読み込み・検証・一時データ登録処理</summary>
        /// <param name="source"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public async Task <ImportDataResult> ReadAsync(TransactionImportSource source, CancellationToken token = default(CancellationToken))
        {
            var encoding = Encoding.GetEncoding(source.EncodingCodePage);
            var csv      = encoding.GetString(source.Data);

            var companyTask = companyProcessor.GetAsync(new CompanySearch {
                Id = source.CompanyId,
            }, token);
            var appConTask = applicationControlProcessor.GetAsync(source.CompanyId, token);

            await Task.WhenAll(companyTask, appConTask);

            var company            = companyTask.Result.First();
            var applicationControl = appConTask.Result;

            var importer = new BillingImporterBase(applicationControl)
            {
                CompanyId         = source.CompanyId,
                CompanyCode       = company.Code,
                LoginUserId       = source.LoginUserId,
                ImporterSettingId = source.ImporterSettingId,
                FilePath          = csv,
                CsvParser         = new CsvParser {
                    Encoding      = encoding,
                    StreamCreator = new PlainTextMemoryStreamCreator(),
                },
                GetImporterSettingAsync       = settingId => GetImporterSettingAsync(settingId, token),
                GetImporterSettingDetailAsync = settingId => GetImporterSettingDetailsAsync(settingId, token),
                GetCurrencyAsync = companyId => GetCurrenciesAsync(companyId, token),
                GetJuridicalParsonalitiesAsync = companyId => GetJuridicalParsonalitiesAsync(companyId, token),
                GetGeneralSettingValueAsync    = (companyId, code) => GetGeneralSettingValueAsync(companyId, code, token),
                GetTaxClassAsync = () => GetTaxClassesAsync(token),
                GetBillingDivisionContractByCustomerIdsAsync = ids => GetBillingDivisionsByCustomerIdsAsync(ids, token),
                GetHolidayCalendarsAsync           = companyId => GetHolidayCalendarsAsync(companyId, token),
                LoadColumnNameSettingsInnerAsync   = tableName => GetColumnNamesAsync(source.CompanyId, tableName, token),
                BillingImportDuplicationCheckAsync = (companyId, items, details) => GetDuplicationRows(companyId, items, details, token),
                GetCustomerByCodesAsync            = (companyId, codes) => GetCustomersAsync(companyId, codes, token),
                GetDepartmentByCodesAsync          = (companyId, codes) => GetDepartmntsAdync(companyId, codes, token),
                GetAccountTitleByCodesAsync        = (companyId, codes) => GetAccountTitlesAsync(companyId, codes, token),
                GetStaffByCodesAsync       = (companyId, codes) => GetStaffsAsync(companyId, codes, token),
                GetCategoriesByCodesAsync  = (companyId, categoryType, codes) => GetCategoriesAsync(companyId, categoryType, codes, token),
                GetIsEnableToEditNoteAsync = companyId => GetIsEnableToEditNoteAsync(companyId, token),

                Serialize           = item => serializer.PackSingleObject(item),
                SaveImportDataAsync = data => importDataProcessor.SaveAsync(data, token),
            };
            var readResult = await importer.ReadCsvAsync();

            return(new ImportDataResult {
                ImportData = importer.ImportData,
                ReadCount = importer.ReadCount,
                ValidCount = importer.ValidCount,
                InvalidCount = importer.InvalidCount,
                NewCustomerCreationCount = importer.NewCustomerCreationCount,
                Logs = importer.GetValidationLogs(),
            });
        }
示例#3
0
        /// <summary>読込・検証処理</summary>
        /// <param name="source"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public async Task <ImportDataResult> ReadAsync(TransactionImportSource source, CancellationToken token = default(CancellationToken))
        {
            var encoding = Encoding.GetEncoding(source.EncodingCodePage);
            var csv      = encoding.GetString(source.Data);

            var companyTask = GetCompanyAsync(source.CompanyId, token);
            var appConTask  = GetApplicationControlAsync(source.CompanyId, token);

            await Task.WhenAll(companyTask, appConTask);

            var company            = companyTask.Result;
            var applicationControl = appConTask.Result;

            var importer = new PaymentScheduleImporterBase(applicationControl)
            {
                CompanyId         = source.CompanyId,
                CompanyCode       = company.Code,
                LoginUserId       = source.LoginUserId,
                ImporterSettingId = source.ImporterSettingId,
                FilePath          = csv,
                CsvParser         = new CsvParser {
                    Encoding      = encoding,
                    StreamCreator = new PlainTextMemoryStreamCreator(),
                },
                DoTargetNotMatchedData    = source.DoTargetNotMatchedData,
                DoReplaceAmount           = source.DoReplaceAmount,
                DoIgnoreSameCustomerGroup = source.DoIgnoreSameCustomerGroup,

                GetImporterSettingAsync                = settingId => GetImporterSettingAsync(settingId, token),
                GetImporterSettingDetailByIdAsync      = settingId => GetImporterSettingDetailsAsync(settingId, token),
                GetItemsForScheduledPaymentImportAsync = (companyId, items, details) => GetBillingsAsync(companyId, items, details, token),
                GetGeneralSettingValueAsync            = (companyId, code) => GetGeneranSettingValueAsync(companyId, code, token),
                GetCustomerByCodesAsync                = (companyId, codes) => GetCustomersAsync(companyId, codes, token),
                GetDepartmentByCodesAsync              = (companyId, codes) => GetDepartmentsAsync(companyId, codes, token),
                GetAccountTitleByCodesAsync            = (companyId, codes) => GetAccountTitlesAsync(companyId, codes, token),
                GetCategoriesByCodesAsync              = (companyId, categoryType, codes) => GetCategoriesAsync(companyId, categoryType, codes, token),
                GetCurrenciesAsync = (companyId, codes) => GetCurrenciesAsync(companyId, codes, token),

                SerializeScheduledPaymentImport = item => serializerScheduledPaymentImport.PackSingleObject(item),
                SerializePaymentSchedule        = item => serializerPaymentSchedule.PackSingleObject(item),
                SaveImportDataAsync             = data => importDataProcessor.SaveAsync(data, token),
            };

            var readResult = importer.ReadCsvAsync();

            return(new ImportDataResult {
                ImportData = importer.ImportData,
                ReadCount = importer.ReadCount,
                ValidCount = importer.ValidCount,
                InvalidCount = importer.InvalidCount,
                Logs = importer.GetValidationLogs(),
            });
        }
示例#4
0
        /// <summary>登録処理</summary>
        /// <param name="source"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public async Task <ImportDataResult> ImportAsync(TransactionImportSource source, CancellationToken token = default(CancellationToken))
        {
            var companyTask = GetCompanyAsync(source.CompanyId, token);
            var appConTask  = GetApplicationControlAsync(source.CompanyId, token);

            await Task.WhenAll(companyTask, appConTask);

            var company            = companyTask.Result;
            var applicationControl = appConTask.Result;

            var importDataId = source.ImportDataId ?? 0;

            var importer = new PaymentScheduleImporterBase(applicationControl)
            {
                CompanyId         = source.CompanyId,
                CompanyCode       = company.Code,
                LoginUserId       = source.LoginUserId,
                ImporterSettingId = source.ImporterSettingId,

                DoTargetNotMatchedData    = source.DoTargetNotMatchedData,
                DoReplaceAmount           = source.DoReplaceAmount,
                DoIgnoreSameCustomerGroup = source.DoIgnoreSameCustomerGroup,

                Deserialize         = bytes => serializerScheduledPaymentImport.UnpackSingleObject(bytes),
                LoadImportDataAsync = () => importDataProcessor.GetAsync(importDataId, objectType: 0, token: token),
                SaveInnerAsync      = async(companyId, loginUserId, settingId, items) => {
                    var results = (await billingScheduledPaymentProcessor.ImportAsync(new BillingScheduledPaymentImportSource {
                    }, token)).ToArray();
                    return(new ScheduledPaymentImportResult {
                        ProcessResult = new ProcessResult {
                            Result = true,
                        },
                        ScheduledPaymentImport = results,
                    });
                },
            };

            var result = await importer.ImportAsync();

            return(new ImportDataResult {
                SaveCount = importer.SaveCount,
                SaveAmount = importer.SaveAmount,
            });
        }
示例#5
0
        public async Task <byte[]> GetAsync(TransactionImportSource source, CancellationToken token = default(CancellationToken))
        {
            var companyId    = source.CompanyId;
            var importDataId = source.ImportDataId.Value;
            var objectType   = source.IsValidData ? 0 : 1;

            var companyTask = companyQueryProcessor.GetAsync(new CompanySearch {
                Id = companyId,
            }, token);
            var appConTask     = applicationControlGetByCompanyQueryProcessor.GetAsync(companyId, token);
            var columnNameTask = columnNameSettingQueryProcessor.GetAsync(new ColumnNameSetting
            {
                CompanyId  = companyId,
                TableName  = nameof(Billing),
                ColumnName = nameof(Billing.Note1),
            }, token);
            var itemsTask = importDataDetailQueryProcessor.GetAsync(importDataId, objectType, token);

            await Task.WhenAll(companyTask, appConTask, columnNameTask, itemsTask);

            var company = companyTask.Result.First();
            var appCon  = appConTask.Result;
            var note1   = columnNameTask.Result.FirstOrDefault()?.DisplayColumnName ?? "備考";
            var details = itemsTask.Result.ToArray();
            var items   = details.Select(x => serializer.UnpackSingleObject(x.RecordItem)).ToList();

            if (!items.Any())
            {
                return(null);
            }

            var useForeignCurrency = appCon.UseForeignCurrency == 1;

            var report = new BillingImporterSectionReport();

            var title = $"請求フリーインポーター 取込{(source.IsValidData ? "可能" : "不可能")}データ一覧{DateTime.Now:yyyyMMdd}";

            report.SetBasicPageSetting(company.Code, company.Name);
            report.Name = title;
            report.SetData(items, title, useForeignCurrency, note1);
            report.Run();

            return(report.Convert());
        }
        /// <summary>得意先取得</summary>
        /// <param name="source">CompanyId, ImprotSettingId, ImportDataId</param>
        /// <param name="token"></param>
        /// <returns></returns>
        public async Task <IEnumerable <Customer> > GetCustomers(TransactionImportSource source, CancellationToken token = default(CancellationToken))
        {
            var importDataId   = source.ImportDataId ?? 0;
            var detailsTask    = GetImporterSettingDetailsAsync(source.ImporterSettingId, token);
            var importDataTask = importDataProcessor.GetAsync(importDataId);
            var categoryTask   = categoryProcessor.GetAsync(new CategorySearch {
                CompanyId = source.CompanyId, CategoryType = Rac.VOne.Common.CategoryType.Collect,
            }, token);

            await Task.WhenAll(detailsTask, importDataTask, categoryTask);

            var details            = detailsTask.Result;
            var importData         = importDataTask.Result;
            var categoryDictionary = categoryTask.Result.ToDictionary(x => x.Code);

            var billings = importData.Details.Select(x => serializer.UnpackSingleObject(x.RecordItem));

            return(billings.ConvertToCustomers(details, source.LoginUserId, categoryDictionary).ToArray());
        }
        /// <summary>読み込み・検証・一時データ登録処理</summary>
        /// <param name="source"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public async Task <ImportDataResult> ReadAsync(TransactionImportSource source, CancellationToken token = default(CancellationToken))
        {
            var encoding = Encoding.GetEncoding(source.EncodingCodePage);
            var csv      = encoding.GetString(source.Data);

            var companyTask = companyProcessor.GetAsync(new CompanySearch {
                Id = source.CompanyId,
            }, token);
            var appConTask = applicationControlProcessor.GetAsync(source.CompanyId, token);

            await Task.WhenAll(companyTask, appConTask);

            var company            = companyTask.Result.First();
            var applicationControl = appConTask.Result;

            var importer = new ReceiptImporterBase(applicationControl)
            {
                CompanyId         = source.CompanyId,
                CompanyCode       = company.Code,
                LoginUserId       = source.LoginUserId,
                ImporterSettingId = source.ImporterSettingId,
                FilePath          = csv,
                CsvParser         = new CsvParser {
                    Encoding      = encoding,
                    StreamCreator = new PlainTextMemoryStreamCreator(),
                },
                GetImporterSettingAsync            = async settingId => (await importerSettingProcessor.GetAsync(new ImporterSetting {
                    Id = settingId
                }, token)).FirstOrDefault(),
                GetImporterSettingDetailByIdAsync  = async settingId => (await importerSettingDetailProcessor.GetAsync(new ImporterSetting {
                    Id = settingId
                }, token)).ToList(),
                GetGeneralSettingValueAsync        = async(companyId, code) => (await generalSettingProcessor.GetAsync(new GeneralSetting {
                    CompanyId = companyId, Code = code,
                }, token)).FirstOrDefault()?.Value,
                ReceiptImportDuplicationCheckAsync = async(companyid, items, details) => (await receiptProcessor.ReceiptImportDuplicationCheckAsync(companyid, items, details, token)).ToArray(),

                GetCurrenciesAsync               = async(companyId, codes) => (await currencyProcessor.GetAsync(new CurrencySearch {
                    CompanyId = companyId, Codes = codes,
                }, token)).ToList(),
                GetCategoriesByCodesAsync        = async(companyId, categoryType, codes) => (await categoryProcessor.GetAsync(new CategorySearch {
                    CompanyId = companyId, CategoryType = categoryType, Codes = codes,
                }, token)).ToList(),
                GetSectionByCodesAsync           = async(companyId, codes) => (await sectionProcessor.GetAsync(new SectionSearch {
                    CompanyId = companyId, Codes = codes,
                }, token)).ToList(),
                GetCustomerByCodesAsync          = async(companyId, codes) => (await customerProcessor.GetAsync(new CustomerSearch {
                    CompanyId = companyId, Codes = codes,
                }, token)).ToList(),
                GetLegalPersonaritiesAsync       = async(companyId) => (await juridicalPersonalityProcessor.GetAsync(new JuridicalPersonality {
                    CompanyId = companyId,
                }, token)).Select(x => x.Kana).ToArray(),
                GetCollationSettingAsync         = companyId => collationSettingProcessor.GetAsync(companyId, token),
                LoadColumnNameSettingsInnerAsync = async tableName => (await columnNameSettingProcessor.GetAsync(new ColumnNameSetting {
                    CompanyId = source.CompanyId, TableName = tableName,
                }, token)).ToArray(),

                Serialize           = item => serializer.PackSingleObject(item),
                SaveImportDataAsync = data => importDataProcessor.SaveAsync(data, token),
            };

            var readResult = await importer.ReadCsvAsync();

            return(new ImportDataResult {
                ImportData = importer.ImportData,
                ReadCount = importer.ReadCount,
                ValidCount = importer.ValidCount,
                InvalidCount = importer.InvalidCount,
                Logs = importer.GetValidationLogs(),
            });
        }
示例#8
0
 public async Task <ImportDataResult> Import(TransactionImportSource source, CancellationToken token)
 => await receiptFileImportProcessor.ImportAsync(source, token);
示例#9
0
 public async Task <ActionResult <ImportDataResult> > Read(TransactionImportSource source, CancellationToken token)
 => await receiptFileImportProcessor.ReadAsync(source, token);
示例#10
0
 public async Task <ImportDataResult> ImportPaymentSchedule(TransactionImportSource source, CancellationToken token)
 => await paymentScheduleFileImportProcessor.ImportAsync(source, token);
示例#11
0
 public async Task <IEnumerable <Customer> > GetImportNewCustomer(TransactionImportSource source, CancellationToken token)
 => (await billingFileImportProcessor.GetCustomers(source, token)).ToArray();
示例#12
0
 public async Task <ImportDataResult> Read(TransactionImportSource source, CancellationToken token)
 => await billingFileImportProcessor.ReadAsync(source, token);
示例#13
0
 public async Task <ActionResult <ImportDataResult> > ReadScheduledPayment(TransactionImportSource source, CancellationToken token)
 => await paymentScheduleFileImportProcessor.ReadAsync(source, token);
示例#14
0
 public async Task <ActionResult <ImportDataResult> > Import(TransactionImportSource source, CancellationToken token)
 => await billingFileImportProcessor.ImportAsync(source, token);