/// <summary> /// Handle request to get backup configuration info /// </summary> /// <param name="optionsParams"></param> /// <param name="requestContext"></param> /// <returns></returns> public static async Task HandleBackupConfigInfoRequest( DefaultDatabaseInfoParams optionsParams, RequestContext <BackupConfigInfoResponse> requestContext) { try { var response = new BackupConfigInfoResponse(); ConnectionInfo connInfo; DisasterRecoveryService.ConnectionServiceInstance.TryFindConnection( optionsParams.OwnerUri, out connInfo); if (connInfo != null) { DatabaseTaskHelper helper = AdminService.CreateDatabaseTaskHelper(connInfo, databaseExists: true); SqlConnection sqlConn = GetSqlConnection(connInfo); if ((sqlConn != null) && !connInfo.IsSqlDW && !connInfo.IsAzure) { BackupConfigInfo backupConfigInfo = DisasterRecoveryService.Instance.GetBackupConfigInfo(helper.DataContainer, sqlConn, sqlConn.Database); backupConfigInfo.DatabaseInfo = AdminService.GetDatabaseInfo(connInfo); response.BackupConfigInfo = backupConfigInfo; } } await requestContext.SendResult(response); } catch (Exception ex) { await requestContext.SendError(ex.ToString()); } }
/// <summary> /// Handle request to get backup configuration info /// </summary> /// <param name="optionsParams"></param> /// <param name="requestContext"></param> /// <returns></returns> internal async Task HandleBackupConfigInfoRequest( DefaultDatabaseInfoParams optionsParams, RequestContext <BackupConfigInfoResponse> requestContext) { try { var response = new BackupConfigInfoResponse(); ConnectionInfo connInfo; DisasterRecoveryService.ConnectionServiceInstance.TryFindConnection( optionsParams.OwnerUri, out connInfo); if (connInfo != null) { using (DatabaseTaskHelper helper = AdminService.CreateDatabaseTaskHelper(connInfo, databaseExists: true)) { using (SqlConnection sqlConn = ConnectionService.OpenSqlConnection(connInfo, "Backup")) { if (sqlConn != null && !connInfo.IsCloud) { BackupConfigInfo backupConfigInfo = this.GetBackupConfigInfo(helper.DataContainer, sqlConn, sqlConn.Database); response.BackupConfigInfo = backupConfigInfo; } } } } await requestContext.SendResult(response); } catch (Exception ex) { await requestContext.SendError(ex.ToString()); } }