public static void insertWell(string filePathSelectTemplatelate, string sJH, ItemWellSection itemInsert, int iBefore) { XElement wellNode = setWellNode(filePathSelectTemplatelate, itemInsert); XDocument XsingleWellStyleRoot = XDocument.Load(filePathSelectTemplatelate); XElement wellCol = XsingleWellStyleRoot.Element("SectionMap").Element("WellCollection"); //判断是否存在,存在删除 var currentNode = wellCol.Elements("well").SingleOrDefault(x => x.Attribute("id").Value == sJH); if (currentNode != null) { if (iBefore == 0) { currentNode.AddAfterSelf(wellNode); } else { currentNode.AddBeforeSelf(wellNode); } } else { wellCol.Add(wellNode); } XsingleWellStyleRoot.Save(filePathSelectTemplatelate); }
public static void updateWell(string filePathSelectTemplatelate, ItemWellSection item) { XElement wellNode = setWellNode(filePathSelectTemplatelate, item); XDocument XsingleWellStyleRoot = XDocument.Load(filePathSelectTemplatelate); XElement wellCol = XsingleWellStyleRoot.Element("SectionMap").Element("WellCollection"); //判断是否存在,存在删除 var currentNode = wellCol.Elements("well").SingleOrDefault(x => x.Attribute("id").Value == item.sJH); if (currentNode != null) { currentNode.Remove(); } wellCol.Add(wellNode); XsingleWellStyleRoot.Save(filePathSelectTemplatelate); }
public static XElement setWellNode(string filePathSelectTemplatelate, ItemWellSection item) { XElement wellNode = new XElement("well", new XAttribute("id", item.sJH)); wellNode.Add(new XElement("JH", item.sJH)); wellNode.Add(new XElement("X", item.dbX)); wellNode.Add(new XElement("Y", item.dbY)); wellNode.Add(new XElement("kb", item.fKB)); wellNode.Add(new XElement("fShowTop", item.fShowedDepthTop)); wellNode.Add(new XElement("fShowBot", item.fShowedDepthBase)); wellNode.Add(new XElement("iTypeWell", item.iWellType)); wellNode.Add(new XElement("fWellBase", item.fWellBase)); wellNode.Add(new XElement("Xview", item.fXview.ToString())); wellNode.Add(new XElement("Yview", item.fYview.ToString())); wellNode.Add(new XElement("XviewTrackList")); return(wellNode); }
public static List <ItemWellSection> makeListWellSection(string filePathSectionGeoCss) { List <ItemWellSection> listWellsSection = new List <ItemWellSection>(); foreach (XmlElement elWell in cXmlDocSectionGeo.getWellNodes(filePathSectionGeoCss)) { if (elWell["JH"].InnerText != "") { ItemWellSection item = new ItemWellSection(elWell["JH"].InnerText); item.fShowedDepthTop = float.Parse(elWell["fShowTop"].InnerText); item.fShowedDepthBase = float.Parse(elWell["fShowBot"].InnerText); item.fXview = float.Parse(elWell["Xview"].InnerText); item.fYview = float.Parse(elWell["Yview"].InnerText); listWellsSection.Add(item); } } return(listWellsSection); }