Ejemplo n.º 1
0
        private void GetRequestTaskList(RequestsDAL requestDAL)
        {
            var query = _filterTaskManager.BuildApprovalWorkflowHistoryQuery(RequestsList.ListName, this.ApproverFullName, DateTime.Now);

            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 = requestManagement.WFStatus == ApprovalStatus.Approved ? ApprovedStatusId
                            : requestManagement.WFStatus == ApprovalStatus.InProcess ? InProcessStatusId
                            : requestManagement.WFStatus == ApprovalStatus.Completed ? CompletedId
                            : requestManagement.WFStatus == ApprovalStatus.Rejected ? RejectedStatusId
                            : InProgressStatusId;
                        FilterTaskList.Add(filterTask);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void GetCertificateTaskList(RequestForDiplomaSupplyDAL certificateDAL)
        {
            List <int> delegatedItemIDs = this.DelegationList.Where(d => d.ListUrl == RequestForDiplomaSuppliesList.Url).Select(d => d.ListItemID).ToList();
            var        delegationQuery  = _filterTaskManager.BuildApprovedByDelegationQuery(_currentUserInfoId, RequestForDiplomaSuppliesList.Fields.PendingAtField, "Lookup", delegatedItemIDs);

            var query = $@"<Where>
                                <And>
                                    {delegationQuery}
                                    <Eq>
                                        <FieldRef Name='{ApprovalFields.WFStatus}' />
                                        <Value Type='Text'>{StringConstant.ApprovalStatus.InProgress}</Value>
                                    </Eq>
                                </And>
                            </Where>";

            if (this.CountOnly)
            {
                TotalCount += certificateDAL.CountByQuery(query);
            }
            else
            {
                var certificateManagementList = certificateDAL.GetByQuery(query);
                if (certificateManagementList != null && certificateManagementList.Count > 0)
                {
                    foreach (var certificateManagement in certificateManagementList)
                    {
                        var filterTask = new FilterTask(certificateManagement);
                        filterTask.ApprovalStatusId = ApprovalStatusId;
                        FilterTaskList.Add(filterTask);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void GetOvertimeTaskList(OverTimeManagementDAL overTimeManagementDAL)
        {
            var query = $@"<Where>
                                <Or>
                                    <And>
                                        <Eq>
                                            <FieldRef Name='{StringConstant.OverTimeManagementList.FirstApprovedByField}' LookupId='TRUE' />
                                            <Value Type='User'>{_currentUserADId}</Value>
                                        </Eq>
                                        <Eq>
                                            <FieldRef Name='{StringConstant.OverTimeManagementList.FirstApprovedDateField}' />
                                            <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.ToString(StringConstant.DateFormatForCAML)}</Value>
                                        </Eq>
                                    </And>
                                    <And>
                                        <Or>
                                            <Eq>
                                                <FieldRef Name='{StringConstant.CommonSPListField.ApprovalStatusField}' />
                                                <Value Type='Text'>true</Value>
                                            </Eq>
                                            <Eq>
                                                <FieldRef Name='{StringConstant.CommonSPListField.ApprovalStatusField}' />
                                                <Value Type='Text'>false</Value>
                                            </Eq>
                                        </Or>
                                        <And>
                                            <Eq>
                                                <FieldRef Name='{StringConstant.OverTimeManagementList.ApprovedByField}' LookupId='TRUE' />
                                                <Value Type='User'>{_currentUserADId}</Value>
                                            </Eq>
                                            <Eq>
                                                <FieldRef Name='{StringConstant.DefaultSPListField.ModifiedField}' />
                                                <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.ToString(StringConstant.DateFormatForCAML)}</Value>
                                            </Eq>
                                        </And>
                                    </And>
                                </Or>
                            </Where>";

            if (this.CountOnly)
            {
                TotalCount += overTimeManagementDAL.CountByQuery(query);
            }
            else
            {
                var overtimeManagementList = overTimeManagementDAL.GetByQuery(query);
                if (overtimeManagementList != null && overtimeManagementList.Count > 0)
                {
                    foreach (var overtimeManagement in overtimeManagementList)
                    {
                        var filterTask = new FilterTask(overtimeManagement);
                        filterTask.ApprovalStatusId = overtimeManagement.ApprovalStatus == "true" ? ApprovedStatusId
                            : overtimeManagement.ApprovalStatus == "false" ? RejectedStatusId
                            : InProgressStatusId;
                        FilterTaskList.Add(filterTask);
                    }
                }
            }
        }
        public IHttpActionResult GetByFilter()
        {
            FilterTask filter     = new FilterTask();
            var        repository = new RepositoryBusinessProfiles();
            var        response   = repository.GetAllList("ddd", filter);

            return(Ok <DataResponse <EntityList <EntityBusinessProfile> > >(response));
        }
        private void GetRecruitmentTaskList(EmployeeRequirementSheetDAL recruitmentDAL)
        {
            // Ngay can nhan su <= NOW + 15 + 1
            List <int> delegatedItemIDs = this.DelegationList.Where(d => d.ListUrl == EmployeeRequirementSheetsList.Url).Select(d => d.ListItemID).ToList();
            var        delegationQuery  = _filterTaskManager.BuildApprovedByDelegationQuery(_currentUserInfoId, EmployeeRequirementSheetsList.Fields.PendingAtField, "Lookup", delegatedItemIDs);

            var query = $@"<Where>
                            <And>
                                <And>
                                    {delegationQuery}
                                    <Eq>
                                        <FieldRef Name='{ApprovalFields.WFStatus}' />
                                        <Value Type='Text'>{StringConstant.ApprovalStatus.InProgress}</Value>
                                    </Eq>
                                </And>
                                <Or>
                                    <Eq>
                                        <FieldRef Name='{CommonSPListField.CommonReqDueDateField}' />
                                        <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.AddDays(16).ToString(StringConstant.DateFormatForCAML)}</Value>
                                    </Eq>
                                    <Or>
                                        <Eq>
                                            <FieldRef Name='{CommonSPListField.CommonReqDueDateField}' />
                                            <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.AddDays(17).ToString(StringConstant.DateFormatForCAML)}</Value>
                                        </Eq>
                                        <And>
                                            <Geq>
                                                <FieldRef Name='{CommonSPListField.CommonReqDueDateField}' />
                                                <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.ToString(StringConstant.DateFormatForCAML)}</Value>
                                            </Geq>
                                            <Lt>
                                                <FieldRef Name='{CommonSPListField.CommonReqDueDateField}' />
                                                <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.AddDays(16).ToString(StringConstant.DateFormatForCAML)}</Value>
                                            </Lt>
                                        </And>
                                    </Or>
                                </Or>
                            </And>
                        </Where>";

            if (this.CountOnly)
            {
                TotalCount += recruitmentDAL.CountByQuery(query);
            }
            else
            {
                var recruitmentManagementList = recruitmentDAL.GetByQuery(query);
                if (recruitmentManagementList != null && recruitmentManagementList.Count > 0)
                {
                    foreach (var recruitmentManagement in recruitmentManagementList)
                    {
                        var filterTask = new FilterTask(recruitmentManagement);
                        filterTask.ApprovalStatusId = ApprovalStatusId;
                        FilterTaskList.Add(filterTask);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        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.PendingAtField, "Lookup", delegatedItemIDs);

            var query = $@"<Where>
                            <And>
                                <And>
                                    {delegationQuery}
                                    <Eq>
                                        <FieldRef Name='{ApprovalFields.WFStatus}' />
                                        <Value Type='Text'>{StringConstant.ApprovalStatus.InProgress}</Value>
                                    </Eq>
                                </And>
                                <Or>
                                    <And>
                                        <Neq>
                                            <FieldRef Name='{RequestsList.RequestTypeRefField}'/>
                                            <Value Type='Lookup'>{requestByValue}</Value>
                                        </Neq>
                                        <Gt>
                                            <FieldRef Name='{RequestsList.FinishDateField}' />
                                            <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.AddDays(1).ToString(StringConstant.DateFormatForCAML)}</Value>
                                        </Gt>
                                    </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);
                    }
                }
            }
        }
