private void GetLayerNode(Layer lyr, XmlDocument doc) { Layer plyr = MapView.Active.Map.FindLayer(lyr.URI, true); MapMember mm = lyr; XmlNode lnd; lnd = doc.SelectSingleNode("//Layers/String[text()='" + lyr.URI + "']"); CIMService cs = new MapMemberService((MapMember)lyr); //var xmlLayer = GetlayerDefinitionAsync(lyr); var xmlLayer = cs.GetDefinitionAsync(); XmlDocumentFragment xfrag = doc.CreateDocumentFragment(); xfrag.InnerXml = xmlLayer.Result; XmlNode nd = xfrag.FirstChild; switch (lyr.GetType().Name) { case "GroupLayer": lnd.AppendChild(xfrag); GroupLayer glyr = (GroupLayer)lyr; foreach (var layer in glyr.Layers) { lnd = doc.SelectSingleNode("//Layers/String[text()='" + lyr.URI + "']"); GetLayerNode(layer, doc); } break; case "FeatureLayer": var cfl = CIMFeatureLayer.FromXml(xmlLayer.Result); GetRenderer(cfl.Renderer, nd, ReportDir); lnd.AppendChild(nd); break; case "RasterLayer": var crl = CIMRasterLayer.FromXml(xmlLayer.Result); //GetRenderer(crl., nd, ReportDir); lnd.AppendChild(nd); break; case "StandaloneTable": lnd = doc.SelectSingleNode("//StandaloneTables/String[text()='" + lyr.URI + "']"); lnd.AppendChild(nd); break; default: lnd.AppendChild(nd); break; } }
private Task saveReport(string xml, string outputDir) { return(QueuedTask.Run(() => { var doc = new XmlDocument(); try { doc.LoadXml(xml); XmlNodeList nodelist = doc.ChildNodes; string str = ""; foreach (XmlNode node in nodelist) { XmlNode nd = node.SelectSingleNode("URI"); string _URIPath = nd.InnerText.Replace("CIMPATH=", ""); string _outPath = System.IO.Path.Combine(outputDir, System.IO.Path.GetDirectoryName(_URIPath)); string _URIFileName = System.IO.Path.GetFileNameWithoutExtension(_URIPath); string _URIimgPath = System.IO.Path.Combine(_outPath, "img\\" + _URIFileName); //string fname = nd.InnerText.Replace("CIMPATH=", "").Replace("/", "_").Replace(".xml", ""); switch (node.Name) { case "CIMFeatureLayer": var cfl = CIMFeatureLayer.FromXml(xml); GetRenderer(cfl.Renderer, node, outputDir); str = TransformDocument(doc.InnerXml, System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), @"Stylesheet\CIMFeatureLayer.xslt"), System.IO.Path.Combine(_outPath, _URIFileName)); break; case "CIMMap": str = TransformDocument(xml, System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), @"Stylesheet\CIMMap.xslt"), System.IO.Path.Combine(_outPath, _URIFileName)); exportMapContent(xml, outputDir); break; case "CIMGroupLayer": str = TransformDocument(xml, System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), @"Stylesheet\CIMGroupLayer.xslt"), System.IO.Path.Combine(_outPath, _URIFileName)); break; default: str = TransformDocument(xml, System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), @"Stylesheet\CIMFeatureLayer.xslt"), System.IO.Path.Combine(_outPath, _URIFileName)); break; } } return doc; } catch (System.Xml.XmlException xmle) { return null; } })); }