I am writing custom activity for sharepoint workflow and I don\'t know how I can use current workflow item, SPWeb or SPSite.
I see http://blogs.microsoft.co.il/blogs/dav
I try this code and runs as well bat the contex objet always is null. some one know why?
protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
{
//return base.Execute(executionContext);
int IdRetorno = -1;
try {
SPSecurity.RunWithElevatedPrivileges(delegate
{
LogExceptionToWorkflowHistory("Inicio:", executionContext, WorkflowInstanceId);
using (SPSite sitio = new SPSite(this.__Context.Site.ID))
{
using (SPWeb web = sitio.AllWebs[this.__Context.Site.ID])
{
SPList sourceList = web.Lists[new Guid(ListId)];
LogExceptionToWorkflowHistory(ListId, executionContext, WorkflowInstanceId);
SPList destinoList = web.Lists[new Guid(SourceListId)];
LogExceptionToWorkflowHistory(SourceListId, executionContext, WorkflowInstanceId);
SPListItem sourceItem = sourceList.Items.GetItemById(ListItem);
LogExceptionToWorkflowHistory(ListItem.ToString(), executionContext, WorkflowInstanceId);
SPListItem destinoItem = destinoList.Items.Add();
CopyFieldValues(sourceItem, destinoItem);
destinoItem.SystemUpdate();
sourceItem.Delete();
IdRetorno = destinoItem.ID;
}
}
});
}
catch (Exception ex) {
if (!System.Diagnostics.EventLog.SourceExists("MyApp1"))
System.Diagnostics.EventLog.CreateEventSource(
"MyApp1", "Application");
EventLog EventLog1 = new EventLog();
EventLog1.Source = "MyApp1";
EventLog1.WriteEntry(ex.Message,EventLogEntryType.FailureAudit);
LogExceptionToWorkflowHistory(ex.Message, executionContext, WorkflowInstanceId);
}
OutListItemID = IdRetorno;
return base.Execute(executionContext);
}
thanks