private void onEmpty() { if (this.onEmptyScr != null) { RefScriptExecute exec = new RefScriptExecute(this.onEmptyScr, this); exec.run(); } }
/// <summary> /// trigger if the iteration is Done. /// executes the assigned script if set /// </summary> private void iterateDone() { if (this.iterateDoneScr != null) { RefScriptExecute exec = new RefScriptExecute(this.iterateDoneScr, this); exec.run(); } }
private void doneDb() { if (this.onDoneScr != null) { RefScriptExecute exec = new RefScriptExecute(this.onDoneScr, this); exec.run(); } }
private void scrMysqError(string message) { if (this.onErrorScr != null) { this.onErrorScr.createOrUpdateStringVar("&" + this.errorVariableName, message); RefScriptExecute exec = new RefScriptExecute(this.onErrorScr, this); exec.run(); } }
/// <summary> /// starts the iteration. The current iteration name /// is assigned to the scriptvar &ITERATION.PROFIL /// </summary> /// <param name="str"></param> private void iterate(string str) { if (this.iterateScr != null) { this.iterateScr.createOrUpdateStringVar("&ITERATION.PROFIL", str); RefScriptExecute exec = new RefScriptExecute(this.iterateScr, this); exec.run(); } }
private void iteration(string fieldname, string value) { if (this.onIterationScr != null) { this.onIterationScr.createOrUpdateStringVar("&" + this.iterationVaribaleName, fieldname); this.onIterationScr.createOrUpdateStringVar("&" + this.iterationVaribaleValue, value); RefScriptExecute exec = new RefScriptExecute(this.onIterationScr, this); exec.run(); } }
public void splitAndIterate(string source, string splitBy, string nameOfVar, ReflectionScript script) { if (script != null) { string[] parts = source.Split(splitBy.ToCharArray()); foreach (string part in parts) { RefScriptExecute exec = new RefScriptExecute(script, this); script.createOrUpdateStringVar("&" + nameOfVar, part); exec.run(); } } }
private void rowIteration(Hashtable hashResult) { if (onRowIterationScr != null) { int number = 0; foreach (DictionaryEntry row in hashResult) { string headName = row.Key.ToString(); string val = ""; if (row.Value != null) { val = row.Value.ToString(); } this.onRowIterationScr.createOrUpdateStringVar("&" + headName, val); number++; this.onRowIterationScr.createOrUpdateStringVar("&ROW." + number, val); } RefScriptExecute exec = new RefScriptExecute(this.onRowIterationScr, this); exec.run(); } }
private Boolean execLine(ReflectionScriptDefines scrLine) { // what ever happens ..tis line is executed this.currentExecLine++; if (this.forceAbort) { return(true); } if (this.currentScript.Parent != null && this.currentScript.Parent.CurrentExecuter != null) { if (this.currentScript.Parent.CurrentExecuter.aborting()) { return(true); } } string cmd = scrLine.code.ToUpper(); //this.currentScript.updateParam(scrLine); if (cmd == "MESSAGEBOX") { string message = ""; foreach (string parStr in scrLine.scriptParameters) { message += this.currentScript.fillUpAll(parStr); } MessageBox.Show(message); } if (cmd == "REG") { string procIdent = ""; foreach (string parStr in scrLine.scriptParameters) { procIdent += this.currentScript.fillUpAll(parStr); } ProcSync.addSubProc(RefScriptExecute.PROC_NAME + this.ProcID, procIdent); } if (cmd == "UNREG") { string procIdent = ""; foreach (string parStr in scrLine.scriptParameters) { procIdent += this.currentScript.fillUpAll(parStr); } if (ProcSync.getProcCount(RefScriptExecute.PROC_NAME + this.ProcID, procIdent) > 0) { ProcSync.removeSubProc(RefScriptExecute.PROC_NAME + this.ProcID, procIdent); } } if (cmd == "EXEC") { List <string> execPars = new List <string>(); string externalScript = ""; foreach (string parStr in scrLine.scriptParameters) { if (externalScript == "") { externalScript = this.currentScript.fillUpAll(parStr); } else { execPars.Add(this.currentScript.fillUpAll(parStr)); } } PConfig seting = new PConfig(); string scrPath = seting.getSettingWidthDefault("client.scriptpath", System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments)); string scrFileName = scrPath + System.IO.Path.DirectorySeparatorChar.ToString() + externalScript; if (System.IO.File.Exists(scrFileName)) { string code = System.IO.File.ReadAllText(scrFileName); ReflectionScript exScrpt = new ReflectionScript(); exScrpt.setCode(code); exScrpt.addSetupIfNotExists(ReflectionScript.SETUP_PREVIEW, true); RefScriptExecute subExec = new RefScriptExecute(exScrpt, this.parentObject); int ppp = 0; foreach (string parToExec in execPars) { ppp++; exScrpt.createOrUpdateStringVar("&PARAM." + ppp, parToExec); } subExec.run(); } else { ScriptErrors error = new ScriptErrors(); error.errorMessage = "script not found:" + scrFileName; error.lineNumber = scrLine.lineNumber; error.runtimeError = true; error.errorCode = Projector.RefSrcStates.ERROR_TYPE_WARNING; this.currentScript.addError(error); } } if (cmd == "WAITFOR") { Application.DoEvents(); string procIdent = ""; foreach (string parStr in scrLine.scriptParameters) { procIdent += this.currentScript.fillUpAll(parStr); } if (ProcSync.getProcCount(RefScriptExecute.PROC_NAME + this.ProcID, procIdent) > 0) { // max time reached ? if (this.checkWaitingTimer(procIdent)) { // get back to my self currentExecLine--; Application.DoEvents(); return(true); } else { ScriptErrors error = new ScriptErrors(); error.errorMessage = "Max Waiting Time reached. Check code or increase max waiting Time"; error.lineNumber = scrLine.lineNumber; error.runtimeError = true; error.errorCode = Projector.RefSrcStates.ERROR_TYPE_WARNING; this.currentScript.addError(error); this.removeWaitTimerIfExists(procIdent); } } else { this.removeWaitTimerIfExists(procIdent); } } if (scrLine.setState != 0) { if (scrLine.isParentAssigned) { if (this.currentScript.Parent != null && this.currentScript.Parent.CurrentExecuter != null) { //this.currentScript.Parent. this.currentScript.Parent.CurrentExecuter.runState = scrLine.setState; this.currentScript.Parent.CurrentExecuter.changedState(); } else { ScriptErrors error = new ScriptErrors(); error.errorMessage = "Parent can be used in subscripts only "; error.lineNumber = scrLine.lineNumber; error.runtimeError = true; error.errorCode = Projector.RefSrcStates.EXEC_ERROR_INVALIDOBJECT; this.currentScript.addError(error); } } else { this.runState = scrLine.setState; } } // execute object assignements that NOT are methods. so just code assignements if (scrLine.isAssignement && scrLine.name != null && scrLine.isMethod == false) { // for any assignement a variable must be exists and allready defined this.currentScript.recalcBrackets(scrLine); } if (scrLine.isVariable && !scrLine.isSetup) { this.currentScript.updateParam(scrLine, true); } if (scrLine.isObject && this.objectDefines.ContainsKey(cmd)) { scrLine.Referenz = objectDefines[cmd]; this.execReflectObject(scrLine); if (scrLine.ReflectObject == null) { ScriptErrors error = new ScriptErrors(); error.errorMessage = "object " + scrLine.typeOfObject + " not createable"; error.lineNumber = scrLine.lineNumber; error.errorCode = Projector.RefSrcStates.EXEC_ERROR_NONOBJECT; error.runtimeError = true; this.currentScript.addError(error); lastErrorCode = Projector.RefSrcStates.EXEC_ERROR_INVALIDOBJECT; return(false); } if (!this.scrVars.objectIsStored(scrLine.name)) { this.scrVars.createObject(scrLine.name, scrLine.ReflectObject, scrLine.typeOfObject); } else { ScriptErrors error = new ScriptErrors(); error.errorMessage = "object " + scrLine.typeOfObject + " allready added. Check Script"; error.lineNumber = scrLine.lineNumber; error.errorCode = Projector.RefSrcStates.EXEC_ERROR_NONOBJECT; error.runtimeError = true; this.currentScript.addError(error); lastErrorCode = Projector.RefSrcStates.EXEC_ERROR_INVALIDOBJECT; return(false); } } if (scrLine.isMethod && scrLine.namedReference != null) { Object useObject = this.getRegisteredObject(scrLine.namedReference); //Object useObject = scrLine.ReflectObject; //Object useObject = this.currentScript.getRegisteredObject(scrLine.namedReference); if (useObject != null) { this.lastErrorCode = 0; this.currentScript.updateParam(scrLine, true); Object execResult = this.execMethod(useObject, scrLine); scrLine.ReflectObject = useObject; this.currentScript.scrVars.updateExistingObject(scrLine.namedReference, useObject); if (this.lastErrorCode > 0) { ScriptErrors error = new ScriptErrors(); error.errorMessage = "object " + scrLine.typeOfObject + " reports an error on execution " + this.lastErrorCode + this.lastErrorMessage; error.lineNumber = scrLine.lineNumber; error.runtimeError = true; error.errorCode = this.lastErrorCode; this.currentScript.addError(error); } else { this.currentScript.updateMeByObject(scrLine); if (scrLine.isAssignement && execResult != null) { if (scrLine.isParentAssigned) { if (this.currentScript.Parent != null) { this.currentScript.Parent.scrVars.updateVarByObject(scrLine.name, execResult); } } else { this.currentScript.scrVars.updateVarByObject(scrLine.name, execResult); } } } } else { ScriptErrors error = new ScriptErrors(); error.errorMessage = "execution Fail: " + scrLine.namedReference + " is not registered as an executable Object "; error.lineNumber = scrLine.lineNumber; error.errorCode = this.lastErrorCode; error.runtimeError = true; this.currentScript.addError(error); } } // last trigger call if (this.debugMode) { this.currentDebugLine = scrLine; this.updateMessage(scrLine); } return(true); }