コード例 #1
0
        private static void TransformationFlowToTxt(XmlNode flow, out int inputIdx, out int outputIdx, out string flowTxt)
        {
            flowTxt = "";

            inputIdx  = int.Parse(flow.SelectSingleNode(".//Int32[@Key='InputIndex']/@Value").Value);
            outputIdx = int.Parse(flow.SelectSingleNode(".//Int32[@Key='OutputIndex']/@Value").Value);

            XmlNodeList transforms = flow.SelectNodes(".//Array[@Key='Transformations']/*");
            int         step       = 0;

            foreach (XmlNode transform in transforms)
            {
                flowTxt += "/* Step " + step.ToString() + " */" + "\r\n";
                XmlNodeList parameters    = transform.SelectNodes(".//List[@Key='Parameters']/*");
                string      transformName = transform.SelectSingleNode(".//*[@Key='Name']/@Value").Value;
                if (parameters.Count > 0)
                {
                    flowTxt += transformName + "(";
                    int p = 0;
                    foreach (XmlNode parameter in parameters)
                    {
                        string pName = parameter.SelectSingleNode(".//*[@Key='Name']/@Value").Value;
                        string ptxt  = TextfieldToTxt.Parse(parameter.SelectSingleNode(".//*[@Key='Value']"));
                        flowTxt += pName + ": " + ptxt + (p < parameters.Count - 1 ? ", " : "");
                        p++;
                    }
                    flowTxt += ")\r\n";
                }
                else
                {
                    flowTxt += transformName + "\r\n";
                }
                step++;
            }
        }
コード例 #2
0
        public static void ErrorToTxt(Step step, int indentLevel, out string ThreadLog, out string ThreadFunctions)
        {
            ThreadLog       = "";
            ThreadFunctions = "";
            string indentString = new string(' ', indentLevel * 4 * 0);

            string name        = TextfieldToTxt.Parse(step.StepXmlNode.SelectSingleNode(".//ErrorInfo/*[@Key='ErrorName']"));
            string description = TextfieldToTxt.Parse(step.StepXmlNode.SelectSingleNode(".//ErrorInfo/*[@Key='ErrorDescription']"));

            XmlNodeList parameters = step.StepXmlNode.SelectNodes(".//List[@Key='ErrorParameters']/*");

            ThreadLog = "(Name: " + name + ", Description: " + description;

            foreach (XmlNode param in parameters)
            {
                string pname  = param.SelectSingleNode(".//*[@Key='Name']/@Value").Value;
                string pvalue = TextfieldToTxt.Parse(param.SelectSingleNode(".//*[@Key='Value']"));
                ThreadLog += ", " + pname + ": " + pvalue;
            }

            string action = step.StepXmlNode.SelectSingleNode(".//Scope/@Value").Value;

            ThreadLog += ", End: " + action;

            ThreadLog += ")";
        }
コード例 #3
0
        public static void LockToTxt(ref Step[,] canvasMatrix, int threadCol, int indentLevel, int lockHeight, int lockWidth, out string ThreadLog, out string ThreadFunctions)
        {
            ThreadLog       = "";
            ThreadFunctions = "";
            string indentString = new string(' ', indentLevel * 4);

            XmlNode expression = canvasMatrix[0, 0].StepXmlNode.SelectSingleNode(".//*[@Key='LockExpression']");
            string  lockString, dummy;

            ConditionXmlToTxt.ParseCondition(expression, out lockString, out dummy, out dummy, out dummy);

            XmlNode timeoutxml = canvasMatrix[0, 0].StepXmlNode.SelectSingleNode(".//*[@Key='TimeoutExpression']");
            string  timeout    = "";

            if (timeoutxml != null && timeoutxml.Name != "Null")
            {
                timeout = TextfieldToTxt.Parse(timeoutxml);
            }

            Step[,] threadSteps = MatrixTransformations.ResizeArray <Step>(ref canvasMatrix, 1, 0, canvasMatrix.GetLength(0) - 1, canvasMatrix.GetLength(1) - 1);
            string log, functions;

            PartialCanvasToTxt.Analyze(ref threadSteps, threadCol, 0, 0, indentLevel + 1, out log, out functions);


            ThreadLog = "lock (" + lockString + ")";
            if (timeout.Length > 0)
            {
                ThreadLog += " // Timeout: " + timeout + " seconds";
            }
            ThreadLog      += "\r\n" + indentString + "{" + "\r\n";
            ThreadLog      += indentString + "    " + log.Trim();
            ThreadLog      += "\r\n" + indentString + "}";
            ThreadFunctions = functions;
        }
コード例 #4
0
        public static void AttributeToTxt(XmlNode step, int indentLevel, out string ThreadLog, out string ThreadFunctions)
        {
            ThreadLog       = "";
            ThreadFunctions = "";

            XmlNodeList attributes = step.SelectNodes(".//RuntimeAttributeRecordCollection//RuntimeAttributeRecord");

            string prototype = "(";

            for (int i = 0; i < attributes.Count; i++)
            {
                string  attname  = attributes[i].SelectSingleNode(".//*[@Key='AttributeName']/@Value").Value;
                XmlNode valuexml = attributes[i].SelectSingleNode(".//*[@Key='Expression']");
                string  input    = "null";
                if (valuexml.Name != "Null")
                {
                    input = TextfieldToTxt.Parse(valuexml);
                }

                prototype += attname + ": " + input;
                if (i < attributes.Count - 1)
                {
                    prototype += ", ";
                }
            }

            prototype += ")";

            ThreadLog = prototype;
        }
