private void UpdateIndexInfo(EtpUri uri, IList <ChannelIndexInfo> indexInfos, TimeSpan?offset) { var entity = GetEntity(uri); Logger.DebugFormat("Updating index info for uid '{0}' and name '{1}'.", entity.Uuid, entity.Citation.Title); // Add ChannelIndex for each index var headerUpdate = MongoDbUtility.BuildPushEach <ChannelSet, ChannelIndex>(null, "Index", indexInfos.Select(CreateChannelIndex)); // TODO: Update Citation //headerUpdate = UpdateCommonData(headerUpdate, entity, offset); var mongoUpdate = new MongoDbUpdate <ChannelSet>(Container, GetCollection(), null); var filter = GetEntityFilter(uri); mongoUpdate.UpdateFields(filter, headerUpdate); }
private void UpdateChannels(EtpUri uri, ChannelDataReader reader, TimeSpan?offset) { var entity = GetEntity(uri); Logger.DebugFormat("Updating channels for uid '{0}' and name '{1}'.", entity.Uuid, entity.Citation.Title); var isTimeIndex = reader.Indices.Take(1).Select(x => x.IsTimeIndex).FirstOrDefault(); var channels = reader.Mnemonics .Select((x, i) => new { Mnemonic = x, Index = i }) .Where(x => entity.Channel.GetByMnemonic(x.Mnemonic) == null) .Select(x => CreateChannel(uri, x.Mnemonic, reader.Units[x.Index], reader.DataTypes[x.Index], isTimeIndex, entity.Index)); var mongoUpdate = new MongoDbUpdate <ChannelSet>(Container, GetCollection(), null); var headerUpdate = MongoDbUtility.BuildPushEach <ChannelSet, Channel>(null, "Channel", channels); var filter = GetEntityFilter(uri); mongoUpdate.UpdateFields(filter, headerUpdate); }