internal void DeleteLayer(RedlineLayer layer) { var regId = GetRegistryFeatureSource(); MgFeatureCommandCollection commands = new MgFeatureCommandCollection(); MgDeleteFeatures delete = new MgDeleteFeatures("Default:MarkupRegistry", "ResourceId = '" + layer.FeatureSource + "'"); commands.Add(delete); MgPropertyCollection results = _featSvc.UpdateFeatures(regId, commands, false); MgInt32Property deleteResult = results.GetItem(0) as MgInt32Property; if (deleteResult != null && deleteResult.GetValue() > 0) { var ldfId = new MgResourceIdentifier(layer.LayerDefinition); var fsId = new MgResourceIdentifier(layer.FeatureSource); if (_resSvc.ResourceExists(ldfId)) { _resSvc.DeleteResource(ldfId); } if (_resSvc.ResourceExists(fsId)) { _resSvc.DeleteResource(fsId); } } }
private void button1_Click(object sender, EventArgs e) { try { var fact = new MgdServiceFactory(); MgResourceService resSvc = (MgResourceService)fact.CreateService(MgServiceType.ResourceService); MgResourceIdentifier resId = new MgResourceIdentifier(textBox1.Text); resSvc.DeleteResource(resId); MessageBox.Show("Success"); } catch (MgException ex) { MessageBox.Show(ex.ToString(), "Error from MapGuide"); } }