コード例 #5
0
        public static void WaitForEventToTxt(Step step, int indentLevel, out string ThreadLog, out string ThreadFunctions)
        {
            ThreadLog       = "";
            ThreadFunctions = "";

            XmlNode varXml = step.StepXmlNode.SelectSingleNode(".//*[@Key='EventExpression']");
            string  value  = TextfieldToTxt.Parse(varXml);

            ThreadLog = "(Event: " + value + ")";
        }
コード例 #6
0
        public static void WriteToTxt(Step step, int indentLevel, out string ThreadLog, out string ThreadFunctions)
        {
            ThreadLog       = "";
            ThreadFunctions = "";

            XmlNode timeoutxml = step.StepXmlNode.SelectSingleNode(".//*[@Key='ExecutionTimeout']");
            string  timeout    = "";

            if (timeoutxml != null && timeoutxml.Name != "Null")
            {
                timeout = TextfieldToTxt.Parse(timeoutxml);
            }

            XmlNodeList inputs  = step.StepXmlNode.SelectNodes(".//List[@Key='StaticInputs' and  @ElementType='InputProperty']/*");
            XmlNodeList outputs = step.StepXmlNode.SelectNodes(".//List[@Key='StaticOutputs' and  @ElementType='OutputProperty']/*");

            ThreadFunctions  = step.StepName.Replace("_x0020_", "_") + "()";
            ThreadFunctions += "\r\n{\r\n" + "/* ------ WriteTool ------ */" + "\r\n" + "\r\n";


            for (int i = 0; i < inputs.Count; i++)
            {
                if (bool.Parse(inputs[i].SelectSingleNode(".//Boolean[@Key='IsEnabled']/@Value").Value))
                {
                    XmlNode inputxml    = inputs[i].SelectSingleNode("./*[@Key='Value']");
                    string  displayName = inputs[i].SelectSingleNode("./*[@Key='DisplayName']/@Value").Value;
                    string  input       = "null";
                    if (inputxml.Name != "Null")
                    {
                        input = TextfieldToTxt.Parse(inputxml);
                    }

                    ThreadFunctions += "/* " + displayName + " */" + "\r\n";
                    ThreadFunctions += input + "\r\n\r\n";
                }
            }
            string terminationString = step.StepXmlNode.SelectSingleNode(".//*[@Key='TerminationString']/*[@Key='Value']/@Value").Value;

            ThreadFunctions += "\r\n" + "/* Termination String: " + ConvertTerminationString(terminationString) + " */\r\n";
            string clearReadBuffer = step.StepXmlNode.SelectSingleNode(".//*[@Key='ClearBuffer']/@Value").Value;

            ThreadFunctions += "\r\n" + "/* Clear Read Buffer On Write: " + clearReadBuffer + " */\r\n";
            ThreadFunctions += "}\r\n";

            ThreadLog += "()"; //prototype
            if (timeout.Length > 0)
            {
                ThreadLog += " // Timeout: " + timeout + " seconds";
            }
        }
コード例 #7
0
        public static void SetEventToTxt(Step step, int indentLevel, out string ThreadLog, out string ThreadFunctions)
        {
            ThreadLog       = "";
            ThreadFunctions = "";

            XmlNode varXml = step.StepXmlNode.SelectSingleNode(".//*[@Key='EventExpression']");
            string  value  = TextfieldToTxt.Parse(varXml);

            bool setValue = bool.Parse(step.StepXmlNode.SelectSingleNode(".//Boolean[@Key='Set']/@Value").Value);

            ThreadLog = "(Event: " + value + ", Turn: " + (setValue? "On":"Off");

            ThreadLog += ")";
        }
コード例 #8
0
        public static void PassFailToTxt(Step step, int indentLevel, out string ThreadLog, out string ThreadFunctions)
        {
            ThreadLog       = "";
            ThreadFunctions = "";

            ThreadFunctions = step.StepName.Replace("_x0020_", "_") + "()";

            string tooltype = step.StepXmlNode.SelectSingleNode(".//*[@Key='NotificationType']/@Value").Value;
            string toolname = "PassFailTool";

            switch (tooltype)
            {
            case "0":
                toolname = "Pass";
                break;

            case "1":
                toolname = "Fail";
                break;

            case "2":
                toolname = "Text To Report";
                break;

            default:
                break;
            }

            ThreadFunctions += "\r\n{\r\n" + "/* ------ " + toolname + " Tool ------ */" + "\r\n" + "\r\n";

            //text
            XmlNode messageXml = step.StepXmlNode.SelectSingleNode(".//*[@Key='DescriptionTextSource']");

            ThreadFunctions += "/* " + "Text" + " */" + "\r\n";
            ThreadFunctions += TextfieldToTxt.Parse(messageXml) + "\r\n";

            //attachment
            if (bool.Parse(step.StepXmlNode.SelectSingleNode(".//FileAttachment[@Key='Attachment']/Boolean[@Key='IsAttached']/@Value").Value))
            {
                XmlNode fileCaption = step.StepXmlNode.SelectSingleNode(".//FileAttachment[@Key='Attachment']/*[@Key='FileCaption']");
                ThreadFunctions += "/* " + "File Caption: " + " */" + "\r\n" + TextfieldToTxt.Parse(fileCaption) + "\r\n";
                XmlNode filePath = step.StepXmlNode.SelectSingleNode(".//FileAttachment[@Key='Attachment']/*[@Key='FilePath']");
                ThreadFunctions += "/* " + "File Path: " + " */" + "\r\n" + TextfieldToTxt.Parse(filePath) + "\r\n";
            }

            ThreadFunctions += "}\r\n";

            ThreadLog += "()"; //prototype
        }
