private static void GetSQLContentState(ISQLContentState _cd, Action <ProgressChangedEventArgs> reportProgress) { try { reportProgress(new ProgressChangedEventArgs(1, String.Format("Connection string {0}", _cd.SQLConnectionString))); System.Data.IDbConnection _connection = new SqlConnection(_cd.SQLConnectionString); using (SHRARCHIVE _entities = new SHRARCHIVE(_connection)) if (_entities.DatabaseExists()) { reportProgress(new ProgressChangedEventArgs(1, "The specified database exists.")); GetLastOperation(_entities, CAS.SharePoint.Client.Link2SQL.ArchivingOperationLogs.OperationName.Cleanup, x => _cd.CleanupLastRunBy = x, y => _cd.CleanupLastRunDate = y); GetLastOperation(_entities, CAS.SharePoint.Client.Link2SQL.ArchivingOperationLogs.OperationName.Synchronization, x => _cd.SyncLastRunBy = x, y => _cd.SyncLastRunDate = y); GetLastOperation(_entities, CAS.SharePoint.Client.Link2SQL.ArchivingOperationLogs.OperationName.Archiving, x => _cd.ArchivingLastRunBy = x, y => _cd.ArchivingLastRunDate = y); _cd.SQLConnected = true; } else { reportProgress(new ProgressChangedEventArgs(1, "The specified database cannot be opened.")); } } catch (Exception _ex) { reportProgress(new ProgressChangedEventArgs(1, String.Format("Testing SQL connection has been aborted by the exception: {0}", _ex.Message))); } }
private static void GetLastOperation(SHRARCHIVE entities, CAS.SharePoint.Client.Link2SQL.ArchivingOperationLogs.OperationName operationName, Action <string> RunBy, Action <DateTime?> RunDate) { ArchivingOperationLogs _recentActions = CAS.SharePoint.Client.Link2SQL.ArchivingOperationLogs.GetRecentActions <ArchivingOperationLogs>(entities, operationName); if (_recentActions != null) { RunBy(_recentActions.UserName); RunDate(_recentActions.Date); } else { RunBy(String.Empty); RunDate(new Nullable <DateTime>()); } }