public void LoadApplicationData()
        {
            //load Database Connection
            databaseInterface = new DatabaseConnection();

            //load Application Settings
            AppLoader appLoader = new AppLoader(databaseInterface, DATA_SOURCE_STRING);

            //apploader will create simulation config from database data
            _simConfig = new SimulationRunningConfig(appLoader.loadAppSettings());

               //_simConfig = new SimulationRunningConfig(); //load default hard coded config.

            //start listening for UDP Messages
            Task.Factory.StartNew(() => startUdpListener());
        }
 public AppLoader(DatabaseConnection connect, string connectionString)
 {
     dbConnect = connect;
     dbConnectString = connectionString;
 }
        public XMLSystemProfile loadSystemProfileFromDatabase(DatabaseConnection database)
        {
            if (database == null) throw new NullReferenceException("AppLoader: Database connection is null");
            //connection not open so open it
            if (database.IsOpenConnection() == false)
                dbConnect.Connect(dbConnectString);

            XMLSystemProfile profile = new XMLSystemProfile();

            string query = "SELECT * FROM SystemProfile WHERE 1";

               SQLiteDataReader reader = dbConnect.ExecuteQuery(query);

            while (reader.Read())
            {
                profile.ProcessorManufacturer = (string)reader["Processor_Manufacturer"];
                profile.ProcessorName = (string)reader["Processor_Name"];
                //profile.ProcessorMaxClockSpeed = (UInt32)reader["Processor_Max_ClockSpeed"];
                profile.ProcessorID = (string)reader["Processor_ID"];
                //profile.ProcessorRevision = (UInt16)reader["Processor_Revision"];
                profile.OpSystemCaption = (string)reader["OpSystem_Caption"];
                //profile.OpSystemServicePackMajorVersion = (UInt16)reader["OpSystem_ServicePack_MajorVersion"];
                //profile.OpSystemServicePackMinorVersion = (UInt16)reader["OpSystem_ServicePack_MinorVersion"];
                profile.OpSystemInstallDate = (string)reader["OpSystem_Install_Date"];
                profile.OpSystemVersion = (string)reader["OpSystem_Version"];
                //profile.OpSystemFreePhysicalMemory = (UInt64)reader["OpSystem_Free_Physical_Memory"];
                profile.SystemCaption = (string)reader["System_Caption"];
                profile.SystemDescription = (string)reader["System_Description"];
                profile.SystemManufacturer = (string)reader["System_Manufacturer"];
                profile.SystemModel = (string)reader["System_Model"];
                //profile.SystemTotalPhysicalMemory = (UInt64)reader["System_Total_Physical_Memory"];

            }

            return profile;
        }
        public void updateDatabaseSystemProfile(DatabaseConnection database, XMLSystemProfile profile)
        {
            if(database == null) throw new NullReferenceException("AppLoader: Database connection is null");
            //connection not open so open it
            if(database.IsOpenConnection() == false)
                 dbConnect.Connect(dbConnectString);

            StringBuilder update = new StringBuilder();
            update.Append("INSERT INTO SystemProfile ");
            update.Append("(Processor_Manufacturer,Processor_Name ,Processor_Max_ClockSpeed, Processor_ID ,Processor_Revision ,OpSystem_Caption ,"+
                            "OpSystem_ServicePack_MajorVersion ,OpSystem_ServicePack_MinorVersion ,OpSystem_Install_Date ,OpSystem_Version ,"+
                            "OpSystem_Free_Physical_Memory , System_Caption ,System_Description ,System_Manufacturer ,System_Model ,System_Total_Physical_Memory)");
            update.Append("VALUES ");
            update.Append("(");
            update.Append("'"+profile.ProcessorManufacturer+"',");
            update.Append("'" + profile.ProcessorName + "',");
            update.Append("'" + profile.ProcessorMaxClockSpeed + "',");
            update.Append("'" + profile.ProcessorID + "',");
            update.Append("'" + profile.ProcessorRevision + "',");
            update.Append("'" + profile.OpSystemCaption + "',");
            update.Append("'" + profile.OpSystemServicePackMajorVersion + "',");
            update.Append("'" + profile.OpSystemServicePackMinorVersion + "',");
            update.Append("'" + profile.OpSystemInstallDate + "',");
            update.Append("'" + profile.OpSystemVersion + "',");
            update.Append("'" + profile.OpSystemFreePhysicalMemory+ "',");
            update.Append("'" + profile.SystemCaption+ "',");
            update.Append("'" + profile.SystemDescription + "',");
            update.Append("'" + profile.SystemManufacturer + "',");
            update.Append("'" + profile.SystemModel + "',");
            update.Append("'" + profile.SystemTotalPhysicalMemory + "'");
            update.Append(");");

            dbConnect.ExecuteUpdate(update.ToString());
        }
 public SimulationManagementHelper(SimulationRunningConfig config, string tedDatasource)
 {
     setSimConfig(config);
     tedConnectString = tedDatasource;
     Interface = new DatabaseConnection();
 }