/// <summary> /// Creates a scheduler based upon the scheduler assembly name and /// scheduler type name specified in the manager's configuration file. /// If it fails to create the specified scheduler then it returns the default scheduler. /// </summary> /// <returns></returns> public IScheduler CreateScheduler(Configuration oConfiguration) { if (oConfiguration != null) { string strSchedulerAssemblyName = oConfiguration.SchedulerAssemblyName; if (IsSpecified(strSchedulerAssemblyName)) { string strSchedulerTypeName = oConfiguration.SchedulerTypeName; if (IsSpecified(strSchedulerTypeName)) { IScheduler oScheduler = CreateScheduler(strSchedulerAssemblyName, strSchedulerTypeName); if (oScheduler != null) { return oScheduler; } } else { logger.Debug("Scheduler type name was not specified."); } } else { logger.Debug("Scheduler assembly name was not specified."); } } logger.Debug("Creating default scheduler."); return new DefaultScheduler(); }
public bool Start(Configuration ConfigFromUI) { _container.Config = ConfigFromUI; try { _container.Start(); Msgbox.ShowMsgbox("Manager started","Manager is Running!", "", "", "OK"); //for heirarchical stuff // if (Config.Intermediate) // { // //Config.Id = Manager.Id; // //Config.Dedicated = Manager.Dedicated; // } return true; } catch (Exception ex) { _container = null; string errorMsg = string.Format("Could not start Manager. Reason: {0}{1}", Environment.NewLine, ex.Message); if (ex.InnerException != null) { errorMsg += string.Format("{0}", ex.InnerException.Message); } //Log(errorMsg); logger.Error(errorMsg, ex); return false; } //Application should refresh UI controls now }
/// <summary> /// Gets an instance of this class (creates it, the first time). /// </summary> /// <returns></returns> internal static InternalShared GetInstance(Configuration config) { if (Instance == null) { Instance = new InternalShared(config); } return Instance; }
public ManagerContainerWrapper() { ManagerContainer.ManagerStartEvent += new ManagerStartStatusEventHandler(this.Manager_StartStatusEvent); _container = new ManagerContainer(); _container.RemotingConfigFile = "eduGRID_ManagerApp.exe.config"; _container.ReadConfig(false, AppDomain.CurrentDomain.BaseDirectory, "eduGRIDManager.config.xml"); Config = _container.Config; //After this is initialized, Application should read Config and fill up ui with default values }
public void SetConfiguration(Alchemi.Manager.Configuration configuration) { this._port = configuration.OwnPort; this._managerStorageEnum = configuration.DbType; this._serverName = configuration.DbServer; this._databaseName = configuration.DbName; this._username = configuration.DbUsername; this._password = configuration.DbPassword; this.UpdateUi(); }
private void SaveConfigurationData(Configuration configuration) { UpdateConfigurationFromForm(configuration); configuration.Slz(); configurationFileChanged = false; saveButton.Enabled = configurationFileChanged; }
/// <summary> /// Read the configuration data from the configuration file into the controls /// </summary> /// <param name="configuration"></param> private void ReadConfigurationData(Configuration configuration) { if (configuration == null) { return; } IEnumerator enumerator = managerStorageTypes.Items.GetEnumerator(); while (enumerator.MoveNext()) { ManagerStorageTypeDropdownItem item = (ManagerStorageTypeDropdownItem)enumerator.Current; if (item.StorageType == configuration.DbType) { managerStorageTypes.SelectedItem = item; } } databaseServer.Text = configuration.DbServer; databaseName.Text = configuration.DbName; databaseUsername.Text = configuration.DbUsername; databasePassword.Text = configuration.DbPassword; }
private void LoadConfigurationFileFromManagerLocation() { bool dataChanged; try { managerConfiguration = Configuration.GetConfiguration(managerLocation.Text); dataChanged = false; } catch (FileNotFoundException) { // manager file not found, load the defaults managerConfiguration = new Configuration(managerLocation.Text); dataChanged = true; } ReadConfigurationData(managerConfiguration); configurationFileChanged = dataChanged; }
Alchemi.Manager.Configuration GetConfiguration() { Alchemi.Manager.Configuration configuration; try { configuration = Configuration.GetConfiguration(); } catch( System.IO.FileNotFoundException fileNotFoundException ) { // if the configuration doesn't exist, let's create it configuration = new Configuration(); } return configuration; }
private InternalShared(Configuration config) { DataRootDirectory = Utils.GetFilePath("dat", AlchemiRole.Manager, true); DedicatedSchedulerActive = new ManualResetEvent(true); Scheduler = (new SchedulerFactory()).CreateScheduler(config); }
private void btInstall_Click(object sender, EventArgs e) { //instead of the old method, just use the ManagerStorageSetup members now. Alchemi.Manager.Configuration config = null; try { // serialize configuration Log("[ Creating Configuration File ] ... "); config = new Alchemi.Manager.Configuration(InstallLocation); config.DbServer = txServer.Text; config.DbUsername = txUsername.Text; config.DbPassword = txAdminPwd.Text; config.DbName = "master"; //we need this to initially create the alchemi database. config.Slz(); Log("[ Done ]."); //for now just use RunSQL method. ManagerStorageFactory.CreateManagerStorage(config); IManagerStorage store = ManagerStorageFactory.ManagerStorage(); // (re)create database Log("[ Setting up storage ] ... "); string scriptPath = Path.Combine(scriptLocation, "Alchemi_database.sql"); while (!File.Exists(scriptPath)) { MessageBox.Show("Alchemi SQL files not found in folder: " + scriptLocation + ". Please select the folder where the sql scripts are located!", "Locate Script Files", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); DialogResult result = dirBox.ShowDialog(this); if (result == DialogResult.Cancel) break; scriptLocation = dirBox.SelectedPath; scriptPath = Path.Combine(scriptLocation, "Alchemi_database.sql"); } if (!File.Exists(scriptPath)) { return; //cannot continue. } // create structure Log("[ Creating Database Structure ] ... "); //load it from sql files for now. later make use of resources. using (FileStream fs = File.OpenRead(scriptPath)) { StreamReader sr = new StreamReader(fs); String sql = sr.ReadToEnd(); sr.Close(); fs.Close(); store.RunSql(sql); } Log("[ Done ]."); Log("[ Creating tables ] ... "); scriptPath = Path.Combine(scriptLocation, "Alchemi_structure.sql"); //load it from sql files for now. later make use of resources. using (FileStream fs = File.OpenRead(scriptPath)) { StreamReader sr = new StreamReader(fs); String sql = sr.ReadToEnd(); sr.Close(); fs.Close(); store.RunSql(sql); } Log("[ Done ]."); Log("[ Inserting initialization data ] ... "); scriptPath = Path.Combine(scriptLocation, "Alchemi_data.sql"); //load it from sql files for now. later make use of resources. using (FileStream fs = File.OpenRead(scriptPath)) { StreamReader sr = new StreamReader(fs); String sql = sr.ReadToEnd(); sr.Close(); fs.Close(); store.RunSql(sql); } Log("[ Done ]."); // serialize configuration Log("[ Updating Configuration File ] ... "); config.DbServer = txServer.Text; config.DbUsername = txUsername.Text; config.DbPassword = txAdminPwd.Text; config.DbName = "Alchemi"; config.Slz(); Log("[ Done ]."); Log("Wrote configuration file to " + InstallLocation); Log("[ Installation Complete! ]"); btInstall.Enabled = false; btFinish.Enabled = true; } catch (Exception ex) { Log("[ Error ]"); Log(ex.Message); return; } }
public void ReadConfig(bool useDefault, string location, string filename) { if (!useDefault) { try { Config = Configuration.GetConfiguration(location, filename); } catch (Exception) { useDefault = true; } } if (useDefault) { Config = new Configuration(); } }
/// <summary> /// Reads the Manager configuration from the Alchemi.Manager.config.xml file, /// <br /> or gets the default configuration if useDefault = true. /// </summary> /// <param name="useDefault"></param> public void ReadConfig(bool useDefault) { if (!useDefault) { try { Config = Configuration.GetConfiguration(); } catch (Exception) { useDefault = true; } } if (useDefault) { Config = new Configuration(); } }
//OLD not used anymore. private void btInstall_Click1(object sender, EventArgs e) { Process process = new Process(); process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; process.StartInfo.UseShellExecute = false; process.StartInfo.CreateNoWindow = true; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.FileName = "osql"; string outputText = ""; // (re)create database txLog.AppendText("[ Creating Database ] ... "); try { string scriptPath = Path.Combine(InstallLocation,"Alchemi_database.sql"); process.StartInfo.Arguments = string.Format("-S {0} -U {1} -P {2} -i \"{3}\" -n", txUsername.Text, txServer.Text, txAdminPwd.Text, scriptPath); process.Start(); process.WaitForExit(); outputText = process.StandardOutput.ReadToEnd(); } catch (Exception ex) { txLog.AppendText("[ Error ]" + Environment.NewLine); if (ex.Message == "The system cannot find the file specified") { Log("'osql' could not be found. Check that SQL Server 2000 or MSDE is installed and 'osql' is in the path.."); } else { Log(ex.Message); } return; } if (process.ExitCode == 0) { txLog.AppendText("[ Done ]" + Environment.NewLine); Log(outputText); } else { txLog.AppendText("[ Error ]" + Environment.NewLine); Log(outputText); return; } // create structure txLog.AppendText("[ Creating Database Structure ] ... "); try { string scriptPath = Path.Combine(InstallLocation,"Alchemi_structure.sql"); process.StartInfo.Arguments = string.Format("-S {0} -U {1} -P {2} -d Alchemi -i \"{3}\" -n", txUsername.Text, txServer.Text, txAdminPwd.Text, scriptPath); process.Start(); process.WaitForExit(); outputText = process.StandardOutput.ReadToEnd(); } catch (Exception ex) { txLog.AppendText("[ Error ]" + Environment.NewLine); Log(ex.Message); return; } if (process.ExitCode == 0) { txLog.AppendText("[ Done ]" + Environment.NewLine); Log(outputText); } else { txLog.AppendText("[ Error ]" + Environment.NewLine); Log(outputText); return; } // insert data txLog.AppendText("[ Inserting Default Data ] ... "); try { string scriptPath = Path.Combine(InstallLocation,"Alchemi_data.sql"); process.StartInfo.Arguments = string.Format("-S {0} -U {1} -P {2} -d Alchemi -i \"{3}\" -n", txUsername.Text, txServer.Text, txAdminPwd.Text, scriptPath); process.Start(); process.WaitForExit(); outputText = process.StandardOutput.ReadToEnd(); } catch (Exception ex) { txLog.AppendText("[ Error ]" + Environment.NewLine); Log(ex.Message); return; } if (process.ExitCode == 0) { txLog.AppendText("[ Done ]" + Environment.NewLine); Log(outputText); } else { txLog.AppendText("[ Error ]" + Environment.NewLine); Log(outputText); return; } // serialize configuration txLog.AppendText("[ Creating Configuration File ] ... "); try { //get the manager install location. it is ../v.v.v //string mgrInstallDir = Path.Combine(Directory.GetParent(InstallLocation).FullName,Alchemi.Core.Utility.Utils.AssemblyVersion); txLog.AppendText(" Writing Configuration to " + InstallLocation + Environment.NewLine); Configuration config = new Configuration(InstallLocation); config.DbServer = txServer.Text; config.DbUsername = txUsername.Text; config.DbPassword = txAdminPwd.Text; config.Slz(); txLog.AppendText("[ Done ]" + Environment.NewLine); Log("wrote configuration file to " + InstallLocation); } catch (Exception ex) { txLog.AppendText("[ Error ]" + Environment.NewLine); Log(ex.ToString()); } Log(""); Log("[ Installation Complete! ]"); btInstall.Enabled = false; btFinish.Enabled = true; }
/// <summary> /// Update the configuration object from the form data. /// </summary> /// <param name="configuration"></param> private void UpdateConfigurationFromForm(Configuration configuration) { ManagerStorageTypeDropdownItem item = (ManagerStorageTypeDropdownItem)managerStorageTypes.SelectedItem; configuration.DbType = item.StorageType; configuration.DbServer = databaseServer.Text; configuration.DbName = databaseName.Text; configuration.DbUsername = databaseUsername.Text; configuration.DbPassword = databasePassword.Text; }
private void btInstall_Click(object sender, EventArgs e) { //instead of the old method, just use the ManagerStorageSetup members now. Alchemi.Manager.Configuration config = null; try { // serialize configuration Log("[ Creating Configuration File ] ... "); config = new Alchemi.Manager.Configuration(InstallLocation); config.DbServer = txServer.Text; config.DbUsername = txUsername.Text; config.DbPassword = txAdminPwd.Text; config.DbName = "master"; //we need this to initially create the alchemi database. config.Slz(); Log("[ Done ]."); //for now just use RunSQL method. ManagerStorageFactory.CreateManagerStorage(config); IManagerStorage store = ManagerStorageFactory.ManagerStorage(); // (re)create database Log("[ Setting up storage ] ... "); string scriptPath = Path.Combine(scriptLocation, "Alchemi_database.sql"); while (!File.Exists(scriptPath)) { MessageBox.Show("Alchemi SQL files not found in folder: " + scriptLocation + ". Please select the folder where the sql scripts are located!", "Locate Script Files", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); DialogResult result = dirBox.ShowDialog(this); if (result == DialogResult.Cancel) { break; } scriptLocation = dirBox.SelectedPath; scriptPath = Path.Combine(scriptLocation, "Alchemi_database.sql"); } if (!File.Exists(scriptPath)) { return; //cannot continue. } // create structure Log("[ Creating Database Structure ] ... "); //load it from sql files for now. later make use of resources. using (FileStream fs = File.OpenRead(scriptPath)) { StreamReader sr = new StreamReader(fs); String sql = sr.ReadToEnd(); sr.Close(); fs.Close(); store.RunSql(sql); } Log("[ Done ]."); Log("[ Creating tables ] ... "); scriptPath = Path.Combine(scriptLocation, "Alchemi_structure.sql"); //load it from sql files for now. later make use of resources. using (FileStream fs = File.OpenRead(scriptPath)) { StreamReader sr = new StreamReader(fs); String sql = sr.ReadToEnd(); sr.Close(); fs.Close(); store.RunSql(sql); } Log("[ Done ]."); Log("[ Inserting initialization data ] ... "); scriptPath = Path.Combine(scriptLocation, "Alchemi_data.sql"); //load it from sql files for now. later make use of resources. using (FileStream fs = File.OpenRead(scriptPath)) { StreamReader sr = new StreamReader(fs); String sql = sr.ReadToEnd(); sr.Close(); fs.Close(); store.RunSql(sql); } Log("[ Done ]."); // serialize configuration Log("[ Updating Configuration File ] ... "); config.DbServer = txServer.Text; config.DbUsername = txUsername.Text; config.DbPassword = txAdminPwd.Text; config.DbName = "Alchemi"; config.Slz(); Log("[ Done ]."); Log("Wrote configuration file to " + InstallLocation); Log("[ Installation Complete! ]"); btInstall.Enabled = false; btFinish.Enabled = true; } catch (Exception ex) { Log("[ Error ]"); Log(ex.Message); return; } }
/// <summary> /// Reads the Manager configuration from the Alchemi.Manager.config.xml file, /// <br /> or gets the default configuration, if there is an error reading the file. /// </summary> public void ReadConfig() { try { Config = Configuration.GetConfiguration(); } catch //get default { Config = new Configuration(); } }