public async Task <IgnoreKanasResult> GetItemsAsync(string sessionKey, int companyId) { return(await authorizationProcessor.DoAuthorizeAsync(sessionKey, async token => { var result = (await ignoreKanaProcessor.GetAsync(new IgnoreKana { CompanyId = companyId }, token)).ToList(); return new IgnoreKanasResult { ProcessResult = new ProcessResult { Result = true }, IgnoreKanas = result, }; }, logger)); }
/// <summary>インポート処理</summary> /// <param name="source"></param> /// <param name="token"></param> /// <returns></returns> public async Task <ImportResult> ImportAsync(MasterImportSource source, CancellationToken token = default(CancellationToken)) { var mode = (ImportMethod)source.ImportMethod; var encoding = Encoding.GetEncoding(source.EncodingCodePage); var csv = encoding.GetString(source.Data); var companyTask = companyProcessor.GetAsync(new CompanySearch { Id = source.CompanyId, }, token); var loginUserTask = loginUserProcessor.GetAsync(new LoginUserSearch { Ids = new[] { source.LoginUserId }, }, token); var appConTask = applicationControlProcessor.GetAsync(source.CompanyId, token); var categoryTask = categoryProcessor.GetAsync(new CategorySearch { CompanyId = source.CompanyId, CategoryType = CategoryType.Exclude, }, token); await Task.WhenAll(companyTask, loginUserTask, appConTask, categoryTask); var company = companyTask.Result.First(); var loginUser = loginUserTask.Result.First(); var appCon = appConTask.Result; var categoryDictionary = categoryTask.Result.ToDictionary(x => x.Code); var definition = new IgnoreKanaFileDefinition(new DataExpression(appCon)); var parser = new CsvParser { Encoding = encoding, StreamCreator = new PlainTextMemoryStreamCreator(), }; definition.ExcludeCategoryIdField.GetModelsByCode = val => categoryDictionary; var importer = definition.CreateImporter(m => m.Kana, parser); importer.UserId = source.LoginUserId; importer.UserCode = loginUser.Code; importer.CompanyId = source.CompanyId; importer.CompanyCode = company.Code; importer.LoadAsync = () => ignoreKanaProcessor.GetAsync(new IgnoreKana { CompanyId = source.CompanyId, }, token); importer.RegisterAsync = x => ignoreKanaProcessor.ImportAsync(x.New, x.Dirty, x.Removed, token); var result = await importer.ImportAsync(csv, mode, token, null); result.Logs = importer.GetErrorLogs(); return(result); }
public async Task <ActionResult <IEnumerable <IgnoreKana> > > GetItems(IgnoreKana kana, CancellationToken token) => (await ignoreKanaProcessor.GetAsync(kana, token)).ToArray();
/// <summary>constructor</summary> public EbFileImportProcessor( ICompanyProcessor companyProcessor, ILoginUserProcessor loginUserProcessor, IApplicationControlProcessor applicationControlProcessor, ICollationSettingProcessor collationSettingProcessor, ICategoryProcessor categoryProcessor, ICurrencyProcessor currencyProcessor, IJuridicalPersonalityProcessor juridicalPersonalityProcessor, IBankAccountProcessor bankAccountProcessor, ICustomerProcessor customerProcessor, IIgnoreKanaProcessor ignoreKanaProcessor, IEBExcludeAccountSettingProcessor ebExcludeAccountSettingProcessor, ISectionProcessor sectionProcessor, IImportFileLogProcessor importFileLogProcessor ) { this.companyProcessor = companyProcessor; this.loginUserProcessor = loginUserProcessor; this.applicationControlProcessor = applicationControlProcessor; this.collationSettingProcessor = collationSettingProcessor; this.categoryProcessor = categoryProcessor; this.currencyProcessor = currencyProcessor; this.juridicalPersonalityProcessor = juridicalPersonalityProcessor; this.bankAccountProcessor = bankAccountProcessor; this.ignoreKanaProcessor = ignoreKanaProcessor; this.customerProcessor = customerProcessor; this.ebExcludeAccountSettingProcessor = ebExcludeAccountSettingProcessor; this.sectionProcessor = sectionProcessor; this.importFileLogProcessor = importFileLogProcessor; importer = new EbDataImporterBase { IsAsync = true, IsPlainText = true, }; importer.Helper.InitializeAsync = async token => { var applicationControlTask = applicationControlProcessor.GetAsync(importer.Helper.CompanyId, token); var collationSettingTask = collationSettingProcessor.GetAsync(importer.Helper.CompanyId, token); var defaultCurrencyTask = currencyProcessor.GetAsync(new CurrencySearch { CompanyId = importer.Helper.CompanyId, Codes = new[] { Rac.VOne.Common.Constants.DefaultCurrencyCode }, }, token); var defaultReceiptCategoryTask = categoryProcessor.GetAsync(new CategorySearch { CompanyId = importer.Helper.CompanyId, CategoryType = CategoryType.Receipt, Codes = new[] { "01" }, }, token); var juridicalPersonalityTask = juridicalPersonalityProcessor.GetAsync(new JuridicalPersonality { CompanyId = importer.Helper.CompanyId }, token); await Task.WhenAll( applicationControlTask, collationSettingTask, defaultCurrencyTask, defaultReceiptCategoryTask, juridicalPersonalityTask ); importer.Helper.ApplicationControl = applicationControlTask.Result; importer.Helper.CollationSetting = collationSettingTask.Result; importer.Helper.DefaultCurrency = defaultCurrencyTask.Result.First(); importer.Helper.DefaultReceiptCategory = defaultReceiptCategoryTask.Result.First(); importer.Helper.LegalPersonalities = juridicalPersonalityTask.Result.Select(x => x.Kana).ToArray(); }; importer.Helper.GetBankAccountAsync = async(bankCode, branchCode, accountTypeId, accountNumber, token) => { var result = await bankAccountProcessor.GetAsync(new BankAccountSearch { CompanyId = importer.Helper.CompanyId, BankCodes = new[] { bankCode }, BranchCodes = new[] { branchCode }, AccountTypeId = accountTypeId, AccountNumber = accountNumber, }, token); return(result.FirstOrDefault()); }; importer.Helper.GetBankAccountByBankNameAsync = async(bankName, branchName, accountTypeId, accountNumber, token) => { var result = await bankAccountProcessor.GetAsync(new BankAccountSearch { CompanyId = importer.Helper.CompanyId, BankName = bankName, BranchName = branchName, AccountTypeId = accountTypeId, AccountNumber = accountNumber, }, token); return(result.FirstOrDefault()); }; importer.Helper.GetBankAccountByBranchNameAsync = async(bankCode, branchName, token) => { var result = await bankAccountProcessor.GetAsync(new BankAccountSearch { CompanyId = importer.Helper.CompanyId, BankCodes = new[] { bankCode }, BranchName = branchName, }, token); return(result.FirstOrDefault()); }; importer.Helper.GetBankAccountByBranchNameAndNumberAsync = async(bankCode, branchName, accountTypeId, accountNumber, token) => { var result = await bankAccountProcessor.GetAsync(new BankAccountSearch { CompanyId = importer.Helper.CompanyId, BankCodes = new[] { bankCode }, BranchName = branchName, AccountTypeId = accountTypeId, AccountNumber = accountNumber, }, token); return(result.FirstOrDefault()); }; importer.Helper.GetCustomerIdByExclusiveInfoAsync = async(bankCode, branchCode, payerCode, token) => { var result = await customerProcessor.GetAsync(new CustomerSearch { CompanyId = importer.Helper.CompanyId, ExclusiveBankCode = bankCode, ExclusiveBranchCode = branchCode, ExclusiveAccountNumber = payerCode, }, token); return(result.FirstOrDefault()?.Id); }; importer.Helper.GetSectionIdByPayerCodeAsync = async(payerCode, token) => { var result = await sectionProcessor.GetAsync(new SectionSearch { CompanyId = importer.Helper.CompanyId, PayerCodes = new[] { payerCode }, }, token); return(result.FirstOrDefault()?.Id); }; importer.Helper.GetExcludeCategoryIdAsync = async(payerName, token) => { var result = await ignoreKanaProcessor.GetAsync(new IgnoreKana { CompanyId = importer.Helper.CompanyId, Kana = payerName, }, token); return(result.FirstOrDefault()?.ExcludeCategoryId); }; importer.Helper.GetEBExcludeAccountSettingListAsync = async token => (await ebExcludeAccountSettingProcessor.GetAsync(importer.Helper.CompanyId, token)).ToList(); importer.Helper.SaveDataInnerAsync = async(logs, token) => (await importFileLogProcessor.SaveAsync(logs, token)).ToList(); }