• WebServices调用AO的方法


    1 服务器端代码:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    using ESRI.ArcGIS.esriSystem;
    using ESRI.ArcGIS.DataSourcesGDB;
    using ESRI.ArcGIS.Geodatabase;
    using ESRI.ArcGIS.Geometry;
    using ESRI.ArcGIS.DataSourcesFile;

    [WebService(Namespace
    = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo
    = WsiProfiles.BasicProfile1_1)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
    // [System.Web.Script.Services.ScriptService]
    public class Service : System.Web.Services.WebService
    {
    public Service () {

    //如果使用设计的组件,请取消注释以下行
    //InitializeComponent();
    }

    [WebMethod]
    public string HelloWorld()
    {
    return "Hello World";
    }
    [WebMethod]
    public bool AddPointToFileGDB(double x, double y)
    {
    IAoInitialize aoInit
    = new AoInitializeClass();
    aoInit.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcServer);


    IWorkspaceFactory pWSF
    = new ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactoryClass() as IWorkspaceFactory;
    ESRI.ArcGIS.esriSystem.IPropertySet pPropertySet
    = new ESRI.ArcGIS.esriSystem.PropertySetClass();
    pPropertySet.SetProperty(
    "DATABASE", @"D:\数据\New File Geodatabase.gdb");
    IFeatureWorkspace pFW
    = pWSF.Open(pPropertySet, 0) as IFeatureWorkspace;

    IPoint pPoint
    = new PointClass();
    pPoint.X
    = x;
    pPoint.Y
    = y;

    IFeatureClass pFC
    = pFW.OpenFeatureClass("point");

    IFeature pF
    = pFC.CreateFeature();
    pF.Shape
    = pPoint;
    pF.Store();

    return true;
    }
    }

    2 客户端代码:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class _Default : System.Web.UI.Page 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            addpointserver.Service se = new addpointserver.Service();
            se.AddPointToFileGDBCompleted += new addpointserver.AddPointToFileGDBCompletedEventHandler(se_AddPointToFileGDBCompleted);
            se.AddPointToFileGDBAsync(double.Parse(TextBox1.Text),double.Parse( TextBox2.Text));
           
            
        }
    
        void se_AddPointToFileGDBCompleted(object sender, addpointserver.AddPointToFileGDBCompletedEventArgs e)
        {
            Response.Write("done!");
        }
    }
    

    3 注意事项:file gdb所在所在目录必须有 ASPNET角色和NETWorkService角色的读写权限,不然不能读写

    4 怎么才能在WinXP下,使得文件夹属性页有“安全”标签页呢?解决方法如下:

    1、 打开资源管理器
    2、 进入 工具——文件夹选项 菜单,切换到“查看”标签页
    3、 去掉“使用简单文件共享(推荐)”选项
  • 相关阅读:
    FLINK 设计文档
    prometheus-dashboard-to-grafana
    apache-flink-training-metrics-monitoring
    多个inputstream的情况下,watermark的值怎么赋值? kakfa中多个partition提取 watermark
    how-apache-flink-enables-new-streaming-applications-part-1
    Advanced DataStream API Low-latency Event Time Join
    checkpoint and savepoint in FlinK
    Flink connectedstreams
    FLINK 案例分析
    Apache 流框架 Flink,Spark Streaming,Storm对比分析(一)
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/1954353.html
Copyright © 2020-2023  润新知