コード例 #1
0
        public void Handle(EMP_ContractStage stage, bool result)
        {
            if (stage.EMP_Ref_StageStatus.Code != CodeConstManager.EmpContractStageStatus.New)
            {
                return;
            }

            var handler = new EmpContractStageHistoryHandler(_uow);

            if (result)
            {
                handler.SetStageApproved(stage);
                handler.AddHistoryApproved(stage.ContractId);
            }
            else
            {
                handler.SetStageRejected(stage);
                handler.AddHistoryRejected(stage.ContractId);
                var legalStage = stage.EMP_Contract.EMP_ContractStage.FirstOrDefault(x =>
                                                                                     x.EMP_Ref_Stage.Code == CodeConstManager.EmpContractStage.LegalDepartmant);
                if (legalStage != null)
                {
                    handler.SetStageRejected(legalStage);
                }
            }

            var cozStage = stage.EMP_Contract.EMP_ContractStage.First(x => x.EMP_Ref_Stage.Code == CodeConstManager.EmpContractStage.Coz);

            cozStage.StageStatusId = _uow.GetQueryable <EMP_Ref_StageStatus>()
                                     .Where(x => x.Code == CodeConstManager.EmpContractStageStatus.ApprovalRequired).Select(x => x.Id)
                                     .FirstOrDefault();

            _uow.Save();
        }
コード例 #2
0
        public void Handle(EMP_ContractStage stage, bool result)
        {
            if (stage.EMP_Ref_StageStatus.Code != CodeConstManager.EmpContractStageStatus.InWork)
            {
                return;
            }

            var handler = new EmpContractStageHistoryHandler(_uow);

            if (result)
            {
                handler.SetStageApproved(stage);
                handler.AddHistoryApproved(stage.ContractId);

                var wasInAdjustment = stage.EMP_Contract.EMP_ContractHistory.Any(x =>
                                                                                 x.OBK_Ref_ContractHistoryStatus.Code == OBK_Ref_ContractHistoryStatus.Returned);
                if (wasInAdjustment)
                {
                    var cozStage = stage.EMP_Contract.EMP_ContractStage.First(x => x.EMP_Ref_Stage.Code == CodeConstManager.EmpContractStage.Coz);
                    cozStage.StageStatusId = _uow.GetQueryable <EMP_Ref_StageStatus>()
                                             .Where(x => x.Code == CodeConstManager.EmpContractStageStatus.ApprovalRequired).Select(x => x.Id)
                                             .FirstOrDefault();
                }
            }
            else
            {
                handler.SetStageRejected(stage);
                handler.AddHistoryRejected(stage.ContractId);
            }

            _uow.Save();
        }
コード例 #3
0
        public void Handle(EMP_ContractStage stage, bool result)
        {
            var handler = new EmpContractStageHistoryHandler(_uow);

            if (stage.EMP_Ref_StageStatus.Code == CodeConstManager.EmpContractStageStatus.InWork)
            {
                stage.StageStatusId = _uow.GetQueryable <EMP_Ref_StageStatus>()
                                      .Where(x => x.Code == CodeConstManager.EmpContractStageStatus.ApprovalRequired).Select(x => x.Id)
                                      .FirstOrDefault();

                if (result)
                {
                    handler.AddHistoryApproved(stage.ContractId);
                }
                else
                {
                    handler.AddHistoryRejected(stage.ContractId);
                }

                _uow.Save();
                return;
            }

            if (stage.EMP_Ref_StageStatus.Code == CodeConstManager.EmpContractStageStatus.ApprovalRequired)
            {
                if (result)
                {
                    handler.SetStageApproved(stage);
                    handler.AddHistoryApproved(stage.ContractId);
                }
                else
                {
                    handler.SetStageRejected(stage);
                    handler.AddHistoryRejected(stage.ContractId);
                    var legalStage = stage.EMP_Contract.EMP_ContractStage.FirstOrDefault(x =>
                                                                                         x.EMP_Ref_Stage.Code == CodeConstManager.EmpContractStage.LegalDepartmant);
                    if (legalStage != null)
                    {
                        handler.SetStageRejected(legalStage);
                    }
                }

                var defStage = new EMP_ContractStage
                {
                    Id         = Guid.NewGuid(),
                    DateCreate = DateTime.Now,
                    ContractId = stage.ContractId,
                    StageId    = _uow.GetQueryable <EMP_Ref_Stage>()
                                 .Where(x => x.Code == CodeConstManager.EmpContractStage.Def).Select(x => x.Id)
                                 .FirstOrDefault(),
                    StageStatusId = _uow.GetQueryable <EMP_Ref_StageStatus>()
                                    .Where(x => x.Code == CodeConstManager.EmpContractStageStatus.New).Select(x => x.Id)
                                    .FirstOrDefault()
                };
                _uow.Insert(defStage);

                var defUnit = _uow.GetQueryable <Unit>().First(x => x.Code == "finance");
                _uow.Insert(new EMP_ContractStageExecutors
                {
                    Id = Guid.NewGuid(),
                    EMP_ContractStage = defStage,
                    ExecutorType      = CodeConstManager.OBK_CONTRACT_STAGE_EXECUTOR_TYPE_EXECUTOR,
                    ExecutorId        = Guid.Parse(defUnit.BossId)
                });

                _uow.Save();
                return;
            }
        }
