Ejemplo n.º 1
0
        //TODO : add for "m/s", pa, etc

        /// <summary>
        /// Create a new WITSML server instance.
        /// </summary>
        /// <param name="url"> URL to server. Non-null.</param>
        /// <param name="userName">User name for server login. Non-null.</param>
        /// <param name="password"> Password for server login. Non-null.</param>
        /// <param name="version">Version we will communicate through. Non-null.</param>
        /// <param name="clientCapabilities">The client signature to pass to server. Non-null.</param>
        public WitsmlServer(String url, String userName, String password,
                            WitsmlVersion version,
                            Capabilities clientCapabilities)
        {
            if (url == null)
            {
                throw new ArgumentException("url cannot be null");
            }

            if (userName == null)
            {
                throw new ArgumentException("userName cannot be null");
            }

            if (version == null)
            {
                throw new ArgumentException("version cannot be null");
            }

            if (clientCapabilities == null)
            {
                throw new ArgumentException("clientCapabilities cannot be null");
            }

            this.clientCapabilities = clientCapabilities;
            this.version            = version;

            accessor = new WitsmlStoreAccessor(url, userName, password, clientCapabilities.toXml());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Return the actual (i.e. version specific) class of the given WITSML type.
        /// </summary>
        /// <param name="version">Version to consider. Non-null.</param>
        /// <param name="type">WITSML type to find class of. Non-null.</param>
        /// <returns>The actual class. Never null.</returns>
        private static Type getActualClass(WitsmlVersion version, String type)
        {
            string      nspace           = "v" + version.getVersion().Replace(".", "");
            List <Type> AvailableClasses = Assembly.GetExecutingAssembly().GetTypes().Where(x => x.Namespace.Contains(nspace)).ToList();
            Type        fountClass       = AvailableClasses.Where(x => x.Name.ToLower().Contains(type.ToLower())).FirstOrDefault();

            return(fountClass);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Create a client capabilities object with the specified properties.
 /// </summary>
 /// <param name="version">WITSML version accepted by client. May be null.</param>
 /// <param name="contactName">Contact name. May be null.</param>
 /// <param name="contactEmail">Contact e-mail. May be null.</param>
 /// <param name="contactPhone">Contact phone number. May be null.</param>
 /// <param name="name">System product name. May be null.</param>
 /// <param name="description">System description. May be null.</param>
 /// <param name="vendor">System vendor. May be null.</param>
 /// <param name="programVersion">System version. May be null.</param>
 public Capabilities(WitsmlVersion version,
                     String contactName,
                     String contactEmail,
                     String contactPhone,
                     String name,
                     String description,
                     String vendor,
                     String programVersion)
     : this(version, false, contactName, contactEmail, contactPhone,
            name, description, vendor, programVersion)
 {
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Create a capabilities object with the specified properties.
        /// </summary>
        /// <param name="version">WITSML version accepted by client. May be bull.</param>
        /// <param name="isServer">Indicates if this is a server (true) or client (false) capabilities instance.</param>
        /// <param name="contactName">Contact name for the site. May be null.</param>
        /// <param name="contactEmail">Contact e-mail for the site. May be null.</param>
        /// <param name="contactPhone">Contact phone for the site. May be null.</param>
        /// <param name="name">System product name. May be null.</param>
        /// <param name="description">System description. May be null.</param>
        /// <param name="vendor">System vendor. May be null.</param>
        /// <param name="programVersion">System version. May be null.</param>
        Capabilities(WitsmlVersion version,
                     bool isServer,
                     String contactName,
                     String contactEmail,
                     String contactPhone,
                     String name,
                     String description,
                     String vendor,
                     String programVersion)
        {
            this._isServer     = isServer;
            this.functions     = isServer ? new List <FunctionCapability>() : null;
            this.witsmlVersion = version != null?version.getVersion() : null;

            this.contactName    = contactName;
            this.contactEmail   = contactEmail;
            this.contactPhone   = contactPhone;
            this.name           = name;
            this.description    = description;
            this.vendor         = vendor;
            this.programVersion = programVersion;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Create a capabilities instance by parsing the specified WITSML string.
        /// </summary>
        /// <param name="version">XML defining the capabilities.</param>
        /// <param name="xml"></param>
        internal Capabilities(WitsmlVersion version, String xml)
        {
            if (version == null)
            {
                throw new ArgumentException("version cannot be null.");
            }
            if (xml == null)
            {
                throw new ArgumentException("xml cannot be null");
            }

            String witsmlVersionTmp  = null;
            String contactNameTmp    = null;
            String contactEmailTmp   = null;
            String contactPhoneTmp   = null;
            String nameTmp           = null;
            String descriptionTmp    = null;
            String vendorTmp         = null;
            String programVersionTmp = null;

            //SAXBuilder builder = new SAXBuilder();

            try
            {
                XDocument document = XDocument.Load(new StringReader(xml));
                XElement  root     = document.Root; //.getRootElement();
                //Debug.Assert(root != null; //TODO: Can this happen? Throw illegal arg exception?

                XNamespace @namespace       = root.Name.Namespace;                    //.getNamespace();
                XElement   capServerElement = root.Element(@namespace + "capServer"); //, @namespace);
                XElement   capClientElement = root.Element(@namespace + "capClient"); //, @namespace);

                _isServer = capServerElement != null;
                functions = _isServer ? new List <FunctionCapability>() : null;

                XElement capElement = _isServer ? capServerElement : capClientElement;

                if (capElement != null)
                {
                    witsmlVersionTmp = capElement.Attribute("apiVers").Value;

                    XElement contactElement = capElement.Element(@namespace + "contact");//, @namespace);
                    if (contactElement != null)
                    {
                        contactNameTmp  = contactElement.Element(contactElement.Name.Namespace + "name").Value.Trim();  //, contactElement.Name.Namespace.getNamespace());
                        contactEmailTmp = contactElement.Element(contactElement.Name.Namespace + "email").Value.Trim(); //, contactElement.getNamespace());
                        contactPhoneTmp = contactElement.Element(contactElement.Name.Namespace + "phone").Value.Trim(); //, contactElement.getNamespace());
                    }

                    nameTmp           = capElement.Element(capElement.Name.Namespace + "name").Value;        //, capElement.getNamespace());
                    descriptionTmp    = capElement.Element(capElement.Name.Namespace + "description").Value; //, capElement.getNamespace());
                    vendorTmp         = capElement.Element(capElement.Name.Namespace + "vendor").Value;      //, capElement.getNamespace());
                    programVersionTmp = capElement.Element(capElement.Name.Namespace + "version").Value;     //, capElement.getNamespace());

                    var functionElements = capElement.Elements(@namespace + "function");                     //, @namespace);

                    foreach (XElement functionElement in functionElements)
                    {
                        String functionName    = functionElement.Attribute("name").Value;
                        String functionVersion = functionElement.Attribute("apiVers").Value;

                        FunctionCapability function = new FunctionCapability(functionName, functionVersion);

                        var dataObjectElements = functionElement.Elements(@namespace + "dataObject");

                        foreach (XElement dataObjectElement in dataObjectElements)
                        {
                            String dataObject = dataObjectElement.Value.Trim();
                            function.addWitsmlType(dataObject);
                        }
                        addFunction(function);
                    }
                }

                witsmlVersion  = witsmlVersionTmp;
                contactName    = contactNameTmp;
                contactEmail   = contactEmailTmp;
                contactPhone   = contactPhoneTmp;
                name           = nameTmp;
                description    = descriptionTmp;
                vendor         = vendorTmp;
                programVersion = programVersionTmp;
            }

            catch (IOException exception)
            {
                // Convert to a non-IO exception to hide implementation details of this class.
                throw new WitsmlParseException(xml, exception);
            }
            catch (Exception /*JDOMException */ exception)
            {
                // Convert to a non-JDOM exception to hide implementation details of this class.
                throw new WitsmlParseException(xml, exception);
            }
        }