public string MakeDateFromDouble(string data, Las las) { DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0); DateTime startDateTime = las.StartDateTimeIndex; var dtf = startDateTime.Subtract(dtDateTime).TotalSeconds; var offset = Parsing.ParseDouble(data); dtDateTime = dtDateTime.AddSeconds(dtf + offset); //if (dtf < 86400000 && offset != 0) //{ // dtDateTime = dtDateTime.AddSeconds(dtf + offset); //} //else //{ // dtDateTime = dtDateTime.AddSeconds(dtf); //} return(dtDateTime.ToString()); }
// Главный процесс // public void FromLasFile(Las las, string uidWell, string uidWellbore, string uid, string name) { //var digestLas = DigestLas(las); //List<LogCurveInfo> newLcis = (List<LogCurveInfo>)digestLas[0]; //LogCurveInfo indexLci = (LogCurveInfo)digestLas[1]; //var isIndexIndex = digestLas[2]; //var getIndex = digestLas[3]; List <LogCurveInfo> newLcis = new List <LogCurveInfo>(); newLcis = las.LogCurveInfos; var ns = ""; var vers = ""; if (WitsmlVersion >= 1410) { ns = "http://www.witsml.org/schemas/1series"; vers = "1.4.1.0"; } else { ns = "http://www.witsml.org/schemas/131"; vers = "1.3.1.1"; } var indexCurve = newLcis[0].Mnemonic; xmlWriter.Formatting = Formatting.Indented; xmlWriter.Indentation = 4; xmlWriter.WriteStartDocument(); xmlWriter.WriteStartElement("logs"); xmlWriter.WriteAttributeString("xmlns", ns); xmlWriter.WriteAttributeString("version", vers); xmlWriter.WriteStartElement("log"); xmlWriter.WriteAttributeString("uidWell", uidWell); xmlWriter.WriteAttributeString("uidWellbore", uidWellbore); xmlWriter.WriteAttributeString("uid", uid); xmlWriter.WriteElementString("nameWell", name); xmlWriter.WriteElementString("nameWellbore", name); xmlWriter.WriteElementString("name", name); xmlWriter.WriteElementString("serviceCompany", las.ServiceCompany ?? ""); xmlWriter.WriteElementString("description", "Created by lab212"); var measureDepthUnit = ""; try { measureDepthUnit = NormalizeUnit(las.MeasuredDepthUnit); } catch (UnrecognizedUnitException e) { conversionError.badUnits.Add("measured depth", e.Message); measureDepthUnit = "unitless"; } if (!String.IsNullOrEmpty(measureDepthUnit)) { xmlWriter.WriteElementString("indexType", "measured depth"); //xmlWriter.WriteElementString("startIndex", las.StartMeasuredDepthIndex.ToString().Replace(',','.')); xmlWriter.WriteStartElement("startIndex"); xmlWriter.WriteAttributeString("uom", measureDepthUnit); xmlWriter.WriteString(las.StartMeasuredDepthIndex.ToString().Replace(',', '.')); xmlWriter.WriteEndElement(); //xmlWriter.WriteElementString("endIndex", las.StopMeasuredDepthIndex.ToString().Replace(',', '.')); xmlWriter.WriteStartElement("endIndex"); xmlWriter.WriteAttributeString("uom", measureDepthUnit); xmlWriter.WriteString(las.StopMeasuredDepthIndex.ToString().Replace(',', '.')); xmlWriter.WriteEndElement(); } else { xmlWriter.WriteElementString("indexType", "date time"); xmlWriter.WriteElementString("startDateTimeIndex", las.StartDateTimeIndex.ToString().Replace(',', '.')); xmlWriter.WriteElementString("endDateTimeIndex", las.StopDateTimeIndex.ToString().Replace(',', '.')); } if (WitsmlVersion >= 1410) { xmlWriter.WriteElementString("indexCurve", indexCurve); } else { //xmlWriter.WriteStartElement("indexCurve", indexLci.Mnemonic); //xmlWriter.WriteAttributeString("columnIndex", "1"); //xmlWriter.WriteEndElement(); } xmlWriter.WriteElementString("nullValue", las.NullValue.ToString()); foreach (var lci in newLcis.Select((x, i) => new { Value = x, Index = i })) { try { if (String.IsNullOrEmpty(las.MeasuredDepthUnit)) { var start = las.StartDateTimeIndex.ToString(); var stop = las.StopDateTimeIndex.ToString(); AddLogCurveInfo(lci.Value, lci.Index, start, stop, measureDepthUnit); // error } else { var start = las.StartMeasuredDepthIndex.ToString(); var stop = las.StopMeasuredDepthIndex.ToString(); AddLogCurveInfo(lci.Value, lci.Index, start, stop, measureDepthUnit); // error } } catch (UnrecognizedUnitException ee) { badUnits.Add(lci.Value.Mnemonic, ee.Message); } } if (badUnits.Count == 0) { xmlWriter.WriteStartElement("logData"); if (WitsmlVersion >= 1410) { var listMnemonic = ""; var listUnit = ""; foreach (var lci in newLcis) { listMnemonic += lci.Mnemonic + ","; listUnit += lci.Unit + ","; } xmlWriter.WriteElementString("mnemonicList", listMnemonic); xmlWriter.WriteElementString("unitList", listUnit); } // Вот здесь записываются все значения data las.EachDataLine(this); } xmlWriter.WriteEndElement(); xmlWriter.WriteEndElement(); xmlWriter.WriteEndElement(); xmlWriter.Close(); OutputStream.Close(); }