public void UpdateFramework(FrameworkInformation fi, FrameworkMetaDataResult frameworks, IEnumerable <AchievementRateProvider> achievementRates, AchievementRateNationalResult nationalAchievementRates)
        {
            var metaData = frameworks.Frameworks.FirstOrDefault(m =>
                                                                m.FworkCode == fi.Code &&
                                                                m.PwayCode == fi.PathwayCode &&
                                                                m.ProgType == fi.ProgType);

            if (metaData != null)
            {
                var achievementRate = achievementRates.Where(m =>
                                                             IsEqual(m.Ssa2Code, metaData.SectorSubjectAreaTier2))
                                      .Where(m => TestLevel(m.ApprenticeshipLevel, ApprenticeshipLevelMapper.MapToLevel(metaData.ProgType)))
                                      .ToList();

                var nationalAchievementRate = nationalAchievementRates.Rates.Where(m =>
                                                                                   IsEqual(m.Ssa2Code, metaData.SectorSubjectAreaTier2))
                                              .Where(m => TestLevel(m.ApprenticeshipLevel, ApprenticeshipLevelMapper.MapToLevel(metaData.ProgType)))
                                              .ToList();

                var rate = ExtractValues(achievementRate);

                fi.OverallAchievementRate = rate.Item1;

                fi.OverallCohort = rate.Item2;

                fi.NationalOverallAchievementRate =
                    GetNationalOverallAchievementRate(nationalAchievementRate);
            }
        }
Пример #2
0
        private FrameworkInformation GetFrameworkInformation(DirectoryInfo directory, NuGetFramework targetFramework)
        {
            var frameworkInfo = new FrameworkInformation();

            frameworkInfo.Path = directory.FullName;

            // The redist list contains the list of assemblies for this target framework
            string redistList = Path.Combine(directory.FullName, "RedistList", "FrameworkList.xml");

            Log.LogVerbose($"Loading Framework Information for {targetFramework}");
            Log.LogVerbose($"Scanning {directory.FullName}");

            if (File.Exists(redistList))
            {
                if (Log.IsEnabled(LogLevel.Verbose))
                {
                    Log.LogVerbose($"Reading redist list from {redistList.Substring(directory.FullName.Length + 1)}");
                }
                frameworkInfo.RedistListPath = redistList;

                using (var stream = File.OpenRead(redistList))
                {
                    var frameworkList = XDocument.Load(stream);

                    foreach (var e in frameworkList.Root.Elements())
                    {
                        var assemblyName = e.Attribute("AssemblyName").Value;
                        var version      = e.Attribute("Version")?.Value;

                        var entry = new AssemblyEntry();
                        entry.Version = version != null?Version.Parse(version) : null;

                        frameworkInfo.Assemblies.Add(assemblyName, entry);
                        Log.LogDebug($"Found assembly {assemblyName} {entry.Version}, in redist list");
                    }

                    var nameAttribute = frameworkList.Root.Attribute("Name");

                    frameworkInfo.Name = nameAttribute == null ? null : nameAttribute.Value;
                }
            }

            return(frameworkInfo);
        }
Пример #3
0
        private ProviderDocument CreateFrameworkProviderDocument(CoreProvider provider, FrameworkInformation frameworkInformation, List <DeliveryInformation> deliveryInformation)
        {
            try
            {
                var frameworkProvider = new ProviderDocument(ElasticsearchDocumentTypes.PROVIDER_FRAMEWORK_DOCUMENT)
                {
                    FrameworkCode = frameworkInformation.Code,
                    PathwayCode   = frameworkInformation.PathwayCode,
                    FrameworkId   = string.Format(_settings.FrameworkIdFormat, frameworkInformation.Code, frameworkInformation.ProgType, frameworkInformation.PathwayCode),
                    Level         = MapToLevelFromProgType(frameworkInformation.ProgType)
                };

                PopulateDocumentSharedProperties(frameworkProvider, provider, frameworkInformation, deliveryInformation);

                return(frameworkProvider);
            }
            catch (Exception ex) when(ex is ArgumentNullException || ex is NullReferenceException)
            {
                throw new MappingException("Unable to map to Framework Provider Document", ex);
            }
        }
