コード例 #1
0
        public virtual DynamicContentPublication ToModel(DynamicContentPublication publication)
        {
            if (publication == null)
            {
                throw new NullReferenceException(nameof(publication));
            }

            publication.Id                            = Id;
            publication.CreatedBy                     = CreatedBy;
            publication.CreatedDate                   = CreatedDate;
            publication.Description                   = Description;
            publication.ModifiedBy                    = ModifiedBy;
            publication.ModifiedDate                  = ModifiedDate;
            publication.Name                          = Name;
            publication.Priority                      = Priority;
            publication.IsActive                      = IsActive;
            publication.StoreId                       = StoreId;
            publication.StartDate                     = StartDate;
            publication.EndDate                       = EndDate;
            publication.PredicateSerialized           = ConditionExpression;
            publication.PredicateVisualTreeSerialized = PredicateVisualTreeSerialized;

            if (ContentItems != null)
            {
                //TODO
                publication.ContentItems = ContentItems.Where(ci => ci.ContentItem != null).Select(x => x.ContentItem.ToModel(AbstractTypeFactory <DynamicContentItem> .TryCreateInstance())).ToList();
            }
            if (ContentPlaces != null)
            {
                //TODO
                publication.ContentPlaces = ContentPlaces.Where(ci => ci.ContentPlace != null).Select(x => x.ContentPlace.ToModel(AbstractTypeFactory <DynamicContentPlace> .TryCreateInstance())).ToList();
            }

            return(publication);
        }
コード例 #2
0
		public override bool Execute()
		{
			LogExtensionPoint.AmbientLoggerFactory.AddProvider(new TaskLoggerProvider(Log));

			this.Log().Info($"Retargeting UWP assets to {TargetPlatform}.");

			Func<ResourceCandidate, string> resourceToTargetPath;
			switch (TargetPlatform)
			{
				case "ios":
					resourceToTargetPath = resource => iOSResourceConverter.Convert(resource, DefaultLanguage);
					break;
				case "android":
					resourceToTargetPath = resource => AndroidResourceConverter.Convert(resource, DefaultLanguage);
					break;
				default:
					this.Log().Info($"Skipping unknown platform {TargetPlatform}");
					return true;
			}

			Assets = ContentItems.Where(content => IsAsset(content.ItemSpec)).ToArray();
			RetargetedAssets = Assets
				.Select(asset =>
				{
					if (!asset.MetadataNames.Contains("Link"))
					{
						this.Log().Info($"Skipping '{asset.ItemSpec}' because 'Link' metadata is not set.");
						return null;
					}

					var fullPath = asset.GetMetadata("FullPath");
					var relativePath = asset.GetMetadata("Link");

					var resourceCandidate = ResourceCandidate.Parse(fullPath, relativePath);

					if (!UseHighDPIResources && int.TryParse(resourceCandidate.GetQualifierValue("scale"), out var scale) && scale > HighDPIThresholdScale)
					{
						this.Log().Info($"Skipping '{asset.ItemSpec}' of scale {scale} because {nameof(UseHighDPIResources)} is false.");
						return null;
					}

					var targetPath = resourceToTargetPath(resourceCandidate);

					if (targetPath == null)
					{
						this.Log().Info($"Skipping '{asset.ItemSpec}' as it's not supported on {TargetPlatform}.");
						return null;
					}
					
					this.Log().Info($"Retargeting '{asset.ItemSpec}' to '{targetPath}'.");
					return new TaskItem(asset.ItemSpec, new Dictionary<string, string>() { { "LogicalName", targetPath } });
				})
				.Trim()
				.ToArray();

			return true;
		}
コード例 #3
0
 /*==========================================================================================================================
 | GET TECHNICAL PAPERS
 \-------------------------------------------------------------------------------------------------------------------------*/
 /// <summary>
 ///   Provides a helper function for retrieving a list of <see cref="TechnicalPaperTopicViewModel"/>s based on a category
 ///   key.
 /// </summary>
 public TopicViewModelCollection<TechnicalPaperTopicViewModel> GetTechnicalPapers(string category) =>
   new TopicViewModelCollection<TechnicalPaperTopicViewModel>(
     ContentItems
       .Where(t => (t.Category ?? "")
       .Equals(category))
     .Cast<TechnicalPaperTopicViewModel>()
     .OrderByDescending(p => p.PublicationDate)
     .AsEnumerable()
   );
