Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            MongoConnectionString = new MongoConnectionString(Configuration.GetConnectionString("Mongo"));

            services.Configure <AppSettings>(Configuration);
            services.AddSingleton(Configuration);

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.AddSingleton <IVolumeSpikeDbContext>(opt =>
            {
                var client = new MongoClient(MongoConnectionString.Settings);
                var db     = client.GetDatabase(MongoConnectionString.Database);
                IOptions <AppSettings> appSettings = opt.GetRequiredService <IOptions <AppSettings> >();
                return(new VolumeSpikeDbContext(db, appSettings));
            });

            services.AddSingleton <IMessageHub, MessageHub>();
            services.AddSingleton <ICacheClient, StackExchangeRedisCacheClient>();
            services.AddSingleton <ISerializer, MsgPackObjectSerializer>();
            services.AddSingleton <IVolumeSpikesDetector, VolumeSpikesDetector>();
            services.AddSingleton <IPolygonWsClient, PolygonWsClient>();
            services.AddScoped <ISymbolService, SymbolService>();
            services.AddScoped <ILastTradesService, LastTradesService>();
            services.AddScoped <IVolumeRecordService, VolumeRecordService>();
        }
Exemplo n.º 2
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers()
            .ConfigureApiBehaviorOptions(opts => {
                opts.SuppressModelStateInvalidFilter = true;
                opts.SuppressMapClientErrors         = true;
            });
            services.AddSwaggerGen(c => c.SwaggerDoc("v1", new OpenApiInfo {
                Title = "InvestmentReporting.StateService", Version = "v1"
            }));
            services.AddSharedAuthentication();
            services.AddMemoryCache();

            services.AddSingleton <IMongoDatabase>(_ => {
                var mongoSettings = MongoClientSettings.FromConnectionString(MongoConnectionString.Create());
                var client        = new MongoClient(mongoSettings);
                return(client.GetDatabase("InvestmentReporting"));
            });
            services.AddSingleton <IIdGenerator, ObjectIdGenerator>();
            services.AddSingleton <IStateRepository, MongoStateRepository>();
            services.AddSingleton <CurrencyConfiguration>();
            services.AddSingleton <StateManager>();
            services.AddSingleton <IStateManager>(sp => sp.GetRequiredService <StateManager>());
            services.AddSingleton <ReadStateUseCase>();
            services.AddSingleton <ResetStateUseCase>();
            services.AddSingleton <ReadOperationsUseCase>();
            services.AddSingleton <ResetOperationsUseCase>();
            services.AddSingleton <CreateBrokerUseCase>();
            services.AddSingleton <CreateAccountUseCase>();
            services.AddSingleton <AddIncomeUseCase>();
            services.AddSingleton <AddExpenseUseCase>();
            services.AddSingleton <BuyAssetUseCase>();
            services.AddSingleton <SellAssetUseCase>();
        }
Exemplo n.º 3
0
        public static IServiceCollection AddInfrastructure(this IServiceCollection serviceCollection,
                                                           MongoConnectionString mongoOptions, EmailSenderOptions emailSenderOptions)
        {
            serviceCollection.AddSingleton(mongoOptions);
            serviceCollection.AddTransient <IEmailRepository, MongoEmailRepository>();
            serviceCollection.AddTransient <IEmailQueueRepository, MongoEmailRepository>();
            serviceCollection.AddTransient <IEmailSender, EmailSender>(provider => new EmailSender(emailSenderOptions));

            return(serviceCollection);
        }
