Пример #1
0
        public void PushToServer(IManagedConnection connection)
        {
            string reason;

            if (!NewCohortDefinition.IsAcceptableAsNewCohort(out reason))
            {
                throw new Exception(reason);
            }

            NewCohortDefinition.LocationOfCohort.PushToServer(NewCohortDefinition, connection);
        }
Пример #2
0
        public void Check(ICheckNotifier notifier)
        {
            NewCohortDefinition.LocationOfCohort.Check(notifier);

            if (NewCohortDefinition.ID != null)
            {
                notifier.OnCheckPerformed(
                    new CheckEventArgs(
                        "Expected the cohort definition " + NewCohortDefinition +
                        " to have a null ID - we are trying to create this, why would it already exist?",
                        CheckResult.Fail));
            }
            else
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Confirmed that cohort ID is null", CheckResult.Success));
            }

            if (Project.ProjectNumber == null)
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Project " + Project + " does not have a ProjectNumber specified, it should have the same number as the CohortCreationRequest (" + NewCohortDefinition.ProjectNumber + ")", CheckResult.Fail));
            }
            else
            if (Project.ProjectNumber != NewCohortDefinition.ProjectNumber)
            {
                notifier.OnCheckPerformed(
                    new CheckEventArgs(
                        "Project " + Project + " has ProjectNumber=" + Project.ProjectNumber +
                        " but the CohortCreationRequest.ProjectNumber is " + NewCohortDefinition.ProjectNumber + "",
                        CheckResult.Fail));
            }


            string matchDescription;

            if (!NewCohortDefinition.IsAcceptableAsNewCohort(out matchDescription))
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Cohort failed novelness check:" + matchDescription,
                                                             CheckResult.Fail));
            }
            else
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Confirmed that cohort " + NewCohortDefinition + " does not already exist",
                                                             CheckResult.Success));
            }

            if (string.IsNullOrWhiteSpace(DescriptionForAuditLog))
            {
                notifier.OnCheckPerformed(new CheckEventArgs("User did not provide a description of the cohort for the AuditLog", CheckResult.Fail));
            }
        }