Ejemplo n.º 1
0
        public XMLScreen GetScreenAsXML()
        {
            Refresh();
            XMLScreen XmlS = (XMLScreen)emu.GetScreenAsXML();

            XmlS.Render(emu.Config.ColumnsCount, emu.Config.RowsCount);
            return(XmlS);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Get the current screen as an XMLScreen data structure
 /// </summary>
 /// <returns></returns>
 internal IXMLScreen GetScreenAsXML()
 {
     if (currentConnection == null)
     {
         throw new TNHostException("TNEmulator is not connected", "There is no currently open TN3270 connection", null);
     }
     if (currentConnection.ExecuteAction(false, "DumpXML"))
     {
         //
         return(XMLScreen.LoadFromString(currentConnection.GetAllStringData(false)));
     }
     else
     {
         return(null);
     }
 }
Ejemplo n.º 3
0
        public List <ITreeViewItem> Childrens()
        {
            List <ITreeViewItem> Childrens = new List <ITreeViewItem>();

            MFDriver = (MainFrameDriver)App.AutomateTabGingerRunner.ApplicationAgents[0].Agent.Driver;
            XMLScreen XMLS = MFDriver.GetRenderedScreen();

            foreach (XMLScreenField xf in XMLS.Fields)
            {
                MainframeControlTreeItem MFTI = new MainframeControlTreeItem();
                MFTI.Name = xf.Text;
                MFTI.XSF  = xf;
                MFTI.Path = xf.Location.left + "/" + xf.Location.top;
                Childrens.Add(MFTI);
            }
            return(Childrens);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Get the current screen as an XMLScreen data structure
        /// </summary>
        /// <returns></returns>
        internal IXMLScreen GetScreenAsXML()
        {
            DisposeOfCurrentScreenObject();

            if (currentConnection == null)
            {
                throw new TNHostException("Terminal não está conectado", "Não existe conexão com terminal 3270 aberta", null);
            }
            if (currentConnection.ExecuteAction(false, "DumpXML"))
            {
                //
                return(XMLScreen.LoadFromString(currentConnection.GetAllStringData(false)));
            }
            else
            {
                return(null);
            }
        }
        public List <ITreeViewItem> Childrens()
        {
            List <ITreeViewItem> Childrens = new List <ITreeViewItem>();
            //TODO: improve below to use really automate page used mainfram driver
            Agent agent = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <Agent>().Where(x => x.DriverType == Agent.eDriverType.MainFrame3270 && ((AgentOperations)x.AgentOperations).Status == Agent.eStatus.Running).FirstOrDefault();

            if (agent != null)
            {
                MFDriver = (MainFrameDriver)((AgentOperations)agent.AgentOperations).Driver;
                XMLScreen XMLS = MFDriver.GetRenderedScreen();
                foreach (XMLScreenField xf in XMLS.Fields)
                {
                    MainframeControlTreeItem MFTI = new MainframeControlTreeItem();
                    MFTI.Name = xf.Text;
                    MFTI.XSF  = xf;
                    MFTI.Path = xf.Location.left + "/" + xf.Location.top;
                    Childrens.Add(MFTI);
                }
            }
            return(Childrens);
        }
Ejemplo n.º 6
0
        public void Refresh()
        {
            try
            {
                XMLScreen XMLS = mDriver.MFE.GetScreenAsXML();

                MainFrameUIHelper.RefreshCamvasComponents(mDriver, this, ConsoleCanvas, XMLS, null);
            }
            catch (Exception mfe)
            {
                XMLScreen      XMLS = new XMLScreen();
                XMLScreenField XF   = new XMLScreenField();
                XF.Text                 = "Mainframe not Connected " + mfe.Message;
                XF.Attributes           = new XMLScreenAttributes();
                XF.Attributes.Protected = true;
                XF.Location             = new XMLScreenLocation();
                XF.Location.position    = 0;
                XF.Location.top         = 0;
                XF.Location.left        = 0;
                XF.Location.length      = XF.Text.Length;

                MainFrameUIHelper.RefreshCamvasComponents(mDriver, this, ConsoleCanvas, XMLS, XF);
            }
        }
Ejemplo n.º 7
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");
            }
        }
Ejemplo n.º 8
0
        public static void RefreshCamvasComponents(MainFrameDriver MF, MainFrameDriverWindow MFDW, Canvas ConsoleCanvas, XMLScreen ScreenElements, XMLScreenField MXF = null)
        {
            DefaultBursh = Brushes.Cyan;
            ConsoleCanvas.Children.Clear();
            if (MFDW.HeightPerRow == 00 || MFDW.WidthPerCharachter == 00 || Double.IsInfinity(MFDW.WidthPerCharachter) || Double.IsInfinity(MFDW.HeightPerRow) || Double.IsNaN(MFDW.WidthPerCharachter) || Double.IsNaN(MFDW.HeightPerRow))
            {
                SetupMainframeDriverComponents(MF, MFDW, ConsoleCanvas);
            }

            if (MXF != null)
            {
                Control C = GetControlFromScreenField(MXF);

                Brush Brsh = CalculateBrush(MXF);
                ConfigureControl(C, MXF, ConsoleCanvas, MFDW);
                C.Foreground = Brsh;

                SetControlLocation(C, MFDW);
                return;
            }

            if (ScreenElements.Fields == null || ScreenElements == null)
            {
                return;
            }
            foreach (XMLScreenField XF in ScreenElements.Fields)
            {
                Control C = GetControlFromScreenField(XF);
                if (C == null)
                {
                    continue;
                }
                Brush Brsh = CalculateBrush(XF);
                ConfigureControl(C, XF, ConsoleCanvas, MFDW);
                C.Foreground = Brsh;

                SetControlLocation(C, MFDW);
            }
        }
Ejemplo n.º 9
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;
            }
        }