I followed the K2.net Studio SDK, created a Mail Server event template, then I created my own activity template (works fine), and tried to add the Mail Server template to it, but it doesn't work. K2 prompts out the following message:
I'm not sure the procedure that I added the event to activity is correct or not. In my activity, the Execute code is:
public bool Execute(K2Studio.Activity myActivity)
{
base.Initialize(myActivity);
myActivity.Description = this.MyTemplateDescription;
AddDataField(myActivity);
AddEvent(myActivity);
return true;
}
The AddEvent(myActivity) is:
public void AddEvent(K2Studio.Activity myActivity)
{
K2Studio.Event myEvent = myActivity.Events.AddServerEvent("My Event Template");
MyEventTemplate myEventTemplate = new MyEventTemplate();
//myEventTemplate.BuildEvent(myEvent);
myEventTemplate.Execute(myEvent);
}
The Execute code for the Event template is:
public bool Execute(K2Studio.Event myEvent)
{
// Set the event template type
//myEvent.Type = K2Studio.EnumEvent.Server;
PropertyTemplate.Instance = new PropertyTemplate();
//base.PropertyTemplateAssists.Add(PropertyTemplate.Instance);
//base.Initialize(myEvent);
//myEvent.Name = this.MyEventTemplateName;
myEvent.Description = this.MyTemplateDescription;
//PropertyTemplate.Instance.LoadData();
if (base.RunWizard(new TemplateWizard()) == System.Windows.Forms.DialogResult.Cancel)
{
// If no Data present, remove Event from Activity else Save it
if (!PropertyTemplate.Instance.HasData)
{
myEvent.Activity.Events.Remove(myEvent.Name);
}
else
{
base.SaveAll(true);
}
}
else
{
base.SaveAll(true);
}
return true;
}
I found the exception points are:
base.PropertyTemplateAssists.Add(...); base.Initialize(myEvent); PropertyTemplate.Instance.LoadData(); respectively.
When I commented out all these, the activity template can automate the Mail Server template, brings up the first page of the wizard form, but when I pressed "Next" to go further, K2 also prompts up the same error message.
Any help would be appreciated,
Cheers,
Patrick