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

推荐订阅源

T
Troy Hunt's Blog
Blog — PlanetScale
Blog — PlanetScale
Engineering at Meta
Engineering at Meta
F
Full Disclosure
Recorded Future
Recorded Future
The GitHub Blog
The GitHub Blog
Microsoft Security Blog
Microsoft Security Blog
GbyAI
GbyAI
博客园_首页
博客园 - 叶小钗
MongoDB | Blog
MongoDB | Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
H
Hacker News: Front Page
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
博客园 - 司徒正美
Webroot Blog
Webroot Blog
Google DeepMind News
Google DeepMind News
Help Net Security
Help Net Security
Cloudbric
Cloudbric
PCI Perspectives
PCI Perspectives
有赞技术团队
有赞技术团队
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
TaoSecurity Blog
TaoSecurity Blog
L
Lohrmann on Cybersecurity
量子位
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Tailwind CSS Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
B
Blog RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
大猫的无限游戏
大猫的无限游戏
P
Proofpoint News Feed
N
News and Events Feed by Topic
罗磊的独立博客
T
Threat Research - Cisco Blogs
Schneier on Security
Schneier on Security
T
Tor Project blog
IT之家
IT之家
M
MIT News - Artificial intelligence
S
Security @ Cisco Blogs
O
OpenAI News
AI
AI
S
Securelist
Simon Willison's Weblog
Simon Willison's Weblog
The Last Watchdog
The Last Watchdog
月光博客
月光博客
Security Archives - TechRepublic
Security Archives - TechRepublic
L
LINUX DO - 热门话题

博客园 - 永春

随笔 随笔 asp+access在64位上的问题 换个活法 项目做的很无语 五分钟叫你看懂美国金融危机的成因和巨大危害[转] Sqlserver中的日期类型值不能小于1753年 C#读取WORD时发生“拒绝访问”及“消息筛选器显示应用程序正在使用中”异常的处理 Asp.Net之自定义表达式构造器(ExpressionBuilder) [Sharepoint2007对象模型]第三回:Web应用程序(SPWebApplication) Sharepoint2007对象模型系列 [Sharepoint2007对象模型]第二回:Web应用程序服务(SPWebService) C#强化系列文章九:代码访问安全性使用 项目经理的个人修养 《博客园精华集--Sharepoint分册》第三轮结果 《博客园精华集》Sharepoint+MOSS分册第2轮筛选结果文章列表 Asp.Net页面执行流程分析 C#强化系列文章八:HttpModule,HttpHandler,HttpHandlerFactory简单使用 在MOSS中使用.Net3.5中的Ajax功能
[Sharepoint2007对象模型]第一回:服务器场(SPFarm)
永春 · 2008-07-31 · via 博客园 - 永春

Sharepoint是微软一个很重要的服务器产品,它可以方便的创建和维护一个网站,在Sharepoint的管理中心提供了很强大的管理工具。同时为了更加灵活的后期定制和开发,Sharepoint提供了完整的对象模型,对象模型也就相当于Sharepoint的二次开发接口,从服务器场到一个网站,以至一个Sharepoint中的列表都有相应的对象模型。本系列希望能对Sharepoint的对象模型进行一个大体的介绍。

第一回:服务器场
服务器场是Sharepoint2007中最高的一个层次,在安装Sharepoint时可以把几台机器安装在同一个服务器场中,比如同一个服务器场中可以包含一台搜索服务器、两台应用服务器......,服务器场对应的对象模型就是SPFarm
在C#中可以直接取得服务器场的对象模型:

        public SPFarm CurrentFarm = SPFarm.Local;

(当前应用程序需要在服务器场内的某台服务器上)
在一个服务器场下主要包含五个对象:功能集定义,属性集,服务器场上的服务器,服务器上的服务,解决方案.
功能集定义包含服务器场的一些功能,对应的对象模型为:SPFeatureDefinition

            TreeNode nodeFeature = nodeParent.Nodes.Add("功能集定义");
            
foreach (SPFeatureDefinition definition in CurrentFarm.FeatureDefinitions)
            {
                nodeFeature.Nodes.Add(GetFeatureName(definition));
            }

GetFeatureName方法取得功能的名称,(2052代表的是简体中文)

        private string GetFeatureName(SPFeatureDefinition definition)
        {
            
string strRet = definition.GetTitle(new System.Globalization.CultureInfo(2052));
            
if (String.IsNullOrEmpty(strRet))
            {
                strRet 
= definition.DisplayName;
            }
            
return strRet;
        }

属性集包含服务器场上定义的一些属性:

            TreeNode nodeProperty = nodeParent.Nodes.Add("属性集");
            
foreach (DictionaryEntry entry in CurrentFarm.Properties)
            {
                nodeProperty.Nodes.Add(entry.Key.ToString());
            }

服务器场上的服务器指的是服务场上使用了哪些服务器,比如web服务器的名称,数据库服务的名称等,对应的对象模型为:SPServer

            TreeNode nodeServer = nodeParent.Nodes.Add("服务器场上的服务器");
            
foreach (SPServer server in CurrentFarm.Servers)
            {
                nodeServer.Nodes.Add(server.DisplayName);
            }

服务器上的服务指的是提供了哪些服务,比如Web应用程序服务,搜索服务等,对应的对象模型为:SPService

            TreeNode nodeService = nodeParent.Nodes.Add("服务器上的服务");
            
foreach (SPService Service in CurrentFarm.Services)
            {
                TreeNode nodeWeb 
= nodeService.Nodes.Add(Service.TypeName);
                
if (Service is SPWebService)
                {
                    SPWebService webServices 
= Service as SPWebService;
                    ShowWebService(webServices, nodeWeb);
                }
            }

ShowWebService方法是用来取得web应用程序服务信息的,在第二回中会详细说明。

解决方案取得的是服务器场上安装了哪些解决方案,我们可以使用 stsadm –o addsolution –filename solution.wsp命令安装自己的解决方案,它对应的对象模型是SPSolution

            TreeNode nodeSolution = nodeParent.Nodes.Add("解决方案");
            
foreach (SPSolution Solution in CurrentFarm.Solutions)
            {
                nodeSolution.Nodes.Add(Solution.DisplayName);
            }

最后的画面截图如下所示:

小结:本回只是介绍了sharepoint对象模型几个比较大的对象,后面的文章会对一些比较重要的对象进行逐步说明。其中SPWebService是比较重要的对象,会在下回说到