public string BuildTaskListQuery(string listName, string status, int userAdId) { var query = $@"<Where> <And> <Eq> <FieldRef Name='Status' /> <Value Type='Choice'>{status}</Value> </Eq> <And> <Eq> <FieldRef Name='StepModule' /> <Value Type='Choice'>{listName}</Value> </Eq> <Eq> <FieldRef Name='AssignedTo' LookupId='TRUE' /> <Value Type='User'>{userAdId}</Value> </Eq> </And> </And> </Where>"; List <TaskManagement> taskManagementCollection = _taskManagementDAL.GetByQuery(query); if (taskManagementCollection != null && taskManagementCollection.Count > 0) { IEnumerable <int> itemIds = taskManagementCollection.Where(t => t.ItemId > 0).Select(t => t.ItemId).AsEnumerable(); if (itemIds != null && itemIds.Any()) { StringBuilder sbItem = new StringBuilder(); foreach (var itemId in itemIds) { sbItem.Append($@"<Value Type='Counter'>{itemId}</Value>"); } return($@" <In> <FieldRef Name='ID' /> <Values> {sbItem.ToString()} </Values> </In> "); } } // Default condition - EMPTY: return($@"<Eq> <FieldRef Name='ID' /> <Value Type='Counter'>0</Value> </Eq>"); }
private XElement BuildViewString(int assigneeId, string siteUrl) { XElement filterElement = null; string filterStr = "<Eq><FieldRef Name='ID' /><Value Type='Counter'>0</Value></Eq>"; TaskManagementDAL _taskManagementDAL = new TaskManagementDAL(siteUrl); string taskQueryStr = string.Format(@"<Where> <And> <Eq> <FieldRef Name='Status' /> <Value Type='Choice'>{0}</Value> </Eq> <And> <Eq> <FieldRef Name='StepModule' /> <Value Type='Choice'>{1}</Value> </Eq> <Eq> <FieldRef Name='AssignedTo' LookupId='TRUE' /> <Value Type='User'>{2}</Value> </Eq> </And> </And> </Where>", TaskStatusList.InProgress.ToString(), StepModuleList.FreightManagement.ToString(), assigneeId); List <TaskManagement> taskManagementCollection = _taskManagementDAL.GetByQuery(taskQueryStr); if (taskManagementCollection != null && taskManagementCollection.Count > 0) { List <int> itemIds = taskManagementCollection.Where(t => t.ItemId > 0).Select(t => t.ItemId).ToList(); if (itemIds != null && itemIds.Count > 0) { filterStr = ""; foreach (var itemId in itemIds) { filterStr += string.Format("<Value Type='Counter'>{0}</Value>", itemId); } if (!string.IsNullOrEmpty(filterStr)) { filterStr = string.Format("<In><FieldRef Name='ID'/><Values>{0}</Values></In>", filterStr); } } } filterElement = XElement.Parse(filterStr); return(filterElement); }
public bool HasApprovalPermission(string vehicleId) { string siteUrl = SPContext.Current.Site.Url; EmployeeInfoDAL _employeeInfoDAL = new EmployeeInfoDAL(siteUrl); TaskManagementDAL _taskManagementDAL = new TaskManagementDAL(siteUrl); EmployeeInfo employeeInfo = _employeeInfoDAL.GetByADAccount(SPContext.Current.Web.CurrentUser.ID); string taskQueryStr = string.Format(@"<Where> <And> <Eq> <FieldRef Name='Status' /> <Value Type='Choice'>{0}</Value> </Eq> <And> <Eq> <FieldRef Name='StepModule' /> <Value Type='Choice'>{1}</Value> </Eq> <And> <Eq> <FieldRef Name='AssignedTo' LookupId='TRUE' /> <Value Type='User'>{2}</Value> </Eq> <Eq> <FieldRef Name='ItemId' /> <Value Type='Number'>{3}</Value> </Eq> </And> </And> </And> </Where>", TaskStatusList.InProgress.ToString(), StepModuleList.VehicleManagement.ToString(), employeeInfo.ADAccount.ID, vehicleId); List <TaskManagement> taskManagementCollection = _taskManagementDAL.GetByQuery(taskQueryStr); if (taskManagementCollection != null && taskManagementCollection.Count > 0) { return(true); } return(false); }
public DelegationModel GetDelegatedTaskInfo(string Id) { DelegationModel delegationModel = new DelegationModel(); int listItemId = 0; if (int.TryParse(Id, out listItemId)) { string[] viewFields = new string[] { StringConstant.VehicleManagementList.DH, StringConstant.VehicleManagementList.BOD, StringConstant.CommonSPListField.ApprovalStatusField, StringConstant.CommonSPListField.CommonDepartmentField }; string queryStr = $@"<Where> <Eq> <FieldRef Name='ID' /> <Value Type='Counter'>{listItemId}</Value> </Eq> </Where>"; string siteUrl = SPContext.Current.Site.Url; List <Biz.Models.VehicleManagement> vehicleManagementCollection = _vehicleManagementDAL.GetByQuery(queryStr, viewFields); if (vehicleManagementCollection != null && vehicleManagementCollection.Count > 0) { Biz.Models.VehicleManagement vehicleManagement = vehicleManagementCollection[0]; StepManagementDAL _stepManagementDAL = new StepManagementDAL(siteUrl); var currentStep = _stepManagementDAL.GetStepManagement(vehicleManagement.ApprovalStatus, StepModuleList.VehicleManagement, vehicleManagement.CommonDepartment.LookupId); if (currentStep != null) { TaskManagementDAL _taskManagementDAL = new TaskManagementDAL(siteUrl); string taskQueryStr = string.Format(@"<Where> <And> <Eq> <FieldRef Name='Status' /> <Value Type='Choice'>{0}</Value> </Eq> <And> <Eq> <FieldRef Name='StepModule' /> <Value Type='Choice'>{1}</Value> </Eq> <And> <Eq> <FieldRef Name='CurrentStepStatus' /> <Value Type='Choice'>{2}</Value> </Eq> <Eq> <FieldRef Name='ItemId' /> <Value Type='Number'>{3}</Value> </Eq> </And> </And> </And> </Where>", TaskStatusList.InProgress.ToString(), StepModuleList.VehicleManagement.ToString(), vehicleManagement.ApprovalStatus, vehicleManagement.ID); List <TaskManagement> taskManagementCollection = _taskManagementDAL.GetByQuery(taskQueryStr); if (taskManagementCollection != null) { EmployeeInfoDAL _employeeInfoDAL = new EmployeeInfoDAL(siteUrl); foreach (var taskManagement in taskManagementCollection) { EmployeeInfo assigneeInfo = _employeeInfoDAL.GetByADAccount(taskManagement.AssignedTo.ID); Delegation delegation = DelegationPermissionManager.IsDelegation(assigneeInfo.ID, StringConstant.VehicleManagementList.ListUrl, vehicleManagement.ID); delegationModel = new DelegationModel(delegation); if (delegationModel.Requester.LookupId > 0) { break; } } } } } } return(delegationModel); }