Пример #1
0
        private IChannelMetadataRecord ToChannelMetadataRecord(IEtpAdapter etpAdapter, Channel channel, IList <IIndexMetadataRecord> indexMetadata)
        {
            var uri          = channel.GetUri();
            var channelIndex = GetIndexRange(channel);
            var lastChanged  = channel.Citation.LastUpdate.ToUnixTimeMicroseconds().GetValueOrDefault();

            var primaryIndex = indexMetadata.FirstOrDefault();
            var isTimeIndex  = etpAdapter.IsTimeIndex(primaryIndex);

            var dataObject = etpAdapter.CreateDataObject();

            etpAdapter.SetDataObject(dataObject, channel, uri, channel.Mnemonic, 0, lastChanged);

            var metadata = etpAdapter.CreateChannelMetadata(uri);

            metadata.DataType     = channel.DataType.GetValueOrDefault(EtpDataType.@double).ToString().Replace("@", string.Empty);
            metadata.Description  = channel.Citation != null ? channel.Citation.Description ?? channel.Mnemonic : channel.Mnemonic;
            metadata.ChannelName  = channel.Mnemonic;
            metadata.Uom          = Units.GetUnit(channel.Uom);
            metadata.MeasureClass = channel.ChannelClass?.Title ?? ObjectTypes.Unknown;
            metadata.Source       = channel.Source ?? ObjectTypes.Unknown;
            metadata.Uuid         = channel.Mnemonic;
            metadata.DomainObject = dataObject;
            //metadata.Status = (ChannelStatuses)(int)channel.GrowingStatus.GetValueOrDefault(ChannelStatus.inactive);
            metadata.StartIndex = primaryIndex == null ? null : channelIndex.Start.IndexToScale(primaryIndex.Scale, isTimeIndex);
            metadata.EndIndex   = primaryIndex == null ? null : channelIndex.End.IndexToScale(primaryIndex.Scale, isTimeIndex);
            metadata.Indexes    = etpAdapter.ToList(indexMetadata);

            return(metadata);
        }
Пример #2
0
        /// <summary>
        /// Converts a logCurveInfo to a channel metadata record.
        /// </summary>
        /// <param name="etpAdapter">The ETP adapter.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="curve">The curve.</param>
        /// <param name="indexMetadata">The index metadata.</param>
        /// <returns></returns>
        protected override IChannelMetadataRecord ToChannelMetadataRecord(IEtpAdapter etpAdapter, Log entity, LogCurveInfo curve, IIndexMetadataRecord indexMetadata)
        {
            var uri          = curve.GetUri(entity);
            var isTimeLog    = IsTimeLog(entity, true);
            var curveIndexes = GetCurrentIndexRange(entity);
            var unixTime     = entity.CommonData.DateTimeLastChange.ToUnixTimeMicroseconds();

            var dataObject = etpAdapter.CreateDataObject();

            etpAdapter.SetDataObject(dataObject, curve, uri, curve.Mnemonic, 0, unixTime.GetValueOrDefault());

            var metadata = etpAdapter.CreateChannelMetadata(uri);

            metadata.DataType     = curve.TypeLogData.GetValueOrDefault(LogDataType.@double).ToString().Replace("@", string.Empty);
            metadata.Description  = curve.CurveDescription ?? curve.Mnemonic;
            metadata.ChannelName  = curve.Mnemonic;
            metadata.Uom          = Units.GetUnit(curve.Unit);
            metadata.MeasureClass = curve.ClassWitsml?.Name ?? ObjectTypes.Unknown;
            metadata.Source       = curve.DataSource ?? ObjectTypes.Unknown;
            metadata.DomainObject = dataObject;
            metadata.Status       = etpAdapter.GetChannelStatus(entity.ObjectGrowing.GetValueOrDefault());
            metadata.StartIndex   = curveIndexes[curve.Mnemonic].Start.IndexToScale(indexMetadata.Scale, isTimeLog);
            metadata.EndIndex     = curveIndexes[curve.Mnemonic].End.IndexToScale(indexMetadata.Scale, isTimeLog);
            metadata.Indexes      = etpAdapter.ToList(new List <IIndexMetadataRecord> {
                indexMetadata
            });

            return(metadata);
        }
