예제 #1
0
        public bool AllowApproveAndRejectPbck1(WorkflowAllowApproveAndRejectInput input)
        {
            if (input.CreatedUser == input.CurrentUser)
            {
                return(false);
            }

            if (input.DocumentStatus != Enums.DocumentStatus.WaitingForApproval)
            {
                return(false);
            }

            if (input.UserRole != Enums.UserRole.POA)
            {
                return(false);
            }

            var lisPoa = _poabll.GetPoaByNppbkcIdAndMainPlant(input.NppbkcId);

            //add delegate poa too
            List <string> listUser        = lisPoa.Select(c => c.POA_ID).Distinct().ToList();
            var           listPoaDelegate =
                _poaDelegationServices.GetListPoaDelegateByDate(listUser, DateTime.Now);

            listUser.AddRange(listPoaDelegate);

            return(listUser.Contains(input.CurrentUser));
        }
예제 #2
0
        public bool AllowManagerReject(WorkflowAllowApproveAndRejectInput input)
        {
            if (input.DocumentStatus == Enums.DocumentStatus.WaitingGovApproval)
            {
                if (input.UserRole == Enums.UserRole.Controller && input.ManagerApprove == input.CurrentUser)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #3
0
        public bool AllowWasteGoodIssue(WorkflowAllowApproveAndRejectInput input)
        {
            if (input.CreatedUser != input.CurrentUser)
            {
                if (
                    !_poaDelegationServices.IsDelegatedUserByUserAndDate(input.CreatedUser, input.CurrentUser,
                                                                         DateTime.Now))
                {
                    return(false);
                }
            }

            return(input.DocumentStatus == Enums.DocumentStatus.GoodIssue);
        }
예제 #4
0
        public bool AllowDomesticAlcoholGoodReceive(WorkflowAllowApproveAndRejectInput input)
        {
            //if (input.CreatedUser != input.CurrentUser)
            //    if (
            //        !_poaDelegationServices.IsDelegatedUserByUserAndDate(input.CreatedUser, input.CurrentUser,
            //            DateTime.Now))
            //        return false;
            if (!IsUserUnsealing(input))
            {
                return(false);
            }

            return(input.DocumentStatus == Enums.DocumentStatus.GoodReceive);
        }
예제 #5
0
        public bool AllowDomesticAlcoholPurchaseOrder(WorkflowAllowApproveAndRejectInput input)
        {
            if (input.CreatedUser != input.CurrentUser)
            {
                if (
                    !_poaDelegationServices.IsDelegatedUserByUserAndDate(input.CreatedUser, input.CurrentUser,
                                                                         DateTime.Now))
                {
                    return(false);
                }
            }

            return(input.DocumentStatus == Enums.DocumentStatus.PurchaseOrder);
        }
예제 #6
0
        public bool AllowStoGiCompleted(WorkflowAllowApproveAndRejectInput input)
        {
            if (input.CreatedUser != input.CurrentUser)
            {
                if (
                    !_poaDelegationServices.IsDelegatedUserByUserAndDate(input.CreatedUser, input.CurrentUser,
                                                                         DateTime.Now))
                {
                    return(false);
                }
            }

            return(input.DocumentStatus == Enums.DocumentStatus.StoRecGICompleted);
        }
예제 #7
0
        public bool AllowTfPostedPortToImporter(WorkflowAllowApproveAndRejectInput input)
        {
            //if (input.CreatedUser != input.CurrentUser)
            //    if (
            //        !_poaDelegationServices.IsDelegatedUserByUserAndDate(input.CreatedUser, input.CurrentUser,
            //            DateTime.Now))
            //        return false;
            if (!IsUserUnsealing(input))
            {
                return(false);
            }

            return(input.DocumentStatus == Enums.DocumentStatus.TFPosted);
        }
예제 #8
0
        public bool AllowWasteGoodReceive(WorkflowAllowApproveAndRejectInput input)
        {
            if (input.DocumentStatus != Enums.DocumentStatus.GoodReceive)
            {
                return(false);
            }

            //if (!IsUserUnsealing(input))
            //    return false;

            //if (input.CreatedUser == input.CurrentUser) return true;

            //return IsOnePlant(input.DestPlant, input.CurrentUser);

            return(IsUserUnsealing(input));
        }
예제 #9
0
        public bool AllowGrCreated(WorkflowAllowApproveAndRejectInput input)
        {
            //if (input.CreatedUser != input.CurrentUser)
            //{
            //    if (
            //        !_poaDelegationServices.IsDelegatedUserByUserAndDate(input.CreatedUser, input.CurrentUser,
            //            DateTime.Now))
            //        return false;
            //}
            if (!IsUserUnsealing(input))
            {
                return(false);
            }

            return(input.DocumentStatus == Enums.DocumentStatus.GRCreated ||
                   input.DocumentStatus == Enums.DocumentStatus.GRCompleted ||
                   input.DocumentStatus == Enums.DocumentStatus.WaitingForUnSealing);
        }
예제 #10
0
        private bool IsUserUnsealing(WorkflowAllowApproveAndRejectInput input)
        {
            if (input.CreatedUser == input.CurrentUser)
            {
                return(true);
            }
            if (_poaDelegationServices.IsDelegatedUserByUserAndDate(input.CreatedUser, input.CurrentUser, DateTime.Now))
            {
                return(true);
            }
            //return false;
            ////get user by plant
            //var listUserPlantMap = _userPlantMapService.GetByPlantId(input.PlantId);
            //var listUser = listUserPlantMap.Select(c => c.USER_ID).ToList();
            //if (listUser.Contains(input.CurrentUser))
            //    return true;
            ////and get user by plant delegate
            //var listUserDelegate = _poaDelegationServices.GetListPoaDelegateByDate(listUser, DateTime.Now);
            //return listUserDelegate.Contains(input.CurrentUser);

            //get user by plant
            var listUser = new List <string>();

            var listUserPlantMap = _userPlantMapService.GetUserBRoleMapByPlantIdAndUserRole(input.DestPlant,
                                                                                            Enums.UserRole.User);

            listUser.AddRange(listUserPlantMap);

            //list poa
            var listPoa = _poabll.GetPoaActiveByNppbkcId(input.DestNppbkcId);

            listUser.AddRange(listPoa.Select(c => c.POA_ID));

            if (listUser.Contains(input.CurrentUser))
            {
                return(true);
            }


            var listUserDelegate = _poaDelegationServices.GetListPoaDelegateByDate(listUser, DateTime.Now);

            return(listUserDelegate.Contains(input.CurrentUser));
        }
예제 #11
0
        public bool AllowWasteDisposal(WorkflowAllowApproveAndRejectInput input)
        {
            //if (input.CreatedUser != input.CurrentUser)
            //    return false;

            if (!_wasteRoleServices.IsUserDisposalTeamByPlant(input.CurrentUser, input.DestPlant))

            {
                //get delegated disposal poa
                var listDisposal = _wasteRoleServices.GetUserDisposalTeamByPlant(input.DestPlant);
                var poaDelegate  = _poaDelegationServices.GetListPoaDelegateByDate(listDisposal, DateTime.Now);
                if (!poaDelegate.Contains(input.CurrentUser))
                {
                    return(false);
                }
            }

            return(input.DocumentStatus == Enums.DocumentStatus.WasteDisposal);
        }
예제 #12
0
        public bool AllowCancelSAP(WorkflowAllowApproveAndRejectInput input)
        {
            if (input.DocumentStatus < Enums.DocumentStatus.CreateSTO)
            {
                return(false);
            }
            if (input.DocumentStatus == Enums.DocumentStatus.Cancelled ||
                input.DocumentStatus == Enums.DocumentStatus.Completed)
            {
                return(false);
            }
            if (input.CreatedUser != input.CurrentUser)
            {
                if (
                    !_poaDelegationServices.IsDelegatedUserByUserAndDate(input.CreatedUser, input.CurrentUser,
                                                                         DateTime.Now))
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #13
0
 public bool AllowAttachment(WorkflowAllowApproveAndRejectInput input)
 {
     if (input.DocumentStatus <= Enums.DocumentStatus.WaitingGovApproval)
     {
         return(false);
     }
     if (input.CreatedUser == input.CurrentUser)
     {
         return(true);
     }
     if (input.UserRole == Enums.UserRole.User)
     {
         if (!_poaDelegationServices.IsDelegatedUserByUserAndDate(input.CreatedUser, input.CurrentUser, DateTime.Now))
         {
             return(false);
         }
     }
     else if (input.UserRole == Enums.UserRole.POA)
     {
         return(IsPoaAllowedDelegate(input.DocumentNumber, input.CurrentUser));
         //return input.CurrentUser == input.PoaApprove;
     }
     return(false);
 }
예제 #14
0
        public bool AllowGovApproveAndReject(WorkflowAllowApproveAndRejectInput input)
        {
            //if (input.CreatedUser == input.CurrentUser)
            //    return false;
            var completedEdit = false;

            if (input.FormType == Enums.FormType.PBCK1 && input.DocumentStatus == Enums.DocumentStatus.Completed)
            {
                completedEdit = true;
            }

            if (input.DocumentStatus != Enums.DocumentStatus.WaitingGovApproval && !completedEdit)
            {
                return(false);
            }

            if (input.DocumentStatus == Enums.DocumentStatus.WaitingGovApproval || completedEdit)
            {
                string originalPoa;

                if (input.UserRole == Enums.UserRole.Controller)
                {
                    return(false);
                }

                if (input.CreatedUser == input.CurrentUser)
                {
                    return(true);
                }

                originalPoa = input.CreatedUser;

                ////get delegate if exist
                //var listDelegatedUser = _poaDelegationServices.GetPoaDelegationToByPoaFromAndDate(
                //    input.CreatedUser, DateTime.Now);
                //if (listDelegatedUser.Contains(input.CurrentUser))
                //    return true;

                if (input.UserRole == Enums.UserRole.POA)
                {
                    //get poa Original that already approve or reject
                    var workflowHistoryDto =
                        _workflowHistoryBll.GetDtoApprovedRejectedPoaByDocumentNumber(input.DocumentNumber);

                    if (workflowHistoryDto != null)
                    {
                        if (!string.IsNullOrEmpty(workflowHistoryDto.COMMENT) &&
                            workflowHistoryDto.COMMENT.Contains(Constans.LabelDelegatedBy)) //approve by delegated
                        {
                            //find the original
                            originalPoa =
                                workflowHistoryDto.COMMENT.Substring(
                                    workflowHistoryDto.COMMENT.IndexOf(Constans.LabelDelegatedBy,
                                                                       System.StringComparison.Ordinal));
                            originalPoa = originalPoa.Replace(Constans.LabelDelegatedBy, "");
                            originalPoa = originalPoa.Replace("]", "");
                        }
                        else
                        {
                            originalPoa = workflowHistoryDto.ACTION_BY;
                        }
                    }


                    ////get poa that already approve or reject
                    //var poaId = _workflowHistoryBll.GetApprovedRejectedPoaByDocumentNumber(input.DocumentNumber);
                    //if (string.IsNullOrEmpty(poaId))
                    //    return false;

                    //if (poaId == input.CurrentUser)
                    //    return true;
                }

                //get delegated user
                var listUser = new List <string>();
                listUser.Add(originalPoa);
                var poaDelegate = _poaDelegationServices.GetPoaDelegationToByPoaFromAndDate(originalPoa,
                                                                                            DateTime.Now);

                listUser.AddRange(poaDelegate);

                if (originalPoa != input.CreatedUser)
                {
                    //get delegate for created user too
                    poaDelegate = _poaDelegationServices.GetPoaDelegationToByPoaFromAndDate(input.CreatedUser,
                                                                                            DateTime.Now);

                    listUser.AddRange(poaDelegate);
                }

                if (listUser.Contains(input.CurrentUser))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #15
0
        /// <summary>
        /// allow to approve and rejected
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public bool AllowApproveAndReject(WorkflowAllowApproveAndRejectInput input)
        {
            if (input.CreatedUser == input.CurrentUser)
            {
                return(false);
            }

            //need approve by POA only
            if (input.DocumentStatus == Enums.DocumentStatus.WaitingForApproval || input.DocumentStatus == Enums.DocumentStatus.WaitingForApproval2)
            {
                if (input.UserRole != Enums.UserRole.POA)
                {
                    return(false);
                }

                //created user need to as user
                //if (_poabll.GetUserRole(input.CreatedUser) != Enums.UserRole.User)
                //    return false;

                //if document was rejected then must approve by poa that rejected
                //var rejectedPoa = _workflowHistoryBll.GetApprovedRejectedPoaByDocumentNumber(input.DocumentNumber);
                var rejectedPoa = _workflowHistoryBll.GetDtoApprovedRejectedPoaByDocumentNumber(input.DocumentNumber);

                if (rejectedPoa != null)
                {
                    //delegate
                    if (!IsPoaAllowedDelegate(input.DocumentNumber, input.CurrentUser))
                    {
                        return(false);
                    }

                    //end delegate

                    //if (input.CurrentUser != rejectedPoa)
                    //    return false;
                }

                if (input.FormType == Enums.FormType.PBCK3)
                {
                    var rejectedSourcePoa = _workflowHistoryBll.GetApprovedRejectedPoaByDocumentNumber(input.DocumentNumberSource);
                    if (rejectedSourcePoa != "" && rejectedSourcePoa != input.CreatedUser)
                    {
                        //if (input.CurrentUser != rejectedSourcePoa)
                        //    return false;
                        //delegate
                        if (!IsPoaAllowedDelegate(input.DocumentNumberSource, input.CurrentUser))
                        {
                            return(false);
                        }
                        //end delegate
                    }
                }
                else if (input.FormType == Enums.FormType.PBCK1)
                {
                    var lisPoa = _poabll.GetPoaByNppbkcIdAndMainPlant(input.NppbkcId);
                    //add delegate poa too
                    List <string> listUser        = lisPoa.Select(c => c.POA_ID).Distinct().ToList();
                    var           listPoaDelegate =
                        _poaDelegationServices.GetListPoaDelegateByDate(listUser, DateTime.Now);
                    listUser.AddRange(listPoaDelegate);

                    return(listUser.Contains(input.CurrentUser));
                }

                //poa must be active
                var poa = _poabll.GetActivePoaById(input.CurrentUser);
                if (poa == null)
                {
                    return(false);
                }

                var isPoaCreatedUser = _poabll.GetActivePoaById(input.CreatedUser);
                if (isPoaCreatedUser != null)
                {
                    //created user is poa, let's check isOneNppbkc with current user or not
                    return(IsOneNppbkc(input.NppbkcId, input.CurrentUser));
                }

                return(input.PlantId != null?IsOnePlant(input.PlantId, input.CurrentUser) : IsOneNppbkc(input.NppbkcId, input.CurrentUser));
            }

            if (input.DocumentStatus == Enums.DocumentStatus.WaitingForApprovalController)
            {
                if (input.UserRole != Enums.UserRole.Controller)
                {
                    return(false);
                }

                //get poa id by document number in workflow history

                //var poaId = _workflowHistoryBll.GetPoaByDocumentNumber(input.DocumentNumber);

                //if (string.IsNullOrEmpty(poaId))
                //    return false;

                //var managerId = _poabll.GetManagerIdByPoaId(poaId);

                //return managerId == input.CurrentUser;

                return(true);
            }

            return(false);
        }