コード例 #9
0
        public static void EndSessionToTxt(Step step, int indentLevel, out string ThreadLog, out string ThreadFunctions)
        {
            ThreadLog       = "";
            ThreadFunctions = "";
            string indentString = new string(' ', indentLevel * 4 * 0);
            string action       = step.StepXmlNode.SelectSingleNode(".//*[@Key='DisconnectAction']/@Value").Value;

            XmlNode varxml  = step.StepXmlNode.SelectSingleNode(".//*[@Key='SessionName']");
            string  varname = TextfieldToTxt.Parse(varxml);

            ThreadLog  = "(SessionName: " + varname;
            ThreadLog += ", Action: " + action;

            ThreadLog += ")";
        }
コード例 #10
0
        public static void DelayToTxt(Step step, int indentLevel, out string ThreadLog, out string ThreadFunctions)
        {
            ThreadLog       = "";
            ThreadFunctions = "";
            string indentString = new string(' ', indentLevel * 4 * 0);
            bool   showProgress = bool.Parse(step.StepXmlNode.SelectSingleNode(".//*[@Key='IsShow']/@Value").Value);

            XmlNode valuexml = step.StepXmlNode.SelectSingleNode(".//*[@Key='Delay']");
            string  value    = TextfieldToTxt.Parse(valuexml);

            ThreadLog = "(Delay: " + value + " seconds";
            if (showProgress)
            {
                ThreadLog += ", ShowProgress: True";
            }

            ThreadLog += ")";
        }
コード例 #11
0
        public static void SetVariableToTxt(Step step, int indentLevel, out string ThreadLog, out string ThreadFunctions)
        {
            ThreadLog       = "";
            ThreadFunctions = "";
            string indentString    = new string(' ', indentLevel * 4 * 0);
            bool   assignFromValue = bool.Parse(step.StepXmlNode.SelectSingleNode(".//Boolean[@Key='AssignFromValue']/@Value").Value);

            XmlNode variablexml = step.StepXmlNode.SelectSingleNode(".//*[@Key='VariableNameTextSource']");

            string varname = TextfieldToTxt.Parse(variablexml);

            if (assignFromValue)
            {
                XmlNode valuexml  = step.StepXmlNode.SelectSingleNode(".//*[@Key='VariableValue']");
                string  datatype  = step.StepXmlNode.SelectSingleNode(".//*[@Key='VariableType']/@Value").Value;
                string  dimension = step.StepXmlNode.SelectSingleNode(".//*[@Key='VariableDimension']/@Value").Value;
                string  value     = TextfieldToTxt.Parse(valuexml);

                if (datatype == "String" && dimension == "Scalar")
                {
                    ThreadLog = indentString + varname + " = \"" + value + "\"";
                }
                else
                {
                    ThreadLog = indentString + varname + " = " + value;
                }
            }
            else
            {
                XmlNode expression = step.StepXmlNode.SelectSingleNode(".//*[@Key='Expression']");
                string  value      = TextfieldToTxt.Parse(expression);
                if (value.Contains("_x000D__x000A_"))
                {
                    ThreadLog       = indentString + varname + " = " + step.StepName.Replace("_x0020_", "_") + "()";
                    ThreadFunctions = step.StepName.Replace("_x0020_", "_") + "()" + "\r\n" + "{\r\n" + value + "\r\n}\r\n";
                }
                else
                {
                    ThreadLog = indentString + varname + " = " + value;
                }
            }
        }
コード例 #12
0
        public static void MessageToTxt(Step step, int indentLevel, out string ThreadLog, out string ThreadFunctions)
        {
            ThreadLog       = "";
            ThreadFunctions = "";

            XmlNode timeoutxml = step.StepXmlNode.SelectSingleNode(".//*[@Key='ExecutionTimeout']");
            string  timeout    = "";

            if (timeoutxml != null && timeoutxml.Name != "Null")
            {
                timeout = TextfieldToTxt.Parse(timeoutxml);
            }

            XmlNodeList inputs = step.StepXmlNode.SelectNodes(".//List[@Key='StaticInputs' and  @ElementType='InputProperty']/*");

            ThreadFunctions  = step.StepName.Replace("_x0020_", "_") + "()";
            ThreadFunctions += "\r\n{\r\n" + "/* ------ MessageTool ------ */" + "\r\n" + "\r\n";

            //message
            XmlNode messageXml = step.StepXmlNode.SelectSingleNode(".//List[@Key='StaticInputs' and  @ElementType='InputProperty']/InputProperty/String[@Key='Name' and @Value='Message']/../*[@Key='Value']");

            ThreadFunctions += "/* " + "Message" + " */" + "\r\n";
            ThreadFunctions += TextfieldToTxt.Parse(messageXml) + "\r\n";

            //timeout
            if (bool.Parse(step.StepXmlNode.SelectSingleNode(".//Boolean[@Key='UseTimeout']/@Value").Value))
            {
                XmlNode timeoutXml = step.StepXmlNode.SelectSingleNode(".//List[@Key='StaticInputs' and  @ElementType='InputProperty']/InputProperty/String[@Key='Name' and @Value='Timeout']/../*[@Key='Value']");
                ThreadFunctions += "/* " + "Duration: " + TextfieldToTxt.Parse(timeoutXml) + " seconds */" + "\r\n";
            }

            ThreadFunctions += "}\r\n";

            ThreadLog += "()"; //prototype
            if (timeout.Length > 0)
            {
                ThreadLog += " // Timeout: " + timeout + " seconds";
            }
        }