Ejemplo n.º 7
0
    // 观看二级节点的其他片断
    protected void filter_TreeItemClick(object sender, TreeItemClickEventArgs e)
    {
        string     strError         = "";
        string     strResultsetName = this.filter.ResultSetName;
        FilterTask t = app.FindFilterTask(strResultsetName);    // Task对象是利用Session内结果集名来进行管理的

        if (t == null)
        {
            strError = "结果集名 '" + strResultsetName + "' 没有找到对应的任务对象";
            goto ERROR1;
        }
        if (t.TaskState == TaskState.Processing)
        {
            strError = "任务对象 '" + strResultsetName + "' 正在创建过程中,请稍后再访问";
            goto ERROR1;
        }

        string strParameters = this.filter.SelectedNodePath;

        string[] parameters = strParameters.Split(new char[] { ',' });
        string   strNode    = "";
        int      nStart     = 0;

        if (parameters.Length >= 1)
        {
            strNode = parameters[0];
        }
        if (parameters.Length >= 2)
        {
            Int32.TryParse(parameters[1], out nStart);
        }

        int nRet = ResultsetFilter.SwitchPage(ref t.ResultItems,
                                              strNode,
                                              nStart,
                                              out strError);

        if (nRet == -1)
        {
            goto ERROR1;
        }

        // 确保上一级被选定。但此时和右边的 browselist 内容就不对应了
        this.filter.SelectedNodePath = GetParentResultsetName(this.filter.SelectedNodePath) + "/nav";
        return;

ERROR1:
        Response.Write(HttpUtility.HtmlEncode(strError));
        Response.End();
    }
