示例#1
0
 public async Task <PaymentAgenciesResult> GetItemsAsync(string SessionKey, int CompanyId)
 {
     return(await authorizationProcessor.DoAuthorizeAsync(SessionKey, async token =>
     {
         var result = (await paymentAgencyProcessor.GetAsync(new MasterSearchOption {
             CompanyId = CompanyId,
         }, token)).ToList();
         return new PaymentAgenciesResult
         {
             ProcessResult = new ProcessResult {
                 Result = true
             },
             PaymentAgencies = 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 agencyTask = paymentAgencyProcessor.GetAsync(new MasterSearchOption {
                CompanyId = source.CompanyId,
            }, token);

            await Task.WhenAll(companyTask, loginUserTask, appConTask, agencyTask);

            var company          = companyTask.Result.First();
            var loginUser        = loginUserTask.Result.First();
            var appCon           = appConTask.Result;
            var agencyDictionary = agencyTask.Result.ToDictionary(x => x.Code);

            var definition = new KanaHistoryPaymentAgencyFileDefinition(new DataExpression(appCon));

            definition.PaymentAgencyIdField.GetModelsByCode = val => agencyDictionary;
            var parser = new CsvParser {
                Encoding      = encoding,
                StreamCreator = new PlainTextMemoryStreamCreator(),
            };

            var importer = definition.CreateImporter(x => new { x.PayerName, x.SourceBankName, x.SourceBranchName, x.PaymentAgencyId }, parser);

            importer.UserId      = source.LoginUserId;
            importer.UserCode    = loginUser.Code;
            importer.CompanyId   = source.CompanyId;
            importer.CompanyCode = company.Code;
            importer.LoadAsync   = () => kanaHistoryPaymentAgencyProcessor.GetAsync(new KanaHistorySearch {
                CompanyId = source.CompanyId,
            }, token);
            importer.RegisterAsync = x => kanaHistoryPaymentAgencyProcessor.ImportAsync(x.New, x.Dirty, x.Removed, token);

            var result = await importer.ImportAsync(csv, mode, token, null);

            result.Logs = importer.GetErrorLogs();

            return(result);
        }
示例#3
0
 public async Task <ActionResult <IEnumerable <PaymentAgency> > > GetItems(MasterSearchOption option, CancellationToken token)
 => (await paymentAgencyProcessor.GetAsync(option, token)).ToArray();