/// <summary> /// Открывает текущий файл лога /// </summary> private static void OpenLogFile(ISberBankApplication sberBank) { DirectoryInfo di = new DirectoryInfo(sberBank.PathManager.LogPath); if (!di.Exists) { return; } string mask = String.Format("{0}*.{1}", SberBankHelper.LogFileName, FileLogWriter.Extension); FileInfo fi = di.GetFiles(mask).TakeRecent(); if (fi == null) { return; } try { Process.Start(fi.FullName); } catch { // } }
/// <summary> /// Удаляет файлы лога /// </summary> private static void DeleteLogFiles(ISberBankApplication sberBank) { foreach (var v in new DirectoryInfo(sberBank.PathManager.LogPath).GetFiles(String.Format("*.{0}", FileLogWriter.Extension))) { v.Delete(); } }
/// <summary> /// Управление сетевым обменом /// </summary> private static void NetworkControl(ISberBankApplication sberBank) { SberBank.NetworkForceDisable = !SberBank.NetworkForceDisable; sberBank.Logger.Write(SberBank.NetworkForceDisable ? LogLevel.Warning : LogLevel.Debug, String.Format("Сетевой обмен отключен : {0}", SberBank.NetworkForceDisable.GetString())); }
/// <summary> /// Записывает техническую информацию в лог /// </summary> public static void WriteRuntimeInfoToLog(ISberBankApplication sberBank) { foreach (string s in sberBank.GetRuntimeInfo()) { sberBank.Logger.Write(LogLevel.Error, s, SberBankLogCategories.Runtime); } }
public SessionTimeMonitoringObject(ISberBankApplication sberBank) : base("Время текущей сессии", (int)MonitoringObjectCategory.Other) { watch = new Stopwatch(); this.sberBank = sberBank; this.sberBank.AfterRun += (state) => { watch.Start(); }; this.sberBank.AfterShutdown += (state) => { watch.Stop(); watch.Reset(); }; }
/// <summary> /// Записывает комментарий в лог /// </summary> private static void WriteLogComment(ISberBankApplication sberBank, object param) { string comment = (string)param; if (!String.IsNullOrEmpty(comment)) { sberBank.Logger.Write(LogLevel.Error, Common.GetSafeLogComment(comment), SberBankLogCategories.Comments); } }
public MainForm() : base(true) { InitializeComponent(); //this.SetLogoIcon(); this.SetLogoImages(picTop, status); UpdateCaption(); tslblStatusState.SetLogoForeColor(); tslblStatusNetwork.SetLogoForeColor(); imgServices.Images.Add(Images.OK); imgServices.Images.Add(Images.Error); imgServices.Images.Add(Images.Extension); imgServices.Images.Add(Images.Extension.MakeGrayscale()); imgServices.Images.Add(Images.Find); imgServices.Images.Add(Images.Warning); lblExtensionsWarning.ImageIndex = ImageIndexWarning; lblMonitorWarning.ImageIndex = ImageIndexWarning; var lvgc = lvwMonitor.Groups; lvgc.Clear(); foreach (var mt in RuntimeHelper.GetEnumElements <MonitoringObjectCategory>()) { lvgc.Add(mt.ToString(), mt.GetString()); } sberBank = null; settingsForm = null; aboutForm = null; inputForm = new InputForm(); stateTimer = new ToolStripStateTimer(tslblStatusState, TimeSpan.FromSeconds(2)); stateTimer.DefaultText = StatusStateReady; stateTimer.UpdateStateText(); var chordHandler = new ChordKeyHandler(this); actions = new Dictionary <int, HotKeyAction>(); actions.Add(chordHandler.AddChord(Keys.Control, Keys.L, Keys.F), HotKeyAction.OpenLogFolder); actions.Add(chordHandler.AddChord(Keys.Control, Keys.L, Keys.D), HotKeyAction.DeleteLogFiles); actions.Add(chordHandler.AddChord(Keys.Control, Keys.L, Keys.O), HotKeyAction.OpenLogFile); actions.Add(chordHandler.AddChord(Keys.Control, Keys.L, Keys.W), HotKeyAction.LogComment); actions.Add(chordHandler.AddChord(Keys.Control, Keys.L, Keys.R), HotKeyAction.LogRuntimeInfo); actions.Add(chordHandler.AddChord(Keys.Control, Keys.D, Keys.N), HotKeyAction.NetworkControl); actions.Add(chordHandler.AddChord(Keys.Control, Keys.S, Keys.E), HotKeyAction.ShowExtensionFilter); actions.Add(chordHandler.AddChord(Keys.Control, Keys.L, Keys.C), HotKeyAction.LogControl); chordHandler.ChordPressed += OnChordPressed; menuMain = null; }
/// <summary> /// Выполняет указанное действие горячей клавиши /// </summary> public static void Run(HotKeyAction action, ISberBankApplication sberBank, object param) { if (locks[action]) { //Trace.WriteLine(String.Format("DiagnosticAction {0} is LOCKED", action)); return; } if (ThreadRequired(action)) { ThreadPool.QueueUserWorkItem(p => { RunCore(action, sberBank, param); }); } else { RunCore(action, sberBank, param); } }
/// <summary> /// Выполняет указанное действие горячей клавиши /// </summary> private static void RunCore(HotKeyAction action, ISberBankApplication sberBank, object param) { locks[action] = true; try { Console.Beep(); switch (action) { case HotKeyAction.OpenLogFolder: OpenLogFolder(sberBank); break; case HotKeyAction.LogRuntimeInfo: WriteRuntimeInfoToLog(sberBank); break; case HotKeyAction.LogComment: WriteLogComment(sberBank, param); break; case HotKeyAction.DeleteLogFiles: DeleteLogFiles(sberBank); break; case HotKeyAction.NetworkControl: NetworkControl(sberBank); break; case HotKeyAction.OpenLogFile: OpenLogFile(sberBank); break; case HotKeyAction.LogControl: LogControl(sberBank); break; } } catch (Exception e) { MessageBox.Show(String.Format("Ошибка при выполнении действия {0}\r\n\r\n{1}", action, e.Message), ApplicationServices.GetApplicationName()); } finally { locks[action] = false; } }
/// <summary> /// Включение/отключение логгера /// </summary> private static void LogControl(ISberBankApplication sberBank) { sberBank.Logger.Enabled = !sberBank.Logger.Enabled; }
/// <summary> /// Открывает папку, содержащую логи сервера /// </summary> private static void OpenLogFolder(ISberBankApplication sberBank) { Process.Start(sberBank.PathManager.LogPath); }