/// <summary> /// Log the result of the backup session in the database. /// </summary> /// <param name="clientId">Unique Id of the client that have perform the backup.</param> /// <param name="bckSession">Informations on the backup.</param> public void LogBackupResult(string clientId, BackupSession bckSession) { string fileId = GetPstFile(clientId, bckSession.LocalPath).Id.ToString(); var _sqlCommand = new SqlCommand($"INSERT INTO tbBackupSessions VALUES(" + $"@fileId," + $"@remotePath," + $"@compressedSize," + $"@isCompressed," + $"@backupMethod," + $"@isSchedule," + $"@startTime," + $"@endTime," + $"@chunkCount," + $"@errorCode," + $"@errorMessage);", _dbConnection); AddParameter(_sqlCommand, "@fileId", System.Data.SqlDbType.UniqueIdentifier, new Guid(fileId)); AddParameter(_sqlCommand, "@remotePath", System.Data.SqlDbType.NVarChar, bckSession.RemotePath.Substring(0, System.Math.Min(300, bckSession.RemotePath.Length))); AddParameter(_sqlCommand, "@isCompressed", System.Data.SqlDbType.Bit, bckSession.IsCompressed); AddParameter(_sqlCommand, "@compressedSize", System.Data.SqlDbType.BigInt, bckSession.CompressedSize); AddParameter(_sqlCommand, "@backupMethod", System.Data.SqlDbType.Int, bckSession.BackupMethod); AddParameter(_sqlCommand, "@isSchedule", System.Data.SqlDbType.Bit, bckSession.IsSchedule); AddParameter(_sqlCommand, "@startTime", System.Data.SqlDbType.DateTime, bckSession.StartTime); AddParameter(_sqlCommand, "@endTime", System.Data.SqlDbType.DateTime, bckSession.EndTime); AddParameter(_sqlCommand, "@chunkCount", System.Data.SqlDbType.Int, bckSession.ChunkCount); AddParameter(_sqlCommand, "@errorCode", System.Data.SqlDbType.Int, bckSession.ErrorCode); AddParameter(_sqlCommand, "@errorMessage", System.Data.SqlDbType.NVarChar, bckSession.ErrorMessage.Substring(0, System.Math.Min(300, bckSession.ErrorMessage.Length))); _sqlCommand.ExecuteNonQuery(); if (bckSession.ErrorCode == PstBackupEngine.BackupResultInfo.BackupResult.Success) { UpdateBackupSuccessDate(clientId, fileId, bckSession.EndTime); } }
/// <summary> /// Register the result of a backup of a PST file into the database /// </summary> /// <param name="clientId">Unique Id of the client that own the PST file</param> /// <param name="backupSession">Informations on the backup session</param> public void RegisterBackupResult(string clientId, BackupSession backupSession) { Logger.Write(30022, $"Logging backup result for {backupSession.LocalPath}", Logger.MessageSeverity.Debug); _reportServerDb.LogBackupResult(clientId, backupSession); }