/// <summary> /// Применить изменения, сделанные в копии настроек. /// </summary> /// <param name="settingsCopy">Копия.</param> public virtual void ApplyChanges(HydraTaskSettings settingsCopy) { Id = settingsCopy.Id; TaskType = settingsCopy.TaskType; ExtensionInfo.Clear(); ExtensionInfo.AddRange(settingsCopy.ExtensionInfo); SupportedLevel1Fields = settingsCopy.SupportedLevel1Fields.ToArray(); ExtensionInfo.Keys.OfType <string>().ForEach(NotifyPropertyChanged); }
ExecuteResultsAsAsyncEnumerable ( TDbConnection connection , string storeProcedureName , JToken inputsParameters = null //string.Empty , int commandTimeoutInSeconds = 90 ) { var extensionInfo = new ExtensionInfo() { resultSetID = 0 , messageID = 0 , recordCounts = null , messages = null }; TDbCommand command = null; List <TDbParameter> dbParameters; bool statisticsEnabled; StatementCompletedEventHandler onStatementCompletedEventHandlerProcessAction = null; SqlInfoMessageEventHandler onSqlInfoMessageEventHandlerProcessAction = null; JObject result; try { ( command , dbParameters , statisticsEnabled , onStatementCompletedEventHandlerProcessAction , onSqlInfoMessageEventHandlerProcessAction , result ) = ResultPreprocess ( connection , storeProcedureName , inputsParameters , commandTimeoutInSeconds , extensionInfo ); await connection .OpenAsync(); var dataReader = command .ExecuteReader ( CommandBehavior .CloseConnection ); var entries = dataReader .AsMultipleResultsIAsyncEnumerable(); //( // (resultSetIndex, rowIndex, columns, dataRecord) => // { // return dataRecord; // } //); await foreach //(var entry in entries) ( var ( resultSetIndex , rowIndex , columns , dataRecord ) in entries ) { extensionInfo .resultSetID = resultSetIndex; yield return ( resultSetIndex , rowIndex , columns , dataRecord ); } await dataReader .CloseAsync(); } finally { extensionInfo.Clear(); if (onStatementCompletedEventHandlerProcessAction != null) { if (command is SqlCommand sqlCommand) { sqlCommand .StatementCompleted -= onStatementCompletedEventHandlerProcessAction; } } if (onSqlInfoMessageEventHandlerProcessAction != null) { if (connection is SqlConnection sqlConnection) { sqlConnection .InfoMessage -= onSqlInfoMessageEventHandlerProcessAction; if (sqlConnection.StatisticsEnabled) { sqlConnection.StatisticsEnabled = false; } } } if (_needAutoRefreshExecutedTimeForSlideExpire) { RefreshCachedExecuted ( connection , storeProcedureName ); } if (connection.State != ConnectionState.Closed) { await connection .CloseAsync(); } if (command != null) { command .Dispose(); } } }
public void ExecuteReaderProcess ( TDbConnection connection , string storeProcedureName , JToken inputsParameters = null //string.Empty , Action < int // resultSetID , JArray , IDataReader , int // row index > onReadRowProcessAction = null , int commandTimeoutInSeconds = 90 ) { var extensionInfo = new ExtensionInfo() { resultSetID = 0 , messageID = 0 , recordCounts = null , messages = null }; TDbCommand command = null; List <TDbParameter> dbParameters; bool statisticsEnabled; StatementCompletedEventHandler onStatementCompletedEventHandlerProcessAction = null; SqlInfoMessageEventHandler onSqlInfoMessageEventHandlerProcessAction = null; JObject result; try { ( command , dbParameters , statisticsEnabled , onStatementCompletedEventHandlerProcessAction , onSqlInfoMessageEventHandlerProcessAction , result ) = ResultPreprocess ( connection , storeProcedureName , inputsParameters , commandTimeoutInSeconds , extensionInfo ); connection .Open(); var dataReader = command .ExecuteReader ( CommandBehavior .CloseConnection ); do { JArray jColumns = null; if (onReadRowProcessAction != null) { if (jColumns == null) { jColumns = dataReader .GetColumnsJArray(); } dataReader .ReadRows ( jColumns , (reader, columns, rowIndex) => { onReadRowProcessAction ( extensionInfo.resultSetID , columns , reader , rowIndex ); } ); } extensionInfo .resultSetID++; jColumns = null; }while ( dataReader .NextResult() ); dataReader.Close(); } finally { extensionInfo.Clear(); if (onStatementCompletedEventHandlerProcessAction != null) { if (command is SqlCommand sqlCommand) { sqlCommand .StatementCompleted -= onStatementCompletedEventHandlerProcessAction; } } if (onSqlInfoMessageEventHandlerProcessAction != null) { if (connection is SqlConnection sqlConnection) { sqlConnection .InfoMessage -= onSqlInfoMessageEventHandlerProcessAction; if (sqlConnection.StatisticsEnabled) { sqlConnection.StatisticsEnabled = false; } } } if (_needAutoRefreshExecutedTimeForSlideExpire) { RefreshCachedExecuted ( connection , storeProcedureName ); } if (connection.State != ConnectionState.Closed) { connection .Close(); } if (command != null) { command .Dispose(); } } }