示例#1
0
        public static void Start(Action<Document> action)
        {
            CommandStart commandStart = new CommandStart();
            // определение имени команды по вызвавему методу и иего артрибуту CommandMethod;
            try
            {
                var caller = new StackTrace().GetFrame(1).GetMethod();
                CurrentCommand = GetCallerCommand(caller);
                //commandStart = new CommandStart(CurrentCommand, caller.DeclaringType.Assembly);
                commandStart.CommandName = CurrentCommand;
                commandStart.Assembly = caller.DeclaringType.Assembly;
                commandStart.Plugin = commandStart.Assembly.GetName().Name;
                Logger.Log.StartCommand(commandStart);
                CommandCounter.CountCommand(CurrentCommand);
            }
            catch { }

            Document doc = Application.DocumentManager.MdiActiveDocument;
            if (doc == null) return;
            commandStart.Doc = doc.Name;
            Logger.Log.Info($"Document={doc.Name}");
            PluginStatisticsHelper.PluginStart(commandStart);

            Inspector.Clear();
            try
            {
                action(doc);
            }
            catch (CancelByUserException cancelByUser)
            {
                doc.Editor.WriteMessage(cancelByUser.Message);
            }
            catch (System.Exception ex)
            {
                if (!ex.Message.Contains(General.CanceledByUser))
                {
                    Logger.Log.Error(ex, CurrentCommand);
                    Inspector.AddError($"Ошибка в программе. {ex}", System.Drawing.SystemIcons.Error);
                }
                doc.Editor.WriteMessage(ex.Message);
            }
            Inspector.Show();
        }
示例#2
0
 public void StartCommand(CommandStart command)
 {
     base.Info($"Start command: {command.CommandName}; Сборка: {command.Assembly.FullName}; ");
 }
示例#3
0
文件: Commands.cs 项目: trgis/AcadLib
 public void BlockListCommand()
 {
     CommandStart.Start(doc => doc.Database.List());
 }
示例#4
0
文件: Commands.cs 项目: trgis/AcadLib
 public void ColorBookNCS()
 {
     CommandStart.Start(doc => ColorBookHelper.GenerateNCS());
 }
示例#5
0
文件: Commands.cs 项目: trgis/AcadLib
 public void PIK_UserSettings()
 {
     CommandStart.Start(doc => { UserSettingsService.Show(); });
 }