Exemplo n.º 4
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers()
            .ConfigureApiBehaviorOptions(opts => {
                opts.SuppressModelStateInvalidFilter = true;
                opts.SuppressMapClientErrors         = true;
            });
            services.AddSwaggerGen(c => c.SwaggerDoc("v1", new OpenApiInfo {
                Title = "InvestmentReporting.ImportService", Version = "v1"
            }));
            services.AddSharedAuthentication();
            services.AddMemoryCache();

            services.AddSingleton <IMongoDatabase>(_ => {
                var mongoSettings = MongoClientSettings.FromConnectionString(MongoConnectionString.Create());
                var client        = new MongoClient(mongoSettings);
                return(client.GetDatabase("InvestmentReporting"));
            });
            services.AddSingleton <IIdGenerator, ObjectIdGenerator>();
            services.AddSingleton <IStateRepository, MongoStateRepository>();
            services.AddSingleton <CurrencyConfiguration>();
            services.AddSingleton <StateManager>();
            services.AddScoped <TransactionStateManager>();
            services.AddScoped <IStateManager>(sp => sp.GetRequiredService <TransactionStateManager>());
            services.AddScoped(sp => {
                var factory = new ImportUseCaseFactory(t => (IImportUseCase)sp.GetRequiredService(t));
                factory.Register <AlphaDirectImportUseCase>("AlphaDirectMyBroker");
                factory.Register <TinkoffImportUseCase>("TinkoffBrokerReport");
                return(factory);
            });
            services.AddScoped <AlphaDirectImportUseCase>();
            services.AddScoped <AlphaBrokerMoneyMoveParser>();
            services.AddScoped <AlphaTradeParser>();
            services.AddScoped <TinkoffImportUseCase>();
            services.AddScoped <TinkoffBrokerMoneyMoveParser>();
            services.AddScoped <AssetParser>();
            services.AddScoped <TinkoffTradeParser>();
            services.AddScoped <AlphaDirectCouponParser>();
            services.AddScoped <TinkoffCouponParser>();
            services.AddScoped <DividendParser>();
            services.AddScoped <AssetMoveParser>();
            services.AddScoped <SplitDetector>();
            services.AddScoped <TransferParser>();
            services.AddScoped <AddIncomeUseCase>();
            services.AddScoped <AddExpenseUseCase>();
            services.AddScoped <BuyAssetUseCase>();
            services.AddScoped <SellAssetUseCase>();
            services.AddScoped <ReduceAssetUseCase>();
            services.AddSingleton <BackgroundImportService>();
        }
Exemplo n.º 5
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers()
            .ConfigureApiBehaviorOptions(opts => {
                opts.SuppressModelStateInvalidFilter = true;
                opts.SuppressMapClientErrors         = true;
            });
            services.AddSwaggerGen(c => c.SwaggerDoc("v1", new OpenApiInfo {
                Title = "InvestmentReporting.MetaService", Version = "v1"
            }));
            services.AddSharedAuthentication();
            services.AddMemoryCache();

            services.AddSingleton <IMongoDatabase>(_ => {
                var mongoSettings = MongoClientSettings.FromConnectionString(MongoConnectionString.Create());
                var client        = new MongoClient(mongoSettings);
                return(client.GetDatabase("InvestmentReporting"));
            });
            services.AddSingleton <IIdGenerator, ObjectIdGenerator>();
            services.AddSingleton <IStateRepository, MongoStateRepository>();
            services.AddSingleton <IStateManager, StateManager>();
            services.AddSingleton <IAssetTagRepository, MongoAssetTagRepository>();
            services.AddSingleton <IAssetMetadataRepository, MongoAssetMetadataRepository>();
            services.AddSingleton <ICurrencyPriceRepository, MongoCurrencyPriceRepository>();
            services.AddSingleton <IAssetPriceRepository, MongoAssetPriceRepository>();
            services.AddSingleton <IDashboardRepository, MongoDashboardRepository>();
            services.AddSingleton <CurrencyConfiguration>();
            services.AddSingleton <MetadataManager>();
            services.AddSingleton <AssetTagManager>();
            services.AddSingleton <DashboardManager>();
            services.AddSingleton <AssetPriceManager>();
            services.AddSingleton <CurrencyPriceManager>();
            services.AddSingleton <ExchangeManager>();
            services.AddSingleton <ReadStateUseCase>();
            services.AddSingleton <ReadVirtualStateUseCase>();
            services.AddSingleton <ReadAssetTagsUseCase>();
            services.AddSingleton <AddAssetTagUseCase>();
            services.AddSingleton <RemoveAssetTagUseCase>();
            services.AddSingleton <ReadDashboardConfigsUseCase>();
            services.AddSingleton <UpdateDashboardConfigUseCase>();
            services.AddSingleton <RemoveDashboardConfigUseCase>();
            services.AddSingleton <ReadDashboardStateUseCase>();
        }
