public static List <object> Autocomplete(string keyword = "", int maxTerms = 25, int widgetId = 0)
        {
            int userId = 0;

            string where = "";
            int     totalRows = 0;
            AppUser user      = AccountServices.GetCurrentUser();

            if (user != null && user.Id > 0)
            {
                userId = user.Id;
            }
            //SetAuthorizationFilter( user, ref where );


            if (UtilityManager.GetAppKeyValue("usingElasticOrganizationSearch", false))
            {
                return(ElasticHelper.OrganizationAutoComplete(keyword, maxTerms, ref totalRows));
            }
            else
            {
                SetKeywordFilter(keyword, true, ref where);
                //string keywords = ServiceHelper.HandleApostrophes( keyword );
                //if ( keywords.IndexOf( "%" ) == -1 )
                //	keywords = "%" + keywords.Trim() + "%";
                //where = string.Format( " (base.name like '{0}') ", keywords );

                return(EntityMgr.Autocomplete(where, 1, maxTerms, userId, ref totalRows));
            }
        }
Exemple #2
0
 public static List <CommonSearchSummary> Search(MainSearchInput data, ref int pTotalRows)
 {
     if (UtilityManager.GetAppKeyValue("usingElasticTransferValueSearch", false))
     {
         //var results = ElasticHelper.GeneralSearch( CodesManager.ENTITY_TYPE_TRANSFER_VALUE_PROFILE, data, ref pTotalRows );
         return(ElasticHelper.GeneralSearch(CodesManager.ENTITY_TYPE_TRANSFER_VALUE_PROFILE, "TransferValue", data, ref pTotalRows));
     }
     else
     {
         List <CommonSearchSummary> results = new List <CommonSearchSummary>();
         var list = DoSearch(data, ref pTotalRows);
         foreach (var item in list)
         {
             results.Add(new CommonSearchSummary()
             {
                 Id                      = item.Id,
                 Name                    = item.Name,
                 Description             = item.Description,
                 SubjectWebpage          = item.SubjectWebpage,
                 PrimaryOrganizationName = item.PrimaryOrganizationName,
                 CTID                    = item.CTID,
                 EntityTypeId            = CodesManager.ENTITY_TYPE_TRANSFER_VALUE_PROFILE,
                 EntityType              = "TransferValueProfile"
             });
         }
         return(results);
     }
 }        //
        //	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)
        {
            string where = "";
            int totalRows = 0;

            //SetKeywordFilter( keyword, true, ref where );
            string keywords = ServiceHelper.HandleApostrophes(keyword);

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


            if (UtilityManager.GetAppKeyValue("usingElasticAssessmentSearch", false))
            {
                return(ElasticHelper.AssessmentAutoComplete(keyword, maxTerms, ref totalRows));
            }
            else
            {
                SetKeywordFilter(keyword, true, ref where);
                return(EntityMgr.Autocomplete(where, 1, maxTerms, ref totalRows));
            }
        }
        }        //

        public static List <CommonSearchSummary> PathwaySetSearch2(MainSearchInput data, ref int pTotalRows)
        {
            if (UtilityManager.GetAppKeyValue("usingElasticPathwaySetSearch", false))
            {
                return(ElasticHelper.PathwaySetSearch(data, ref pTotalRows));
            }
            else
            {
                List <CommonSearchSummary> results = new List <CommonSearchSummary>();
                var list = DoPathwaySetSearch(data, ref pTotalRows);
                foreach (var item in list)
                {
                    results.Add(new CommonSearchSummary()
                    {
                        Id                      = item.Id,
                        Name                    = item.Name,
                        Description             = item.Description,
                        SubjectWebpage          = item.SubjectWebpage,
                        PrimaryOrganizationName = item.PrimaryOrganizationName,
                        CTID                    = item.CTID,
                        EntityTypeId            = CodesManager.ENTITY_TYPE_PATHWAY_SET,
                        EntityType              = "PathwaySet"
                    });
                }
                return(results);
            }
        }        //
 public static List <OrganizationSummary> Search(MainSearchInput data, ref int pTotalRows)
 {
     if (UtilityManager.GetAppKeyValue("usingElasticOrganizationSearch", false))
     {
         return(ElasticHelper.OrganizationSearch(data, ref pTotalRows));
     }
     else
     {
         return(DoSearch(data, ref pTotalRows));
     }
 }
 /// <summary>
 /// Full credentials search
 /// </summary>
 /// <param name="data"></param>
 /// <param name="pTotalRows"></param>
 /// <returns></returns>
 public static List <ThisSearchEntity> Search(MainSearchInput data, ref int pTotalRows)
 {
     if (UtilityManager.GetAppKeyValue("usingElasticCredentialSearch", false) || data.Elastic)
     {
         return(ElasticHelper.Credential_Search(data, ref pTotalRows));
     }
     else
     {
         return(DoSearch(data, ref pTotalRows));
     }
 }
        //public static List<ThisEntity> Search( string keywords, int pageNumber, int pageSize, ref int totalRows )
        //{
        //	string pOrderBy = "";
        //	string filter = "";
        //	int userId = 0;
        //	AppUser user = AccountServices.GetCurrentUser();
        //	if ( user != null && user.Id > 0 )
        //		userId = user.Id;

        //	SetKeywordFilter( keywords, true, ref filter );
        //	//SetAuthorizationFilter( user, ref filter );

        //	return EntityMgr.Search( filter, pOrderBy, pageNumber, pageSize, ref totalRows );
        //}

        public static List <ThisEntity> Search(MainSearchInput data, ref int pTotalRows)
        {
            if (UtilityManager.GetAppKeyValue("usingElasticAssessmentSearch", false))
            {
                return(ElasticHelper.AssessmentSearch(data, ref pTotalRows));
            }
            else
            {
                return(DoSearch(data, ref pTotalRows));
            }
        }
