Ejemplo n.º 1
0
        /// <summary>
        /// Get all content version of current exported content in all languages.
        /// </summary>
        /// <param name="contentToExport"></param>
        /// <returns></returns>
        protected virtual IEnumerable <IContent> GetContentVersions(
            ContentReference contentToExport, RawContentInfo rawContentInfo, out ContentVersion latestPublishedMasterVersion)
        {
            var versionFilter = new VersionFilter
            {
                ContentLink    = contentToExport,
                Languages      = rawContentInfo.Languages.Select(x => CultureInfo.GetCultureInfo(x)),
                ExcludeDeleted = true
            };

            if (_transferExportOptionsEx.VersionStatuses != null)
            {
                versionFilter.Statuses = _transferExportOptionsEx.VersionStatuses;
            }

            int totalCount;
            var versions = _contentVersionRepository
                           .List(versionFilter, 0, int.MaxValue, out totalCount);

            latestPublishedMasterVersion = versions.FirstOrDefault(x =>
                                                                   x.Status == VersionStatus.Published &&
                                                                   x.LanguageBranch == rawContentInfo.MasterLanguage);

            versions = FilterVersions(versions);

            return(versions
                   .OrderBy(x => x.LanguageBranch == rawContentInfo.MasterLanguage ? 1 : 2)
                   .ThenBy(x => x.Saved)
                   .Select(x => GetContent(x))
                   .Where(x => x != null));
        }
Ejemplo n.º 2
0
        public static IEnumerable <TModel> AdvancedFilter <TModel>(
            this IEnumerable <TModel> enumerable,
            Expression <Func <TModel, Version> > propertyToFilter,
            VersionFilter filter,
            Version filterValue)
        {
            MemberExpression memberExpression = (MemberExpression)propertyToFilter.Body;
            string           memberName       = memberExpression.Member.Name;

            if (filterValue == null) //If value to check is null then show all non null valuesw
            {
                filter = VersionFilter.IsNotBlank;
            }

            //Sort through null/not null first to prevent later errors
            IEnumerable <TModel> nullVersions  = enumerable.AsQueryable().Where($"t=>t.{memberName} == null");
            IEnumerable <TModel> validVersions = enumerable.AsQueryable().Where($"t=>t.{memberName} != null");

            return(filter switch
            {
                VersionFilter.Is => validVersions.AsQueryable().Where($"t=>t.{memberName} = @0", filterValue),
                VersionFilter.IsBlank => nullVersions,
                VersionFilter.IsEarlier => validVersions.AsQueryable().Where($"t=>t.{memberName} < @0", filterValue),
                VersionFilter.IsEarlierMajorVersion => validVersions.AsQueryable().Where($"t=>t.{memberName}.Major < @0", filterValue.Major),
                VersionFilter.IsLater => validVersions.AsQueryable().Where($"t=>t.{memberName}.Major > @0", filterValue.Major),
                VersionFilter.IsLaterMajorVersion => validVersions.AsQueryable().Where($"t=>t.{memberName}.Major > @0", filterValue.Major),
                VersionFilter.IsSameMajorVersion => validVersions.AsQueryable().Where($"t=>t.{memberName}.Major = @0", filterValue.Major),
                VersionFilter.IsNot => validVersions.AsQueryable().Where($"t=>t.{memberName} != @0", filterValue),
                VersionFilter.IsNotBlank => validVersions,
                VersionFilter.IsSameOrEarlier => validVersions.AsQueryable().Where($"t=>t.{memberName} <= @0", filterValue),
                VersionFilter.IsSameOrLater => validVersions.AsQueryable().Where($"t=>t.{memberName} >= @0", filterValue),
                _ => validVersions, // Default to is not blank
            });
Ejemplo n.º 3
0
        /// <summary>
        ///     Search for new update packages with the given options
        /// </summary>
        /// <returns>Return the result of the update search</returns>
        public async Task <UpdatePackageSearchResult> SearchForNewUpdatePackagesAsync()
        {
            var versionFilter = VersionFilter?.GetSupportedPrereleases();

            if (versionFilter?.Length > 10)
            {
                throw new ArgumentException("A maximum of 10 version filters is allowed.");
            }

            var httpClient = _httpClient.Value;
            var version    = VersionProvider.GetVersion();

            HttpClientSetHeaders(version);

            try
            {
                var uri = new Uri($"packages/{Uri.EscapeDataString(version.ToString())}/check", UriKind.Relative);

                var platforms = PlatformProvider?.GetEncodedPlatforms();
                if (platforms != null)
                {
                    uri = uri.AddQueryParameters("platforms", platforms.Value.ToString());
                }

                if (versionFilter?.Length > 0)
                {
                    uri = uri.AddQueryParameters("versionFilter",
                                                 Uri.EscapeDataString(JsonConvert.SerializeObject(versionFilter)));
                }

                var response = await httpClient.GetAsync(uri);

                if (!response.IsSuccessStatusCode)
                {
                    throw await UpdateSystemResponseExtensions.GetResponseException(response, this);
                }

                var result = await response.Content.ReadAsStringAsync();

                var jwtResponse =
                    JsonConvert.DeserializeObject <JwtResponse <UpdatePackageSearchResult> >(result,
                                                                                             _jsonSerializerSettings);

                HttpClientSetJwt(jwtResponse);
                var searchResult = jwtResponse.Result;
                searchResult.Initialize(this);

                if (!searchResult.IsUpdateAvailable)
                {
                    Settings?.NoUpdatesFoundCleanup(ProjectId);
                }

                return(searchResult);
            }
            finally
            {
                httpClient.DefaultRequestHeaders.AcceptLanguage.Clear();
            }
        }
        private static bool Eval(string versionStr)
        {
            var sut    = new VersionFilter(3);
            var @event = new CommandEvent {
                KaVEVersion = versionStr
            };

            return(sut.Func(@event));
        }
Ejemplo n.º 5
0
 public static bool IsMatch(this VersionFilter versionFilter, Version version)
 {
     return(versionFilter.GetMinVersion() < version && version < versionFilter.GetMaxVersion());
 }
Ejemplo n.º 6
0
 public Range(VersionFilter lower, VersionFilter upper)
 {
     Lower = lower;
     Upper = upper;
 }
Ejemplo n.º 7
0
 public VersionTarget(VersionFilter lower, VersionFilter upper)
 {
     TargetRange = new Range(lower, upper);
     EnsureValidRange(TargetRange);
 }
Ejemplo n.º 8
0
 public VersionTarget(VersionFilter targetVersion)
 {
     TargetVersion = targetVersion;
 }