Пример #3
0
        private IChannelMetadataRecord ToChannelMetadataRecord(IEtpAdapter etpAdapter, Trajectory entity, IIndexMetadataRecord indexMetadata)
        {
            var uri         = entity.GetUri();
            var lastChanged = entity.Citation.LastUpdate.ToUnixTimeMicroseconds().GetValueOrDefault();

            var dataObject = etpAdapter.CreateDataObject();

            etpAdapter.SetDataObject(dataObject, entity, uri, entity.Citation.Title, 0, lastChanged);

            var metadata = etpAdapter.CreateChannelMetadata(uri);

            metadata.DataType     = [email protected]();
            metadata.Description  = entity.Citation.Description ?? entity.Citation.Title;
            metadata.ChannelName  = entity.Citation.Title;
            metadata.Uom          = Units.GetUnit(entity.MDMin?.Uom.ToString());
            metadata.MeasureClass = ObjectTypes.Unknown;
            metadata.Source       = ObjectTypes.Unknown;
            metadata.Uuid         = entity.Uuid;
            metadata.DomainObject = dataObject;
            metadata.Status       = etpAdapter.GetChannelStatus(entity.GrowingStatus == ChannelStatus.active);
            metadata.StartIndex   = entity.MDMin?.Value.IndexToScale(indexMetadata.Scale);
            metadata.EndIndex     = entity.MDMax?.Value.IndexToScale(indexMetadata.Scale);
            metadata.Indexes      = etpAdapter.ToList(new List <IIndexMetadataRecord> {
                indexMetadata
            });

            return(metadata);
        }
Пример #4
0
        private static IDataObject ToDataObject(IEtpAdapter etpAdapter, Trajectory entity, TrajectoryStation trajectoryStation)
        {
            var dataObject = etpAdapter.CreateDataObject();

            if (entity == null || trajectoryStation == null)
            {
                return(dataObject);
            }

            var uri      = entity.GetUri();
            var childUri = uri.Append(ObjectTypes.TrajectoryStation, trajectoryStation.Uid);

            etpAdapter.SetDataObject(dataObject, trajectoryStation, childUri, entity.Citation.Title, 0, compress: false);

            return(dataObject);
        }
Пример #5
0
        /// <summary>
        /// Puts the growing part for a growing object.
        /// </summary>
        /// <param name="etpAdapter">The ETP adapter.</param>
        /// <param name="uri">The growing obejct's URI.</param>
        /// <param name="contentType">Type of the content.</param>
        /// <param name="data">The data.</param>
        public override void PutGrowingPart(IEtpAdapter etpAdapter, EtpUri uri, string contentType, byte[] data)
        {
            var dataObject = etpAdapter.CreateDataObject();

            dataObject.Data = data;

            // Convert byte array to TrajectoryStation
            var trajectoryStationXml = dataObject.GetString();
            var tsDocument           = WitsmlParser.Parse(trajectoryStationXml);
            var trajectoryStation    = WitsmlParser.Parse <TrajectoryStation>(tsDocument.Root);

            // Merge TrajectoryStation into the Trajectory if it is not null
            if (trajectoryStation != null)
            {
                // Get the Trajectory for the uri
                var entity = GetEntity(uri);
                entity.TrajectoryStation = trajectoryStation.AsList();

                var document = WitsmlParser.Parse(WitsmlParser.ToXml(entity));
                var parser   = new WitsmlQueryParser(document.Root, ObjectTypes.GetObjectType <Trajectory>(), null);
                UpdateTrajectoryWithStations(parser, entity, uri, true);
            }
        }