GIS的积累
It is never to late to learn

导航

 

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、 去掉“使用简单文件共享(推荐)”选项
posted on 2011-02-14 15:05  GIS的学习  阅读(427)  评论(0编辑  收藏  举报