/// <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, }); }
public async Task <ScheduledPaymentImportResult> ImportScheduledPaymentAsync(string SessionKey, int CompanyId, int LoginUserId, int ImporterSettingId, ScheduledPaymentImport[] SchedulePayment) { return(await authorizationProcessor.DoAuthorizeAsync(SessionKey, async token => { var result = (await billingScheduledPaymentProcessor.ImportAsync(new BillingScheduledPaymentImportSource { CompanyId = CompanyId, LoginUserId = LoginUserId, ImporterSettingId = ImporterSettingId, Items = SchedulePayment, }, token)).ToArray(); return new ScheduledPaymentImportResult { ProcessResult = new ProcessResult { Result = true }, ScheduledPaymentImport = result, }; }, logger)); }