Esempio n. 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();
        }
Esempio n. 2
0
 public void StartCommand(CommandStart command)
 {
     base.Info($"Start command: {command.CommandName}; Сборка: {command.Assembly.FullName}; ");
 }
Esempio n. 3
0
 public void BlockListCommand()
 {
     CommandStart.Start(doc => doc.Database.List());
 }
Esempio n. 4
0
 public void ColorBookNCS()
 {
     CommandStart.Start(doc => ColorBookHelper.GenerateNCS());
 }
Esempio n. 5
0
 public void PIK_UserSettings()
 {
     CommandStart.Start(doc => { UserSettingsService.Show(); });
 }