Exemplo n.º 1
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);
 }
Exemplo n.º 2
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);
 }
 public void Initialize(IOpenRPAClient client, Detector InEntity)
 {
     this.client = client;
     Entity      = InEntity;
     watcher     = new FileSystemWatcher();
     Start();
 }
Exemplo n.º 4
0
 public void Initialize(IOpenRPAClient client, IDetector InEntity)
 {
     Entity = InEntity;
     recEngine.SetInputToDefaultAudioDevice();
     recEngine.SpeechRecognized += SpeechRecognized;
     Start();
 }
Exemplo n.º 5
0
 public void Initialize(IOpenRPAClient client)
 {
     _ = PluginConfig.allow_child_searching;
     _ = PluginConfig.allow_multiple_hits_mid_selector;
     _ = PluginConfig.enum_selector_properties;
     _ = PluginConfig.get_elements_in_different_thread;
     _ = PluginConfig.traverse_selector_both_ways;
 }
Exemplo n.º 6
0
 public void Initialize(IOpenRPAClient client)
 {
     NMHook.registreChromeNativeMessagingHost(false);
     NMHook.registreffNativeMessagingHost(false);
     NMHook.checkForPipes(true, true);
     NMHook.onMessage      += onMessage;
     NMHook.Connected      += omConnected;
     NMHook.onDisconnected += onDisconnected;
 }
Exemplo n.º 7
0
 public void Initialize(IOpenRPAClient client)
 {
     _           = PluginConfig.collectionname;
     _           = PluginConfig.enabled_keyboard_recording;
     _           = PluginConfig.enabled_mouse_recording;
     this.client = client;
     instance    = this;
     Initialize();
 }
Exemplo n.º 8
0
 public void Initialize(IOpenRPAClient client)
 {
     NMHook.registreChromeNativeMessagingHost(false);
     NMHook.registreffNativeMessagingHost(false);
     NMHook.checkForPipes(true, true);
     NMHook.onMessage      += OnMessage;
     NMHook.Connected      += OnConnected;
     NMHook.onDisconnected += OnDisconnected;
     _ = PluginConfig.wait_for_tab_after_set_value;
 }
Exemplo n.º 9
0
 public void Initialize(IOpenRPAClient client)
 {
     Python.Runtime.PythonEngine.Initialize();
     IntPtr ctx = Python.Runtime.PythonEngine.BeginAllowThreads();
     //if (InvokeCode.pool == null)
     //{
     //    InvokeCode.pool = RunspaceFactory.CreateRunspacePool(1, 5);
     //    InvokeCode.pool.ApartmentState = System.Threading.ApartmentState.MTA;
     //    InvokeCode.pool.Open();
     //}
 }
Exemplo n.º 10
0
 public void Initialize(IOpenRPAClient client)
 {
     NMHook.registreChromeNativeMessagingHost(false);
     NMHook.registreffNativeMessagingHost(false);
     NMHook.checkForPipes(true, true);
     NMHook.onMessage      += OnMessage;
     NMHook.Connected      += OnConnected;
     NMHook.onDisconnected += OnDisconnected;
     _ = PluginConfig.debug_console_output;
     _ = PluginConfig.wait_for_tab_after_set_value;
     _ = PluginConfig.wait_for_tab_click;
     _ = PluginConfig.compensate_for_old_addon;
 }
Exemplo n.º 11
0
 public void Initialize(IOpenRPAClient client)
 {
     Plugin.client = client;
     // _ = PluginConfig.allow_child_searching;
     _ = PluginConfig.allow_attach;
     _ = PluginConfig.cache_timeout;
     _ = PluginConfig.enable_cache;
     _ = PluginConfig.allow_multiple_hits_mid_selector;
     _ = PluginConfig.enum_selector_properties;
     _ = PluginConfig.get_elements_in_different_thread;
     _ = PluginConfig.search_timeout;
     _ = PluginConfig.traverse_selector_both_ways;
 }