Ejemplo n.º 8
0
        private void GetNotOvertimeTaskList(NotOvertimeManagementDAL notOvertimeManagementDAL)
        {
            var dueDate = DateTime.Now.AddDays(1);

            var query = $@"<Where>
                                <And>
                                    <Or>
                                        <Eq>
                                            <FieldRef Name='{StringConstant.CommonSPListField.ApprovalStatusField}' />
                                            <Value Type='Text'>Approved</Value>
                                        </Eq>
                                        <Eq>
                                            <FieldRef Name='{StringConstant.CommonSPListField.ApprovalStatusField}' />
                                            <Value Type='Text'>Rejected</Value>
                                        </Eq>
                                    </Or>
                                    <And>
	                                    <Eq>
                                            <FieldRef Name='{StringConstant.NotOvertimeList.DHField}' LookupId='TRUE' />
                                            <Value Type='User'>{_currentUserADId}</Value>
                                        </Eq>
                                        <Eq>
                                            <FieldRef Name='{StringConstant.DefaultSPListField.ModifiedField}' />
                                            <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.ToString(StringConstant.DateFormatForCAML)}</Value>
                                        </Eq>
                                    </And>
                                </And>
                            </Where>";

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

                if (notOvertimeManagementList != null)
                {
                    foreach (var notOvertimeManagement in notOvertimeManagementList)
                    {
                        var filterTask = new FilterTask(notOvertimeManagement);
                        filterTask.ApprovalStatusId = notOvertimeManagement.ApprovalStatus == "Approved" ? ApprovedStatusId : RejectedStatusId;
                        FilterTaskList.Add(filterTask);
                    }
                }
            }
        }
        private void GetGuestReceptionTaskList(GuestReceptionManagementDAL guestReceptionManagementDAL)
        {
            List <int> delegatedItemIDs = this.DelegationList.Where(d => d.ListUrl == GuestReceptionManagementList.Url).Select(d => d.ListItemID).ToList();
            var        delegationQuery  = _filterTaskManager.BuildApprovedByDelegationQuery(_currentUserInfoId, GuestReceptionManagementList.Fields.PendingAtField, "Lookup", delegatedItemIDs);

            // Thuan todo
            var query = string.Empty;

            //var query = $@"<Where>
            //                <And>
            //                    <And>
            //                        {delegationQuery}
            //                        <Eq>
            //                            <FieldRef Name='{ApprovalFields.WFStatus}' />
            //                            <Value Type='Text'>{StringConstant.ApprovalStatus.InProgress}</Value>
            //                        </Eq>
            //                    </And>
            //                    <Or>
            //                        <Eq>
            //                            <FieldRef Name='{RequirementForGuestReceptionList.Fields.StartDate}' />
            //                            <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.ToString(StringConstant.DateFormatForCAML)}</Value>
            //                        </Eq>
            //                        <Eq>
            //                            <FieldRef Name='{RequirementForGuestReceptionList.Fields.StartDate}' />
            //                            <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.AddDays(1).ToString(StringConstant.DateFormatForCAML)}</Value>
            //                        </Eq>
            //                    </Or>
            //                </And>
            //                </Where>";

            if (this.CountOnly)
            {
                TotalCount += guestReceptionManagementDAL.CountByQuery(query);
            }
            else
            {
                var guestReceptionManagementList = guestReceptionManagementDAL.GetByQuery(query);
                if (guestReceptionManagementList != null && guestReceptionManagementList.Count > 0)
                {
                    foreach (var guestReceptionManagement in guestReceptionManagementList)
                    {
                        var filterTask = new FilterTask(guestReceptionManagement);
                        filterTask.ApprovalStatusId = ApprovalStatusId;
                        FilterTaskList.Add(filterTask);
                    }
                }
            }
        }
        private void GetNotOvertimeTaskList(NotOvertimeManagementDAL notOvertimeManagementDAL)
        {
            var dueDate = DateTime.Now.AddDays(1);

            List <int> delegatedItemIDs = this.DelegationList.Where(d => d.ListUrl == NotOvertimeList.ListUrl).Select(d => d.ListItemID).ToList();
            var        delegationQuery  = _filterTaskManager.BuildApprovedByDelegationQuery(_currentUserADId, NotOvertimeList.DHField, "User", delegatedItemIDs);

            var query = $@"<Where>
                                <And>
                                    <And>
	                                    {delegationQuery}
                                        <Or>
                                            <Eq>
                                               <FieldRef Name='{StringConstant.NotOvertimeList.DateField}' />
                                               <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.ToString(StringConstant.DateFormatForCAML)}</Value>
                                            </Eq>
                                            <Eq>
                                               <FieldRef Name='{StringConstant.NotOvertimeList.DateField}' />
                                               <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.AddDays(1).ToString(StringConstant.DateFormatForCAML)}</Value>
                                            </Eq>
                                        </Or>
                                    </And>
	                                <IsNull>
		                                <FieldRef Name='{StringConstant.NotOvertimeList.AprovalStatusField}' />
	                                </IsNull>
                                </And>
                            </Where>";

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

                if (notOvertimeManagementList != null)
                {
                    foreach (var notOvertimeManagement in notOvertimeManagementList)
                    {
                        var filterTask = new FilterTask(notOvertimeManagement);
                        filterTask.ApprovalStatusId = ApprovalStatusId;
                        FilterTaskList.Add(filterTask);
                    }
                }
            }
        }
        private void GetMeetingRoomTaskList(RequisitionOfMeetingRoomDAL requisitionOfMeetingRoomDAL)
        {
            List <int> delegatedItemIDs = this.DelegationList.Where(d => d.ListUrl == RequisitionOfMeetingRoomList.Url).Select(d => d.ListItemID).ToList();
            var        delegationQuery  = _filterTaskManager.BuildApprovedByDelegationQuery(_currentUserInfoId, RequisitionOfMeetingRoomList.Fields.PendingAtField, "Lookup", delegatedItemIDs);

            var query = $@"<Where>
                            <And>
                                <And>
                                    {delegationQuery}
                                    <Eq>
                                        <FieldRef Name='{ApprovalFields.WFStatus}' />
                                        <Value Type='Text'>{StringConstant.ApprovalStatus.InProgress}</Value>
                                    </Eq>
                                </And>
                                <Or>
                                    <Eq>
                                        <FieldRef Name='{RequisitionOfMeetingRoomList.Fields.StartDate}' />
                                        <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.ToString(StringConstant.DateFormatForCAML)}</Value>
                                    </Eq>
                                    <Eq>
                                        <FieldRef Name='{RequisitionOfMeetingRoomList.Fields.StartDate}' />
                                        <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.AddDays(1).ToString(StringConstant.DateFormatForCAML)}</Value>
                                    </Eq>
                                </Or>
                            </And>
                            </Where>";

            if (this.CountOnly)
            {
                TotalCount += requisitionOfMeetingRoomDAL.CountByQuery(query);
            }
            else
            {
                var requisitionOfMeetingRoomList = requisitionOfMeetingRoomDAL.GetByQuery(query);
                if (requisitionOfMeetingRoomList != null && requisitionOfMeetingRoomList.Count > 0)
                {
                    foreach (var requisitionOfMeetingRoom in requisitionOfMeetingRoomList)
                    {
                        var filterTask = new FilterTask(requisitionOfMeetingRoom);
                        filterTask.ApprovalStatusId = ApprovalStatusId;
                        FilterTaskList.Add(filterTask);
                    }
                }
            }
        }
