怎样用C#代码管理SharePoint解决方式
怎样用C#代码管理SharePoint解决方式
怎样获得沙盒解决方式
using (SPSite site = new SPSite("http://localhost"))
{
foreach (SPUserSolution solution in site.Solutions)
{
Console.WriteLine(solution.Name);
Console.WriteLine(solution.Status);
}
}
怎样获得场解决方式
foreach (SPSolution solution in SPFarm.Local.Solutions)
{
Console.WriteLine(solution.Name);
Console.WriteLine(solution.SolutionId);
Console.WriteLine(solution.Status);
}
接下来看看怎样通过server端对象模型安装解决方式吧。
安装沙盒解决方式
using (SPSite site = new SPSite("http://localhost"))
{
SPDocumentLibrary gallery
=(SPDocumentLibrary)site.GetCatalog(SPListTemplateType.SolutionCatalog);
SPFile file = gallery.RootFolder.Files.Add("SandboxedSolution.wsp",
File.ReadAllBytes("SandboxedSolution.wsp"));
SPUserSolution solution = site.Solutions.Add(file.Item.ID);
}
移除沙盒解决方式
using (SPSite site = new SPSite("http://localhost"))
{
SPUserSolution solution = site.Solutions.Cast<SPUserSolution>().
Where(s => s.Name == "Your Solution").First();
site.Solutions.Remove(solution);
}
安装场解决方式
private static void InstallFarmSolution()
{
SPSolution solution = SPFarm.Local.Solutions.Add("File Path here");
solution.Deploy(DateTime.Now, true, GetAllWebApplications(), true);
}
我们须要指定解决方式路径。上面的代码让解决方式安装到全部Web应用程序中。GetAllWebApplication()方法主体例如以下:
public static Collection<SPWebApplication> GetAllWebApplications()
{
Collection<SPWebApplication> result = new Collection<SPWebApplication>();
SPServiceCollection services = SPFarm.Local.Services;
foreach (SPService s in services)
{
if (s is SPWebService)
{
SPWebService webService = (SPWebService)s;
foreach (SPWebApplication webApp in webService.WebApplications)
{
result.Add(webApp);
}
}
}
return result;
}
移除场解决方式
private void RetractFarmSolution(SPSolution solution)
{
solution.Retract(DateTime.Now);
}
创建Timer job收回解决方式。你能够指定開始收回的时间。
private void RetractFarmSolution(SPSolution solution, Collection<SPWebApplication> webApplications)
{
solution.Retract(DateTime.Now, webApplications);
}
总结
參考:
怎样用C#代码管理SharePoint解决方式的更多相关文章
- PowerShell 导出SharePoint管理中心解决方式
PowerShell 导出SharePoint管理中心解决方式 SharePoint QQ群有人问能不能下载(导出)管理中心里的解决方式.由于在管理中心中点击解决方式会进入还有一个页面 ...
- 部署SharePoint解决方式包时遇到的问题
部署SharePoint解决方式包时遇到的问题 近期我在使用STSADM.EXE命令部署解决方式包的时候.遇到一个问题.很的难搞. 创建WSP文件非常easy.加入到解决方式库也非常e ...
- Android_动态权限管理的解决方式
本博文为子墨原创.转载请注明出处! http://blog.csdn.net/zimo2013/article/details/50478201 1.前言 (1).因为MIUI等部分国产定制系统也有权 ...
- 通过PowerShell卸载全部的SharePoint 2010 解决方式
通过PowerShell卸载全部的SharePoint 2010 解决方式 为了演示.我常常须要拆毁再重建SharePoint 2010 环境. 我常常须要用到的操作就 ...
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第13章节--使用业务连接服务创建业务线解决方式 SP Apps中的BCS
BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第13章节--使用业务连接服务创建业务线解决方式 SP Apps中的BCS 之前的联系中,你安装了一个业 ...
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第11章节--为Office和SP解决方式开发集成Apps Office新的App模型
BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第11章节--为Office和SP解决方式开发集成Apps Office新的App模型 Office 2 ...
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第11章节--为Office和SP解决方式开发集成Apps Office的JavaScript对象模型
BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第11章节--为Office和SP解决方式开发集成Apps Office的JavaScript对象模型 ...
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第11章节--为Office和SP解决方式开发集成Apps 集成SP和Office App
BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第11章节--为Office和SP解决方式开发集成Apps 集成SP和Office App 你能够用两种 ...
- google跟踪代码管理器gtm无法给相同class元素绑定click事件埋点解决
Google 跟踪代码管理器是一个跟踪代码管理系统 (TMS),可以帮助您快速轻松地更新网站或移动应用上的跟踪代码及相关代码段(统称为“代码”).将一小段跟踪代码管理器代码添加到项目后,您可以通过网页 ...
随机推荐
- Software Development and Newton's Laws of Motion
Software Development and Newton's Laws of Motion Intro I have no idea since when the word velocity f ...
- grails的controller和action那点事---远程调试groovy代码
最近由于项目需要,用到了grails,这玩意确实好用,生产率高有类型python的速度与简洁.仅第一印象,用的还不深入,说的不对请轻拍. 遇到的几个问题: 1. groovy远程调试 玩Java的应该 ...
- 用链表实现栈----《数据结构与算法分析----C语言描述》
一.头文件: #ifndef _STACK_LINK_H_ #define _STACK_LINK_H_ struct stack_record; typedef struct stack_recor ...
- UVA12304 2D Geometry 110 in 1! 计算几何
计算几何: 堆几何模版就能够了. . .. Description Problem E 2D Geometry 110 in 1! This is a collection of 110 (in bi ...
- PHP草根论之设计模式-訪问者模式
关于模式本身的概念,请參考网上其他文章 此处仅仅讨论在PHP实际开发过程中的应用 此模式适用范围极为受限,适用情景: 1.适用于项目维护过程,不适用于项目开发过程 2.新增需求,要求为一个/多个类添加 ...
- hdu 2082 生成函数
主题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2082 找单词 Time Limit: 1000/1000 MS (Java/Others) Me ...
- 在android创建bitmap避免低记忆法
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="ht ...
- 官网下载qt-opensource-windows-x86-mingw482_opengl-5.3.1.exe。封装好了Qt libraries、Qt Creator。只需要这一个可执行程序就好了。
官网下载qt-opensource-windows-x86-mingw482_opengl-5.3.1.exe( http://qt-project.org/downloads).这个可执行程序已经为 ...
- 黄聪:Microsoft Enterprise Library 5.0 系列教程(九) Policy Injection Application Block
原文:黄聪:Microsoft Enterprise Library 5.0 系列教程(九) Policy Injection Application Block 代理对象(Proxy Object) ...
- PB数据库相关
---------------------------------------------------------------- 数据库画板: 一张表定义了主键或者唯一索引,则能够在Results视窗 ...