Ejemplo n.º 1
0
        public void InitView()
        {
            Boolean isAnonymousUser = UserContext.isAnonymous;
            long    idCall          = View.PreloadIdCall;
            Int32   idUser          = UserContext.CurrentUserID;

            lm.Comol.Modules.CallForPapers.Domain.CallForPaperType type = ServiceCall.GetCallType(idCall);
            int idModule = (type == CallForPaperType.CallForBids) ? ServiceCall.ServiceModuleID() : ServiceRequest.ServiceModuleID();

            dtoCall call = (type == CallForPaperType.CallForBids) ? ServiceCall.GetDtoCall(idCall) : null;

            if (call != null)
            {
                View.SetContainerName(call.Name, call.EndEvaluationOn);
            }
            int idCommunity = GetCurrentCommunity(call);

            View.IdCall          = idCall;
            View.IdCallModule    = idModule;
            View.IdCallCommunity = idCommunity;
            View.CallType        = type;

            if (call != null && call.AdvacedEvaluation)
            {
                //Advanced.dto.dtoCommEvalInfo evInfo = ServiceCall.CommissionEvalTypeGet(View.IdAdvCommittee);

                //if (evInfo.Type == Advanced.EvalType.Average)
                //    View.CurrentEvaluationType = EvaluationType.Average;
                //else
                //    View.CurrentEvaluationType = EvaluationType.Sum;


                //Il TIPO di valutazione IMPOSTATO ha impatto SOLO nell'aggregazione tra COMMISSARI.
                //Nell'aggregazione tra i criteri di un VALUTATORE, uso SEMPRE E SOLO LA SOMMA!

                // View.CurrentEvaluationType = EvaluationType.Sum;
                //Sposto a DOPO , dove ho l'AdvCommission!
            }
            else
            {
                View.CurrentEvaluationType = (call != null ? call.EvaluationType : EvaluationType.Sum);
            }



            dtoEvaluationsFilters filters = View.PreloadFilters;
            ModuleCallForPaper    module  = ServiceCall.CallForPaperServicePermission(idUser, idCommunity);

            Boolean allowEvaluate = false;
            Boolean allowAdmin    = ((module.ManageCallForPapers || module.Administration || ((module.CreateCallForPaper || module.EditCallForPaper) && call.Owner.Id == idUser)));

            View.SetActionUrl(
                (allowAdmin) ? CallStandardAction.Manage : CallStandardAction.List,
                RootObject.ViewCalls(idCall,
                                     type,
                                     ((allowAdmin) ? CallStandardAction.Manage : CallStandardAction.List),
                                     idCommunity,
                                     View.PreloadView),
                call.AdvacedEvaluation,
                RootObject.AdvCommissionEdit(idCall, View.IdAdvCommittee, Advanced.CommiteeEditPage.Members));

            if (UserContext.isAnonymous)
            {
                View.DisplaySessionTimeout(RootObject.ViewSubmissionsToEvaluate(CallForPaperType.CallForBids, idCall, idCommunity, View.PreloadView, View.PreloadOrderBy, View.PreloadAscending, filters.IdSubmitterType, filters.Status, View.GetItemEncoded(filters.SearchForName)));
            }
            if (call == null)
            {
                View.DisplayUnknownCall(idCommunity, idModule, idCall, type);
            }
            else if (type == CallForPaperType.RequestForMembership)
            {
                View.DisplayEvaluationUnavailable();
            }
            else
            {
                if (call.AdvacedEvaluation)
                {
                    Advanced.EvaluationAdvPermission advPermission = ServiceCall.EvaluationAdvPermission(idCall, View.IdAdvCommittee);

                    allowEvaluate = ((advPermission & Advanced.EvaluationAdvPermission.Evaluate) == Advanced.EvaluationAdvPermission.Evaluate);
                    bool allowView = ((advPermission & Advanced.EvaluationAdvPermission.View) == Advanced.EvaluationAdvPermission.View);

                    if (allowEvaluate | allowView)
                    {
                        View.AllowEvaluate = allowEvaluate; // (allowEvaluate && (!call.EndEvaluationOn.HasValue || call.EndEvaluationOn.Value >= DateTime.Now));
                        View.DisplayEvaluationInfo(call.EndEvaluationOn);
                        long idMember = ServiceCall.MemberIdGet(View.IdAdvCommittee);
                        InitalizeViewAdv(idCall, idCommunity, View.IdAdvCommittee, idMember, filters);
                    }
                    else
                    {
                    }
                }
                else
                {
                    long    idEvaluator = Service.GetIdEvaluator(idCall, UserContext.CurrentUserID);
                    Boolean isEvaluator = (idEvaluator > 0); //Service.isEvaluator(idCall, UserContext.CurrentUserID);
                    allowEvaluate    = isEvaluator;          //(isEvaluator || module.ManageCallForPapers || module.Administration || ((module.CreateCallForPaper || module.EditCallForPaper) && call.Owner.Id == idUser));
                    View.IdEvaluator = idEvaluator;
                    if (!allowEvaluate)
                    {
                        View.DisplayEvaluationUnavailable();
                    }
                    else if (!isEvaluator)
                    {
                        View.DisplayNotEvaluationPermission();
                    }
                    else
                    {
                        View.AllowEvaluate = (allowEvaluate && (!call.EndEvaluationOn.HasValue || call.EndEvaluationOn.Value >= DateTime.Now));
                        View.DisplayEvaluationInfo(call.EndEvaluationOn);
                        InitalizeView(idCall, idCommunity, View.PreloadIdCommittee, idEvaluator, filters);
                    }
                }
            }
        }