/** * Create a log curve instance. * * @param log Parent log. Non-null. * @param name Name of curve. Non-null. * @param curveNo Curve number. */ internal WitsmlLogCurve(witsmllib.WitsmlLog log, String name, int curveNo) : base(log, name, curveNo) { }
/// <summary> /// Parse the specified DOM element and instantiate the properties of this instance. /// </summary> /// <param name="element">element XML element to parse. Non-null.</param> void update(XElement element) { if (element == null) { throw new ArgumentNullException("element cannot be null"); } // Remove current bulk data foreach (witsmllib.WitsmlLogCurve curve in curves) { ((WitsmlLogCurve)curve).clear(); } // Common data XElement commonDataElement = element.Element(element.Name.Namespace + "commonData"); //, element.getNamespace()); if (commonDataElement != null) { commonData = new WitsmlCommonData(commonDataElement); } // Index indexType = XmlUtil.update(element, "indexType", indexType); if (indexType != null) { if (indexType.ToLower().Contains("time")) { startIndex = getIndex(XmlUtil.update(element, "startDateTimeIndex", (String)null)); endIndex = getIndex(XmlUtil.update(element, "endDateTimeIndex", (String)null)); } else { startIndex = getIndex(XmlUtil.update(element, "startIndex", (String)null)); endIndex = getIndex(XmlUtil.update(element, "endIndex", (String)null)); } } indexCurveName = XmlUtil.update(element, "indexCurve", indexCurveName); _isGrowing = XmlUtil.update(element, "objectGrowing", _isGrowing); nRows = XmlUtil.update(element, "dataRowCount", nRows); serviceCompany = XmlUtil.update(element, "serviceCompany", serviceCompany); runNumber = XmlUtil.update(element, "runNumber", runNumber); bhaRunNumber = XmlUtil.update(element, "bhaRunNumber", bhaRunNumber); pass = XmlUtil.update(element, "pass", pass); creationTime = XmlUtil.update(element, "creationDate", creationTime); description = XmlUtil.update(element, "description", description); direction = XmlUtil.update(element, "direction", direction); stepIncrement = XmlUtil.update(element, "stepIncrement", stepIncrement); indexUnit = XmlUtil.update(element, "indexUnits", indexUnit); noValue = XmlUtil.update(element, "nullValue", noValue); unitNamingSystem = XmlUtil.update(element, "uomNamingSystem", unitNamingSystem); comment = XmlUtil.update(element, "otherData", comment); // Curve data var logCurveInfoElements = element.Elements(element.Name.Namespace + "logCurveInfo"); //, element.getNamespace()); foreach (Object e in logCurveInfoElements) { XElement logCurveInfoElement = (XElement)e; String curveName = XmlUtil.update(logCurveInfoElement, "mnemonic", (String)null); Int32? curveNo = XmlUtil.update(logCurveInfoElement, "columnIndex", (Int32?)null); WitsmlLogCurve curve = (WitsmlLogCurve)findCurve(curveName); if (curve == null) { curve = new WitsmlLogCurve(this, curveName, curveNo.Value); curves.Add(curve); } curve.update(logCurveInfoElement); } // Bulk data XElement logDataElement = element.Element(element.Name.Namespace + "logData"); //, element.getNamespace()); if (logDataElement != null) { var dataElements = logDataElement.Elements(element.Name.Namespace + "data"); //, element.getNamespace()); //for (var j = dataElements.iterator(); j.hasNext(); ) foreach (var j in dataElements) { XElement dataElement = (XElement)j; //.next(); String valueString = dataElement.Value.Trim(); //.getTextTrim(); String[] tokens = valueString.Split(dataDelimiter); //, -1); for (int i = 0; i < tokens.Length; i++) { String token = tokens[i]; if (token.Equals(noValue)) { token = ""; } WitsmlLogCurve curve = (witsmllib.v131.WitsmlLogCurve)findCurve(i + 1); curve.addValue(token); } // Handle missing log values for (int i = tokens.Length; i < getNCurves(); i++) { WitsmlLogCurve curve = (witsmllib.v131.WitsmlLogCurve)findCurve(i + 1); curve.addValue(null); } } } else //We didn't get the Curves, we have to ask again, because server does not support multi log and logData request at the same time. { if (this.curves.Where(x => x.getValues().Count() == 0).Count() > 0) { witsmllib.WitsmlLog newLogObject = base.getWitsmlServer().getOne <witsmllib.WitsmlLog>(this, new WitsmlQuery(), this.getId()); foreach (var item in newLogObject.getCurves()) { int index = item.getCurveNo(); if (this.curves[index - 1].getValues().Count() == 0) { this.curves[index - 1] = item; } } } if (this.curves.Where(x => x.getValues().Count() == 0).Count() > 0) { throw new Exception("Count not get all Curve Object for this curve"); } } unitConvert(); }