예제 #1
0
        public static List <ThisEntity> DoSearch(MainSearchInput data, ref int totalRows)
        {
            string where = "";
            List <string> competencies = new List <string>();

            //only target full entities
            where = " ( base.EntityStateId = 3 ) ";

            SearchServices.HandleCustomFilters(data, 61, ref where);

            SetKeywordFilter(data.Keywords, false, ref where);
            SearchServices.SetSubjectsFilter(data, CodesManager.ENTITY_TYPE_LEARNING_OPP_PROFILE, ref where);

            SetPropertiesFilter(data, ref where);
            SearchServices.SetRolesFilter(data, ref where);
            SearchServices.SetBoundariesFilter(data, ref where);
            //SetBoundariesFilter( data, ref where );

            //CIP
            SetFrameworksFilter(data, ref where);

            //Competencies
            SetCompetenciesFilter(data, ref where, ref competencies);

            LoggingHelper.DoTrace(5, "LearningOpportunityServices.Search(). Filter: " + where);
            return(EntityMgr.Search(where, data.SortOrder, data.StartPage, data.PageSize, ref totalRows, ref competencies));
        }
예제 #2
0
        public static ThisEntity GetByCtid(string ctid)
        {
            ThisEntity entity = new ThisEntity();

            if (string.IsNullOrWhiteSpace(ctid))
            {
                return(entity);
            }

            return(EntityMgr.GetByCtid(ctid));
        }
예제 #3
0
        public static ThisEntity GetDetailByCtid(string ctid, bool skippingCache = false)
        {
            ThisEntity entity = new ThisEntity();

            if (string.IsNullOrWhiteSpace(ctid))
            {
                return(entity);
            }
            var learningOpportunity = EntityMgr.GetByCtid(ctid);

            return(GetDetail(learningOpportunity.Id, skippingCache));
        }
예제 #4
0
        public bool Import(ThisEntity entity, ref SaveStatus status)
        {
            //do a get, and add to cache before updating
            if (entity.Id > 0)
            {
                //note could cause problems verifying after an import (i.e. shows cached version. Maybe remove from cache after completion.
                var detail = GetDetail(entity.Id);
            }
            bool          isValid  = new EntityMgr().Save(entity, ref status);
            List <string> messages = new List <string>();

            if (entity.Id > 0)
            {
                if (UtilityManager.GetAppKeyValue("delayingAllCacheUpdates", false) == false)
                {
                    //update cache
                    new CacheManager().PopulateEntityRelatedCaches(entity.RowId);
                    //update Elastic
                    if (Utilities.UtilityManager.GetAppKeyValue("usingElasticLearningOppSearch", false))
                    {
                        ElasticServices.LearningOpp_UpdateIndex(entity.Id);
                    }
                    else
                    {
                        new SearchPendingReindexManager().Add(7, entity.Id, 1, ref messages);
                        if (messages.Count > 0)
                        {
                            status.AddWarningRange(messages);
                        }
                    }
                }
                else
                {
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_LEARNING_OPP_PROFILE, entity.Id, 1, ref messages);
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, entity.OwningOrganizationId, 1, ref messages);
                    if (messages.Count > 0)
                    {
                        status.AddWarningRange(messages);
                    }
                }

                CacheManager.RemoveItemFromCache("lopp", entity.Id);
            }

            return(isValid);
        }
        public bool Import(ThisEntity entity, ref SaveStatus status)
        {
            LoggingHelper.DoTrace(7, thisClassName + ".Import - entered");
            //do a get, and add to cache before updating
            if (entity.Id > 0)
            {
                //note could cause problems verifying after an import (i.e. shows cached version. Maybe remove from cache after completion.
                if (UtilityManager.GetAppKeyValue("learningOppCacheMinutes", 0) > 0)
                {
                    if (System.DateTime.Now.Hour > 7 && System.DateTime.Now.Hour < 18)
                    {
                        GetDetail(entity.Id);
                    }
                }
            }
            bool          isValid  = new EntityMgr().Save(entity, ref status);
            List <string> messages = new List <string>();

            if (entity.Id > 0)
            {
                if (UtilityManager.GetAppKeyValue("learningOppCacheMinutes", 0) > 0)
                {
                    CacheManager.RemoveItemFromCache("lopp_", entity.Id);
                }

                if (UtilityManager.GetAppKeyValue("delayingAllCacheUpdates", false) == false)
                {
                    //update cache
                    ThreadPool.QueueUserWorkItem(UpdateCaches, entity);
                    //new CacheManager().PopulateEntityRelatedCaches( entity.RowId );
                    //add owning org to reindex queue
                }
                else
                {
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_LEARNING_OPP_PROFILE, entity.Id, 1, ref messages);
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, entity.OwningOrganizationId, 1, ref messages);
                    if (messages.Count > 0)
                    {
                        status.AddWarningRange(messages);
                    }
                }
            }

            return(isValid);
        }
