SharePoint 2010部署WCF续 - feature event receiver实现自动部署
来源:互联网 发布:中英文翻译对照软件 编辑:程序博客网 时间:2024/05/19 18:16
在上篇文章里,有部署在sharepoint2010上部署WCF的过程,现实现自动化部署,不手工参与web.config的修改。
并增加了另外一个WCF。
1. 为工程添加一个feature(修改feature name & scope)
2. 添加feature event receiver
3. 在receiver类中添加下图所示helper elements
#region web.config modification
private struct ModificationEntry {
public string Name;
public string XPath;
public SPWebConfigModification.SPWebConfigModificationType ModType;
// parameterized contructor
public ModificationEntry(string Name, string XPath, string Value, SPWebConfigModification.SPWebConfigModificationType
ModType)
// intialize structure instances
this.Name = Name;
this.XPath = XPath;
this.Value = Value;
#region
private ModificationEntry
[] Entries = {
new ModificationEntry
(
"add[@name='WCFDeployment']"
,
"configuration/system.serviceModel"
,
【get the WCF configuration information from app.config】
,
SPWebConfigModification.SPWebConfigModificationType
.EnsureChildNode)
private SPWebConfigModification CreateModification(ModificationEntry
modEntry)
SPWebConfigModification
modification; modification =
new SPWebConfigModification
(modEntry.Name, modEntry.XPath); modification.Owner =
"test"
;
return
modification;
private void AddModifications(SPWebApplication
webApp)
foreach (ModificationEntry modEntry in
Entries)
private void RemoveModifications(SPWebApplication
webApp)
foreach (ModificationEntry modEntry in
Entries)
4. override 2个方法:
public override void FeatureActivated(SPFeatureReceiverProperties
properties)
{
SPSite site = (SPSite)properties.Feature.Parent;
AddModifications(WebApp);
}
// Uncomment the method below to handle the event raised before a feature is deactivated.
public override void FeatureDeactivating(SPFeatureReceiverProperties
properties)
{
SPSite site = (SPSite)properties.Feature.Parent;
SPWebApplication WebApp = (SPWebApplication)site.WebApplication;
RemoveModifications(WebApp); }
5. 部署,搞定!
注意问题:
千万别忘了修改这个标签的内容(从app.config中拷贝出来的时候,app.config中的是wcf的server)。
<add baseAddress=""http://localhost/_layouts/WCFDeployment/SecondWCF/"" />
发现了个问题: redeploy 的时候居然原来添加的节点删除不掉? 有知道的告诉我生
// Uncomment the method below to handle the event raised after a feature has been activated.
#endregion
{
webApp.WebConfigModifications.Remove(CreateModification(modEntry));
}
webApp.WebService.ApplyWebConfigModifications();
}
{
{
webApp.WebConfigModifications.Add(CreateModification(modEntry));
}
webApp.WebService.ApplyWebConfigModifications();
}
{
}
modification.Sequence = 0;
modification.Type = modEntry.ModType;
modification.Value = modEntry.Value;
{
#endregion
};
}
}
{
- SharePoint 2010部署WCF续 - feature event receiver实现自动部署
- Sharepoint 2010 Event 部署注意事项
- SharePoint部署WSP解决方案包,部署Feature
- SharePoint 部署解决方案Feature ID冲突
- 通过Feature部署Sharepoint 2013的EventReceiver
- SharePoint 2010 用Event Receiver将文件夹自动变成approved状态 (1)
- SharePoint 2010 用Event Receiver将文件夹自动变成approved状态 (2)
- sharepoint 2010部署
- SharePoint 2010 部署架构
- SharePoint 2010之部署WCF(deploy WCF service to SharePoint 2010 via VS 2010 step by step)
- 如何通过PowerShell 部署Feature(SharePoint 2013)
- SharePoint部署
- sharepoint部署
- sharepoint部署
- WCF部署
- 使用 SharePoint API 自动部署 Web 应用程序
- SharePoint 2010 的服务器部署
- SharePoint 2010 部署 WSP 包
- JS二级联动
- linux下安装软件详解
- asp.net上传图片汇总
- 腾讯搜搜做的月刊太精彩了(封底特别值得关注)
- 实用的DBHeper类
- SharePoint 2010部署WCF续 - feature event receiver实现自动部署
- tar 命令用法
- rar for linux的安装使用
- JBoss JBPM 实践系列(二)--- jbpm设计器的配置和使用
- 程序初始化失败的解决办法
- C#遍历文件夹构造文件树
- ps命令详解
- C# 用正则表达式替换字符串时,要注意替换的次数
- vb.net 自定义数据库链接类(Access)