public static RemoteTemplatesSourceConfig GetRemoteTemplatesSourceConfig(string storageAccount, EnvEnum environment) { string env = environment.ToString().ToLowerInvariant(); CloudBlobContainer container = RemoteSource.GetContainerAnonymous(storageAccount, env); var remoteElements = RemoteSource.GetAllElements(container); var remotePackages = remoteElements.Where(e => e != null && e.Name.StartsWith(env, StringComparison.OrdinalIgnoreCase) && e.Name.EndsWith(".mstx", StringComparison.OrdinalIgnoreCase)) .Select((e) => new RemoteTemplatesPackage() { Name = e.Name, StorageUri = e.Uri, Bytes = e.Properties.Length, Date = e.Properties.LastModified.Value.DateTime, Version = ParseVersion(e.Name), }) .OrderByDescending(e => e.Date) .OrderByDescending(e => e.Version) .GroupBy(e => e.MainVersion) .Select(e => e.FirstOrDefault()); RemoteTemplatesSourceConfig config = new RemoteTemplatesSourceConfig() { VersionCount = remotePackages.Count(), Latest = remotePackages.FirstOrDefault(), Versions = remotePackages.ToList() }; return(config); }
public static TemplatesSourceConfig GetTemplatesSourceConfig(string storageAccount, EnvEnum environment) { string env = environment.ToString().ToLowerInvariant(); CloudBlobContainer container = GetContainerAnonymous(storageAccount, env); var remoteElements = RemoteSource.GetAllElements(container); var remotePackages = remoteElements.Where(e => e != null && e.Name.StartsWith(env, StringComparison.OrdinalIgnoreCase) && e.Name.EndsWith(".mstx", StringComparison.OrdinalIgnoreCase)) .Select((e) => new TemplatesPackageInfo() { Name = e.Name, Bytes = e.Properties.Length, Date = e.Properties.LastModified.Value.DateTime, Platform = e.Metadata.ContainsKey("platform") ? e.Metadata["platform"] : string.Empty, Language = e.Metadata.ContainsKey("language") ? e.Metadata["language"] : string.Empty, WizardVersions = e.Metadata.ContainsKey("wizardversion") ? e.Metadata["wizardversion"].Split(';').Select(v => new Version(v)).ToList() : new List <Version>(), }) .OrderByDescending(e => e.Date) .OrderByDescending(e => e.Version) .GroupBy(e => new { e.MainVersion, e.Language, e.Platform }) .Select(e => e.FirstOrDefault()); TemplatesSourceConfig config = new TemplatesSourceConfig() { Latest = remotePackages.FirstOrDefault(), Versions = remotePackages.ToList(), RootUri = container.Uri, }; return(config); }