Пример #4
0
 public ProviderDocument CreateFrameworkProviderDocument(CoreProvider provider, FrameworkInformation frameworkInformation, IEnumerable <DeliveryInformation> deliveryInformation)
 {
     return(CreateFrameworkProviderDocument(provider, frameworkInformation, deliveryInformation.ToList()));
 }
Пример #5
0
 public ProviderDocument CreateFrameworkProviderDocument(CoreProvider provider, FrameworkInformation frameworkInformation, DeliveryInformation deliveryInformation)
 {
     return(CreateFrameworkProviderDocument(provider, frameworkInformation, new List <DeliveryInformation> {
         deliveryInformation
     }));
 }
Пример #6
0
        private void PopulateCache()
        {
#if DNX451
            if (PlatformHelper.IsMono)
            {
                var mscorlibLocationOnThisRunningMonoInstance = typeof(object).GetTypeInfo().Assembly.Location;

                var libPath = Path.GetDirectoryName(Path.GetDirectoryName(mscorlibLocationOnThisRunningMonoInstance));

                // Mono is a bit inconsistent as .NET 4.5 and .NET 4.5.1 are the
                // same folder
                var supportedVersions = new Dictionary <string, string> {
                    { "4.6", "4.5" },
                    { "4.5.3", "4.5" },
                    { "4.5.1", "4.5" },
                    { "4.5", "4.5" },
                    { "4.0", "4.0" }
                };

                // Temporary cache while enumerating assemblies in directories
                var pathCache = new Dictionary <string, FrameworkInformation>();

                foreach (var versionFolderPair in supportedVersions)
                {
                    var targetFrameworkPath = Path.Combine(libPath, versionFolderPair.Value);

                    if (!Directory.Exists(targetFrameworkPath))
                    {
                        continue;
                    }

                    FrameworkInformation frameworkInfo;
                    if (!pathCache.TryGetValue(targetFrameworkPath, out frameworkInfo))
                    {
                        frameworkInfo      = new FrameworkInformation();
                        frameworkInfo.Path = targetFrameworkPath;

                        var assemblies = new List <Tuple <string, string> >();

                        PopulateAssemblies(assemblies, targetFrameworkPath);
                        PopulateAssemblies(assemblies, Path.Combine(targetFrameworkPath, "Facades"));

                        foreach (var pair in assemblies)
                        {
                            var entry = new AssemblyEntry();
                            entry.Path = pair.Item2;
                            frameworkInfo.Assemblies[pair.Item1] = entry;
                        }

                        pathCache[targetFrameworkPath] = frameworkInfo;
                    }

                    var frameworkName = new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.Net, new Version(versionFolderPair.Key));
                    _cache[frameworkName] = frameworkInfo;
                }

                // Not needed anymore
                pathCache.Clear();
            }
