public WindowsClickDetectorView(IDetectorPlugin plugin)
 {
     InitializeComponent();
     this.plugin           = plugin;
     HighlightImage.Source = Extensions.GetImageSourceFromResource("search.png");
     DataContext           = this;
 }
Пример #2
0
 public static IDetectorPlugin UpdateDetector(IOpenRPAClient client, entity.Detector entity)
 {
     foreach (var d in detectorPluginTypes)
     {
         if (d.Key == entity.Plugin)
         {
             IDetectorPlugin plugin = Plugins.detectorPlugins.Where(x => x.Entity._id == entity._id).FirstOrDefault();
             if (plugin == null)
             {
                 return(AddDetector(client, entity));
             }
             try
             {
                 plugin.Stop();
                 plugin.Entity = entity;
                 if (string.IsNullOrEmpty(entity.name))
                 {
                     entity.name = plugin.Name;
                 }
                 plugin.Start();
                 return(plugin);
             }
             catch (Exception ex)
             {
                 Log.Error("OpenRPA.Interfaces.Plugins.AddDetector: " + ex.ToString());
             }
         }
     }
     return(null);
 }
Пример #3
0
 public static IDetectorPlugin AddDetector(entity.Detector entity)
 {
     foreach (var d in detectorPluginTypes)
     {
         if (d.Key == entity.Plugin)
         {
             try
             {
                 IDetectorPlugin plugin = (IDetectorPlugin)Activator.CreateInstance(d.Value);
                 if (string.IsNullOrEmpty(entity.name))
                 {
                     entity.name = plugin.Name;
                 }
                 plugin.Initialize(entity);
                 Plugins.detectorPlugins.Add(plugin);
                 return(plugin);
             }
             catch (Exception ex)
             {
                 Log.Error("OpenRPA.Interfaces.Plugins.AddDetector: " + ex.ToString());
             }
         }
     }
     return(null);
 }
Пример #4
0
 public static IDetectorPlugin AddDetector(IOpenRPAClient client, entity.Detector entity)
 {
     foreach (var d in detectorPluginTypes)
     {
         if (d.Key == entity.Plugin)
         {
             try
             {
                 IDetectorPlugin plugin = (IDetectorPlugin)Activator.CreateInstance(d.Value);
                 if (string.IsNullOrEmpty(entity.name))
                 {
                     entity.name = plugin.Name;
                 }
                 plugin.Initialize(client, entity);
                 IDetectorPlugin exists = Plugins.detectorPlugins.Where(x => x.Entity._id == entity._id).FirstOrDefault();
                 if (exists == null)
                 {
                     Plugins.detectorPlugins.Add(plugin);
                 }
                 return(plugin);
             }
             catch (Exception ex)
             {
                 Log.Error("OpenRPA.Interfaces.Plugins.AddDetector: " + ex.ToString());
             }
         }
     }
     return(null);
 }
Пример #5
0
        public void Start(bool doRegisterExchange)
        {
            IDetectorPlugin dp = Plugins.detectorPlugins.Where(x => x.Entity._id == _id).FirstOrDefault();

            if (dp == null)
            {
                dp = Plugins.AddDetector(RobotInstance.instance, this);
                if (dp == null)
                {
                    Log.Error("Failed loading detector " + name + " " + _id);
                    return;
                }
            }
            if (doRegisterExchange)
            {
                _ = RegisterExchange();
            }
            if (RobotInstance.instance != null && RobotInstance.instance.Window != null)
            {
                dp.OnDetector -= RobotInstance.instance.Window.OnDetector;
                dp.OnDetector += RobotInstance.instance.Window.OnDetector;
            }
            else
            {
                Log.Error("Failed registering detector event sink for " + name + " main window not loaded yet !!!!!");
            }
            dp.Start();
        }
