/// <summary> /// /// </summary> /// <param name="PID"></param> /// <returns></returns> public static Utility_3D.ConvertedModel GetAndConvertModel(String PID) { Utility_3D.ConverterOptions opts = (Utility_3D.ConverterOptions)HttpContext.Current.Session["options"]; string NewModelFormat = (string)HttpContext.Current.Session["format"]; DataAccessFactory factory = new vwarDAL.DataAccessFactory(); vwarDAL.IDataRepository vd = factory.CreateDataRepositorProxy(); ContentObject co = vd.GetContentObjectById(PID, false, false); byte[] filedata = vd.GetContentFileData(PID, co.Location); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.AppendHeader("content-disposition", "attachment; filename=" + co.Location); HttpContext.Current.Response.ContentType = vwarDAL.DataUtils.GetMimeType(co.Location); Utility_3D _3d = new Utility_3D(); _3d.Initialize(Website.Config.ConversionLibarayLocation); Utility_3D.Model_Packager pack = new Utility_3D.Model_Packager(); Utility_3D.ConvertedModel model = pack.Convert(new System.IO.MemoryStream(filedata), "temp.zip", NewModelFormat, opts); vd.Dispose(); return(model); }
protected void ValidationViewSubmitButton_Click(object sender, EventArgs e) { /* if (this.FedoraContentObject == null || String.IsNullOrEmpty(this.FedoraContentObject.PID)) * { * FedoraContentObject = DAL.GetContentObjectById(ContentObjectID, false, false); ; * }*/ vwarDAL.IDataRepository dal = (new vwarDAL.DataAccessFactory()).CreateDataRepositorProxy();; FedoraContentObject = dal.GetContentObjectById(ContentObjectID, false, false); if (!string.IsNullOrEmpty(this.UnitScaleTextBox.Text)) { this.FedoraContentObject.UnitScale = this.UnitScaleTextBox.Text.Trim(); } this.FedoraContentObject.UpAxis = this.UpAxisRadioButtonList.SelectedValue.Trim(); //polygons int numPolys = 0; if (int.TryParse(NumPolygonsTextBox.Text, out numPolys)) { FedoraContentObject.NumPolygons = numPolys; } int numTextures = 0; if (int.TryParse(NumTexturesTextBox.Text, out numTextures)) { FedoraContentObject.NumTextures = numTextures; } FedoraContentObject.Enabled = true; dal.UpdateContentObject(this.FedoraContentObject); //redirect Response.Redirect(Website.Pages.Types.FormatModel(this.ContentObjectID)); dal.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(); } }
protected void Page_Load(object sender, EventArgs e) { //maintain scroll position if (this.Page.Master.FindControl("SearchPanel") != null) { //hide the search panel this.Page.Master.FindControl("SearchPanel").Visible = false; } try { FedoraContentObject = CachedFedoraContentObject; } catch { if (!String.IsNullOrEmpty(ContentObjectID)) { vwarDAL.IDataRepository vd = (new vwarDAL.DataAccessFactory()).CreateDataRepositorProxy(); FedoraContentObject = vd.GetContentObjectById(ContentObjectID, false); vd.Dispose(); } } //redirect if user is not authenticated if (!Context.User.Identity.IsAuthenticated) { Response.Redirect(Website.Pages.Types.Default); } if (!Page.IsPostBack) { IsNew = true; var id = ContentObjectID; this.MultiView1.ActiveViewIndex = 0; this.BindCCLHyperLink(); this.BindContentObject(); ContentFileUploadRequiredFieldValidator.Enabled = IsNew; } }
protected void MissingTextureViewNextButton_Click(object sender, EventArgs e) { //get a reference to the model Utility_3D.ConvertedModel model = null;// GetModel(); foreach (Control c in MissingTextureArea.Controls) { if (c is Controls_MissingTextures) { //loop over each dialog and find out if the user uploaded a file Utility_3D.Model_Packager pack = new Utility_3D.Model_Packager(); var uploadfile = (Controls_MissingTextures)c; //if they uploaded a file, push the file and model into the dll which will add the file if (uploadfile.FileName != "") { pack.AddTextureToModel(ref model, uploadfile.FileContent, uploadfile.FileName); } } } //save the changes to the model //SetModel(model); //Get the DAL vwarDAL.IDataRepository dal = (new vwarDAL.DataAccessFactory()).CreateDataRepositorProxy();; //Get the content object for this model ContentObject contentObj = dal.GetContentObjectById(ContentObjectID, false); using (MemoryStream stream = new MemoryStream()) { //upload the modified datastream to the dal stream.Write(model.data, 0, model.data.Length); stream.Seek(0, SeekOrigin.Begin); dal.SetContentFile(stream, contentObj, contentObj.Location); } this.MultiView1.SetActiveView(this.ValidationView); dal.Dispose(); }
public static JsonWrappers.AdvancedDownloadPreviewSettings ViewButton_Click(string PID, bool bConvert, bool bConvertTextures, bool bResizeTextures, bool bReducePolys, string NewModelFormat, string NewTextureFormat, int NewTextureSize, float PolygonThresh, bool Smoothing, bool IgnoreBoundry, float MaxError, float MaxEdgeLength, string mode) { if (!bConvert) { NewModelFormat = ".dae"; } Utility_3D.ConverterOptions opts = new Utility_3D.ConverterOptions(); if (bConvertTextures) { opts.EnableTextureConversion(NewTextureFormat); } if (bResizeTextures) { opts.EnableScaleTextures(NewTextureSize); } if (bReducePolys) { opts.EnablePolygonReduction(PolygonThresh); } opts.SetPolygonReductionSmoothing(Smoothing); opts.SetPolygonReductionMaxLength(MaxEdgeLength); opts.SetPolygonReductionMaxError(MaxError); if (mode == "Simple") { opts.SetPolygonReductionModeSimple(); } else { opts.SetPolygonReductionModeComplex(); } HttpContext.Current.Session["options"] = opts; HttpContext.Current.Session["format"] = NewModelFormat; // string PID = HttpContext.Current.Request.QueryString["ContentObjectID"]; DataAccessFactory factory = new vwarDAL.DataAccessFactory(); vwarDAL.IDataRepository vd = factory.CreateDataRepositorProxy(); ContentObject co = vd.GetContentObjectById(PID, false, false); JsonWrappers.AdvancedDownloadPreviewSettings jsReturnParams = new JsonWrappers.AdvancedDownloadPreviewSettings(); jsReturnParams.FlashLocation = co.Location; Utils.FileStatus currentStatus = new Utils.FileStatus("", Utils.FormatType.UNRECOGNIZED); //tempFedoraCO.DisplayFile = currentStatus.filename.Replace("zip", "o3d").Replace("skp", "o3d"); currentStatus.filename = co.Location; currentStatus.hashname = co.Location; jsReturnParams.IsViewable = true; jsReturnParams.BasePath = "../Public/"; jsReturnParams.BaseContentUrl = "Model.ashx?temp=true&file="; jsReturnParams.O3DLocation = currentStatus.hashname.ToLower().Replace("zip", "o3d").Replace("skp", "o3d"); jsReturnParams.FlashLocation = currentStatus.hashname; jsReturnParams.ShowScreenshot = true; jsReturnParams.UpAxis = co.UpAxis; jsReturnParams.UnitScale = co.UnitScale; string optionalPath = (co.Location.LastIndexOf("o3d", StringComparison.CurrentCultureIgnoreCase) != -1) ? "viewerTemp/" : "converterTemp/"; string pathToTempFile = "~/App_Data/" + optionalPath + co.Location; using (FileStream stream = new FileStream(HttpContext.Current.Server.MapPath(pathToTempFile), FileMode.Create, FileAccess.Write)) { Utility_3D.ConvertedModel model = GetAndConvertModel(PID); byte[] data = model.data; Utility_3D.ConvertedModel model2 = (new Utility_3D.Model_Packager()).Convert(new MemoryStream(model.data), "test.zip"); jsReturnParams.Polygons = model2._ModelData.VertexCount.Polys; stream.Write(data, 0, data.Length); stream.Close(); } HttpContext.Current.Session["contentObject"] = co; vd.Dispose(); return(jsReturnParams); // HttpContext.Current.Response.BinaryWrite(GetAndConvertModel().data); }
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); } }