Esempio n. 1
0
        private void GetLeaveTaskList(LeaveManagementDAL leaveManagementDAL)
        {
            var query = _filterTaskManager.BuildApprovalTaskListQuery(StepModuleList.LeaveManagement.ToString(), _currentUserADId, DateTime.Now);

            if (this.CountOnly)
            {
                TotalCount += leaveManagementDAL.CountByQuery(query);
            }
            else
            {
                var leaveManagementList = leaveManagementDAL.GetByQuery(query);
                if (leaveManagementList != null && leaveManagementList.Count > 0)
                {
                    foreach (var leaveManagement in leaveManagementList)
                    {
                        var filterTask = new FilterTask(leaveManagement);
                        filterTask.ApprovalStatusId = leaveManagement.ApprovalStatus == Status.Approved ? ApprovedStatusId
                            : leaveManagement.ApprovalStatus == Status.Rejected ? RejectedStatusId
                            : InProgressStatusId;
                        FilterTaskList.Add(filterTask);
                    }
                }
            }
        }
        private void GetLeaveTaskList(LeaveManagementDAL leaveManagementDAL)
        {
            var        taskListQuery    = _filterTaskManager.BuildTaskListQuery(StepModuleList.LeaveManagement.ToString(), TaskStatusList.InProgress.ToString(), _currentUserADId);
            List <int> delegatedItemIDs = this.DelegationList.Where(d => d.ListUrl == LeaveManagementList.ListUrl).Select(d => d.ListItemID).ToList();
            var        delegationQuery  = _filterTaskManager.BuildApprovedByDelegationQuery(_currentUserADId, string.Empty, string.Empty, delegatedItemIDs);

            var query = $@"<Where>
                                <And>
                                    <Or>
                                        {taskListQuery}
                                        {delegationQuery}
                                    </Or>
                                    <Or>
                                        <Or>
                                            <And>
                                                <And>
                                                    <Gt>
                                                        <FieldRef Name='{LeaveManagementList.TotalDaysField}' />
                                                        <Value Type='Number'>0</Value>
                                                    </Gt>
                                                    <Lt>
                                                        <FieldRef Name='{LeaveManagementList.TotalDaysField}' />
                                                        <Value Type='Number'>3</Value>
                                                    </Lt>
                                                </And>
                                                <Gt>
                                                    <FieldRef Name='{CommonSPListField.CommonReqDueDateField}' />
                                                    <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.AddDays(1).ToString(StringConstant.DateFormatForCAML)}</Value>
                                                </Gt>
                                            </And>
                                            <And>
                                                <And>
                                                    <Geq>
                                                        <FieldRef Name='{LeaveManagementList.TotalDaysField}' />
                                                        <Value Type='Number'>3</Value>
                                                    </Geq>
                                                    <Lt>
                                                        <FieldRef Name='{LeaveManagementList.TotalDaysField}' />
                                                        <Value Type='Number'>5</Value>
                                                    </Lt>
                                                </And>
                                                <Geq>
                                                    <FieldRef Name='{CommonSPListField.CommonReqDueDateField}' />
                                                    <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.AddDays(3).ToString(StringConstant.DateFormatForCAML)}</Value>
                                                </Geq>
                                            </And>
                                        </Or>
                                        <And>
                                            <Geq>
                                                <FieldRef Name='{LeaveManagementList.TotalDaysField}' />
                                                <Value Type='Number'>5</Value>
                                            </Geq>
                                            <Gt>
                                                <FieldRef Name='{CommonSPListField.CommonReqDueDateField}' />
                                                <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.AddDays(15).ToString(StringConstant.DateFormatForCAML)}</Value>
                                            </Gt>
                                        </And>
                                    </Or>
                                </And>
                            </Where>";

            if (this.CountOnly)
            {
                TotalCount += leaveManagementDAL.CountByQuery(query);
            }
            else
            {
                var leaveManagementList = leaveManagementDAL.GetByQuery(query);

                if (leaveManagementList != null)
                {
                    foreach (var leaveManagement in leaveManagementList)
                    {
                        var filterTask = new FilterTask(leaveManagement);
                        filterTask.ApprovalStatusId = ApprovalStatusId;
                        FilterTaskList.Add(filterTask);
                    }
                }
            }
        }