/// <summary> /// Izvrsava operaciju za ovu instancu /// </summary> public void freeRunnerOperationExecute(freeRunnerOperation toExecute) { freeRunnerModule.freeRunnerOperationExecute(toExecute, this, null, this); }
/// <summary> /// Izvrsava operaciju nad ITEM-om /// </summary> /// <param name="toExecute">Operacija koja treba da se izvrsi</param> /// <param name="__item">Objekat koji je prosledjen prilikom poziva: moze biti editor ili objekat - ali treba da bude trenutno selektovani objekat</param> /// <param name="__collection">Kolekcija ciji je item clan</param> /// <param name="parentObject">Parent objekat u odnosu na selektovan item</param> public static void freeRunnerOperationExecute(freeRunnerOperation toExecute, freeRunnerModule __item, ObservableCollection <freeRunnerModule> __collection, Object parentObject) { freeRunnerModule _item = __item as freeRunnerModule; if (_item == null) { _item = parentObject as freeRunnerModule; } if (_item == null) { return; } String signature = ""; String signatureTwo = ""; String workdirectory = ""; switch (toExecute) { case freeRunnerOperation.run: _item.lastResponse = ""; if (_item.autoKillExistingProcess) { _item.freeRunnerOperationExecute(freeRunnerOperation.killActiveProcess); } switch (_item.toolToRun) { case externalTool.freeRunner: _item.activeProcess = run.startApplication(_item.path, _item.arguments, _item.useSchellExecute, _item.homeDirectory); break; default: _item.activeProcess = run.startApplication(_item.toolToRun, _item.arguments); break; } if (_item.activeProcess != null) { _item.activeProcess.Exited += _item.activeProcess_Exited; if (!_item.useSchellExecute) { switch (_item.StandardMode) { case freeRunnerLoging.disable: break; default: try { _item.activeProcess.OutputDataReceived += _item.activeProcess_OutputDataReceived; _item.activeProcess.BeginOutputReadLine(); } catch (Exception ex) { _item.lastResponse = ex.Message; } break; } switch (_item.ErrorMode) { case freeRunnerLoging.disable: break; default: try { _item.activeProcess.ErrorDataReceived += _item.activeProcess_ErrorDataReceived; _item.activeProcess.BeginErrorReadLine(); } catch (Exception ex) { _item.lastResponse = ex.Message; } break; } //_item.lastResponse = _item.activeProcess.StandardOutput } else { _item.lastResponse = "(turn off useSchellExecute to get StardardOutput results)"; } signature = _item.activeProcess.ProcessName + " (" + _item.activeProcess.Id + ") "; signatureTwo = " [" + _item.toolToRun.ToString() + "] path: " + _item.path + " with arguments: " + _item.arguments + " workdirectory: " + workdirectory; logSystem.log("Process started: " + signature + signatureTwo, logType.Done); } else { logSystem.log("Process start failed " + signatureTwo, logType.ExecutionError); } break; case freeRunnerOperation.killActiveProcess: if (_item.activeProcess != null) { signature = _item.activeProcess.ProcessName + " (" + _item.activeProcess.Id + ")"; if (_item.activeProcess.HasExited) { logSystem.log("Process already exited " + signature, logType.Done); } else { _item.activeProcess.Kill(); logSystem.log("Process killed " + signature, logType.Done); } _item.activeProcess.Dispose(); } else { logSystem.log("No active process to kill.", logType.ExecutionError); } break; case freeRunnerOperation.takeSelectedProcess: if (_item.selectedProcess != null) { _item.activeProcess = _item.selectedProcess; } break; case freeRunnerOperation.externalToolToFreerunMode: _item.activeProcess = run.startApplication(_item.toolToRun); break; case freeRunnerOperation.checkActiveProcess: break; case freeRunnerOperation.getCSharpLine: _item.lastResponse = "run.startApplication(\"" + _item.path + "\", \"" + _item.arguments + "\", " + _item.useSchellExecute.ToString() + ", \"" + _item.homeDirectory + "\");"; clipboard.setObject(_item.lastResponse); break; case freeRunnerOperation.browseForFile: throw new NotImplementedException(); //String selected = @select.selectFile("", fileDialog.open, // "Executable files (*.exe;*.jar;*.bat;*.dll;*.air;*.msi)|*.exe;*.jar;*.bat;*.dll;*.air;*.msi|All files (*.*)|*.*"); // if (!String.IsNullOrEmpty(selected)) _item.path = selected; break; default: logSystem.log("Operation execution not supported yed> " + toExecute.ToString(), logType.ExecutionError, true); break; } __item.refresh(); }