Ejemplo n.º 12
0
        public IHttpActionResult GetByFilter(FilterTask filter)
        {
            string[] allowedRoles         = { "RDTSK" };
            string[] superRoles           = { "RDTSKALL" };
            string[] taskDeletePrivileges = { "DLTALLINTSK" };

            if (HasRight(allowedRoles) || HasRight(superRoles))
            {
                var repository = new RepositoryTask();

                var response = repository.GetTasks(filter, CurrentUserId, CurrentBusinessId, HasSuperRight(superRoles), HasRight(taskDeletePrivileges), true);
                return(Ok <DataResponse <EntityList <EntityTask> > >(response));
            }
            else
            {
                return(Ok <DataResponse>(null));
            }
        }
        private void GetBusinessTripTaskList(BusinessTripManagementDAL businessTripManagementDAL)
        {
            var        taskListQuery    = _filterTaskManager.BuildTaskListQuery(StepModuleList.BusinessTripManagement.ToString(), TaskStatusList.InProgress.ToString(), _currentUserADId);
            List <int> delegatedItemIDs = this.DelegationList.Where(d => d.ListUrl == BusinessTripManagementList.Url).Select(d => d.ListItemID).ToList();
            var        delegationQuery  = _filterTaskManager.BuildApprovedByDelegationQuery(_currentUserADId, string.Empty, string.Empty, delegatedItemIDs);

            var query = $@"<Where>
                                <And>
                                    <Or>
                                        {taskListQuery}
                                        {delegationQuery}
                                    </Or>
                                    <Or>
                                        <Eq>
                                            <FieldRef Name='{CommonSPListField.CommonReqDueDateField}' />
                                            <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.ToString(StringConstant.DateFormatForCAML)}</Value>
                                        </Eq>
                                        <Eq>
                                            <FieldRef Name='{CommonSPListField.CommonReqDueDateField}' />
                                            <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.AddDays(1).ToString(StringConstant.DateFormatForCAML)}</Value>
                                        </Eq>
                                    </Or>
                                </And>
                            </Where>";

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

                if (businessTripManagementList != null)
                {
                    foreach (var businessTripManagement in businessTripManagementList)
                    {
                        var filterTask = new FilterTask(businessTripManagement);
                        filterTask.ApprovalStatusId = ApprovalStatusId;
                        FilterTaskList.Add(filterTask);
                    }
                }
            }
        }
Ejemplo n.º 14
0
 public static FilterTaskModel FromDTO(FilterTask item)
 {
     return(new FilterTaskModel
     {
         ItemId = item.ItemId,
         ModuleId = item.ModuleId,
         ModuleName = item.ModuleName,
         RequesterId = item.Requester.LookupId,
         RequesterName = item.Requester.LookupValue,
         ItemApprovalUrl = item.ItemApprovalUrl,
         DepartmentId = item.Department.LookupId,
         DepartmentName = item.Department.LookupValue,
         Description = item.Description,
         ApprovalStatus = item.ApprovalStatus,
         ApprovalStatusId = item.ApprovalStatusId,
         CreatedDate = item.CreatedDate.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture),
         DueDate = item.DueDate == DateTime.MinValue ? string.Empty : item.DueDate.Value.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture)
     });
 }
Ejemplo n.º 15
0
        private void GetShiftTaskList(ShiftManagementDAL shiftManagementDAL)
        {
            int year  = DateTime.Now.Year;
            int month = DateTime.Now.Month;
            int day   = DateTime.Now.Day;

            var query = $@"<Where>
                                <And>
                                    <And>
                                        <Eq>
                                            <FieldRef Name='{StringConstant.ShiftManagementList.CommonAddApprover1Field}' LookupId='TRUE' />
                                            <Value Type='User'>{_currentUserADId}</Value>
                                        </Eq>
                                        <Eq>
                                            <FieldRef Name='{StringConstant.DefaultSPListField.ModifiedByField}' LookupId='TRUE' />
                                            <Value Type='User'>{_currentUserADId}</Value>
                                        </Eq>
                                    </And>
                                    <Eq>
                                        <FieldRef Name='{StringConstant.DefaultSPListField.ModifiedField}' />
                                        <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.ToString(StringConstant.DateFormatForCAML)}</Value>
                                    </Eq>
                                </And>
                            </Where>";

            if (this.CountOnly)
            {
                TotalCount += shiftManagementDAL.CountByQuery(query);
            }
            else
            {
                var shiftManagementList = shiftManagementDAL.GetByQuery(query);
                if (shiftManagementList != null && shiftManagementList.Count > 0)
                {
                    foreach (var shiftManagement in shiftManagementList)
                    {
                        var filterTask = new FilterTask(shiftManagement);
                        filterTask.ApprovalStatusId = ApprovedStatusId;
                        FilterTaskList.Add(filterTask);
                    }
                }
            }
        }
Ejemplo n.º 16
0
        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);
                    }
                }
            }
        }
Ejemplo n.º 17
0
        private void GetGuestReceptionTaskList(GuestReceptionManagementDAL guestReceptionManagementDAL)
        {
            var query = _filterTaskManager.BuildApprovalWorkflowHistoryQuery(GuestReceptionManagementList.ListName, this.ApproverFullName, DateTime.Now);

            if (this.CountOnly)
            {
                TotalCount += guestReceptionManagementDAL.CountByQuery(query);
            }
            else
            {
                var guestReceptionManagementList = guestReceptionManagementDAL.GetByQuery(query);
                if (guestReceptionManagementList != null && guestReceptionManagementList.Count > 0)
                {
                    foreach (var guestReceptionManagement in guestReceptionManagementList)
                    {
                        var filterTask = new FilterTask(guestReceptionManagement);
                        filterTask.ApprovalStatusId = guestReceptionManagement.WFStatus == Status.Approved ? ApprovedStatusId
                            : guestReceptionManagement.WFStatus == ApprovalStatus.Rejected ? RejectedStatusId
                            : InProgressStatusId;
                        FilterTaskList.Add(filterTask);
                    }
                }
            }
        }
