コード例 #1
0
ファイル: RefScrMath.cs プロジェクト: swaros/projector
 /// <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;
 }
コード例 #2
0
ファイル: RefScriptExecute.cs プロジェクト: swaros/projector
 public RefScriptExecute(ReflectionScript script, Object parent)
 {
     this.parentObject  = parent;
     this.currentScript = script;
     this.currentScript.CurrentExecuter = this;
     this.ProcID = this.getRunIdent();
     this.init();
 }
コード例 #3
0
 public void invoke(ReflectionScript script)
 {
     this.Script = script;
     if (this.Script.getErrorCount() == 0)
     {
         RefScriptExecute executer = new RefScriptExecute(this.Script, this);
         executer.run();
     }
 }
コード例 #4
0
ファイル: MdiForm.cs プロジェクト: swaros/projector
 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();
         }
     }
 }
コード例 #5
0
ファイル: RString.cs プロジェクト: swaros/projector
        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();
                }
            }
        }
コード例 #6
0
        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;
        }
コード例 #7
0
ファイル: ReflectNew.cs プロジェクト: swaros/projector
        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);
        }
コード例 #8
0
 public void OnEmptyResult(ReflectionScript scr)
 {
     this.onEmptyScr = scr;
 }
コード例 #9
0
ファイル: IntervalTimer.cs プロジェクト: swaros/projector
 public void OnTick(ReflectionScript script)
 {
     this.onTimerScr = script;
 }
コード例 #10
0
ファイル: GroupQuery.cs プロジェクト: swaros/projector
 public void OnDoneCsvExport(ReflectionScript onDoneReading)
 {
     this.onDoneExportCsv = onDoneReading;
 }
コード例 #11
0
 public void OnWebResponse(string nameOfVar, ReflectionScript script)
 {
     this.webRequestName    = nameOfVar;
     this.OnWebResultScript = script;
 }
コード例 #12
0
ファイル: LabelText.cs プロジェクト: swaros/projector
 public void OnTextChange(ReflectionScript scr)
 {
     this.onChangeScr = scr;
 }
コード例 #13
0
 public void OnError(String messagevar, ReflectionScript scr)
 {
     this.errorVariableName = messagevar;
     this.onErrorScr        = scr;
 }
コード例 #14
0
 public void OnRow(ReflectionScript scr)
 {
     this.onRowIterationScr = scr;
 }
コード例 #15
0
        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);
        }
コード例 #16
0
ファイル: LabelText.cs プロジェクト: swaros/projector
 public void OnLeave(ReflectionScript scr)
 {
     this.onLeaveScr = scr;
 }
コード例 #17
0
 public void OnOpenFilenameSelected(string pathVarName, ReflectionScript script)
 {
     this.nameOfVar  = pathVarName;
     this.openScript = script;
 }
コード例 #18
0
ファイル: LabelText.cs プロジェクト: swaros/projector
 public void OnEnter(ReflectionScript scr)
 {
     this.onEnterScr = scr;
 }
コード例 #19
0
 public void OnIteration(String iterationName, string iterationValue, ReflectionScript scr)
 {
     this.iterationVaribaleName  = iterationName;
     this.iterationVaribaleValue = iterationValue;
     this.onIterationScr         = scr;
 }
コード例 #20
0
ファイル: RefScriptExecute.cs プロジェクト: swaros/projector
        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);
        }
コード例 #21
0
 public void OnDone(ReflectionScript scr)
 {
     this.onDoneScr = scr;
 }
コード例 #22
0
ファイル: ProfileWorker.cs プロジェクト: swaros/projector
 /// <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;
 }
コード例 #23
0
 public void OnMessage(ReflectionScript script)
 {
     this.OnMessageScript = script;
 }
コード例 #24
0
ファイル: FormGroup.cs プロジェクト: swaros/projector
        public void invoke(ReflectionScript invokeScript)
        {
            RefScriptExecute executer = new RefScriptExecute(invokeScript, this);

            executer.run();
        }
コード例 #25
0
 public void OnCloseForm(ReflectionScript script)
 {
     this.onCloseScript = script;
 }
コード例 #26
0
        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();
        }
コード例 #27
0
ファイル: GroupQuery.cs プロジェクト: swaros/projector
 public void OnStatusChange(string statusVar, ReflectionScript onDoneReading)
 {
     this.statusMessageVar = statusVar;
     this.onStatusScript   = onDoneReading;
 }
コード例 #28
0
 public void OnClick(ReflectionScript invkoeOnClick)
 {
     this.invokeOnClickScr = invkoeOnClick;
 }
コード例 #29
0
ファイル: GroupQuery.cs プロジェクト: swaros/projector
 public void OnClose(ReflectionScript onDoneReading)
 {
     this.onCloseScript = onDoneReading;
 }
コード例 #30
0
 public RefScriptMaskMatch(String source, ReflectionScript useMe)
 {
     this.sourceStr = source;
     this.parent    = useMe;
     this.buildElements();
 }