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

推荐订阅源

A
Arctic Wolf
博客园 - 聂微东
F
Fortinet All Blogs
云风的 BLOG
云风的 BLOG
小众软件
小众软件
V
Visual Studio Blog
博客园 - 三生石上(FineUI控件)
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Apple Machine Learning Research
Apple Machine Learning Research
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Cloudflare Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
L
LangChain Blog
A
About on SuperTechFans
阮一峰的网络日志
阮一峰的网络日志
I
Intezer
T
The Blog of Author Tim Ferriss
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
Know Your Adversary
Know Your Adversary
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Palo Alto Networks Blog
Scott Helme
Scott Helme
S
Secure Thoughts
Spread Privacy
Spread Privacy
T
Threat Research - Cisco Blogs
Attack and Defense Labs
Attack and Defense Labs
P
Privacy & Cybersecurity Law Blog
O
OpenAI News
H
Heimdal Security Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Help Net Security
Help Net Security
C
Cyber Attacks, Cyber Crime and Cyber Security
Blog — PlanetScale
Blog — PlanetScale
GbyAI
GbyAI
G
Google Developers Blog
博客园 - Franky
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
K
Kaspersky official blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
T
Tor Project blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Tenable Blog
Google Online Security Blog
Google Online Security Blog
PCI Perspectives
PCI Perspectives

博客园 - 永春

随笔 随笔 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是比较重要的对象,会在下回说到