public static void Render(LogStatsDal dal, LiveViewOptions options, LayoutStyle layoutStyle) { Initialize(); List <DbccLogInfoItem> vlfs; try { vlfs = dal.ReadDbccLogInfo(null, true, options.ForceDbccLoginfo); } catch (Exception ex) { try { RenderException(options, ex); } catch { // Intentionally swallow any exceptions. } return; } using (Bitmap bitmap = CreateImage(vlfs, options, layoutStyle)) { if (options.DisplaySurface.InvokeRequired) { options.DisplaySurface.Invoke(new Action <LiveViewOptions, Bitmap>(SetImage), options, bitmap); } else { SetImage(options, bitmap); } } long totalLogSize = vlfs.Sum(v => v.FileSize); string displaySize = Utilities.FriendlySize(totalLogSize); DatabaseInfo dbInfo = dal.GetCurrentDatabaseInfo(); string statusMessage = $"Instance: {dal.InstanceName}; Database: {dal.DatabaseName}; Recovery model: {dbInfo.RecoveryModelDescription}; Log size: {displaySize}; VLFs: {vlfs.Count}; Wait: {dbInfo.LogReuseWaitDescription}; Last refresh: {DateTime.Now:HH:mm:ss}"; ToolStrip toolStrip = options.StatusLabel.GetCurrentParent(); if (toolStrip != null) { if (toolStrip.InvokeRequired) { toolStrip.Invoke(new Action <LiveViewOptions, string>(SetStatus), options, statusMessage); } else { SetStatus(options, statusMessage); } } }
private void Dispose(bool disposing) { if (disposing) { if (_dal != null) { _dal.Dispose(); _dal = null; } } }
public LiveViewVisualizer(LiveViewOptions options, LayoutStyle layoutStyle) { if (options == null) { throw new ArgumentNullException(nameof(options)); } _options = options; _layoutStyle = layoutStyle; _isCancelled = false; _dal = new LogStatsDal(options.Connection); }