Exemple #1
0
 public async Task <ReceiptImportDuplicationResult> ReceiptImportDuplicationCheckAsync(string SessionKey, int CompanyId, ReceiptImportDuplication[] ReceiptImportDuplication, ImporterSettingDetail[] ImporterSettingDetail)
 {
     return(await authorizationProcessor.DoAuthorizeAsync(SessionKey, async token =>
     {
         var result = (await receiptProcessor.ReceiptImportDuplicationCheckAsync(CompanyId, ReceiptImportDuplication, ImporterSettingDetail, token)).ToArray();
         return new ReceiptImportDuplicationResult
         {
             ProcessResult = new ProcessResult {
                 Result = true
             },
             RowNumbers = result,
         };
     }, logger));
 }
        /// <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(),
            });
        }
Exemple #3
0
 public async Task <IEnumerable <int> > ReceiptImportDuplicationCheck(ReceiptImportDuplicationSearch option, CancellationToken token)
 => (await receiptProcessor.ReceiptImportDuplicationCheckAsync(option.CompanyId, option.Items, option.Details, token)).ToArray();