public void AsyncExec(IMacroEventListener listener) { InitReceptionPool(); _macroThread = new Thread((ThreadStart) delegate() { MacroMain(listener); }); _macroThread.Name = "Macro - " + _module.Title; _macroThread.Start(); }
public void SetMacroEventListener(IMacroEventListener f) { _macroListener = f; }
internal MacroExecutor RunMacroModule(MacroModule module, ISession sessionToBind, IMacroEventListener listener) { try { Assembly asm = MacroUtil.LoadMacroAssembly(module); MacroExecutor macroExec = new MacroExecutor(module, asm); if (sessionToBind != null) { bool bound = _sessionBinder.Bind(macroExec, sessionToBind); if (!bound) { GUtil.Warning(null, Strings.GetString("Message.MacroPlugin.AnotherMacroIsRunningInThisSession")); return(null); } } if (listener != null) { listener.IndicateMacroStarted(); } macroExec.AsyncExec(listener); return(macroExec); } catch (Exception ex) { RuntimeUtil.ReportException(ex); return(null); } }
private void MacroMain(IMacroEventListener listener) { try { InitEnv(); //AppDomain.CurrentDomain.Load(_assembly.FullName); MethodInfo mi = _assembly.EntryPoint; if (DebugOpt.Macro) { Type[] ts = _assembly.GetTypes(); foreach (Type t in ts) { Debug.WriteLine("Found Type " + t.FullName); mi = _assembly.GetType("JScript Main").GetMethod("Main"); Debug.WriteLine("Method Found " + mi.Name); } } if (mi == null) MacroUtil.InvokeMessageBox(MacroPlugin.Instance.Strings.GetString("Message.MacroModule.NoEntryPoint")); else mi.Invoke(null, BindingFlags.InvokeMethod, null, new object[1] { new string[0] }, CultureInfo.CurrentUICulture); } catch (TargetInvocationException tex) { Exception inner = tex.InnerException; lock (_traceWindowLock) { if (_traceWindow == null) { MacroUtil.InvokeMessageBox(String.Format(MacroPlugin.Instance.Strings.GetString("Message.MacroExec.ExceptionWithoutTraceWindow"), inner.Message)); Debug.WriteLine("TargetInvocationException"); Debug.WriteLine(inner.GetType().Name); Debug.WriteLine(inner.Message); Debug.WriteLine(inner.StackTrace); } else { _traceWindow.AddLine(MacroPlugin.Instance.Strings.GetString("Message.MacroExec.ExceptionInMacro")); _traceWindow.AddLine(String.Format("{0} : {1}", inner.GetType().FullName, inner.Message)); _traceWindow.AddLine(inner.StackTrace); } } } catch (Exception ex) { Debug.WriteLine(ex.Message); Debug.WriteLine(ex.StackTrace); } finally { CloseAll(); if (listener != null) listener.IndicateMacroFinished(); lock (_traceWindowLock) { if (_traceWindow != null) { if (_traceWindow.Visible) _traceWindow.HideOnCloseButton = false; else { MacroTraceWindow traceWindow = _traceWindow; _traceWindow.BeginInvoke( (System.Windows.Forms.MethodInvoker)delegate() { traceWindow.Dispose(); }); } _traceWindow = null; } } } }
public void AsyncExec(IMacroEventListener listener) { InitReceptionPool(); _macroThread = new Thread((ThreadStart)delegate() { MacroMain(listener); }); _macroThread.Name = "Macro - " + _module.Title; _macroThread.Start(); }
private void MacroMain(IMacroEventListener listener) { try { InitEnv(); //AppDomain.CurrentDomain.Load(_assembly.FullName); MethodInfo mi = _assembly.EntryPoint; if (DebugOpt.Macro) { Type[] ts = _assembly.GetTypes(); foreach (Type t in ts) { Debug.WriteLine("Found Type " + t.FullName); mi = _assembly.GetType("JScript Main").GetMethod("Main"); Debug.WriteLine("Method Found " + mi.Name); } } if (mi == null) { MacroUtil.InvokeMessageBox(MacroPlugin.Instance.Strings.GetString("Message.MacroModule.NoEntryPoint")); } else { mi.Invoke(null, BindingFlags.InvokeMethod, null, new object[1] { new string[0] }, CultureInfo.CurrentUICulture); } } catch (TargetInvocationException tex) { Exception inner = tex.InnerException; lock (_traceWindowLock) { if (_traceWindow == null) { MacroUtil.InvokeMessageBox(String.Format(MacroPlugin.Instance.Strings.GetString("Message.MacroExec.ExceptionWithoutTraceWindow"), inner.Message)); Debug.WriteLine("TargetInvocationException"); Debug.WriteLine(inner.GetType().Name); Debug.WriteLine(inner.Message); Debug.WriteLine(inner.StackTrace); } else { _traceWindow.AddLine(MacroPlugin.Instance.Strings.GetString("Message.MacroExec.ExceptionInMacro")); _traceWindow.AddLine(String.Format("{0} : {1}", inner.GetType().FullName, inner.Message)); _traceWindow.AddLine(inner.StackTrace); } } } catch (Exception ex) { Debug.WriteLine(ex.Message); Debug.WriteLine(ex.StackTrace); } finally { CloseAll(); if (listener != null) { listener.IndicateMacroFinished(); } lock (_traceWindowLock) { if (_traceWindow != null) { if (_traceWindow.Visible) { _traceWindow.HideOnCloseButton = false; } else { MacroTraceWindow traceWindow = _traceWindow; _traceWindow.BeginInvoke( (System.Windows.Forms.MethodInvoker) delegate() { traceWindow.Dispose(); }); } _traceWindow = null; } } } }
internal MacroExecutor RunMacroModule(MacroModule module, ISession sessionToBind, IMacroEventListener listener) { try { Assembly asm = MacroUtil.LoadMacroAssembly(module); MacroExecutor macroExec = new MacroExecutor(module, asm); if (sessionToBind != null) { bool bound = _sessionBinder.Bind(macroExec, sessionToBind); if (!bound) { GUtil.Warning(null, Strings.GetString("Message.MacroPlugin.AnotherMacroIsRunningInThisSession")); return null; } } if (listener != null) listener.IndicateMacroStarted(); macroExec.AsyncExec(listener); return macroExec; } catch (Exception ex) { RuntimeUtil.ReportException(ex); return null; } }