コード例 #13
0
        public static void TransformToTxt(Step step, int indentLevel, out string ThreadLog, out string ThreadFunctions)
        {
            ThreadLog       = "";
            ThreadFunctions = "";

            XmlNodeList inputs  = step.StepXmlNode.SelectNodes(".//List[@Key='Inputs' and  @ElementType='InputProperty']/*");
            XmlNodeList outputs = step.StepXmlNode.SelectNodes(".//List[@Key='Outputs' and  @ElementType='OutputProperty']/*");

            string prototype = "(";

            for (int i = 0; i < inputs.Count; i++)
            {
                XmlNode inputxml    = inputs[i].SelectSingleNode("./*[@Key='Value']");
                string  displayName = inputs[i].SelectSingleNode("./*[@Key='DisplayName']/@Value").Value;
                string  input       = "null";
                if (inputxml.Name != "Null")
                {
                    input = TextfieldToTxt.Parse(inputxml);
                }

                prototype += displayName + ": " + input;
                if (i < inputs.Count - 1)
                {
                    prototype += ", ";
                }
            }

            if (outputs.Count > 0)
            {
                prototype += ", ";
            }

            for (int i = 0; i < outputs.Count; i++)
            {
                XmlNode outputxml      = outputs[i].SelectSingleNode("./*[@Key='Value']");
                string  displayName    = outputs[i].SelectSingleNode("./*[@Key='DisplayName']/@Value").Value;
                bool    createVariable = bool.Parse(outputs[i].SelectSingleNode("./*[@Key='CreateVariable']/@Value").Value);
                bool    saveResults    = bool.Parse(outputs[i].SelectSingleNode("./*[@Key='SaveResults']/@Value").Value);

                string output = "";
                if (outputxml.Name != "Null")
                {
                    output = TextfieldToTxt.Parse(outputxml);
                }

                prototype += "out " + displayName;
                if (output.Length > 0)
                {
                    prototype += ": " + output;
                }
                if (createVariable == true)
                {
                    prototype += " /*[Create Variable]*/";
                }
                if (saveResults == true)
                {
                    prototype += " /*[Save Results]*/";
                }

                if (i < outputs.Count - 1)
                {
                    prototype += ", ";
                }
            }
            prototype += ")";
            ThreadLog  = prototype;

            ThreadFunctions  = step.StepName.Replace("_x0020_", "_") + "()" + "\r\n" + "{";
            ThreadFunctions += "\r\n" + "/* ------ Transformation Flows ------ */" + "\r\n";

            XmlNodeList transformFlows = step.StepXmlNode.SelectNodes(".//TransformationFlow");
            int         f = 0;

            foreach (XmlNode flow in transformFlows)
            {
                string flowTxt;
                int    inputIdx, outputIdx;
                TransformationFlowToTxt(flow, out inputIdx, out outputIdx, out flowTxt);
                ThreadFunctions += "/* Flow " + f.ToString() + " (";
                ThreadFunctions += "Input: " + inputs[inputIdx].SelectSingleNode("./*[@Key='DisplayName']/@Value").Value + ", ";
                ThreadFunctions += "Output: " + outputs[outputIdx].SelectSingleNode("./*[@Key='DisplayName']/@Value").Value + ") */" + "\r\n";
                ThreadFunctions += flowTxt;
                ThreadFunctions += "\r\n" + "\r\n";


                f++;
            }

            ThreadFunctions += "\r\n" + "/*------ Transformation Flows End ------ */" + "\r\n" + "}" + "\r\n\r\n";
        }