Ejemplo n.º 18
0
        private void GetMeetingRoomTaskList(RequisitionOfMeetingRoomDAL requisitionOfMeetingRoomDAL)
        {
            var query = _filterTaskManager.BuildApprovalWorkflowHistoryQuery(RequisitionOfMeetingRoomList.ListName, this.ApproverFullName, DateTime.Now);

            if (this.CountOnly)
            {
                TotalCount += requisitionOfMeetingRoomDAL.CountByQuery(query);
            }
            else
            {
                var requisitionOfMeetingList = requisitionOfMeetingRoomDAL.GetByQuery(query);
                if (requisitionOfMeetingList != null && requisitionOfMeetingList.Count > 0)
                {
                    foreach (var requisitionOfMeeting in requisitionOfMeetingList)
                    {
                        var filterTask = new FilterTask(requisitionOfMeeting);
                        filterTask.ApprovalStatusId = requisitionOfMeeting.WFStatus == Status.Approved ? ApprovedStatusId
                            : requisitionOfMeeting.WFStatus == ApprovalStatus.Rejected ? RejectedStatusId
                            : InProgressStatusId;
                        FilterTaskList.Add(filterTask);
                    }
                }
            }
        }
Ejemplo n.º 19
0
        private void GetCertificateTaskList(RequestForDiplomaSupplyDAL certificateDAL)
        {
            var query = _filterTaskManager.BuildApprovalWorkflowHistoryQuery(RequestForDiplomaSuppliesList.ListName, this.ApproverFullName, DateTime.Now);

            if (this.CountOnly)
            {
                TotalCount += certificateDAL.CountByQuery(query);
            }
            else
            {
                var certificateManagementList = certificateDAL.GetByQuery(query);
                if (certificateManagementList != null && certificateManagementList.Count > 0)
                {
                    foreach (var certificateManagement in certificateManagementList)
                    {
                        var filterTask = new FilterTask(certificateManagement);
                        filterTask.ApprovalStatusId = certificateManagement.WFStatus == Status.Approved ? ApprovedStatusId
                            : certificateManagement.WFStatus == ApprovalStatus.Rejected ? RejectedStatusId
                            : InProgressStatusId;
                        FilterTaskList.Add(filterTask);
                    }
                }
            }
        }
Ejemplo n.º 20
0
        private void GetBusinessTripTaskList(BusinessTripManagementDAL businessTripManagementDAL)
        {
            var query = _filterTaskManager.BuildApprovalTaskListQuery(StepModuleList.BusinessTripManagement.ToString(), _currentUserADId, DateTime.Now);

            if (this.CountOnly)
            {
                TotalCount += businessTripManagementDAL.CountByQuery(query);
            }
            else
            {
                var businessTripManagementList = businessTripManagementDAL.GetByQuery(query);
                if (businessTripManagementList != null && businessTripManagementList.Count > 0)
                {
                    foreach (var businessTripManagement in businessTripManagementList)
                    {
                        var filterTask = new FilterTask(businessTripManagement);
                        filterTask.ApprovalStatusId = businessTripManagement.ApprovalStatus == Status.Approved ? ApprovedStatusId
                            : businessTripManagement.ApprovalStatus == Status.Rejected ? RejectedStatusId
                            : InProgressStatusId;
                        FilterTaskList.Add(filterTask);
                    }
                }
            }
        }
Ejemplo n.º 21
0
    // 根据记录数量的多少,少的时候可以立即返回结果,多的时候用线程后台处理,然后可以随时查询状态
    // 线程用线程池,避免过多耗用线程数目

    // 根据结果集名,提取全部书目 XML 记录,然后批处理经过 MarcFilter 过滤,创建若干个子结果集
    // 最基本的功能是返回子结果集的显示名,文件名,包含记录数量,供前端显示在界面上
    // 较为深入的功能是,将子结果集按照 key 排序归并,而显示出二级条目和数量。二级结果集是子结果集的子结果集

    // TODO: 如何及时清理Task对象,避免内存过度膨胀? 是否仅保存最新10个Task对象?
    void GetFilterInfo(
        string strResultsetName,
        string strSelected,
        string strLang)
    {
        string        strError    = "";
        GetFilterInfo result_info = new GetFilterInfo();

        if (string.IsNullOrEmpty(strResultsetName) == true)
        {
            strError = "结果集名不应为空";
            goto ERROR1;
        }

        FilterTask t = app.FindFilterTask(strResultsetName);    // Task对象是利用 Session 内结果集名来进行管理的

        if (t == null)
        {
            // 如果一个结果集还没有被后台任务处理,就立即启动一个后台任务
            t = new FilterTask();
            app.SetFilterTask(strResultsetName, t);

            string strGlobalResultSetName = "";
            bool   bShare = false;

            if (strResultsetName[0] == '#')
            {
                strGlobalResultSetName = strResultsetName.Substring(1);
            }
            else
            {
                // 构造全局结果集名
                strGlobalResultSetName = sessioninfo.GetHashCode() + "_" + strResultsetName;

                LibraryChannel channel = sessioninfo.GetChannel(true);
                try
                {
                    // 先把结果集共享
                    // 管理结果集
                    // parameters:
                    //      strAction   share/remove 分别表示共享为全局结果集对象/删除全局结果集对象
                    long lRet = // sessioninfo.Channel.
                                channel.ManageSearchResult(
                        null,
                        "share",
                        strResultsetName,
                        strGlobalResultSetName,
                        out strError);
                    if (lRet == -1)
                    {
                        goto ERROR1;
                    }

                    bShare = true;
                }
                finally
                {
                    sessioninfo.ReturnChannel(channel);
                }
            }

            FilterTaskInput i = new FilterTaskInput();
            i.App            = app;
            i.FilterFileName = Path.Combine(app.DataDir, "cfgs/facet.fltx");
            i.ResultSetName  = strGlobalResultSetName;
            i.ShareResultSet = bShare;
            // i.SessionInfo = sessioninfo;
            i.TempDir  = app.TempDir;
            i.TaskName = strResultsetName;  // Task对象是利用Session内结果集名来进行管理的
            i.MaxCount = 1000;
            // i.aggregation_names = new List<string>() {"author"};

            XmlDocument def_dom = GetFacetDefDom(out strError);
            if (def_dom == null)
            {
                goto ERROR1;
            }
            i.DefDom = def_dom;

            ThreadPool.QueueUserWorkItem(t.ThreadPoolCallBack, i);
            strError = "#pending";  // 表示正在处理,希望前端稍后重新访问
            goto ERROR1;
        }
        else
        {
            if (t.TaskState == TaskState.Processing)
            {
                if (t.ProgressRange != 0)
                {
                    result_info.ProgressValue = (int)(((double)t.ProgressValue / (double)t.ProgressRange) * 100);
                }
                strError = "#pending";  // 表示正在处理,希望前端稍后重新访问
                goto ERROR1;
            }
            if (string.IsNullOrEmpty(t.ErrorInfo) == false)
            {
                strError = t.ErrorInfo;
                goto ERROR1;
            }

            GC.Collect();   // 试着释放 Hashtable 等

            long lHitCount = MyWebPage.GetServerResultCount(sessioninfo, strResultsetName);

            XmlDocument def_dom = GetFacetDefDom(out strError);
            if (def_dom == null)
            {
                goto ERROR1;
            }
            this.m_facetDom = def_dom;
            this.m_strLang  = strLang;

            try
            {
                // 创建FilterInfo数组
                result_info.Items = ResultsetFilter.BuildFilterInfos(
                    strResultsetName,
                    lHitCount,
                    strSelected,
                    GetKeyNameCaption,
                    t.ResultItems,
                    app.TempDir,    // sessioninfo.GetTempDir(),
                    10);
                // GC.Collect();    // 担心 DpResultSet 未能回收
            }
            catch (Exception ex)
            {
                strError = ExceptionUtil.GetAutoText(ex);
                goto ERROR1;
            }

            if (t.HitCount > 1000)
            {
                result_info.Comment = "分面导航只提取了当前结果集的前 1000 条记录";
            }
        }

        // 返回一级节点的名字和包含记录数量
        this.Response.Write(MyWebPage.GetResultString(result_info));
        this.Response.End();
        return;

ERROR1:
        result_info.ErrorString = strError;
        this.Response.Write(MyWebPage.GetResultString(result_info));
        this.Response.End();
    }
