public CreateDataRepositorProxy ( ) : IDataRepository | ||
Результат | IDataRepository |
public static string DeleteModel(string pid) { pid = HttpContext.Current.Server.UrlDecode(pid); string response = "0"; var factory = new DataAccessFactory(); IDataRepository dal = factory.CreateDataRepositorProxy(); ContentObject co = dal.GetContentObjectById(pid, false); if (co != null && HttpContext.Current.User.Identity.IsAuthenticated && (co.SubmitterEmail.Equals(HttpContext.Current.User.Identity.Name, StringComparison.InvariantCultureIgnoreCase) || Website.Security.IsAdministrator())) { try { dal.DeleteContentObject(co); response = "1"; } catch { } } else if (!HttpContext.Current.User.Identity.IsAuthenticated) { HttpContext.Current.Response.StatusCode = 403; } dal.Dispose(); return response; }
/// <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); }
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(); } }
/// <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; }
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 } }
public static JsonWrappers.UploadDetailDefaults Step2_Submit(string ScaleValue, string UpAxis) { HttpContext context = HttpContext.Current; HttpServerUtility server = context.Server; FileStatus currentStatus = (FileStatus)context.Session["fileStatus"]; var factory = new DataAccessFactory(); IDataRepository dal = factory.CreateDataRepositorProxy(); ContentObject tempCO = (ContentObject)context.Session["contentObject"]; tempCO.UpAxis = server.HtmlEncode(UpAxis); tempCO.UnitScale = server.HtmlEncode(ScaleValue); //dal.UpdateContentObject(tempCO); context.Session["contentObject"] = tempCO; //Bind the JsonWrappers.UploadDetailDefaults jsReturnParams = new JsonWrappers.UploadDetailDefaults(); if (HttpContext.Current.User.Identity.IsAuthenticated) { UserProfile p = null; try { p = UserProfileDB.GetUserProfileByUserName(context.User.Identity.Name); } catch { } if (p != null) { jsReturnParams.HasDefaults = true; jsReturnParams.DeveloperName = p.DeveloperName; jsReturnParams.ArtistName = p.ArtistName; jsReturnParams.DeveloperUrl = p.WebsiteURL; jsReturnParams.SponsorName = p.SponsorName; string tempImagePath = context.Server.MapPath("~/App_Data/imageTemp/"); if (p.DeveloperLogo != null) { string extension = p.DeveloperLogoContentType.Substring(p.DeveloperLogoContentType.LastIndexOf("/") + 1); string tempDevLogoFilename = "devlogo_" + currentStatus.hashname.Replace("zip", extension); using (FileStream stream = new FileStream(tempImagePath + tempDevLogoFilename, FileMode.Create)) { stream.Write(p.DeveloperLogo, 0, p.DeveloperLogo.Length); } jsReturnParams.DeveloperLogoFilename = tempDevLogoFilename; } if (p.SponsorLogo != null) { string extension = p.SponsorLogoContentType.Substring(p.SponsorLogoContentType.LastIndexOf("/") + 1); string tempSponsorLogoFilename = "sponsorlogo_" + currentStatus.hashname.Replace("zip", extension); using (FileStream stream = new FileStream(tempImagePath + tempSponsorLogoFilename, FileMode.Create)) { stream.Write(p.SponsorLogo, 0, p.SponsorLogo.Length); } jsReturnParams.SponsorLogoFilename = tempSponsorLogoFilename; } } } dal.Dispose(); return jsReturnParams; }
public static bool SendAccessRequest(string pid, string message) { if (Membership.GetUser() == null || !Membership.GetUser().IsApproved) { return false; } var factory = new DataAccessFactory(); IDataRepository vd = factory.CreateDataRepositorProxy(); var co = vd.GetContentObjectById(pid, false); MessageManager manager = new MessageManager(); message = Westwind.Web.Utilities.HtmlSanitizer.SanitizeHtml(message,null); manager.SendMessage(Membership.GetUser().UserName, co.SubmitterEmail, "Requesting Access to Model: " + co.Title + " (" + pid + ")", "A request has been sent from " + Membership.GetUser().UserName + " for access to model " + co.Title + " (" + pid + "). Please review this request and decide on the proper action. Click here to access the model: <a href='/public/model.aspx?ContentObjectID=" + pid +"'>"+pid+"</a> The user sent this message in the request: \n\n" + message + "<br/><div class='accessbutton' onclick='GrantOrDenyRequest(\"" + Membership.GetUser().UserName + "\",\"Grant\",\"" + pid + "\");'>Grant Access</div><div class='accessbutton' onclick='GrantOrDenyRequest(\"" + Membership.GetUser().UserName + "\",\"Deny\",\"" + pid + "\");'>Deny Request</div>" , Membership.GetUser().UserName); return true; }
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(); }
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); }
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; ///////////////////////////////////////// //TO DO: Real Cert Time tempCO.Date_Certification = DateTime.Now; tempCO.Date_Copyright = DateTime.Now; tempCO.Date_Modification = DateTime.Now; ///////////////////////////////////////// //TO DO: Real data tempCO.CommunityURL = ""; tempCO.ContributorsURL = ""; tempCO.CertificationURL = ""; tempCO.Copyright = ""; tempCO.RightsHolder = ""; Dictionary<String, Object> metadataroot = HttpContext.Current.Session["metadata"] as Dictionary<String, Object>; tempCO.JSONMetadata = metadataroot; if (metadataroot != null) { Dictionary<String, Object> metadata = null; if(metadataroot.ContainsKey("ImmersiveEducationInitiative")) metadata = metadataroot["ImmersiveEducationInitiative"] as Dictionary<String, Object>; if (metadata != null) { if (metadata.ContainsKey("COMMUNITY")) tempCO.CommunityURL = metadata["COMMUNITY"].ToString(); if (metadata.ContainsKey("CONTRIBUTORS")) tempCO.ContributorsURL = metadata["CONTRIBUTORS"].ToString(); if (metadata.ContainsKey("CERTIFICATION")) tempCO.CertificationURL = metadata["CERTIFICATION"].ToString(); if (metadata.ContainsKey("COPYRIGHT")) tempCO.Copyright = metadata["COPYRIGHT"].ToString(); if (metadata.ContainsKey("RIGHTSHOLDER")) tempCO.RightsHolder = metadata["RIGHTSHOLDER"].ToString(); if (metadata.ContainsKey("TITLE")) tempCO.Title = metadata["TITLE"].ToString(); if (metadata.ContainsKey("DESCRIPTION")) tempCO.Description = metadata["DESCRIPTION"].ToString(); DateTime tempdate; if (metadata.ContainsKey("DATE_COPYRIGHT")) { DateTime.TryParse(metadata["DATE_COPYRIGHT"].ToString(), out tempdate); tempCO.Date_Copyright = tempdate; } if (metadata.ContainsKey("DATE_CERTIFICATION")) { DateTime.TryParse(metadata["DATE_CERTIFICATION"].ToString(), out tempdate); tempCO.Date_Certification = tempdate; } if (metadata.ContainsKey("DATE_MODIFICATION")) { DateTime.TryParse(metadata["DATE_MODIFICATION"].ToString(), out tempdate); tempCO.Date_Modification = tempdate; } if (metadata.ContainsKey("ARTIST")) { tempCO.ArtistName = ArrayOrStringToString(metadata["ARTIST"]); } if (metadata.ContainsKey("CREATOR")) { tempCO.DeveloperName = ArrayOrStringToString(metadata["CREATOR"]); } if (metadata.ContainsKey("KEYWORDS")) { string[] Keywords = metadata["KEYWORDS"].ToString().Split(new char[] {','}); for (int i = 0; i < Keywords.Length; i++) Keywords[i] = Keywords[i].Trim(); tempCO.Keywords = String.Join(",", Keywords); } if (metadata.ContainsKey("LICENSE")) { tempCO.CreativeCommonsLicenseURL = metadata["LICENSE"].ToString(); } } } 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 } }
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); }