Esempio n. 1
0
        static public XMLScreen LoadFromString(string text)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(XMLScreen));
            //
            StringReader fs    = null;
            XMLScreen    rules = null;

            try
            {
                fs = new StringReader(text);
                //XmlTextReader reader = new XmlTextReader(fs);

                rules          = (XMLScreen)serializer.Deserialize(fs);        //reader);
                rules.FileName = null;
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception " + e.Message + " reading document. saved as c:\\dump.xml");
                StreamWriter sw = File.CreateText("c:\\dump.xml");
                sw.WriteLine(text);
                sw.Close();
                throw;
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }
            rules.Render();
            rules._stringValueCache = text;
            return(rules);
        }
Esempio n. 2
0
        static public XMLScreen load(string filename)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(XMLScreen));
            //
            FileStream fs    = null;
            XMLScreen  rules = null;

            try
            {
                fs = new FileStream(filename, FileMode.Open);
                //XmlTextReader reader = new XmlTextReader(fs);

                rules          = (XMLScreen)serializer.Deserialize(fs);
                rules.FileName = filename;
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }
            rules.Render();
            return(rules);
        }
Esempio n. 3
0
        static public XMLScreen load(Stream sr)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(XMLScreen));
            //
            XMLScreen rules = null;

            object temp = serializer.Deserialize(sr);

            rules = (XMLScreen)temp;

            if (rules != null)
            {
                rules.FileName = null;

                rules.Render();
            }
            return(rules);
        }
Esempio n. 4
0
        private void PerformActMainframeGetDetails(Act act)
        {
            ActMainframeGetDetails MFGD = (ActMainframeGetDetails)act;

            //todo Implement get Type and others


            switch (MFGD.DetailsToFetch)
            {
            case ActMainframeGetDetails.eDetailsToFetch.GetText:

                ActMainFrameGetText(act);

                break;

            case ActMainframeGetDetails.eDetailsToFetch.GetDetailsFromText:

                MainframeGetDetailsFromText(act);
                break;

            case ActMainframeGetDetails.eDetailsToFetch.GetAllEditableFeilds:

                XmlDocument    XD  = new XmlDocument();
                XmlDeclaration dec = XD.CreateXmlDeclaration("1.0", null, null);
                XD.AppendChild(dec);
                XmlElement root = XD.CreateElement("EditableFields");
                XD.AppendChild(root);

                string CaretValuePair = @"<?xml version='1.0' encoding='UTF-8'?><nodes>";

                XMLScreen XC = MFE.GetScreenAsXML();
                foreach (XMLScreenField XSF in XC.Fields)
                {
                    if (XSF.Attributes.Protected)
                    {
                        continue;
                    }
                    string node = "<node caret=\"" + XSF.Location.position.ToString() + "\" text=\"" + XSF.Text + "\"> </node>";

                    CaretValuePair = CaretValuePair + node;

                    XmlElement EditableField = XD.CreateElement("EditableField");
                    EditableField.SetAttribute("Caret", XSF.Location.position.ToString());
                    EditableField.SetAttribute("Text", XSF.Text);
                    root.AppendChild(EditableField);
                }

                act.AddOrUpdateReturnParamActual("Fields", XD.OuterXml);

                break;

            case ActMainframeGetDetails.eDetailsToFetch.GetCurrentScreenAsXML:

                Open3270.TN3270.XMLScreen XMLS = MFE.GetScreenAsXML();
                System.Xml.Serialization.XmlSerializer xsSubmit = new System.Xml.Serialization.XmlSerializer(typeof(Open3270.TN3270.XMLScreen));
                System.IO.StringWriter sww    = new System.IO.StringWriter();
                System.Xml.XmlWriter   writer = System.Xml.XmlWriter.Create(sww);

                xsSubmit.Serialize(writer, XMLS);
                String ScreenXML = sww.ToString();     // Your XML

                act.AddOrUpdateReturnParamActual("ScreenXML", ScreenXML);

                break;

            default:
                throw new NotSupportedException("The action is not supporte yet");
            }
        }
