惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

腾讯CDC
Schneier on Security
Schneier on Security
B
Blog RSS Feed
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
A
About on SuperTechFans
Recorded Future
Recorded Future
Recent Announcements
Recent Announcements
Microsoft Security Blog
Microsoft Security Blog
L
LangChain Blog
Hugging Face - Blog
Hugging Face - Blog
The GitHub Blog
The GitHub Blog
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
Vercel News
Vercel News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MyScale Blog
MyScale Blog
V2EX - 技术
V2EX - 技术
N
Netflix TechBlog - Medium
F
Fortinet All Blogs
V
Visual Studio Blog
Martin Fowler
Martin Fowler
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - Franky
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
The Exploit Database - CXSecurity.com
F
Full Disclosure
Scott Helme
Scott Helme
H
Heimdal Security Blog
博客园 - 叶小钗
Google DeepMind News
Google DeepMind News
Cyberwarzone
Cyberwarzone
Application and Cybersecurity Blog
Application and Cybersecurity Blog
V
Vulnerabilities – Threatpost
Blog — PlanetScale
Blog — PlanetScale
Security Latest
Security Latest
WordPress大学
WordPress大学
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Troy Hunt's Blog
S
SegmentFault 最新的问题
Forbes - Security
Forbes - Security
Jina AI
Jina AI
S
Securelist
小众软件
小众软件
Simon Willison's Weblog
Simon Willison's Weblog
J
Java Code Geeks
AWS News Blog
AWS News Blog
N
News and Events Feed by Topic
博客园 - 三生石上(FineUI控件)
量子位

博客园 - tonyYe

请求筛选模块被配置为拒绝包含双重转义序列的请求。HTTP 错误 404.11 - Not Found asp.net页面传值方法汇总 - tonyYe - 博客园 Syntax error on line 198 httpd.conf: ServerAdmin takes one argument ASP.NET 2.0中Page事件的执行顺序 {转} EM 无法启动,重新完全配置EM ToString - tonyYe - 博客园 快捷方式制作 ListView导出到Excel TreeView的NodeCheck联动 利用js去除打印时的页眉页脚 使用证书来做RSA非对称式加密 用证书实现windows 2003下IIS的SSL安全通信 Windows命令提示符大全 学习.net应该知道什么 C# 3.0新特性之扩展方法 针对构架师的.NET 3.0介绍 Microsoft .net 框架开发平台体系架构 查询保存在outlook里的用户名和密码 ASP.NET 2.0 GridView
MapGuide公共静态方法
tonyYe · 2008-03-04 · via 博客园 - tonyYe

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using OSGeo.MapGuide;
using System.Collections.Specialized;

/// <summary>
/// Shared 的摘要说明
/// </summary>

public class MapGuideShared
{
    
/// <summary>
    
/// 
    
/// </summary>

    public MapGuideShared()
    
{
        
//
        
// TODO: 在此处添加构造函数逻辑
        
//
    }

    
/// <summary>
    
/// 
    
/// </summary>
    
/// <param name="res"></param>
    
/// <param name="commands"></param>

    public static void ReleaseReader(MgPropertyCollection res, ref MgFeatureCommandCollection commands)
    
{
        
if (res == null)
            
return;

        
for (int i = 0; i < res.GetCount(); i++)
        
{
            MgFeatureCommand cmd 
= commands.GetItem(i);
            
if (cmd is MgInsertFeatures)
            
{
                MgFeatureProperty resProp 
= (MgFeatureProperty)res.GetItem(i);
                
if (resProp != null)
                
{
                    MgFeatureReader reader 
= (MgFeatureReader)resProp.GetValue();
                    
if (reader == null)
                        
return;
                    reader.Close();
                }

            }

        }

    }

    
/// <summary>
    
/// 更改图层
    
/// </summary>
    
/// <param name="sCondition">条件</param>
    
/// <param name="map">地图</param>
    
/// <param name="gsLayer">图层</param>
    
/// <param name="properties">修改属性集</param>
    
/// <param name="resourceService">资源服务</param>
    
/// <param name="featureService">要素服务</param>

