private void Launchdriver() { IsServerAvailable = GingerCore.Common.Utility.IsServerListening(this.HostName, HostPort); if (!IsServerAvailable) { Reporter.ToStatus(eStatusMsgKey.MainframeIncorrectConfiguration); return; } MFE = new Terminal(this.HostName, HostPort, TermType, SSL, MFRows, MFColumns, this); if (ConnectToMainframe()) { mDriverWindow = new MainFrameDriverWindow(this); mDriverWindow.Show(); mDriverWindow.Refresh(); Dispatcher = new DriverWindowDispatcher(mDriverWindow.Dispatcher); Dispatcher.Invoke(new Action(() => OnDriverMessage(eDriverMessageType.DriverStatusChanged))); System.Windows.Threading.Dispatcher.Run(); } else { mDriverWindow = null; } }
private void Launchdriver() { IsServerAvailable = GingerCore.Common.Utility.IsServerListening(this.HostName, HostPort); if (IsServerAvailable == false) { Reporter.ToGingerHelper(eGingerHelperMsgKey.MainframeIncorrectConfiguration); return; } MFE = new Terminal(this.HostName, HostPort, TermType, SSL, MFRows, MFColumns, this); if (ConnectToMainframe()) { mDriverWindow = new MainFrameDriverWindow(this); mDriverWindow.Show(); mDriverWindow.Refresh(); OnDriverMessage(eDriverMessageType.DriverStatusChanged); Dispatcher = mDriverWindow.Dispatcher; System.Windows.Threading.Dispatcher.Run(); } else { if (mDriverWindow != null) { //not creating window object unless connection established mDriverWindow = null; } } }
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": PerformActMainframeGetDetails(act); break; case "GingerCore.Actions.MainFrame.ActMainframeSendKey": ActMainframeSendKey MFSK = (ActMainframeSendKey)act; MFE.SendKey(MFSK.KeyToSend); break; case "GingerCore.Actions.MainFrame.ActMainframeSetText": PerformActMainframeSetText(act); break; default: throw new NotSupportedException("Action not Implemented"); } mDriverWindow.Refresh(); } catch (Exception e) { act.Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed; act.ExInfo = e.Message; } }
private static void Control_LostFocus(object sender, RoutedEventArgs e) { try { MainFrameDriverWindow MDW = (MainFrameDriverWindow)(Window.GetWindow((Control)sender)); if (MDW == null) { return; } SetTextoMainframe(sender); MDW.Refresh(); } finally { } }
private static void label_loaded(object sender, RoutedEventArgs e) { Label l = (Label)sender; List <object> lo = (List <object>)l.Tag; MainFrameDriver mdv = (MainFrameDriver)lo.ElementAt(0); MainFrameDriverWindow mdw = (MainFrameDriverWindow)lo.ElementAt(1); double d = l.ActualWidth / mdv.MFColumns; mdw.WidthPerCharachter = d; mdw.MinWidth = (mdv.MFColumns + 5) * d; mdw.MinHeight = (mdv.MFRows) * (l.ActualHeight); Console.WriteLine(d.ToString()); mdw.Refresh(); }
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; } }