Exemple #1
0
        Result IExternalCommand.Execute(ExternalCommandData data, ref string message, ElementSet elements)
        {
            var _exception = default(Exception);
            var _message   = message;

            try { return(ActivationGate.Open(() => Execute(data, ref _message, elements), this)); }
            catch (Exceptions.CancelException e) { _message = e.Message; return(Result.Cancelled); }
            catch (Exceptions.FailException e) { _message = e.Message; return(Result.Failed); }
            catch (Autodesk.Revit.Exceptions.ApplicationException e) { _message = e.Message; return(Result.Failed); }
            catch (Exception e)
            {
                if (!CatchException(e, data.Application))
                {
                    throw;
                }

                _exception = e;
            }
            finally { message = _message; }

            if (_exception is object)
            {
                ReportException(_exception, data.Application);
            }

            return(Result.Failed);
        }
Exemple #2
0
        void IExternalEventHandler.Execute(UIApplication app)
        {
            var _exception = default(Exception);

            try { ActivationGate.Open(() => Execute(app), this); }
            catch (Exceptions.CancelException e) { if (!string.IsNullOrEmpty(e.Message))
                                                   {
                                                       Debug.Fail(e.Source, e.Message);
                                                   }
            }
            catch (Exceptions.FailException e)   { Debug.Fail(e.Source, e.Message); }
            catch (Autodesk.Revit.Exceptions.ApplicationException e) { Debug.Fail(e.Source, e.Message); }
            catch (Exception e)
            {
                if (!CatchException(e, app))
                {
                    throw;
                }

                _exception = e;
            }

            if (_exception is object)
            {
                ReportException(_exception, app);
            }
        }
        Result IExternalApplication.OnStartup(UIControlledApplication app)
        {
            if (app.ActiveAddInId.GetGUID() != GetGUID())
            {
                return(Result.Failed);
            }

            return(ActivationGate.Open(() => OnStartup(app), this));
        }
Exemple #4
0
 ExternalDBApplicationResult IExternalDBApplication.OnShutdown(ControlledApplication application) =>
 ActivationGate.Open(() => OnShutdown(application), this);
 Result IExternalApplication.OnShutdown(UIControlledApplication app) =>
 ActivationGate.Open(() => OnShutdown(app), this);