}               //

        /// <summary>
        /// May be workaround, may be permanent, getting combined
        /// </summary>
        /// <param name="parentUid"></param>
        /// <param name="alignmentType"></param>
        /// <returns></returns>
        //public static List<CredentialAlignmentObjectProfile> GetAllAs_CredentialAlignmentObjectProfile( Guid parentUid, ref Dictionary<string, RegistryImport> frameworksList)
        //{
        //	CredentialAlignmentObjectProfile entity = new CredentialAlignmentObjectProfile();
        //	List<CredentialAlignmentObjectProfile> list = new List<CredentialAlignmentObjectProfile>();
        //          //var frameworksList = new Dictionary<string, RegistryImport>();
        //          string prevFramework = "";
        //	Entity parent = EntityManager.GetEntity( parentUid );
        //	if ( parent == null || parent.Id == 0 )
        //	{
        //		return list;
        //	}
        //	try
        //	{
        //		using ( var context = new ViewContext() )
        //		{
        //			/*
        //			List<DBEntity> results = context.Entity_Competency
        //					.Where( s => s.EntityId == parent.Id
        //					)
        //					.OrderBy( s => s.EducationFramework )
        //					.ThenBy( s => s.TargetNodeName )
        //					.ToList();
        //			if ( results != null && results.Count > 0 )
        //			{
        //				foreach ( DBEntity item in results )
        //				{
        //					entity = new CredentialAlignmentObjectProfile();
        //					MapFromDB( item, entity );
        //					list.Add( entity );
        //				}
        //			}
        //			*/
        //			List<Views.EntityCompetencyFramework_Items_Summary> results = context.EntityCompetencyFramework_Items_Summary
        //					.Where( s => s.EntityId == parent.Id
        //					)
        //					.OrderBy( s => s.FrameworkName )
        //					.ThenBy( s => s.Competency )
        //					.ToList();
        //			if ( results != null && results.Count > 0 )
        //			{
        //				foreach ( var item in results )
        //				{
        //					entity = new CredentialAlignmentObjectProfile();
        //					MapFromDB( item, entity );
        //                          if ( prevFramework != entity.FrameworkName )
        //                          {
        //                              if ( !string.IsNullOrWhiteSpace(entity.FrameworkCtid) )
        //                              {
        //                                  //var fw = new Dictionary<string, RegistryImport>();
        //                                  RegistryImport ri = ImportManager.GetByCtid(entity.FrameworkCtid);
        //                                  if ( frameworksList.ContainsKey(entity.FrameworkName) == false )
        //                                      frameworksList.Add(entity.FrameworkName, ri);
        //                              }
        //                              prevFramework = entity.FrameworkName;
        //                          }

        //                          list.Add( entity );
        //				}
        //                  }
        //		}
        //	}
        //	catch ( Exception ex )
        //	{
        //		LoggingHelper.LogError( ex, thisClassName + ".GetAllAs_CredentialAlignmentObjectProfile" );
        //	}
        //	return list;
        //}//

        //public static void MapFromDB( Views.EntityCompetencyFramework_Items_Summary from, CredentialAlignmentObjectProfile to )
        //{
        //	to.Id = from.EntityCompetencyId;
        //	to.ParentId = from.EntityId;
        //          //to.EducationFrameworkId = from.EducationFrameworkId ?? 0;
        //          to.FrameworkName = from.FrameworkName;
        //          //add url?? to Entity for now?
        //          //don't populate if for registry
        //          //18-06-28 mparsons - aim to make FrameworkUrl obsolete!
        //          //                  - SourceUrl should be populated
        //          //if ( from.FrameworkUrl.ToLower().IndexOf("credentialengineregistry.org/resources/ce-") == -1 )
        //          //{
        //          //    to.FrameworkUrl = from.FrameworkUrl;
        //          //}
        //          //else if ( !string.IsNullOrWhiteSpace(from.SourceUrl) )
        //          //    to.FrameworkUrl = from.SourceUrl;
        //          //
        //          to.SourceUrl = from.SourceUrl;
        //          to.FrameworkUri = from.FrameworkUri;
        //          to.FrameworkCtid = from.FrameworkCtid;

        //          //
        //	to.TargetNode = from.TargetNode;
        //	to.TargetNodeDescription = from.TargetNodeDescription;
        //	to.TargetNodeName = from.Competency;
        //	to.Weight = ( from.Weight ?? 0M );
        //	to.CodedNotation = from.CodedNotation;

        //	if ( IsValidDate( from.Created ) )
        //		to.Created = ( DateTime ) from.Created;

        //}

        /// <summary>
        /// Need to fake this out, until enlightenment occurs
        /// </summary>
        /// <param name="parentUid"></param>
        /// <returns></returns>
        public static List <CredentialAlignmentObjectFrameworkProfile> GetAllAs_CAOFramework(Guid parentUid, ref Dictionary <string, RegistryImport> frameworksList)
        {
            CredentialAlignmentObjectFrameworkProfile        entity = new CredentialAlignmentObjectFrameworkProfile();
            List <CredentialAlignmentObjectFrameworkProfile> list   = new List <CredentialAlignmentObjectFrameworkProfile>();
            //var frameworksList = new Dictionary<string, RegistryImport>();
            string viewerUrl = UtilityManager.GetAppKeyValue("cassResourceViewerUrl");
            bool   hidingFrameworksNotPublished   = UtilityManager.GetAppKeyValue("hideFrameworksNotPublished", false);
            CredentialAlignmentObjectItem caoItem = new CredentialAlignmentObjectItem();
            Entity parent = EntityManager.GetEntity(parentUid);

            if (parent == null || parent.Id == 0)
            {
                return(list);
            }

            try
            {
                using (var context = new EntityContext())
                {
                    List <DBEntity> results = context.Entity_Competency
                                              .Where(s => s.EntityId == parent.Id
                                                     )
                                              .OrderBy(s => s.FrameworkName)
                                              .ThenBy(s => s.TargetNodeName)
                                              .ToList();
                    if (results != null && results.Count > 0)
                    {
                        string prevName = "";
                        foreach (DBEntity item in results)
                        {
                            if (prevName != item.FrameworkName)
                            {
                                if (!string.IsNullOrWhiteSpace(prevName))
                                {
                                    //actually try handling in detail page - not working

                                    if (!entity.IsARegistryFrameworkUrl ||
                                        !hidingFrameworksNotPublished ||
                                        (entity.IsARegistryFrameworkUrl && entity.ExistsInRegistry)
                                        )
                                    {
                                        if (!entity.IsDeleted)
                                        {
                                            list.Add(entity);
                                        }
                                    }
                                }

                                entity = new CredentialAlignmentObjectFrameworkProfile();
                                if (item.EducationFramework != null && item.EducationFramework.Id > 0)
                                {
                                    entity.FrameworkName = item.EducationFramework.FrameworkName;
                                    entity.FrameworkUri  = item.EducationFramework.FrameworkUri;
                                    entity.SourceUrl     = item.EducationFramework.SourceUrl;
                                    if (entity.IsARegistryFrameworkUrl &&
                                        (item.EducationFramework.ExistsInRegistry ?? false)
                                        )
                                    {
                                        entity.ExistsInRegistry = true;
                                        if (item.EducationFramework.EntityStateId == 0)
                                        {
                                            //need to skip - need more than this. A non-registry framework will not exist in registry
                                            entity.IsDeleted = true;
                                        }
                                    }

                                    //18-12-13 mp - can only use viewer, if a cer URL - although this may change for other sources
                                    if (!string.IsNullOrWhiteSpace(viewerUrl) && entity.IsARegistryFrameworkUrl)
                                    {
                                        entity.CaSSViewerUrl = string.Format(viewerUrl, UtilityManager.GenerateMD5String(entity.FrameworkUri));
                                    }
                                    //if ( item.FrameworkUrl.ToLower().IndexOf("credentialengineregistry.org/resources/ce-") == -1 )
                                    //    entity.SourceUrl = item.EducationFramework.SourceUrl;
                                    //else
                                    //    entity.SourceUrl = item.EducationFramework.SourceUrl ?? "";

                                    if (!string.IsNullOrWhiteSpace(item.EducationFramework.CTID))
                                    {
                                        entity.FrameworkPayload = ImportManager.GetByCtid(item.EducationFramework.CTID);
                                        if (!string.IsNullOrWhiteSpace(entity.FrameworkPayload.Payload) &&
                                            frameworksList.ContainsKey(entity.FrameworkName) == false)
                                        {
                                            frameworksList.Add(entity.FrameworkName, entity.FrameworkPayload);
                                        }
                                    }
                                }
                                else
                                {
                                    //this should not happen - should log this
                                    entity.FrameworkName = item.FrameworkName;
                                    entity.SourceUrl     = item.FrameworkUrl ?? "";
                                    //should we populate frameworkUri as well?
                                    entity.FrameworkUri = item.FrameworkUrl ?? "";
                                }


                                entity.ParentId = item.EducationFrameworkId ?? 0;
                                prevName        = item.FrameworkName;
                            }

                            caoItem = new CredentialAlignmentObjectItem();
                            MapFromDB(item, caoItem);
                            entity.Items.Add(caoItem);
                            entity.HasCompetencies = true;
                        }
                        //add last one
                        if (!string.IsNullOrWhiteSpace(prevName))
                        {
                            if (!entity.IsARegistryFrameworkUrl ||
                                !hidingFrameworksNotPublished ||
                                (entity.IsARegistryFrameworkUrl && entity.ExistsInRegistry)
                                )
                            {
                                if (!entity.IsDeleted)
                                {
                                    list.Add(entity);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, thisClassName + ".GetAllAs_CAOFramework");
            }
            return(list);
        }        //
예제 #2
0
        }               //

        /// <summary>
        /// May be workaround, may be permanent, getting combined
        /// </summary>
        /// <param name="parentUid"></param>
        /// <param name="alignmentType"></param>
        /// <returns></returns>
        public static List <CredentialAlignmentObjectProfile> GetAllAs_CredentialAlignmentObjectProfile(Guid parentUid, ref Dictionary <string, RegistryImport> frameworksList)
        {
            CredentialAlignmentObjectProfile        entity = new CredentialAlignmentObjectProfile();
            List <CredentialAlignmentObjectProfile> list   = new List <CredentialAlignmentObjectProfile>();
            //var frameworksList = new Dictionary<string, RegistryImport>();
            string prevFramework = "";
            Entity parent        = EntityManager.GetEntity(parentUid);

            if (parent == null || parent.Id == 0)
            {
                return(list);
            }
            try
            {
                using (var context = new ViewContext())
                {
                    /*
                     * List<DBEntity> results = context.Entity_Competency
                     *              .Where( s => s.EntityId == parent.Id
                     *              )
                     *              .OrderBy( s => s.CompetencyFramework )
                     *              .ThenBy( s => s.TargetNodeName )
                     *              .ToList();
                     * if ( results != null && results.Count > 0 )
                     * {
                     *      foreach ( DBEntity item in results )
                     *      {
                     *              entity = new CredentialAlignmentObjectProfile();
                     *              MapFromDB( item, entity );
                     *              list.Add( entity );
                     *      }
                     * }
                     */
                    List <Views.EntityCompetencyFramework_Items_Summary> results = context.EntityCompetencyFramework_Items_Summary
                                                                                   .Where(s => s.EntityId == parent.Id
                                                                                          )
                                                                                   .OrderBy(s => s.FrameworkName)
                                                                                   .ThenBy(s => s.Competency)
                                                                                   .ToList();
                    if (results != null && results.Count > 0)
                    {
                        foreach (var item in results)
                        {
                            entity = new CredentialAlignmentObjectProfile();
                            MapFromDB(item, entity);
                            if (prevFramework != entity.FrameworkName)
                            {
                                if (!string.IsNullOrWhiteSpace(entity.FrameworkCtid))
                                {
                                    //var fw = new Dictionary<string, RegistryImport>();
                                    RegistryImport ri = ImportManager.GetByCtid(entity.FrameworkCtid);
                                    if (frameworksList.ContainsKey(entity.FrameworkName) == false)
                                    {
                                        frameworksList.Add(entity.FrameworkName, ri);
                                    }
                                }
                                prevFramework = entity.FrameworkName;
                            }

                            list.Add(entity);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, thisClassName + ".GetAllAs_CredentialAlignmentObjectProfile");
            }
            return(list);
        }        //