Пример #6
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            Log.FunctionIndent("DetectorsView", "Button_Click");
            try
            {
                var             btn = sender as System.Windows.Controls.Button;
                var             kv  = (System.Collections.Generic.KeyValuePair <string, System.Type>)btn.DataContext;
                var             d   = new Interfaces.entity.Detector(); d.Plugin = kv.Value.FullName;
                IDetectorPlugin dp  = null;
                d.Path = Interfaces.Extensions.ProjectsDirectory;
                NotifyPropertyChanged("detectorPlugins");
                d.name = kv.Value.Name;
                var result = await global.webSocketClient.InsertOne("openrpa", 0, false, d);

                d._id  = result._id;
                d._acl = result._acl;
                IDetectorPlugin exists = Plugins.detectorPlugins.Where(x => x.Entity._id == d._id).FirstOrDefault();
                if (exists == null)
                {
                    dp             = Plugins.AddDetector(RobotInstance.instance, d);
                    dp.OnDetector += main.OnDetector;
                    dp.Entity._id  = result._id;
                    dp.Entity._acl = result._acl;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
            Log.FunctionOutdent("DetectorsView", "Button_Click");
        }
Пример #7
0
 public void OnDetector(IDetectorPlugin plugin, IDetectorEvent detector, EventArgs e)
 {
     try
     {
         Log.Information("Detector " + plugin.Entity.name + " was triggered, with id " + plugin.Entity._id);
         foreach (var wi in WorkflowInstance.Instances.ToList())
         {
             if (wi.isCompleted)
             {
                 continue;
             }
             if (wi.Bookmarks != null)
             {
                 foreach (var b in wi.Bookmarks)
                 {
                     var _id = (plugin.Entity as Interfaces.entity.Detector)._id;
                     Log.Debug(b.Key + " -> " + "detector_" + _id);
                     if (b.Key == "detector_" + _id)
                     {
                         wi.ResumeBookmark(b.Key, detector);
                     }
                 }
             }
         }
         if (!global.isConnected)
         {
             return;
         }
         Interfaces.mq.RobotCommand command = new Interfaces.mq.RobotCommand();
         // detector.user = global.webSocketClient.user;
         var data   = JObject.FromObject(detector);
         var Entity = (plugin.Entity as Interfaces.entity.Detector);
         command.command    = "detector";
         command.detectorid = Entity._id;
         if (string.IsNullOrEmpty(Entity._id))
         {
             return;
         }
         command.data = data;
         Task.Run(async() =>
         {
             try
             {
                 await global.webSocketClient.QueueMessage(Entity._id, command, null, null, 0);
             }
             catch (Exception ex)
             {
                 Log.Debug(ex.Message);
             }
         });
     }
     catch (Exception ex)
     {
         Log.Error(ex, "");
         MessageBox.Show(ex.Message);
     }
 }
Пример #8
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var             btn = sender as System.Windows.Controls.Button;
            var             kv  = (System.Collections.Generic.KeyValuePair <string, System.Type>)btn.DataContext;
            var             d   = new Interfaces.entity.Detector(); d.Plugin = kv.Value.FullName;
            IDetectorPlugin dp  = null;

            d.Path         = Interfaces.Extensions.ProjectsDirectory;
            dp             = Plugins.AddDetector(RobotInstance.instance, d);
            dp.OnDetector += main.OnDetector;
            NotifyPropertyChanged("detectorPlugins");
        }
Пример #9
0
        async public Task RegisterExchange()
        {
            Log.Debug("Register Exchange for " + name);
            IDetectorPlugin dp = Plugins.detectorPlugins.Where(x => x.Entity._id == _id).FirstOrDefault();

            if (dp == null)
            {
                return;
            }
            if (global.webSocketClient.isConnected && global.openflowconfig != null && !string.IsNullOrEmpty(global.openflowconfig.version))
            {
                var ver    = Version.Parse(global.openflowconfig.version);
                var reqver = Version.Parse("1.3.103"); // exchange support for detectors was not added until 1.3.103
                if (ver < reqver)
                {
                    return;
                }
                if (dp.Entity != null && dp.Entity.detectortype == "exchange" && !string.IsNullOrEmpty(dp.Entity._id))
                {
                    await global.webSocketClient.RegisterExchange(dp.Entity._id, "fanout", false);
                }
            }
        }
Пример #10
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            AutomationHelper.syncContext = System.Threading.SynchronizationContext.Current;
            Task.Run(() =>
            {
                LabelStatusBar.Text = "Loading plugins";
                Plugins.loadPlugins(Extensions.projectsDirectory);
                if (string.IsNullOrEmpty(Config.local.wsurl))
                {
                    var Detectors = Interfaces.entity.Detector.loadDetectors(Extensions.projectsDirectory);
                    foreach (var d in Detectors)
                    {
                        IDetectorPlugin dp = null;
                        d.Path             = Extensions.projectsDirectory;
                        dp = Plugins.AddDetector(d);
                        if (dp != null)
                        {
                            dp.OnDetector += OnDetector;
                        }
                    }
                }

                ExpressionEditor.EditorUtil.init();
                AutomationHelper.init();
                new System.Activities.Core.Presentation.DesignerMetadata().Register();
                if (!string.IsNullOrEmpty(Config.local.wsurl))
                {
                    global.webSocketClient         = new Net.WebSocketClient(Config.local.wsurl);
                    global.webSocketClient.OnOpen += WebSocketClient_OnOpen;
                    _ = global.webSocketClient.Connect();
                }
                else
                {
                    CloseSplash();
                }
            });
        }