コード例 #1
0
        public bool Import(ThisEntity entity, ref SaveStatus status)
        {
            //do a get, and add to cache before updating
            if (entity.Id > 0)
            {
                //no need to get and cache if called from batch import - maybe during day, but likelihood of issues is small?
                if (UtilityManager.GetAppKeyValue("credentialCacheMinutes", 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("credentialCacheMinutes", 0) > 0)
                {
                    CacheManager.RemoveItemFromCache("credential", entity.Id);
                }

                if (UtilityManager.GetAppKeyValue("delayingAllCacheUpdates", false) == false)
                {
                    ThreadPool.QueueUserWorkItem(UpdateCaches, entity);

                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, entity.OwningOrganizationId, 1, ref messages);
                    if (messages.Count > 0)
                    {
                        status.AddWarningRange(messages);
                    }
                }
                else
                {
                    //only update elatic if has apparent relevent changes
                    if (status.UpdateElasticIndex)
                    {
                        new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_CREDENTIAL, entity.Id, 1, ref messages);
                    }
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, entity.OwningOrganizationId, 1, ref messages);
                    //check for embedded items
                    //has part
                    AddCredentialsToPendingReindex(entity.HasPartIds);
                    AddCredentialsToPendingReindex(entity.IsPartOfIds);

                    if (messages.Count > 0)
                    {
                        status.AddWarningRange(messages);
                    }
                }
            }

            return(isValid);
        }
コード例 #2
0
        public static ThisEntity GetMinimumByCtid(string ctid)
        {
            ThisEntity entity = new ThisEntity();

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

            return(EntityMgr.GetMinimumByCtid(ctid));
        }
コード例 #3
0
        public static WMA.CredentialDetail GetDetailByCtidForAPI(string ctid, bool skippingCache = false)
        {
            var credential = EntityMgr.GetMinimumByCtid(ctid);

            return(GetDetailForAPI(credential.Id, skippingCache));
            //CredentialRequest cr = new CredentialRequest();
            //cr.IsDetailRequest();
            //cr.IncludingProcessProfiles = false;
            //var entity = EntityHelper.GetDetail( credential.Id, skippingCache );

            //return MapToAPI( entity );
        }
コード例 #4
0
        public static ThisEntity GetDetailByCtid(string ctid, bool skippingCache = false)
        {
            ThisEntity entity = new ThisEntity();

            if (string.IsNullOrWhiteSpace(ctid))
            {
                return(entity);
            }
            var credential = EntityMgr.GetMinimumByCtid(ctid);

            return(GetDetail(credential.Id, skippingCache));
        }
コード例 #5
0
        public bool Import(ThisEntity entity, ref SaveStatus status)
        {
            //do a get, and add to cache before updating
            if (entity.Id > 0)
            {
                var detail = GetDetail(entity.Id, false);
            }
            bool          isValid  = new EntityMgr().Save(entity, ref status);
            List <string> messages = new List <string>();

            if (entity.Id > 0)
            {
                CacheManager.RemoveItemFromCache("credential", entity.Id);

                if (UtilityManager.GetAppKeyValue("delayingAllCacheUpdates", false) == false)
                {
                    ThreadPool.QueueUserWorkItem(UpdateCaches2, entity);
                    new SearchPendingReindexManager().Add(1, entity.Id, 1, ref messages);
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, entity.OwningOrganizationId, 1, ref messages);
                    if (messages.Count > 0)
                    {
                        status.AddWarningRange(messages);
                    }
                }
                else
                {
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_CREDENTIAL, entity.Id, 1, ref messages);
                    new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, entity.OwningOrganizationId, 1, ref messages);
                    //check for embedded items
                    //has part
                    AddCredentialsToPendingReindex(entity.HasPartIds);
                    AddCredentialsToPendingReindex(entity.IsPartOfIds);

                    if (messages.Count > 0)
                    {
                        status.AddWarningRange(messages);
                    }
                }
            }

            return(isValid);
        }
コード例 #6
0
        /// <summary>
        /// Full credentials search
        /// </summary>
        /// <param name="data"></param>
        /// <param name="pTotalRows"></param>
        /// <returns></returns>
        public static List <ThisSearchEntity> DoSearch(MainSearchInput data, ref int pTotalRows)
        {
            string where = "";
            DateTime start = DateTime.Now;

            //Stopwatch stopwatch = new Stopwatch();
            //stopwatch.Start();
            LoggingHelper.DoTrace(6, string.Format("===CredentialServices.Search === Started: {0}", start));
            int           userId       = 0;
            List <string> competencies = new List <string>();

            AppUser user = AccountServices.GetCurrentUser();

            if (user != null && user.Id > 0)
            {
                userId = user.Id;
            }
            //only target full entities
            where = " ( base.EntityStateId = 3 ) ";

            SetKeywordFilter(data.Keywords, false, ref where);
            where = where.Replace("[USERID]", user.Id.ToString());

            SearchServices.SetSubjectsFilter(data, CodesManager.ENTITY_TYPE_CREDENTIAL, ref where);

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

            //Should probably move this to its own method?
            string agentRoleTemplate = " ( id in (SELECT [CredentialId] FROM [dbo].[CredentialAgentRelationships_Summary] where RelationshipTypeId = {0} and OrgId = {1})) ";
            int    roleId            = 0;
            int    orgId             = 0;
            string AND = "";

            if (where.Length > 0)
            {
                AND = " AND ";
            }

            //Updated to use FilterV2
            foreach (var filter in data.FiltersV2.Where(m => m.Name == "qualityAssuranceBy").ToList())
            {
                roleId = filter.GetValueOrDefault("RoleId", 0);
                orgId  = filter.GetValueOrDefault("AgentId", 0);
                where  = where + AND + string.Format(agentRoleTemplate, roleId, orgId);
                AND    = " AND ";
            }

            /* //Retained for reference
             * foreach ( MainSearchFilter filter in data.Filters.Where( s => s.Name == "qualityAssuranceBy" ) )
             * {
             *      if ( filter.Data.ContainsKey( "RoleId" ) )
             *              roleId = (int)filter.Data[ "RoleId" ];
             *      if ( filter.Data.ContainsKey( "AgentId" ) )
             *              orgId = ( int ) filter.Data[ "AgentId" ];
             *      where = where + AND + string.Format( agentRoleTemplate, roleId, orgId );
             * }
             */

            SetPropertiesFilter(data, ref where);

            SearchServices.SetRolesFilter(data, ref where);
            SearchServices.SetBoundariesFilter(data, ref where);
            //need to fix rowId

            //naics, ONET
            SetFrameworksFilter(data, ref where);
            //Competencies
            SetCompetenciesFilter(data, ref where, ref competencies);
            SetCredCategoryFilter(data, ref where);               //Not updated for FiltersV2 - I don't think we're using this anymore - NA 5/11/2017
            SetConnectionsFilter(data, ref where);

            TimeSpan timeDifference = start.Subtract(DateTime.Now);

            LoggingHelper.DoTrace(5, thisClassName + string.Format(".Search(). Filter: {0}, elapsed: {1} ", where, timeDifference.TotalSeconds));

            List <ThisSearchEntity> list = EntityMgr.Search(where, data.SortOrder, data.StartPage, data.PageSize, ref pTotalRows);

            //stopwatch.Stop();
            timeDifference = start.Subtract(DateTime.Now);
            LoggingHelper.DoTrace(6, string.Format("===CredentialServices.Search === Ended: {0}, Elapsed: {1}, Filter: {2}", DateTime.Now, timeDifference.TotalSeconds, where));
            return(list);
        }