# witsml **Repository Path**: maige88/witsml ## Basic Information - **Project Name**: witsml - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2021-04-19 - **Last Updated**: 2021-09-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README [![Build status](https://ci.appveyor.com/api/projects/status/45oiw568eb0grkrk?svg=true)](https://ci.appveyor.com/project/PDS/witsml) [![Coverity Scan Build Status](https://scan.coverity.com/projects/18117/badge.svg)](https://scan.coverity.com/projects/pds-technology-witsml) ## WITSML **Quick Links:**  [Blog](https://witsml.pds.technology/blog) | [Getting Started](https://witsml.pds.technology/docs/getting-started) | [Documentation](https://witsml.pds.technology/docs/documentation) | [Downloads](https://witsml.pds.technology/docs/downloads) | [Support](https://witsml.pds.technology/docs/support) The “PDS.WITSMLstudio” solution provides reusable components referenced by all PDS WITSMLstudio applications containing the following projects: ##### Framework Provides the composition container used to resolve dependencies. ##### Framework.Web Configures the composition container to resolve dependencies for web projects and provides security. ##### Core Contains common classes related to WITSML that are referenced by other projects, including but not limited to the following: - ChannelDataReader - facilitates parsing and reading of log channel data ````C# /// /// Gets multiple readers for each LogData from a instance. /// /// The log. /// An . public static IEnumerable GetReaders(this Witsml141.Log log) { if (log?.LogData == null) yield break; _log.DebugFormat("Creating ChannelDataReaders for {0}", log.GetType().FullName); var isTimeIndex = log.IsTimeLog(); var increasing = log.IsIncreasing(); foreach (var logData in log.LogData) { if (logData?.Data == null || !logData.Data.Any()) continue; var mnemonics = ChannelDataReader.Split(logData.MnemonicList); var units = ChannelDataReader.Split(logData.UnitList); var nullValues = log.GetNullValues(mnemonics).Skip(1).ToArray(); // Split index curve from other value curves var indexCurve = log.LogCurveInfo.GetByMnemonic(log.IndexCurve) ?? new Witsml141.ComponentSchemas.LogCurveInfo { Mnemonic = new Witsml141.ComponentSchemas.ShortNameStruct(mnemonics.FirstOrDefault()), Unit = units.FirstOrDefault() }; // Skip index curve when passing mnemonics to reader mnemonics = mnemonics.Skip(1).ToArray(); units = units.Skip(1).ToArray(); yield return new ChannelDataReader(logData.Data, mnemonics.Length + 1, mnemonics, units, nullValues, log.GetUri(), dataDelimiter: log.GetDataDelimiterOrDefault()) // Add index curve to separate collection .WithIndex(indexCurve.Mnemonic.Value, indexCurve.Unit, increasing, isTimeIndex); } } ```` - DataObjectNavigator - a framework for navigating a WITSML document ````C# /// /// Navigates the element. /// /// The element. /// The type. /// The parent path. protected void NavigateElement(XElement element, Type type, string parentPath = null) { if (IsIgnored(element.Name.LocalName)) return; var properties = GetPropertyInfo(type); var groupings = element.Elements().GroupBy(e => e.Name.LocalName); foreach (var group in groupings) { if (IsIgnored(group.Key, GetPropertyPath(parentPath, group.Key))) continue; var propertyInfo = GetPropertyInfoForAnElement(properties, group.Key); if (propertyInfo != null) { NavigateElementGroup(propertyInfo, group, parentPath); } else { HandleInvalidElementGroup(group.Key); } } NavigateAttributes(element, parentPath, properties); } ```` - DataObjectValidator - a framework for validating a WITSML document ````C# /// /// Determines whether the specified object is valid. /// /// The validation context. /// A collection that holds failed-validation information. IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { switch (Context.Function) { case Functions.GetFromStore: foreach (var result in ValidateForGet()) yield return result; break; case Functions.PutObject: case Functions.AddToStore: foreach (var result in ValidateProperties().Union(ValidateForInsert())) yield return result; break; case Functions.UpdateInStore: foreach (var result in ValidateForUpdate()) yield return result; break; case Functions.DeleteObject: case Functions.DeleteFromStore: foreach (var result in ValidateForDelete()) yield return result; break; } } ```` - WitsmlParser - static helper methods to parse WITSML XML strings ````C# /// /// Parses the specified XML document using LINQ to XML. /// /// The XML string. /// if set to true includes debug log output. /// An instance. /// public static XDocument Parse(string xml, bool debug = true) { if (debug) { _log.Debug("Parsing XML string."); } try { // remove invalid character along with leading/trailing white space xml = xml?.Trim().Replace("\x00", string.Empty) ?? string.Empty; return XDocument.Parse(xml); } catch (XmlException ex) { throw new WitsmlException(ErrorCodes.InputTemplateNonConforming, ex); } } ```` - Extensions – methods commonly used for WITSML classes ````C# /// /// Converts the to unix time microseconds. /// /// The timestamp. /// The timestamp in unix time microseconds public static long ToUnixTimeMicroseconds(this Timestamp timestamp) { return ((DateTimeOffset) timestamp).ToUnixTimeMicroseconds(); } ```` ##### Store.Core Hosts WITSMLstudio Store service implementation, including service interfaces and high level data provider implementation, including: - WitsmlDataAdapter – encapsulates basic CRUD functionality for WITSML data objects ````C# /// /// Data adapter that encapsulates CRUD functionality for /// /// [Export(typeof(IWitsmlDataAdapter))] [Export(typeof(IWitsml141Configuration))] [PartCreationPolicy(CreationPolicy.Shared)] public partial class Well141DataAdapter : MongoDbDataAdapter, IWitsml141Configuration { ... ```` - WitsmlDataProvider – implements support for WITSML API functions ````C# var context = WitsmlOperationContext.Current.Request = request.ToContext(); var version = string.Empty; var dataProvider = Container.Resolve(new ObjectName(context.ObjectType, version)); var result = dataProvider.GetFromStore(context); ```` - WitsmlQueryParser – handles parsing of WITSML input in a request ````C# var Parser = new WitsmlQueryParser(root, context.ObjectType, context.Options); ... var logDatas = Parser.Properties("logData").ToArray(); if (logDatas.Length > 1) { yield return new ValidationResult(ErrorCodes.RecurringLogData.ToString(), new[] { "LogData" }); } ```` - EtpDataProvider – implements support for ETP API functions ````C# /// /// Initializes a new instance of the class. /// /// The composition container. /// The data adapter. protected EtpDataProvider(IContainer container, IWitsmlDataAdapter dataAdapter) : base(container, dataAdapter) { } ... /// /// Deletes a data object by the specified URI. /// /// The data object URI. public virtual void Delete(EtpUri uri) { DataAdapter.Delete(uri); } ```` - WitsmlExtensions – commonly used methods for WITSML classes ````C# /// /// Adds support for the specified function and data object to the capServer instance. /// /// The capServer instance. /// The WITSML Store API function. /// The data object. /// The maximum data nodes. /// The maximum data points. public static void Add(this Witsml141.CapServer capServer, Functions function, string dataObject, int maxDataNodes, int maxDataPoints) { Add(capServer, function, new Witsml141Schemas.ObjectWithConstraint(dataObject) { MaxDataNodes = maxDataNodes, MaxDataPoints = maxDataPoints }); } ```` ##### Core.UnitTest Contains unit tests for PDS WITSMLstudio. ##### Store.IntegrationTest Contains integration tests for PDS WITSMLstudio Store. ##### Store.Web Implements configuration and security for WITSML and ETP endpoints. ##### Store Configures and hosts PDS WITSMLstudio Store on IIS. ##### Store.MongoDb Contains the WitsmlDataAdapter implementation for MongoDB. - MongoDbDataAdapter - is a data adapter that encapsulates CRUD functionality for WITSML objects. ````C# /// /// Updates a data object in the data store. /// /// The input template parser. /// The data object to be updated. public override void Update(WitsmlQueryParser parser, T dataObject) { var uri = GetUri(dataObject); using (var transaction = DatabaseProvider.BeginTransaction(uri)) { UpdateEntity(parser, uri, transaction); ValidateUpdatedEntity(Functions.UpdateInStore, uri); transaction.Commit(); } } ```` - MongoDbUtility - a utility class that encapsulates helper methods for parsing element in query and update ````C# /// /// Gets the list of URI by object type. /// /// The URI list. /// Type of the object. /// the list of URI specified by the object type. public static List GetObjectUris(IEnumerable uris, string objectType) { return uris.Where(u => u.ObjectType == objectType).ToList(); } ```` - MongoTransaction - encapsulates transaction-like behavior for MongoDB ````C# /// /// Commits the transaction in MongoDb. /// public void Commit() { var database = DatabaseProvider.GetDatabase(); foreach (var transaction in Transactions.Where(t => t.Status == TransactionStatus.Pending && t.Action == MongoDbAction.Delete)) { Delete(database, transaction); } ClearTransactions(); Committed = true; } ```` ##### Store.MongoDb.IntegrationTest Integration tests for Store.MongoDb. --- ### Copyright and License Copyright © 2018 PDS Americas LLC Released under the PDS Open Source WITSML™ Product License Agreement http://www.pds.group/WITSMLstudio/OpenSource/ProductLicenseAgreement --- ### Export Compliance This source code makes use of cryptographic software: - SSL/TLS is optionally used to secure web communications The country in which you currently reside may have restrictions on the import, possession, use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check your country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted. See for more information. The U.S. Government Department of Commerce, Bureau of Industry and Security (BIS), has classified this source code as Export Control Classification Number (ECCN) 5D002.c.1, which includes information security software using or performing cryptographic functions with symmetric and/or asymmetric algorithms. This source code is published here: > https://github.com/pds-technology/witsml In accordance with US Export Administration Regulations (EAR) Section 742.15(b), this source code is not subject to EAR: - This source code has been made publicly available in accordance with EAR Section 734.3(b)(3)(i) by publishing it in accordance with EAR Section 734.7(a)(4) at the above URL. - The BIS and the ENC Encryption Request Coordinator have been notified via e-mail of this URL.