/// <summary> /// Retrieve an resource from the registry by ctid and do import /// </summary> /// <param name="ctid"></param> /// <param name="status"></param> /// <returns></returns> public bool ImportByResourceId(string ctid, SaveStatus status) { //this is currently specific, assumes envelop contains a credential //can use the hack fo GetResourceType to determine the type, and then call the appropriate import method string statusMessage = ""; //EntityServices mgr = new EntityServices(); string ctdlType = ""; try { string payload = RegistryServices.GetResourceByCtid(ctid, ref ctdlType, ref statusMessage); if (!string.IsNullOrWhiteSpace(payload)) { input = JsonConvert.DeserializeObject <InputEntity>(payload.ToString()); //ctdlType = RegistryServices.GetResourceType( payload ); return(Import(input, "", status)); } else { return(false); } } catch (Exception ex) { LoggingHelper.LogError(ex, thisClassName + ".ImportByResourceId()"); status.AddError(ex.Message); if (ex.Message.IndexOf("Path '@context', line 1") > 0) { status.AddWarning("The referenced registry document is using an old schema. Please republish it with the latest schema!"); } return(false); } }
/// <summary> /// Retrieve an resource from the registry by ctid and do import /// </summary> /// <param name="ctid"></param> /// <param name="status"></param> /// <returns></returns> public bool ImportByResourceId(string ctid, SaveStatus status) { //this is currently specific, assumes envelop contains a credential //can use the hack fo GetResourceType to determine the type, and then call the appropriate import method string statusMessage = ""; EntityServices mgr = new EntityServices(); string ctdlType = ""; try { string payload = RegistryServices.GetResourceByCtid(ctid, ref ctdlType, ref statusMessage); if (!string.IsNullOrWhiteSpace(payload)) { input = JsonConvert.DeserializeObject <InputEntity>(payload.ToString()); //ctdlType = RegistryServices.GetResourceType( payload ); return(Import(input, "", status)); } else { return(false); } } catch (Exception ex) { LoggingHelper.LogError(ex, thisClassName + ".ImportByResourceId()"); return(false); } }
/// <summary> /// Retrieve a resource from the registry by ctid /// </summary> /// <param name="ctid"></param> /// <param name="statusMessage"></param> /// <returns></returns> public static int GetEntityTypeIdFromResource(string ctid) { string statusMessage = ""; string ctdlType = ""; string r = RegistryServices.GetResourceByCtid(ctid, ref ctdlType, ref statusMessage); switch (ctdlType.ToLower()) { case "credentialorganization": return(2); //break; case "qacredentialorganization": //what distinctions do we need for QA orgs? return(2); //break; case "organization": return(2); case "AssessmentProfile": return(3); //break; case "learningopportunityprofile": return(7); //break; case "conditionmanifest": return(19); //break; case "costmanifest": return(20); //break; default: //default to credential return(1); //break; } }