Exemplo n.º 1
0
        public void RefreshConnections()
        {
            if (!isConnected)
            {
                return;
            }
            var msg = new SAPEvent("getconnections");

            msg = SAPhook.Instance.SendMessage(msg, TimeSpan.FromSeconds(PluginConfig.bridge_timeout_seconds));
            if (msg != null)
            {
                isSapRunning = true;
                var sessions = new List <SAPSession>();
                var data     = msg.Get <SAPGetSessions>();
                Connections = data.Connections;
                foreach (var con in Connections)
                {
                    foreach (var ses in con.sessions)
                    {
                        sessions.Add(ses);
                    }
                }
                Sessions = sessions.ToArray();
            }
            else
            {
                isSapRunning = false;
                Sessions     = new SAPSession[] { };
                Connections  = new SAPConnection[] { };
            }
        }
Exemplo n.º 2
0
        private static SAPElement[] GetElementsWithuiSelector(SAPSession session, SAPSelector selector, IElement fromElement, int skip, int maxresults, bool FlatternGuiTree)
        {
            var        result       = new List <SAPElement>();
            SAPElement _fromElement = fromElement as SAPElement;

            var root       = new SAPSelectorItem(selector[0]);
            var sel        = new SAPSelectorItem(selector[1]);
            var SystemName = root.SystemName;
            var id         = sel.id;
            var path       = sel.path;

            var msg = new SAPEvent("getitem");

            msg.Set(new SAPEventElement()
            {
                Id = id, SystemName = SystemName, GetAllProperties = true, Path = path, Skip = skip, MaxItem = maxresults, Flat = FlatternGuiTree
            });
            msg = SAPhook.Instance.SendMessage(msg, TimeSpan.FromSeconds(PluginConfig.bridge_timeout_seconds));
            if (msg != null)
            {
                var ele = msg.Get <SAPEventElement>();
                if (!string.IsNullOrEmpty(ele.Id))
                {
                    var _element = new SAPElement(null, ele);
                    result.Add(_element);
                }
            }
            return(result.ToArray());
        }
Exemplo n.º 3
0
        private static SAPElement[] GetElementsWithuiSelector(SAPSession session, SAPSelector selector, IElement fromElement, int maxresults)
        {
            var        result       = new List <SAPElement>();
            SAPElement _fromElement = fromElement as SAPElement;

            var root       = new SAPSelectorItem(selector[0]);
            var sel        = new SAPSelectorItem(selector[1]);
            var SystemName = root.SystemName;
            var id         = sel.id;

            var msg = new SAPEvent("getitem");

            msg.Set(new SAPEventElement()
            {
                Id = id, SystemName = SystemName
            });
            msg = SAPhook.Instance.SendMessage(msg, TimeSpan.FromSeconds(5));
            if (msg != null)
            {
                var ele    = msg.Get <SAPEventElement>();
                var Parent = new SAPElement(null, ele);
                result.Add(Parent);
            }
            return(result.ToArray());
        }
Exemplo n.º 4
0
        protected override void Execute(CodeActivityContext context)
        {
            string host       = Host.Get(context);
            string username   = Username.Get(context);
            string password   = Password.Get(context);
            string client     = Client.Get(context);
            string language   = Language.Get(context);
            string systemname = SystemName.Get(context);

            SAPhook.Instance.RefreshConnections();
            bool       dologin  = true;
            SAPSession _session = null;

            if (SAPhook.Instance.Sessions != null)
            {
                foreach (var session in SAPhook.Instance.Sessions)
                {
                    if (session.Info.SystemName.ToLower() == systemname.ToLower())
                    {
                        _session = session; dologin = false; break;
                    }
                }
            }
            if (dologin)
            {
                var data    = new SAPLoginEvent(host, username, password, client, language, systemname);
                var message = new SAPEvent("login");
                message.Set(data);
                _ = SAPhook.Instance.SendMessage(message, TimeSpan.FromMinutes(10));
            }
            if (_session == null)
            {
                SAPhook.Instance.RefreshConnections();
                if (SAPhook.Instance.Sessions != null)
                {
                    foreach (var session in SAPhook.Instance.Sessions)
                    {
                        if (session.Info.SystemName.ToLower() == systemname.ToLower())
                        {
                            _session = session; break;
                        }
                    }
                }
            }
            // SAPhook.Instance.InvokeMethod(systemname, "wnd[0]", "resizeWorkingPane", new object[] { 300,200,false}, TimeSpan.FromSeconds(PluginConfig.bridge_timeout_seconds));
            Interaction.AppActivate(_session.ActiveWindow.Text);

            //SAPhook.Instance.InvokeMethod(systemname, "wnd[0]", "iconify", null, TimeSpan.FromSeconds(PluginConfig.bridge_timeout_seconds));
            //SAPhook.Instance.InvokeMethod(systemname, "wnd[0]", "iconify", null, TimeSpan.FromSeconds(PluginConfig.bridge_timeout_seconds));
            // SAPhook.Instance.InvokeMethod(systemname, "wnd[0]", "maximize", null, TimeSpan.FromSeconds(PluginConfig.bridge_timeout_seconds));
            //session.findById("wnd[0]").iconify
            //session.findById("wnd[0]").maximize
        }