コード例 #14
0
        public static void CommandToTxt(Step step, int indentLevel, out string ThreadLog, out string ThreadFunctions)
        {
            ThreadLog       = "";
            ThreadFunctions = "";

            XmlNode timeoutxml = step.StepXmlNode.SelectSingleNode(".//*[@Key='ExecutionTimeout']");
            string  timeout    = "";

            if (timeoutxml != null && timeoutxml.Name != "Null")
            {
                timeout = TextfieldToTxt.Parse(timeoutxml);
            }

            XmlNodeList inputs  = step.StepXmlNode.SelectNodes(".//List[@Key='StaticInputs' and  @ElementType='InputProperty']/*");
            XmlNodeList outputs = step.StepXmlNode.SelectNodes(".//List[@Key='StaticOutputs' and  @ElementType='OutputProperty']/*");

            ThreadFunctions  = step.StepName.Replace("_x0020_", "_") + "()";
            ThreadFunctions += "\r\n{\r\n" + "/* ------ TerminalCommandTool ------ */" + "\r\n" + "\r\n";

            for (int i = 0; i < inputs.Count; i++)
            {
                if (inputs[i].SelectSingleNode(".//String[@Key='Name']/@Value").Value == "Command")
                {
                    if (bool.Parse(inputs[i].SelectSingleNode(".//Boolean[@Key='IsEnabled']/@Value").Value))
                    {
                        XmlNode inputxml    = inputs[i].SelectSingleNode("./*[@Key='Value']");
                        string  displayName = inputs[i].SelectSingleNode("./*[@Key='DisplayName']/@Value").Value;
                        string  input       = "null";
                        if (inputxml.Name != "Null")
                        {
                            input = TextfieldToTxt.Parse(inputxml);
                        }

                        ThreadFunctions += "/* " + displayName + " */" + "\r\n";
                        ThreadFunctions += input + "\r\n\r\n";
                    }
                    break;
                }
            }

            XmlNode writeToolInfo     = step.StepXmlNode.SelectSingleNode(".//WriteToolInfo");
            string  terminationString = writeToolInfo.SelectSingleNode(".//*[@Key='TerminationString']/*[@Key='Value']/@Value").Value;

            ThreadFunctions += "/* Termination String: " + ConvertTerminationString(terminationString) + " */\r\n";
            string clearReadBuffer = step.StepXmlNode.SelectSingleNode(".//*[@Key='ClearBuffer']/@Value").Value;

            ThreadFunctions += "\r\n" + "/* Clear Read Buffer On Write: " + clearReadBuffer + " */\r\n";


            XmlNode readToolInfo    = step.StepXmlNode.SelectSingleNode(".//ReadToolInfo");
            string  terminationType = readToolInfo.SelectSingleNode(".//TerminationType[@Key='TerminationType']/@Value").Value;
            XmlNode expression;

            switch (terminationType)
            {
            case "StepDuration":
                expression       = readToolInfo.SelectSingleNode(".//*[@Key='StepDuration']");
                ThreadFunctions += "/* Step Duration: " + TextfieldToTxt.Parse(expression) + " seconds */" + "\r\n";
                break;

            case "FixedLength":
                expression       = readToolInfo.SelectSingleNode(".//*[@Key='FixedLength']");
                ThreadFunctions += "/* Fixed Length: " + TextfieldToTxt.Parse(expression) + " chars */" + "\r\n";
                break;

            case "Text":
                expression       = readToolInfo.SelectSingleNode(".//*[@Key='TerminationString']");
                ThreadFunctions += "/* Termination Text */" + "\r\n" + TextfieldToTxt.Parse(expression) + "\r\n";
                ThreadFunctions += "/* Remove match from output: " + readToolInfo.SelectSingleNode(".//Boolean[@Key='RemoveMatchFromOutput']/@Value").Value + " */" + "\r\n";
                break;

            case "RegularExpression":
                expression       = readToolInfo.SelectSingleNode(".//*[@Key='TerminationString']");
                ThreadFunctions += "/* Termination Regex */" + "\r\n" + TextfieldToTxt.Parse(expression) + "\r\n";
                ThreadFunctions += "/* Remove match from output: " + readToolInfo.SelectSingleNode(".//Boolean[@Key='RemoveMatchFromOutput']/@Value").Value + " */" + "\r\n";
                break;

            case "PatternSet":
                expression       = readToolInfo.SelectSingleNode(".//*[@Key='PatternName']");
                ThreadFunctions += "/* Pattern Name: " + TextfieldToTxt.Parse(expression) + " */" + "\r\n";
                ThreadFunctions += "/* Remove match from output: " + readToolInfo.SelectSingleNode(".//Boolean[@Key='RemoveMatchFromOutput']/@Value").Value + " */" + "\r\n";
                break;

            case "TimeoutAfterLastInput":
                expression       = readToolInfo.SelectSingleNode(".//*[@Key='TimeoutAfterLastInput']");
                ThreadFunctions += "/* Idle Timeout: " + TextfieldToTxt.Parse(expression) + " seconds */" + "\r\n";
                break;
            }


            ThreadFunctions += "}\r\n";


            string prototype = "(";

            for (int i = 0; i < outputs.Count; i++)
            {
                XmlNode outputxml      = outputs[i].SelectSingleNode("./*[@Key='Value']");
                string  displayName    = outputs[i].SelectSingleNode("./*[@Key='DisplayName']/@Value").Value;
                bool    createVariable = bool.Parse(outputs[i].SelectSingleNode("./*[@Key='CreateVariable']/@Value").Value);
                bool    saveResults    = bool.Parse(outputs[i].SelectSingleNode("./*[@Key='SaveResults']/@Value").Value);

                string output = "";
                if (outputxml.Name != "Null")
                {
                    output = TextfieldToTxt.Parse(outputxml);
                }

                prototype += "out " + displayName;
                if (output.Length > 0)
                {
                    prototype += ": " + output;
                }
                if (createVariable == true)
                {
                    prototype += " /*[Create Variable]*/";
                }
                if (saveResults == true)
                {
                    prototype += " /*[Save Results]*/";
                }

                if (i < outputs.Count - 1)
                {
                    prototype += ", ";
                }
            }
            prototype += ")";

            if (timeout.Length > 0)
            {
                prototype += " // Timeout: " + timeout + " seconds";
            }
            ThreadLog = prototype;
        }