コード例 #4
0
        public void SendToWork(Guid stageId, Guid executorId)
        {
            var stage       = _uow.GetQueryable <EMP_ContractStage>().First(x => x.Id == stageId);
            var executor    = _uow.GetQueryable <Employee>().First(x => x.Id == executorId);
            var contract    = _uow.GetQueryable <EMP_Contract>().First(x => x.Id == stage.ContractId);
            var stageStatus = _uow.GetQueryable <EMP_Ref_StageStatus>().First(x => x.Code == CodeConstManager.EmpContractStageStatus.InWork);

            if (stage.EMP_Ref_StageStatus.Code == CodeConstManager.EmpContractStageStatus.NotDistributed)
            {
                stage.StageStatusId = stageStatus.Id;
            }

            contract.ContractStatusId = _uow.GetQueryable <EMP_Ref_Status>()
                                        .Where(x => x.Code == CodeConstManager.EmpContractStatus.InWork).Select(x => x.Id).FirstOrDefault();

            var stageExecutor = new EMP_ContractStageExecutors
            {
                Id           = Guid.NewGuid(),
                ExecutorId   = executor.Id,
                ExecutorType = CodeConstManager.OBK_CONTRACT_STAGE_EXECUTOR_TYPE_EXECUTOR
            };

            if (stage.EMP_Ref_Stage.Code == CodeConstManager.EmpContractStage.Coz)
            {
                var validationGroupStage = contract.EMP_ContractStage.FirstOrDefault(x =>
                                                                                     x.EMP_Ref_Stage.Code == CodeConstManager.EmpContractStage.ValidationGroup);
                var defStage = contract.EMP_ContractStage.FirstOrDefault(x =>
                                                                         x.EMP_Ref_Stage.Code == CodeConstManager.EmpContractStage.Def);
                var isRejected = validationGroupStage != null && validationGroupStage.EMP_Ref_StageStatus.Code == CodeConstManager.EmpContractStageStatus.NotApproved ||
                                 defStage != null && defStage.EMP_Ref_StageStatus.Code == CodeConstManager.EmpContractStageStatus.NotApproved;

                var legalStage = new EMP_ContractStage
                {
                    Id            = Guid.NewGuid(),
                    ContractId    = contract.Id,
                    DateCreate    = DateTime.Now,
                    StageStatusId = isRejected
                        ? _uow.GetQueryable <EMP_Ref_StageStatus>()
                                    .Where(x => x.Code == CodeConstManager.EmpContractStageStatus.NotApproved)
                                    .Select(x => x.Id).FirstOrDefault()
                        : stageStatus.Id,
                    StageId = _uow.GetQueryable <EMP_Ref_Stage>()
                              .Where(x => x.Code == CodeConstManager.EmpContractStage.LegalDepartmant).Select(x => x.Id)
                              .FirstOrDefault()
                };
                _uow.Insert(legalStage);
                stageExecutor.EMP_ContractStage = legalStage;
            }
            else
            {
                stageExecutor.EMP_ContractStage = stage;
            }

            _uow.Insert(stageExecutor);

            new EmpContractStageHistoryHandler(_uow).AddHistorySentToWork(contract.Id);

            _uow.Save();

            SendNotificationToExecutorWork(executorId, contract);
        }
コード例 #5
0
 public void SetStageRejected(EMP_ContractStage stage)
 {
     stage.StageStatusId = _uow.GetQueryable <EMP_Ref_StageStatus>()
                           .Where(x => x.Code == CodeConstManager.EmpContractStageStatus.NotApproved).Select(x => x.Id)
                           .FirstOrDefault();
 }
コード例 #6
0
        public void Handle(EMP_ContractStage stage, bool result)
        {
            if (stage.EMP_Ref_StageStatus.Code != CodeConstManager.EmpContractStageStatus.ApprovalRequired)
            {
                return;
            }

            var handler = new EmpContractStageHistoryHandler(_uow);

            if (result)
            {
                handler.SetStageApproved(stage);
                handler.AddHistoryApproved(stage.ContractId);
            }
            else
            {
                handler.SetStageRejected(stage);
                handler.AddHistoryRejected(stage.ContractId);
            }

            var legalStage = stage.EMP_Contract.EMP_ContractStage.FirstOrDefault(x =>
                                                                                 x.EMP_Ref_Stage.Code == CodeConstManager.EmpContractStage.LegalDepartmant);

            if (!result || IsRejectedInOtherStages(stage.EMP_Contract))
            {
                if (legalStage != null)
                {
                    handler.SetStageRejected(legalStage);
                }
            }
            else
            {
                if (legalStage != null)
                {
                    legalStage.StageStatusId = _uow.GetQueryable <EMP_Ref_StageStatus>()
                                               .Where(x => x.Code == CodeConstManager.EmpContractStageStatus.Approved).Select(x => x.Id).FirstOrDefault();
                }

                var ceoStage = new EMP_ContractStage
                {
                    Id         = Guid.NewGuid(),
                    ContractId = stage.ContractId,
                    DateCreate = DateTime.Now,
                    StageId    = _uow.GetQueryable <EMP_Ref_Stage>()
                                 .Where(x => x.Code == CodeConstManager.EmpContractStage.Ceo).Select(x => x.Id)
                                 .FirstOrDefault(),
                    StageStatusId = _uow.GetQueryable <EMP_Ref_StageStatus>()
                                    .Where(x => x.Code == CodeConstManager.EmpContractStageStatus.ApprovalRequired)
                                    .Select(x => x.Id).FirstOrDefault()
                };
                _uow.Insert(ceoStage);

                var ceoExecutor = new EMP_ContractStageExecutors
                {
                    Id = Guid.NewGuid(),
                    EMP_ContractStage = ceoStage,
                    ExecutorType      = CodeConstManager.OBK_CONTRACT_STAGE_EXECUTOR_TYPE_SIGNER,
                    ExecutorId        = _uow.GetQueryable <Unit>()
                                        .Where(x => x.Code == "ncels_deputyceo" && x.EmployeeId != null)
                                        .Select(x => x.EmployeeId.Value).FirstOrDefault()
                };
                _uow.Insert(ceoExecutor);
            }

            _uow.Save();
        }