/// <summary> /// Populates the Place object's properties from the given content view. /// </summary> /// <param name="thisObject">Place object</param> /// <param name="contentsView">content view object</param> /// <returns>Place instance</returns> public static Place SetValuesFrom(this Place thisObject, ContentsView contentsView) { if (contentsView != null) { if (thisObject == null) { thisObject = new Place(); } thisObject.Name = contentsView.Title; thisObject.MSRComponentId = contentsView.ContentID; thisObject.FileType = contentsView.TypeID.ToEnum<int, ContentTypes>(ContentTypes.Generic); thisObject.ContentLink = thisObject.FileType == ContentTypes.Link ? contentsView.ContentUrl : string.Empty; thisObject.ContentAzureID = thisObject.FileType == ContentTypes.Link ? string.Empty : contentsView.ContentAzureID.ToString(); thisObject.Url = contentsView.Filename; thisObject.Thumbnail = (contentsView.ThumbnailID.HasValue && contentsView.ThumbnailID != Guid.Empty) ? contentsView.ThumbnailID.ToString() : null; // Permissions for Content view are hard-coded to Read as it is used for browse thisObject.Permission = Permission.Reader; } return thisObject; }
/// <summary> /// Populates the Place object's properties from the given content. /// </summary> /// <param name="thisObject">Place object</param> /// <param name="contentDetail">content Details object</param> /// <returns>Place instance</returns> public static Place SetValuesFrom(this Place thisObject, ContentDetails contentDetail) { if (contentDetail != null) { if (thisObject == null) { thisObject = new Place(); } thisObject.Name = contentDetail.Name; thisObject.MSRComponentId = contentDetail.ID; thisObject.FileType = contentDetail.ContentData.ContentType; if (contentDetail.ContentData is LinkDetail) { var linkDetail = contentDetail.ContentData as LinkDetail; thisObject.ContentLink = linkDetail.ContentUrl; thisObject.ContentAzureID = string.Empty; } else { var fileDetail = contentDetail.ContentData as FileDetail; thisObject.ContentLink = string.Empty; thisObject.ContentAzureID = fileDetail.AzureID.ToString(); } thisObject.Url = contentDetail.ContentData.Name; thisObject.Thumbnail = (contentDetail.Thumbnail != null && contentDetail.Thumbnail.AzureID != Guid.Empty) ? contentDetail.Thumbnail.AzureID.ToString() : null; thisObject.Permission = contentDetail.UserPermission; } return thisObject; }
/// <summary> /// Populates the PayloadDetails object's properties from the given collection of ContentsView object's properties. /// </summary> /// <param name="thisObject">PayloadDetails object</param> /// <param name="contents">ContentsView objects</param> /// <returns>PayloadDetails instance</returns> public static PayloadDetails SetValuesFrom(this PayloadDetails thisObject, IEnumerable<ContentsView> contents) { if (contents != null) { if (thisObject == null) { thisObject = InitializePayload(); } foreach (var content in contents) { if (content.Filename.EndsWith(Constants.TourFileExtension, StringComparison.OrdinalIgnoreCase)) { var tour = new TourModel(); tour.SetValuesFrom(content); thisObject.Tours.Add(tour); } else if (content.Filename.EndsWith(Constants.CollectionFileExtension, StringComparison.OrdinalIgnoreCase)) { var childCollection = new PayloadDetails(); childCollection.Name = content.Title; childCollection.Id = content.ContentAzureID.ToString(); childCollection.MSRComponentId = content.ContentID; childCollection.Group = "Explorer"; childCollection.IsCollection = true; childCollection.Thumbnail = (content.ThumbnailID.HasValue && content.ThumbnailID != Guid.Empty) ? content.ThumbnailID.ToString() : null; // Permissions for Content view are hard-coded to Read as it is used for browse childCollection.Permission = Permission.Reader; thisObject.Children.Add(childCollection); } else { var place = new Place(); place.SetValuesFrom(content); thisObject.Links.Add(place); } } } return thisObject; }
/// <summary> /// Populates the PayloadDetails object's properties from the given Content object's properties. /// </summary> /// <param name="thisObject">PayloadDetails object</param> /// <param name="contentDetail">Content Details object</param> /// <returns>PayloadDetails instance</returns> public static PayloadDetails SetValuesFrom(this PayloadDetails thisObject, ContentDetails contentDetail) { if (contentDetail != null) { if (thisObject == null) { thisObject = InitializePayload(); } if (contentDetail.ContentData is FileDetail) { var fileDetail = contentDetail.ContentData as FileDetail; if (contentDetail.ContentData.ContentType == ContentTypes.Tours) { var tour = new TourModel(); tour.SetValuesFrom(contentDetail); thisObject.Tours.Add(tour); } else if (contentDetail.ContentData.ContentType == ContentTypes.Wtml) { var childCollection = new PayloadDetails(); childCollection.Name = contentDetail.Name; childCollection.Id = fileDetail.AzureID.ToString(); childCollection.MSRComponentId = contentDetail.ID; childCollection.Group = "Explorer"; childCollection.IsCollection = true; childCollection.Thumbnail = (contentDetail.Thumbnail != null && contentDetail.Thumbnail.AzureID != Guid.Empty) ? contentDetail.Thumbnail.AzureID.ToString() : null; childCollection.Permission = contentDetail.UserPermission; thisObject.Children.Add(childCollection); } else { var place = new Place(); place.SetValuesFrom(contentDetail); thisObject.Links.Add(place); } } else { var place = new Place(); place.SetValuesFrom(contentDetail); thisObject.Links.Add(place); } } return thisObject; }
public FileStreamResult GetProfilePayload() { var serviceBaseUri = ServiceBaseUri(); // If we are not doing Re-writes of Url, we need to set the thumbnails explicitly at all places var payloadDetails = PayloadDetailsExtensions.InitializePayload(); payloadDetails.Thumbnail = RewriteThumbnailUrl(payloadDetails.Thumbnail, "defaultfolderwwtthumbnail"); payloadDetails.Name = Resources.MyFolderLabel; //upgrade notice //var upgradeLink = new Place(); //upgradeLink.Name = "Upgrade Notice"; //upgradeLink.Url = "/upgrade/index?wwtfull=true"; //upgradeLink.Permission = Permission.Reader; //upgradeLink.Thumbnail = RewriteThumbnailUrl(upgradeLink.Thumbnail, "upgradenotice"); //payloadDetails.Links.Add(upgradeLink); // Get My communities node. var myCommunities = PayloadDetailsExtensions.InitializePayload(); myCommunities.Name = Resources.MyCommunitiesWWTLabel; myCommunities.Url = string.Format(CultureInfo.InvariantCulture, "{0}/Communities", serviceBaseUri); myCommunities.Thumbnail = RewriteThumbnailUrl(myCommunities.Thumbnail, "defaultfolderwwtthumbnail"); payloadDetails.Children.Add(myCommunities); // Get My contents node. var myContents = PayloadDetailsExtensions.InitializePayload(); myContents.Name = Resources.MyContentsWWTLabel; myContents.Url = string.Format(CultureInfo.InvariantCulture, "{0}/Contents", serviceBaseUri); myContents.Thumbnail = RewriteThumbnailUrl(myContents.Thumbnail, "defaultfolderwwtthumbnail"); payloadDetails.Children.Add(myContents); // Get Browse EO node. var browseDetails = PayloadDetailsExtensions.InitializePayload(); browseDetails.Name = Resources.BrowseWWTLabel; browseDetails.Url = string.Format(CultureInfo.InvariantCulture, "{0}/Browse", serviceBaseUri); browseDetails.Thumbnail = RewriteThumbnailUrl(browseDetails.Thumbnail, "defaultfolderwwtthumbnail"); payloadDetails.Children.Add(browseDetails); // TODO: Get Search EO node. var searchEoLink = new Place(); searchEoLink.Name = Resources.SearchWWTLabel; searchEoLink.Url = string.Format(CultureInfo.InvariantCulture, "{0}/Community/index{1}", BaseUri(), "?wwtfull=true"); searchEoLink.Permission = Permission.Reader; searchEoLink.Thumbnail = RewriteThumbnailUrl(searchEoLink.Thumbnail, "searchwwtthumbnail"); // This will make sure that the additional context menu options specific to folders are not shown in WWT. searchEoLink.MSRComponentId = -1; payloadDetails.Links.Add(searchEoLink); // TODO: Get Help node. var helpLink = new Place(); helpLink.Name = Resources.HelpWWTLabel; helpLink.Url = string.Format(CultureInfo.InvariantCulture, "{0}/Support/index{1}", BaseUri(), "?wwtfull=true"); helpLink.Permission = Permission.Reader; helpLink.Thumbnail = RewriteThumbnailUrl(helpLink.Thumbnail, "helpwwtthumbnail"); // This will make sure that the additional context menu options specific to folders are not shown in WWT. helpLink.MSRComponentId = -1; payloadDetails.Links.Add(helpLink); var payload = new FileStreamResult(GetOutputStream(payloadDetails), Response.ContentType); return payload; }