コード例 #15
0
        public static void CommandToTxt(Step step, int indentLevel, out string ThreadLog, out string ThreadFunctions)
        {
            ThreadLog       = "";
            ThreadFunctions = "";

            XmlNode timeoutxml = step.StepXmlNode.SelectSingleNode(".//*[@Key=\"ExecutionTimeout\"]");
            string  timeout    = "";

            if (timeoutxml != null && timeoutxml.Name != "Null")
            {
                timeout = TextfieldToTxt.Parse(timeoutxml);
            }

            XmlNodeList inputs  = step.StepXmlNode.SelectNodes(".//List[@Key='StaticInputs' and  @ElementType='InputProperty']/*");
            XmlNodeList outputs = step.StepXmlNode.SelectNodes(".//List[@Key='StaticOutputs' and  @ElementType='OutputProperty']/*");

            ThreadFunctions  = step.StepName.Replace("_x0020_", "_") + "()";
            ThreadFunctions += "\r\n{\r\n" + "/* ------ CommandTool ------ */" + "\r\n" + "\r\n";


            for (int i = 0; i < inputs.Count; i++)
            {
                XmlNode inputxml    = inputs[i].SelectSingleNode("./*[@Key='Value']");
                string  displayName = inputs[i].SelectSingleNode("./*[@Key='DisplayName']/@Value").Value;
                string  input       = "null";
                if (inputxml.Name != "Null")
                {
                    input = TextfieldToTxt.Parse(inputxml);
                }

                ThreadFunctions += "/* " + displayName + " */" + "\r\n";
                ThreadFunctions += input + "\r\n\r\n";
            }
            string killontimeout = step.StepXmlNode.SelectSingleNode(".//*[@Key='KillCommandOnTimeout']/@Value").Value;

            ThreadFunctions += "\r\n" + "/* Kill command on timeout: " + killontimeout + " */\r\n";
            ThreadFunctions += "}\r\n";


            string prototype = "(";

            for (int i = 0; i < outputs.Count; i++)
            {
                XmlNode outputxml      = outputs[i].SelectSingleNode("./*[@Key='Value']");
                string  displayName    = outputs[i].SelectSingleNode("./*[@Key='DisplayName']/@Value").Value;
                bool    createVariable = bool.Parse(outputs[i].SelectSingleNode("./*[@Key='CreateVariable']/@Value").Value);
                bool    saveResults    = bool.Parse(outputs[i].SelectSingleNode("./*[@Key='SaveResults']/@Value").Value);

                string output = "";
                if (outputxml.Name != "Null")
                {
                    output = TextfieldToTxt.Parse(outputxml);
                }

                prototype += "out " + displayName;
                if (output.Length > 0)
                {
                    prototype += ": " + output;
                }
                if (createVariable == true)
                {
                    prototype += " /*[Create Variable]*/";
                }
                if (saveResults == true)
                {
                    prototype += " /*[Save Results]*/";
                }

                if (i < outputs.Count - 1)
                {
                    prototype += ", ";
                }
            }
            prototype += ")";

            if (timeout.Length > 0)
            {
                prototype += " // Timeout: " + timeout + " seconds";
            }
            ThreadLog = prototype;
        }
コード例 #16
0
        public static void TestToTxt(XmlNode step, int indentLevel, out string ThreadLog, out string ThreadFunctions)
        {
            ThreadLog       = "";
            ThreadFunctions = "";

            XmlNode timeoutxml = step.SelectSingleNode(".//*[@Key='ExecutionTimeout']");
            string  timeout    = "";

            if (timeoutxml != null && timeoutxml.Name != "Null")
            {
                timeout = TextfieldToTxt.Parse(timeoutxml);
            }

            XmlNodeList inputs  = step.SelectNodes(".//List[@Key='Inputs' and  @ElementType='InputProperty']/*");
            XmlNodeList outputs = step.SelectNodes(".//List[@Key='Outputs' and  @ElementType='OutputProperty']/*");

            string prototype = "(";

            for (int i = 0; i < inputs.Count; i++)
            {
                XmlNode inputxml    = inputs[i].SelectSingleNode("./*[@Key='Value']");
                string  displayName = inputs[i].SelectSingleNode("./*[@Key='DisplayName']/@Value").Value;
                string  input       = "null";
                if (inputxml.Name != "Null")
                {
                    input = TextfieldToTxt.Parse(inputxml);
                }

                prototype += displayName + ": " + input;
                if (i < inputs.Count - 1)
                {
                    prototype += ", ";
                }
            }

            if (inputs.Count > 0 && outputs.Count > 0)
            {
                prototype += ", ";
            }

            for (int i = 0; i < outputs.Count; i++)
            {
                XmlNode outputxml      = outputs[i].SelectSingleNode("./*[@Key='Value']");
                string  displayName    = outputs[i].SelectSingleNode("./*[@Key='DisplayName']/@Value").Value;
                bool    createVariable = bool.Parse(outputs[i].SelectSingleNode("./*[@Key='CreateVariable']/@Value").Value);
                bool    saveResults    = bool.Parse(outputs[i].SelectSingleNode("./*[@Key='SaveResults']/@Value").Value);

                string output = "";
                if (outputxml.Name != "Null")
                {
                    output = TextfieldToTxt.Parse(outputxml);
                }

                prototype += "out " + displayName;
                if (output.Length > 0)
                {
                    prototype += ": " + output;
                }
                if (createVariable == true)
                {
                    prototype += " /*[Create Variable]*/";
                }
                if (saveResults == true)
                {
                    prototype += " /*[Save Results]*/";
                }

                if (i < outputs.Count - 1)
                {
                    prototype += ", ";
                }
            }
            prototype += ")";

            if (timeout.Length > 0)
            {
                prototype += " // Timeout: " + timeout;
            }
            ThreadLog = prototype;
        }
