/// <summary> /// Constructs the Math object. /// /// </summary> /// <param name="parent">The script that uses the the math</param> /// <param name="Name">Name of the Calculation</param> /// <param name="code">the code that contains the calculation</param> public RefScrMath(ReflectionScript parent, string Name, string code) { this.parentScript = parent; this.mathBase = new RefScrMathObj(); this.mathBase.name = Name; this.mathBase.code = code; this.mathBase.Value = 0; }
public RefScriptExecute(ReflectionScript script, Object parent) { this.parentObject = parent; this.currentScript = script; this.currentScript.CurrentExecuter = this; this.ProcID = this.getRunIdent(); this.init(); }
public void invoke(ReflectionScript script) { this.Script = script; if (this.Script.getErrorCount() == 0) { RefScriptExecute executer = new RefScriptExecute(this.Script, this); executer.run(); } }
private void scriptExec_Click(object sender, EventArgs e) { if (this.scriptText != null) { ReflectionScript script = new ReflectionScript(); script.setCode(this.scriptText); if (script.getNotRuntimeErrorCount() == 0) { RefScriptExecute executer = new RefScriptExecute(script, this); executer.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(); } } }
public Hashtable getAllStrings() { Hashtable fullStrings = this.globalRenameHash; foreach (DictionaryEntry subScr in this.subScripts) { ReflectionScript refScr = (ReflectionScript)subScr.Value; foreach (DictionaryEntry subVars in refScr.getAllStrings()) { if (!fullStrings.ContainsKey(subVars.Key)) { fullStrings.Add(subVars.Key, subVars.Value); } } } return(fullStrings); //return this.globalRenameHash; }
private ReflectForm getForm(ReflectionScriptDefines refObject, Object parent) { ReflectForm newForm; newForm = (ReflectForm)this.getExistingObject(refObject.name); string objToken = refObject.name; if (newForm == null) { newForm = new ReflectForm(); } newForm.ScriptIdent = refObject.name; newForm.Name = objToken; if (parent is MdiForm) { MdiForm mdi = (MdiForm)parent; mdi.addSubWindow(newForm, refObject.name); } else if (parent is Form) { this.showRForm(newForm, refObject.name); } else if (parent is ReflectionScript) { ReflectionScript parScr = (ReflectionScript)parent; if (parScr.SetupBoolValue(ReflectionScript.SETUP_PREVIEW)) { this.showRForm(newForm, refObject.name); } } else { this.showRForm(newForm, refObject.name); } this.addObject(refObject.name, newForm); return(newForm); }
public void OnEmptyResult(ReflectionScript scr) { this.onEmptyScr = scr; }
public void OnTick(ReflectionScript script) { this.onTimerScr = script; }
public void OnDoneCsvExport(ReflectionScript onDoneReading) { this.onDoneExportCsv = onDoneReading; }
public void OnWebResponse(string nameOfVar, ReflectionScript script) { this.webRequestName = nameOfVar; this.OnWebResultScript = script; }
public void OnTextChange(ReflectionScript scr) { this.onChangeScr = scr; }
public void OnError(String messagevar, ReflectionScript scr) { this.errorVariableName = messagevar; this.onErrorScr = scr; }
public void OnRow(ReflectionScript scr) { this.onRowIterationScr = scr; }
public Boolean updateExistingObject(String name, Object value, Boolean selfInc) { Boolean found = false; /* * if (globalRenameHash.ContainsKey("&" + name)) * { * found = true; * if (selfInc) * { * globalRenameHash["&" + name] += value.ToString(); * } * else * { * globalRenameHash["&" + name] = value.ToString(); * } * } */ if (objectStorage.ContainsKey(name) && this.objectStorage.ContainsKey(name)) { found = true; if (!selfInc) { Type valueType = value.GetType(); Type originType = this.objectStorage[name].GetType(); if (valueType == originType) { this.objectStorage[name] = value; if (globalRenameHash.ContainsKey("&" + name)) { globalRenameHash["&" + name] = value; } } else { this.lastErrorCode = Projector.Script.Vars.Variables.ERROR_INCOMPATIBLE_TYPE; this.lastErrorMessage = name + "::Cast Error [" + value + "] can not converted from [" + valueType.Name + "] in to [" + originType.Name + "]"; this.isError = true; return(false); } /* * if (this.debugMode) * { * this.updateDebugMessage("&" + name, value.ToString()); * }*/ } else { if (value is String && this.objectStorage[name] is String) { String store = (string)this.objectStorage[name]; store += value; this.objectStorage[name] = value; if (globalRenameHash.ContainsKey("&" + name)) { globalRenameHash["&" + name] = store; } } else if (value is String && this.objectStorage[name] is int) { int store = (int)this.objectStorage[name]; try { store += int.Parse(value.ToString()); } catch (Exception ex) { this.lastErrorCode = Projector.Script.Vars.Variables.ERROR_INCOMPATIBLE_TYPE; this.lastErrorMessage = name + "::Cast Error. " + value + " can to be converted to INT. |" + ex.Message; this.isError = true; return(false); } this.objectStorage[name] = store; if (globalRenameHash.ContainsKey("&" + name)) { globalRenameHash["&" + name] = store; } } else if (value is int && this.objectStorage[name] is int) { int store = (int)this.objectStorage[name]; store += (int)value; this.objectStorage[name] = store; if (globalRenameHash.ContainsKey("&" + name)) { globalRenameHash["&" + name] = store; } } else if (value is Double && this.objectStorage[name] is int) { /* * int store = (int)this.objectStorage[name]; * Double pVal = (Double) value; * store += (int) Math.Round( pVal ); * this.objectStorage[name] = store; * if (globalRenameHash.ContainsKey("&" + name)) * globalRenameHash["&" + name] = store; */ this.lastErrorCode = Projector.Script.Vars.Variables.ERROR_INCOMPATIBLE_TYPE; this.lastErrorMessage = name + "::Type Double can not be used for Type Integer."; this.isError = true; } else if (value is String && this.objectStorage[name] is Double) { Double store = (Double)this.objectStorage[name]; try { Double pVal = Double.Parse(value.ToString()); store += pVal; } catch (Exception ex) { this.lastErrorCode = Projector.Script.Vars.Variables.ERROR_INCOMPATIBLE_TYPE; this.lastErrorMessage = name + "::Cast Error. " + value + " can to be converted to Double. " + ex.Message; this.isError = true; return(false); } this.objectStorage[name] = store; if (globalRenameHash.ContainsKey("&" + name)) { globalRenameHash["&" + name] = store; } } else { /* this.addError("this type can not be incremented");*/ this.lastErrorCode = Projector.Script.Vars.Variables.ERROR_TYPE_NOT_INC_COMPATIBLE; this.lastErrorMessage = "This Type can't be incremented"; this.isError = true; found = false; } } foreach (DictionaryEntry scrpt in this.subScripts) { ReflectionScript refScr = (ReflectionScript)scrpt.Value; if (refScr.scrVars.objectIsStored("parent." + name)) { refScr.scrVars.updateExistingObject("parent." + name, this.objectStorage[name]); } if (refScr.scrVars.objectIsStored(name)) { refScr.scrVars.updateExistingObject(name, this.objectStorage[name]); } } /* * if (this.debugMode) * { * this.updateDebugMessage(name, value.ToString()); * }*/ } if (found == false) { this.lastErrorCode = Projector.Script.Vars.Variables.ERROR_UNKNOW_TARGET; this.lastErrorMessage = "variable &" + name + " not existing/writable"; this.isError = true; } return(found); }
public void OnLeave(ReflectionScript scr) { this.onLeaveScr = scr; }
public void OnOpenFilenameSelected(string pathVarName, ReflectionScript script) { this.nameOfVar = pathVarName; this.openScript = script; }
public void OnEnter(ReflectionScript scr) { this.onEnterScr = scr; }
public void OnIteration(String iterationName, string iterationValue, ReflectionScript scr) { this.iterationVaribaleName = iterationName; this.iterationVaribaleValue = iterationValue; this.onIterationScr = scr; }
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); }
public void OnDone(ReflectionScript scr) { this.onDoneScr = scr; }
/// <summary> /// assign script that will be executed until interation /// </summary> /// <param name="scr">Reflectionscriot that will be executed on each iteration</param> public void OnIteration(ReflectionScript scr) { this.iterateScr = scr; }
public void OnMessage(ReflectionScript script) { this.OnMessageScript = script; }
public void invoke(ReflectionScript invokeScript) { RefScriptExecute executer = new RefScriptExecute(invokeScript, this); executer.run(); }
public void OnCloseForm(ReflectionScript script) { this.onCloseScript = script; }
public ReflectionScriptHighLight(ReflectionScript script, RichTextBox rtf) { execColors[0] = Color.FromArgb(75, 20, 35); execColors[1] = Color.FromArgb(80, 40, 45); execColors[2] = Color.FromArgb(85, 60, 55); execColors[3] = Color.FromArgb(90, 80, 65); execColors[4] = Color.FromArgb(95, 100, 75); execColors[5] = Color.FromArgb(100, 120, 85); execColors[6] = Color.FromArgb(105, 140, 95); execColors[7] = Color.FromArgb(115, 160, 105); execColors[8] = Color.FromArgb(120, 180, 115); execColors[9] = Color.FromArgb(125, 200, 125); this.Srcipt = script; this.assignedRtf = rtf; this.drawingRtf = new RichBox(); drawingRtf.Rtf = assignedRtf.Rtf; this.RtfColors = new RtfColoring(drawingRtf); drawingRtf.highlighting = true; loadColors(); rtf.BackColor = HighlightStyle.defaultColor; this.ObjectStyle.ForeColor = Color.DarkMagenta; this.ObjectStyleReferenz.ForeColor = Color.SteelBlue; this.VaribalesStyle.ForeColor = Color.DarkGreen; //this.VaribalesStyle.BackColor = Color.Transparent; this.CommandStyle.ForeColor = Color.Blue; this.ReferenzStyle.ForeColor = Color.DarkGoldenrod; this.VarStyle.ForeColor = Color.DarkOrange; this.KeyWordStyle.ForeColor = Color.DarkBlue; this.CommentStyle.ForeColor = Color.DarkOliveGreen; this.CommentStyle.BackColor = Color.LightGray; this.ErrorStyle.ForeColor = Color.DarkRed; this.ErrorStyle.BackColor = Color.LightPink; this.InProgressStyle.ForeColor = Color.OrangeRed; this.InProgressStyle.BackColor = Color.Yellow; this.executionStyle.ForeColor = Color.LightGreen; this.executionStyle.BackColor = Color.DarkGreen; this.TextStyle.ForeColor = Color.SlateBlue; this.TextStyle.BackColor = Color.LightCyan; this.NumberStyle.ForeColor = Color.DarkGoldenrod; this.RtfColors.stringStyle = this.TextStyle; this.resetFonts(); }
public void OnStatusChange(string statusVar, ReflectionScript onDoneReading) { this.statusMessageVar = statusVar; this.onStatusScript = onDoneReading; }
public void OnClick(ReflectionScript invkoeOnClick) { this.invokeOnClickScr = invkoeOnClick; }
public void OnClose(ReflectionScript onDoneReading) { this.onCloseScript = onDoneReading; }
public RefScriptMaskMatch(String source, ReflectionScript useMe) { this.sourceStr = source; this.parent = useMe; this.buildElements(); }