询问者
您好,关于附加plug-in的问题

问题
-
大家好,我看了SDK2011的“Walkthrough: Register a Plug-in using the Plug-in Registration Tool”的教程,教我怎么创建并附加plug-in(建立出程序集,进行签名,并且使用SDK自带的那个附加程序集的工具进行的附加(工具在SDK的地址\tools\pluginregistration))。
接着我又按教程上说,进行测试
Test the Plug-in
-
Open the Microsoft Dynamics CRM Web application for the same organization that you registered the plug-in assembly under.
-
Move to the workplace, select Accounts, and then click New.
-
In the Account Name box, type an account name, for example, Adventure Works Cycle, and then click Save & Close.
-
Double-click the form name in the Accounts grid to open the form.
-
Click Activities to display a list of related activities for the account. You should see the activity named “Send e-mail to the new customer“ that the plug-in created.
结果是,我在活动列表中并没有我创建的plug-in,请问应如何解决?
对了,以下是我的程序集代码,照着SDK写的。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;using Microsoft.Xrm.Sdk;
namespace FollowupPlugin3
{
public class FollowupPlugin4 : IPlugin
{public void Execute(IServiceProvider serviceProvider)
{
//提取跟踪服务以供沙盒插件使用
ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));//获取执行上下文权限
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));//InputParameters收集包含所有数据传输的请求
if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)
{
//从输入参数获取目标实体
Entity entity = (Entity)context.InputParameters["Target"];//判断目标实体是否为帐户实体
//如果不是帐户,这个插件未登记正确
if (entity.LogicalName != "account")
{
return;
}try
{
//创建一个跟踪帐户七天的活动任务
Entity followup = new Entity("task");
followup["subject"] = "Send e-mail to the new customer";
followup["description"] = "Follow up with the customer.Check if there are any new issues that need resolution.";
followup["scheduledstart"] = DateTime.Now.AddDays(7);
followup["scheduledend"] = DateTime.Now.AddDays(7);
followup["category"] = context.PrimaryEntityName;//当前帐户的任务活动
if (context.OutputParameters.Contains("id"))
{
Guid regardingobjectid = new Guid(context.OutputParameters["id"].ToString());
string regardingobjectidTye = "account";
followup["regardingobjectid"] = new EntityReference(regardingobjectidTye, regardingobjectid);
}//获取组织服务的引用
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);//创建CRM任务
tracingService.Trace("FollowupPlugin:Creating the task activity.");
service.Create(followup);
}
catch (Exception ex)
{
tracingService.Trace("FollowupPlugin: {0}", ex.ToString());
throw;
}
}
}
}
}谢谢各位前辈…鞠躬
-