#endif
        }
        private static void PopulateReferenceAssemblies(string path, IGlobalAssemblyCache globalAssemblyCache, IDictionary <FrameworkName, FrameworkInformation> cache)
        {
            var di = new DirectoryInfo(path);

            if (!di.Exists)
            {
                return;
            }

            foreach (var d in di.EnumerateDirectories())
            {
                if (d.Name.StartsWith("v"))
                {
                    continue;
                }

                foreach (var v in d.EnumerateDirectories())
                {
                    var    frameworkInfo = new FrameworkInformation();
                    var    frameworkName = new FrameworkName(d.Name, new Version(v.Name.TrimStart('v')));
                    var    facadePath    = Path.Combine(v.FullName, "RuntimeFacades");
                    string redistList    = Path.Combine(v.FullName, "RedistList", "FrameworkList.xml");

                    if (File.Exists(redistList))
                    {
                        foreach (var assemblyName in GetFrameworkAssemblies(redistList))
                        {
                            var assemblyPath = Path.Combine(v.FullName, assemblyName + ".dll");

                            if (!File.Exists(assemblyPath))
                            {
                                // Check the gac fror full framework only
                                if (frameworkName.Identifier == VersionUtility.DefaultTargetFramework.Identifier)
                                {
                                    if (!globalAssemblyCache.TryResolvePartialName(assemblyName, out assemblyPath))
                                    {
                                        continue;
                                    }
                                }
                                else
                                {
                                    continue;
                                }
                            }

                            frameworkInfo.Assemblies.Add(new AssemblyInfo(assemblyName, assemblyPath));
                        }
                    }
                    else
                    {
                        foreach (var assemblyFileInfo in v.EnumerateFiles("*.dll"))
                        {
                            try
                            {
#if DESKTOP // CORECLR_TODO: AssemblyName.GetAssemblyName
                                var an = AssemblyName.GetAssemblyName(assemblyFileInfo.FullName);
                                frameworkInfo.Assemblies.Add(new AssemblyInfo(an.Name, assemblyFileInfo.FullName));
#else
                                frameworkInfo.Assemblies.Add(new AssemblyInfo(assemblyFileInfo.Name, assemblyFileInfo.FullName));
#endif
                            }
                            catch (Exception ex)
                            {
                                // Probably not a valid assembly
                                Trace.TraceError(ex.Message);
                            }
                        }
                    }

                    cache[frameworkName] = frameworkInfo;
                }
            }
        }
Пример #8
0
        private void PopulateCache()
        {
            #if DNX451
            if (PlatformHelper.IsMono)
            {
                var mscorlibLocationOnThisRunningMonoInstance = typeof(object).GetTypeInfo().Assembly.Location;

                var libPath = Path.GetDirectoryName(Path.GetDirectoryName(mscorlibLocationOnThisRunningMonoInstance));

                // Mono is a bit inconsistent as .NET 4.5 and .NET 4.5.1 are the
                // same folder
                var supportedVersions = new Dictionary<string, string> {
                    { "4.6", "4.5" },
                    { "4.5.3", "4.5" },
                    { "4.5.1", "4.5" },
                    { "4.5", "4.5" },
                    { "4.0", "4.0" }
                };

                // Temporary cache while enumerating assemblies in directories
                var pathCache = new Dictionary<string, FrameworkInformation>();

                foreach (var versionFolderPair in supportedVersions)
                {
                    var targetFrameworkPath = Path.Combine(libPath, versionFolderPair.Value);

                    if (!Directory.Exists(targetFrameworkPath))
                    {
                        continue;
                    }

                    FrameworkInformation frameworkInfo;
                    if (!pathCache.TryGetValue(targetFrameworkPath, out frameworkInfo))
                    {
                        frameworkInfo = new FrameworkInformation();
                        frameworkInfo.Path = targetFrameworkPath;

                        var assemblies = new List<Tuple<string, string>>();

                        PopulateAssemblies(assemblies, targetFrameworkPath);
                        PopulateAssemblies(assemblies, Path.Combine(targetFrameworkPath, "Facades"));

                        foreach (var pair in assemblies)
                        {
                            var entry = new AssemblyEntry();
                            entry.Path = pair.Item2;
                            frameworkInfo.Assemblies[pair.Item1] = entry;
                        }

                        pathCache[targetFrameworkPath] = frameworkInfo;
                    }

                    var frameworkName = new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.Net, new Version(versionFolderPair.Key));
                    _cache[frameworkName] = frameworkInfo;
                }

                // Not needed anymore
                pathCache.Clear();
            }
            #endif
        }
