/// <summary> /// Event handler for handling data for the oracle data repository. /// </summary> /// <param name="sender">Object which raises the event.</param> /// <param name="eventArgs">Arguments to the event.</param> private void OnHandleOracleData(object sender, IHandleDataEventArgs eventArgs) { if (sender == null) { throw new ArgumentNullException("sender"); } if (eventArgs == null) { throw new ArgumentNullException("eventArgs"); } var recordFilters = eventArgs.Table.RecordFilters; if (OnHandleData == null) { return; } if (recordFilters.Count == 0) { var data = new List <IEnumerable <IDataObjectBase> >(_dataManipulators.ManipulateData(eventArgs.Table, eventArgs.Data, eventArgs.EndOfData)); try { OnHandleData.Invoke(this, new HandleOracleDataEventArgs(eventArgs.Table, data, eventArgs.EndOfData)); return; } finally { while (data.Count > 0) { data.Clear(); } } } var result = new List <IEnumerable <IDataObjectBase> >(eventArgs.Data.Where(m => recordFilters.Any(recordFilter => !recordFilter.Exclude(m)))); try { var data = new List <IEnumerable <IDataObjectBase> >(_dataManipulators.ManipulateData(eventArgs.Table, result, eventArgs.EndOfData)); try { OnHandleData.Invoke(this, new HandleOracleDataEventArgs(eventArgs.Table, data, eventArgs.EndOfData)); } finally { while (data.Count > 0) { data.Clear(); } } } finally { while (result.Count > 0) { result.Clear(); } } }
/// <summary> /// Gets data from a table. /// </summary> /// <param name="table">Table from where data should be returned.</param> public virtual void DataGetFromTable(ITable table) { if (table == null) { throw new ArgumentNullException("table"); } try { IList <FileInfo> tableFiles; if (!_tableDictionary.TryGetValue(table.NameSource.ToUpper(), out tableFiles)) { throw new DeliveryEngineRepositoryException(Resource.GetExceptionMessage(ExceptionMessage.TableNotFound, table.NameSource)); } var records = new List <List <IDataObjectBase> >(); try { foreach (var tableFile in tableFiles) { using (var fileStream = tableFile.Open(FileMode.Open, FileAccess.Read, FileShare.Read)) { using (var streamReader = new StreamReader(fileStream, Encoding.Default)) { while (!streamReader.EndOfStream) { var record = ReadRecordFromTable(table, streamReader); records.Add(record); if (records.Count < 1024) { continue; } if (OnHandleData == null) { records.Clear(); continue; } OnHandleData.Invoke(this, new HandleOldToNewDataEventArgs(table, records, false)); while (records.Count > 0) { while (records.ElementAt(0).Count > 0) { records.ElementAt(0).Clear(); } records.RemoveAt(0); } } streamReader.Close(); } fileStream.Close(); } } if (OnHandleData != null) { OnHandleData.Invoke(this, new HandleOldToNewDataEventArgs(table, records, true)); } } finally { while (records.Count > 0) { while (records.ElementAt(0).Count > 0) { records.ElementAt(0).Clear(); } records.RemoveAt(0); } } } catch (DeliveryEngineSystemException) { throw; } catch (DeliveryEngineRepositoryException) { throw; } catch (Exception ex) { throw new DeliveryEngineRepositoryException(Resource.GetExceptionMessage(ExceptionMessage.RepositoryError, MethodBase.GetCurrentMethod().Name, ex.Message), ex); } }