/// <summary> /// Method to execute the command. /// </summary> /// <remarks>The default implementation calls the implemented Restorestate before and Savestate after the Process method. /// The Process method is where the operation is performed. /// </remarks> public virtual void Execute() { StateManager sm = StateManager.GetStateManagerFromSession(); if (sm == null) { if (StateManager.IsManualState()) { throw new NullReferenceException(L10NUtils.Resources.GetString(StateManager.StateManagerResErr1)); } } ParseContext(); if (sm != null) { PrepareStateManagerParamsDictionary(sm); sm.RestoreState(); } Process(); if (sm != null) { sm.SaveState(); } }
/// <summary> /// Gets the XML containing the layer information to be used to transform to HTML. /// </summary> /// <remarks>This method goes through the map's layers and adds them to the XML document in the format which XSLT is expecting.</remarks> /// <param name="mapAlias">MapAlias of the map.</param> /// <param name="uniqueID">Unique ID of the LayerControl.</param> /// <param name="imgPath">Path to images and XSLT files.</param> /// <returns>Returns XML containing layer information.</returns> public XmlDocument GetLayerXML(string mapAlias, string uniqueID, string imgPath) { _mapAlias = mapAlias; StateManager sm = StateManager.GetStateManagerFromSession(); if (sm == null) { if (StateManager.IsManualState()) { throw new NullReferenceException(L10NUtils.Resources.GetString(StateManager.StateManagerResErr1)); } } if (sm != null) { sm.ParamsDictionary[StateManager.ActiveMapAliasKey] = _mapAlias; sm.RestoreState(); } Map map = GetMapObj(_mapAlias); XmlDocument _doc = null; _doc = InitDocument(new XmlDocument()); XmlElement root = _doc.DocumentElement; XmlElement custParam = _doc.CreateElement("custom-parameters"); XmlElement param1 = _doc.CreateElement("param"); param1.SetAttribute("name", "", "param-shift-width"); param1.SetAttribute("value", "", "15"); custParam.AppendChild(param1); XmlElement param2 = _doc.CreateElement("param"); param2.SetAttribute("name", "", "img-directory"); param2.SetAttribute("value", "", imgPath + "/"); custParam.AppendChild(param2); XmlElement param3 = _doc.CreateElement("param"); param3.SetAttribute("name", "", "mapzoom"); param3.SetAttribute("value", "", map.Zoom.Value.ToString()); custParam.AppendChild(param3); root.AppendChild(custParam); XmlElement topMost = _doc.CreateElement("branch"); topMost.SetAttribute("title", "", map.Name); topMost.SetAttribute("img", null, "lcgroup.bmp"); topMost.SetAttribute("branchtype", "", "folder"); topMost.SetAttribute("expanded", null, "true"); topMost.SetAttribute("nocheckbox", null, "true"); root.AppendChild(topMost); foreach (IMapLayer layer in map.Layers) { if (layer is LabelLayer) { topMost.AppendChild(CreateLabelLayerElement(_doc, layer, uniqueID)); } else if (layer is ObjectThemeLayer) { topMost.AppendChild(CreateObjectThemeElement(_doc, layer, uniqueID)); } else if (layer is FeatureLayer) { topMost.AppendChild(CreateFeatureLayerElement(_doc, layer, uniqueID)); } else if (layer is GroupLayer) { topMost.AppendChild(CreateGroupLayerElement(_doc, layer, uniqueID)); } } if (sm != null) { sm.SaveState(); } return(_doc); }