public static void UpdateWorkflowPath(WorkflowContext context, string wfNoFieldName) { try { if (context != null) { FieldInfo field = context.GetType().GetField("_WorkflowVariables", BindingFlags.NonPublic | BindingFlags.Instance); WorkflowVariableValues workflowVariables = field.GetValue(context) as WorkflowVariableValues; SPList unlockWorkflowList = SPContext.Current.Web.Lists[WorkflowListName.UnLockWorkflow]; QueryField titleField = new QueryField("Title"); QueryField wfListField = new QueryField("WorkflowListName"); CamlExpression exp = titleField.Equal(context.DataFields[wfNoFieldName].AsString()) && wfListField.Equal(SPContext.Current.List.Title); SPListItemCollection items = ListQuery.Select().From(unlockWorkflowList).Where(exp).GetItems(); if (items.Count > 0) { SPListItem item = items[0]; item["EventData"] += string.Format("{0}#;", SerializeUtil.Serialize(workflowVariables)); item.Update(); } else { SPListItem newItem = unlockWorkflowList.Items.Add(); newItem[SPBuiltInFieldId.Title] = context.DataFields[wfNoFieldName].AsString(); newItem["WorkflowListName"] = SPContext.Current.List.Title; newItem["EventData"] = string.Format("{0}#;", SerializeUtil.Serialize(workflowVariables)); newItem.Update(); } //CommonUtil.logInfo(string.Format("TaskOutcome:{0}", context.Task.Outcome)); } } catch (Exception ex) { CommonUtil.logError(string.Format("[UpdateWorkflowPath]:{0}", ex.StackTrace)); } }