Ejemplo n.º 22
0
        public List <Task> FilterTasks([FromQuery] FilterTask qtask)
        {
            ManageTasks mngTasks = new ManageTasks();

            return(mngTasks.GetTasksByFilter(qtask));
        }
Ejemplo n.º 23
0
        public DataResponse <EntityList <EntityTask> > GetTasks(FilterTask filter, int currentUserId, int?currentBusinessId, bool hasRight, bool hasDeletePermission, bool isApiCall = false, int take = 10, int skip = 0)
        {
            var response = new DataResponse <EntityList <EntityTask> >();

            try
            {
                if (filter != null)
                {
                    take = filter.Take;
                    skip = filter.Skip;
                }

                base.DBInit();

                var query = DBEntity.Tasks.Where(a => a.IsActive == true);

                //var reps = new List<int>();
                //reps = DBEntity.Reps.Where(a => a.RepGroup.RepgroupManagerMappers.Any(b => b.ManagerId == currentUserId) || a.RepGroup.SalesDirectorId == currentUserId).Select(a => a.UserId).ToList();
                ////---ManagerChange    reps = DBEntity.Reps.Where(a => a.RepGroup.ManagerId == currentUserId).Select(a => a.UserId).ToList();
                //reps.Add(currentUserId);

                query = query.Where(a => a.BusinessId == currentBusinessId);

                //if (!hasRight)
                //    query = query.Where(a => a.TaskUsers.Any(tu => reps.Contains(tu.UserId)) || a.RequestedBy == currentUserId);

                if (!hasRight)
                {
                    query = query.Where(a => a.TaskUsers.Any(tu => tu.UserId == currentUserId) || a.RequestedBy == currentUserId);
                }

                if (filter != null)
                {
                    if (filter.PracticeID.HasValue)
                    {
                        query = query.Where(a => a.PracticeId == filter.PracticeID);
                    }

                    if (!String.IsNullOrEmpty(filter.KeyWords))
                    {
                        query = query.Where(a => a.Practice.PracticeName.ToLower().Contains(filter.KeyWords)

                                            || a.Subject.ToLower().Contains(filter.KeyWords) ||
                                            a.TaskDescription.ToLower().Contains(filter.KeyWords)

                                            || a.TaskUsers.Any(p => p.User.FirstName.ToLower().Contains(filter.KeyWords)) ||
                                            a.TaskUsers.Any(p => p.User.LastName.ToLower().Contains(filter.KeyWords))

                                            || a.User.FirstName.ToLower().Contains(filter.KeyWords) ||
                                            a.User.LastName.ToLower().Contains(filter.KeyWords)

                                            || a.ReferenceNumber.Contains(filter.KeyWords)
                                            );
                    }
                    if (filter.AssignedOrRequest == (int)AssignedOrRequest.AssignedToMe)
                    {
                        query = query.Where(a => a.TaskUsers.Any(b => b.IsWatcher == false && b.User.Id == currentUserId));
                    }

                    if (filter.AssignedOrRequest == (int)AssignedOrRequest.RequestedByMe)
                    {
                        query = query.Where(a => a.CreatedBy == currentUserId);
                    }

                    if (filter.IsActive != null)
                    {
                        query = query.Where(a => a.IsActive == filter.IsActive);
                    }

                    if (!String.IsNullOrEmpty(filter.ReferenceNumber))
                    {
                        query = query.Where(a => a.ReferenceNumber.Contains(filter.ReferenceNumber));
                    }

                    if (filter.RequestType > 0)
                    {
                        query = query.Where(a => a.TaskRequestTypeId == filter.RequestType);
                    }
                    else if (filter.RequestType == -1)
                    {
                        query = query.Where(a => a.TaskRequestTypeId == null);
                    }

                    if (filter.Status > 0)
                    {
                        query = query.Where(a => a.Status == filter.Status);
                    }

                    if (filter.RequestedBy > 0)
                    {
                        query = query.Where(a => a.RequestedBy == filter.RequestedBy);
                    }

                    if (filter.AssignedTo > 0)
                    {
                        query = query.Where(a => a.TaskUsers.Any(b => b.IsWatcher == false && b.User.Id == filter.AssignedTo));
                    }

                    if (filter.Priority > 0)
                    {
                        query = query.Where(a => a.PriorityTypeId == filter.Priority);
                    }

                    if (filter.DueOn > 0)
                    {
                        Periods periodFilter = (Periods)filter.DueOn;
                        var     dt           = DateTime.UtcNow;
                        var     endDt        = DateTime.UtcNow;
                        switch (periodFilter)
                        {
                        case Periods.Today:
                            dt    = DateTime.UtcNow.AddHours(-12);
                            query = query.Where(a => a.TargetDate > dt);
                            break;

                        case Periods.Yesterday:
                            dt    = DateTime.UtcNow.AddHours(-12);
                            endDt = dt.AddHours(-12);
                            query = query.Where(a => a.TargetDate <dt && a.TargetDate> endDt);
                            break;


                        case Periods.ThisWeek:

                            dt    = DateTime.UtcNow.AddDays(-7);
                            query = query.Where(a => a.TargetDate > dt);
                            break;


                        case Periods.LastWeek:

                            dt    = DateTime.UtcNow.AddDays(-7);
                            endDt = dt.AddDays(-7);

                            query = query.Where(a => a.TargetDate <dt && a.TargetDate> endDt);

                            break;

                        case Periods.ThisMonth:

                            dt = DateTime.UtcNow.AddDays(-30);

                            query = query.Where(a => a.TargetDate > dt);
                            break;

                        case Periods.LastMonth:

                            dt    = DateTime.UtcNow.AddDays(-30);
                            endDt = dt.AddDays(-30);


                            query = query.Where(a => a.TargetDate <dt && a.TargetDate> endDt);
                            break;

                        case Periods.ThisYear:

                            dt = DateTime.UtcNow.AddDays(-365);

                            query = query.Where(a => a.TargetDate > dt);
                            break;

                        case Periods.LastYear:

                            dt    = DateTime.UtcNow.AddDays(-365);
                            endDt = dt.AddDays(-365);


                            query = query.Where(a => a.TargetDate <dt && a.TargetDate> endDt);
                            break;

                        default:
                            break;
                        }
                    }
                }

                var selectQuery = query.Select(a => new EntityTask
                {
                    CurrentUserId     = currentUserId,
                    HasDeleteRight    = hasDeletePermission || currentUserId == a.User.Id,
                    CurrentBusinessId = currentBusinessId.Value,
                    TaskId            = a.Id,
                    Subject           = a.Subject,
                    TaskDescription   = a.TaskDescription,
                    TaskRequestTypeId = a.TaskRequestTypeId,
                    TaskType          = a.LookupTaskType.TaskType,
                    PriorityTypeId    = a.PriorityTypeId,
                    ClosingDate       = a.ClosingDate,
                    TargetDate        = a.TargetDate,
                    TaskItemOrders    = a.TaskItemOrders,
                    PracticeId        = a.PracticeId,
                    PracticeName      = a.Practice.PracticeName,
                    ReferenceNumber   = a.ReferenceNumber,
                    IsActive          = a.IsActive,
                    AssignedUsersList = a.TaskUsers.Where(c => c.IsWatcher == false).Select(b => new UserDetails {
                        Name = b.User.FirstName + " " + b.User.LastName, UserId = b.UserId
                    }),
                    WatchersList = a.TaskUsers.Where(c => c.IsWatcher == true).Select(b => new UserDetails {
                        Name = b.User.FirstName + " " + b.User.LastName, UserId = b.UserId
                    }),
                    RequestedUser = new UserDetails {
                        Name = a.User.FirstName + " " + a.User.LastName, UserId = a.User.Id
                    },
                    FilesList = a.TaskAttachments.Where(c => c.IsActive != false).Select(d => new FilesUploaded {
                        Id = d.Id, FileName = d.FileName
                    }),
                    StatusId  = a.Status,
                    AlertDate = a.TaskUserAlerts.Where(b => b.UserId == currentUserId).FirstOrDefault().AlertDate,
                    IsApiCall = isApiCall,
                    CreatedBy = a.CreatedBy,
                    CreatedOn = a.CreatedOn,
                    UpdatedBy = a.UpdatedBy,
                    UpdatedOn = a.UpdatedOn
                }).OrderBy(a => a.StatusId == (int)TaskStatuses.Completed).ThenByDescending(a => a.UpdatedOn);

                response = GetList <EntityTask>(selectQuery, skip, take);

                response.Model.List.ForEach(a =>
                {
                    if (a.PriorityTypeId.HasValue)
                    {
                        a.PriorityType = EnumHelper.GetEnumName <TaskPriorities>(a.PriorityTypeId.Value);
                    }
                    if (a.StatusId.HasValue)
                    {
                        a.Status = EnumHelper.GetEnumName <TaskStatuses>(a.StatusId.Value);
                    }
                    a.CreatedOn = a.CreatedOn.ToLocalTime();
                });
            }
            catch (Exception ex)
            {
                ex.Log();
            }
            finally
            {
                base.DBClose();
            }
            return(response);
        }
        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++;
                        }
                    }
                }
            }
        }
        private void GetLeaveTaskList(LeaveManagementDAL leaveManagementDAL)
        {
            // DUE Date = NOW / NOW + 1;
            // NOW <= FROM AND NOW >= DUE Date
            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>
                                                <Or>
                                                    <Eq>
                                                        <FieldRef Name='{CommonSPListField.CommonReqDueDateField}' />
                                                        <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.ToString(StringConstant.DateFormatForCAML)}</Value>
                                                    </Eq>
                                                    <Eq>
                                                        <FieldRef Name='{CommonSPListField.CommonReqDueDateField}' />
                                                        <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.AddDays(1).ToString(StringConstant.DateFormatForCAML)}</Value>
                                                    </Eq>
                                                </Or>
                                            </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>
                                                <Or>
                                                    <Or>
                                                        <Eq>
                                                            <FieldRef Name='{CommonSPListField.CommonReqDueDateField}' />
                                                            <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.AddDays(3).ToString(StringConstant.DateFormatForCAML)}</Value>
                                                        </Eq>
                                                        <Eq>
                                                            <FieldRef Name='{CommonSPListField.CommonReqDueDateField}' />
                                                            <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.AddDays(4).ToString(StringConstant.DateFormatForCAML)}</Value>
                                                        </Eq>
                                                    </Or>
                                                    <And>
                                                        <Geq>
                                                            <FieldRef Name='{CommonSPListField.CommonReqDueDateField}' />
                                                            <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.ToString(StringConstant.DateFormatForCAML)}</Value>
                                                        </Geq>
                                                        <Lt>
                                                            <FieldRef Name='{CommonSPListField.CommonReqDueDateField}' />
                                                            <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.AddDays(3).ToString(StringConstant.DateFormatForCAML)}</Value>
                                                        </Lt>
                                                    </And>
                                                </Or>
                                            </And>
                                        </Or>
                                        <And>
                                            <Geq>
                                                <FieldRef Name='{LeaveManagementList.TotalDaysField}' />
                                                <Value Type='Number'>5</Value>
                                            </Geq>
                                            <Or>
                                                <Or>
                                                    <Eq>
                                                        <FieldRef Name='{CommonSPListField.CommonReqDueDateField}' />
                                                        <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.AddDays(15).ToString(StringConstant.DateFormatForCAML)}</Value>
                                                    </Eq>
                                                    <Eq>
                                                        <FieldRef Name='{CommonSPListField.CommonReqDueDateField}' />
                                                        <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.AddDays(16).ToString(StringConstant.DateFormatForCAML)}</Value>
                                                    </Eq>
                                                </Or>
                                                <And>
                                                    <Geq>
                                                        <FieldRef Name='{CommonSPListField.CommonReqDueDateField}' />
                                                        <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.ToString(StringConstant.DateFormatForCAML)}</Value>
                                                    </Geq>
                                                    <Lt>
                                                        <FieldRef Name='{CommonSPListField.CommonReqDueDateField}' />
                                                        <Value IncludeTimeValue='FALSE' Type='DateTime'>{DateTime.Now.AddDays(15).ToString(StringConstant.DateFormatForCAML)}</Value>
                                                    </Lt>
                                                </And>
                                            </Or>
                                        </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);
                    }
                }
            }
        }