예제 #6
0
        //public static List<CodeItem> SearchAsCodeItem( string keyword, int startingPageNbr, int pageSize, ref int totalRows )
        //{
        //	List<ThisEntity> list = Search( keyword, startingPageNbr, pageSize, ref totalRows );
        //	List<CodeItem> codes = new List<CodeItem>();
        //	foreach ( ThisEntity item in list )
        //	{
        //		codes.Add( new CodeItem()
        //		{
        //			Id = item.Id,
        //			Name = item.Name,
        //			Description = item.Description
        //		} );
        //	}
        //	return codes;
        //}
        public static List <object> Autocomplete(string keyword, int maxTerms = 25, int widgetId = 0)
        {
            string where = "";
            int totalRows = 0;

            string keywords = ServiceHelper.HandleApostrophes(keyword);

            if (keywords.IndexOf("%") == -1)
            {
                keywords = "%" + keywords.Trim() + "%";
            }
            where = string.Format(" (base.name like '{0}') ", keywords);

            if (UtilityManager.GetAppKeyValue("usingElasticLearningOppSearch", false))
            {
                return(ElasticServices.LearningOppAutoComplete(keyword, maxTerms, ref totalRows));
            }
            else
            {
                SetKeywordFilter(keyword, true, ref where);

                return(EntityMgr.Autocomplete(where, 1, maxTerms, ref totalRows));
            }
        }
예제 #7
0
        public static ThisEntity GetBasic(int id, bool forEditView = false)
        {
            ThisEntity entity = EntityMgr.GetBasic(id);

            return(entity);
        }
예제 #8
0
        //public static ThisEntity GetDetail( int id )
        //{
        //    ThisEntity entity = EntityMgr.GetForDetail( id );
        //    return entity;

        //}
        public static ThisEntity GetDetail(int id, bool skippingCache = false)
        {
            int      cacheMinutes = UtilityManager.GetAppKeyValue("learningOppCacheMinutes", 0);
            DateTime maxTime      = DateTime.Now.AddMinutes(cacheMinutes * -1);
            string   key          = "lopp_" + id.ToString();

            if (skippingCache == false &&
                HttpRuntime.Cache[key] != null && cacheMinutes > 0)
            {
                var cache = ( CachedLopp )HttpRuntime.Cache[key];
                try
                {
                    if (cache.lastUpdated > maxTime)
                    {
                        LoggingHelper.DoTrace(6, string.Format(thisClassName + ".GetDetail === Using cached version of Lopp, Id: {0}, {1}", cache.Item.Id, cache.Item.Name));

                        return(cache.Item);
                    }
                }
                catch (Exception ex)
                {
                    LoggingHelper.DoTrace(6, thisClassName + ".GetDetail === exception " + ex.Message);
                }
            }
            else
            {
                LoggingHelper.DoTrace(8, thisClassName + string.Format(".GetDetail === Retrieving full version of Lopp, Id: {0}", id));
            }

            DateTime start = DateTime.Now;

            ThisEntity entity = EntityMgr.GetForDetail(id);

            DateTime end     = DateTime.Now;
            int      elasped = (end - start).Seconds;

            //Cache the output if more than specific seconds,
            //NOTE need to be able to force it for imports
            //&& elasped > 2
            if (key.Length > 0 && cacheMinutes > 0)
            {
                var newCache = new CachedLopp()
                {
                    Item        = entity,
                    lastUpdated = DateTime.Now
                };
                if (HttpContext.Current != null)
                {
                    if (HttpContext.Current.Cache[key] != null)
                    {
                        HttpRuntime.Cache.Remove(key);
                        HttpRuntime.Cache.Insert(key, newCache);

                        LoggingHelper.DoTrace(5, string.Format("==={0}.GetDetail $$$ Updating cached version of Lopp, Id: {1}, {2}", thisClassName, entity.Id, entity.Name));
                    }
                    else
                    {
                        LoggingHelper.DoTrace(5, string.Format("==={0}.GetDetail ****** Inserting new cached version of Lopp, Id: {1}, {2}", thisClassName, entity.Id, entity.Name));

                        System.Web.HttpRuntime.Cache.Insert(key, newCache, null, DateTime.Now.AddMinutes(cacheMinutes), TimeSpan.Zero);
                    }
                }
            }
            else
            {
                LoggingHelper.DoTrace(7, string.Format("==={0}.GetDetail $$$$$$ skipping caching of Lopp, Id: {1}, {2}, elasped:{3}", thisClassName, entity.Id, entity.Name, elasped));
            }

            return(entity);
        }