Пример #9
0
        private FrameworkInformation GetFrameworkInformation(DirectoryInfo directory, NuGetFramework targetFramework)
        {
            var frameworkInfo = new FrameworkInformation();
            frameworkInfo.Path = directory.FullName;

            // The redist list contains the list of assemblies for this target framework
            string redistList = Path.Combine(directory.FullName, "RedistList", "FrameworkList.xml");

            Log.LogVerbose($"Loading Framework Information for {targetFramework}");
            Log.LogVerbose($"Scanning {directory.FullName}");

            if (File.Exists(redistList))
            {
                if (Log.IsEnabled(LogLevel.Verbose))
                {
                    Log.LogVerbose($"Reading redist list from {redistList.Substring(directory.FullName.Length + 1)}");
                }
                frameworkInfo.RedistListPath = redistList;

                using (var stream = File.OpenRead(redistList))
                {
                    var frameworkList = XDocument.Load(stream);

                    foreach (var e in frameworkList.Root.Elements())
                    {
                        var assemblyName = e.Attribute("AssemblyName").Value;
                        var version = e.Attribute("Version")?.Value;

                        var entry = new AssemblyEntry();
                        entry.Version = version != null ? Version.Parse(version) : null;
                        frameworkInfo.Assemblies.Add(assemblyName, entry);
                        Log.LogDebug($"Found assembly {assemblyName} {entry.Version}, in redist list");
                    }

                    var nameAttribute = frameworkList.Root.Attribute("Name");

                    frameworkInfo.Name = nameAttribute == null ? null : nameAttribute.Value;
                }
            }

            return frameworkInfo;
        }
Пример #10
0
        private static void PopulateReferenceAssemblies(string path, IGlobalAssemblyCache globalAssemblyCache, IDictionary<FrameworkName, FrameworkInformation> cache)
        {
            var di = new DirectoryInfo(path);

            if (!di.Exists)
            {
                return;
            }

            foreach (var d in di.EnumerateDirectories())
            {
                if (d.Name.StartsWith("v"))
                {
                    continue;
                }

                foreach (var v in d.EnumerateDirectories())
                {
                    var frameworkInfo = new FrameworkInformation();
                    var frameworkName = new FrameworkName(d.Name, new Version(v.Name.TrimStart('v')));
                    var facadePath = Path.Combine(v.FullName, "RuntimeFacades");
                    string redistList = Path.Combine(v.FullName, "RedistList", "FrameworkList.xml");

                    if (File.Exists(redistList))
                    {
                        foreach (var assemblyName in GetFrameworkAssemblies(redistList))
                        {
                            var assemblyPath = Path.Combine(v.FullName, assemblyName + ".dll");

                            if (!File.Exists(assemblyPath))
                            {
                                // Check the gac fror full framework only
                                if (frameworkName.Identifier == VersionUtility.DefaultTargetFramework.Identifier)
                                {
                                    if (!globalAssemblyCache.TryResolvePartialName(assemblyName, out assemblyPath))
                                    {
                                        continue;
                                    }
                                }
                                else
                                {
                                    continue;
                                }
                            }

                            frameworkInfo.Assemblies.Add(new AssemblyInfo(assemblyName, assemblyPath));
                        }
                    }
                    else
                    {
                        foreach (var assemblyFileInfo in v.EnumerateFiles("*.dll"))
                        {
                            try
                            {
            #if DESKTOP // CORECLR_TODO: AssemblyName.GetAssemblyName
                                var an = AssemblyName.GetAssemblyName(assemblyFileInfo.FullName);
                                frameworkInfo.Assemblies.Add(new AssemblyInfo(an.Name, assemblyFileInfo.FullName));
            #else
                                frameworkInfo.Assemblies.Add(new AssemblyInfo(assemblyFileInfo.Name, assemblyFileInfo.FullName));
            #endif
                            }
                            catch (Exception ex)
                            {
                                // Probably not a valid assembly
                                Trace.TraceError(ex.Message);
                            }
                        }
                    }

                    cache[frameworkName] = frameworkInfo;
                }
            }
        }