public void loadSimApplicationConfiguration(SimulationRunningConfig config)
 {
     if (config.AppSettings.NetworkSettings == null) throw new NullReferenceException("XMLSimApplication: Unable to load NetworkSettings - null");
     NetworkSettings = config.AppSettings.NetworkSettings;
     if (config.AppSettings.SystemProfile == null) throw new NullReferenceException("XMLSimApplication: Unable to load SystemProfile - null");
     SystemProfile = config.AppSettings.SystemProfile;
 }
        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());
        }
        //build a list of all the hardware on this computer
        public void buildXMLSystemProfile()
        {
            _systemProfile = new XMLSystemProfile();

            //Get Processor info
            SelectQuery query = new SelectQuery(@"SELECT * FROM Win32_Processor");

            using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(query))
            {
                foreach (ManagementObject process in searcher.Get())
                {
                    _systemProfile.ProcessorManufacturer = (string)process["Manufacturer"];
                    _systemProfile.ProcessorName = (string)process["Name"];
                    _systemProfile.ProcessorMaxClockSpeed = (UInt32)process["MaxClockSpeed"];
                    _systemProfile.ProcessorID = (string)process["ProcessorID"];
                    _systemProfile.ProcessorRevision = (UInt16)process["Revision"];
                    System.Console.WriteLine("{0},{1},{2},{3},{4}", _systemProfile.ProcessorManufacturer, _systemProfile.ProcessorName, _systemProfile.ProcessorMaxClockSpeed, _systemProfile.ProcessorID, _systemProfile.ProcessorRevision);
                }
            }

            //Get CD Rom info
            query = new SelectQuery(@"SELECT * FROM Win32_CDROMDrive");

            using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(query))
            {
                _systemProfile.CDROMList = new List<XMLHardwareCDROM>();

                foreach (ManagementObject process in searcher.Get())
                {
                    //query each CDROM device and add to the list
                    XMLHardwareCDROM cd = new XMLHardwareCDROM();
                    cd.CDRomName = (string)process["Name"];
                    cd.CDRomCaption = (string)process["Caption"];
                    cd.CDRomDeviceID = (string)process["DeviceID"];
                    cd.CDRomDescription = (string)process["Description"];
                    _systemProfile.CDROMList.Add(cd);
                    System.Console.WriteLine("{0},{1},{2},{3}", cd.CDRomName, cd.CDRomCaption, cd.CDRomDeviceID, cd.CDRomDescription);
                }
            }

            //Get Operating System info
            query = new SelectQuery(@"SELECT * FROM Win32_OperatingSystem");

            using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(query))
            {

                foreach (ManagementObject process in searcher.Get())
                {
                    _systemProfile.OpSystemCaption = (string)process["Caption"];
                    _systemProfile.OpSystemServicePackMajorVersion = (UInt16)process["ServicePackMajorVersion"];
                    _systemProfile.OpSystemServicePackMinorVersion = (UInt16)process["ServicePackMinorVersion"];
                    _systemProfile.OpSystemInstallDate = (string)process["InstallDate"];
                    _systemProfile.OpSystemVersion = (string)process["Version"];
                    _systemProfile.OpSystemFreePhysicalMemory = (UInt64)process["FreePhysicalMemory"];
                    System.Console.WriteLine("{0},{1},{2},{3},{4},{5}", _systemProfile.OpSystemCaption, _systemProfile.OpSystemServicePackMajorVersion, _systemProfile.OpSystemServicePackMinorVersion, _systemProfile.OpSystemInstallDate, _systemProfile.OpSystemVersion, _systemProfile.OpSystemFreePhysicalMemory);

                }
            }

            query = new SelectQuery(@"SELECT * FROM Win32_ComputerSystem");

            using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(query))
            {

                foreach (ManagementObject process in searcher.Get())
                {
                    process.Get();
                    _systemProfile.SystemCaption = (string)process["Caption"];
                    _systemProfile.SystemDescription = (string)process["Description"];
                    _systemProfile.SystemManufacturer = (string)process["Manufacturer"];
                    _systemProfile.SystemModel = (string)process["Model"];
                    _systemProfile.SystemTotalPhysicalMemory = (UInt64)process["TotalPhysicalMemory"];
                    System.Console.WriteLine("{0},{1},{2},{3},{4}", _systemProfile.SystemCaption, _systemProfile.SystemDescription, _systemProfile.SystemManufacturer, _systemProfile.SystemModel, _systemProfile.SystemTotalPhysicalMemory);
                }
            }
        }
        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;
        }