コード例 #4
0
        public Task <IEnumerable <ContentItem> > GetContentItems(string path, GetThemeAssetsCriteria criteria)
        {
            var query = ContentItems.Where(i => i.Path.StartsWith(path));

            if (criteria != null && criteria.LastUpdateDate.HasValue)
            {
                query = query.Where(i => (i.ModifiedDate.HasValue && criteria.LastUpdateDate.Value < i.ModifiedDate.Value) || (criteria.LastUpdateDate.Value < i.CreatedDate));
            }

            return(Task.FromResult(query.AsEnumerable()));
        }
コード例 #5
0
        public void DeleteTheme(string path)
        {
            var existingTheme = Themes.FirstOrDefault(t => t.Id == path);

            if (existingTheme != null)
            {
                Remove(existingTheme);
                var contentItems = ContentItems.Where(c => c.Path.StartsWith(path));
                foreach (var item in contentItems)
                {
                    Remove(item);
                }

                UnitOfWork.Commit();
            }
        }
コード例 #6
0
        public async Task <bool> DeleteTheme(string path)
        {
            var existingTheme = await Themes.FirstOrDefaultAsync(t => t.Id == path);

            if (existingTheme != null)
            {
                Remove(existingTheme);
                var contentItems = ContentItems.Where(c => c.Path.StartsWith(path));
                foreach (var item in contentItems)
                {
                    Remove(item);
                }

                UnitOfWork.Commit();
            }

            return(true);
        }
コード例 #7
0
ファイル: Storage.cs プロジェクト: yonyonson604/ChronoZoom
        /// <summary>Gets owner of the triplet</summary>
        /// <param name="name">Name of the triplet. Triplets referring to timelines, exhibits, artifacts and bNodes are supported.
        /// In all other cases method returns null.</param>
        /// <param name="bNodes">List of previously examined bNodes to avoid endless recursion</param>
        /// <returns>String representation of owning user ID</returns>
        public string GetSubjectOwner(TripleName name, List <string> bNodes = null)
        {
            name = EnsurePrefix(name);
            switch (name.Prefix)
            {
            case TripleName.UserPrefix:
                return(name.Name);

            case TripleName.TimelinePrefix:
                var timelineId = Guid.Parse(name.Name);
                var timeline   = Timelines.Where(t => t.Id == timelineId).FirstOrDefault();
                if (timeline == null)
                {
                    return(null);
                }
                Entry(timeline).Reference(t => t.Collection).Load();
                return(GetCollectionOwner(timeline.Collection));

            case TripleName.ExhibitPrefix:
                var exhibitId = Guid.Parse(name.Name);
                var exhibit   = Exhibits.Where(e => e.Id == exhibitId).FirstOrDefault();
                if (exhibit == null)
                {
                    return(null);
                }
                Entry(exhibit).Reference(e => e.Collection).Load();
                return(GetCollectionOwner(exhibit.Collection));

            case TripleName.ArtifactPrefix:
                var artifactId = Guid.Parse(name.Name);
                var artifact   = ContentItems.Where(c => c.Id == artifactId).FirstOrDefault();
                if (artifact == null)
                {
                    return(null);
                }
                Entry(artifact).Reference(a => a.Collection).Load();
                return(GetCollectionOwner(artifact.Collection));

            case TripleName.TourPrefix:
                var tourId = Guid.Parse(name.Name);
                var tour   = Tours.FirstOrDefault(t => t.Id == tourId);
                if (tour == null)
                {
                    return(null);
                }
                Entry(tour).Reference(t => t.Collection).Load();
                return(GetCollectionOwner(tour.Collection));

            case "_":
                var subject = name.ToString();
                // Guard against infinite loop
                if (bNodes != null && bNodes.Contains(subject))
                {
                    return(null);
                }
                // Find subject of any triple that uses passed subject as object
                var linkedSubject = Triples.
                                    Include(t => t.Objects).
                                    Where(t => t.Objects.Any(o => o.Object == subject)).
                                    Select(t => t.Subject).FirstOrDefault();
                if (String.IsNullOrEmpty(linkedSubject))
                {
                    return(null);
                }
                // Get owner of linked subject
                if (bNodes == null)
                {
                    bNodes = new List <string>(new string[] { subject });
                }
                else
                {
                    bNodes.Add(subject);
                }
                return(GetSubjectOwner(TripleName.Parse(linkedSubject), bNodes));

            default:
                return(null);
            }
        }
