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