public List <Biz.Models.WorkflowHistory> GetWorkflowHistory(WorkflowHistoryDAL workflowHistoryDAL, string listName, int itemID) { List <Biz.Models.WorkflowHistory> workflowHistoryItems = null; try { string queryString = string.Format(@"<Where> <And> <Eq> <FieldRef Name='{0}' /> <Value Type='Text'>{1}</Value> </Eq> <Eq> <FieldRef Name='{2}' /> <Value Type='Number'>{3}</Value> </Eq> </And> </Where>", WorkflowHistoryList.Fields.ListName, listName, WorkflowHistoryList.Fields.CommonItemID, itemID); workflowHistoryItems = workflowHistoryDAL.GetByQuery(queryString); } catch (Exception ex) { ULSLogging.LogError(ex); } return(workflowHistoryItems); }
public string BuildApprovalWorkflowHistoryQuery(string listName, string approverName, DateTime date) { var query = $@"<Where> <And> <And> <Eq> <FieldRef Name='{WorkflowHistoryList.Fields.CommonDate}' /> <Value IncludeTimeValue='FALSE' Type='DateTime'>{date.ToString(StringConstant.DateFormatForCAML)}</Value> </Eq> <Eq> <FieldRef Name='{WorkflowHistoryList.Fields.PostedBy}' /> <Value Type='Text'>{approverName}</Value> </Eq> </And> <And> <Eq> <FieldRef Name='{WorkflowHistoryList.Fields.ListName}' /> <Value Type='Text'>{listName}</Value> </Eq> <Or> <Eq> <FieldRef Name='{WorkflowHistoryList.Fields.Status}' /> <Value Type='Text'>{Status.Approved}</Value> </Eq> <Eq> <FieldRef Name='{WorkflowHistoryList.Fields.Status}' /> <Value Type='Text'>{Status.Rejected}</Value> </Eq> </Or> </And> </And> </Where>"; var approvalList = _workFlowHistory.GetByQuery(query); if (approvalList != null && approvalList.Any()) { IEnumerable <int> requestItemIds = approvalList.Select(x => x.CommonItemID).Distinct(); StringBuilder sbItem = new StringBuilder(); foreach (var itemId in requestItemIds) { sbItem.Append($@"<Value Type='Counter'>{itemId}</Value>"); } return($@"<Where> <In> <FieldRef Name='ID' /> <Values> {sbItem.ToString()} </Values> </In> </Where>"); } // Default condition - EMPTY: return($@"<Where> <Eq> <FieldRef Name='ID' /> <Value Type='Counter'>0</Value> </Eq> </Where>"); }