public void InitView(Boolean forPublicCall)
        {
            long             idCall          = View.PreloadIdCall;
            Boolean          skinInitialized = false;
            dtoRequest       call            = null;
            CallForPaperType type            = Service.GetCallType(idCall);

            call = Service.GetDtoRequest(idCall);
            if (type == CallForPaperType.None || call == null)
            {
                type = CallForPaperType.RequestForMembership;
            }
            View.CallType = type;
            int idCommunity = SetCallCurrentCommunity(call);
            int idModule    = Service.ServiceModuleID();

            Boolean hasPermissionToSubmit = Service.IsCallAvailableByUser(idCall, UserContext.CurrentUserID);

            if (call == null)
            {
                View.LoadUnknowCall(idCommunity, idModule, idCall, type);
            }
            else if (UserContext.isAnonymous && !forPublicCall)
            {
                if (call.IsPublic)
                {
                    View.GoToUrl(RootObject.SubmitToCallBySubmitterType(type, idCall, call.IsPublic, View.PreloadedIdSubmission, View.PreloadedIdSubmitter, View.FromPublicList, View.PreloadView, View.PreloadIdOtherCommunity));
                }
                else
                {
                    View.DisplaySessionTimeout();
                }
            }
            else if (UserContext.isAnonymous && forPublicCall && !call.IsPublic)
            {
                View.DisplayCallUnavailableForPublic();
            }
            else if (!hasPermissionToSubmit && call.IsPublic && forPublicCall == false)
            {
                View.GoToUrl(RootObject.SubmitToCallBySubmitterType(type, idCall, call.IsPublic, View.IdSubmission, View.PreloadedIdSubmitter, View.FromPublicList, View.PreloadView, View.PreloadIdOtherCommunity));
            }
            else
            {
                int        idUser     = UserContext.CurrentUserID;
                litePerson currenUser = GetCurrentUser(ref idUser);

                View.isAnonymousSubmission = forPublicCall;
                View.TryToComplete         = false;
                ModuleRequestForMembership module = Service.RequestForMembershipServicePermission(idUser, idCommunity);

                View.IdCallModule = idModule;
                if (call == null)
                {
                    View.LoadUnknowCall(idCommunity, idModule, idCall, type);
                    if (module.ViewBaseForPapers)
                    {
                        if (View.FromPublicList)
                        {
                            View.SetActionUrl(CallStandardAction.List, RootObject.PublicCollectorCalls(CallForPaperType.RequestForMembership, idCall, View.PreloadIdCommunity));
                        }
                        else if (!UserContext.isAnonymous)
                        {
                            View.SetActionUrl(CallStandardAction.List, RootObject.ViewCalls(idCall, CallForPaperType.RequestForMembership, CallStandardAction.List, (module.ViewBaseForPapers) ? idCommunity : View.PreloadIdOtherCommunity, View.PreloadView));
                        }
                    }
                }
                else if (call.Status <= CallForPaperStatus.Published || call.Status == CallForPaperStatus.SubmissionClosed || call.Status == CallForPaperStatus.SubmissionsLimitReached)
                {
                    View.DisplayCallUnavailable(call.Status);
                    if (module.ViewBaseForPapers)
                    {
                        if (View.FromPublicList)
                        {
                            View.SetActionUrl(CallStandardAction.List, RootObject.PublicCollectorCalls(CallForPaperType.RequestForMembership, idCall, View.PreloadIdCommunity));
                        }
                        else if (!UserContext.isAnonymous)
                        {
                            View.SetActionUrl(CallStandardAction.List, RootObject.ViewCalls(idCall, CallForPaperType.RequestForMembership, CallStandardAction.List, (module.ViewBaseForPapers) ? idCommunity : View.PreloadIdOtherCommunity, View.PreloadView));
                        }
                    }
                    if (forPublicCall)
                    {
                        View.InitializeView(Service.GetExternalContext(idCall), Service.CallWithFileToUpload(idCall, 0));
                        skinInitialized = true;
                    }
                }
                else if (module.ViewBaseForPapers || call.IsPublic || hasPermissionToSubmit)
                {
                    long idSubmission = View.PreloadedIdSubmission;
                    View.IdCall         = idCall;
                    View.CallRepository = call.GetRepositoryIdentifier();
                    if (module.ViewBaseForPapers || hasPermissionToSubmit)
                    {
                        if (View.FromPublicList)
                        {
                            View.SetActionUrl(CallStandardAction.List, RootObject.PublicCollectorCalls(CallForPaperType.RequestForMembership, idCall, View.PreloadIdCommunity));
                        }
                        else if (!UserContext.isAnonymous)
                        {
                            View.SetActionUrl(CallStandardAction.List, RootObject.ViewCalls(idCall, CallForPaperType.RequestForMembership, CallStandardAction.List, (module.ViewBaseForPapers) ? idCommunity : View.PreloadIdOtherCommunity, View.PreloadView));
                        }
                    }

                    // Find active submission
                    dtoSubmissionRevision submission = null;
                    if (forPublicCall && UserContext.isAnonymous)
                    {
                        submission = Service.GetActiveUserSubmission(idCall, UserContext.CurrentUserID, idSubmission, View.PreloadedUniqueID);
                        if (submission != null && submission.Owner.Id != idUser)
                        {
                            submission = null;
                        }
                    }
                    else
                    {
                        submission = Service.GetActiveUserSubmission(idCall, UserContext.CurrentUserID, idSubmission);
                    }


                    if (forPublicCall)
                    {
                        View.InitializeView(Service.GetExternalContext(idCall), Service.CallWithFileToUpload(idCall, 0));
                        skinInitialized = true;
                    }
                    else
                    {
                        SubmitterType submitter = null;
                        if (submission != null)
                        {
                            submitter = Service.GetSubmitterType(submission.Type.Id);
                        }
                        else
                        {
                            submitter = Service.GetSubmitterType(View.PreloadedIdSubmitter);
                        }

                        if (idSubmission == 0 && submitter != null && submitter.AllowMultipleSubmissions && Service.GetSubmissionCountBySubmitter(idCall, UserContext.CurrentUserID, submitter.Id) < submitter.MaxMultipleSubmissions)
                        {
                            submission = null;
                        }
                        View.InitializeView(Service.CallWithFileToUpload(idCall, (submission == null) ? 0 : submission.Type.Id));
                    }

                    DateTime InitTime = DateTime.Now;
                    if (call.StartDate > InitTime)
                    {
                        View.DisplaySubmissionTimeBefore(call.StartDate);
                    }
                    else if ((submission == null && !call.AllowSubmission(InitTime)) || (submission != null && submission.ExtensionDate.HasValue && call.AllowLateSubmission(InitTime, submission.ExtensionDate.Value)))
                    {
                        View.DisplaySubmissionTimeAfter(call.EndDate);
                    }
                    else if (submission != null && (submission.Deleted != BaseStatusDeleted.None || (submission.Status != SubmissionStatus.none && submission.Status != SubmissionStatus.draft)))
                    {
                        if (forPublicCall)
                        {
                            View.GoToUrl(RootObject.ViewSubmission(call.Type, call.Id, submission.Id, submission.UniqueId, true, View.FromPublicList, CallStatusForSubmitters.Submitted, View.PreloadIdOtherCommunity, 0));
                        }
                        else if (!UserContext.isAnonymous)
                        {
                            View.GoToUrl(RootObject.ViewSubmission(call.Type, call.Id, submission.Id, View.FromPublicList, CallStatusForSubmitters.Submitted, View.PreloadIdOtherCommunity, 0));
                        }
                    }
                    else if (submission != null && submission.Revisions.Where(r => r.Type != RevisionType.Original).Any())
                    {
                        if (!forPublicCall || (forPublicCall && !UserContext.isAnonymous))
                        {
                            View.GoToUrl(RootObject.UserReviewCall(call.Type, call.Id, submission.Id, submission.GetIdWorkingRevision(), CallStatusForSubmitters.Submitted, View.PreloadIdOtherCommunity));
                        }
                        else
                        {
                            View.DisplayCallUnavailableForPublic();
                        }
                    }
                    else
                    {
                        idSubmission = (submission == null) ? 0 : submission.Id;
                        long idRevision = (submission == null) ? 0 : submission.GetIdOriginal();
                        View.IdRevision   = idRevision;
                        View.IdSubmission = idSubmission;

                        View.AllowDeleteSubmission = false;
                        Boolean allowSave = false;
                        Boolean allowCompleteSubmission = false;
                        LoadCall(call, submission);

                        View.AllowSubmitterChange = false;
                        if (module.AddSubmission || call.IsPublic || hasPermissionToSubmit)
                        {
                            View.AllowDeleteSubmission = (submission != null && submission.Deleted == BaseStatusDeleted.None && submission.Status == SubmissionStatus.draft);
                            allowCompleteSubmission    = (submission != null && submission.Deleted == BaseStatusDeleted.None && submission.Status == SubmissionStatus.draft);
                            allowSave      = (submission != null && submission.Deleted == BaseStatusDeleted.None && submission.Status == SubmissionStatus.draft);
                            View.AllowSave = allowSave;
                            View.AllowCompleteSubmission = allowCompleteSubmission;
                            if (submission == null)
                            {
                                View.IdSubmission         = 0;
                                View.AllowSubmitterChange = true;
                                View.SendStartSubmission(idCommunity, idModule, idCall, ModuleRequestForMembership.ActionType.StartSubmission);
                            }
                            else
                            {
                                View.InitSubmissionTime = InitTime;
                                //if (submission.Status >= SubmissionStatus.submitted && viewList == CallStatusForSubmitters.SubmissionOpened)
                                //    viewList = CallStatusForSubmitters.Submitted;
                                View.AllowSubmitterSelection = false;
                                View.IdSubmission            = submission.Id;
                                LoadSections(idCall, submission.Type.Id, submission.Id, idRevision);
                                View.SendUserAction(idCommunity, idModule, submission.Id, ModuleRequestForMembership.ActionType.ViewSubmission);
                            }
                        }
                        else
                        {
                            View.AllowSave = allowSave;
                            View.AllowCompleteSubmission = allowCompleteSubmission;
                            if (idSubmission == 0)
                            {
                                View.DisableSubmitterTypesSelection();
                            }
                        }
                    }
                }
                else
                {
                    View.DisplayNoPermission(idCommunity, idModule);
                }
            }
            if (forPublicCall && !skinInitialized)
            {
                View.InitializeEmptyView();
            }
        }
