Esempio n. 1
0
 public ViewModel_AddDataManually()
 {
     _db              = new DatabaseService();
     _connService     = new SqlConnectionService();
     _qService        = new DatabaseQueryService(_connService);
     _modService      = new DatabaseModificationService(_connService);
     this.DisplayName = "Add Data Manually To Database";
 }
Esempio n. 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //Configure logger ASAP so that if the app crashes latter we can have logs of the crash
            ConfigureLogger();

            services.AddMvc().AddSessionStateTempDataProvider();
            //Add session support
            services.AddSession();
            // Allow the use of the MySQL Database as a service in this project.
            // Uses connection string from the project configuration
            // Passing it as a service ensures everything in the project will use this query service and use this connection string
            DatabaseQueryService dbQueryService = new DatabaseQueryService(Configuration.GetConnectionString("DefaultConnection"));
            EmailService         emailService   = new EmailService(Configuration.GetSection("EmailServiceConfiguration")["SourceEmailAddress"],
                                                                   Configuration.GetSection("EmailServiceConfiguration")["SourceEmailPassword"]);
            IConfigurationSection alertMonitoringConfig = Configuration.GetSection("AlertMonitoringServiceConfiguration");

            if (alertMonitoringConfig != null && Convert.ToBoolean(alertMonitoringConfig["Enabled"]))
            {
                Thread alertMonitoringThread = new Thread(delegate()
                {
                    int snoozeDurationMinutes = Convert.ToInt32(alertMonitoringConfig["SnoozeDurationMinutes"]);
                    AlertMonitoringService alertMonitoringService = new AlertMonitoringService(dbQueryService, emailService, snoozeDurationMinutes);
                    alertMonitoringService.StartMonitoring();
                });
                alertMonitoringThread.Start();
            }

            // Other services are constructed using the database query service, meaning they all use the same connection string
            AbstractGraphStatisticService graphStatisticService = new GraphStatisticService(dbQueryService);
            AbstractLocationService       locationService       = new LocationService(dbQueryService);
            AbstractCameraService         cameraService         = new CameraService(dbQueryService, graphStatisticService, locationService);
            AbstractAuthenticationService authenticationService = new AuthenticationService(dbQueryService);
            AbstractDataMessageService    dataMessageService    = new DataMessageService(dbQueryService);
            AbstractNotificationService   notificationService   = new NotificationService(dbQueryService);
            AbstractAlertService          alertService          = new AlertService(dbQueryService, cameraService, notificationService);
            AbstractAPIKeyService         apiKeyService         = new APIKeyService(dbQueryService);
            AbstractUserService           userService           = new UserService(dbQueryService, notificationService, Configuration.GetSection("WebServiceConfiguration")["Hostname"], emailService, apiKeyService);

            IConfigurationSection alertSummaryConfig = Configuration.GetSection("AlertSummaryServiceConfiguration");
            bool sendFramesAsJpg = alertMonitoringConfig != null && Convert.ToBoolean(alertSummaryConfig["SendFramesAsJpg"]);
            AlertSummaryService alertSummaryService = new AlertSummaryService(alertService, sendFramesAsJpg);

            services.Add(new ServiceDescriptor(typeof(AbstractAuthenticationService), authenticationService));
            services.Add(new ServiceDescriptor(typeof(AbstractCameraService), cameraService));
            services.Add(new ServiceDescriptor(typeof(AbstractDataMessageService), dataMessageService));
            services.Add(new ServiceDescriptor(typeof(AbstractLocationService), locationService));
            services.Add(new ServiceDescriptor(typeof(AbstractGraphStatisticService), graphStatisticService));
            services.Add(new ServiceDescriptor(typeof(AbstractAlertService), alertService));
            services.Add(new ServiceDescriptor(typeof(AbstractNotificationService), notificationService));
            services.Add(new ServiceDescriptor(typeof(AbstractUserService), userService));
            services.Add(new ServiceDescriptor(typeof(AbstractAPIKeyService), apiKeyService));
            services.Add(new ServiceDescriptor(typeof(AlertSummaryService), alertSummaryService));
        }
Esempio n. 3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().AddSessionStateTempDataProvider();
            //Add session support
            services.AddSession();
            // Allow the use of the MySQL Database as a service in this project.
            // Uses connection string from the project configuration
            // Passing it as a service ensures everything in the project will use this query service and use this connection string
            DatabaseQueryService dbQueryService = new DatabaseQueryService(Configuration.GetConnectionString("DefaultConnection"));

            // Other services are constructed using the database query service, meaning they all use the same connection string
            AbstractGraphStatisticService graphStatisticService = new GraphStatisticService(dbQueryService);
            AbstractLocationService       locationService       = new LocationService(dbQueryService);
            AbstractCameraService         cameraService         = new CameraService(dbQueryService, graphStatisticService, locationService);
            AbstractAuthenticationService authenticationService = new AuthenticationService(dbQueryService);
            AbstractDataMessageService    dataMessageService    = new DataMessageService(dbQueryService);

            services.Add(new ServiceDescriptor(typeof(AbstractAuthenticationService), authenticationService));
            services.Add(new ServiceDescriptor(typeof(AbstractCameraService), cameraService));
            services.Add(new ServiceDescriptor(typeof(AbstractDataMessageService), dataMessageService));
            services.Add(new ServiceDescriptor(typeof(AbstractLocationService), locationService));
            services.Add(new ServiceDescriptor(typeof(AbstractGraphStatisticService), graphStatisticService));
        }
 public void InitalizeDatabaseConnection()
 {
     this.Hide();
     if (databaseConnectionWindow == null)
     {
         databaseConnectionWindow = new DatabaseConnector();
     }
     databaseConnectionWindow.Show();
     databaseConnectionWindow.AddDelegate(() =>
     {
         if (databaseConnectionWindow.connectionString == null)
         {
             this.Close();
         }
         else
         {
             this.Show();
             databaseQueryService       = new DatabaseQueryService(databaseConnectionWindow.connectionString);
             var dbList                 = databaseQueryService.getDatabaseList();
             ConnectionGrid.DataContext = dbList;
         }
         return(1);
     });
 }