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); }
public bool Import(ThisEntity entity, ref SaveStatus status) { bool isValid = new EntityMgr().Save(entity, null, ref status); List <string> messages = new List <string>(); if (entity.Id > 0) { if (UtilityManager.GetAppKeyValue("delayingAllCacheUpdates", false) == false) { //update cache - not applicable yet //update Elastic if (Utilities.UtilityManager.GetAppKeyValue("updatingElasticIndexImmediately", false)) { //ElasticHelper.DataSetProfileProfile_UpdateIndex( entity.Id ); } else { new SearchPendingReindexManager().Add(classEntityTypeId, entity.Id, 1, ref messages); if (messages.Count > 0) { status.AddWarningRange(messages); } } //also update related org //???????????? if (entity.DataProvider != null && entity.DataProvider.Id > 0) { new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, entity.DataProvider.Id, 1, ref messages); } } else { new SearchPendingReindexManager().Add(classEntityTypeId, entity.Id, 1, ref messages); if (entity.DataProvider != null && entity.DataProvider.Id > 0) { new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ORGANIZATION, entity.DataProvider.Id, 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) { 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); }
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) { //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); }
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 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("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("asmt", entity.Id); } if (UtilityManager.GetAppKeyValue("delayingAllCacheUpdates", false) == false) { //update cache ThreadPool.QueueUserWorkItem(UpdateCaches, entity); //new CacheManager().PopulateEntityRelatedCaches( entity.RowId ); //update Elastic - this if makes no sense, it is either update elastic immediate or add to pending //if ( UtilityManager.GetAppKeyValue( "updatingElasticIndexImmediately", false ) ) // ElasticHelper.Assessment_UpdateIndex( entity.Id ); //else //{ // new SearchPendingReindexManager().Add( 3, entity.Id, 1, ref messages ); // if ( messages.Count > 0 ) // status.AddWarningRange( messages ); //} } else { new SearchPendingReindexManager().Add(CodesManager.ENTITY_TYPE_ASSESSMENT_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); }
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); }
/// <summary> /// Attempt to resolve an organization reference by either a registry URI or CTID /// </summary> /// <param name="referencedAtId">Registry URI or CTID</param> /// <param name="status"></param> /// <param name="isResolved"></param> /// <returns></returns> public static Guid ResolveOrgByRegistryAtId(string referencedAtId, ref SaveStatus status, ref bool isResolved) { Guid entityUid = new Guid(); string ctid = ""; List <string> messages = new List <string>(); //test direct, and fall back to by ctid?? //should only handle Uri's for now if (referencedAtId.Trim().ToLower().IndexOf("http") == 0) { //should probably ensure a registry url ctid = ExtractCtid(referencedAtId.Trim()); EM.Import_EntityResolution item = ImportManager.Import_EntityResolution_GetById(referencedAtId); if (item != null && item.Id > 0) { isResolved = item.IsResolved != null ? ( bool )item.IsResolved : false; //need to make sure valid //actually should always be valid //if ( BaseFactory.IsGuidValid( item.EntityUid ) ) return(( Guid )item.EntityUid); //add activity or error //return entityUid; } else { if (IsCtidValid(ctid, ref messages)) { item = ImportManager.Import_EntityResolution_GetByCtid(ctid); if (item != null && item.Id > 0) { isResolved = item.IsResolved != null ? ( bool )item.IsResolved : false; return(( Guid )item.EntityUid); } } } } else { ctid = ExtractCtid(referencedAtId.Trim()); if (IsCtidValid(ctid, ref messages)) { EM.Import_EntityResolution item2 = ImportManager.Import_EntityResolution_GetByCtid(ctid); if (item2 != null && item2.Id > 0) { isResolved = item2.IsResolved != null ? ( bool )item2.IsResolved : false; return(( Guid )item2.EntityUid); } } } //add an import entry ImportManager importManager = new ImportManager(); entityUid = Guid.NewGuid(); string statusMsg = ""; int orgId = new OrganizationManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (orgId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } else { int id = importManager.Import_EntityResolutionAdd(referencedAtId, ctid, CodesManager.ENTITY_TYPE_ORGANIZATION, entityUid, orgId, false, ref messages); //need to create a placeholder if (id == 0) { status.AddError("Error - failed to add Import_EntityResolution for " + referencedAtId); status.AddWarningRange(messages); return(new Guid()); } } return(entityUid); }
public static int ResolveEntityByRegistryAtId(string referencedAtId, int entityTypeId, ref SaveStatus status, ref bool isResolved) { Guid entityUid = Guid.NewGuid(); int newEntityId = 0; string ctid = ""; List <string> messages = new List <string>(); //test direct, and fall back to by ctid?? //should only handle Uri's for now if (referencedAtId.Trim().ToLower().IndexOf("http") == 0) { //should probably ensure a registry url ctid = ExtractCtid(referencedAtId.Trim()); LoggingHelper.DoTrace(7, string.Format("ResolutionServices.ResolveEntityByRegistryAtId: EntityTypeId: {0}, referencedAtId: {1} ", entityTypeId, referencedAtId)); EM.Import_EntityResolution item = ImportManager.Import_EntityResolution_GetById(referencedAtId); if (item != null && item.Id > 0 && (item.EntityBaseId ?? 0) > 0) { isResolved = item.IsResolved != null ? ( bool )item.IsResolved : false; //need to make sure valid //actually should always be valid //if ( BaseFactory.IsGuidValid( item.EntityUid ) ) return((int)item.EntityBaseId); } else { LoggingHelper.DoTrace(6, string.Format("ResolutionServices. **FAILED** ResolveEntityByRegistryAtId: EntityTypeId: {0}, target.CtdlId: {1}. Trying with CTID: {2}", entityTypeId, referencedAtId, ctid)); if (IsCtidValid(ctid, ref messages)) { item = ImportManager.Import_EntityResolution_GetByCtid(ctid); if (item != null && item.Id > 0 && (item.EntityBaseId ?? 0) > 0) { isResolved = item.IsResolved != null ? ( bool )item.IsResolved : false; return(( int )item.EntityBaseId); } } } } else { ctid = ExtractCtid(referencedAtId.Trim()); LoggingHelper.DoTrace(7, string.Format("ResolutionServices.ResolveEntityByRegistryAtId. referencedAtId appears to be a ctid EntityTypeId: {0}, referencedAtId: {1}, ctid: {2} ", entityTypeId, referencedAtId, ctid)); if (IsCtidValid(ctid, ref messages)) { EM.Import_EntityResolution item2 = ImportManager.Import_EntityResolution_GetByCtid(ctid); if (item2 != null && item2.Id > 0 && (item2.EntityBaseId ?? 0) > 0) { isResolved = item2.IsResolved != null ? ( bool )item2.IsResolved : false; return(( int )item2.EntityBaseId); } else { LoggingHelper.DoTrace(5, string.Format("ResolutionServices.ResolveEntityByRegistryAtId. DID NOT RESOLVE VIA CTID referencedAtId appears to be a ctid EntityTypeId: {0}, ctid: {2} ", entityTypeId, referencedAtId, ctid)); } } } //add an import entry - need to do the base first ImportManager importManager = new ImportManager(); string statusMsg = ""; if (entityTypeId == CodesManager.ENTITY_TYPE_CREDENTIAL) { newEntityId = new CredentialManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_ASSESSMENT_PROFILE) { newEntityId = new AssessmentManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_LEARNING_OPP_PROFILE) { newEntityId = new LearningOpportunityManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_COST_MANIFEST) { newEntityId = new CostManifestManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_CONDITION_MANIFEST) { newEntityId = new ConditionManifestManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_PATHWAY) { newEntityId = new PathwayManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_PATHWAY_COMPONENT) { newEntityId = new PathwayComponentManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_COMPETENCY_FRAMEWORK) { //actually should not happen - confirm the cf must exist or will be rejected by API newEntityId = new CompetencyFrameworkManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_TRANSFER_VALUE_PROFILE) { //actually should not happen - confirm the tvp must exist or will be rejected by API newEntityId = new TransferValueProfileManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } // if (newEntityId > 0) { int id = importManager.Import_EntityResolutionAdd(referencedAtId, ctid, entityTypeId, entityUid, newEntityId, false, ref messages, true); //need to create a placeholder if (id == 0) { status.AddError("Error - failed to add Import_EntityResolution for " + referencedAtId); status.AddWarningRange(messages); //this may be wiping out newEntityId //return 0; } } return(newEntityId); }
public static Guid ResolveEntityByRegistryAtIdToGuid(string property, string referencedAtId, int entityTypeId, ref SaveStatus status, ref bool isResolved) { Guid entityUid = new Guid(); string ctid = ""; int newEntityId = 0; if (string.IsNullOrWhiteSpace(referencedAtId)) { return(entityUid); } List <string> messages = new List <string>(); //test direct, and fall back to by ctid?? //should only handle Uri's for now if (referencedAtId.Trim().ToLower().IndexOf("http") == 0) { //should probably ensure a registry url ctid = ExtractCtid(referencedAtId.Trim()); if (ctid == "ce-fa6c139f-0615-401f-9920-6ec8c445baca") { } EM.Import_EntityResolution item = ImportManager.Import_EntityResolution_GetById(referencedAtId); if (item != null && item.Id > 0) { isResolved = item.IsResolved != null ? ( bool )item.IsResolved : false; //need to make sure valid //actually should always be valid //if ( BaseFactory.IsGuidValid( item.EntityUid ) ) //20-07-30 mparsons - why is EntityUid returned here? //check this return(( Guid )item.EntityUid); } else { if (IsCtidValid(ctid, ref messages)) { item = ImportManager.Import_EntityResolution_GetByCtid(ctid); if (item != null && item.Id > 0) { isResolved = item.IsResolved != null ? ( bool )item.IsResolved : false; return(( Guid )item.EntityUid); } } } } else { ctid = ExtractCtid(referencedAtId.Trim()); if (IsCtidValid(ctid, ref messages)) { EM.Import_EntityResolution item2 = ImportManager.Import_EntityResolution_GetByCtid(ctid); if (item2 != null && item2.Id > 0) { isResolved = item2.IsResolved != null ? ( bool )item2.IsResolved : false; return(( Guid )item2.EntityUid); } } } //add an import entry ImportManager importManager = new ImportManager(); entityUid = Guid.NewGuid(); string statusMsg = ""; if (entityTypeId == CodesManager.ENTITY_TYPE_CREDENTIAL) { newEntityId = new CredentialManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError("Credential Add Pending failed for: " + property + ". " + statusMsg); entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_ASSESSMENT_PROFILE) { newEntityId = new AssessmentManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError("Assessment Add Pending failed for: " + property + ". " + statusMsg); entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_LEARNING_OPP_PROFILE) { newEntityId = new LearningOpportunityManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError("Learning Opportunity Add Pending failed for: " + property + ". " + statusMsg); entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_COST_MANIFEST) { //should know the parent org, add to this method newEntityId = new CostManifestManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError("CostManifest Add Pending failed for: " + property + ". " + statusMsg); entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_CONDITION_MANIFEST) { newEntityId = new ConditionManifestManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError("ConditionManifest Add Pending failed for: " + property + ". " + statusMsg); entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_TRANSFER_VALUE_PROFILE) { //not sure we will ever have a reference to a TVP? newEntityId = new TransferValueProfileManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError("TransferValue Add Pending failed for: " + property + ". " + statusMsg); entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_PATHWAY) { newEntityId = new PathwayManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError("Pathway Add Pending failed for: " + property + ". " + statusMsg); entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_PATHWAY_COMPONENT) { if (ctid == "ce-fa6c139f-0615-401f-9920-6ec8c445baca") { } //need pathwayCTID for this ce-abcb5fe0-8fde-4f06-9d70-860cd5bdc763 newEntityId = new PathwayComponentManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else { //for properties like organization.Offers, we don't know what the entity type is. //SO..... } if (BaseFactory.IsGuidValid(entityUid)) { int id = importManager.Import_EntityResolutionAdd(referencedAtId, ctid, entityTypeId, entityUid, newEntityId, false, ref messages); //need to create a placeholder if (id == 0) { status.AddError("Error - failed to add Import_EntityResolution for " + referencedAtId); status.AddWarningRange(messages); //return 0; } } return(entityUid); }
public static Guid ResolveEntityByRegistryAtIdToGuid(string referencedAtId, int entityTypeId, ref SaveStatus status, ref bool isResolved) { Guid entityUid = new Guid(); string ctid = ""; int newEntityId = 0; if (string.IsNullOrWhiteSpace(referencedAtId)) { return(entityUid); } List <string> messages = new List <string>(); //test direct, and fall back to by ctid?? //should only handle Uri's for now if (referencedAtId.Trim().ToLower().IndexOf("http") == 0) { //should probably ensure a registry url ctid = ExtractCtid(referencedAtId.Trim()); EM.Import_EntityResolution item = ImportManager.Import_EntityResolution_GetById(referencedAtId); if (item != null && item.Id > 0) { isResolved = item.IsResolved != null ? ( bool )item.IsResolved : false; //need to make sure valid //actually should always be valid //if ( BaseFactory.IsGuidValid( item.EntityUid ) ) return(( Guid )item.EntityUid); //add activity or error //return entityUid; } else { if (IsCtidValid(ctid, ref messages)) { item = ImportManager.Import_EntityResolution_GetByCtid(ctid); if (item != null && item.Id > 0) { isResolved = item.IsResolved != null ? ( bool )item.IsResolved : false; return(( Guid )item.EntityUid); } } } } else { ctid = ExtractCtid(referencedAtId.Trim()); if (IsCtidValid(ctid, ref messages)) { EM.Import_EntityResolution item2 = ImportManager.Import_EntityResolution_GetByCtid(ctid); if (item2 != null && item2.Id > 0) { isResolved = item2.IsResolved != null ? ( bool )item2.IsResolved : false; return(( Guid )item2.EntityUid); } } } //add an import entry ImportManager importManager = new ImportManager(); entityUid = Guid.NewGuid(); string statusMsg = ""; if (entityTypeId == CodesManager.ENTITY_TYPE_CREDENTIAL) { newEntityId = new CredentialManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_ASSESSMENT_PROFILE) { newEntityId = new AssessmentManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_LEARNING_OPP_PROFILE) { newEntityId = new LearningOpportunityManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_COST_MANIFEST) { //should know the parent org, add to this method newEntityId = new CostManifestManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else if (entityTypeId == CodesManager.ENTITY_TYPE_CONDITION_MANIFEST) { newEntityId = new ConditionManifestManager().AddPendingRecord(entityUid, ctid, referencedAtId, ref statusMsg); if (newEntityId == 0) { //need to log, and reset status.AddError(statusMsg); //need to know what property would need to be fixed - really shouldn't happen entityUid = new Guid(); } } else { //for properties like organization.Offers, we don't know what the entity type is. //SO..... } if (BaseFactory.IsGuidValid(entityUid)) { int id = importManager.Import_EntityResolutionAdd(referencedAtId, ctid, entityTypeId, entityUid, newEntityId, false, ref messages); //need to create a placeholder if (id == 0) { status.AddError("Error - failed to add Import_EntityResolution for " + referencedAtId); status.AddWarningRange(messages); //return 0; } } return(entityUid); }