public void AddRow(CheckPointLogModel logData) { var columns = new List<KeyValuePair<string, object>>(); if (logData != null) { columns.Add(new KeyValuePair<string, object>("№", logData.Counters.Journal)); columns.Add(new KeyValuePair<string, object>("Дата", this.TruncateDate(logData.StartDate).ToString(StringConstrants.DateTimeFormat))); columns.Add(new KeyValuePair<string, object>("Changelist", logData.Counters.MaxCommitChange)); columns.Add(new KeyValuePair<string, object>("Upgrade", logData.Counters.Upgrade)); columns.Add(new KeyValuePair<string, object>("Потребители", logData.UserCount)); columns.Add(new KeyValuePair<string, object>("Проекти", logData.ProjectCount)); columns.Add(new KeyValuePair<string, object>("Файлове", logData.Sizes.FilesCount)); columns.Add(new KeyValuePair<string, object>("Версии", logData.Sizes.RevisionsCount)); columns.Add(new KeyValuePair<string, object>("Депо", string.Format("{0:0.00} Mb", logData.DepotSize))); columns.Add(new KeyValuePair<string, object>("Log", string.Format("{0:0.00} Mb", logData.Log.FileSize))); columns.Add(new KeyValuePair<string, object>("Auditlog", string.Format("{0:0.00} Mb", logData.AuditLog.FileSize))); columns.Add(new KeyValuePair<string, object>("Име", logData.Arhive != null ? logData.Arhive.ArhivePatternName : string.Empty)); columns.Add(new KeyValuePair<string, object>("Размер", string.Format("{0:0.00} Mb", logData.Arhive != null ? logData.Arhive.Size : 0))); columns.Add(new KeyValuePair<string, object>("Платформа", logData.ServerInfo.Platform)); columns.Add(new KeyValuePair<string, object>("Версия", string.Format("'{0}", logData.ServerInfo.Version))); columns.Add(new KeyValuePair<string, object>("Ревизия", logData.ServerInfo.Revision)); columns.Add(new KeyValuePair<string, object>("от Дата", this.TruncateDate(logData.ServerInfo.Date).ToString(StringConstrants.DateFormat))); } var workbook = new Workbook(); workbook.LoadFromFile(this.FullFileRoot); Worksheet sheet = workbook.Worksheets.FirstOrDefault(s => s.Name == SheetName) as Worksheet; if (sheet == null) { throw new ArgumentNullException("Excel sheet not found"); } var range = sheet.Range; var headerStart = this.FindHeader(range, "№"); var lastRow = this.FindLastRow(range, headerStart); sheet.InsertRow(lastRow.Row, 1, InsertOptionsType.FormatAsBefore); for (int index = 0; index < columns.Count; index++) { var currentCol = lastRow.Column + index; var headerText = sheet.Range[headerStart.Row, currentCol].Text; var currentCell = columns[index]; if (headerText == currentCell.Key) { sheet.Range[lastRow.Row, currentCol].Value2 = currentCell.Value; } } workbook.Save(); workbook.Dispose(); }
public void Execute() { CheckPointLogModel result = new CheckPointLogModel(); this.Initialize(result); this.Validate(); this.StopService(); this.MakeCheckpoint(result); this.BackupLogs(result); this.MakeArhive(result); this.StartService(); this.GetStatistics(result); this.WriteToExcel(result); this.EndMessage(); this.EngineManager.ExcelWriter.OpenExcel(); }
public void GetStatistics(CheckPointLogModel result) { IPerforceCommands perforce = this.EngineManager.PerforceCommands; result.ServerInfo = perforce.GetServerVersion(); result.Counters = perforce.GetCounters(); result.Sizes = perforce.GetSizes(); result.UserCount = perforce.GetUsersCount(); result.ProjectCount = perforce.GetProjectCount(); IDirectoryInformation dirInfo = this.EngineManager.DirectoryInformation; result.DepotSize = dirInfo.DirSizeInMb(perforce.ServerRoot, this.Configurations.DepotSubPath, this.InfoLogger); }
public void BackupLogs(CheckPointLogModel result) { ILogFileArhivator logArhivator = this.EngineManager.LogFileArhivator; result.Log = logArhivator.Compress("log", this.Configurations.MaxLogSize, this.Configurations.LogArhiveSubPath); result.AuditLog = logArhivator.Compress("auditlog", this.Configurations.MaxAuditLogSize, this.Configurations.LogArhiveSubPath); }
public void WriteToExcel(CheckPointLogModel result) { IExcelWriter excelWriter = this.EngineManager.ExcelWriter; excelWriter.AddRow(result); IRootArhivator rootArhivator = this.EngineManager.RootArhivator; rootArhivator.AddFileToArhiv(excelWriter.FullFileRoot, result.Arhive.ArhiveFullPath); this.Logger.WriteInfo("Data saved to Excel"); }
public void MakeCheckpoint(CheckPointLogModel result) { IPerforceServerExecutor server = this.EngineManager.PerforceServerExecutor; server.MakeCheckPoint(this.Configurations.CheckpointSubPath); // Remove old Checkpoints ICheckpointArhivator checkpointBackup = this.EngineManager.CheckpointArhivator; result.CheckpointName = checkpointBackup.Compress(this.Configurations.CheckpointArhiveSubPath); }
public void MakeArhive(CheckPointLogModel result) { IRootArhivator rootArhivator = this.EngineManager.RootArhivator; result.Arhive = rootArhivator.Compress(result.CheckpointName, this.Configurations.ArhivePath); }
public void Initialize(CheckPointLogModel result) { this.InfoLogger.WriteLine(" - Start..."); string version = string.Empty; if (!string.IsNullOrWhiteSpace(this.version)) { version = string.Format("v.{0}", this.version); } this.Logger.WriteInfoFormat("PerforceBackup {0} started...", version); this.InfoLogger.WriteLine(" - Date: {0}", result.StartDate.ToString(StringConstrants.DateTimeFormat)); this.StartService(); }