private Boolean AllowStatusEdit(long idCall, CallForPaperType type, dtoBaseForPaper call, Boolean allowSave)
        {
            switch (type)
            {
            case CallForPaperType.CallForBids:
                switch (call.Status)
                {
                case CallForPaperStatus.Draft:
                    return(allowSave || CallService.CallHasSubmissions(idCall));

                case CallForPaperStatus.SubmissionClosed:
                    return(allowSave && (!CallService.CallHasSubmissions(idCall) || (call.EndDate.HasValue == false || call.EndDate.HasValue && call.EndDate <= DateTime.Now)));

                case CallForPaperStatus.SubmissionsLimitReached:
                    return(allowSave && CallService.CallHasSubmissions(idCall));

                case CallForPaperStatus.SubmissionOpened:
                    return(allowSave && (!CallService.CallHasSubmissions(idCall) || (call.EndDate.HasValue == false || call.EndDate.HasValue && call.EndDate <= DateTime.Now)));

                default:
                    return(allowSave && !CallService.CallHasSubmissions(idCall));
                }

            default:
                return(allowSave);
            }
        }
Exemple #2
0
        public void InitView()
        {
            long idCall = View.PreloadIdCall;

            dtoBaseForPaper  call = null;
            CallForPaperType type = CallService.GetCallType(idCall);

            if (type == CallForPaperType.None)
            {
                type = View.PreloadType;
            }
            call = CallService.GetDtoBaseCall(idCall);

            View.CallType = type;
            int idCommunity = SetCallCurrentCommunity(call);

            if (UserContext.isAnonymous)
            {
                View.DisplaySessionTimeout();
            }
            else
            {
                litePerson                 currenUser  = CurrentManager.GetLitePerson(UserContext.CurrentUserID);
                Boolean                    allowManage = false;
                Boolean                    allowView   = false;
                Boolean                    allowSave   = false;
                ModuleCallForPaper         module      = null;
                ModuleRequestForMembership moduleR     = null;
                switch (type)
                {
                case CallForPaperType.CallForBids:
                    module      = CallService.CallForPaperServicePermission(UserContext.CurrentUserID, idCommunity);
                    allowView   = (module.ViewCallForPapers || module.Administration || module.ManageCallForPapers);
                    allowManage = module.CreateCallForPaper || module.Administration || module.ManageCallForPapers || module.EditCallForPaper;
                    allowSave   = (module.Administration || module.ManageCallForPapers || (module.CreateCallForPaper && idCall == 0) || (call != null && module.EditCallForPaper && currenUser == call.Owner));
                    break;

                case CallForPaperType.RequestForMembership:
                    moduleR     = CallService.RequestForMembershipServicePermission(UserContext.CurrentUserID, idCommunity);
                    allowView   = (moduleR.ViewBaseForPapers || moduleR.Administration || moduleR.ManageBaseForPapers);
                    allowManage = moduleR.CreateBaseForPaper || moduleR.Administration || moduleR.ManageBaseForPapers || moduleR.EditBaseForPaper;
                    allowSave   = (moduleR.Administration || moduleR.ManageBaseForPapers || (moduleR.CreateBaseForPaper && idCall == 0) || (call != null && moduleR.EditBaseForPaper && currenUser == call.Owner));
                    break;

                default:
                    break;
                }

                int idModule = (type == CallForPaperType.CallForBids) ? CallService.ServiceModuleID() : RequestService.ServiceModuleID();
                View.IdCallModule = idModule;
                if (call == null)
                {
                    View.LoadUnknowCall(idCommunity, idModule, idCall, type);
                }
                else if (allowManage || allowSave)
                {
                    View.AllowSave = allowSave && (!CallService.CallHasSubmissions(idCall));
                    View.IdCall    = idCall;
                    View.SetActionUrl(CallStandardAction.Manage, RootObject.ViewCalls(type, CallStandardAction.Manage, idCommunity, View.PreloadView));
                    if (type == CallForPaperType.CallForBids)
                    {
                        LoadRequiredFiles(idCall, module);
                        View.SendUserAction(idCommunity, idModule, idCall, ModuleCallForPaper.ActionType.ViewRequestedFiles);
                    }
                    else
                    {
                        LoadRequiredFiles(idCall, moduleR);
                        View.SendUserAction(idCommunity, idModule, idCall, ModuleRequestForMembership.ActionType.ViewRequestedFiles);
                    }

                    View.SetActionUrl(CallStandardAction.PreviewCall, RootObject.PreviewCall(type, idCall, idCommunity, View.PreloadView));
                }
                else
                {
                    View.DisplayNoPermission(idCommunity, idModule);
                }
            }
        }
        public void SaveSettings(dtoBaseForPaper dto, String submitterName, Boolean allowUseOfDss, Boolean validateStatus)
        {
            int idCommunity = View.IdCommunity;

            try
            {
                int idModule = (dto.Type == CallForPaperType.CallForBids) ? CallService.ServiceModuleID() : RequestService.ServiceModuleID();

                if (dto.Type == CallForPaperType.RequestForMembership && dto.EndDate.HasValue && dto.StartDate >= dto.EndDate.Value)
                {
                    View.DisplayDateError(dto.StartDate, dto.EndDate.Value);
                }
                else if (dto.Type == CallForPaperType.CallForBids && dto.EndDate.HasValue && dto.StartDate >= dto.EndDate.Value && ((dtoCall)dto).EndEvaluationOn.HasValue && dto.EndDate.Value >= ((dtoCall)dto).EndEvaluationOn.Value)
                {
                    View.DisplayDateError(CallForPaperType.CallForBids);
                }
                else if (dto.Type == CallForPaperType.CallForBids && dto.EndDate.HasValue && dto.StartDate >= dto.EndDate.Value)
                {
                    View.DisplayDateError(dto.StartDate, dto.EndDate.Value);
                }
                else if (dto.Type == CallForPaperType.CallForBids && dto.EndDate.HasValue && ((dtoCall)dto).EndEvaluationOn.HasValue && dto.EndDate.Value >= ((dtoCall)dto).EndEvaluationOn.Value)
                {
                    View.DisplayEvaluationDateError(dto.EndDate.Value, ((dtoCall)dto).EndEvaluationOn.Value);
                }
                else
                {
                    Boolean stepsToComplete = false;
                    List <lm.Comol.Core.Wizard.NavigableWizardItem <WizardCallStep> > wizardSteps = null;
                    BaseForPaper          call        = null;
                    List <WizardCallStep> skipedSteps = new List <WizardCallStep>();;
                    long    idCall        = dto.Id;
                    Boolean hasSubmission = false;
                    if (idCall > 0)
                    {
                        hasSubmission = CallService.CallHasSubmissions(idCall);
                    }
                    if (dto.Status > CallForPaperStatus.Draft && idCall == 0)
                    {
                        dto.Status         = CallForPaperStatus.Draft;
                        stepsToComplete    = true;
                        View.CurrentStatus = dto.Status;
                    }
                    else if (dto.Status > CallForPaperStatus.Draft && idCall > 0)
                    {
                        wizardSteps = CallService.GetAvailableSteps(idCall, WizardCallStep.GeneralSettings, View.CallType);
                        skipedSteps = CallService.GetSkippedSteps(wizardSteps, idCall, View.CallType);

                        stepsToComplete = (skipedSteps.Count > 0);

                        if (stepsToComplete && !hasSubmission)
                        {
                            dto.Status         = CallForPaperStatus.Draft;
                            View.CurrentStatus = dto.Status;
                        }
                    }


                    if (dto.Type == CallForPaperType.CallForBids)
                    {
                        call = CallService.SaveCallSettings((dtoCall)dto, idCommunity, validateStatus);
                    }
                    else
                    {
                        call = RequestService.SaveCallSettings((dtoRequest)dto, idCommunity, validateStatus, submitterName);
                    }
                    if (call != null)
                    {
                        idCall = call.Id;
                        RefreshCallName(View.CurrentAction, dto.Name, idCommunity);
                    }
                    View.IdCall = idCall;
                    if (dto.Type == CallForPaperType.CallForBids)
                    {
                        View.SendUserAction(idCommunity, idModule, idCall, (View.CurrentAction == CallStandardAction.Add) ? ModuleCallForPaper.ActionType.AddCallSettings : ModuleCallForPaper.ActionType.SaveCallSettings);
                    }
                    else
                    {
                        View.SendUserAction(idCommunity, idModule, idCall, (View.CurrentAction == CallStandardAction.Add) ? ModuleRequestForMembership.ActionType.AddCallSettings : ModuleRequestForMembership.ActionType.SaveCallSettings);
                    }
                    if (wizardSteps == null)
                    {
                        wizardSteps = CallService.GetAvailableSteps(idCall, WizardCallStep.GeneralSettings, call.Type);
                    }

                    if (stepsToComplete && skipedSteps.Count > 0)
                    {
                        View.DisplaySkippedRequiredSteps(skipedSteps);
                    }
                    else if (stepsToComplete && wizardSteps.Count > 0)
                    {
                        View.DisplaySkippedRequiredSteps(wizardSteps.Where(ws => ws.Status == Core.Wizard.WizardItemStatus.error || ws.Status == Core.Wizard.WizardItemStatus.disabled).Select(ws => ws.Id).ToList());
                    }
                    else if (call != null)
                    {
                        View.DisplaySettingsSaved();
                    }
                    if (View.InvalidStatusFound)
                    {
                        View.InvalidStatusFound = false;
                        View.LoadStatus(CallService.GetAvailableStatus(idCall), dto.Status);
                        dto = CallService.GetDtoBaseCall(idCall);
                        View.LoadCall(dto);
                        if (dto.Type == CallForPaperType.CallForBids)
                        {
                            View.LoadEvaluationSettings(CallService.GetEvaluationSettings(idCall, allowUseOfDss));
                        }
                    }
                    else
                    {
                        View.LoadStatus(CallService.GetAvailableStatus(idCall), dto.Status);
                    }

                    View.LoadWizardSteps(idCall, dto.Type, idCommunity, wizardSteps);
                }
            }
            catch (SkipRequiredSteps exc) {
                View.DisplaySkippedRequiredSteps(exc.Steps);
            }
            catch (CallForPaperInvalidStatus ex)
            {
                View.InvalidStatusFound = true;
                switch (dto.Status)
                {
                case CallForPaperStatus.Draft:
                    if (dto.StartDate >= DateTime.Now)
                    {
                        View.CurrentStatus = (!dto.EndDate.HasValue || (dto.EndDate.HasValue && dto.EndDate.Value <= DateTime.Now)) ? CallForPaperStatus.SubmissionOpened: CallForPaperStatus.SubmissionClosed;
                    }
                    else
                    {
                        View.CurrentStatus = CallForPaperStatus.SubmissionOpened;
                    }
                    break;
                }
                View.LoadInvalidStatus(dto.Status, dto.EndDate);
                RefreshCallName(View.CurrentAction, dto.Name, idCommunity);
            }
        }
