Sharepoint学习笔记---Sandbox Solution-- Full Trust Proxy--开发实例之(1、创建一个能访问DataBase的Full Trust Proxy)
2011-09-15 17:34
561 查看
在Sharepoint学习笔记---Sandbox Solution-- Full Trust Proxy--开发步骤一文,我们讲述了开发和部署Sandbox Solution的Full Trust Proxy的基本步骤,在这里,我们采用另一种方式来开发和部署一个能访问数据库的Full Trust Proxy,由于内容比较多,所以分割成两个部分,本部分主要讲如何开发这个Full Trust Proxy,而下一部分则讲如何在Webpart中调用它来展示所取得的数据库数据。
直接进入操作步骤。
一、创建和设置项目
1、在Vs2010中新建一个Empty SharePoint Project,命名为: MyTestSandBoxAccessDBInfo,由于是开发Full Trust Proxy,所以此项目要基于Farm开发,
我们用于测试的Sharpoint网站网址是 http://sd1-sp1dev:5000/sites/Develop/
View Code using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.UserCode;
using Microsoft.SharePoint.Administration;
namespace My.Sharepoint.SandBox.MyTestSandBoxAccessDBInfo.Features.Registration
{
/// <summary>
/// This class handles events raised during feature activation, deactivation, installation, uninstallation, and upgrade.
/// </summary>
/// <remarks>
/// The GUID attached to this class may be used during packaging and should not be modified.
/// </remarks>
[Guid("f64dd849-567d-497a-bd56-9e92ea33f9ce")]
public class RegistrationEventReceiver : SPFeatureReceiver
{
// Uncomment the method below to handle the event raised after a feature has been activated.
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
Type type = typeof(My.Sharepoint.SandBox.MyTestSandBoxAccessDBInfo.TestProxyCode.SQLProxyExecute);
SPProxyOperationType proxyOperationType = new SPProxyOperationType(type.Assembly.FullName, type.FullName);
SPUserCodeService userCodeService = SPUserCodeService.Local;
userCodeService.ProxyOperationTypes.Add(proxyOperationType);
userCodeService.Update();
}
// Uncomment the method below to handle the event raised before a feature is deactivated.
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
Type type = typeof(My.Sharepoint.SandBox.MyTestSandBoxAccessDBInfo.TestProxyCode.SQLProxyExecute);
SPProxyOperationType proxyOperationType = new SPProxyOperationType(type.Assembly.FullName, type.FullName);
SPUserCodeService userCodeService = SPUserCodeService.Local;
userCodeService.ProxyOperationTypes.Remove(proxyOperationType);
userCodeService.Update();
}
// Uncomment the method below to handle the event raised after a feature has been installed.
//public override void FeatureInstalled(SPFeatureReceiverProperties properties)
//{
//}
// Uncomment the method below to handle the event raised before a feature is uninstalled.
//public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
//{
//}
// Uncomment the method below to handle the event raised when a feature is upgrading.
//public override void FeatureUpgrading(SPFeatureReceiverProperties properties, string upgradeActionName, System.Collections.Generic.IDictionary<string, string> parameters)
//{
//}
}
}
。
6、建立(Build)并部署(Deploy)此项目。
直接进入操作步骤。
一、创建和设置项目
1、在Vs2010中新建一个Empty SharePoint Project,命名为: MyTestSandBoxAccessDBInfo,由于是开发Full Trust Proxy,所以此项目要基于Farm开发,
我们用于测试的Sharpoint网站网址是 http://sd1-sp1dev:5000/sites/Develop/
View Code using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.UserCode;
using Microsoft.SharePoint.Administration;
namespace My.Sharepoint.SandBox.MyTestSandBoxAccessDBInfo.Features.Registration
{
/// <summary>
/// This class handles events raised during feature activation, deactivation, installation, uninstallation, and upgrade.
/// </summary>
/// <remarks>
/// The GUID attached to this class may be used during packaging and should not be modified.
/// </remarks>
[Guid("f64dd849-567d-497a-bd56-9e92ea33f9ce")]
public class RegistrationEventReceiver : SPFeatureReceiver
{
// Uncomment the method below to handle the event raised after a feature has been activated.
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
Type type = typeof(My.Sharepoint.SandBox.MyTestSandBoxAccessDBInfo.TestProxyCode.SQLProxyExecute);
SPProxyOperationType proxyOperationType = new SPProxyOperationType(type.Assembly.FullName, type.FullName);
SPUserCodeService userCodeService = SPUserCodeService.Local;
userCodeService.ProxyOperationTypes.Add(proxyOperationType);
userCodeService.Update();
}
// Uncomment the method below to handle the event raised before a feature is deactivated.
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
Type type = typeof(My.Sharepoint.SandBox.MyTestSandBoxAccessDBInfo.TestProxyCode.SQLProxyExecute);
SPProxyOperationType proxyOperationType = new SPProxyOperationType(type.Assembly.FullName, type.FullName);
SPUserCodeService userCodeService = SPUserCodeService.Local;
userCodeService.ProxyOperationTypes.Remove(proxyOperationType);
userCodeService.Update();
}
// Uncomment the method below to handle the event raised after a feature has been installed.
//public override void FeatureInstalled(SPFeatureReceiverProperties properties)
//{
//}
// Uncomment the method below to handle the event raised before a feature is uninstalled.
//public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
//{
//}
// Uncomment the method below to handle the event raised when a feature is upgrading.
//public override void FeatureUpgrading(SPFeatureReceiverProperties properties, string upgradeActionName, System.Collections.Generic.IDictionary<string, string> parameters)
//{
//}
}
}
。
6、建立(Build)并部署(Deploy)此项目。
相关文章推荐
- SharePoint【学习笔记】--【Sandbox Solution】-- Full Trust Proxy --开发实例之(1、创建一个能访问DataBase的Full Trust Proxy)
- Sharepoint学习笔记---Sandbox Solution-- Full Trust Proxy--开发实例之(2、在Webpart中访问Full Trust Proxy)
- SharePoint【学习笔记】--【Sandbox Solution】-- Full Trust Proxy--开发实例之(2、在Webpart中访问Full Trust Proxy)
- SharePoint【学习笔记】--【Sandbox Solution】-- Full Trust Proxy--开发步骤
- Sharepoint学习笔记---Sandbox Solution-- Full Trust Proxy--开发步骤
- CAD二次开发学习笔记二(创建一个对话框)
- 步步为营 SharePoint 开发学习笔记系列 四、创建sub site和创建list
- SharePoint【学习笔记】-- 【Upgrading&Version版本升级】:Content Type Feature(一.创建和部署一个基本的Content Type Feature)
- Sharepoint学习笔记—Site Definition系列--6、基于一个已经部署的List Template来创建List Instance
- Grunt学习笔记之开发环境的搭建与创建一个基本的项目
- Sharepoint学习笔记---Upgrading&Version版本升级:Content Type Feature(一.创建和部署一个基本的Content Type Feature)
- python进阶学习笔记(四)——python中访问限制、创建类属性、定义实例方法、定义类方法、类的继承
- 步步为营 SharePoint 开发学习笔记系列 三、创建Web Application和创建Site
- docker学习笔记2—创建一个nginx的镜像,并使用浏览器访问
- OpenStack开发学习笔记03————创建一个openstack
- 步步为营 SharePoint 开发学习笔记系列 四、创建sub site和创建list
- 推荐一个学习SharePoint开发极好的实例
- Sharepoint学习笔记---SPList--创建一个带有Lookup字段的List
- 步步为营 SharePoint 开发学习笔记系列 三、创建Web Application和创建Site
- SharePoint 2016:找不到 Project Web App 实例。请在访问此页面之前至少创建一个 PWA 实例。