コード例 #1
0
        public static void Configure(CommandLineApplication command)
        {
            command.Description = "Ensure the database is created";

            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);

            command.OnExecute(() =>
            {
                string databaseConnectionName = databaseConnectionOption.Value();
                string password = passwordOption.HasValue() ? passwordOption.Value() : String.Empty;
                ServiceCollection serviceCollection = ServiceCollectionSetup.SetupCoreServices(
                    databaseConnectionName,
                    password
                    );

                // Application services
                serviceCollection.AddTransient <IDatabaseCreationService, DatabaseCreationService>();

                IServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();

                IDatabaseCreationService databaseCreationService = serviceProvider.GetRequiredService <IDatabaseCreationService>();
                databaseCreationService.Create();

                return(0);
            });
        }
コード例 #2
0
        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);
            });
        }
コード例 #3
0
        public static void Configure(CommandLineApplication command)
        {
            command.Description = "Generate a balance sheet from the database at a given time";

            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 atOption = command.Option(
                "-a|--at",
                "The time to prepare a balance sheet for",
                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 <IAccountService, AccountService>();
                serviceCollection.AddSingleton <IBalanceSheetService, BalanceSheetService>();
                serviceCollection.AddSingleton <ICurrencyService, CurrencyService>();
                serviceCollection.AddSingleton <IEnvironmentService, EnvironmentService>();

                // Application services
                serviceCollection.AddSingleton <IBalanceSheetWriterService, BalanceSheetConsoleWriterService>();

                IServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();

                IBalanceSheetService balanceSheetService = serviceProvider.GetRequiredService <IBalanceSheetService>();
                DateTime at = DateTime.Parse(atOption.Value());
                BalanceSheet balanceSheet = balanceSheetService.Generate(at);

                IBalanceSheetWriterService balanceSheetWriterService = serviceProvider.GetRequiredService <IBalanceSheetWriterService>();
                balanceSheetWriterService.Write(balanceSheet, at);

                return(0);
            });
        }