コード例 #17
0
        public static void CaptureImageToTxt(XmlNode step, int indentLevel, out string ThreadLog, out string ThreadFunctions)
        {
            ThreadLog       = "";
            ThreadFunctions = "";

            XmlNodeList inputs  = step.SelectNodes(".//List[@Key='Inputs' and  @ElementType='InputProperty']/*");
            XmlNodeList outputs = step.SelectNodes(".//List[@Key='Outputs' and  @ElementType='OutputProperty']/*");

            string prototype = "(Capture Image Option: ";

            string optionkey = step.SelectSingleNode(".//*[@Key='OptionKey']").Name;

            switch (optionkey)
            {
            case "CaptureScreenOption":
                prototype += "Capture Screen";
                break;

            case "CaptureFromFileOption":
                prototype += "Capture From File";
                break;

            case "CaptureProcessMainWindowOption":
                prototype += "Capture From Process Name";
                break;

            default:
                prototype += "CaptureImageTool.CaptureImageToTxt - unknown capture option: " + optionkey;
                break;
            }

            prototype += ", ";

            for (int i = 0; i < inputs.Count; i++)
            {
                XmlNode inputxml    = inputs[i].SelectSingleNode("./*[@Key='Value']");
                string  displayName = inputs[i].SelectSingleNode("./*[@Key='DisplayName']/@Value").Value;
                string  input       = "null";
                if (inputxml.Name != "Null")
                {
                    input = TextfieldToTxt.Parse(inputxml);
                }

                prototype += displayName + ": " + input;
                if (i < inputs.Count - 1)
                {
                    prototype += ", ";
                }
            }

            if (inputs.Count > 0 && outputs.Count > 0)
            {
                prototype += ", ";
            }

            for (int i = 0; i < outputs.Count; i++)
            {
                XmlNode outputxml      = outputs[i].SelectSingleNode("./*[@Key='Value']");
                string  displayName    = outputs[i].SelectSingleNode("./*[@Key='DisplayName']/@Value").Value;
                bool    createVariable = bool.Parse(outputs[i].SelectSingleNode("./*[@Key='CreateVariable']/@Value").Value);
                bool    saveResults    = bool.Parse(outputs[i].SelectSingleNode("./*[@Key='SaveResults']/@Value").Value);

                string output = "";
                if (outputxml.Name != "Null")
                {
                    output = TextfieldToTxt.Parse(outputxml);
                }

                prototype += "out " + displayName;
                if (output.Length > 0)
                {
                    prototype += ": " + output;
                }
                if (createVariable == true)
                {
                    prototype += " /*[Create Variable]*/";
                }
                if (saveResults == true)
                {
                    prototype += " /*[Save Results]*/";
                }

                if (i < outputs.Count - 1)
                {
                    prototype += ", ";
                }
            }
            prototype += ")";

            ThreadLog = prototype;
        }
コード例 #18
0
        private static string AnalyzeVariables(XmlNodeList variables)
        {
            string output = "";

            foreach (XmlNode varxml in variables)
            {
                XmlNode dtxml    = varxml.SelectSingleNode(".//*[@Key='Type']");
                string  datatype = "";
                if (dtxml.Name == "DataType")
                {
                    datatype = dtxml.SelectSingleNode("@Value").Value;
                }
                else if (dtxml.Name == "EventDataType")
                {
                    datatype = "Event";
                }

                string name        = varxml.SelectSingleNode(".//String[@Key='Name']/@Value").Value;
                string description = varxml.SelectSingleNode(".//*[@Key='Description']/@Value").Value;
                string dimension   = varxml.Name;
                switch (dimension)
                {
                case "MatrixVariable":
                    dimension = "[,]";
                    break;

                case "VectorVariable":
                    dimension = "[]";
                    break;

                case "SingleVariable":
                case "EventVariable":
                case "SessionVariable":
                case "LockVariable":
                    dimension = "";
                    break;

                default:
                    break;
                }

                string initialValue = "";
                switch (datatype)
                {
                case "String":
                case "Numeric":
                    initialValue = TextfieldToTxt.Parse(varxml.SelectSingleNode(".//*[@Key='InitialValue']"));
                    if (datatype == "String")
                    {
                        datatype = "string";
                    }
                    if (datatype == "Numeric")
                    {
                        datatype = "double";
                    }
                    break;

                case "Event":
                    initialValue = "\"Off\"";
                    break;

                default:
                    initialValue = "";
                    break;
                }

                if (datatype == "string")
                {
                    initialValue = "\"" + initialValue + "\"";
                }

                if (description.Length > 0)
                {
                    output += "/*" + description + "*/" + "\r\n";
                }

                output += datatype + ((dimension.Length > 0) ? (dimension + " "):" ") + name + ((initialValue.Length > 0)?(" = " + initialValue):"") + "\r\n";
            }

            return(output);
        }
