Exemplo n.º 1
0
        public void write(IRecordRef which, IDictionary <string, object> record)
        {
            MongoDBOut outInst = _inst[which.RecordName];

            if (outInst == null)
            {
                throw new UnrecoverableOperationException($"Record reference for Mongo record {which.RecordName} is invalid.");
            }

            var descriptor = new IndexDescriptor()
            {
                Position = _cache.Position
            };

            var doc = outInst.BsonSerialize(record);

            using (var bw = new BsonBinaryWriter(_cache))
                BsonSerializer.Serialize <BsonDocument>(bw, doc);

            descriptor.RecordLength = _cache.Position - descriptor.Position;

            if (!_index.ContainsKey(which.RecordName))
            {
                _index.Add(which.RecordName, new LinkedList <IndexDescriptor>());
            }

            _index[which.RecordName].AddLast(descriptor);
            _recordCount++;
        }
Exemplo n.º 2
0
        private void OutputRecords(SqlDataReader reader, IOutputTransaction trx, IRecordRef record,
                                   Dictionary <String, Func <Object, Object> > customColumnConverters = null)
        {
            int count = 0;

            while (reader.Read())
            {
                SortedDictionary <String, Object> rec = new SortedDictionary <string, object>();

                for (int x = 0; x < reader.FieldCount; x++)
                {
                    var colName = reader.GetColumnSchema()[x].ColumnName;

                    var insertVal = reader[x];

                    if (insertVal.GetType() == typeof(System.DBNull))
                    {
                        continue;
                    }

                    if (customColumnConverters != null && customColumnConverters.ContainsKey(colName))
                    {
                        insertVal = customColumnConverters[colName](reader[x]);
                    }


                    rec.Add(reader.GetColumnSchema()[x].ColumnName, insertVal);
                }

                trx.write(record, rec);
                count++;
            }

            _log.Trace($"Wrote {count} audit records.");
        }
Exemplo n.º 3
0
        public void write(IRecordRef which, IDictionary <string, object> record)
        {
            if (!_records.Contains(which.RecordName))
            {
                throw new UnrecoverableOperationException($"Attempting to write to unregistered record {which.RecordName}");
            }

            if (!_loggers.ContainsKey(which.RecordName))
            {
                _loggers.Add(which.RecordName, new LoggerOut(which.RecordName));
            }

            _loggers[which.RecordName].stage(record);
        }
Exemplo n.º 4
0
        public void write(IRecordRef which, IDictionary <string, object> record)
        {
            if (_committed)
            {
                throw new UnrecoverableOperationException($"Attempted to write record {which.RecordName} after commit.");
            }

            if (!(which is RecordHandler))
            {
                throw new UnrecoverableOperationException($"RecordRef for {which.RecordName} is not of type RecordHandler");
            }

            var rh = which as RecordHandler;

            rh.write(_channel, record);
        }
Exemplo n.º 5
0
 public void CxActivity_dbo_Audit_Logins(DateTime sinceDate, IOutputTransaction trx, IRecordRef record)
 {
     using (var reader = _db.FetchRecords_CxActivity_dbo_Audit_Logins(sinceDate))
         OutputRecords(reader, trx, record);
 }
Exemplo n.º 6
0
        public void CxDB_accesscontrol_AuditTrail(DateTime sinceDate, IOutputTransaction trx, IRecordRef record)
        {
            Func <Object, Object> detailsConverter = (val) =>
            {
                var serializer = JsonSerializer.Create();

                using (JsonTextReader jtr = new JsonTextReader(new StringReader(val as String)))
                    return(serializer.Deserialize <SortedDictionary <String, Object> >(jtr));
            };

            using (var reader = _db.FetchRecords_CxDB_accesscontrol_AuditTrail(sinceDate))
                OutputRecords(reader, trx, record, new Dictionary <string, Func <object, object> >
                {
                    { "Details", detailsConverter }
                });
        }