private void button1_Click(object sender, RoutedEventArgs e) { ContentObject co = new ContentObject(); co.PID = "adl:1"; co.SubmitterEmail = "*****@*****.**"; co.Keywords = "test,boat,model,gun"; string result = LR_3DR_Bridge.ModelUploadedInternal(co); }
public string Publish() { System.Net.ServicePoint point = System.Net.ServicePointManager.FindServicePoint(new Uri(LR_3DR_Bridge.LR_Integration_PublishURL()));; System.Net.ServicePointManager.CertificatePolicy = new AcceptAllCerts(); System.Net.WebClient wc = new System.Net.WebClient(); wc.Credentials = new System.Net.NetworkCredential(LR_3DR_Bridge.LR_Integration_NodeUsername(), LR_3DR_Bridge.LR_Integration_NodePassword()); string result = wc.UploadString(LR_3DR_Bridge.LR_Integration_PublishURL(), Serialize()); return(result); }
public static void DownloadButton_Click_Impl(string format, string ContentObjectID) { var factory = new DataAccessFactory(); IDataRepository vd = factory.CreateDataRepositorProxy(); var co = vd.GetContentObjectById(ContentObjectID, false); if (LR_3DR_Bridge.LR_Integration_Enabled()) { LR_3DR_Bridge.ModelDownloaded(co); } vd.IncrementDownloads(ContentObjectID); try { if (String.IsNullOrEmpty(format)) { string clientFileName = (!String.IsNullOrEmpty(co.OriginalFileName)) ? co.OriginalFileName : co.Location; var data = vd.GetContentFile(co.PID, clientFileName); Website.Documents.ServeDocument(data, clientFileName); } else { var data = vd.GetContentFile(co.PID, co.Location); if (format == ".dae") { Website.Documents.ServeDocument(data, co.Location); } else if (format != ".O3Dtgz") { Website.Documents.ServeDocument(data, co.Location, null, format); } else { var displayFile = vd.GetContentFile(co.PID, co.DisplayFile); Website.Documents.ServeDocument(displayFile, co.DisplayFile); } } } catch (System.Threading.ThreadAbortException tabexc) { } catch (Exception f) { } vd.Dispose(); }
protected void Rating_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(ratingText.Text)) { vwarDAL.IDataRepository vd = (new vwarDAL.DataAccessFactory()).CreateDataRepositorProxy();; var ratingValue = rating.CurrentRating; vd.InsertReview(ratingValue, ratingText.Text.Length > 255 ? ratingText.Text.Substring(0, 255) : ratingText.Text, Context.User.Identity.Name, ContentObjectID); ViewState[RATINGKEY] = null; Response.Redirect(Request.RawUrl); ContentObject co = vd.GetContentObjectById(ContentObjectID, false); if (LR_3DR_Bridge.LR_Integration_Enabled()) { LR_3DR_Bridge.ModelRated(co); } vd.Dispose(); vd = null; } }
private void DoSubmitAll() { vwarDAL.DataAccessFactory df = new DataAccessFactory(); vwarDAL.IDataRepository dal = df.CreateDataRepositorProxy(); IEnumerable <ContentObject> objects = dal.GetAllContentObjects(); int total = 0; int current = 0; foreach (ContentObject co in objects) { total++; } progressBar1.Maximum = total; progressBar2.Maximum = 4; foreach (ContentObject co in objects) { current++; progressBar1.Value = current; progressBar2.Value = 0; AllowUIToUpdate(); textBlock1.Text = LR_3DR_Bridge.ModelDownloadedInternal(co); progressBar2.Value = 1; AllowUIToUpdate(); ContentObject co2 = dal.GetContentObjectById(co.PID, false, true); textBlock1.Text = LR_3DR_Bridge.ModelRatedInternal(co2); progressBar2.Value = 2; AllowUIToUpdate(); textBlock1.Text = LR_3DR_Bridge.ModelUploadedInternal(co); progressBar2.Value = 3; AllowUIToUpdate(); textBlock1.Text = LR_3DR_Bridge.ModelViewedInternal(co); progressBar2.Value = 4; AllowUIToUpdate(); } }
public static string SubmitUpload(string DeveloperName, string ArtistName, string DeveloperUrl, string SponsorName, string LicenseType, bool RequireResubmit) { HttpServerUtility server = HttpContext.Current.Server; ContentObject tempCO = (ContentObject)HttpContext.Current.Session["contentObject"]; try { FileStatus status = (FileStatus)HttpContext.Current.Session["fileStatus"]; var factory = new DataAccessFactory(); IDataRepository dal = factory.CreateDataRepositorProxy(); dal.InsertContentObject(tempCO); tempCO.DeveloperName = server.HtmlEncode(DeveloperName); tempCO.ArtistName = server.HtmlEncode(ArtistName); tempCO.MoreInformationURL = server.HtmlEncode(DeveloperUrl); tempCO.RequireResubmit = RequireResubmit; tempCO.SponsorName = server.HtmlEncode(SponsorName); vwarDAL.PermissionsManager perMgr = new PermissionsManager(); var groupSetReturnCode = perMgr.SetModelToGroupLevel(HttpContext.Current.User.Identity.Name, tempCO.PID, vwarDAL.DefaultGroups.AllUsers, ModelPermissionLevel.Fetchable); groupSetReturnCode = perMgr.SetModelToGroupLevel(HttpContext.Current.User.Identity.Name, tempCO.PID, vwarDAL.DefaultGroups.AnonymousUsers, ModelPermissionLevel.Searchable); string pid = tempCO.PID; //tempCO.SponsorURL = SponsorUrl; !missing SponsorUrl metadata in ContentObject if (LicenseType == "publicdomain") { tempCO.CreativeCommonsLicenseURL = "http://creativecommons.org/publicdomain/mark/1.0/"; } else { tempCO.CreativeCommonsLicenseURL = String.Format(ConfigurationManager.AppSettings["CCBaseUrl"], LicenseType); } //Upload the thumbnail and logos string filename = status.hashname; string basehash = filename.Substring(0, filename.LastIndexOf(".") - 1); foreach (FileInfo f in new DirectoryInfo(HttpContext.Current.Server.MapPath("~/App_Data/imageTemp")).GetFiles("*" + basehash + "*")) { using (FileStream fstream = f.OpenRead()) { string type = f.Name.Substring(0, f.Name.IndexOf('_')); switch (type) { case ImagePrefix.DEVELOPER_LOGO: tempCO.DeveloperLogoImageFileName = "developer_logo" + f.Extension; tempCO.DeveloperLogoImageFileNameId = dal.SetContentFile(fstream, tempCO.PID, tempCO.DeveloperLogoImageFileName); break; case ImagePrefix.SPONSOR_LOGO: tempCO.SponsorLogoImageFileName = "sponsor_logo" + f.Extension; tempCO.SponsorLogoImageFileNameId = dal.SetContentFile(fstream, tempCO.PID, tempCO.SponsorLogoImageFileName); break; case ImagePrefix.SCREENSHOT: tempCO.ScreenShot = "screenshot" + f.Extension; tempCO.ScreenShotId = dal.SetContentFile(fstream, tempCO.PID, tempCO.ScreenShot); System.Drawing.Imaging.ImageFormat fmt = System.Drawing.Imaging.ImageFormat.Png; if (f.Extension == ".png") { fmt = System.Drawing.Imaging.ImageFormat.Png; } else if (f.Extension == ".jpg") { fmt = System.Drawing.Imaging.ImageFormat.Jpeg; } else if (f.Extension == ".gif") { fmt = System.Drawing.Imaging.ImageFormat.Gif; } else { throw new Exception("Invalid screenshot format"); } tempCO.ThumbnailId = Website.Common.GetFileSHA1AndSalt(fstream) + f.Extension; using (FileStream outFile = new FileStream(HttpContext.Current.Server.MapPath("~/thumbnails/" + tempCO.ThumbnailId), FileMode.Create)) Website.Common.GenerateThumbnail(fstream, outFile, fmt); break; default: break; } } } string dataPath = HttpContext.Current.Server.MapPath("~/App_Data/"); if (status.type == FormatType.VIEWABLE) { //Upload the original file using (FileStream s = new FileStream(dataPath + status.hashname, FileMode.Open)) { tempCO.OriginalFileId = dal.SetContentFile(s, pid, "original_" + status.filename); tempCO.OriginalFileName = "original_" + status.filename; } using (FileStream s = new FileStream(Path.Combine(dataPath, "converterTemp/" + status.hashname.ToLower().Replace("skp", "zip")), FileMode.Open, FileAccess.Read)) { tempCO.DisplayFileId = dal.SetContentFile(s, pid, status.filename.ToLower().Replace("skp", "zip")); } using (FileStream s = new FileStream(Path.Combine(dataPath, "viewerTemp/" + status.hashname.ToLower().Replace("skp", "o3d").Replace("zip", "o3d")), FileMode.Open)) { dal.SetContentFile(s, pid, status.filename.ToLower().Replace("skp", "o3d").Replace("zip", "o3d")); } } else if (status.type == FormatType.RECOGNIZED) { using (FileStream s = new FileStream(dataPath + status.hashname, FileMode.Open)) { tempCO.OriginalFileName = "original_" + status.filename; tempCO.OriginalFileId = dal.SetContentFile(s, pid, tempCO.OriginalFileName); } } tempCO.Enabled = true; tempCO.UploadedDate = DateTime.Now; dal.UpdateContentObject(tempCO); UploadReset(status.hashname); List <string> textureReferences = HttpContext.Current.Session["contentTextures"] as List <string>; List <string> textureReferenceMissing = HttpContext.Current.Session["contentMissingTextures"] as List <string>; if (textureReferences != null) { foreach (string tex in textureReferences) { tempCO.SetParentRepo(dal); tempCO.AddTextureReference(tex, "unknown", 0); } } if (textureReferenceMissing != null) { foreach (string tex in textureReferenceMissing) { tempCO.SetParentRepo(dal); tempCO.AddMissingTexture(tex, "unknown", 0); } } if (LR_3DR_Bridge.LR_Integration_Enabled()) { LR_3DR_Bridge.ModelUploaded(tempCO); } Website.Mail.SendModelUploaded(tempCO); dal.Dispose(); perMgr.Dispose(); return(tempCO.PID); } catch (Exception e) { #if DEBUG return(String.Format("fedoraError|" + e.Message + "<br /><br />" + e.StackTrace)); #else return("fedoraError|" + ConfigurationManager.AppSettings["UploadPage_FedoraError"]); #endif } }
private void BindModelDetails() { if (String.IsNullOrEmpty(ContentObjectID)) { Response.Redirect("~/Default.aspx"); } PermissionsManager prm = new PermissionsManager(); ModelPermissionLevel Permission = prm.GetPermissionLevel(Context.User.Identity.Name, ContentObjectID); prm.Dispose(); prm = null; if (Permission < ModelPermissionLevel.Searchable) { Response.StatusCode = (int)HttpStatusCode.Unauthorized; return; } APILink.NavigateUrl = "https://" + ConfigurationManager.AppSettings["LR_Integration_APIBaseURL"] + "/" + ContentObjectID + "/Metadata/json?id=00-00-00"; var uri = Request.Url; //string proxyTemplate = "Model.ashx?pid={0}&file={1}&fileid={2}"; vwarDAL.IDataRepository vd = (new vwarDAL.DataAccessFactory()).CreateDataRepositorProxy(); vwarDAL.ContentObject co = vd.GetContentObjectById(ContentObjectID, !IsPostBack, true); vd.Dispose(); vd = null; //model screenshot if (co != null) { if (LR_3DR_Bridge.LR_Integration_Enabled()) { LR_3DR_Bridge.ModelViewed(co); } DownloadButton.Enabled = Permission >= ModelPermissionLevel.Fetchable; DownloadButton.Visible = Permission >= ModelPermissionLevel.Fetchable; 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();"; } if (String.IsNullOrWhiteSpace(co.ScreenShot) && String.IsNullOrWhiteSpace(co.ScreenShotId)) { ScreenshotImage.ImageUrl = Page.ResolveUrl("~/styles/images/nopreview_icon.png"); } else { ScreenshotImage.ImageUrl = String.Format("Serve.ashx?pid={0}&mode=GetScreenshot", co.PID); } AddHeaderTag("link", "og:image", ScreenshotImage.ImageUrl); } else if ("Texture".Equals(co.AssetType, StringComparison.InvariantCultureIgnoreCase)) { ScreenshotImage.ImageUrl = String.Format("Serve.ashx?pid={0}&mode=GetScreenshot", co.PID, co.Location); } IDLabel.Text = co.PID; TitleLabel.Text = co.Title; AddHeaderTag("meta", "og:title", co.Title); //show hide edit link if (Permission >= ModelPermissionLevel.Editable) { editLink.Visible = true; PermissionsLink.Visible = true; DeleteLink.Visible = true; //editLink.NavigateUrl = "~/Users/Edit.aspx?ContentObjectID=" + co.PID; } else { EditorButtons.Visible = false; } if (Permission >= ModelPermissionLevel.Fetchable) { //show and hide requires resubmit checkbox if (co.RequireResubmit) { RequiresResubmitCheckbox.Visible = true; RequiresResubmitCheckbox.Enabled = true; RequiresResubmitLabel.Visible = true; } submitRating.Visible = true; } else { string returnUrlParam = "?ReturnUrl=" + Page.ResolveUrl("~/Public/Model.aspx?ContentObjectID=" + co.PID); LoginLink.NavigateUrl += returnUrlParam; ReveiwLoginHyperLink.NavigateUrl += returnUrlParam; if (User.Identity.IsAuthenticated) { RequestAccessLabel.Visible = true; } else { LoginToDlLabel.Visible = true; } submitRating.Visible = false; } //rating int rating = Website.Common.CalculateAverageRating(co.Reviews); ir.CurrentRating = rating; this.NotRatedLabel.Visible = (rating == 0); //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/Results.aspx?ContentObjectID=" + ContentObjectID + "&Keywords=" + Server.UrlEncode(keyword.Trim()), CssClass = "Hyperlink" }; keywords.Controls.Add(link); keywords.Controls.Add(new LiteralControl(" ")); } //more details this.MoreDetailsHyperLink.NavigateUrl = co.MoreInformationURL; this.MoreDetailsHyperLink.Text = co.MoreInformationURL; string submitterFullName = Website.Common.GetFullUserName(co.SubmitterEmail); if (co.UploadedDate != null) { UploadedDateLabel.Text = "Uploaded by: " + submitterFullName + " on " + co.UploadedDate.ToString(); } //sponsor logo if (!string.IsNullOrEmpty(co.SponsorLogoImageFileName)) { this.SponsorLogoImage.ImageUrl = String.Format("Serve.ashx?pid={0}&mode=GetSponsorLogo", co.PID); } this.SponsorNameLabel.Text = co.SponsorName; //developr logo if (!string.IsNullOrEmpty(co.DeveloperLogoImageFileName)) { this.DeveloperLogoImage.ImageUrl = String.Format("Serve.ashx?pid={0}&mode=GetDeveloperLogo", co.PID); } //this.DeveloperLogoRow.Visible = !string.IsNullOrEmpty(co.DeveloperLogoImageFileName); //developer name this.DeveloperNameHyperLink.NavigateUrl = "~/Public/Results.aspx?ContentObjectID=" + ContentObjectID + "&DeveloperName=" + Server.UrlEncode(co.DeveloperName); this.DeveloperNameHyperLink.Text = co.DeveloperName; if (String.IsNullOrEmpty(co.ArtistName)) { } else { this.ArtistNameHyperLink.NavigateUrl = "~/Public/Results.aspx?ContentObjectID=" + ContentObjectID + "&ArtistName=" + Server.UrlEncode(co.ArtistName); this.ArtistNameHyperLink.Text = co.ArtistName; } //this.DeveloperRow.Visible = !string.IsNullOrEmpty(co.DeveloperName); this.FormatLabel.Text = ((string.IsNullOrEmpty(co.Format)) ? "Unknown" : co.Format); //num polygons this.NumPolygonsLabel.Text = co.NumPolygons.ToString(); //num textures this.NumTexturesLabel.Text = co.NumTextures.ToString(); //cclrow this.CCLHyperLink.NavigateUrl = co.CreativeCommonsLicenseURL; if (!string.IsNullOrEmpty(co.CreativeCommonsLicenseURL)) { switch (co.CreativeCommonsLicenseURL.ToLower().Trim()) { case "http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode": this.CCLHyperLink.ImageUrl = "../styles/images/by-nc-sa.png"; this.CCLHyperLink.ToolTip = "by-nc-sa"; break; case "http://creativecommons.org/licenses/by-nc-nd/3.0/legalcode": this.CCLHyperLink.ImageUrl = "../styles/images/by-nc-nd.png"; this.CCLHyperLink.ToolTip = "by-nc-nd"; break; case "http://creativecommons.org/licenses/by-nc/3.0/legalcode": this.CCLHyperLink.ImageUrl = "../styles/images/by-nc.png"; this.CCLHyperLink.ToolTip = "by-nc"; break; case "http://creativecommons.org/licenses/by-nd/3.0/legalcode": this.CCLHyperLink.ImageUrl = "../styles/images/by-nd.png"; this.CCLHyperLink.ToolTip = "by-nd"; break; case "http://creativecommons.org/licenses/by-sa/3.0/legalcode": this.CCLHyperLink.ImageUrl = "../styles/images/by-sa.png"; this.CCLHyperLink.ToolTip = "by-sa"; break; case "http://creativecommons.org/publicdomain/mark/1.0/": this.CCLHyperLink.ImageUrl = "../styles/images/publicdomain.png"; this.CCLHyperLink.ToolTip = "Public Domain"; break; case "http://creativecommons.org/licenses/by/3.0/legalcode": this.CCLHyperLink.ImageUrl = "../styles/images/by.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 = co.Reviews; this.CommentsGridView.DataBind(); //SupportingFileGrid.DataSource = co.SupportingFiles; //if(Permission < ModelPermissionLevel.Fetchable) // ((ButtonField)SupportingFileGrid.Columns[2]).ImageUrl = "../styles/images/icons/expand_disabled.jpg"; //SupportingFileGrid.DataBind(); //SupportingFileGrid.Enabled = Permission >= ModelPermissionLevel.Fetchable; EditKeywords.Text = co.Keywords; EditDistributionDeterminationDate.Text = co.Distribution_Determination_Date.ToString(); EditDistributionOffice.Text = co.Distribution_Contolling_Office; EditDistributionReasonLabel.Text = co.Distribution_Reason; EditDistributionRegulation.Text = co.Distribution_Regulation; DistributionLabel.Text = Enum.GetName(typeof(DistributionGrade), co.Distribution_Grade); DistributionStatementText.InnerText = GetDistributionText(co); } }
public void Sign(string passphrase, string keyID, string keyloc) { string data = Bencode(); string randomname = System.IO.Path.GetRandomFileName(); randomname = System.IO.Path.GetTempPath() + randomname; try { System.Security.Cryptography.SHA256 sha256 = System.Security.Cryptography.SHA256.Create(); byte[] buffer = System.Text.Encoding.UTF8.GetBytes(data); byte[] hash = sha256.ComputeHash(buffer); System.IO.StreamWriter sw = new System.IO.StreamWriter(randomname + ".json.bencoded"); sw.Write(hash); sw.Close(); string pgpfilename = LR_3DR_Bridge.LR_Integration_GPGLocation() + "gpg.exe"; string arguements; if (keyID == "") { arguements = " -b -a --passphrase-fd 0 " + "\"" + randomname + ".json.bencoded" + "\""; } else { arguements = "--default-key " + keyID + " -b -a --passphrase-fd 0 " + "\"" + randomname + ".json.bencoded" + "\""; } System.Diagnostics.ProcessStartInfo sfi = new System.Diagnostics.ProcessStartInfo(pgpfilename, arguements); sfi.RedirectStandardInput = true; sfi.CreateNoWindow = true; sfi.UseShellExecute = false; System.Diagnostics.Process p = System.Diagnostics.Process.Start(sfi); p.StandardInput.WriteLine(passphrase); p.WaitForExit(); if (p.ExitCode != 0) { throw new Exception("GPG.exe returned code " + p.ExitCode.ToString()); } System.IO.StreamReader sr = new System.IO.StreamReader(randomname + ".json.bencoded.asc"); string sig = sr.ReadToEnd(); sr.Close(); System.IO.File.Delete(randomname + ".json.bencoded.asc"); System.IO.File.Delete(randomname + ".json.bencoded"); digital_signature = new lr_digital_signature(); digital_signature.key_location.Add(keyloc); digital_signature.signature = sig; digital_signature.signing_method = new lr_signing_method.LR_PGP10(); } catch (Exception e) { try { System.IO.File.Delete(randomname + ".json.bencoded.asc"); } catch (Exception j) { } try { System.IO.File.Delete(randomname + ".json.bencoded"); } catch (Exception j) { } throw e; } }