public static void Configure(CommandLineApplication command) { command.Description = "Generate a cashflow statement from the database for a given period"; CommandOption databaseConnectionOption = command.Option( "-d|--database", "The database connection to connect to", CommandOptionType.SingleValue); CommandOption passwordOption = command.Option( "-p|--password", "The password to connect with", CommandOptionType.SingleValue); CommandOption startAtOption = command.Option( "-s|--startAt", "The start of the cashflow period", CommandOptionType.SingleValue); CommandOption endAtOption = command.Option( "-e|--endAt", "The end of the cashflow period", CommandOptionType.SingleValue); command.OnExecute(() => { string databaseConnectionName = databaseConnectionOption.Value(); string password = passwordOption.HasValue() ? passwordOption.Value() : String.Empty; ServiceCollection serviceCollection = ServiceCollectionSetup.SetupCoreServices( databaseConnectionName, password ); // Financier.Core services serviceCollection.AddSingleton <IAccountRelationshipService, AccountRelationshipService>(); serviceCollection.AddSingleton <IAccountService, AccountService>(); serviceCollection.AddSingleton <ICurrencyService, CurrencyService>(); serviceCollection.AddSingleton <ICashflowService, CashflowService>(); serviceCollection.AddSingleton <IEnvironmentService, EnvironmentService>(); serviceCollection.AddSingleton <ITransactionService, TransactionService>(); // Application services serviceCollection.AddSingleton <ICashflowStatementWriterService, CashflowStatementConsoleWriterService>(); IServiceProvider serviceProvider = serviceCollection.BuildServiceProvider(); ICashflowService cashflowService = serviceProvider.GetRequiredService <ICashflowService>(); DateTime startAt = DateTime.Parse(startAtOption.Value()); DateTime endAt = DateTime.Parse(endAtOption.Value()); CashflowStatement cashflowStatement = cashflowService.Generate(CashflowPeriod.Fortnightly, startAt, endAt); ICashflowStatementWriterService cashflowStatementWriterService = serviceProvider.GetRequiredService <ICashflowStatementWriterService>(); cashflowStatementWriterService.Write(cashflowStatement); return(0); }); }
public EquiasManager(IEquiasAuthenticationService equiasAuthenticationService, IEquiasService equiasService, ITradeService tradeService, ITradeSummaryService tradeSummaryService, ICashflowService cashflowService, IProfileService profileService, ISettingService settingService, IVaultService vaultService, IEquiasMappingService equiasMappingService, ILogger <EquiasManager> logger) { this.equiasAuthenticationService = equiasAuthenticationService; this.equiasService = equiasService; this.tradeService = tradeService; this.equiasMappingService = equiasMappingService; this.vaultService = vaultService; this.settingService = settingService; this.logger = logger; this.tradeSummaryService = tradeSummaryService; this.cashflowService = cashflowService; this.profileService = profileService; }