Exemple #1
0
        public Eco.dto.dtoEcoEvaluation EcoEvaluationGet(long commId, long evaluationId)
        {
            Adv.Domain.AdvCommission Comm = Manager.Get <Adv.Domain.AdvCommission>(commId);
            if (Comm == null)
            {
                return(new Eco.dto.dtoEcoEvaluation());
            }

            Eco.dto.dtoEcoEvaluation eval = new Eco.dto.dtoEcoEvaluation(Manager.Get <EcoD.EconomicEvaluation>(evaluationId));

            //Eco.dto.dtoEcoEvaluation evals = Manager.GetAll<EcoD.EconomicEvaluation>(ev =>
            //    ev.Commission != null && ev.Commission.Id == commId && ev.Deleted == BaseStatusDeleted.None
            //    && ev.
            //    ).Select(ev => new Eco.dto.dtoEcoEvaluation(ev)).FirstOrDefault();

            if (Comm.Members.Any(m => m.Member.Id == UC.CurrentUserID))
            {
                eval.CanView   = true;
                eval.CanModify = eval.status == Eco.EvalStatus.draft || eval.status == Eco.EvalStatus.take;
                eval.CanReopen = eval.status == Eco.EvalStatus.completed;
                eval.CanClose  = false;
            }

            if (Comm.President.Id == UC.CurrentUserID || Comm.Members.Any(m => m.Member.Id == UC.CurrentUserID && m.IsPresident))
            {
                eval.CanView   = true;
                eval.CanModify = eval.status == Eco.EvalStatus.draft || eval.status == Eco.EvalStatus.take;
                eval.CanReopen = eval.status == Eco.EvalStatus.completed;
                eval.CanClose  = eval.status == Eco.EvalStatus.completed;
            }

            return(eval);
        }
Exemple #2
0
        public bool EvaluationIsLastAverage(Adv.Domain.AdvCommission commission)
        {
            try
            {
                if (commission.Step != null)
                {
                    if (commission.Step.Type == Adv.StepType.economics)
                    {
                        try
                        {
                            Adv.Domain.AdvStep step = Manager.GetAll <Adv.Domain.AdvStep>(
                                st =>
                                st.Call != null && st.Call.Id == commission.Step.Call.Id &&
                                st.Type != Adv.StepType.economics
                                ).OrderByDescending(st => st.Order).FirstOrDefault();

                            return(step.EvalType == Adv.EvalType.Sum ? false : true);
                        }
                        catch
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(commission.Step.EvalType == Adv.EvalType.Sum ? false : true);
                    }
                }
            } catch { }

            return(false);
        }
Exemple #3
0
        public Eco.dto.dtoEcoSummaryContainer EcoSummaryGet(long commId)
        {
            Eco.dto.dtoEcoSummaryContainer container = new Eco.dto.dtoEcoSummaryContainer();

            Adv.Domain.AdvCommission commission = Manager.Get <Adv.Domain.AdvCommission>(commId);
            if (commission == null)
            {
                return(container);
            }

            if (!((commission.President != null && commission.President.Id == UC.CurrentUserID) ||
                  (commission.Members != null && commission.Members.Any(m => m.Member != null && m.Member.Id == UC.CurrentUserID)
                  )))
            {
                return(container);
            }

            container.hasPermission = true;



            container.StepId = (commission.Step != null) ? commission.Step.Id : 0;

            if (commission.Call != null)
            {
                container.CallId = commission.Call.Id;
            }
            else
            {
                container.CallId = 0;
            }



            container.Summaries = Manager.GetAll <EcoD.EconomicEvaluation>(ev =>
                                                                           ev.Commission != null && ev.Commission.Id == commId && ev.Deleted == BaseStatusDeleted.None
                                                                           )
                                  .OrderBy(ev => ev.Rank)
                                  .Select(ev => new Eco.dto.dtoEcoSummary(ev))
                                  .ToList();


            container.CanCloseCommission =
                commission.Status == Adv.CommissionStatus.Started &&
                (container.Summaries.All(s => s.status == Eco.EvalStatus.confirmed) &&
                 (commission.President != null && commission.President.Id == UC.CurrentUserID));

            container.IsAverage = EvaluationIsLastAverage(commission);

            return(container);
        }
Exemple #4
0
 public bool EvaluationIsLastAverage(Int64 commissionId)
 {
     Adv.Domain.AdvCommission commission = Manager.Get <Adv.Domain.AdvCommission>(commissionId);
     return(EvaluationIsLastAverage(commission));
 }
