Пример #1
0
        public void InitView()
        {
            Boolean isAnonymousUser = UserContext.isAnonymous;
            long    idCall          = View.PreloadIdCall;

            CallForPaperType type         = Service.GetCallType(idCall);
            long             idSubmission = View.PreloadedIdSubmission;
            long             idRevision   = View.PreloadedIdRevision;
            Guid             uniqueId     = View.PreloadedUniqueID;

            dtoSubmissionRevision submission = Service.GetSubmissionWithRevisions(idSubmission, true);
            int idModule = (type == CallForPaperType.CallForBids) ? Service.ServiceModuleID() : ServiceRequest.ServiceModuleID();

            View.CallType = type;

            dtoBaseForPaper call        = Service.GetDtoBaseCall(idCall);
            int             idCommunity = SetCallCurrentCommunity(call);

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

            View.IdSubmission = idSubmission;
            if (submission != null && (idRevision == 0 && submission.Revisions.Where(r => r.Id == idRevision && r.AllowSave).Any()))
            {
                idRevision = submission.GetIdWorkingRevision();
            }
            View.IdRevision = idRevision;
            Int32 containerIdCommunity = (View.PreloadIdOtherCommunity != -1) ? View.PreloadIdOtherCommunity : idCommunity;

            if (isAnonymousUser)
            {
                View.DisplaySessionTimeout();
            }
            else if (submission == null)
            {
                View.DisplayRevisionUnknown();
                View.SetActionUrl(CallStandardAction.ViewRevisions, RootObject.ViewRevisions(type, CallStandardAction.List, containerIdCommunity, CallStatusForSubmitters.Revisions));
            }
            else if (submission != null && (idRevision == 0 || submission.IsAnonymous || submission.IdPerson != UserContext.CurrentUserID))
            {
                if (idRevision == 0)
                {
                    View.DisplayRevisionUnavailable();
                }
                else
                {
                    View.DisplayNoPermission(idCommunity, idModule);
                }
                View.SetActionUrl(CallStandardAction.ViewRevisions, RootObject.ViewRevisions(type, CallStandardAction.List, containerIdCommunity, CallStatusForSubmitters.Revisions));
            }
            else
            {
                int        idUser     = UserContext.CurrentUserID;
                litePerson currenUser = GetCurrentUser(ref idUser);
                Boolean    allowView  = false;
                View.CallRepository = call.GetRepositoryIdentifier();
                switch (type)
                {
                case CallForPaperType.CallForBids:
                    ModuleCallForPaper module = Service.CallForPaperServicePermission(idUser, idCommunity);
                    allowView = (submission.Owner.Id == idUser || module.ManageCallForPapers || module.Administration || ((module.CreateCallForPaper || module.EditCallForPaper) && call.Owner.Id == idUser));
                    break;

                case CallForPaperType.RequestForMembership:
                    ModuleRequestForMembership moduleR = Service.RequestForMembershipServicePermission(idUser, idCommunity);
                    allowView = (submission.Owner.Id == idUser || moduleR.ManageBaseForPapers || moduleR.Administration || ((moduleR.CreateBaseForPaper || moduleR.EditBaseForPaper) && call.Owner.Id == idUser));
                    break;
                }
                View.IdSubmission    = idSubmission;
                View.IdSubmitterType = submission.Type.Id;
                View.TryToComplete   = false;

                dtoRevisionRequest rev = submission.GetWorkingRevision();

                View.InitializeView(Service.RevisionWithFileToUpload(idRevision));
                DateTime InitTime                = DateTime.Now;
                Boolean  allowTimeRevision       = rev.AllowSubmission(InitTime);
                Boolean  allowSave               = false;
                Boolean  allowCompleteSubmission = false;


                if (!allowTimeRevision && (rev.Status == RevisionStatus.Request || rev.Status == RevisionStatus.RequestAccepted || rev.Status == RevisionStatus.Required))
                {
                    View.DisplayRevisionTimeExpired();
                    switch (type)
                    {
                    case CallForPaperType.CallForBids:
                        View.SendUserAction(idCommunity, idModule, idRevision, ModuleCallForPaper.ActionType.ViewRevision);
                        break;

                    case CallForPaperType.RequestForMembership:
                        View.SendUserAction(idCommunity, idModule, idRevision, ModuleRequestForMembership.ActionType.ViewRevision);
                        break;
                    }
                }
                else
                {
                    idSubmission = (submission == null) ? 0 : submission.Id;
                    View.AllowDeleteSubmission = false;
                    //View.AllowDeleteSubmission = (submission != null && submission.Deleted == BaseStatusDeleted.None && submission.Status == SubmissionStatus.draft);
                    allowCompleteSubmission = allowTimeRevision && (rev != null && rev.Deleted == BaseStatusDeleted.None && rev.AllowSave);
                    allowSave = allowCompleteSubmission;
                    View.InitSubmissionTime = InitTime;

                    switch (type)
                    {
                    case CallForPaperType.CallForBids:
                        View.SendUserAction(idCommunity, idModule, idRevision, ModuleCallForPaper.ActionType.ViewRevision);
                        break;

                    case CallForPaperType.RequestForMembership:
                        View.SendUserAction(idCommunity, idModule, idRevision, ModuleRequestForMembership.ActionType.ViewRevision);
                        break;
                    }
                }
                View.AllowSave = allowSave;
                View.AllowCompleteSubmission = allowCompleteSubmission;
                LoadRevision(call, submission, rev);
                if (allowView)
                {
                    if (View.PreloadView == CallStatusForSubmitters.Revisions)
                    {
                        View.SetActionUrl(CallStandardAction.ViewRevisions, RootObject.ViewRevisions(type, CallStandardAction.List, containerIdCommunity, CallStatusForSubmitters.Revisions));
                    }
                    else
                    {
                        View.SetActionUrl(CallStandardAction.List, RootObject.ViewCalls(idCall, type, CallStandardAction.List, containerIdCommunity, View.PreloadView));
                    }
                }
            }
        }
