Ejemplo n.º 1
0
        private void Pipeclient_ServerMessage(NamedPipeConnection <SAPEvent, SAPEvent> connection, SAPEvent message)
        {
            try
            {
                if (replyqueue.ContainsKey(message.messageid))
                {
                    if (System.Threading.Monitor.TryEnter(replyqueue, 1000))
                    {
                        try
                        {
                            var e = replyqueue[message.messageid];
                            e.reply = message;
                            if (e.reset != null)
                            {
                                e.reset.Set();
                            }
                            replyqueue.Remove(message.messageid);
                            return;
                        }
                        finally
                        {
                            System.Threading.Monitor.Exit(replyqueue);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
            try
            {
                if (message.action == "recorderevent")
                {
                    var data = message.Get <SAPRecordingEvent>();
                    if (data != null)
                    {
                        Log.Debug(message.action + " " + data.ActionName + " " + data.Id);
                    }
                    else
                    {
                        Log.Debug(message.action);
                    }

                    var r = new RecordEvent();
                    r.SupportInput  = false;
                    r.SupportSelect = false;
                    r.ClickHandled  = true;
                    if (data.Action == "InvokeMethod")
                    {
                        var skipMethods = PluginConfig.recording_skip_methods.ToLower().Split(',');
                        if (skipMethods.Contains(data.ActionName.ToLower()))
                        {
                            return;
                        }
                        var a = new InvokeMethod();
                        a.Path = data.Id; a.ActionName = data.ActionName; a.SystemName = data.SystemName;
                        if (data.Parameters != null)
                        {
                            a.Parameters = data.Parameters;
                            for (var i = 0; i < data.Parameters.Length; i++)
                            {
                                var name = "param" + i.ToString();
                            }
                        }
                        a.loadImageAsync(data.Id, data.SystemName, data.ActionName, data.StatusBarText);
                        r.a = new GetElementResult(a);
                    }
                    if (data.Action == "SetProperty")
                    {
                        var skipMethods = PluginConfig.recording_skip_properties.ToLower().Split(',');
                        if (skipMethods.Contains(data.ActionName.ToLower()))
                        {
                            return;
                        }
                        var a = new SetProperty();
                        a.Path = data.Id; a.ActionName = data.ActionName; a.SystemName = data.SystemName;
                        if (data.Parameters != null)
                        {
                            a.Parameters = data.Parameters;
                            for (var i = 0; i < data.Parameters.Length; i++)
                            {
                                var name = "param" + i.ToString();
                            }
                        }
                        a.loadImageAsync(data.Id, data.SystemName, data.StatusBarText);
                        r.a = new GetElementResult(a);
                    }
                    if (r != null)
                    {
                        Plugin.Instance.RaiseUserAction(r);
                    }
                }
                else if (message.action == "mousedown")
                {
                    LastEventElement = message.Get <SAPEventElement>();
                    LastElement      = new SAPElement(null, LastEventElement);
                    // Log.Output("SAP " + message.action + " " + LastElement.id);
                }
                else if (message.action == "mousemove")
                {
                    LastEventElement = message.Get <SAPEventElement>();
                    LastElement      = new SAPElement(null, LastEventElement);
                    // Log.Output("SAP " + message.action + " " + LastElement.id + " " + LastElement.Path);
                }
                else
                {
                    // Log.Output("SAP " + message.action);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
        }
Ejemplo n.º 2
0
        private void Pipeclient_ServerMessage(NamedPipeConnection <SAPEvent, SAPEvent> connection, SAPEvent message)
        {
            try
            {
                if (replyqueue.ContainsKey(message.messageid))
                {
                    lock (replyqueue)
                    {
                        var e = replyqueue[message.messageid];
                        e.reply = message;
                        if (e.reset != null)
                        {
                            e.reset.Set();
                        }
                        replyqueue.Remove(message.messageid);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
            try
            {
                if (message.action == "recorderevent")
                {
                    var data = message.Get <SAPRecordingEvent>();
                    if (data != null)
                    {
                        Log.Debug(message.action + " " + data.ActionName + " " + data.Id);
                    }
                    else
                    {
                        Log.Debug(message.action);
                    }

                    var r = new RecordEvent();
                    r.SupportInput  = false;
                    r.SupportSelect = false;
                    r.ClickHandled  = true;
                    if (data.Action == "InvokeMethod")
                    {
                        var a = new InvokeMethod();
                        a.Path = data.Id; a.ActionName = data.ActionName; a.SystemName = data.SystemName;
                        if (data.Parameters != null)
                        {
                            a.Parameters = data.Parameters;
                            for (var i = 0; i < data.Parameters.Length; i++)
                            {
                                var name = "param" + i.ToString();
                            }
                        }
                        r.a = new GetElementResult(a);
                    }
                    if (data.Action == "SetProperty")
                    {
                        var a = new SetProperty();
                        a.Path = data.Id; a.ActionName = data.ActionName; a.SystemName = data.SystemName;
                        if (data.Parameters != null)
                        {
                            a.Parameters = data.Parameters;
                            for (var i = 0; i < data.Parameters.Length; i++)
                            {
                                var name = "param" + i.ToString();
                            }
                        }
                        r.a = new GetElementResult(a);
                    }
                    if (r != null)
                    {
                        Plugin.Instance.RaiseUserAction(r);
                    }
                }
                else if (message.action == "mousedown")
                {
                    LastEventElement = message.Get <SAPEventElement>();
                    LastElement      = new SAPElement(null, LastEventElement);
                    Log.Output("SAP " + message.action + " " + LastElement.id);
                }
                else if (message.action == "mousemove")
                {
                    LastEventElement = message.Get <SAPEventElement>();
                    LastElement      = new SAPElement(null, LastEventElement);
                    Log.Output("SAP " + message.action + " " + LastElement.id);
                }
                else
                {
                    Log.Output("SAP " + message.action);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
        }