예제 #1
0
 public ActMainFrameSetTextEditPage(ActMainframeSetText Act)
 {
     mAct = Act;
     InitializeComponent();
     App.ObjFieldBinding(SendAfterSettingText, CheckBox.IsCheckedProperty, mAct, "SendAfterSettingText");
     App.FillComboFromEnumVal(SetTextModeCombo, mAct.SetTextMode);
     App.ObjFieldBinding(SetTextModeCombo, ComboBox.SelectedValueProperty, mAct, "SetTextMode");
     App.ObjFieldBinding(ReloadValue, CheckBox.IsCheckedProperty, mAct, "ReloadValue");
     SetCaretValueGrid();
     CaretValueGrid.btnAdd.AddHandler(Button.ClickEvent, new RoutedEventHandler(AddCaretValueItem));
 }
예제 #2
0
        private void PerformActMainframeSetText(Act act)
        {
            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 ArgumentOutOfRangeException("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;

            default:
                throw new NotSupportedException("This action is not implemented yet");
            }
            if (MFST.SendAfterSettingText)
            {
                mDriverWindow.Refresh();
                try
                {
                    Thread.Sleep(DelayBwSetTextandSend * 1000);
                }
                catch
                {
                    Thread.Sleep(3000);
                }
                MFE.SendKey(TnKey.Enter);
            }
        }
예제 #3
0
        private static void SetTextoMainframe(object sender)
        {
            MainFrameDriver       mdriver = null;
            XMLScreenField        XF      = null;
            string                Command = null;
            MainFrameDriverWindow MDW     = null;
            bool IsFeildPassword          = false;

            if (sender.GetType() == typeof(TextBox))
            {
                TextBox TB = (TextBox)sender;
                XF  = (XMLScreenField)TB.Tag;
                MDW = (MainFrameDriverWindow)Window.GetWindow(TB);
                if (MDW == null)
                {
                    return;
                }
                mdriver = MDW.mDriver;
                Command = TB.Text;
            }
            else if (sender.GetType() == typeof(PasswordBox))
            {
                IsFeildPassword = true;
                PasswordBox PWB = (PasswordBox)sender;
                XF      = (XMLScreenField)PWB.Tag;
                MDW     = (MainFrameDriverWindow)Window.GetWindow(PWB);
                mdriver = MDW.mDriver;
                Command = PWB.Password;
            }
            else
            {
                return;
            }

            if (XF == null || String.IsNullOrEmpty(Command) || mdriver == null)
            {
            }
            else
            {
                mdriver.SetTextAtPosition(Command, XF.Location.left, XF.Location.top, false);
                if (MDW.RecordBtn.IsChecked == true)
                {
                    try
                    {
                        ActMainframeSetText AMFST = new ActMainframeSetText();

                        AMFST.LocateBy    = eLocateBy.ByCaretPosition;
                        AMFST.LocateValue = XF.Location.position.ToString();
                        AMFST.Value       = Command;
                        if (mdriver.mBusinessFlow == null)
                        {
                            return;
                        }
                        if (IsFeildPassword)
                        {
                            AMFST.Description = "Set Password ";
                        }
                        else
                        {
                            AMFST.Description = "Set Text: " + Command;
                        }

                        mdriver.mBusinessFlow.CurrentActivity.Acts.Add((Actions.Act)AMFST);
                    }
                    finally
                    {
                    }
                }
            }
        }
예제 #4
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;
            }
        }