예제 #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
파일: Logger.cs 프로젝트: vildar82/AcadLib
 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(); });
 }