/// <summary> /// Create new Process and fill with parameters form GUI. /// </summary> private void RefreshProcess() { runner = new Runner(txtSQLCommandsFile.Text); RefreshGlobalParameters(); if(chkTransformSnapshots.Checked) runner.Add(RefreshSnapshotsProcess()); if (chkTransformSimDBFoF.Checked) runner.Add(RefreshSimDBFOFsProcess()); if (chkFFTData.Checked) runner.Add(RefreshFFTDataProcess()); }
static void Main(string[] args) { AttachConsole(ATTACH_PARENT_PROCESS); CommandLineOptions opts = new CommandLineOptions(); //defines the command line parameters var par = new OptionSet() { //need to throw option exceptions for all options that have non-optionable values { "g|gui", "launches the gui, all other options are ignored", v => {if (v != null) opts.gui = true; } }, { "z|timestep=", "sets the {TIMESTEP} to transform", (short v) => {opts.timestep = v; } }, { "1|firstsnap", "true if this is the first snapshot loaded for this simulation", v => {opts.firstSnap = true; } }, // DEPRECATED OPTION /*{ "d|database=", "dictates what database the data will be loaded into", v => {opts.database = v; } }, { "r|server=", "dictates what server the database is on", v => {opts.server = v; } },*/ { "t|fft", "loads the fft data", v => {opts.fft = true; } }, { "f|fof", "loads the fof data", v => {opts.fof = true; } }, { "s|snap", "loads the particle data", v => {opts.snap = true; } }, /*{ "p|phbits=", "sets the {NUMBER} of bits to use when calculating Peano-Hilbert index", (int v) => {opts._phbits = v; } }, { "n|nzones=", "sets the {NUMBER} of zones", (int v) => { opts._nzones = v; } }, { "b|box=", "sets the {SIZE} of the simulation box", (int v) => { opts._boxsize = v; } },*/ { "m|sim=", "the {NAME} of the simulation this timestep belongs to", v => { if (v == null) throw new OptionException ("Missing the simulation name for option -sim", "-sim"); opts.sim = v; } }, { "v|server=", "the name of the database {SERVER}", v => { if (v == null) throw new OptionException ("Missing the server name for for option -server", "-server"); opts.server = v; } }, { "d|database=", "the {NAME} of the SQL database", v => { if (v == null) throw new OptionException("Missing the database name for for option -database", "-database"); opts.database = v; } }, { "q|sqlcf=", "sets the {NAME} of the SQL command file to write to", v => { if (v == null) throw new OptionException ("Missing the name of the SQL commands file for option -sqlcf", "-sqlcf"); opts.sqlCF = v; } }, { "h|help", "Show this message and exit", v => opts.show_help = v != null }, }; if (args.Length > 0) { try { par.Parse(args); } // TODO: SUMMARY catch (OptionException e) { Console.Write("GadgetLoader: "); Console.WriteLine(e.Message); Console.WriteLine("Try 'GadgetLoader --help' for more information."); return; } if (!opts.validOptions()) { ShowHelp(par); return; } if (opts.show_help) { ShowHelp(par); return; } //creates a gui if (opts.gui) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmMain()); } else { Runner runner = new Runner(opts.sqlCF); LoaderParamSingleton.getInstance(opts); GlobalParameters globalParameters = RefreshGlobalParameters(opts); try { RefreshProcess(globalParameters, runner, opts); runner.Run(); } catch (Exception e) { globalParameters.summary.addError(e.Message); } finally { globalParameters.summary.writeSummary(); globalParameters.summary.writeBCPFile(); System.Windows.Forms.SendKeys.SendWait("{ENTER}"); } } } //If no options, run gui else { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmMain()); } }
/// <summary> /// Create new Process and initialize with parsed command line parameters /// </summary> /// <param name="gp">The GlobalParameters object containing global state</param> /// <param name="runner">The Runner object to execute the process</param> /// <param name="opts">The command line options</param> private static void RefreshProcess(GlobalParameters gp, Runner runner, CommandLineOptions opts) { string inpath = ""; string outpath = ""; //read snapshot configuration from database try { SqlConnection configConn = new SqlConnection(LoaderParamSingleton.createConnString(opts.database, opts.server)); configConn.Open(); SqlDataReader myReader = null; string command = "select * from dbo.config where sim = @sim and snapnum = @snapnum"; SqlCommand myCommand = new SqlCommand(command, configConn); SqlParameter timestepParam = new SqlParameter("@snapnum", System.Data.SqlDbType.SmallInt); SqlParameter simParam = new SqlParameter("@sim", System.Data.DbType.String); timestepParam.Value = opts.timestep; simParam.Value = opts.sim; myCommand.Parameters.Add(timestepParam); myCommand.Parameters.Add(simParam); myReader = myCommand.ExecuteReader(); //Can add any other properties we want to read from DB here int numLines = 0; while (myReader.Read()) { //TODO: do i need to escape backslashes in the paths? //I don't think so, it's been working fine so far inpath = myReader["inpath"].ToString(); outpath = myReader["outpath"].ToString(); numLines++; } configConn.Close(); if (numLines > 1) { throw new ConfigurationException( "Multiple entries matching this snapshot in configuration table"); } else if (numLines < 1) { throw new ConfigurationException( "Zero entries matching this snapshot in configuration table"); } gp.summary.setFile(outpath + "\\summary"); } /*catch (Exception e) { Console.Out.WriteLine("Caugth DB exception"); gp.summary.addError(e.Message); return; }*/ catch (Exception) { throw; } if (opts.snap) { Console.WriteLine("Adding Snapshot process to runner"); runner.Add(RefreshSnapshotsProcess(gp, inpath, outpath, opts)); } if (opts.fof) { runner.Add(RefreshIndraFOFProcess(gp, inpath, outpath, opts)); } if (opts.fft) { runner.Add(RefreshIndraFFTProcess(gp, inpath, outpath, opts)); } }
/// <summary> /// Create new Process and fill with parameters form GUI. /// </summary> private void RefreshProcess() { runner = new Runner(txtSQLCommandsFile.Text); RefreshGlobalParameters(); if(chkTransformSnapshots.Checked) runner.Add(RefreshSnapshotsProcess()); if(chkTransformFOFOrderedSnapshots.Checked) runner.Add(RefreshFOFOrderedSnapshotsProcess()); if(chkTransformGroups.Checked) runner.Add(RefreshGroupsProcess()); if(chkTransformHaloTrees.Checked) runner.Add(RefreshHaloTreesProcess()); if (chkTransformGalaxies.Checked) runner.Add(RefreshGalaxyTreesProcess()); if (chkTransformSimDBFoF.Checked) runner.Add(RefreshSimDBFOFsProcess()); }