public static UpdateDetailsResponse UpdateDetails(string polys, string textures, string format, string pid) { APIWrapper api = null; if (Membership.GetUser() != null && Membership.GetUser().IsApproved) { api = new APIWrapper(Membership.GetUser().UserName, null); } else { api = new APIWrapper(vwarDAL.DefaultUsers.Anonymous[0], null); } vwar.service.host.Metadata md = api.GetMetadata(pid, "00-00-00"); md.NumPolygons = polys; md.NumTextures = textures; md.Format = format; string result = api.UpdateMetadata(md, pid, "00-00-00"); UpdateDetailsResponse response = new UpdateDetailsResponse(result == "Ok"); response.polys = md.NumPolygons; response.textures = md.NumTextures; response.format = md.Format; return(response); }
public static UpdateDeveloperInfoResponse UpdateDeveloperInfo(string DeveloperName, string ArtistName, string MoreInfoURL, string pid, string newfilename) { APIWrapper api = null; if (Membership.GetUser() != null && Membership.GetUser().IsApproved) { api = new APIWrapper(Membership.GetUser().UserName, null); } else { api = new APIWrapper(vwarDAL.DefaultUsers.Anonymous[0], null); } vwar.service.host.Metadata md = api.GetMetadata(pid, "00-00-00"); UpdateDeveloperInfoResponse response = new UpdateDeveloperInfoResponse(false); if (md.ArtistName != ArtistName || md.DeveloperName != DeveloperName || md.MoreInformationURL != MoreInfoURL) { md.ArtistName = ArtistName; md.DeveloperName = DeveloperName; md.MoreInformationURL = MoreInfoURL; string result = api.UpdateMetadata(md, pid, "00-00-00"); response = new UpdateDeveloperInfoResponse(result == "Ok"); response.DeveloperName = md.DeveloperName; response.ArtistName = md.ArtistName; response.MoreInfoURL = md.MoreInformationURL; } try { using (FileStream stream = new FileStream(HostingEnvironment.MapPath(String.Format("~/App_Data/imageTemp/{0}", newfilename)), FileMode.Open)) { byte[] data = new byte[stream.Length]; stream.Read(data, 0, (int)stream.Length); api.UploadDeveloperLogo(data, pid, newfilename, "00-00-00"); } File.Delete(HostingEnvironment.MapPath(String.Format("~/App_Data/imageTemp/{0}", newfilename))); } catch (Exception e) { } return(response); }
public static string GetDistributionText(vwar.service.host.Metadata co) { switch ((vwarDAL.DistributionGrade)Enum.Parse(typeof(vwarDAL.DistributionGrade), co.Distribution_Grade)) { case DistributionGrade.Distribution_A: return("Approved for public release; distribution is unlimited"); break; case DistributionGrade.Distribution_B: return("Distribution authorized to U.S. Government agencies only. " + co.Distribution_Reason + " " + co.Distribution_Determination_Date + ". Other requests for this document shall be referred to " + co.Distribution_Contolling_Office); break; case DistributionGrade.Distribution_C: return("Distribution authorized to U.S. Government Agencies and their contractors " + co.Distribution_Reason + " " + co.Distribution_Determination_Date + ". Other requests for this document shall be referred to " + co.Distribution_Contolling_Office); break; case DistributionGrade.Distribution_D: return("Distribution authorized to the Department of Defense and U.S. DoD contractors only. " + co.Distribution_Reason + " " + co.Distribution_Determination_Date + ". Other requests shall be referred to " + co.Distribution_Contolling_Office); break; case DistributionGrade.Distribution_E: return("Distribution authorized to DoD Components only " + co.Distribution_Reason + " " + co.Distribution_Determination_Date + ". Other requests shall be referred to " + co.Distribution_Contolling_Office); break; case DistributionGrade.Distribution_F: return("Further dissemination only as directed by " + co.Distribution_Contolling_Office + " " + co.Distribution_Determination_Date + " or higher DoD authority."); break; case DistributionGrade.Distribution_X: return("Distribution authorized to U.S. Government Agencies and private individuals or enterprises eligible to obtain export-controlled technical data in accordance with " + co.Distribution_Regulation + "; " + co.Distribution_Determination_Date + ". DoD Controlling Office is " + co.Distribution_Contolling_Office); break; case DistributionGrade.NA: return(""); break; } return(""); }
public static UpdateDistributionInfoResponse UpdateDistributionInfo(string Class, string DeterminationDate, string Office, string Regulation, string Reason, string pid) { APIWrapper api = null; if (Membership.GetUser() != null && Membership.GetUser().IsApproved) { api = new APIWrapper(Membership.GetUser().UserName, null); } else { api = new APIWrapper(vwarDAL.DefaultUsers.Anonymous[0], null); } vwar.service.host.Metadata md = api.GetMetadata(pid, "00-00-00"); if (md == null) { return(new UpdateDistributionInfoResponse(false)); } UpdateDistributionInfoResponse response = new UpdateDistributionInfoResponse(false); md.Distribution_Grade = Class; md.Distribution_Reason = Reason; md.Distribution_Regulation = Regulation; md.Distribution_Determination_Date = DeterminationDate; md.Distribution_Contolling_Office = Office; string result = api.UpdateMetadata(md, pid, "00-00-00"); if (result == "Ok") { response = new UpdateDistributionInfoResponse(true); response.Class = md.Distribution_Grade;; response.DeterminationDate = DeterminationDate; response.Office = Office; response.Reason = Reason; response.Regulation = Regulation; response.FullText = GetDistributionText(md); } return(response); }
public static GetSupportingFilesResponse GetSupportingFiles(string pid) { APIWrapper api = null; if (Membership.GetUser() != null && Membership.GetUser().IsApproved) { api = new APIWrapper(Membership.GetUser().UserName, null); } else { api = new APIWrapper(vwarDAL.DefaultUsers.Anonymous[0], null); } vwar.service.host.Metadata md = api.GetMetadata(pid, "00-00-00"); if (md == null) { return(new GetSupportingFilesResponse(false)); } PermissionsManager prm = new PermissionsManager(); MembershipUser user = Membership.GetUser(); ModelPermissionLevel Permission = prm.GetPermissionLevel(user != null ? user.UserName:vwarDAL.DefaultUsers.Anonymous[0], pid); prm.Dispose(); GetSupportingFilesResponse response = new GetSupportingFilesResponse(true); response.DownloadAllowed = Permission >= ModelPermissionLevel.Fetchable; response.EditAllowed = Permission >= ModelPermissionLevel.Editable; response.files = new vwarDAL.SupportingFile[md.SupportingFiles.Count]; for (int i = 0; i < md.SupportingFiles.Count; i++) { response.files[i] = new vwarDAL.SupportingFile(md.SupportingFiles[i].Filename, md.SupportingFiles[i].Description, ""); } return(response); }
public static UpdateAssetDataResponse UpdateAssetData(string Title, string Description, string Keywords, string License, string pid) { APIWrapper api = null; if (Membership.GetUser() != null && Membership.GetUser().IsApproved) { api = new APIWrapper(Membership.GetUser().UserName, null); } else { api = new APIWrapper(vwarDAL.DefaultUsers.Anonymous[0], null); } vwar.service.host.Metadata md = api.GetMetadata(pid, "00-00-00"); if (md == null) { return(new UpdateAssetDataResponse(false)); } UpdateAssetDataResponse response = new UpdateAssetDataResponse(true); response.Keywords = md.Keywords.Split(new char[] { ',', '|' }); for (int i = 0; i < response.Keywords.Length; i++) { response.Keywords[i] = response.Keywords[i].ToLower().Trim(); } switch (License.ToLower().Trim()) { case "by-nc-sa": response.LicenseURL = "http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode"; response.LicenseImage = "../styles/images/by-nc-sa.png"; response.LicenseTitle = "by-nc-sa"; break; case "by-nc-nd": response.LicenseURL = "http://creativecommons.org/licenses/by-nc-nd/3.0/legalcode"; response.LicenseImage = "../styles/images/by-nc-nd.png"; response.LicenseTitle = "by-nc-nd"; break; case "by-nc": response.LicenseURL = "http://creativecommons.org/licenses/by-nc/3.0/legalcode"; response.LicenseImage = "../styles/images/by-nc.png"; response.LicenseTitle = "by-nc"; break; case "by-nd": response.LicenseURL = "http://creativecommons.org/licenses/by-nd/3.0/legalcode"; response.LicenseImage = "../styles/images/by-nd.png"; response.LicenseTitle = "by-nd"; break; case "by-sa": response.LicenseURL = "http://creativecommons.org/licenses/by-sa/3.0/legalcode"; response.LicenseImage = "../styles/images/by-sa.png"; response.LicenseTitle = "by-sa"; break; case "publicdomain": response.LicenseURL = "http://creativecommons.org/publicdomain/mark/1.0/"; response.LicenseImage = "../styles/images/publicdomain.png"; response.LicenseTitle = "Public Domain"; break; case "by": response.LicenseURL = "http://creativecommons.org/licenses/by/3.0/legalcode"; response.LicenseImage = "../styles/images/by.png"; response.LicenseTitle = "by"; break; } md.Title = Title; md.Description = Description; md.Keywords = Keywords; md.License = response.LicenseURL; response.Title = md.Title; response.Description = md.Description; string result = api.UpdateMetadata(md, pid, "00-00-00"); if (result != "Ok") { return(new UpdateAssetDataResponse(false)); } return(response); }
private void BindModelDetails() { if (String.IsNullOrEmpty(ContentObjectID)) { Response.Redirect("~/Default.aspx"); } var uri = Request.Url; //string proxyTemplate = "Model.ashx?pid={0}&file={1}&fileid={2}"; vwar.service.host.Metadata co = null; try { string request = "http://3dr.adlnet.gov/Federation/3DR_Federation.svc/" + Request.QueryString["ContentObjectID"] + "/Metadata/json?ID=00-00-00"; FederateRecord fed = GetFederateInfo(PidToNamespace(Request.QueryString["ContentObjectID"])); OrganizationContact.Text = fed.OrganizationPOC; OrganizationContact.NavigateUrl = "mailto:" + fed.OrganizationPOCEmail; OrganizationName.Text = fed.OrginizationName; OrganizationName.NavigateUrl = fed.OrganizationURL; System.Net.WebRequest wr = WebRequest.Create(request); wr.Credentials = new System.Net.NetworkCredential("AnonymousUser", ""); wr.Method = "GET"; wr.PreAuthenticate = true; string data; var response = (HttpWebResponse)wr.GetResponse(); using (var sr = new StreamReader(response.GetResponseStream())) { data = sr.ReadToEnd(); } co = (new JavaScriptSerializer()).Deserialize <vwar.service.host.Metadata>(data); } catch (System.Net.WebException ex) { System.Net.WebRequest wr = WebRequest.Create(ex.Response.ResponseUri); wr.Credentials = new System.Net.NetworkCredential("AnonymousUser", ""); wr.Method = "GET"; wr.PreAuthenticate = true; string data; var response = (HttpWebResponse)wr.GetResponse(); using (var sr = new StreamReader(response.GetResponseStream())) { data = sr.ReadToEnd(); } co = (new JavaScriptSerializer()).Deserialize <vwar.service.host.Metadata>(data); } LoginToDlLabel.Visible = false; //model screenshot if (co != null) { if ("Model".Equals(co.AssetType, StringComparison.InvariantCultureIgnoreCase) || true) { //if the content object file is null, dont' try to display // if (co.DisplayFile != string.Empty && co.Location != string.Empty && Permission > ModelPermissionLevel.Searchable) // { // Page.ClientScript.RegisterClientScriptBlock(GetType(), "vload", string.Format("vLoader = new ViewerLoader('{0}', '{1}', '{2}', '{3}', {4});", Page.ResolveClientUrl("~/Public/Serve.ashx?mode=PreviewModel"), // (co.UpAxis != null) ? co.UpAxis : "", // (co.UnitScale != null) ? co.UnitScale : "", co.NumPolygons, "\"" + co.PID.Replace(':','_') + "\""), true); // BodyTag.Attributes["onunload"] += "vLoader.DestroyViewer();"; // } ScreenshotImage.ImageUrl = "http://3dr.adlnet.gov/Federation/3DR_Federation.svc/" + Request.QueryString["ContentObjectID"] + "/Screenshot?ID=00-00-00"; } AddHeaderTag("link", "og:image", ScreenshotImage.ImageUrl); } else if ("Texture".Equals(co.AssetType, StringComparison.InvariantCultureIgnoreCase)) { ScreenshotImage.ImageUrl = "http://3dr.adlnet.gov/Federation/3DR_Federation.svc/" + Request.QueryString["ContentObjectID"] + "/Screenshot?ID=00-00-00"; } TitleLabel.Text = co.Title; AddHeaderTag("meta", "og:title", co.Title); //show hide edit link LoginToDlLabel.Visible = false; vwar.service.host.Review[] reviews = null; try { String request = "http://3dr.adlnet.gov/Federation/3DR_Federation.svc/" + Request.QueryString["ContentObjectID"] + "/Reviews/json?ID=00-00-00"; System.Net.WebRequest wr = WebRequest.Create(request); wr.Credentials = new System.Net.NetworkCredential("AnonymousUser", ""); wr.Method = "GET"; wr.PreAuthenticate = true; wr.GetResponse().ToString(); var response = (HttpWebResponse)wr.GetResponse(); string data; using (var sr = new StreamReader(response.GetResponseStream())) { data = sr.ReadToEnd(); } reviews = (new JavaScriptSerializer()).Deserialize <vwar.service.host.Review[]>(data); } catch (System.Net.WebException ex) { System.Net.WebRequest wr = WebRequest.Create(ex.Response.ResponseUri); wr.Credentials = new System.Net.NetworkCredential("AnonymousUser", ""); wr.Method = "GET"; wr.PreAuthenticate = true; wr.GetResponse().ToString(); var response = (HttpWebResponse)wr.GetResponse(); string data; using (var sr = new StreamReader(response.GetResponseStream())) { data = sr.ReadToEnd(); } reviews = (new JavaScriptSerializer()).Deserialize <vwar.service.host.Review[]>(data); } //rating int rating = 0; foreach (var review in reviews) { rating += review.Rating; } if (reviews.Count() > 0) { rating = rating / reviews.Count(); } ir.CurrentRating = rating; //description DescriptionLabel.Text = String.IsNullOrEmpty(co.Description) ? "No description available." : co.Description; AddHeaderTag("meta", "og:description", co.Description); upAxis.Value = co.UpAxis; unitScale.Value = co.UnitScale; //keywords var keywordsList = string.IsNullOrEmpty(co.Keywords) ? new String[0] : co.Keywords.Split(new char[] { ',' }); foreach (var keyword in keywordsList) { HyperLink link = new HyperLink() { Text = keyword, NavigateUrl = "~/Public/FederationResults.aspx?SearchTerms=" + Server.UrlEncode(keyword.Trim()), CssClass = "Hyperlink" }; keywords.Controls.Add(link); keywords.Controls.Add(new LiteralControl(" ")); } this.keywordLabel.Visible = !string.IsNullOrEmpty(co.Keywords); //more details this.MoreDetailsHyperLink.NavigateUrl = co.MoreInformationURL; this.MoreDetailsHyperLink.Text = co.MoreInformationURL; this.MoreDetailsRow.Visible = !string.IsNullOrEmpty(co.MoreInformationURL); string submitterFullName = Website.Common.GetFullUserName(co.DeveloperName); if (co.UploadedDate != null) { UploadedDateLabel.Text = "Uploaded by: " + submitterFullName + " on " + co.UploadedDate.ToString(); } this.SponsorLogoImage.ImageUrl = "http://3dr.adlnet.gov/Federation/3DR_Federation.svc/" + Request.QueryString["ContentObjectID"] + "/SponsorLogo?ID=00-00-00"; this.SponsorLogoRow.Visible = true; this.SponsorNameLabel.Text = co.SponsorName; this.SponsorNameRow.Visible = !string.IsNullOrEmpty(co.SponsorName); this.DeveloperLogoImage.ImageUrl = "http://3dr.adlnet.gov/Federation/3DR_Federation.svc/" + Request.QueryString["ContentObjectID"] + "/DeveloperLogo?ID=00-00-00"; //developer name this.DeveloperNameHyperLink.NavigateUrl = "~/Public/FederationResults.aspx?SearchTerms=" + Server.UrlEncode(co.DeveloperName); this.DeveloperNameHyperLink.Text = co.DeveloperName; if (String.IsNullOrEmpty(co.ArtistName)) { this.ArtistRow.Visible = false; } else { this.ArtistNameHyperLink.NavigateUrl = "~/Public/FederationResults.aspx?SearchTerms=" + Server.UrlEncode(co.ArtistName); this.ArtistNameHyperLink.Text = co.ArtistName; } this.DeveloperRow.Visible = !string.IsNullOrEmpty(co.DeveloperName); this.FormatLabel.Text = "Native format: " + ((string.IsNullOrEmpty(co.Format)) ? "Unknown" : co.Format); //num polygons this.NumPolygonsLabel.Text = co.NumPolygons.ToString(); this.NumPolygonsRow.Visible = !string.IsNullOrEmpty(co.NumPolygons.ToString()); //num textures this.NumTexturesLabel.Text = co.NumTextures.ToString(); this.NumTexturesRow.Visible = !string.IsNullOrEmpty(co.NumTextures.ToString()); //cclrow this.CCLHyperLink.Visible = !string.IsNullOrEmpty(co.License); this.CCLHyperLink.NavigateUrl = co.License; if (!string.IsNullOrEmpty(co.License)) { switch (co.License.ToLower().Trim()) { case "http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode": this.CCLHyperLink.ImageUrl = "http://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png"; this.CCLHyperLink.ToolTip = "by-nc-sa"; break; case "http://creativecommons.org/licenses/by-nc-nd/3.0/legalcode": this.CCLHyperLink.ImageUrl = "http://i.creativecommons.org/l/by-nc-nd/3.0/88x31.png"; this.CCLHyperLink.ToolTip = "by-nc-nd"; break; case "http://creativecommons.org/licenses/by-nc/3.0/legalcode": this.CCLHyperLink.ImageUrl = "http://i.creativecommons.org/l/by-nc/3.0/88x31.png"; this.CCLHyperLink.ToolTip = "by-nc"; break; case "http://creativecommons.org/licenses/by-nd/3.0/legalcode": this.CCLHyperLink.ImageUrl = "http://i.creativecommons.org/l/by-nd/3.0/88x31.png"; this.CCLHyperLink.ToolTip = "by-nd"; break; case "http://creativecommons.org/licenses/by-sa/3.0/legalcode": this.CCLHyperLink.ImageUrl = "http://i.creativecommons.org/l/by-sa/3.0/88x31.png"; this.CCLHyperLink.ToolTip = "by-sa"; break; case "http://creativecommons.org/publicdomain/mark/1.0/": this.CCLHyperLink.ImageUrl = "http://i.creativecommons.org/l/publicdomain/88x31.png"; this.CCLHyperLink.ToolTip = "Public Domain"; break; case "http://creativecommons.org/licenses/by/3.0/legalcode": this.CCLHyperLink.ImageUrl = "http://i.creativecommons.org/l/by/3.0/88x31.png"; this.CCLHyperLink.ToolTip = "by"; break; } } //downloads DownloadsLabel.Text = co.Downloads.ToString(); this.DownloadsRow.Visible = !string.IsNullOrEmpty(co.Downloads.ToString()); //views ViewsLabel.Text = co.Views.ToString(); this.ViewsRow.Visible = !string.IsNullOrEmpty(co.Views.ToString()); //download buton //this.DownloadButton.Visible = Context.User.Identity.IsAuthenticated; this.CommentsGridView.DataSource = reviews; this.CommentsGridView.DataBind(); }
private void btnUpload_Click(object sender, EventArgs e) { foreach(TempMetadata tmp in lstFiles.CheckedItems) { if (tmp != null && File.Exists(tmp.ModelLocation)) { _3DRAPI_Imp api = new _3DRAPI_Imp(true); Metadata md = new Metadata { License = tmp.License, Title = tmp.Title, Description = tmp.Description, AssetType = "Model" }; var pid = api.InsertMetadata(md); using (FileStream modelStream = new FileStream(tmp.ModelLocation, FileMode.Open)) { byte[] data = new byte[modelStream.Length]; modelStream.Read(data, 0, data.Length); api.UploadFile(data, pid); } if (File.Exists(tmp.ScreenshotLocation)) { using (FileStream modelStream = new FileStream(tmp.ScreenshotLocation, FileMode.Open)) { byte[] data = new byte[modelStream.Length]; modelStream.Read(data, 0, data.Length); api.UploadScreenShot(data, pid, Path.GetFileName(tmp.ScreenshotLocation)); } } } } if (Complete != null) { Complete(this, new EventArgs()); } }
private static void CopyContentObjectData(Metadata md, vwarDAL.ContentObject co) { //Copy the data from the input object co.Title = md.Title; co.Keywords = md.Keywords; co.Format = md.Format; //co.CreativeCommonsLicenseURL = md.License; //Need to add logic to change values of texture references co.DeveloperName = md.DeveloperName; co.Description = md.Description; co.ArtistName = md.ArtistName; co.AssetType = md.AssetType; co.NumPolygons = System.Convert.ToInt32(md.NumPolygons); co.NumTextures = System.Convert.ToInt32(md.NumTextures); co.SponsorName = md.SponsorName; co.CreativeCommonsLicenseURL = md.License; co.Distribution_Contolling_Office = md.Distribution_Contolling_Office; co.Distribution_Determination_Date = DateTime.Parse(md.Distribution_Determination_Date); co.Distribution_Grade = (vwarDAL.DistributionGrade)Enum.Parse(typeof(vwarDAL.DistributionGrade), md.Distribution_Grade); co.Distribution_Reason = md.Distribution_Reason; co.Distribution_Regulation = co.Distribution_Regulation; co.UnitScale = md.UnitScale; co.UpAxis = md.UpAxis; co.RequireResubmit = md.RequiresResubmit; co.MoreInformationURL = md.MoreInformationURL; }
//Get the metadata object for a conten object public Metadata GetMetadata(string pid, string key) { if (!CheckKey(key)) return null; try { //Metadata to return Metadata map = new Metadata(); pid = pid.Replace('_', ':'); //Get the content object vwarDAL.PermissionsManager perm = new vwarDAL.PermissionsManager(); vwarDAL.ModelPermissionLevel plevel = perm.GetPermissionLevel(vwarDAL.DefaultUsers.Anonymous[0], pid); perm.Dispose(); //Check the permissions if (!DoValidate(Security.TransactionType.Query, pid)) { ReleaseRepo(); return null; } //removing to deal with stale issues when the GUI is used to update metadata. Metadata fromcache = null;// CacheManager.CheckCache<Metadata>(new CacheIdentifier(pid, "", CacheIdentifier.FILETYPE.METADATA)); if (fromcache != null) return fromcache; vwarDAL.ContentObject co = GetRepo().GetContentObjectById(pid, false); //If there is no location, dont return data if (co.Location != "") { map.ConversionAvailable = co.DisplayFileId != "" && co.DisplayFileId != null; map.AnonymousDownloadAvailable = plevel >= vwarDAL.ModelPermissionLevel.Fetchable; map.PID = co.PID; map.Title = co.Title; map.Keywords = co.Keywords; map.Format = co.Format; map.Downloads = co.Downloads.ToString(); map.DeveloperName = co.DeveloperName; map.Description = co.Description; map.ArtistName = co.ArtistName; map.AssetType = co.AssetType; map.NumPolygons = co.NumPolygons.ToString(); map.NumTextures = co.NumTextures.ToString(); map.SponsorName = co.SponsorName; map.UnitScale = co.UnitScale; map.UpAxis = co.UpAxis; map.UploadedDate = co.UploadedDate.ToString(); map.Views = co.Views.ToString(); map.Revision = co.Revision.ToString(); map.TotalRevisions = co.NumberOfRevisions.ToString(); map.MoreInformationURL = co.MoreInformationURL; map.License = co.CreativeCommonsLicenseURL; map.Distribution_Contolling_Office = co.Distribution_Contolling_Office; map.Distribution_Determination_Date = co.Distribution_Determination_Date.ToShortDateString(); map.Distribution_Grade = Enum.GetName(typeof(vwarDAL.DistributionGrade), co.Distribution_Grade); map.Distribution_Reason = co.Distribution_Reason; map.Distribution_Regulation = co.Distribution_Regulation; map.RequiresResubmit = co.RequireResubmit; // map.License = co.CreativeCommonsLicenseURL; //Get the supporting files, and copy to a serializable class map.SupportingFiles = new List<SupportingFile>(); foreach (vwarDAL.SupportingFile i in co.SupportingFiles) { SupportingFile f2 = new SupportingFile(); f2.Filename = i.Filename; f2.Description = i.Description; map.SupportingFiles.Add(f2); } //Get the texture references and copy to a serializable class map.TextureReferences = new List<Texture>(); foreach (vwarDAL.Texture i in co.TextureReferences) { Texture f2 = new Texture(); f2.mFilename = i.mFilename; f2.mType = i.mType; f2.mUVSet = i.mUVSet; map.TextureReferences.Add(f2); } //Get the missing textures, and copy to a serializable class map.MissingTextures = new List<Texture>(); foreach (vwarDAL.Texture i in co.MissingTextures) { Texture f2 = new Texture(); f2.mFilename = i.mFilename; f2.mType = i.mType; f2.mUVSet = i.mUVSet; map.MissingTextures.Add(f2); } CacheManager.Cache<Metadata>(ref map, new CacheIdentifier(pid, "", CacheIdentifier.FILETYPE.METADATA)); } //Return the data ReleaseRepo(); return map; } catch (Exception ex) { return new Metadata { Title = ex.Message }; } ReleaseRepo(); return new Metadata { Title = "got here" }; }
public string UpdateMetadata(Metadata md, string pid, string key) { if (!CheckKey(key)) return null; pid = pid.Replace('_', ':'); //Get the content object vwarDAL.ContentObject co = GetRepo().GetContentObjectById(pid, false); //Check permissions if (!DoValidate(Security.TransactionType.Modify, pid)) { ReleaseRepo(); return null; } CacheManager.ExpireCache(new CacheIdentifier(pid,"",CacheIdentifier.FILETYPE.METADATA)); CopyContentObjectData(md, co); //Make sure these changes get written back to repository co.CommitChanges(); ReleaseRepo(); return "Ok"; }
public string InsertMetadata(Metadata md) { vwarDAL.ContentObject co = new vwarDAL.ContentObject(GetRepo()); CopyContentObjectData(md, co); GetRepo().InsertContentObject(co); ReleaseRepo(); return co.PID; }
public string UpdateMetadata(Metadata md, string pid, string key) { if (!CheckKey(key)) return null; pid = pid.Replace('_', ':'); //Get the content object vwarDAL.ContentObject co = GetRepo().GetContentObjectById(pid, false); //Check permissions if (!DoValidate(Security.TransactionType.Modify, co)) { ReleaseRepo(); return null; } CopyContentObjectData(md, co); //Make sure these changes get written back to repository co.CommitChanges(); ReleaseRepo(); return ""; }
//Get the metadata object for a conten object public Metadata GetMetadata(string pid, string key) { if (!CheckKey(key)) return null; try { //Metadata to return Metadata map = new Metadata(); pid = pid.Replace('_', ':'); //Get the content object vwarDAL.ContentObject co = GetRepo().GetContentObjectById(pid, false); vwarDAL.PermissionsManager perm = new vwarDAL.PermissionsManager(); vwarDAL.ModelPermissionLevel plevel = perm.GetPermissionLevel(vwarDAL.DefaultUsers.Anonymous[0], co.PID); perm.Dispose(); //Check the permissions if (!DoValidate(Security.TransactionType.Query, co)) { ReleaseRepo(); return null; } //If there is no location, dont return data if (co.Location != "") { map.ConversionAvailable = co.DisplayFileId != "" && co.DisplayFileId != null; map.AnonymousDownloadAvailable = plevel >= vwarDAL.ModelPermissionLevel.Fetchable; map.PID = co.PID; map.Title = co.Title; map.Keywords = co.Keywords; map.Format = co.Format; map.Downloads = co.Downloads.ToString(); map.DeveloperName = co.DeveloperName; map.Description = co.Description; map.ArtistName = co.ArtistName; map.AssetType = co.AssetType; map.NumPolygons = co.NumPolygons.ToString(); map.NumTextures = co.NumTextures.ToString(); map.SponsorName = co.SponsorName; map.UnitScale = co.UnitScale; map.UpAxis = co.UpAxis; map.UploadedDate = co.UploadedDate.ToString(); map.Views = co.Views.ToString(); map.Revision = co.Revision.ToString(); map.TotalRevisions = co.NumberOfRevisions.ToString(); map.MoreInformationURL = co.MoreInformationURL; map.License = co.CreativeCommonsLicenseURL; // map.License = co.CreativeCommonsLicenseURL; //Get the supporting files, and copy to a serializable class map.SupportingFiles = new List<SupportingFile>(); foreach (vwarDAL.SupportingFile i in co.SupportingFiles) { SupportingFile f2 = new SupportingFile(); f2.Filename = i.Filename; f2.Description = i.Description; map.SupportingFiles.Add(f2); } //Get the texture references and copy to a serializable class map.TextureReferences = new List<Texture>(); foreach (vwarDAL.Texture i in co.TextureReferences) { Texture f2 = new Texture(); f2.mFilename = i.mFilename; f2.mType = i.mType; f2.mUVSet = i.mUVSet; map.TextureReferences.Add(f2); } //Get the missing textures, and copy to a serializable class map.MissingTextures = new List<Texture>(); foreach (vwarDAL.Texture i in co.MissingTextures) { Texture f2 = new Texture(); f2.mFilename = i.mFilename; f2.mType = i.mType; f2.mUVSet = i.mUVSet; map.MissingTextures.Add(f2); } } //Return the data ReleaseRepo(); return map; } catch (Exception ex) { return new Metadata { Title = ex.Message }; } ReleaseRepo(); return new Metadata { Title = "got here" }; }
private static void CopyContentObjectData(Metadata md, vwarDAL.ContentObject co) { //Copy the data from the input object co.Title = md.Title; co.Keywords = md.Keywords; co.Format = md.Format; //co.CreativeCommonsLicenseURL = md.License; //Need to add logic to change values of texture references co.DeveloperName = md.DeveloperName; co.Description = md.Description; co.ArtistName = md.ArtistName; co.AssetType = md.AssetType; co.NumPolygons = System.Convert.ToInt32(md.NumPolygons); co.NumTextures = System.Convert.ToInt32(md.NumTextures); co.SponsorName = md.SponsorName; co.UnitScale = md.UnitScale; co.UpAxis = md.UpAxis; co.MoreInformationURL = md.MoreInformationURL; }