Ejemplo n.º 26
0
        public List <Task> GetTasksByFilter(FilterTask qtask)
        {
            bool queryCategory = false;
            bool queryRegion   = false;
            bool queryPrice    = false;
            bool querySearch   = false;

            if (qtask.DateStart == new System.DateTime())
            {
                qtask.DateStart = new System.DateTime(1793, 1, 1);
            }
            if (qtask.DateEnd == new System.DateTime())
            {
                qtask.DateEnd = new System.DateTime(3000, 1, 1);
            }
            List <Task> taskList    = new List <Task>();
            string      queryString = "SELECT * From Task WHERE ";

            if (qtask.CategoryId != 0)
            {
                queryString  += "CategoryID=@CATID AND ";
                queryCategory = true;
            }
            if (qtask.Region != null)
            {
                queryString += "Region=@REGION AND ";
                queryRegion  = true;
            }
            if (qtask.PriceHigh != 0 && qtask.PriceHigh > qtask.PriceLow)
            {
                queryString += "Price BETWEEN @PRICELOW AND @PRICEHIGH AND ";
                queryPrice   = true;
            }
            if (qtask.Search != null)
            {
                queryString += "Title LIKE '%' + @TITLE + '%' AND ";
                querySearch  = true;
            }
            queryString += "Date BETWEEN @DATESTART AND @DATEEND";


            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(queryString, connection);
                if (queryCategory)
                {
                    command.Parameters.AddWithValue("@CATID", qtask.CategoryId);
                }
                if (queryRegion)
                {
                    command.Parameters.AddWithValue("@REGION", qtask.Region);
                }
                if (queryPrice)
                {
                    command.Parameters.AddWithValue("@PRICELOW", qtask.PriceLow);
                    command.Parameters.AddWithValue("@PRICEHIGH", qtask.PriceHigh);
                }
                if (querySearch)
                {
                    command.Parameters.AddWithValue("@TITLE", qtask.Search);
                }
                command.Parameters.AddWithValue("@DATESTART", qtask.DateStart);
                command.Parameters.AddWithValue("@DATEEND", qtask.DateEnd);
                command.Connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                try
                {
                    while (reader.Read())
                    {
                        Task task = new Task();
                        task.Id          = reader.GetInt32(0);
                        task.UserId      = reader.GetInt32(1);
                        task.CategoryId  = reader.GetInt32(2);
                        task.Date        = reader.GetDateTime(3);
                        task.Title       = reader.GetString(4);
                        task.Price       = reader.GetDouble(5);
                        task.Description = reader.GetString(6);
                        task.Status      = reader.GetString(7);
                        task.Promoted    = reader.GetBoolean(8);
                        task.Region      = reader.GetString(9);
                        task.PromotedEnd = reader.GetDateTime(10);
                        task.PageViews   = reader.GetInt32(11);
                        taskList.Add(task);
                    }
                }
                finally
                {
                    reader.Close();
                }
            }
            return(taskList);
        }