Exemplo n.º 2
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));
                    }
                }
            }
        }
Exemplo n.º 3
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;

            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;

            if (isAnonymousUser)
            {
                View.DisplaySessionTimeout();
            }
            else if (submission == null)
            {
                View.DisplayRevisionUnknown();
                if (View.PreloadFromManagement)
                {
                    View.SetActionUrl(RootObject.ViewSubmissions(type, idCall, idSubmission, idRevision, View.PreloadView, View.PreloadFilterSubmission, View.PreloadOrderSubmission, View.PreloadAscending, View.PreloadPageIndex, View.PreloadPageSize));
                }
                else
                {
                    View.SetActionUrl(RootObject.ViewRevisions(idRevision, type, View.PreloadAction, idCommunity, View.PreloadView));
                }
            }
            else if (submission != null && (idRevision == 0))
            {
                View.DisplayRevisionUnavailable();
                View.SetActionUrl(RootObject.ViewRevisions(idRevision, type, View.PreloadAction, idCommunity, View.PreloadView));
            }
            else
            {
                int        idUser     = UserContext.CurrentUserID;
                litePerson currenUser = GetCurrentUser(ref idUser);
                Boolean    allowView  = false;

                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;

                if (idRevision == 0)
                {
                    idRevision = submission.GetIdLastActiveRevision();
                }
                dtoRevisionRequest rev = Service.GetRevisionRequest(idRevision, true);
                if (rev == null)
                {
                    View.DisplayRevisionUnknown();
                }
                else if (allowView)
                {
                    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;
                    }
                    LoadSubmission(call, submission, rev);
                }
                else
                {
                    View.DisplayNoPermission(idCommunity, idModule);
                }
                if (allowView)
                {
                    if (View.PreloadFromManagement)
                    {
                        View.SetActionUrl(RootObject.ViewSubmissions(type, idCall, idSubmission, idRevision, View.PreloadView, View.PreloadFilterSubmission, View.PreloadOrderSubmission, View.PreloadAscending, View.PreloadPageIndex, View.PreloadPageSize));
                    }
                    else
                    {
                        View.SetActionUrl(RootObject.ViewRevisions(idRevision, type, View.PreloadAction, idCommunity, View.PreloadView));
                    }
                }
            }
        }