Exemplo n.º 6
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers()
            .ConfigureApiBehaviorOptions(opts => {
                opts.SuppressModelStateInvalidFilter = true;
                opts.SuppressMapClientErrors         = true;
            });
            services.AddSwaggerGen(c => c.SwaggerDoc("v1", new OpenApiInfo {
                Title = "InvestmentReporting.MarketService", Version = "v1"
            }));
            services.AddSharedAuthentication();
            services.AddMemoryCache();

            services.AddSingleton <IMongoDatabase>(_ => {
                var mongoSettings = MongoClientSettings.FromConnectionString(MongoConnectionString.Create());
                var client        = new MongoClient(mongoSettings);
                return(client.GetDatabase("InvestmentReporting"));
            });
            services.AddSingleton <IIdGenerator, ObjectIdGenerator>();
            services.AddSingleton <IStateRepository, MongoStateRepository>();
            services.AddSingleton <IStateManager, StateManager>();
            services.AddSingleton <IAssetMetadataRepository, MongoAssetMetadataRepository>();
            services.AddSingleton <IAssetPriceRepository, MongoAssetPriceRepository>();
            services.AddSingleton <ICurrencyPriceRepository, MongoCurrencyPriceRepository>();
            services.AddSingleton <IApiKeyProvider, EnvironmentApiKeyProvider>();
            services.AddSingleton <IsinProvider>();
            services.AddSingleton <CurrencyConfiguration>();
            services.AddSingleton <MetadataManager>();
            services.AddSingleton <AssetPriceManager>();
            services.AddSingleton <CurrencyPriceManager>();
            services.AddSingleton <AssetIntervalCalculator>();
            services.AddSingleton <CurrencyIntervalCalculator>();
            services.AddSingleton <ExchangeManager>();
            services.AddSingleton <MarketMetadataCollector>();
            services.AddSingleton <MarkerAssetCandleCollector>();
            services.AddSingleton <MarketCurrencyCandleCollector>();
            services.AddSingleton <MarketCandleCollector>();
            services.AddSingleton <SynchronizationUseCase>();
            services.AddHostedService <SynchronizationHostedService>();
            services.AddSingleton <ReadVirtualStateUseCase>();
            services.AddSingleton <MarketCandleResetUseCase>();
        }
Exemplo n.º 7
0
        public MongoEmailRepository(MongoConnectionString connectionString)
        {
            var client = new MongoClient(connectionString.MongoDbConnectionString);

            this.Collection = client.GetDatabase("Mailer").GetCollection <MessageDocument>("messages");
        }
Exemplo n.º 8
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            Console.WriteLine(string.Empty);
            Console.WriteLine("Starting Aggregail MongoDB Admin UI...");

            var settings = new AggregailMongoDBSettings();

            Configuration.Bind(settings);

            settings.Validate();
            services.AddSingleton(settings);

            services.AddControllersWithViews();
            services.AddSignalR();

            // In production, the React files will be served from this directory
            services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/build"; });

            services.AddSingleton(s =>
            {
                var client   = new MongoClient(settings.ConnectionString);
                var database = client.GetDatabase(settings.Database);
                return(database.GetCollection <RecordedEventDocument>(settings.Collection));
            });

            services.AddSingleton(s =>
            {
                var client   = new MongoClient(settings.Users.ConnectionString ?? settings.ConnectionString);
                var database = client.GetDatabase(settings.Users.Database ?? settings.Database);
                return(database.GetCollection <UserDocument>(settings.Users.Collection));
            });

            services.AddSingleton <UserDocumentPasswordHasher>();

            // TODO @nije: SignalR evaluation
            // services.AddHostedService<StreamService>();

            services.AddHostedService <UserBackgroundService>();

            services.AddSingleton <UserValidationEvents>();

            services.AddAuthorization();
            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options =>
            {
                options.Cookie.Name      = "Authorization";
                options.EventsType       = typeof(UserValidationEvents);
                options.TicketDataFormat = new JsonWebTokenDataFormat(new Microsoft.AspNetCore.Authentication.SystemClock());
            });

            if (!settings.QuietStartup)
            {
                var connectionString = MongoConnectionString
                                       .Censored(settings.ConnectionString);

                Console.WriteLine($"[Streams Configuration]");
                Console.WriteLine($" - MongoDB ConnectionString: {connectionString}");
                Console.WriteLine($"   - Database: {settings.Database}");
                Console.WriteLine($"   - Collection: {settings.Collection}");
                Console.WriteLine(string.Empty);

                var usersConnectionString = MongoConnectionString
                                            .Censored(settings.Users.ConnectionString ?? settings.ConnectionString);

                Console.WriteLine($"[Users Configuration]");
                Console.WriteLine($" - MongoDB ConnectionString: {usersConnectionString}");
                Console.WriteLine($"   - Database: {settings.Users.Database ?? settings.Database}");
                Console.WriteLine($"   - Collection: {settings.Users.Collection}");
                Console.WriteLine(string.Empty);
            }
        }