Beispiel #1
0
        public override void RunCommand(object sender)
        {
            var startFile = v_taskPath.ConvertToUserVariable(sender);

            //create variable list
            var variableList = new List <Script.ScriptVariable>();

            foreach (DataRow rw in v_VariableAssignments.Rows)
            {
                var variableName  = (string)rw.ItemArray[0];
                var variableValue = ((string)rw.ItemArray[1]).ConvertToUserVariable(sender);
                variableList.Add(new Script.ScriptVariable
                {
                    VariableName  = variableName,
                    VariableValue = variableValue
                });
            }

            UI.Forms.frmScriptEngine newEngine = new UI.Forms.frmScriptEngine(startFile, null, variableList, true);
            Core.Automation.Engine.AutomationEngineInstance currentScriptEngine = (Core.Automation.Engine.AutomationEngineInstance)sender;
            currentScriptEngine.tasktEngineUI.Invoke((Action) delegate() { currentScriptEngine.tasktEngineUI.TopMost = false; });
            Application.Run(newEngine);
            //currentScriptEngine.tasktEngineUI.TopMost = false;
            currentScriptEngine.tasktEngineUI.Invoke((Action) delegate() { currentScriptEngine.tasktEngineUI.TopMost = true; });
        }
Beispiel #2
0
        private void frmProcessingStatus_Load(object sender, EventArgs e)
        {
            //move engine form to bottom right and bring to front
            if (engineSettings.ShowDebugWindow)
            {
                this.BringToFront();
                MoveFormToBottomRight(this);
            }

            //start running
            engineInstance = new Core.Automation.Engine.AutomationEngineInstance();
            engineInstance.ReportProgressEvent    += Engine_ReportProgress;
            engineInstance.ScriptFinishedEvent    += Engine_ScriptFinishedEvent;
            engineInstance.LineNumberChangedEvent += EngineInstance_LineNumberChangedEvent;
            engineInstance.taskModel       = remoteTask;
            engineInstance.tasktEngineUI   = this;
            engineInstance.serverExecution = this.serverExecution;
            if (xmlData == null)
            {
                engineInstance.ExecuteScriptAsync(this, filePath, Variables);
            }
            else
            {
                engineInstance.ExecuteScriptXML(xmlData);
            }
        }
Beispiel #3
0
        private Script.ScriptVariable LookupVariable(Core.Automation.Engine.AutomationEngineInstance sendingInstance)
        {
            //search for the variable
            var requiredVariable = sendingInstance.VariableList.Where(var => var.VariableName == v_userVariableName).FirstOrDefault();

            //if variable was not found but it starts with variable naming pattern
            if ((requiredVariable == null) && (v_userVariableName.StartsWith(sendingInstance.engineSettings.VariableStartMarker)) && (v_userVariableName.EndsWith(sendingInstance.engineSettings.VariableEndMarker)))
            {
                //reformat and attempt
                var reformattedVariable = v_userVariableName.Replace(sendingInstance.engineSettings.VariableStartMarker, "").Replace(sendingInstance.engineSettings.VariableEndMarker, "");
                requiredVariable = sendingInstance.VariableList.Where(var => var.VariableName == reformattedVariable).FirstOrDefault();
            }

            return(requiredVariable);
        }
Beispiel #4
0
        public override void RunCommand(object sender)
        {
            Core.Automation.Engine.AutomationEngineInstance currentScriptEngine = (Core.Automation.Engine.AutomationEngineInstance)sender;
            var startFile = v_taskPath.ConvertToUserVariable(sender);

            //create variable list
            var variableList       = new List <Script.ScriptVariable>();
            var variableReturnList = new List <Script.ScriptVariable>();

            foreach (DataRow rw in v_VariableAssignments.Rows)
            {
                var    variableName = (string)rw.ItemArray[0];
                object variableValue;
                try
                {
                    variableValue = LookupVariable(currentScriptEngine, (string)rw.ItemArray[1]).VariableValue;
                }
                catch (Exception ex)
                {
                    variableValue = ((string)rw.ItemArray[1]).ConvertToUserVariable(sender);
                }
                var variableReturn = (string)rw.ItemArray[2];
                variableList.Add(new Script.ScriptVariable
                {
                    VariableName  = variableName,
                    VariableValue = variableValue
                });
                if (variableReturn == "Yes")
                {
                    variableReturnList.Add(new Script.ScriptVariable
                    {
                        VariableName  = variableName,
                        VariableValue = variableValue
                    });
                }
            }

            UI.Forms.frmScriptEngine newEngine = new UI.Forms.frmScriptEngine(startFile, null, variableList, true);

            //Core.Automation.Engine.AutomationEngineInstance currentScriptEngine = (Core.Automation.Engine.AutomationEngineInstance) sender;
            currentScriptEngine.tasktEngineUI.Invoke((Action) delegate() { currentScriptEngine.tasktEngineUI.TopMost = false; });
            Application.Run(newEngine);

            //get new variable list from the new task engine after it finishes running
            var newVariableList = newEngine.engineInstance.VariableList;

            foreach (var variable in variableReturnList)
            {
                //check if the variables we wish to return are in the new variable list
                if (newVariableList.Exists(x => x.VariableName == variable.VariableName))
                {
                    //if yes, get that variable from the new list
                    Script.ScriptVariable newTemp = newVariableList.Where(x => x.VariableName == variable.VariableName).FirstOrDefault();
                    //check if that variable previously existed in the current engine
                    if (currentScriptEngine.VariableList.Exists(x => x.VariableName == newTemp.VariableName))
                    {
                        //if yes, overwrite it
                        Script.ScriptVariable currentTemp = currentScriptEngine.VariableList.Where(x => x.VariableName == newTemp.VariableName).FirstOrDefault();
                        currentScriptEngine.VariableList.Remove(currentTemp);
                    }
                    //Add to current engine variable list
                    currentScriptEngine.VariableList.Add(newTemp);
                }
            }

            //currentScriptEngine.tasktEngineUI.TopMost = false;
            currentScriptEngine.tasktEngineUI.Invoke((Action) delegate() { currentScriptEngine.tasktEngineUI.TopMost = true; });
        }