/// <summary> /// Initializes a new instance of ServiceLog. /// </summary> /// <param name="logMode">The LogMode defining the level of detail of the log.</param> /// <param name="maxFileSize">The max file size in byte.</param> internal WsapmLog(LogMode logMode, uint maxFileSize) { this.settingsFolder = WsapmTools.GetCommonApplicationDataFolder(); this.logFile = WsapmTools.GetCommonApplicationLogFile(); this.LogMode = logMode; this.MaxLogFileSize = maxFileSize; }
public MainWindow() { if (AlreadyRunning()) { MessageBox.Show(Wsapm.Resources.Wsapm.MainWindow_AppAlreadyRunning, Wsapm.Resources.Wsapm.MainWindow_Title, MessageBoxButton.OK, MessageBoxImage.Information); App.Current.Shutdown(); return; } ParseArgs(); try { this.settingsLock = new object(); this.logManager = new LogManager(WsapmTools.GetCommonApplicationDataFolder(), WsapmConstants.WsapmApplicationLogFile); this.logManager.LogChanged += logManager_LogChanged; InitializeComponent(); this.serviceManager = new ServiceManager(); this.settingsManager = new SettingsManager(); lock (this.settingsLock) { this.currentSettings = this.settingsManager.LoadSettings(); } this.logManager.Start(); if (this.textBoxLog != null && this.scrollViewerLog != null) { this.textBoxLog.Text = this.logManager.Log; // Load current log manually for the first time. this.scrollViewerLog.ScrollToEnd(); } this.temporaryUptimeManager = new TemporaryUptimeManager(); } catch (Exception ex) { UnhandledExceptionManager.HandleException(ex); } }
public static ActionResult RemoveApplicationDataFolder(Session session) { session.Log("Begin RemoveApplicationDataFolder"); try { string applicationDataFolder = WsapmTools.GetCommonApplicationDataFolder(); if (Directory.Exists(applicationDataFolder)) { Directory.Delete(applicationDataFolder, true); } } catch (Exception ex) { session.Log("Failed to remove application data folder: " + ex.Message); return(ActionResult.Failure); } return(ActionResult.Success); }