private void runPrograms(dsThingPrograms.thingsRow curThing, string eventName = null) { foreach (dsThingPrograms.programsRow program in curThing.GetChildRows("FK_things_programs")) { if (program.enabled && (eventName == null || program.trigger_event == eventName)) { Process progProcess = new Process(); try { progProcess.StartInfo.UseShellExecute = false; // You can start any process, HelloWorld is a do-nothing example. progProcess.StartInfo.FileName = program.filePath; //myProcess.StartInfo.CreateNoWindow = true; progProcess.Start(); // This code assumes the process you are starting will terminate itself. // Given that is is started without a window so you cannot terminate it // on the desktop, it must terminate itself or you can do it programmatically // from this application using the Kill method. } catch (Exception e) { string errorHeader; if (program.name == null || program.name == "") { errorHeader = "Problem launching script/program at " + program.filePath; } else { errorHeader = "Problem launching " + program.name; } MessageBox.Show(errorHeader + ":\n" + e.Message, Globals.errorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void imageDeleteObject_Click(object sender, EventArgs e) { dsThingPrograms.thingsRow curThing = this.dsThingPrograms.things.FindByRFID(curRFID); foreach (dsThingPrograms.programsRow program in curThing.GetChildRows("FK_things_programs")) { this.dsThingPrograms.programs.Rows.Remove(program); } this.dsThingPrograms.things.Rows.Remove(curThing); this.dsThingPrograms.things.WriteXml(Globals.thingsXmlPath, XmlWriteMode.WriteSchema); this.dsThingPrograms.programs.WriteXml(Globals.programsXmlPath, XmlWriteMode.WriteSchema); }