Exemple #4
0
        public void InitView()
        {
            long idCall = View.PreloadIdCall;

            dtoBaseForPaper  call = null;
            CallForPaperType type = CallService.GetCallType(idCall);

            if (type == CallForPaperType.None)
            {
                type = View.PreloadType;
            }
            call = CallService.GetDtoBaseCall(idCall);

            View.CallType = type;
            int idCommunity = SetCallCurrentCommunity(call);

            if (UserContext.isAnonymous)
            {
                View.DisplaySessionTimeout();
            }
            else
            {
                litePerson                 currenUser  = CurrentManager.GetLitePerson(UserContext.CurrentUserID);
                Boolean                    allowManage = false;
                Boolean                    allowView   = false;
                Boolean                    allowSave   = false;
                ModuleCallForPaper         module      = null;
                ModuleRequestForMembership moduleR     = null;
                switch (type)
                {
                case CallForPaperType.CallForBids:
                    module      = CallService.CallForPaperServicePermission(UserContext.CurrentUserID, idCommunity);
                    allowView   = (module.ViewCallForPapers || module.Administration || module.ManageCallForPapers);
                    allowManage = module.CreateCallForPaper || module.Administration || module.ManageCallForPapers || module.EditCallForPaper;
                    allowSave   = (module.Administration || module.ManageCallForPapers || (module.CreateCallForPaper && idCall == 0) || (call != null && module.EditCallForPaper && currenUser == call.Owner));
                    break;

                case CallForPaperType.RequestForMembership:
                    moduleR     = CallService.RequestForMembershipServicePermission(UserContext.CurrentUserID, idCommunity);
                    allowView   = (moduleR.ViewBaseForPapers || moduleR.Administration || moduleR.ManageBaseForPapers);
                    allowManage = moduleR.CreateBaseForPaper || moduleR.Administration || moduleR.ManageBaseForPapers || moduleR.EditBaseForPaper;
                    allowSave   = (moduleR.Administration || moduleR.ManageBaseForPapers || (moduleR.CreateBaseForPaper && idCall == 0) || (call != null && moduleR.EditBaseForPaper && currenUser == call.Owner));
                    break;

                default:
                    break;
                }

                int idModule = (type == CallForPaperType.CallForBids) ? CallService.ServiceModuleID() : RequestService.ServiceModuleID();
                View.IdCallModule = idModule;
                if (call == null)
                {
                    View.LoadUnknowCall(idCommunity, idModule, idCall, type);
                }
                else if (allowManage || allowSave)
                {
                    allowSave      = allowSave && (type == CallForPaperType.RequestForMembership || (type != CallForPaperType.RequestForMembership && (!CallService.CallHasSubmissions(idCall))));
                    View.AllowSave = allowSave;
                    View.IdCall    = idCall;
                    List <lm.Comol.Core.DomainModel.Repository.RepositoryAttachmentUploadActions> availableActions = new List <Core.DomainModel.Repository.RepositoryAttachmentUploadActions>()
                    {
                        Core.DomainModel.Repository.RepositoryAttachmentUploadActions.uploadtomoduleitem
                    };
                    lm.Comol.Core.FileRepository.Domain.RepositoryIdentifier rIdentifier = call.GetRepositoryIdentifier();
                    if (!(rIdentifier.Type == Core.FileRepository.Domain.RepositoryType.Community && rIdentifier.IdCommunity == 0))
                    {
                        View.InitializeAttachmentsControl(idCall, type, rIdentifier, availableActions, Core.DomainModel.Repository.RepositoryAttachmentUploadActions.uploadtomoduleitem);
                    }

                    List <lm.Comol.Core.Wizard.NavigableWizardItem <WizardCallStep> > steps = CallService.GetAvailableSteps(idCall, WizardCallStep.Attachments, type);
                    View.SetActionUrl(CallStandardAction.Manage, RootObject.ViewCalls(type, CallStandardAction.Manage, idCommunity, View.PreloadView));
                    View.LoadWizardSteps(idCall, type, idCommunity, steps);

                    if (type == CallForPaperType.CallForBids)
                    {
                        LoadAttachments(idCall, module);
                        View.SendUserAction(idCommunity, idModule, idCall, ModuleCallForPaper.ActionType.EditAttachments);
                    }
                    else
                    {
                        LoadAttachments(idCall, moduleR);
                        View.SendUserAction(idCommunity, idModule, idCall, ModuleRequestForMembership.ActionType.EditAttachments);
                    }
                    if (steps.Where(s => s.Id == WizardCallStep.SubmittersType && (s.Status == Core.Wizard.WizardItemStatus.valid || s.Status == Core.Wizard.WizardItemStatus.warning)).Any())
                    {
                        View.SetActionUrl(CallStandardAction.PreviewCall, RootObject.PreviewCall(type, idCall, idCommunity, View.PreloadView));
                    }
                }
                else
                {
                    View.DisplayNoPermission(idCommunity, idModule);
                }
            }
        }