Exemple #8
0
        public bool Import(ThisEntity entity, ref SaveStatus status)
        {
            LoggingHelper.DoTrace(5, thisClassName + "Import entered. " + entity.Name);
            //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 Manager().Save(entity, ref status, true);
            List <string> messages = new List <string>();

            if (entity.Id > 0)
            {
                if (UtilityManager.GetAppKeyValue("delayingAllCacheUpdates", false) == false)
                {
                    //update cache - not applicable yet
                    //new CacheManager().PopulateEntityRelatedCaches( entity.RowId );
                    //update Elastic
                    if (Utilities.UtilityManager.GetAppKeyValue("updatingElasticIndexImmediately", false))
                    {
                        ElasticHelper.CompetencyFramework_UpdateIndex(entity.Id);
                    }
                    else
                    {
                        new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_CONCEPT_SCHEME, entity.Id, 1, ref messages);
                        if (messages.Count > 0)
                        {
                            status.AddWarningRange(messages);
                        }
                    }
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, entity.OrganizationId, 1, ref messages);
                }
                else
                {
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_CONCEPT_SCHEME, entity.Id, 1, ref messages);
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, entity.OrganizationId, 1, ref messages);
                    if (messages.Count > 0)
                    {
                        status.AddWarningRange(messages);
                    }
                }
                //no caching needed yet
                //CacheManager.RemoveItemFromCache( "cframework", entity.Id );
            }

            return(isValid);
        }
        public bool Import(ThisEntity entity, ref SaveStatus status)
        {
            //do a get, and add to cache before updating
            if (entity.Id > 0)
            {
                //need to force caching here
                //var detail = GetDetail( entity.Id );
            }
            bool          isValid  = new EntityMgr().Save(entity, ref status);
            List <string> messages = new List <string>();

            if (entity.Id > 0)
            {
                HandleComponents(entity, ref status);

                CacheManager.RemoveItemFromCache("pathway", entity.Id);

                if (UtilityManager.GetAppKeyValue("delayingAllCacheUpdates", false) == false)
                {
                    //update cache
                    new CacheManager().PopulateEntityRelatedCaches(entity.RowId);
                    //update Elastic
                    if (UtilityManager.GetAppKeyValue("usingElasticPathwaySearch", false))
                    {
                        ElasticHelper.Pathway_UpdateIndex(entity.Id);
                    }
                    else
                    {
                        new SearchPendingReindexManager().Add(8, entity.Id, 1, ref messages);
                        if (messages.Count > 0)
                        {
                            status.AddWarningRange(messages);
                        }
                    }
                }
                else
                {
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_PATHWAY, 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);
        }
        /// <summary>
        /// Credential autocomplete
        /// Needs to check authorization level for credential
        /// </summary>
        /// <param name="keyword"></param>
        /// <param name="maxTerms"></param>
        /// <returns></returns>
        public static List <object> Autocomplete(string keywords, int maxTerms = 25)
        {
            int userId = 0;

            string where = " base.EntityStateId = 3 ";
            string  AND        = "";
            int     pTotalRows = 0;
            AppUser user       = AccountServices.GetCurrentUser();

            if (user != null && user.Id > 0)
            {
                userId = user.Id;
            }

            if (UtilityManager.GetAppKeyValue("usingElasticCredentialAutocomplete", false))
            {
                return(ElasticHelper.CredentialAutoComplete(keywords, maxTerms, ref pTotalRows));
            }
            else
            {
                bool usingLinqAutocomplete = true;
                if (usingLinqAutocomplete)
                {
                    return(CredentialManager.AutocompleteInternal(keywords, 1, maxTerms, ref pTotalRows));
                }
                else
                {
                    string text = " (base.name like '{0}'  OR base.AlternateName like '{0}' OR OwningOrganization like '{0}'  ) ";
                    //SetKeywordFilter( keywords, true, ref where );
                    keywords = ServiceHelper.HandleApostrophes(keywords);
                    if (keywords.IndexOf("%") == -1)
                    {
                        keywords = SearchServices.SearchifyWord(keywords);
                    }
                    if (where.Length > 0)
                    {
                        AND = " AND ";
                    }
                    where = where + AND + string.Format(" ( " + text + " ) ", keywords);

                    return(CredentialManager.AutocompleteDB(where, 1, maxTerms, ref pTotalRows));
                }
                // return new List<string>();
            }
        }
        static void UpdateCaches(Object entity)
        {
            if (entity.GetType() != typeof(Models.ProfileModels.LearningOpportunityProfile))
            {
                return;
            }
            var         document = (entity as Models.ProfileModels.LearningOpportunityProfile);
            EntityCache ec       = new EntityCache()
            {
                EntityTypeId   = 7,
                EntityType     = "LearningOpportunity",
                EntityStateId  = document.EntityStateId,
                EntityUid      = document.RowId,
                BaseId         = document.Id,
                Description    = document.Description,
                SubjectWebpage = document.SubjectWebpage,
                CTID           = document.CTID,
                Created        = document.Created,
                LastUpdated    = document.LastUpdated,
                //ImageUrl = document.ImageUrl,
                Name           = document.Name,
                OwningAgentUID = document.OwningAgentUid,
                OwningOrgId    = document.OrganizationId
            };

            var statusMessage = "";

            new EntityManager().EntityCacheSave(ec, ref statusMessage);


            new CacheManager().PopulateEntityRelatedCaches(document.RowId);
            //update Elastic
            List <string> messages = new List <string>();

            if (Utilities.UtilityManager.GetAppKeyValue("updatingElasticIndexImmediately", false))
            {
                ElasticHelper.LearningOpp_UpdateIndex(document.Id);
            }
            else
            {
                new SearchPendingReindexManager().Add(7, document.Id, 1, ref messages);
            }

            new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, document.OwningOrganizationId, 1, ref messages);
        }