您的位置:首页 > 其它

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)此项目。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