// User wants to create a new subprocess protected void Button1_Click(object sender, EventArgs e) { if (!AuthCheck()) { Server.Transfer("AuthFail.html"); return; } int IDprocess; OdbcConnection conn = HELPERS.NewOdbcConn(); string newname; string processname; // New process or existing process? if (ChooserProcess.SelectedItem != null) { // Existing process! IDprocess = int.Parse(ChooserProcess.SelectedItem.Value); processname = ChooserProcess.SelectedItem.Text; } else { IProcess Iprc = new IProcess(conn); newname = ChooserProcess.Text.Trim(); processname = newname; if (newname.Length < 2) { throw new Exception("Name for new process is empty or too brief."); } IDprocess = Iprc.NewProcess(newname); } // Create the new subprocess ISubProcess Isprc = new ISubProcess(conn); newname = this.TextBox_NewSubprocess.Text.Trim(); if (newname.Length < 2) { throw new Exception("Name for new subprocess is empty or too brief."); } int IDsubprocess = Isprc.NewSubProcess(newname, IDprocess); Isprc.SetSubProcess(IDsubprocess, newname, IDprocess, "Active"); // New subprocess now created. Record this with the session. LogInToSubprocess(IDsubprocess, processname, newname); Response.Redirect("HOME.aspx"); }
public static int FindSubProcess (OdbcConnection conn, int IDprocessCCM, string name, bool buildIfNeeded) { ISubProcess Ispr = new ISubProcess(conn); returnListSubProcess[] ret = Ispr.ListSubProcess(null, "\"Name\" like ?", new string[] { name }, ""); if (ret.Length == 1) { return(ret[0].ID); } else { if (buildIfNeeded) { return(Ispr.NewSubProcess(name, IDprocessCCM)); } else { throw new System.NullReferenceException("No subprocess found with this name: " + name); } } }