mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-21 02:17:20 +02:00
80 lines
3.2 KiB
C#
80 lines
3.2 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using WotBlitzStatisticsPro.Common.Model;
|
|
using WotBlitzStatisticsPro.Logic.AccountInformationPipeline;
|
|
using WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations;
|
|
using WotBlitzStatisticsPro.Logic.Pipeline;
|
|
|
|
namespace WotBlitzStatisticsPro.Logic
|
|
{
|
|
public class WargamingAccounts: IWargamingAccounts
|
|
{
|
|
private readonly IOperationFactory _operationFactory;
|
|
|
|
public WargamingAccounts(IOperationFactory operationFactory)
|
|
{
|
|
_operationFactory = operationFactory;
|
|
}
|
|
|
|
public async Task<AccountInfoResponse> GatherAccountInformation(RealmType realm, long accountId, RequestLanguage requestLanguage)
|
|
{
|
|
var context = new AccountInformationPipelineContext(accountId, realm, requestLanguage);
|
|
var pipeline = new Pipeline<AccountInformationPipelineContext>(_operationFactory);
|
|
|
|
pipeline.AddOperation<GetAccountInfoOperation>()
|
|
.AddOperation<GetTanksInfoOperation>()
|
|
.AddOperation<CalculateStatisticsOperation>()
|
|
.AddOperation<BuildAccountInfoResponseOperation>()
|
|
;
|
|
|
|
await pipeline.Build()
|
|
.Invoke(context, null)
|
|
.ConfigureAwait(false);
|
|
|
|
return context.Response;
|
|
}
|
|
|
|
public async Task<AccountInfoResponse> GatherAndSaveAccountInformation(RealmType realm, long accountId, RequestLanguage requestLanguage)
|
|
{
|
|
var context = new AccountInformationPipelineContext(accountId, realm, requestLanguage);
|
|
var pipeline = new Pipeline<AccountInformationPipelineContext>(_operationFactory);
|
|
|
|
pipeline.AddOperation<GetAccountInfoOperation>()
|
|
.AddOperation<ReadAccountInfoFromDbOperation>()
|
|
.AddOperation<CheckLastBattleDateOperation>()
|
|
.AddOperation<GetTanksInfoOperation>()
|
|
.AddOperation<CalculateStatisticsOperation>()
|
|
.AddOperation<SaveAccountAndTanksOperation>()
|
|
.AddOperation<BuildAccountInfoResponseOperation>()
|
|
;
|
|
|
|
await pipeline.Build()
|
|
.Invoke(context, null)
|
|
.ConfigureAwait(false);
|
|
|
|
return context.Response;
|
|
}
|
|
|
|
public async Task<AccountInfoHistoryResponse> GetAccountInfoHistory(RealmType realm, long accountId, DateTime startDate, RequestLanguage requestLanguage)
|
|
{
|
|
var context = new HistoryInformationPipelineContext(accountId, realm, requestLanguage);
|
|
var pipeline = new Pipeline<HistoryInformationPipelineContext>(_operationFactory);
|
|
|
|
//pipeline.AddOperation<ReadAccountInfoFromDbOperation>()
|
|
|
|
// ToDo:
|
|
// 1. First read account info from DB operation
|
|
// 2. Read account history from DB at the startDate !Array SortedByDate! operation
|
|
// 3. Fill the OverallAccountStatistics
|
|
// PeriodAccountStatistics
|
|
// PeriodDifference
|
|
// StatisticsHistory
|
|
|
|
await pipeline.Build()
|
|
.Invoke(context, null)
|
|
.ConfigureAwait(false);
|
|
|
|
return context.Response;
|
|
}
|
|
}
|
|
} |