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));
            }
        }
        /// <summary>
        /// Main search
        /// </summary>
        /// <param name="data"></param>
        /// <param name="pTotalRows"></param>
        /// <returns></returns>
        public static List <OrganizationSummary> DoSearch(MainSearchInput data, ref int pTotalRows)
        {
            string where = "";
            int userId = 0;

            AppUser user = AccountServices.GetCurrentUser();

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

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

            SetKeywordFilter(data.Keywords, true, ref where);

            //SetAuthorizationFilter( user, ref where );
            SearchServices.HandleCustomFilters(data, 59, ref where);

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

            SetBoundariesFilter(data, ref where);
            SetFrameworksFilter(data, ref where);

            SetOrgServicesFilter(data, ref where);

            //check for org category (credentially, or QA). Only valid if one item
            //SetOrgCategoryFilter( data, ref where ); //Not updated - I'm not sure we're still using this. - NA 5/12/2017

            LoggingHelper.DoTrace(5, thisClassName + ".Search(). Filter: " + where);
            return(EntityMgr.MainSearch(where, data.SortOrder, data.StartPage, data.PageSize, ref pTotalRows));
        }
        public static List <CM.Organization> MicroSearch(MicroSearchInputV2 query, int pageNumber, int pageSize, ref int pTotalRows)
        {
            string pOrderBy = "";
            string filter   = "";
            int    userId   = 0;
            string keywords = query.GetFilterValueString("Keywords");
            string orgMbrs  = query.GetFilterValueString("OrgFilters");

            //user is used to determine if can edit results
            AppUser user = new AppUser();

            user = AccountServices.GetCurrentUser();
            if (user != null && user.Id > 0)
            {
                userId = user.Id;
            }
            //this is an option on micro searches to only target orgs associated to the user
            //if ( orgMbrs == "myOrgs" )
            //    SetAuthorizationFilter( user, ref filter, true, true );
            //else
            //    SetAuthorizationFilter( user, ref filter, true, false );

            SetKeywordFilter(keywords, true, ref filter);

            return(Mgr.Search(filter, pOrderBy, pageNumber, pageSize, ref pTotalRows));
        }
Ejemplo n.º 4
0
        public static WMA.OrganizationDetail GetDetailByCtidForAPI(string ctid, bool skippingCache = false)
        {
            var request = new OrganizationManager.OrganizationRequest(2);
            var output  = EntityMgr.GetDetailForAPI(ctid, request);

            return(MapToAPI(output, request));
        }
        /// <summary>
        /// Get by CTID - will return pending records
        /// </summary>
        /// <param name="ctid"></param>
        /// <returns></returns>
        public static ThisEntity GetSummaryByCtid(string ctid)
        {
            ThisEntity entity = new ThisEntity();

            if (string.IsNullOrWhiteSpace(ctid))
            {
                return(entity);
            }
            return(EntityMgr.GetSummaryByCtid(ctid));
        }
        public static ThisEntity GetBySubjectWebpage(string swp)
        {
            ThisEntity entity = new ThisEntity();

            if (string.IsNullOrWhiteSpace(swp))
            {
                return(entity);
            }
            return(EntityMgr.GetBySubjectWebpage(swp));
        }
        public bool Import(ThisEntity entity, ref SaveStatus status)
        {
            //do a get, and add to cache before updating
            if (entity.Id > 0)
            {
                if (UtilityManager.GetAppKeyValue("organizationCacheMinutes", 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("organizationCacheMinutes", 0) > 0)
                {
                    CacheManager.RemoveItemFromCache("organization", entity.Id);
                }

                if (UtilityManager.GetAppKeyValue("delayingAllCacheUpdates", false) == false)
                {
                    //update cache
                    ThreadPool.QueueUserWorkItem(UpdateCaches, entity);
                }
                else
                {
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, entity.Id, 1, ref messages);
                    //add all credential in a verification profile
                    if (entity.VerificationServiceProfiles != null && entity.VerificationServiceProfiles.Count > 0)
                    {
                        foreach (var profile in entity.VerificationServiceProfiles)
                        {
                            if (profile.TargetCredential != null &&
                                profile.TargetCredential.Count > 0)
                            {
                                new CredentialServices().AddCredentialsToPendingReindex(profile.TargetCredential);
                            }
                        }
                    }
                    //20-11-20 mp re: QA performed
                    //				- may have to reindex all orgs etc that have QA performed by a QA org!!!
                    if (messages.Count > 0)
                    {
                        status.AddWarningRange(messages);
                    }
                }
            }

            return(isValid);
        }
        public static ThisEntity GetDetailByCtid(string ctid, bool skippingCache = false)
        {
            ThisEntity entity = new ThisEntity();

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

            return(GetDetail(organization.Id, skippingCache));
        }
        public static ThisEntity GetDetailByCtid(string ctid, bool skippingCache = false)
        {
            ThisEntity entity = new ThisEntity();

            if (string.IsNullOrWhiteSpace(ctid))
            {
                return(entity);
            }
            //21-03-06 mp - there is too much extra work doing this (would be OK if just the entity)
            var organization = EntityMgr.GetSummaryByCtid(ctid);

            return(GetDetail(organization.Id, skippingCache));
        }
Ejemplo n.º 10
0
        //called by the search
        public static WMA.OrganizationDetail GetDetailForAPI(int id, bool skippingCache = false)
        {
            //var output = EntityHelper.GetDetail( id, skippingCache );
            var request = new OrganizationManager.OrganizationRequest(2);

            if (UtilityManager.GetAppKeyValue("includeProcessProfileDetails", true))
            {
                request.IncludingProcessProfiles = true;
            }
            if (UtilityManager.GetAppKeyValue("includeManifestDetails", true))
            {
                request.IncludingManifests = true;
            }

            var output = EntityMgr.GetDetailForAPI(id, request);

            return(MapToAPI(output, request));
        }
        public static CM.Organization GetDetail(int id, bool skippingCache = false)
        {
            int      cacheMinutes = UtilityManager.GetAppKeyValue("organizationCacheMinutes", 0);
            DateTime maxTime      = DateTime.Now.AddMinutes(cacheMinutes * -1);

            string key = "organization_" + id.ToString();

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

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

            DateTime start = DateTime.Now;

            CM.Organization entity = Mgr.GetDetail(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)
            {
                try
                {
                    var newCache = new CachedOrganization()
                    {
                        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("===OrganizationServices.GetDetail $$$ Updating cached version of Organization, Id: {0}, {1}", entity.Id, entity.Name));
                        }
                        else
                        {
                            LoggingHelper.DoTrace(5, string.Format("===OrganizationServices.GetDetail ****** Inserting new cached version of Organization, Id: {0}, {1}", entity.Id, entity.Name));

                            System.Web.HttpRuntime.Cache.Insert(key, newCache, null, DateTime.Now.AddMinutes(cacheMinutes), TimeSpan.Zero);
                        }
                    }
                }
                catch (Exception ex)
                {
                    LoggingHelper.DoTrace(6, thisClassName + ".GetDetail. Updating OrganizationCache === exception " + ex.Message);
                }
            }
            else
            {
                LoggingHelper.DoTrace(7, string.Format("===OrganizationServices.GetDetail $$$$$$ skipping caching of Organization, Id: {0}, {1}, elasped:{2}", entity.Id, entity.Name, elasped));
            }

            return(entity);
        }
 public static CM.Organization GetForSummaryWithRoles(int id)
 {
     return(Mgr.GetForSummary(id, true));
 }
 public static CM.Organization GetBasic(int id)
 {
     CM.Organization entity = Mgr.GetForSummary(id);
     return(entity);
 }