コード例 #1
0
        public static DataTable GetOutOfDateCourses(Int32?providerId = null)
        {
            ProviderPortalEntities db = new ProviderPortalEntities();

            UserContext.UserContextInfo context = UserContext.GetUserContext();
            DataTable dt = new DataTable();

            DbCommand cmd = db.Database.Connection.CreateCommand();

            cmd.CommandText = "exec [dbo].[up_GetProviderCoursesOutOfDate] @ProviderId, @LongCourseMinDurationWeeks, @LongCourseMaxStartDateInPastDays";
            cmd.Parameters.Add(new SqlParameter("@ProviderId", providerId ?? context.ItemId));
            cmd.Parameters.Add(new SqlParameter("@LongCourseMinDurationWeeks", Constants.ConfigSettings.LongCourseMinDurationWeeks));
            cmd.Parameters.Add(new SqlParameter("@LongCourseMaxStartDateInPastDays", Constants.ConfigSettings.LongCourseMaxStartDateInPastDays));

            try
            {
                db.Database.Connection.Open();
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    dt.Load(reader);
                }
            }
            finally
            {
                db.Database.Connection.Close();
            }

            return(dt);
        }
コード例 #2
0
        public static DataTable GetCoursesWithExpiredLAR(Int32?providerId = null)
        {
            //If there are courses which are linked to a no-longer-valid (expired) LAR (learning aim reference) code,
            //then the number of courses like this should be indicated.
            ProviderPortalEntities db = new ProviderPortalEntities();

            UserContext.UserContextInfo context = UserContext.GetUserContext();
            DataTable dt = new DataTable();

            DbCommand cmd = db.Database.Connection.CreateCommand();

            cmd.CommandText = "exec [dbo].[up_GetProviderCoursesWithExpiredLAR] @ProviderId";
            cmd.Parameters.Add(new SqlParameter("@ProviderId", providerId ?? context.ItemId));

            try
            {
                db.Database.Connection.Open();
                using (DbDataReader reader = cmd.ExecuteReader())
                {
                    dt.Load(reader);
                }
            }
            finally
            {
                db.Database.Connection.Close();
            }

            return(dt);
        }
コード例 #3
0
        /// <summary>
        /// Set quality session information for the current context.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="httpContext"></param>
        public static void SetSessionInformation(UserContext.UserContextInfo context)
        {
            if (context == null || context.ItemId == null)
            {
                ClearSessionInformation();
                return;
            }

            var db = new ProviderPortalEntities();

            switch (context.ContextName)
            {
            case UserContext.UserContextName.Provider:
            {
                // Update the score if it doesn't exist
                if (db.QualityScores.All(x => x.ProviderId != context.ItemId.Value))
                {
                    db.up_ProviderUpdateQualityScore(context.ItemId.Value, true);
                }
                var info = db.QualityScores
                           .Where(x => x.ProviderId == context.ItemId.Value)
                           .Select(x => new
                    {
                        Score = x.AutoAggregateQualityRating,
                        UpdatedDateTimeUtc = x.ModifiedDateTimeUtc,
                        SfaFunded          = x.Provider.SFAFunded,
                        DfeFunded          = x.Provider.DFE1619Funded,
                        ProviderType       = x.Provider.ProviderType != null ? x.Provider.ProviderType.ProviderTypeName : String.Empty,
                        LastCalculated     = x.CalculatedDateTimeUtc
                    }).FirstOrDefault();
                DateTime?lastAllDataUpToDateTimeUtc = null;
                Provider provider = db.Providers.Find(context.ItemId.Value);
                if (provider != null)
                {
                    lastAllDataUpToDateTimeUtc = provider.LastAllDataUpToDateTimeUtc;
                }
                HttpContext.Current.Session[Constants.SessionFieldNames.ProviderLastActivity] =
                    info == null ? lastAllDataUpToDateTimeUtc : lastAllDataUpToDateTimeUtc.HasValue ? ProvisionDataCurrent.GetLatestDate(lastAllDataUpToDateTimeUtc.Value, info.UpdatedDateTimeUtc.HasValue ? info.UpdatedDateTimeUtc.Value : DateTime.MinValue) : info.UpdatedDateTimeUtc;
                HttpContext.Current.Session[Constants.SessionFieldNames.ProviderLastProvisionUpdate] =
                    info == null ? null : info.UpdatedDateTimeUtc;
                HttpContext.Current.Session[Constants.SessionFieldNames.ProviderQualityScore] =
                    info == null ? 0.0m : info.Score.Value / 100m;
                HttpContext.Current.Session[Constants.SessionFieldNames.ProviderIsSfaFunded] =
                    info != null && info.SfaFunded;
                HttpContext.Current.Session[Constants.SessionFieldNames.ProviderIsDfe1619Funded] =
                    info != null && info.DfeFunded;
                HttpContext.Current.Session[Constants.SessionFieldNames.ProviderType]             = info != null ? info.ProviderType : String.Empty;
                HttpContext.Current.Session[Constants.SessionFieldNames.ProviderQALastCalculated] = info == null ? (DateTime?)null : info.LastCalculated;
                break;
            }

            case UserContext.UserContextName.Organisation:
            {
                // Update the score if it doesn't exist
                if (db.OrganisationQualityScores.All(x => x.OrganisationId != context.ItemId.Value))
                {
                    db.up_OrganisationUpdateQualityScore(context.ItemId.Value);
                }
                var info = db.OrganisationQualityScores
                           .Where(x => x.OrganisationId == context.ItemId.Value)
                           .Select(x => new
                    {
                        EarliestModifiedDateTimeUtc = x.EarliestModifiedDateTimeUtc,
                        SfaFunded =
                            x.Organisation.OrganisationProviders.Any(
                                y => y.IsAccepted && !y.IsRejected && y.Provider.SFAFunded),
                        DfeFunded =
                            x.Organisation.OrganisationProviders.Any(
                                y => y.IsAccepted && !y.IsRejected && y.Provider.DFE1619Funded)
                    }).FirstOrDefault();
                HttpContext.Current.Session[Constants.SessionFieldNames.OrganisationLastActivity] =
                    info == null ? null : info.EarliestModifiedDateTimeUtc;
                HttpContext.Current.Session[Constants.SessionFieldNames.OrganisationIsSfaFunded] =
                    info != null && info.SfaFunded;
                HttpContext.Current.Session[Constants.SessionFieldNames.OrganisationIsDfe1619Funded] =
                    info != null && info.DfeFunded;
                break;
            }

            default:
            {
                ClearSessionInformation();
                break;
            }
            }
        }