Пример #2
0
        private void LoadRevisionInfos(Boolean allowAdmin, BaseForPaper call, dtoSubmissionRevision submission)
        {
            Boolean allowRevision = false;
            Boolean isOwner       = (submission.IdPerson == UserContext.CurrentUserID);

            switch (call.RevisionSettings)
            {
            case RevisionMode.OnlyManager:
                allowRevision = allowAdmin && !submission.IsAnonymous;
                break;

            case RevisionMode.ManagerSubmitter:
                allowRevision = (allowAdmin && !submission.IsAnonymous) || (isOwner && !submission.IsAnonymous);
                break;

            case RevisionMode.OnlySubmitter:
                allowRevision = (isOwner && !submission.IsAnonymous);
                break;

            default:
                allowRevision = false;
                break;
            }
            Boolean submissionRevision = !call.AdvacedEvaluation && (allowRevision && submission.Status >= SubmissionStatus.submitted && submission.Status != SubmissionStatus.rejected);

            // SE posso fare la revisione e NON ci sono revisioni in corso !
            View.AllowRevisionRequest = submissionRevision && submission.HasWorkingRevision() == false;

            dtoRevisionRequest revision        = submission.GetWorkingRevision();
            List <dtoRevision> acceptRevisions = submission.GetAcceptedRevisions();

            long currentRevision = View.IdRevision;

            if (allowAdmin && currentRevision > 0)
            {
                if (revision != null)
                {
                    Int32 version    = acceptRevisions.Where(r => r.Id <= currentRevision).Select(r => r.Number).Max();
                    Int32 subVersion = submission.Revisions.Where(r => r.Id > acceptRevisions.Where(a => a.IsActive && a.Id <= currentRevision).Select(t => t.Id).FirstOrDefault() && r.Id < currentRevision).Count() + 1;
                    //revision.SubVersion = subVersion;
                    //acceptRevisions.Insert(0,revision);

                    //if (currentRevision == revision.Id && revision.Status != RevisionStatus.Submitted) {
                    switch (revision.Type)
                    {
                    case RevisionType.UserRequired:
                        View.DisplayUserPendingRequest(revision, RootObject.UserReviewCall(View.CallType, View.IdCall, View.IdSubmission, revision.Id, CallStatusForSubmitters.Submitted, View.PreloadIdOtherCommunity));
                        break;

                    case RevisionType.Manager:
                        View.DisplayManagePendingRevision(revision, RootObject.UserReviewCall(View.CallType, View.IdCall, View.IdSubmission, revision.Id, CallStatusForSubmitters.Submitted, View.PreloadIdOtherCommunity));
                        break;
                    }
                    //}
                }
                if (submissionRevision && !submission.HasWorkingRevision())
                {
                    View.InitializeRevisionRequest(((allowAdmin) ? RevisionType.Manager : RevisionType.None));
                }
            }
            else
            {
                // Imposto le richieste di revisione
                if (submissionRevision && !submission.HasWorkingRevision())
                {
                    View.InitializeRevisionRequest((isOwner) ? RevisionType.UserRequired : ((allowAdmin) ? RevisionType.Manager : RevisionType.None));
                }
                if (revision != null && revision.Status != RevisionStatus.Submitted)
                {
                    View.IdPendingRevision = revision.Id;
                    if (isOwner)
                    {
                        switch (revision.Type)
                        {
                        case RevisionType.UserRequired:
                            View.DisplaySelfPendingRequest(revision, RootObject.UserReviewCall(View.CallType, View.IdCall, View.IdSubmission, revision.Id, CallStatusForSubmitters.Submitted, View.PreloadIdOtherCommunity));
                            break;

                        case RevisionType.Manager:
                            View.DisplayPendingRevision(revision, RootObject.UserReviewCall(View.CallType, View.IdCall, View.IdSubmission, revision.Id, CallStatusForSubmitters.Submitted, View.PreloadIdOtherCommunity));
                            break;
                        }
                    }

                    else if (allowAdmin)
                    {
                        switch (revision.Type)
                        {
                        case RevisionType.UserRequired:
                            View.DisplayUserPendingRequest(revision, RootObject.UserReviewCall(View.CallType, View.IdCall, View.IdSubmission, revision.Id, CallStatusForSubmitters.Submitted, View.PreloadIdOtherCommunity));
                            break;

                        case RevisionType.Manager:
                            View.DisplayManagePendingRevision(revision, RootObject.UserReviewCall(View.CallType, View.IdCall, View.IdSubmission, revision.Id, CallStatusForSubmitters.Submitted, View.PreloadIdOtherCommunity));
                            break;
                        }
                    }
                }
                if (revision == null || (revision != null && (revision.Id != View.IdRevision || revision.Status == RevisionStatus.Submitted)))
                {
                    View.DisplayRevisionInfo(submission.Revisions.Where(r => r.Id == View.IdRevision).FirstOrDefault());
                }
            }

            // Carico la lista delle revisioni attualmente accettate !
            View.LoadAvailableRevision(acceptRevisions, View.IdRevision);
        }