Exemplo n.º 12
0
 public void Initialize(IOpenRPAClient client)
 {
     _ = PluginConfig.csharp_intellisense;
     _ = PluginConfig.vb_intellisense;
     Python.Runtime.PythonEngine.Initialize();
     _ = Python.Runtime.PythonEngine.BeginAllowThreads();
     //if (InvokeCode.pool == null)
     //{
     //    InvokeCode.pool = RunspaceFactory.CreateRunspacePool(1, 5);
     //    InvokeCode.pool.ApartmentState = System.Threading.ApartmentState.MTA;
     //    InvokeCode.pool.Open();
     //}
 }
Exemplo n.º 13
0
 public void Initialize(IOpenRPAClient client, IWorkflow workflow, IWorkflowInstance instance)
 {
     automation = AutomationUtil.getAutomation();
     //cache = new CacheRequest();
     //cache.TreeScope = FlaUI.Core.Definitions.TreeScope.Element | FlaUI.Core.Definitions.TreeScope.Subtree | FlaUI.Core.Definitions.TreeScope.Parent;
     ////cacheRequest.TreeScope = FlaUI.Core.Definitions.TreeScope.Element;
     //cache.AutomationElementMode = FlaUI.Core.Definitions.AutomationElementMode.None;
     //cache.Add(automation.PropertyLibrary.Element.AutomationId);
     //cache.Add(automation.PropertyLibrary.Element.ProcessId);
     //cache.Add(automation.PropertyLibrary.Element.Name);
     //cache.Add(automation.PropertyLibrary.Element.ClassName);
     //cache.Add(automation.PropertyLibrary.Element.ControlType);
     //cache.Add(automation.PropertyLibrary.Element.LocalizedControlType);
     //cache.Add(automation.PropertyLibrary.Element.FrameworkId);
     //cache.Add(automation.PropertyLibrary.Element.BoundingRectangle);
     //cache.Add(automation.PropertyLibrary.Element.IsPassword);
     //// cache.Add(automation.PropertyLibrary.Element.Parent);
     //cacheObject = cache.Activate();
 }
Exemplo n.º 14
0
        public void Initialize(IOpenRPAClient client)
        {
            Plugin.client = client;
            _             = PluginConfig.csharp_intellisense;
            _             = PluginConfig.vb_intellisense;
            _             = PluginConfig.use_embedded_python;
            _             = PluginConfig.py_create_no_window;

            //System.Diagnostics.Debugger.Launch();
            //System.Diagnostics.Debugger.Break();
            if (PluginConfig.use_embedded_python)
            {
                if (!Python.Included.Installer.IsPythonInstalled())
                {
                    Python.Included.Installer.SetupPython(true).Wait();
                }
                else
                {
                    Python.Included.Installer.SetupPython(false).Wait();
                }
                var path = Python.Included.Installer.EmbeddedPythonHome;
                PythonUtil.Setup.SetPythonPath(path);
                // Python.Runtime.PythonEngine.Initialize();
            }
            else
            {
                PythonUtil.Setup.Run();
            }


            // PythonUtil.Setup.Run();
            //Python.Runtime.PythonEngine.Initialize();
            _ = Python.Runtime.PythonEngine.BeginAllowThreads();
            //if (InvokeCode.pool == null)
            //{
            //    InvokeCode.pool = RunspaceFactory.CreateRunspacePool(1, 5);
            //    InvokeCode.pool.ApartmentState = System.Threading.ApartmentState.MTA;
            //    InvokeCode.pool.Open();
            //}
        }
 public void Initialize(IOpenRPAClient client)
 {
 }
Exemplo n.º 16
0
 public void Initialize(IOpenRPAClient client)
 {
     Plugin.client = client;
 }
Exemplo n.º 17
0
 public void Initialize(IOpenRPAClient client)
 {
     this.client           = client;
     this.client.Signedin += Client_Signedin;
 }