コード例 #8
0
        public async Task GenerateScreenerMenuList()
        {
            var localList = new List <MenuContentModel>();
            await Task.Delay(0);

            if (TotalCategories != null && TotalCategories.Any())
            {
                var sequence = 0;
                foreach (var item in TotalCategories)
                {
                    sequence += 1;
                    var MenuContentModel = new MenuContentModel();
                    if (item.contentCategoryLevelId == 4)
                    {
                        MenuContentModel.ShowStatus       = true;
                        MenuContentModel.ContentLevelID   = item.contentCategoryLevelId;
                        MenuContentModel.ContentCatgoryId = item.contentCategoryId;
                        MenuContentModel.Code             = item.name;
                        MenuContentModel.Text             = item.name;
                        MenuContentModel.ShowImage        = true;
                        MenuContentModel.SequenceNumber   = sequence;
                        //MenuContentModel.SelectedCommandAction = new Action<MenuContentModel>(AddorRemoveItems);
                        localList.Add(MenuContentModel);
                    }
                    else if (item.contentCategoryLevelId == 5)
                    {
                        if (ContentCategoryItems != null && ContentCategoryItems.Any())
                        {
                            var filteredContentCategoryItems = ContentCategoryItems.Where(p => p.contentCategoryId == item.contentCategoryId).ToArray();
                            if (filteredContentCategoryItems.Length > 0)
                            {
                                if (ContentItems != null && ContentItems.Any())
                                {
                                    var filteredContentItems = ContentItems.Where(p => filteredContentCategoryItems.Select(q => q.contentItemId).Contains(p.contentItemId)).OrderBy(p => p.sequenceNo).ToArray();
                                    if (filteredContentItems.Length > 0)
                                    {
                                        var startingpoint = new MenuContentModel();
                                        startingpoint.Code             = filteredContentItems.FirstOrDefault().itemCode;
                                        startingpoint.ContentItemId    = filteredContentItems.FirstOrDefault().contentItemId;
                                        startingpoint.Text             = "Starting Point for developmental ages " + item.name;
                                        startingpoint.ContentCatgoryId = item.contentCategoryId;
                                        startingpoint.ParentID         = item.parentContentCategoryId;
                                        startingpoint.ContentLevelID   = item.contentCategoryLevelId;
                                        startingpoint.IsStartingPoint  = true;
                                        startingpoint.SequenceNumber   = sequence;
                                        //startingpoint.SelectedCommandAction = new Action<MenuContentModel>(AddorRemoveItems);
                                        localList.Add(startingpoint);
                                        foreach (var contentItem in filteredContentItems)
                                        {
                                            sequence += 1;
                                            var menuItem = new MenuContentModel();
                                            menuItem.ContentLevelID   = item.contentCategoryLevelId;
                                            menuItem.ContentCatgoryId = item.contentCategoryId;
                                            menuItem.ParentID         = item.parentContentCategoryId;
                                            menuItem.Code             = contentItem.itemCode;
                                            menuItem.Text             = !string.IsNullOrEmpty(contentItem.alternateItemText) ? contentItem.alternateItemText : contentItem.itemText;
                                            menuItem.ContentItemId    = contentItem.contentItemId;
                                            menuItem.SequenceNumber   = sequence;
                                            menuItem.HtmlFilePath     = contentItem.HtmlFilePath;
                                            //menuItem.SelectedCommandAction = new Action<MenuContentModel>(AddorRemoveItems);
                                            localList.Add(menuItem);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            ScreenerMenuList = new List <MenuContentModel>(localList);
        }