public void AddAttributeTable(IFeature pFeature, ParkSite pPathPoint, int j) { try { pFeature.set_Value(pFeature.Fields.FindField("SzID"), pPathPoint.szID); pFeature.set_Value(pFeature.Fields.FindField("Changed"), pPathPoint.szSymbolChanged); pFeature.set_Value(pFeature.Fields.FindField("Symbol"), pPathPoint.szSymbol); pFeature.set_Value(pFeature.Fields.FindField("BegineTime"), "到达时间:" + pPathPoint.szBeginTime); pFeature.set_Value(pFeature.Fields.FindField("LeaveTime"), "离开时间:" + pPathPoint.szLeaveTime); pFeature.set_Value(pFeature.Fields.FindField("WorkModeNum"), pPathPoint.uiWorkModeNum); for (int i = 0; i <= 7; i++) { pFeature.set_Value(pFeature.Fields.FindField("Mode_" + i.ToString() + "_symbol"), pPathPoint.ST_WorkModes[i].szSymbol); pFeature.set_Value(pFeature.Fields.FindField("Mode_" + i.ToString() + "_Slice"), pPathPoint.ST_WorkModes[i].dSlice); pFeature.set_Value(pFeature.Fields.FindField("Mode_" + i.ToString() + "_AssSlice"), pPathPoint.ST_WorkModes[i].dAssignSlice); pFeature.set_Value(pFeature.Fields.FindField("Mode_" + i.ToString() + "_BeginTime"), pPathPoint.ST_WorkModes[i].szBeginTime); pFeature.set_Value(pFeature.Fields.FindField("Mode_" + i.ToString() + "_EndTime"), pPathPoint.ST_WorkModes[i].szEndTime); } pFeature.Store(); } catch (Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } }
public bool ReadParkXML(string XMLPath) { try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(XMLPath); XmlNode xn = xmlDoc.SelectSingleNode(@"cmlRoot/szMacroNum"); if (xn != null) { szMacroNum = xn.InnerText; } xn = xmlDoc.SelectSingleNode(@"cmlRoot/szCyNum"); if (xn != null) { szCyNum = xn.InnerText; } xn = xmlDoc.SelectSingleNode(@"cmlRoot/stBeginCoord/dX"); if (xn != null) { stBeginCoord.dx = double.Parse(xn.InnerText); } xn = xmlDoc.SelectSingleNode(@"cmlRoot/stBeginCoord/dY"); if (xn != null) { stBeginCoord.dy = double.Parse(xn.InnerText); } xn = xmlDoc.SelectSingleNode(@"cmlRoot/stEndCoord/dX"); if (xn != null) { stEndCoord.dx = double.Parse(xn.InnerText); } xn = xmlDoc.SelectSingleNode(@"cmlRoot/stEndCoord/dY"); if (xn != null) { stEndCoord.dy = double.Parse(xn.InnerText); } xn = xmlDoc.SelectSingleNode(@"cmlRoot/uiPathRslt"); if (xn != null) { uiPathRslt = int.Parse(xn.InnerText); if (uiPathRslt == 0) { xn = xmlDoc.SelectSingleNode(@"cmlRoot/uiParkNum"); uiParkNum = int.Parse(xn.InnerText); ParkSList = new List <ParkSite>(uiParkNum); XmlNodeList xnl = xmlDoc.SelectNodes(@"cmlRoot/stParkSite"); foreach (XmlNode xNode in xnl) { ParkSite ParkSiteTemp = new ParkSite(); XmlNode xmlnode = xNode.SelectSingleNode("szID"); if (xmlnode != null) { ParkSiteTemp.szID = xmlnode.InnerText; } xmlnode = xNode.SelectSingleNode("szSymbolChanged"); if (xmlnode != null) { ParkSiteTemp.szSymbolChanged = xmlnode.InnerText; } xmlnode = xNode.SelectSingleNode("szSymbol"); if (xmlnode != null) { ParkSiteTemp.szSymbol = xmlnode.InnerText; } xmlnode = xNode.SelectSingleNode("szBeginTime"); if (xmlnode != null) { ParkSiteTemp.szBeginTime = xmlnode.InnerText; } xmlnode = xNode.SelectSingleNode("szLeaveTime"); if (xmlnode != null) { ParkSiteTemp.szLeaveTime = xmlnode.InnerText; } xmlnode = xNode.SelectSingleNode("szTimeValid"); if (xmlnode != null) { ParkSiteTemp.szTimeValid = xmlnode.InnerText; } xmlnode = xNode.SelectSingleNode("szPosStatus"); if (xmlnode != null) { ParkSiteTemp.szPosStatus = xmlnode.InnerText; } xmlnode = xNode.SelectSingleNode(@"stCoord/dX"); if (xmlnode != null) { ParkSiteTemp.stCoord.dy = double.Parse(xmlnode.InnerText);//坐标系x=y } xmlnode = xNode.SelectSingleNode(@"stCoord/dY"); if (xmlnode != null) { ParkSiteTemp.stCoord.dx = double.Parse(xmlnode.InnerText);//坐标系y=x } xmlnode = xNode.SelectSingleNode("uiWorkModeNum"); if (xmlnode != null) { ParkSiteTemp.uiWorkModeNum = int.Parse(xmlnode.InnerText); } XmlNodeList WorkModeNode = xNode.SelectNodes("stWorkMode"); int i = 0; foreach (XmlNode wmN in WorkModeNode) { XmlNode workModeNode = wmN.SelectSingleNode("szSymbol"); ParkSiteTemp.ST_WorkModes[i].szSymbol = workModeNode.InnerText; workModeNode = wmN.SelectSingleNode("szID"); ParkSiteTemp.ST_WorkModes[i].szID = workModeNode.InnerText; //workModeNode = wmN.SelectSingleNode("szName"); //ParkSiteTemp.ST_WorkModes[i].szName = workModeNode.InnerText; workModeNode = wmN.SelectSingleNode("dSlice"); ParkSiteTemp.ST_WorkModes[i].dSlice = double.Parse(workModeNode.InnerText); workModeNode = wmN.SelectSingleNode("dAssignSlice"); ParkSiteTemp.ST_WorkModes[i].dAssignSlice = double.Parse(workModeNode.InnerText); workModeNode = wmN.SelectSingleNode("szBeginTime"); ParkSiteTemp.ST_WorkModes[i].szBeginTime = workModeNode.InnerText; workModeNode = wmN.SelectSingleNode("szEndTime"); ParkSiteTemp.ST_WorkModes[i].szEndTime = workModeNode.InnerText; //workModeNode = wmN.SelectSingleNode("dEndEnergy"); //ParkSiteTemp.ST_WorkModes[i].dEndEnergy = double.Parse(workModeNode.InnerText); i++; } ParkSList.Add(ParkSiteTemp); } } else if (uiPathRslt == 1) { MessageBox.Show("目标点不可达", "提示", MessageBoxButtons.OK); } else if (uiPathRslt == 2) { MessageBox.Show("导航点个数不够", "提示", MessageBoxButtons.OK); } } return(true); } catch (System.Exception ex) { return(false); } }