我正在关注下一个项目:http ://www.thorntontechnical.com/tech/sharepoint/sharepoint-2010-context-menu-item-with-custom-code
元素.XML
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="SPTest.CustomMenuItem.ButtonClicked"
RegistrationType="FileType"
RegistrationId="dtsx"
Location="EditControlBlock"
ImageUrl="/_layouts/IMAGES/DOCLINK.GIF"
Sequence="600"
Title="Execute Package"
Description="Executed Selected Package"
ControlAssembly="SPTest.CustomMenuItem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=beb14bc625e99e7f"
ControlClass="SPTest.CustomMenuItem.CustomItemAction"
>
<UrlAction Url="javascript:__doPostBack('SPTest.CustomMenuItem.CustomItemAction', {ItemId});" />
</CustomAction>
</Elements>
包.模板.XML
<?xml version="1.0" encoding="utf-8"?>
<Solution xmlns="http://schemas.microsoft.com/sharepoint/">
<Assemblies>
<Assembly Location="SPTest.CustomMenuItem.dll" DeploymentTarget="GlobalAssemblyCache">
<SafeControls>
<SafeControl Assembly="SPTest.CustomMenuItem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=beb14bc625e99e7f"
Namespace="SPTest.CustomMenuItem" TypeName="*" Safe="True" SafeAgainstScript="False" />
</SafeControls>
</Assembly>
</Assemblies>
</Solution>
所以... 在 Web.config 文件中,我们可以在 SafeControl 中找到我们的程序集
执行类
using System.IO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
namespace SPTest.CustomMenuItem
{
public class CustomItemAction : SPLinkButton
{
protected override void OnLoad(EventArgs e)
{
this.EnsureChildControls();
base.OnLoad(e);
if (this.Page.Request["__EVENTTARGET"] == "SPTest.CustomMenuItem.ButtonClicked")
{
int itemId = Convert.ToInt32(this.Page.Request["__EVENTARGUMENT"]);
System.IO.TextWriter writer = new StreamWriter(@"C:\XXXXX\XXXXX\XXXXX\custommenuoutput.txt", true);
writer.WriteLine("Event Fired at:" + DateTime.Now.ToLongTimeString() + ": Item ID:" + itemId.ToString());
writer.Close();
}
}
}
}
如您所见,目标是执行在 Sharepoint 上分配的 SSIS 包。带有 Execute Package 选项的 ECB 菜单出现在所有具有 dtsx 类型的文件中。因此,当我单击此底部时,该事件不起作用......我不知道我必须做什么......任何帮助将不胜感激。