Exemplo n.º 1
0
        public ActionResult SendToNextStage(Guid expStageId, int[] nextStageIds, int?stageResultId = null)
        {
            var repository = new ExpertiseStageRepository();

            if (repository.HasNotFixedRemarks(expStageId))
            {
                return(Json(
                           new
                {
                    failed = true,
                    msg = "Невозможно передать на следующий этап так как есть не исправленные замечания"
                }, JsonRequestBehavior.AllowGet));
            }
            string resultDescription;

            var expertiseStage = repository.GetById(expStageId);
            var dec            = repository.GetDeclarationByStage(expStageId);

            if (expertiseStage.EXP_DIC_Stage.Code == CodeConstManager.STAGE_SAFETYREPORT.ToString())
            {
                var rDictionary = new ReadOnlyDictionaryRepository();
                EXP_DIC_StageResult stageResult = null;
                if (stageResultId.HasValue)
                {
                    stageResult = rDictionary.GetStageResultById(stageResultId.Value);
                }

                if (stageResult != null && stageResult.Code == EXP_DIC_StageResult.DoesNotMatchCode)
                {
                    repository.ToBackStage(dec.Id, expStageId, nextStageIds, out resultDescription);
                }
                else
                {
                    repository.ToNextStage(dec.Id, expStageId, nextStageIds, out resultDescription);
                }
            }
            else
            {
                repository.ToNextStage(dec.Id, expStageId, nextStageIds, out resultDescription);
            }
            var from = ExpStageNameHelper.GetName(expertiseStage.StageId);
            var to   = "";

            foreach (var nextStageId in nextStageIds)
            {
                if (!String.IsNullOrEmpty(to))
                {
                    to += ", ";
                }
                var stageName = ExpStageNameHelper.GetName(nextStageId);
                to += stageName;
            }
            ActionLogger.WriteInt(" Отправка заявления №" + dec.Number + " на другой этап", "from: " + from + "; to:" + to);
            return(Json("OK", JsonRequestBehavior.AllowGet));
        }
        protected virtual EXP_ExpertiseStage GetExpertiseStage(Guid?id)
        {
            ExpertiseStageRepository repo = new ExpertiseStageRepository();
            var stage = repo.GetById(id);

            if (stage.EXP_DIC_StageStatus.Code == EXP_DIC_StageStatus.InWork)
            {
                repo.SetStageViewved(id.Value);
            }
            return(stage);
        }