Exemplo n.º 18
0
        public static void LoadPlugins(IOpenRPAClient client, string projectsDirectory, bool recursive)
        {
            Log.Debug("LoadPlugins::begin ");
            List <string> dllFileNames = new List <string>();

            if (recursive)
            {
                foreach (var path in System.IO.Directory.GetFiles(projectsDirectory, "*.dll", System.IO.SearchOption.AllDirectories))
                {
                    dllFileNames.Add(path);
                }
            }
            else
            {
                foreach (var path in System.IO.Directory.GetFiles(projectsDirectory, "*.dll"))
                {
                    dllFileNames.Add(path);
                }
            }
            try
            {
                var extensions = System.IO.Path.Combine(Extensions.ProjectsDirectory, "extensions");
                if (System.IO.Directory.Exists(extensions))
                {
                    foreach (var path in System.IO.Directory.GetFiles(extensions, "*.dll"))
                    {
                        dllFileNames.Add(path);
                    }
                }
            }
            catch (Exception)
            {
            }

            // ICollection<Assembly> assemblies = new List<Assembly>();
            foreach (string dllFile in dllFileNames)
            {
                try
                {
                    // if (dllFile.Contains("OpenRPA.Interfaces.")) continue;
                    if (dllFile.Contains("DotNetProjects."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("Emgu."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("Microsoft.CodeAnalysis."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("Microsoft.Office."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("NuGet."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Collections."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.ComponentModel."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Composition."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Data."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Diagnostics."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Globalization."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.IO."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Linq."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Net."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Reflection."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Resources."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Runtime."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Security."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Text."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Threading."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Xml."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Windows."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("ToastNotifications."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("Xceed.Wpf."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("ControlzEx."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("MahApps."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("Snippets."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("Interop.SAPFEWSELib"))
                    {
                        continue;
                    }
                    if (dllFile.Contains("Interop.SapROTWr"))
                    {
                        continue;
                    }
                    if (dllFile.Contains("grpc_csharp_ext"))
                    {
                        continue;
                    }
                    if (dllFile.Contains("chrome_elf."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("d3dcompiler_"))
                    {
                        continue;
                    }
                    if (dllFile.Contains("libcef.dll"))
                    {
                        continue;
                    }
                    if (dllFile.Contains("libEGL.dll"))
                    {
                        continue;
                    }
                    if (dllFile.Contains("libGLESv2.dll"))
                    {
                        continue;
                    }
                    if (dllFile.Contains("WindowsAccessBridge-32.dll"))
                    {
                        continue;
                    }
                    if (dllFile.Contains("WindowsAccessBridge-64.dll"))
                    {
                        continue;
                    }
                    if (dllFile.Contains("WindowsAccessBridge.dll"))
                    {
                        continue;
                    }
                    if (dllFile.Contains("vk_swiftshader.dll"))
                    {
                        continue;
                    }
                    if (dllFile.Contains("vulkan-1.dll"))
                    {
                        continue;
                    }
                    if (dllFile.Contains("cvextern.dll"))
                    {
                        continue;
                    }
                    if (dllFile.Contains("opencv_videoio_ffmpeg455_64.dll"))
                    {
                        continue;
                    }
                    AssemblyName an       = AssemblyName.GetAssemblyName(dllFile);
                    Assembly     assembly = Assembly.Load(an);
                    // assemblies.Add(assembly);
                }
                catch (System.BadImageFormatException)
                {
                    // don't care
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                }
            }
            LoadPlugins(client);
        }
Exemplo n.º 19
0
 public void Initialize(IOpenRPAClient client)
 {
     _           = PluginConfig.auto_close;
     this.client = client;
 }
Exemplo n.º 20
0
        public static void LoadPlugins(IOpenRPAClient client)
        {
            var sw = new System.Diagnostics.Stopwatch();

            sw.Start();

            IEnumerable <System.Reflection.Assembly> assemblies = AppDomain.CurrentDomain.GetAssemblies().OrderBy(a => a.GetName().Name);
            ICollection <Type> alltypes             = new List <Type>();
            ICollection <Type> pluginTypes          = new List <Type>();
            ICollection <Type> snippetTypes         = new List <Type>();
            ICollection <Type> runPluginTypes       = new List <Type>();
            ICollection <Type> IDetectorPluginTypes = new List <Type>();

            Log.Information("LoadPlugins::Get types " + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
            foreach (var a in assemblies)
            {
                try
                {
                    foreach (var s in a.GetTypes())
                    {
                        alltypes.Add(s);
                    }
                }
                catch (Exception) { }
            }

            Log.Information("LoadPlugins::Get all IRecordPlugins " + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
            var IRecordPlugintype = typeof(IRecordPlugin);

            foreach (var p in alltypes)
            {
                try
                {
                    if (IRecordPlugintype.IsAssignableFrom(p) && p.IsInterface == false)
                    {
                        pluginTypes.Add(p);
                    }
                }
                catch (Exception) { }
            }
            Log.Information("LoadPlugins::Get all IDetectorPlugin " + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
            var IDetectorPlugintype = typeof(IDetectorPlugin);

            foreach (var p in alltypes)
            {
                try
                {
                    if (IDetectorPlugintype.IsAssignableFrom(p) && p.IsInterface == false)
                    {
                        IDetectorPluginTypes.Add(p);
                    }
                }
                catch (Exception) { }
            }

            Log.Information("LoadPlugins::Get all ISnippet " + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
            var ISnippettype = typeof(ISnippet);

            foreach (var p in alltypes)
            {
                try
                {
                    if (ISnippettype.IsAssignableFrom(p) && p.IsInterface == false)
                    {
                        snippetTypes.Add(p);
                    }
                }
                catch (Exception) { }
            }

            Log.Information("LoadPlugins::Get all IRunPlugin " + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
            var IRunPlugintype = typeof(IRunPlugin);

            foreach (var p in alltypes)
            {
                try
                {
                    if (IRunPlugintype.IsAssignableFrom(p) && p.IsInterface == false)
                    {
                        runPluginTypes.Add(p);
                    }
                }
                catch (Exception) { }
            }
            Log.Information("LoadPlugins::Get all ICustomWorkflowExtension " + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
            var WorkflowExtensiontype = typeof(ICustomWorkflowExtension);

            foreach (var p in alltypes)
            {
                try
                {
                    if (WorkflowExtensiontype.IsAssignableFrom(p) && p.IsInterface == false)
                    {
                        if (!WorkflowExtensionsTypes.Contains(p))
                        {
                            WorkflowExtensionsTypes.Add(p);
                        }
                    }
                }
                catch (Exception) { }
            }


            foreach (var type in IDetectorPluginTypes)
            {
                if (!detectorPluginTypes.ContainsKey(type.FullName))
                {
                    detectorPluginTypes.Add(type.FullName, type);
                }
            }
            foreach (Type type in pluginTypes)
            {
                try
                {
                    IRecordPlugin plugin = null;
                    foreach (var p in recordPlugins)
                    {
                        if (p.GetType() == type)
                        {
                            plugin = p;
                            break;
                        }
                    }
                    if (plugin == null)
                    {
                        plugin = (IRecordPlugin)Activator.CreateInstance(type);
                        Log.Information("LoadPlugins::Initialize plugin " + plugin.Name + " " + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
                        // SetStatus("Initialize plugin " + plugin.Name);
                        plugin.Initialize(client);
                        GenericTools.RunUI(() => recordPlugins.Add(plugin));
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                }
            }
            foreach (Type type in snippetTypes)
            {
                try
                {
                    ISnippet plugin = null;
                    foreach (var p in Snippets)
                    {
                        if (p.GetType() == type)
                        {
                            plugin = p;
                            break;
                        }
                    }
                    if (plugin == null)
                    {
                        plugin = (ISnippet)Activator.CreateInstance(type);
                        Log.Information("LoadPlugins::Initialize snippet " + plugin.Name + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
                        Snippets.Add(plugin);
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                }
            }
            foreach (Type type in runPluginTypes)
            {
                try
                {
                    IRunPlugin plugin = null;
                    foreach (var p in runPlugins)
                    {
                        if (p.GetType() == type)
                        {
                            plugin = p;
                            break;
                        }
                    }

                    if (plugin == null)
                    {
                        plugin = (IRunPlugin)Activator.CreateInstance(type);
                        Log.Information("LoadPlugins::Initialize RunPlugin " + plugin.Name + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
                        plugin.Initialize(client);
                        GenericTools.RunUI(() => runPlugins.Add(plugin));
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                }
            }
            Log.Information("LoadPlugins::end " + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
        }
Exemplo n.º 21
0
 public void Initialize(IOpenRPAClient client)
 {
     _ = PluginConfig.get_emails_max_folders;
     _ = PluginConfig.get_emails_skip_public;
 }
Exemplo n.º 22
0
        public static void LoadPlugins(IOpenRPAClient client, string projectsDirectory, bool recursive)
        {
            Log.Information("LoadPlugins::begin ");
            List <string> dllFileNames = new List <string>();

            if (recursive)
            {
                foreach (var path in System.IO.Directory.GetFiles(projectsDirectory, "*.dll", System.IO.SearchOption.AllDirectories))
                {
                    dllFileNames.Add(path);
                }
            }
            else
            {
                foreach (var path in System.IO.Directory.GetFiles(projectsDirectory, "*.dll"))
                {
                    dllFileNames.Add(path);
                }
            }

            // ICollection<Assembly> assemblies = new List<Assembly>();
            foreach (string dllFile in dllFileNames)
            {
                try
                {
                    // if (dllFile.Contains("OpenRPA.Interfaces.")) continue;
                    if (dllFile.Contains("DotNetProjects."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("Emgu."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("Microsoft.CodeAnalysis."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("Microsoft.Office."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("NuGet."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Collections."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.ComponentModel."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Composition."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Data."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Diagnostics."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Globalization."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.IO."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Linq."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Net."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Reflection."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Resources."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Runtime."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Security."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Text."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Threading."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Xml."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Windows."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("ToastNotifications."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("Xceed.Wpf."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("ControlzEx."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("MahApps."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("Snippets."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("Interop.SAPFEWSELib"))
                    {
                        continue;
                    }
                    if (dllFile.Contains("Interop.SapROTWr"))
                    {
                        continue;
                    }
                    if (dllFile.Contains("grpc_csharp_ext"))
                    {
                        continue;
                    }
                    AssemblyName an       = AssemblyName.GetAssemblyName(dllFile);
                    Assembly     assembly = Assembly.Load(an);
                    // assemblies.Add(assembly);
                }
                catch (System.BadImageFormatException)
                {
                    // don't care
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "");
                }
            }
            LoadPlugins(client);
        }
Exemplo n.º 23
0
        public async static Task LoadPlugins(IOpenRPAClient client, string projectsDirectory)
        {
            ICollection <Type> pluginTypes    = new List <Type>();
            ICollection <Type> snippetTypes   = new List <Type>();
            ICollection <Type> runPluginTypes = new List <Type>();
            await Task.Run(() =>
            {
                List <string> dllFileNames = new List <string>();
                foreach (var path in System.IO.Directory.GetFiles(projectsDirectory, "*.dll"))
                {
                    dllFileNames.Add(path);
                }
                ICollection <Assembly> assemblies = new List <Assembly>();
                foreach (string dllFile in dllFileNames)
                {
                    try
                    {
                        AssemblyName an   = AssemblyName.GetAssemblyName(dllFile);
                        Assembly assembly = Assembly.Load(an);
                        assemblies.Add(assembly);
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "");
                    }
                }
                foreach (Assembly assembly in assemblies)
                {
                    if (assembly != null && !assembly.CodeBase.Contains("Microsoft.CodeAnalysis"))
                    {
                        try
                        {
                            Type[] types = assembly.GetTypes();
                            foreach (Type type in types)
                            {
                                if (type.IsInterface || type.IsAbstract)
                                {
                                    continue;
                                }
                                else
                                {
                                    if (type.GetInterface(typeof(IRecordPlugin).FullName) != null)
                                    {
                                        pluginTypes.Add(type);
                                    }
                                    if (type.GetInterface(typeof(IDetectorPlugin).FullName) != null)
                                    {
                                        Plugins.detectorPluginTypes.Add(type.FullName, type);
                                    }
                                    if (type.GetInterface(typeof(ISnippet).FullName) != null)
                                    {
                                        snippetTypes.Add(type);
                                    }
                                    if (type.GetInterface(typeof(IRunPlugin).FullName) != null)
                                    {
                                        runPluginTypes.Add(type);
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error(ex, "loadPlugins");
                        }
                    }
                }
            });

            foreach (Type type in pluginTypes)
            {
                try
                {
                    IRecordPlugin plugin = (IRecordPlugin)Activator.CreateInstance(type);
                    Log.Information("Initialize plugin " + plugin.Name);
                    // SetStatus("Initialize plugin " + plugin.Name);
                    plugin.Initialize(client);
                    recordPlugins.Add(plugin);
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                }
            }
            foreach (Type type in snippetTypes)
            {
                try
                {
                    ISnippet plugin = (ISnippet)Activator.CreateInstance(type);
                    Log.Information("Initialize snippet " + plugin.Name);
                    Snippets.Add(plugin);
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                }
            }
            foreach (Type type in runPluginTypes)
            {
                try
                {
                    IRunPlugin plugin = (IRunPlugin)Activator.CreateInstance(type);
                    Log.Information("Initialize RunPlugin " + plugin.Name);
                    plugin.Initialize(client);
                    runPlugins.Add(plugin);
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                }
            }
        }
Exemplo n.º 24
0
 public void Initialize(IOpenRPAClient client)
 {
     this.client = client;
 }
Exemplo n.º 25
0
        public static void LoadPlugins(IOpenRPAClient client, string projectsDirectory)
        {
            var sw = new System.Diagnostics.Stopwatch();

            sw.Start();
            Log.Information("LoadPlugins::begin " + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
            ICollection <Type> alltypes             = new List <Type>();
            ICollection <Type> pluginTypes          = new List <Type>();
            ICollection <Type> snippetTypes         = new List <Type>();
            ICollection <Type> runPluginTypes       = new List <Type>();
            ICollection <Type> IDetectorPluginTypes = new List <Type>();

            List <string> dllFileNames = new List <string>();

            foreach (var path in System.IO.Directory.GetFiles(projectsDirectory, "*.dll"))
            {
                dllFileNames.Add(path);
            }
            ICollection <Assembly> assemblies = new List <Assembly>();

            foreach (string dllFile in dllFileNames)
            {
                try
                {
                    // if (dllFile.Contains("OpenRPA.Interfaces.")) continue;
                    if (dllFile.Contains("DotNetProjects."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("Emgu."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("Microsoft.CodeAnalysis."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("Microsoft.Office."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("NuGet."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Collections."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.ComponentModel."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Composition."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Data."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Diagnostics."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Globalization."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.IO."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Linq."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Net."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Reflection."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Resources."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Runtime."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Security."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Text."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Threading."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Xml."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("System.Windows."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("ToastNotifications."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("Xceed.Wpf."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("ControlzEx."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("MahApps."))
                    {
                        continue;
                    }
                    if (dllFile.Contains("Interop.SAPFEWSELib"))
                    {
                        continue;
                    }
                    if (dllFile.Contains("Interop.SapROTWr"))
                    {
                        continue;
                    }
                    AssemblyName an       = AssemblyName.GetAssemblyName(dllFile);
                    Assembly     assembly = Assembly.Load(an);
                    assemblies.Add(assembly);
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "");
                }
            }
            Log.Information("LoadPlugins::Get types " + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
            foreach (var a in assemblies)
            {
                try
                {
                    foreach (var s in a.GetTypes())
                    {
                        alltypes.Add(s);
                    }
                }
                catch (Exception) { }
            }

            Log.Information("LoadPlugins::Get all IRecordPlugins " + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
            var IRecordPlugintype = typeof(IRecordPlugin);

            foreach (var p in alltypes)
            {
                try
                {
                    if (IRecordPlugintype.IsAssignableFrom(p) && p.IsInterface == false)
                    {
                        pluginTypes.Add(p);
                    }
                }
                catch (Exception) { }
            }
            Log.Information("LoadPlugins::Get all IDetectorPlugin " + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
            var IDetectorPlugintype = typeof(IDetectorPlugin);

            foreach (var p in alltypes)
            {
                try
                {
                    if (IDetectorPlugintype.IsAssignableFrom(p) && p.IsInterface == false)
                    {
                        IDetectorPluginTypes.Add(p);
                    }
                }
                catch (Exception) { }
            }

            Log.Information("LoadPlugins::Get all ISnippet " + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
            var ISnippettype = typeof(ISnippet);

            foreach (var p in alltypes)
            {
                try
                {
                    if (ISnippettype.IsAssignableFrom(p) && p.IsInterface == false)
                    {
                        snippetTypes.Add(p);
                    }
                }
                catch (Exception) { }
            }

            Log.Information("LoadPlugins::Get all IRunPlugin " + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
            var IRunPlugintype = typeof(IRunPlugin);

            foreach (var p in alltypes)
            {
                try
                {
                    if (IRunPlugintype.IsAssignableFrom(p) && p.IsInterface == false)
                    {
                        runPluginTypes.Add(p);
                    }
                }
                catch (Exception) { }
            }

            foreach (var type in IDetectorPluginTypes)
            {
                Plugins.detectorPluginTypes.Add(type.FullName, type);
            }
            foreach (Type type in pluginTypes)
            {
                try
                {
                    IRecordPlugin plugin = (IRecordPlugin)Activator.CreateInstance(type);
                    Log.Information("LoadPlugins::Initialize plugin " + plugin.Name + " " + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
                    // SetStatus("Initialize plugin " + plugin.Name);
                    plugin.Initialize(client);
                    GenericTools.RunUI(() => recordPlugins.Add(plugin));
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                }
            }
            foreach (Type type in snippetTypes)
            {
                try
                {
                    ISnippet plugin = (ISnippet)Activator.CreateInstance(type);
                    Log.Information("LoadPlugins::Initialize snippet " + plugin.Name + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
                    Snippets.Add(plugin);
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                }
            }
            foreach (Type type in runPluginTypes)
            {
                try
                {
                    IRunPlugin plugin = (IRunPlugin)Activator.CreateInstance(type);
                    Log.Information("LoadPlugins::Initialize RunPlugin " + plugin.Name + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
                    plugin.Initialize(client);
                    GenericTools.RunUI(() => runPlugins.Add(plugin));
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                }
            }
            Log.Information("LoadPlugins::end " + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
        }
 public void Initialize(IOpenRPAClient client, Detector InEntity)
 {
     Entity = InEntity;
     Start();
 }
Exemplo n.º 27
0
 public void Initialize(IOpenRPAClient client)
 {
     Plugin.client = client;
     _             = PluginConfig.enable_xpath_support;
 }
Exemplo n.º 28
0
        public void Initialize(IOpenRPAClient client)
        {
            Plugin.client = client;
            _             = PluginConfig.csharp_intellisense;
            _             = PluginConfig.vb_intellisense;
            _             = PluginConfig.use_embedded_python;
            _             = PluginConfig.py_create_no_window;

            //System.Diagnostics.Debugger.Launch();
            //System.Diagnostics.Debugger.Break();
            bool hadError = false;

            if (PluginConfig.use_embedded_python)
            {
                if (!Python.Included.Installer.IsPythonInstalled())
                {
                    Python.Included.Installer.SetupPython(true).Wait();
                }
                else
                {
                    Python.Included.Installer.SetupPython(false).Wait();
                }
                var path = Python.Included.Installer.EmbeddedPythonHome;
                PythonUtil.Setup.SetPythonPath(path, true);
                // Python.Runtime.PythonEngine.Initialize();
            }
            else
            {
                try
                {
                    if (!string.IsNullOrEmpty(PluginConfig.python_exe_path))
                    {
                        PythonUtil.Setup.SetPythonPath(PluginConfig.python_exe_path, false);
                    }
                    PythonUtil.Setup.Run();
                }
                catch (Exception ex)
                {
                    hadError = true;
                    Log.Error(ex.ToString());
                }
            }
            // PythonUtil.Setup.Run();
            //Python.Runtime.PythonEngine.Initialize();
            if (!hadError)
            {
                //try
                //{
                //    _ = Python.Runtime.PythonEngine.BeginAllowThreads();
                //}
                //catch (Exception ex)
                //{
                //    Log.Error(ex.ToString());
                //}
            }
            //if (InvokeCode.pool == null)
            //{
            //    InvokeCode.pool = RunspaceFactory.CreateRunspacePool(1, 5);
            //    InvokeCode.pool.ApartmentState = System.Threading.ApartmentState.MTA;
            //    InvokeCode.pool.Open();
            //}
        }