我正在visualstudio 2010 中为sharepoint 2010 创建一个审批工作流。工作流在开始时创建一个任务,然后等待批准该任务。但是如何检查任务是否被批准?
也许我更详细地描述了我的 szebario:
- 我有一个添加后必须审查的项目列表。
- 如果他们被批准或拒绝,这是一个绝对的决定,永远不应该改变
- 如果项目获得批准,一些功能应该被解雇
- 如果被拒绝,应该发送邮件!
我的想法:
想法 - 工作流程:
我的第一个想法是创建一个在添加 ListItemd 后触发的工作流。WF 应该创建一个可以审查的任务。如果是肯定的,它应该触发一些功能并自行删除。
Idea-工作流程设计:
Idea-工作流程代码:
public Guid workflowId = default(System.Guid);
public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties();
// these properties are for the workflow task that will be created.
public SPWorkflowTaskProperties CreateTaskApproval_TaskProperties = new SPWorkflowTaskProperties();
public SPWorkflowTaskProperties CreateTaskApproval_AffterTaskProperties = new SPWorkflowTaskProperties();
public SPWorkflowTaskProperties CreateTaskApproval_BeforeTaskProperties = new SPWorkflowTaskProperties();
public String CreateTaskApproval_ContentTypeId = default(System.String);
public Int32 CreateTaskApproval_ListItemId = default(System.Int32);
public Guid CreateTaskApproval_TaskId = default(System.Guid);
private void createTask1_MethodInvoking(object sender, EventArgs e)
{
createTask1.TaskId = new Guid();
// Now create the approval task.
// Set up some of the properties.
CreateTaskApproval_TaskId = Guid.NewGuid();
//Setting the task properties
CreateTaskApproval_TaskProperties.Title = "TestTitle"
CreateTaskApproval_TaskProperties.Description = "Description";
CreateTaskApproval_TaskProperties.AssignedTo = @"testemail\testuser";
CreateTaskApproval_TaskProperties.SendEmailNotification = false;
CreateTaskApproval_TaskProperties.TaskType = 1;
LogComment("Request Task Created.");
}
private void onTaskChanged1_Invoked(object sender, ExternalDataEventArgs e)
{
try
{
//!!!! The Problem is here at Status
// Check to make sure the field is there on the item.
if (CreateTaskApproval_TaskProperties.ExtendedProperties["Status"] != null)
{
// Evaluate the value of the field.
if (CreateTaskApproval_TaskProperties.ExtendedProperties["Status"].ToString() == "Approved" || CreateTaskApproval_TaskProperties.ExtendedProperties["Status"].ToString() == "Declined")
{
TaskApproval_ApproveComplete = true;
}
else
{
TaskApproval_ApproveComplete = false;
}
}
else
{
// This should never happen because there is a default, but always good just in case.
TaskApproval_ApproveComplete = false;
}
}
catch (Exception ex)
{
TaskApproval_ApproveComplete = false;
LogComment(ex.ToString());
}
}
private void completeTask1_MethodInvoking(object sender, EventArgs e)
{
workflowProperties.Item.ModerationInformation.Status = SPModerationStatusType.Approved;
//Fire some code
}
想法 - 工作流程 - 问题:我根本无法获得任务审核状态。(“批准”等)
CreateTaskApproval_TaskProperties.ExtendedProperties["Status"]
有没有人知道怎么做?