コード例 #1
0
 public void AsyncExec(IMacroEventListener listener)
 {
     InitReceptionPool();
     _macroThread      = new Thread((ThreadStart) delegate() { MacroMain(listener); });
     _macroThread.Name = "Macro - " + _module.Title;
     _macroThread.Start();
 }
コード例 #2
0
ファイル: MacroModule.cs プロジェクト: rfyiamcool/solrex
 public void SetMacroEventListener(IMacroEventListener f)
 {
     _macroListener = f;
 }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
 public void SetMacroEventListener(IMacroEventListener f)
 {
     _macroListener = f;
 }
コード例 #5
0
ファイル: MacroExec.cs プロジェクト: FNKGino/poderosa
        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;
                    }
                }
            }
        }
コード例 #6
0
ファイル: MacroExec.cs プロジェクト: FNKGino/poderosa
 public void AsyncExec(IMacroEventListener listener)
 {
     InitReceptionPool();
     _macroThread = new Thread((ThreadStart)delegate() {
         MacroMain(listener);
     });
     _macroThread.Name = "Macro - " + _module.Title;
     _macroThread.Start();
 }
コード例 #7
0
        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;
                    }
                }
            }
        }
コード例 #8
0
ファイル: MacroPlugin.cs プロジェクト: Ricordanza/poderosa
        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;
            }
        }