コード例 #19
0
        public static void CriteriaToTxt(Step step, int indentLevel, out string ThreadLog, out string ThreadFunctions)
        {
            ThreadLog       = "";
            ThreadFunctions = "";

            XmlNodeList inputs  = step.StepXmlNode.SelectNodes(".//CriteriaLogic/InputProperty");
            XmlNodeList outputs = step.StepXmlNode.SelectNodes("//CriteriaLogic/OutputProperty");

            string prototype = "(";

            for (int i = 0; i < inputs.Count; i++)
            {
                XmlNode inputxml    = inputs[i].SelectSingleNode("./*[@Key='Value']");
                string  displayName = inputs[i].SelectSingleNode("./*[@Key='DisplayName']/@Value").Value;
                string  input       = "null";
                if (inputxml.Name != "Null")
                {
                    input = TextfieldToTxt.Parse(inputxml);
                }

                prototype += displayName + ": " + input;
                if (i < inputs.Count - 1)
                {
                    prototype += ", ";
                }
            }

            if (inputs.Count > 0 && outputs.Count > 0)
            {
                prototype += ", ";
            }
            string[] outputNames = new string[outputs.Count];

            for (int i = 0; i < outputs.Count; i++)
            {
                XmlNode outputxml      = outputs[i].SelectSingleNode("./*[@Key='Value']");
                string  displayName    = outputs[i].SelectSingleNode("./*[@Key='DisplayName']/@Value").Value;
                bool    createVariable = bool.Parse(outputs[i].SelectSingleNode("./*[@Key='CreateVariable']/@Value").Value);
                bool    saveResults    = bool.Parse(outputs[i].SelectSingleNode("./*[@Key='SaveResults']/@Value").Value);

                string output = "";
                if (outputxml.Name != "Null")
                {
                    output = TextfieldToTxt.Parse(outputxml);
                }

                prototype += "out " + displayName;
                if (output.Length > 0)
                {
                    prototype     += ": " + output;
                    outputNames[i] = output;
                }
                else
                {
                    outputNames[i] = "{" + displayName + "}";
                }
                if (createVariable == true)
                {
                    prototype += " /*[Create Variable]*/";
                }
                if (saveResults == true)
                {
                    prototype += " /*[Save Results]*/";
                }

                if (i < outputs.Count - 1)
                {
                    prototype += ", ";
                }
            }
            prototype += ")";

            ThreadLog = prototype;

            ThreadFunctions  = step.StepName.Replace("_x0020_", "_") + "()";
            ThreadFunctions += "\r\n{\r\n" + "/* ------ CriteriaTool ------ */" + "\r\n" + "\r\n";

            XmlNodeList criterias = step.StepXmlNode.SelectNodes(".//CriteriaLogic/*[@Key='Expression']");
            string      assert    = "Assert.IsTrue(";

            for (int i = 0; i < criterias.Count; i++)
            {
                string condition, dummy;
                ConditionXmlToTxt.ParseCondition(criterias[i], out condition, out dummy, out dummy, out dummy);

                ThreadFunctions += outputNames[i] + " = " + condition + "\r\n";
                assert          += outputNames[i];
                if (i < criterias.Count - 1)
                {
                    assert += " && ";
                }
            }
            assert          += ")";
            ThreadFunctions += "\r\n" + assert + "\r\n";


            ThreadFunctions += "\r\n";
            ThreadFunctions += "}\r\n";
        }
コード例 #20
0
        public static void SessionToTxt(Step step, int indentLevel, out string ThreadLog, out string ThreadFunctions)
        {
            ThreadLog       = "";
            ThreadFunctions = "";

            XmlNodeList parameters    = step.StepXmlNode.SelectNodes(".//List[@Key='StartSessionParameters']/*");
            XmlNode     sessionType   = step.StepXmlNode.SelectSingleNode(".//*[@Key='SessionType']/@Value");
            XmlNode     connectAction = step.StepXmlNode.SelectSingleNode(".//*[@Key='ConnectAction']/@Value");
            XmlNode     sessionName   = step.StepXmlNode.SelectSingleNode(".//*[@Key='SessionName']");

            string sessionNameTxt = TextfieldToTxt.Parse(sessionName);
            string prototype      = "(";

            prototype += "SessionName: " + sessionNameTxt + ", " +
                         "SessionType: " + sessionType.Value + ", " +
                         "ConnectAction: " + connectAction.Value;

            if (parameters.Count > 0)
            {
                prototype += ", ";
                foreach (XmlNode param in parameters)
                {
                    string conditionTxt, dummy;
                    ConditionXmlToTxt.ParseCondition(param, out conditionTxt, out dummy, out dummy, out dummy);
                    prototype += conditionTxt;
                }
            }

            XmlNodeList connectionInfoElements = step.StepXmlNode.SelectNodes(".//*[@Key='SessionConnectionInfo']/*");

            foreach (XmlNode element in connectionInfoElements)
            {
                string name = element.Attributes["Key"].Value;
                if (name == "NamedParameters")
                {
                    if (element.ChildNodes.Count > 0)
                    {
                        prototype += ", NamedParameters: [";
                        int e = 0;
                        foreach (XmlNode nparam in element.ChildNodes)
                        {
                            string value = TextfieldToTxt.Parse(nparam);
                            prototype += value;

                            if (e < element.ChildNodes.Count - 1)
                            {
                                prototype += ", ";
                            }

                            e++;
                        }
                        prototype += "]";
                    }
                }
                else
                {
                    string value = TextfieldToTxt.Parse(element);
                    prototype += ", " + name + ": " + value;
                }
            }

            prototype += ")";

            ThreadLog = prototype;
        }