Esempio n. 5
0
        public override void RunAction(Act act)
        {
            if (act.GetType().ToString() == "GingerCore.Actions.ActScreenShot")
            {
                TakeScreenShot(act);
                return;
            }

            try
            {
                switch (act.GetType().ToString())
                {
                case "GingerCore.Actions.MainFrame.ActMainframeGetDetails":

                    ActMainframeGetDetails MFGD = (ActMainframeGetDetails)act;
                    //todo Implement get Type and others

                    int locx = -1;
                    int locy = -1;
                    switch (MFGD.DetailsToFetch)
                    {
                    case ActMainframeGetDetails.eDetailsToFetch.GetText:

                        if (MFGD.LocateBy == eLocateBy.ByCaretPosition)
                        {
                            if (String.IsNullOrEmpty(act.ValueForDriver))
                            {
                                string MFText = MFE.GetTextatPosition(Int32.Parse(MFGD.LocateValueCalculated), 50);
                                MFText = MFText.Split().ElementAt(0).ToString();
                                MFGD.AddOrUpdateReturnParamActual("Value", MFText);
                            }
                            else
                            {
                                act.AddOrUpdateReturnParamActual("Value", MFE.GetTextatPosition(Int32.Parse(act.LocateValueCalculated), Int32.Parse(act.ValueForDriver)));
                            }
                        }
                        else if (MFGD.LocateBy == eLocateBy.ByXY)
                        {
                            string XY = MFGD.LocateValueCalculated;

                            String[] XYSeparated = XY.Split(',');

                            int x = Int32.Parse(XYSeparated.ElementAt(0));
                            int y = Int32.Parse(XYSeparated.ElementAt(1));
                            if (x >= Coloumn || y >= Rows)
                            {
                                throw new Exception("X,Y out of bounds please use X/Y less than Rows/Columns configured in agent");
                            }
                            if (String.IsNullOrEmpty(act.ValueForDriver))
                            {
                                string MFText = MFE.GetTextatPosition(x, y, 50);
                                MFText = MFText.Split().ElementAt(0).ToString();
                                MFGD.AddOrUpdateReturnParamActual("Value", MFText);
                            }
                            else
                            {
                                act.AddOrUpdateReturnParamActual("Value", MFE.GetTextatPosition(x, y, Int32.Parse(act.ValueForDriver)));
                            }
                        }
                        break;

                    case ActMainframeGetDetails.eDetailsToFetch.GetDetailsFromText:

                        String[] MainFrameLines = MFE.screenText.Split('\n');
                        int      instance       = 1;
                        for (int i = 0; i < MainFrameLines.Length; i++)
                        {
                            locx = MainFrameLines[i].IndexOf(MFGD.ValueForDriver);
                            if (locx >= 0)
                            {
                                locy = i;
                                if (MFGD.TextInstanceType == ActMainframeGetDetails.eTextInstance.AllInstance)
                                {
                                    if (locy != -1)
                                    {
                                        act.AddOrUpdateReturnParamActualWithPath("CaretPosition", (locy * (MFColumns + 1) + locx).ToString(), instance.ToString());
                                        act.AddOrUpdateReturnParamActualWithPath("X", locx.ToString(), instance.ToString());
                                        act.AddOrUpdateReturnParamActualWithPath("Y", locy.ToString(), instance.ToString());
                                    }
                                }
                                else if (MFGD.TextInstanceType == ActMainframeGetDetails.eTextInstance.InstanceN)
                                {
                                    int k = Int32.Parse(MFGD.TextInstanceNumber);
                                    if (locy != -1 && instance == k)
                                    {
                                        act.AddOrUpdateReturnParamActual("CaretPosition", (locy * (MFColumns + 1) + locx).ToString());
                                        act.AddOrUpdateReturnParamActual("X", locx.ToString());
                                        act.AddOrUpdateReturnParamActual("Y", locy.ToString());
                                        break;
                                    }
                                }
                                else if (MFGD.TextInstanceType == ActMainframeGetDetails.eTextInstance.AfterCaretPosition)
                                {
                                    if (Int32.Parse(MFGD.LocateValueCalculated.ToString()) < (locy * (MFColumns + 1) + locx))
                                    {
                                        act.AddOrUpdateReturnParamActual("CaretPosition", (locy * (MFColumns + 1) + locx).ToString());
                                        act.AddOrUpdateReturnParamActual("X", locx.ToString());
                                        act.AddOrUpdateReturnParamActual("Y", locy.ToString());
                                        break;
                                    }
                                }
                                else
                                {
                                    if (locy != -1)
                                    {
                                        act.AddOrUpdateReturnParamActual("CaretPosition", (locy * (MFColumns + 1) + locx).ToString());
                                        act.AddOrUpdateReturnParamActual("X", locx.ToString());
                                        act.AddOrUpdateReturnParamActual("Y", locy.ToString());
                                        break;
                                    }
                                }
                            }
                            if (locy != -1)
                            {
                                instance++;
                            }
                        }

                        break;

                    case ActMainframeGetDetails.eDetailsToFetch.GetAllEditableFeilds:

                        XmlDocument    XD  = new XmlDocument();
                        XmlDeclaration dec = XD.CreateXmlDeclaration("1.0", null, null);
                        XD.AppendChild(dec);
                        XmlElement root = XD.CreateElement("EditableFields");
                        XD.AppendChild(root);

                        string CaretValuePair = @"<?xml version='1.0' encoding='UTF-8'?><nodes>";

                        XMLScreen XC = MFE.GetScreenAsXML();
                        foreach (XMLScreenField XSF in XC.Fields)
                        {
                            if (XSF.Attributes.Protected == true)
                            {
                                continue;
                            }
                            string node = "<node caret=\"" + XSF.Location.position.ToString() + "\" text=\"" + XSF.Text + "\"> </node>";

                            CaretValuePair = CaretValuePair + node;

                            XmlElement EditableField = XD.CreateElement("EditableField");
                            EditableField.SetAttribute("Caret", XSF.Location.position.ToString());
                            EditableField.SetAttribute("Text", XSF.Text);
                            root.AppendChild(EditableField);
                        }

                        act.AddOrUpdateReturnParamActual("Fields", XD.OuterXml);

                        break;

                    case ActMainframeGetDetails.eDetailsToFetch.GetCurrentScreenAsXML:

                        Open3270.TN3270.XMLScreen XMLS = MFE.GetScreenAsXML();
                        System.Xml.Serialization.XmlSerializer xsSubmit = new System.Xml.Serialization.XmlSerializer(typeof(Open3270.TN3270.XMLScreen));
                        System.IO.StringWriter sww    = new System.IO.StringWriter();
                        System.Xml.XmlWriter   writer = System.Xml.XmlWriter.Create(sww);

                        xsSubmit.Serialize(writer, XMLS);
                        String ScreenXML = sww.ToString();         // Your XML

                        act.AddOrUpdateReturnParamActual("ScreenXML", ScreenXML);

                        break;
                    }
                    break;

                case "GingerCore.Actions.MainFrame.ActMainframeSendKey":
                    ActMainframeSendKey MFSK = (ActMainframeSendKey)act;
                    MFE.SendKey(MFSK.KeyToSend);
                    break;

                case "GingerCore.Actions.MainFrame.ActMainframeSetText":
                    ActMainframeSetText MFST = (ActMainframeSetText)act;

                    switch (MFST.SetTextMode)
                    {
                    case ActMainframeSetText.eSetTextMode.SetSingleField:
                        if (MFST.LocateBy == eLocateBy.ByXY)
                        {
                            string XY = MFST.LocateValueCalculated;

                            String[] XYSeparated = XY.Split(',');

                            int x = Int32.Parse(XYSeparated.ElementAt(0));
                            int y = Int32.Parse(XYSeparated.ElementAt(1));
                            if (x >= Coloumn || y >= Rows)
                            {
                                throw new Exception("X,Y out of bounds please use X/Y less than Rows/Columns configured in agent");
                            }
                            MFE.SetCaretIndex(x, y);
                        }
                        else
                        {
                            MFE.SetCaretIndex(Int32.Parse(act.LocateValueCalculated));
                        }

                        MFE.SendText(act.ValueForDriver);

                        break;

                    case ActMainframeSetText.eSetTextMode.SetMultipleFields:

                        if (MFST.ReloadValue)
                        {
                            MFST.LoadCaretValueList();
                        }
                        foreach (ActInputValue AIV in MFST.CaretValueList)
                        {
                            MFE.SetCaretIndex(Int32.Parse(AIV.Param));
                            ValueExpression VE = new ValueExpression(this.Environment, this.BusinessFlow);
                            VE.Value = AIV.Value;
                            MFE.SendText(VE.ValueCalculated);
                        }

                        break;
                    }
                    if (MFST.SendAfterSettingText)
                    {
                        mDriverWindow.Refresh();
                        try
                        {
                            Thread.Sleep(DelayBwSetTextandSend * 1000);
                        }
                        catch
                        {
                            Thread.Sleep(3000);
                        }
                        MFE.SendKey(TnKey.Enter);
                    }
                    break;

                default:
                    throw new Exception("Action not Implemented");
                }

                mDriverWindow.Refresh();
            }
            catch (Exception e)
            {
                act.Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed;
                act.ExInfo = e.Message;
            }
        }