    public static void UpdateLayer(string sCondition, MgMap map, MgLayer gsLayer, MgPropertyCollection properties,ref MgResourceService resourceService, ref MgFeatureService featureService)
    
{
        
if (sCondition != "")
        
{
            MgResourceIdentifier layerFeatureResource 
= new MgResourceIdentifier(gsLayer.GetFeatureSourceId());
            MgFeatureCommandCollection blueMarkerCommands 
= new MgFeatureCommandCollection();
            SetResourceReadOnly(layerFeatureResource, resourceService);
            MgUpdateFeatures updateCommand 
= new MgUpdateFeatures(gsLayer.Name, properties, sCondition);
            blueMarkerCommands.Add(updateCommand);
            
//execute blue marker command    
            if (blueMarkerCommands.GetCount() >= 1)
            
{
                ReleaseReader(featureService.UpdateFeatures(layerFeatureResource, blueMarkerCommands, 
false), ref blueMarkerCommands);
            }

            gsLayer.SetVisible(
true);
            gsLayer.ForceRefresh();
            map.Save(resourceService);
        }

    }

    
/// <summary>
    
/// 更改图层
    
/// </summary>
    
/// <param name="sCondition">条件</param>
    
/// <param name="map">地图</param>
    
/// <param name="nLayerIndex">图层序号</param>
    
/// <param name="properties">修改属性集</param>
    
/// <param name="resourceService">资源服务</param>
    
/// <param name="featureService">要素服务</param>

    public static void UpdateLayer(string sCondition, MgMap map, int nLayerIndex, MgPropertyCollection properties, ref MgResourceService resourceService,ref  MgFeatureService featureService)
    
{
        MgLayer gsLayer 
= map.GetLayers().GetItem(nLayerIndex) as MgLayer;
        UpdateLayer(sCondition, map, gsLayer, properties, 
ref resourceService, ref featureService);
    }

    
/// <summary>
    
/// 更改图层
    
/// </summary>
    
/// <param name="sCondition">条件</param>
    
/// <param name="map">地图</param>
    
/// <param name="sLayerName">图层名称</param>
    
/// <param name="properties">修改属性集</param>
    
/// <param name="resourceService">资源服务</param>
    
/// <param name="featureService">要素服务</param>

    public static void UpdateLayer(string sCondition, MgMap map, string sLayerName, MgPropertyCollection properties, ref MgResourceService resourceService, ref MgFeatureService featureService)
    
{
        MgLayer gsLayer 
= map.GetLayers().GetItem(sLayerName) as MgLayer;
        UpdateLayer(sCondition, map, gsLayer, properties, 
ref resourceService, ref featureService);
    }

    
/// <summary>
    
/// 
    
/// </summary>
    
/// <param name="map"></param>
    
/// <param name="featureService"></param>
    
/// <param name="resourceService"></param>
    
/// <param name="page"></param>

    public static void OpenMap(ref MgMap map, ref MgFeatureService featureService, ref MgResourceService resourceService, Page page)
    
{
        MgSiteConnection siteConnection 
= new MgSiteConnection();

        NameValueCollection requestParams 
= page.Request.HttpMethod == "GET" ? page.Request.QueryString : page.Request.Form;
        String mgSessionId 
= requestParams["SESSION"];
        String mgLocale 
= requestParams["LOCALE"];
        String mgMapName 
= requestParams["MAPNAME"];
        String configPath 
= page.Request.ServerVariables["APPL_PHYSICAL_PATH"+ "..\\webconfig.ini";

        MapGuideApi.MgInitializeWebTier(configPath);
        MgUserInformation userInfo 
= new MgUserInformation(mgSessionId);
        siteConnection.Open(userInfo);

        
//创建资源服务
        resourceService = (MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
        
//创建要素服务
        featureService = (MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);

        map.Open(resourceService, mgMapName);
    }

    
/// <summary>
    
/// 
    
/// </summary>
    
/// <param name="resoureId"></param>
    
/// <param name="resourceService"></param>

    private static void SetResourceReadOnly(MgResourceIdentifier resoureId, MgResourceService resourceService)
    
{
        String buffer;
        buffer 
= resourceService.GetResourceContent(resoureId).ToString();
        
if (buffer.Contains("<Value>TRUE</Value>"))
        
{
            buffer 
= buffer.Replace("<Value>TRUE</Value>""<Value>FALSE</Value>");
            Byte[] buf_Byte 
= System.Text.Encoding.Default.GetBytes(buffer);
            MgByteSource byteSource 
= new MgByteSource(buf_Byte, buf_Byte.Length);
            resourceService.SetResource(resoureId, byteSource.GetReader(), 
null);
        }

    }

}