Beispiel #1
0
        public DelegationModel GetDelegatedTaskInfo(string Id)
        {
            DelegationModel delegationModel = new DelegationModel();

            int listItemId = 0;

            if (int.TryParse(Id, out listItemId))
            {
                string[] viewFields = new string[] { StringConstant.BusinessTripManagementList.Fields.DH, StringConstant.BusinessTripManagementList.Fields.DirectBOD,
                                                     StringConstant.BusinessTripManagementList.Fields.BOD, StringConstant.BusinessTripManagementList.Fields.AdminDept,
                                                     StringConstant.CommonSPListField.ApprovalStatusField, StringConstant.CommonSPListField.CommonDepartmentField, CommonSPListField.CommonLocationField };
                string queryStr = $@"<Where>
                                      <Eq>
                                         <FieldRef Name='ID' />
                                         <Value Type='Counter'>{listItemId}</Value>
                                      </Eq>
                                   </Where>";
                string siteUrl  = SPContext.Current.Site.Url;
                List <Biz.Models.BusinessTripManagement> businessTripManagementCollection = _businessTripManagementDAL.GetByQuery(queryStr, viewFields);
                if (businessTripManagementCollection != null && businessTripManagementCollection.Count > 0)
                {
                    EmployeeInfo currentApprover = null;
                    Biz.Models.BusinessTripManagement businessTripManagement = businessTripManagementCollection[0];
                    StepManagementDAL _stepManagementDAL = new StepManagementDAL(siteUrl);
                    var currentStep = _stepManagementDAL.GetStepManagement(businessTripManagement.ApprovalStatus, StepModuleList.BusinessTripManagement, businessTripManagement.CommonDepartment.LookupId);
                    if (currentStep != null)
                    {
                        currentApprover = _businessTripManagementDAL.GetApproverAtStep(businessTripManagement.CommonDepartment.LookupId, businessTripManagement.CommonLocation.LookupId, StepModuleList.BusinessTripManagement, currentStep.StepNumber);
                    }

                    if (currentApprover != null)
                    {
                        Delegation delegation = DelegationPermissionManager.IsDelegation(currentApprover.ID, StringConstant.BusinessTripManagementList.Url, businessTripManagement.ID);
                        delegationModel = new DelegationModel(delegation);
                    }
                }
            }

            return(delegationModel);
        }
        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);
        }