Exemple #5
0
        public bool EcoCreateEvaluation(long CommissionId)
        {
            if (!EcoEvalClear(CommissionId))
            {
                return(false);
            }


            Adv.Domain.AdvCommission comm = Manager.Get <Adv.Domain.AdvCommission>(CommissionId);

            if (
                comm.Step == null || comm.Step.Type != Adv.StepType.economics ||
                comm.Call == null)
            {
                return(false);
            }

            var stepsQuery = (from Adv.Domain.AdvStep step in Manager.GetIQ <Adv.Domain.AdvStep>()
                              where step.Type != Adv.StepType.economics &&
                              step.Call != null && step.Call.Id == comm.Call.Id
                              select step);

            Adv.Domain.AdvStep prevStep = stepsQuery.Where(s => s.Type == Adv.StepType.custom).OrderByDescending(s => s.Order).Skip(0).Take(1).FirstOrDefault();

            if (prevStep == null)
            {
                prevStep = stepsQuery.Where(s => s.Type == Adv.StepType.validation).Skip(0).Take(1).FirstOrDefault();
            }

            if (prevStep == null || prevStep.Status != Adv.StepStatus.Closed)
            {
                return(false);
            }

            IList <Adv.Domain.AdvSubmissionToStep> subStep = Manager.GetAll <Adv.Domain.AdvSubmissionToStep>(
                s => s.Step != null &&
                s.Step.Id == prevStep.Id &&
                s.Commission == null &&
                s.Admitted).OrderBy(s => s.Rank).ToList();

            IList <CpDomain.UserSubmission> AdmitSubmission = (from Adv.Domain.AdvSubmissionToStep sts in subStep
                                                               select sts.Submission).Distinct().ToList();

            IList <EcoD.EconomicEvaluation> ecEvaluations = Manager.GetAll <EcoD.EconomicEvaluation>(
                ecev => ecev.Call != null && ecev.Call.Id == comm.Call.Id &&
                ecev.Step != null && ecev.Step.Id == comm.Step.Id &&
                ecev.Commission != null && ecev.Commission.Id == comm.Id);

            if (ecEvaluations == null)
            {
                ecEvaluations = new List <EcoD.EconomicEvaluation>();
            }

            foreach (CpDomain.UserSubmission sub in AdmitSubmission)
            {
                EcoD.EconomicEvaluation ecEval = ecEvaluations.FirstOrDefault(ev => ev.Submission != null && ev.Submission.Id == sub.Id);
                bool isNew = false;
                if (ecEval == null)
                {
                    ecEval = new EcoD.EconomicEvaluation();
                    ecEval.CreateMetaInfo(GetCurrentPerson(), UC.IpAddress, UC.ProxyIpAddress);

                    ecEval.CurrentMember = null;
                    ecEval.Call          = comm.Call;
                    ecEval.Commission    = comm;
                    ecEval.Step          = comm.Step;
                    ecEval.Submission    = sub;
                    ecEval.CreateMetaInfo(GetCurrentPerson(), UC.IpAddress, UC.ProxyIpAddress);
                    isNew = true;
                }
                else
                {
                    ecEval.UpdateMetaInfo(GetCurrentPerson(), UC.IpAddress, UC.ProxyIpAddress);
                }

                ecEval.Status = AdvEconomic.EvalStatus.draft;


                ecEval.Tables = EcoTableFromSubmission(sub, ref ecEval);

                try
                {
                    ecEval.Rank          = subStep.FirstOrDefault(st => st.Submission != null && st.Submission.Id == sub.Id).Rank;
                    ecEval.AverageRating = Math.Round(subStep.FirstOrDefault(st => st.Submission != null && st.Submission.Id == sub.Id).AverageRating, 2);
                    ecEval.SumRating     = subStep.FirstOrDefault(st => st.Submission != null && st.Submission.Id == sub.Id).SumRating;
                } catch (Exception ex)
                {
                }


                if (isNew)
                {
                    ecEvaluations.Add(ecEval);
                }
            }

            if (!Manager.IsInTransaction())
            {
                Manager.BeginTransaction();
            }


            try
            {
                Manager.SaveOrUpdateList <EcoD.EconomicEvaluation>(ecEvaluations);
                Manager.Commit();
            } catch (Exception ex)
            {
                Manager.RollBack();
                return(false);
            }

            return(true);
        }