using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Server;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.SOESupport;
using ESRI.ArcGIS.DataSourcesRaster;
//TODO: sign the project (project properties > signing tab > sign the assembly)
// this is strongly suggested if the dll will be registered using regasm.exe <your>.dll /codebase
namespace NetEditFeaturesRESTSOE
{
[ComVisible(true)]
[Guid("6d79a67b-27d2-4a7f-85a3-6bf6fab061df")]
[ClassInterface(ClassInterfaceType.None)]
[ServerObjectExtension("MapServer",
AllCapabilities = "",
DefaultCapabilities = "",
Description = ".Net Edit features SOE - allows feature validation and editing.",
DisplayName = ".Net Edit Features REST SOE",
Properties = "layerId=0",
SupportsREST = true,
SupportsSOAP = false)]
public class NetEditFeaturesRESTSOE : IServerObjectExtension, IObjectConstruct, IRESTRequestHandler
{
private string soe_name;
private IPropertySet configProps;
private IServerObjectHelper serverObjectHelper;
private ServerLogger logger;
private IRESTRequestHandler reqHandler;
private IMapServerInfo mapServerInfo = null;
private IMapServerDataAccess mapServerDataAccess = null;
private IMapLayerInfos layerInfos = null;
private IMapLayerInfo editLayerInfo = null;
private int layerId = -1;
private IFeatureClass fc = null;
public NetEditFeaturesRESTSOE()
{
soe_name = this.GetType().Name;
logger = new ServerLogger();
reqHandler = new SoeRestImpl(soe_name, CreateRestSchema()) as IRESTRequestHandler;
}
#region IServerObjectExtension Members
public void Init(IServerObjectHelper pSOH)
{
serverObjectHelper = pSOH;
mapServerDataAccess = (IMapServerDataAccess)pSOH.ServerObject;
IMapServer3 ms = (IMapServer3)pSOH.ServerObject;
this.mapServerInfo = ms.GetServerInfo(ms.DefaultMapName);
this.layerInfos = mapServerInfo.MapLayerInfos;
if (layerId < 0)
layerId = 0;
}
public void Shutdown()
{
}
#endregion
#region IObjectConstruct Members
public void Construct(IPropertySet props)
{
configProps = props;
string lid = (string)props.GetProperty("layerId");
this.layerId = Convert.ToInt32(lid);
this.fc = (IFeatureClass) this.mapServerDataAccess.GetDataSource(this.mapServerInfo.Name, this.layerId);
this.editLayerInfo = this.layerInfos.get_Element(this.layerId);
}
#endregion
#region IRESTRequestHandler Members
public string GetSchema()
{
return reqHandler.GetSchema();
}
public byte[] HandleRESTRequest(string Capabilities, string resourceName, string operationName, string operationInput, string outputFormat, string requestProperties, out string responseProperties)
{
return reqHandler.HandleRESTRequest(Capabilities, resourceName, operationName, operationInput, outputFormat, requestProperties, out responseProperties);
}
#endregion
放不下了,网址在这
soe](https://github.com/Esri/arcobjects-sdk-community-samples/blob/master/Net/Server/ServerEditFeaturesRESTSOE/CSharp/EditFeaturesRESTSOE/NetEditFeaturesRESTSOE.cs "")