private void GetRequestTaskList(RequestsDAL requestDAL) { var requestByValue = "Mua hàng/Buy new materials or equipments"; List <int> delegatedItemIDs = this.DelegationList.Where(d => d.ListUrl == RequestsList.Url).Select(d => d.ListItemID).ToList(); var delegationQuery = _filterTaskManager.BuildApprovedByDelegationQuery(_currentUserInfoId, RequestsList.CommonCreatorField, "Lookup", delegatedItemIDs); var query = $@"<Where> <And> <And> {delegationQuery} <Eq> <FieldRef Name='{ApprovalFields.WFStatus}' /> <Value Type='Text'>{StringConstant.ApprovalStatus.InProcess}</Value> </Eq> </And> <Or> <And> <Neq> <FieldRef Name='{RequestsList.RequestTypeRefField}'/> <Value Type='Lookup'>{requestByValue}</Value> </Neq> <Geq> <FieldRef Name='{RequestsList.FinishDateField}' /> <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.ToString(StringConstant.DateFormatForCAML)}</Value> </Geq> </And> <And> <Eq> <FieldRef Name='{RequestsList.RequestTypeRefField}'/> <Value Type='Lookup'>{requestByValue}</Value> </Eq> <Leq> <FieldRef Name='{StringConstant.DefaultSPListField.CreatedField}' /> <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.ToString(StringConstant.DateFormatForCAML)}</Value> </Leq> </And> </Or> </And> </Where>"; if (this.CountOnly) { TotalCount += requestDAL.CountByQuery(query); } else { var requestManagementList = requestDAL.GetByQuery(query); if (requestManagementList != null && requestManagementList.Count > 0) { foreach (var requestManagement in requestManagementList) { var filterTask = new FilterTask(requestManagement); filterTask.ApprovalStatusId = ApprovalStatusId; FilterTaskList.Add(filterTask); } } } }
private void GetChangeShiftTaskList(ChangeShiftManagementDAL changeShiftManagementDAL) { List <int> delegatedItemIDs = this.DelegationList.Where(d => d.ListUrl == ChangeShiftList.ListUrl).Select(d => d.ListItemID).ToList(); var delegationQuery = _filterTaskManager.BuildApprovedByDelegationQuery(_currentUserADId, ChangeShiftList.DHField, "User", delegatedItemIDs); var query = $@"<Where> <And> <And> {delegationQuery} <Gt> <FieldRef Name='{StringConstant.ChangeShiftList.FromDateField}' /> <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.AddDays(1).ToString(StringConstant.DateFormatForCAML)}</Value> </Gt> </And> <IsNull> <FieldRef Name='ApprovalStatus' /> </IsNull> </And> </Where>"; if (this.CountOnly) { TotalCount += changeShiftManagementDAL.CountByQuery(query); } else { var changeShiftManagementList = changeShiftManagementDAL.GetByQuery(query); if (changeShiftManagementList != null) { foreach (var changeShiftManagement in changeShiftManagementList) { var filterTask = new FilterTask(changeShiftManagement); filterTask.ApprovalStatusId = ApprovalStatusId; FilterTaskList.Add(filterTask); } } } }
private void GetShiftTaskList(ShiftManagementDAL shiftManagementDAL) { int year = DateTime.Now.Year; int month = DateTime.Now.Month; int day = DateTime.Now.Day; List <int> delegatedItemIDs = this.DelegationList.Where(d => d.ListUrl == ShiftManagementList.ListUrl).Select(d => d.ListItemID).ToList(); var delegationQuery = _filterTaskManager.BuildApprovedByDelegationQuery(_currentUserADId, ShiftManagementList.ApprovedByField, "User", delegatedItemIDs); var query = $@"<Where> <And> {delegationQuery} <Or> <And> <Eq> <FieldRef Name='{ShiftManagementList.YearField}' /> <Value Type='Number'>{year}</Value> </Eq> <Geq> <FieldRef Name='{ShiftManagementList.MonthField}' /> <Value Type='Number'>{month}</Value> </Geq> </And> <Gt> <FieldRef Name='{ShiftManagementList.YearField}' /> <Value Type='Number'>{year}</Value> </Gt> </Or> </And> </Where>"; var shiftManagementList = shiftManagementDAL.GetByQuery(query); if (shiftManagementList != null && shiftManagementList.Count > 0) { var isValid = false; Type typeShiftManagementDetail = typeof(ShiftManagementDetail); BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public; foreach (var shiftManagement in shiftManagementList) { isValid = true; if (shiftManagement.Year == year) { if (shiftManagement.Month == month) // VALID: Current Day <= 20 { if (day > 20) { isValid = false; } } else if (shiftManagement.Month - 1 == month) // VALID: >=21. Shif Thang 12: 21/11 -> 20/12 -> Thang hien tai 11: >= 21/11 { if (day < 21) { isValid = false; } } } //else if (year == shiftManagement.Year - 1) //{ // if (month == 12) // 21/12/2016 -> 20/1/2017: Shift Thang 1/2017 0> Thang hien tai: 12/2016 // if (day < 21) // isValid = false; //} if (isValid) { var isApproved = true; var shiftManagementDetails = _shiftManagementDetailDAL.GetByShiftManagementID(shiftManagement.ID); if (shiftManagementDetails != null && shiftManagementDetails.Any()) { foreach (var shiftManagementDetail in shiftManagementDetails) { if (!isApproved) { break; } for (int i = 1; i <= 31; i++) { PropertyInfo shiftTimeInfo = typeShiftManagementDetail.GetProperty(string.Format("ShiftTime{0}", i), bindingFlags); object shiftTimeValue = shiftTimeInfo.GetValue(shiftManagementDetail, null); if (shiftTimeValue != null) { LookupItem shiftTimeValueObj = shiftTimeValue as LookupItem; if (!string.IsNullOrEmpty(shiftTimeValueObj.LookupValue)) { PropertyInfo shiftTimeApprovalInfo = typeShiftManagementDetail.GetProperty(string.Format("ShiftTime{0}Approval", i), bindingFlags); object shiftTimeApprovalValue = shiftTimeApprovalInfo.GetValue(shiftManagementDetail, null); if (shiftTimeApprovalValue != null && Convert.ToBoolean(shiftTimeApprovalValue) == false) { isApproved = false; } } } } } } if (!isApproved) { var filterTask = new FilterTask(shiftManagement); filterTask.ApprovalStatusId = ApprovalStatusId; FilterTaskList.Add(filterTask); // Count tasks this.TotalCount++; } } } } }