/// <summary> /// Overrides API base class validate, uses website user rather than HTTP Basic /// </summary> /// <param name="type">The transaction type to validate</param> /// <param name="co">the content object to validate the operation on</param> /// <returns>True if the user may perform this operation on the contentobject</returns> public override bool DoValidate(Security.TransactionType type, vwarDAL.ContentObject co) { vwarDAL.PermissionsManager prm = new vwarDAL.PermissionsManager(); vwarDAL.ModelPermissionLevel Permission = prm.GetPermissionLevel(username, co.PID); prm.Dispose(); if (type == Security.TransactionType.Query && Permission >= vwarDAL.ModelPermissionLevel.Searchable) { return(true); } if (type == Security.TransactionType.Access && Permission >= vwarDAL.ModelPermissionLevel.Fetchable) { return(true); } if (type == Security.TransactionType.Modify && Permission >= vwarDAL.ModelPermissionLevel.Editable) { return(true); } if (type == Security.TransactionType.Delete && Permission >= vwarDAL.ModelPermissionLevel.Admin) { return(true); } if (type == Security.TransactionType.Create && Permission >= vwarDAL.ModelPermissionLevel.Admin) { return(true); } return(false); }
public static String ModelDownloaded(ContentObject co) { System.Threading.ParameterizedThreadStart t = new System.Threading.ParameterizedThreadStart(ModelDownloaded_thread); System.Threading.Thread th = new System.Threading.Thread(t); th.Start(co); return "Thread fired"; }
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 void DeleteContentObject(ContentObject co) { string pid = co.PID.Replace(":", "_"); string dir = m_DataDir + pid +"\\"; foreach (string file in Directory.GetFiles(dir)) { File.Delete(file); } Directory.Delete(dir); }
/// <summary> /// /// </summary> /// <param name="co"></param> /// <param name="keyword"></param> /// <returns></returns> public bool RemoveKeyword(ContentObject co, string keyword) { bool result; System.Data.Odbc.OdbcConnection connection = GetConnection(); { using (var command = connection.CreateCommand()) { command.CommandText = "{CALL RemoveKeyword(?,?)}"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("pid", co.PID); command.Parameters.AddWithValue("keyword", keyword); Boolean.TryParse(command.ExecuteReader().ToString(), out result); if (result == null) { result = false; } } } return(result); }
public IEnumerable <ContentObject> GetContentObjectsByKeywords(string keywords, string identity) { //We must transform the list into something MySQL finds acceptible in its syntax char[] delimiters = new char[] { ',' }; string[] list = keywords.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); string escapeTemplate = "'{0}'"; //Add quotes around each of the list items, while also escaping any existing quotes for (int i = 0; i < list.Length; i++) { list[i] = String.Format(escapeTemplate, list[i].Replace("'", "\'")); } keywords = String.Join(",", list); System.Data.Odbc.OdbcConnection conn = GetConnection(); { List <ContentObject> objects = new List <ContentObject>(); using (var cmd = conn.CreateCommand()) { cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "{CALL GetContentObjectsByKeywords(?,?)}"; cmd.Parameters.AddWithValue("keylist", keywords); cmd.Parameters.AddWithValue("uname", identity); using (var results = cmd.ExecuteReader()) { while (results.HasRows && results.Read()) { ContentObject co = new ContentObject(); FillContentObjectLightLoad(co, results); objects.Add(co); } } } return(objects); } }
/// <summary> /// /// </summary> /// <param name="co"></param> /// <param name="command"></param> private void FillCommandFromContentObject(ContentObject co, OdbcCommand command) { command.Parameters.AddWithValue("newpid", co.PID); command.Parameters.AddWithValue("newtitle", co.Title); command.Parameters.AddWithValue("newcontentfilename", co.Location); command.Parameters.AddWithValue("newcontentfileid", co.DisplayFileId); command.Parameters.AddWithValue("newsubmitter", co.SubmitterEmail); command.Parameters.AddWithValue("newcreativecommonslicenseurl", co.CreativeCommonsLicenseURL); command.Parameters.AddWithValue("newdescription", co.Description); command.Parameters.AddWithValue("newscreenshotfilename", co.ScreenShot); command.Parameters.AddWithValue("newscreenshotfileid", co.ScreenShotId); command.Parameters.AddWithValue("newthumbnailfilename", co.Thumbnail); command.Parameters.AddWithValue("newthumbnailfileid", co.ThumbnailId); command.Parameters.AddWithValue("newsponsorlogofilename", co.SponsorLogoImageFileName); command.Parameters.AddWithValue("newsponsorlogofileid", co.SponsorLogoImageFileNameId); command.Parameters.AddWithValue("newdeveloperlogofilename", co.DeveloperLogoImageFileName); command.Parameters.AddWithValue("newdeveloperlogofileid", co.DeveloperLogoImageFileNameId); command.Parameters.AddWithValue("newassettype", co.AssetType); command.Parameters.AddWithValue("newdisplayfilename", co.DisplayFile); command.Parameters.AddWithValue("newdisplayfileid", co.DisplayFileId); command.Parameters.AddWithValue("newmoreinfourl", co.MoreInformationURL); command.Parameters.AddWithValue("newdevelopername", co.DeveloperName); command.Parameters.AddWithValue("newsponsorname", co.SponsorName); command.Parameters.AddWithValue("newartistname", co.ArtistName); command.Parameters.AddWithValue("newunitscale", co.UnitScale); command.Parameters.AddWithValue("newupaxis", co.UpAxis); command.Parameters.AddWithValue("newuvcoordinatechannel", co.UVCoordinateChannel); command.Parameters.AddWithValue("newintentionoftexture", co.IntentionOfTexture); command.Parameters.AddWithValue("newformat", co.Format); command.Parameters.AddWithValue("newnumpolys", co.NumPolygons); command.Parameters.AddWithValue("newNumTextures", co.NumTextures); command.Parameters.AddWithValue("newRevisionNumber", co.Revision); command.Parameters.AddWithValue("newRequireResubmit", co.RequireResubmit); command.Parameters.AddWithValue("newenabled", co.Enabled); command.Parameters.AddWithValue("newready", co.Ready); command.Parameters.AddWithValue("newOriginalFileName", co.OriginalFileName); command.Parameters.AddWithValue("newOriginalFileId", co.OriginalFileId); }
/// <summary> /// /// </summary> /// <param name="co"></param> public void UpdateContentObject(ContentObject co) { System.Data.Odbc.OdbcConnection conn = GetConnection(); { int id = 0; using (var command = conn.CreateCommand()) { command.CommandText = "{CALL UpdateContentObject(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?); }"; command.CommandType = System.Data.CommandType.StoredProcedure; var properties = co.GetType().GetProperties(); foreach (var prop in properties) { if (prop.PropertyType == typeof(String) && prop.GetValue(co, null) == null) { prop.SetValue(co, String.Empty, null); } } FillCommandFromContentObject(co, command); id = int.Parse(command.ExecuteScalar().ToString()); } SaveKeywords(conn, co, id); } }
/// <summary> /// /// </summary> /// <param name="co"></param> /// <param name="filename"></param> /// <param name="description"></param> public void AddSupportingFile(ContentObject co, string filename, string description, string dsid) { System.Data.Odbc.OdbcConnection connection = GetConnection(); { using (var command = connection.CreateCommand()) { //AddMissingTexture(pid,filename,texturetype,uvset) command.CommandText = "{CALL AddSupportingFile(?,?,?,?)}"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("newfilename", filename); command.Parameters.AddWithValue("newdescription", description); command.Parameters.AddWithValue("newcontentobjectid", co.PID); command.Parameters.AddWithValue("newdsid", dsid); var result = command.ExecuteReader(); //while (result.Read()) //{ co.SupportingFiles.Add(new SupportingFile(filename, description, dsid)); // } } } }
/// <summary> /// /// </summary> /// <param name="co"></param> public void DeleteContentObject(ContentObject co) { _fileStore.DeleteContentObject(co); _metadataStore.DeleteContentObject(co); }
protected void Step1NextButton_Click(object sender, EventArgs e) { //update if (IsModelUpload) { vwarDAL.IDataRepository dal = (new vwarDAL.DataAccessFactory()).CreateDataRepositorProxy(); ; if (this.IsNew) { //create new & add to session ContentObject co = new ContentObject(dal); co.Title = this.TitleTextBox.Text.Trim(); co.UploadedDate = DateTime.Now; co.LastModified = DateTime.Now; co.Views = 0; co.SubmitterEmail = Context.User.Identity.Name.Trim(); dal.InsertContentObject(co); FedoraContentObject = co; this.ContentObjectID = co.PID; } else { FedoraContentObject.Title = TitleTextBox.Text.Trim(); } if (this.FedoraContentObject != null) { //asset type this.FedoraContentObject.AssetType = "Model"; string newFileName = TitleTextBox.Text.ToLower().Replace(' ', '_') + Path.GetExtension(this.ContentFileUpload.PostedFile.FileName); //model upload Utility_3D.ConvertedModel model = null; if (this.ContentFileUpload.HasFile) { string newOriginalFileName = "original_" + newFileName; if (IsNew) { using (MemoryStream stream = new MemoryStream()) { stream.Write(this.ContentFileUpload.FileBytes, 0, this.ContentFileUpload.FileBytes.Length); FedoraContentObject.OriginalFileId = dal.SetContentFile(stream, FedoraContentObject.PID, newOriginalFileName); } } else { //Update the original file dal.UpdateFile(this.ContentFileUpload.FileBytes, FedoraContentObject.PID, FedoraContentObject.OriginalFileName, newOriginalFileName); } FedoraContentObject.OriginalFileName = newOriginalFileName; Utility_3D.Model_Packager pack = new Utility_3D.Model_Packager(); Utility_3D _3d = new Utility_3D(); Utility_3D.ConverterOptions cOptions = new Utility_3D.ConverterOptions(); cOptions.EnableTextureConversion(Utility_3D.ConverterOptions.PNG); cOptions.EnableScaleTextures(Website.Config.MaxTextureDimension); _3d.Initialize(Website.Config.ConversionLibarayLocation); string UploadedFilename = newFileName; if (Path.GetExtension(UploadedFilename) != ".zip") UploadedFilename = Path.ChangeExtension(newFileName, ".zip"); try { model = pack.Convert(this.ContentFileUpload.PostedFile.InputStream, this.ContentFileUpload.PostedFile.FileName, cOptions); } catch { Response.Redirect(Page.ResolveClientUrl("~/Public/Model.aspx?ContentObjectID=" + this.ContentObjectID)); } var displayFilePath = ""; string convertedFileName = newFileName.Replace(Path.GetExtension(newFileName).ToLower(), ".zip"); if (this.ContentFileUpload.HasFile) { using (Stream stream = new MemoryStream()) { stream.Write(model.data, 0, model.data.Length); stream.Seek(0, SeekOrigin.Begin); FedoraContentObject.Location = UploadedFilename; //FedoraContentObject.DisplayFileId = dal.SetContentFile(stream, FedoraContentObject, UploadedFilename); } } else { using (MemoryStream stream = new MemoryStream()) { stream.Write(model.data, 0, model.data.Length); stream.Seek(0, SeekOrigin.Begin); dal.SetContentFile(stream, FedoraContentObject, UploadedFilename); FedoraContentObject.Location = UploadedFilename; } } FedoraContentObject.Location = convertedFileName; if (model.type != "UNKNOWN") { string optionalPath = (newFileName.LastIndexOf("o3d", StringComparison.CurrentCultureIgnoreCase) != -1) ? "viewerTemp/" : "converterTemp/"; string pathToTempFile = "~/App_Data/" + optionalPath; string destPath = Path.Combine(Context.Server.MapPath(pathToTempFile), newFileName); System.IO.FileStream savefile = new FileStream(destPath, FileMode.OpenOrCreate); byte[] filedata = new Byte[model.data.Length]; model.data.CopyTo(filedata, 0); savefile.Write(model.data, 0, (int)model.data.Length); savefile.Close(); string outfilename = Context.Server.MapPath("~/App_Data/viewerTemp/") + newFileName.Replace(".zip", ".o3d"); string convertedtempfile = ConvertFileToO3D(destPath,outfilename); displayFilePath = FedoraContentObject.DisplayFile; string o3dFileName = newFileName.Replace(Path.GetExtension(newFileName).ToLower(), ".o3d"); if (this.ContentFileUpload.HasFile) { using (FileStream stream = new FileStream(convertedtempfile, FileMode.Open)) { FedoraContentObject.DisplayFileId = dal.SetContentFile(stream, FedoraContentObject, o3dFileName); } } else { using (MemoryStream stream = new MemoryStream()) { stream.Write(filedata, 0, filedata.Length); stream.Seek(0, SeekOrigin.Begin); dal.SetContentFile(stream, FedoraContentObject, UploadedFilename); FedoraContentObject.DisplayFile = Path.GetFileName(FedoraContentObject.DisplayFile); } } FedoraContentObject.DisplayFile = o3dFileName; } else { FedoraContentObject.DisplayFile = string.Empty; } FedoraContentObject.UnitScale = model._ModelData.TransformProperties.UnitMeters.ToString(); FedoraContentObject.UpAxis = model._ModelData.TransformProperties.UpAxis; FedoraContentObject.NumPolygons = model._ModelData.VertexCount.Polys; FedoraContentObject.NumTextures = model._ModelData.ReferencedTextures.Length; PopulateValidationViewMetadata(FedoraContentObject); } //upload thumbnail if (this.ThumbnailFileUpload.HasFile) { int length = (int)this.ThumbnailFileUpload.PostedFile.InputStream.Length; if (IsNew || FedoraContentObject.ScreenShot == "")// order counts here have to set screenshot id after the update so we can find the correct dsid this.FedoraContentObject.ScreenShot = "screenshot.png"; FedoraContentObject.ScreenShotId = dal.SetContentFile(this.ThumbnailFileUpload.PostedFile.InputStream, this.FedoraContentObject, FedoraContentObject.ScreenShot); string ext = new FileInfo(ThumbnailFileUpload.PostedFile.FileName).Extension.ToLower(); System.Drawing.Imaging.ImageFormat format; if (ext == ".png") format = System.Drawing.Imaging.ImageFormat.Png; else if (ext == ".jpg") format = System.Drawing.Imaging.ImageFormat.Jpeg; else if (ext == ".gif") format = System.Drawing.Imaging.ImageFormat.Gif; else { ScreenshotValidator.Visible = true; ScreenshotValidator.Text = "Nice job generating a POST request without the interface. Don't you feel special?"; return; } //Avoid wasting space by removing old thumbnails if (!String.IsNullOrEmpty(FedoraContentObject.ThumbnailId)) File.Delete("~/thumbnails/" + FedoraContentObject.ThumbnailId); //Use the original file bytes to remain consistent with the new file upload ID creation for thumbnails FedoraContentObject.ThumbnailId = Website.Common.GetFileSHA1AndSalt(ThumbnailFileUpload.PostedFile.InputStream) + ext; using (FileStream outFile = new FileStream(HttpContext.Current.Server.MapPath("~/thumbnails/" + FedoraContentObject.ThumbnailId), FileMode.Create)) Website.Common.GenerateThumbnail(ThumbnailFileUpload.PostedFile.InputStream, outFile, format); } //creative commons license url if (this.CCLicenseDropDownList.SelectedItem != null && this.CCLicenseDropDownList.SelectedValue != "None") { this.FedoraContentObject.CreativeCommonsLicenseURL = this.CCLicenseDropDownList.SelectedValue.Trim(); } //Require Resubmit Checkbox FedoraContentObject.RequireResubmit = this.RequireResubmitCheckbox.Checked; //developer logo this.UploadDeveloperLogo(dal, this.FedoraContentObject); //developer name if (!string.IsNullOrEmpty(this.DeveloperNameTextBox.Text)) { this.FedoraContentObject.DeveloperName = this.DeveloperNameTextBox.Text.Trim(); } //sponsor logo this.UploadSponsorLogo(dal, this.FedoraContentObject); //sponsor name if (!string.IsNullOrEmpty(this.SponsorNameTextBox.Text)) { this.FedoraContentObject.SponsorName = this.SponsorNameTextBox.Text.Trim(); } //artist name if (!string.IsNullOrEmpty(this.ArtistNameTextBox.Text)) { this.FedoraContentObject.ArtistName = this.ArtistNameTextBox.Text.Trim(); } //format if (!string.IsNullOrEmpty(this.FormatTextBox.Text)) { this.FedoraContentObject.Format = this.FormatTextBox.Text.Trim(); } //description if (!string.IsNullOrEmpty(this.DescriptionTextBox.Text)) { this.FedoraContentObject.Description = this.DescriptionTextBox.Text.Trim(); } //more information url if (!string.IsNullOrEmpty(this.MoreInformationURLTextBox.Text)) { this.FedoraContentObject.MoreInformationURL = this.MoreInformationURLTextBox.Text.Trim(); } //keywords string cleanTags = ""; foreach (string s in KeywordsTextBox.Text.Split(',')) { cleanTags += s.Trim() + ","; } cleanTags = HttpContext.Current.Server.HtmlEncode(cleanTags.Trim(',')); this.FedoraContentObject.Keywords = cleanTags; } dal.UpdateContentObject(FedoraContentObject); if (IsNew) { PermissionsManager perm = new PermissionsManager(); perm.SetModelToGroupLevel(System.Configuration.ConfigurationManager.AppSettings["DefaultAdminName"], FedoraContentObject.PID, vwarDAL.DefaultGroups.AllUsers, ModelPermissionLevel.Fetchable); perm.SetModelToGroupLevel(System.Configuration.ConfigurationManager.AppSettings["DefaultAdminName"], FedoraContentObject.PID, vwarDAL.DefaultGroups.AnonymousUsers, ModelPermissionLevel.Searchable); perm.Dispose(); } SetModelDisplay(); this.PopulateValidationViewMetadata(FedoraContentObject); this.MultiView1.SetActiveView(this.ValidationView); var admins = UserProfileDB.GetAllAdministrativeUsers(); foreach (DataRow row in admins.Rows) { var url = Request.Url.OriginalString.Replace(Request.Url.PathAndQuery, this.ResolveUrl(Website.Pages.Types.FormatModel(this.ContentObjectID))); Website.Mail.SendModelUploaded(FedoraContentObject); } dal.Dispose(); } }
/// <summary> /// /// </summary> /// <param name="co"></param> /// <param name="filename"></param> /// <returns></returns> public Stream GetSupportingFile(ContentObject co, string dsid) { return(new MemoryStream(GetContentFileData(co.PID, dsid))); }
/// <summary> /// /// </summary> /// <param name="co"></param> /// <param name="connection"></param> private void LoadReviews(ContentObject co, OdbcConnection connection) { using (var command = connection.CreateCommand()) { command.CommandText = "{CALL GetReviews(?)}"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("pid", co.PID); var result = command.ExecuteReader(); while (result.Read()) { co.Reviews.Add(new Review() { Rating = int.Parse(result["Rating"].ToString()), Text = result["Text"].ToString(), SubmittedBy = result["SubmittedBy"].ToString(), SubmittedDate = DateTime.Parse(result["SubmittedDate"].ToString()) }); } } }
public IEnumerable<ContentObject> GetContentObjectsByKeywords(string keywords, string identity) { //We must transform the list into something MySQL finds acceptible in its syntax char[] delimiters = new char[] { ',' }; string[] list = keywords.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); string escapeTemplate = "'{0}'"; //Add quotes around each of the list items, while also escaping any existing quotes for (int i = 0; i < list.Length; i++) list[i] = String.Format(escapeTemplate, list[i].Replace("'", "\'")); keywords = String.Join(",", list); System.Data.Odbc.OdbcConnection conn = GetConnection(); { List<ContentObject> objects = new List<ContentObject>(); using (var cmd = conn.CreateCommand()) { cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "{CALL GetContentObjectsByKeywords(?,?)}"; cmd.Parameters.AddWithValue("keylist", keywords); cmd.Parameters.AddWithValue("uname", identity); using (var results = cmd.ExecuteReader()) { while (results.HasRows && results.Read()) { ContentObject co = new ContentObject(); FillContentObjectLightLoad(co, results); objects.Add(co); } } } return objects; } }
/// <summary> /// /// </summary> /// <param name="co"></param> /// <param name="keyword"></param> /// <returns></returns> public bool RemoveKeyword(ContentObject co, string keyword) { bool result; System.Data.Odbc.OdbcConnection connection = GetConnection(); { using (var command = connection.CreateCommand()) { command.CommandText = "{CALL RemoveKeyword(?,?)}"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("pid", co.PID); command.Parameters.AddWithValue("keyword", keyword); Boolean.TryParse(command.ExecuteReader().ToString(), out result); if (result == null) { result = false; } } } return result; }
/// <summary> /// /// </summary> /// <param name="co"></param> /// <param name="filename"></param> /// <returns></returns> public bool RemoveTextureReference(ContentObject co, string filename) { return(_metadataStore.RemoveTextureReference(co, filename)); }
/// <summary> /// /// </summary> /// <param name="pid"></param> /// <param name="updateViews"></param> /// <param name="getReviews"></param> /// <param name="revision"></param> /// <returns></returns> public ContentObject GetContentObjectById(string pid, bool updateViews, bool getReviews = true, int revision = -1) { if (String.IsNullOrEmpty(pid)) { return null; } List<ContentObject> results = new List<ContentObject>(); ContentObject resultCO = null; if (false)//(_Memory.ContainsKey(co.PID)) { //co = _Memory[co.PID]; } else { System.Data.Odbc.OdbcConnection conn = GetConnection(); { using (var command = conn.CreateCommand()) { command.CommandText = "{CALL GetContentObject(?);}"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("targetpid", pid); //command.Parameters.AddWithValue("pid", pid); using (var result = command.ExecuteReader()) { int NumberOfRows = 0; while (result.Read()) { NumberOfRows++; var co = new ContentObject() { PID = pid, Reviews = new List<Review>() }; var properties = co.GetType().GetProperties(); foreach (var prop in properties) { if (prop.PropertyType == typeof(String) && prop.GetValue(co, null) == null) { prop.SetValue(co, String.Empty, null); } } FillContentObjectFromResultSet(co, result); LoadTextureReferences(co, conn); LoadMissingTextures(co, conn); LoadSupportingFiles(co, conn); LoadReviews(co, conn); co.Keywords = LoadKeywords(conn, co.PID); results.Add(co); } ContentObject highest = null; if (results.Count > 0) { if (revision == -1) { highest = (from r in results orderby r.Revision descending select r).First(); } else { highest = (from r in results where r.Revision == revision select r).First(); } resultCO = highest; } else return null; } } } } if (updateViews) { System.Data.Odbc.OdbcConnection secondConnection = GetConnection(); { using (var command = secondConnection.CreateCommand()) { command.CommandText = "{CALL IncrementViews(?)}"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("targetpid", pid); command.ExecuteNonQuery(); } } } return resultCO; }
/// <summary> /// /// </summary> /// <param name="co"></param> public void InsertContentRevision(ContentObject co) { _metadataStore.InsertContentRevision(co); }
public static String ModelUploadedInternal(ContentObject co) { //create a document and an envelop lr_Envelope env = new lr_Envelope(); lr_document doc = new lr_document(); //Add the keys from the contentobject to the keys for the document doc.keys.Add("3DR"); string[] keywords = co.Keywords.Split(new char[]{','},StringSplitOptions.RemoveEmptyEntries); foreach (string key in keywords) doc.keys.Add(key); //This is the URI of the resource this data describes doc.resource_locator = LR_Integration_APIBaseURL() + co.PID + "/Format/dae?ID=00-00-00"; //Submitted by the ADL3DR agent doc.identity.submitter = LR_Integration_SubmitterName(); doc.identity.signer = LR_Integration_SignerName() ; doc.identity.submitter_type = new lr_submitter_type.agent(); //The data is paradata doc.resource_data_type = new lr_resource_data_type.paradata(); //Set ActivityStream as the paradata schema doc.payload_schema.Add(new lr_schema_value.paradata.LR_Paradata_1_0()); Paradata.lr_Activity activity = new lr_Activity(); //Create a paradata object Paradata.lr_Paradata pd = activity.activity; //Create a complex actor type, set to 3dr user lr_Actor.lr_Actor_complex mActor = new lr_Actor.lr_Actor_complex(); mActor.description.Add("AnonymousUser"); mActor.objectType = "3DR User"; //Set the paradata actor pd.actor = mActor; //Create a complex verb type lr_Verb.lr_Verb_complex verb = new lr_Verb.lr_Verb_complex(); verb.action = "Published"; verb.context.id = ""; verb.date = DateTime.Now; verb.measure = null; //Set the paradata verb pd.verb = verb; //Create a complex object type lr_Object.lr_Object_complex _object = new lr_Object.lr_Object_complex(); _object.id = co.PID; //Set the paradata object pd._object = _object; //A human readable description for the paradata pd.content = "The a user uploaded a new model which was assigned the PID " + co.PID; //The resource_data of this Resource_data_description_document is the inline paradata doc.resource_data = activity; env.documents.Add(doc); //Create a second document doc = new lr_document(); //Submitted by the ADL3DR agent doc.identity.submitter = LR_Integration_SubmitterName(); doc.identity.signer = LR_Integration_SignerName(); doc.identity.submitter_type = new lr_submitter_type.agent(); //Add the keys from the content object to the document foreach (string key in keywords) doc.keys.Add(key); //the metadata will be inline doc.payload_placement = new lr_payload_placement.inline(); //This is the resource the data describes doc.resource_locator = LR_Integration_APIBaseURL() + co.PID + "/Format/dae?ID=00-00-00"; //The inline resource data is the contentobject var backupdata = co.JSONMetadata; co.JSONMetadata = null; doc.resource_data = co; //Set the scema to dublin core doc.payload_schema.Add(new lr_schema_value.metadata.DublinCore1_1()); //this is metadata doc.resource_data_type = new lr_resource_data_type.metadata(); //Add the doc to the envelope env.documents.Add(doc); //sign the envelope env.Sign(LR_Integration_KeyPassPhrase(),LR_Integration_KeyID(),LR_Integration_PublicKeyURL()); co.JSONMetadata = backupdata; //Serialize and publish return env.Publish(); }
/// <summary> /// /// </summary> /// <param name="co"></param> public void InsertContentObject(ContentObject co) { _fileStore.InsertContentObject(co); _metadataStore.InsertContentObject(co); }
/// <summary> /// /// </summary> /// <returns></returns> public ContentObject GetNewContentObject() { ContentObject co = new ContentObject(); return(co); }
/// <summary> /// /// </summary> /// <param name="co"></param> /// <param name="resultSet"></param> private void FillContentObjectFromResultSet(ContentObject co, OdbcDataReader resultSet) { try { co.PID = resultSet["PID"].ToString(); co.ArtistName = resultSet["ArtistName"].ToString(); co.AssetType = resultSet["AssetType"].ToString(); co.CreativeCommonsLicenseURL = resultSet["CreativeCommonsLicenseURL"].ToString(); co.Description = resultSet["Description"].ToString(); co.DeveloperLogoImageFileName = resultSet["DeveloperLogoFileName"].ToString(); co.DeveloperLogoImageFileNameId = resultSet["DeveloperLogoFileId"].ToString(); co.DeveloperName = resultSet["DeveloperName"].ToString(); co.DisplayFile = resultSet["DisplayFileName"].ToString(); co.DisplayFileId = resultSet["DisplayFileId"].ToString(); co.Downloads = int.Parse(resultSet["Downloads"].ToString()); co.Format = resultSet["Format"].ToString(); co.IntentionOfTexture = resultSet["IntentionOfTexture"].ToString(); DateTime temp; if (DateTime.TryParse(resultSet["LastModified"].ToString(), out temp)) { co.LastModified = temp; } if (DateTime.TryParse(resultSet["LastViewed"].ToString(), out temp)) { co.LastViewed = temp; } co.Location = resultSet["ContentFileName"].ToString(); co.MoreInformationURL = resultSet["MoreInfoUrl"].ToString(); co.NumPolygons = int.Parse(resultSet["NumPolygons"].ToString()); co.NumTextures = int.Parse(resultSet["NumTextures"].ToString()); co.ScreenShot = resultSet["ScreenShotFileName"].ToString(); co.ScreenShotId = resultSet["ScreenShotFileId"].ToString(); co.SponsorLogoImageFileName = resultSet["SponsorLogoFileName"].ToString(); co.SponsorLogoImageFileNameId = resultSet["SponsorLogoFileId"].ToString(); co.SponsorName = resultSet["SponsorName"].ToString(); co.SubmitterEmail = resultSet["Submitter"].ToString(); co.Title = resultSet["Title"].ToString(); co.Thumbnail = resultSet["ThumbnailFileName"].ToString(); co.ThumbnailId = resultSet["ThumbnailFileId"].ToString(); co.UnitScale = resultSet["UnitScale"].ToString(); co.UpAxis = resultSet["UpAxis"].ToString(); if (DateTime.TryParse(resultSet["UploadedDate"].ToString(), out temp)) { co.UploadedDate = temp; } co.UVCoordinateChannel = resultSet["UVCoordinateChannel"].ToString(); co.Views = int.Parse(resultSet["Views"].ToString()); co.Revision = Convert.ToInt32(resultSet["Revision"].ToString()); var RequiresResubmit = resultSet["requiressubmit"].ToString(); var RequiresResubmitValue = int.Parse(RequiresResubmit); co.RequireResubmit = RequiresResubmitValue != 0; co.OriginalFileName = resultSet["OriginalFileName"].ToString(); co.OriginalFileId = resultSet["OriginalFileId"].ToString(); co.Distribution_Grade = (DistributionGrade)Enum.Parse(typeof(DistributionGrade), resultSet["Distribution_Grade"].ToString()); co.Distribution_Regulation = resultSet["Distribution_Regulation"].ToString(); co.Distribution_Determination_Date = DateTime.Parse(resultSet["Distribution_Determination_Date"].ToString()); co.Distribution_Contolling_Office = resultSet["Distribution_Contolling_Office"].ToString(); co.Distribution_Reason = resultSet["Distribution_Reason"].ToString(); } catch { } }
/// <summary> /// /// </summary> /// <param name="co"></param> /// <param name="filename"></param> /// <returns></returns> public bool RemoveSupportingFile(ContentObject co, string filename) { return(_metadataStore.RemoveSupportingFile(co, filename)); }
/// <summary> /// /// </summary> /// <param name="co"></param> public void UpdateContentObject(ContentObject co) { _metadataStore.RemoveAllKeywords(co); _metadataStore.UpdateContentObject(co); }
public static String ModelDownloadedInternal(ContentObject co) { lr_Envelope env = new lr_Envelope(); lr_document doc = new lr_document(); //Add the keys from the contentobject to the keys for the document doc.keys.Add("3DR"); string[] keywords = co.Keywords.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string key in keywords) doc.keys.Add(key); //This is the URI of the resource this data describes doc.resource_locator = LR_Integration_APIBaseURL() + co.PID + "/Format/dae?ID=00-00-00"; //Submitted by the ADL3DR agent doc.identity.submitter = LR_Integration_SubmitterName(); doc.identity.signer = LR_Integration_SignerName(); doc.identity.submitter_type = new lr_submitter_type.agent(); //The data is paradata doc.resource_data_type = new lr_resource_data_type.paradata(); //Set ActivityStream as the paradata schema doc.payload_schema.Add(new lr_schema_value.paradata.LR_Paradata_1_0()); Paradata.lr_Activity activity = new lr_Activity(); //Create a paradata object Paradata.lr_Paradata pd = activity.activity; //Set the paradata actor pd.actor = null; //Create a complex verb type lr_Verb.lr_Verb_complex verb = new lr_Verb.lr_Verb_complex(); verb.action = "Downloaded"; verb.context.id = ""; verb.date = DateTime.Now; lr_Measure measure = new lr_Measure(); measure.measureType = "count"; measure.value = co.Downloads.ToString(); verb.measure = measure; //Set the paradata verb pd.verb = verb; //Create a complex object type lr_Object.lr_Object_complex _object = new lr_Object.lr_Object_complex(); _object.id = co.PID; //Set the paradata object pd._object = _object; //A human readable description for the paradata pd.content = "The a user downloaded this model from the ADL 3DR."; //The resource_data of this Resource_data_description_document is the inline paradata doc.resource_data = activity; env.documents.Add(doc); //sign the envelope env.Sign(LR_Integration_KeyPassPhrase(), LR_Integration_KeyID(), LR_Integration_PublicKeyURL()); //Serialize and publish return env.Publish(); }
/// <summary> /// /// </summary> /// <param name="pid"></param> /// <param name="updateViews"></param> /// <param name="getReviews"></param> /// <param name="revision"></param> /// <returns></returns> public ContentObject GetContentObjectById(string pid, bool updateViews, bool getReviews = true, int revision = -1) { if (String.IsNullOrEmpty(pid)) { return(null); } List <ContentObject> results = new List <ContentObject>(); ContentObject resultCO = null; if (false)//(_Memory.ContainsKey(co.PID)) { //co = _Memory[co.PID]; } else { System.Data.Odbc.OdbcConnection conn = GetConnection(); { using (var command = conn.CreateCommand()) { command.CommandText = "{CALL GetContentObject(?);}"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("targetpid", pid); //command.Parameters.AddWithValue("pid", pid); using (var result = command.ExecuteReader()) { int NumberOfRows = 0; while (result.Read()) { NumberOfRows++; var co = new ContentObject() { PID = pid, Reviews = new List <Review>() }; var properties = co.GetType().GetProperties(); foreach (var prop in properties) { if (prop.PropertyType == typeof(String) && prop.GetValue(co, null) == null) { prop.SetValue(co, String.Empty, null); } } FillContentObjectFromResultSet(co, result); LoadTextureReferences(co, conn); LoadMissingTextures(co, conn); LoadSupportingFiles(co, conn); LoadReviews(co, conn); co.Keywords = LoadKeywords(conn, co.PID); results.Add(co); } ContentObject highest = null; if (results.Count > 0) { if (revision == -1) { highest = (from r in results orderby r.Revision descending select r).First(); } else { highest = (from r in results where r.Revision == revision select r).First(); } resultCO = highest; } else { return(null); } } } } } if (updateViews) { System.Data.Odbc.OdbcConnection secondConnection = GetConnection(); { using (var command = secondConnection.CreateCommand()) { command.CommandText = "{CALL IncrementViews(?)}"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("targetpid", pid); command.ExecuteNonQuery(); } } } return(resultCO); }
public IEnumerable<ContentObject> GetAllContentObjects(string UserName) { System.Data.Odbc.OdbcConnection conn = GetConnection(); { List<ContentObject> objects = new List<ContentObject>(); using (var command = conn.CreateCommand()) { command.CommandText = "{CALL GetAllContentObjectsVisibleToUser(?)}"; command.Parameters.AddWithValue("uname", UserName); command.CommandType = System.Data.CommandType.StoredProcedure; using (var resultSet = command.ExecuteReader()) { while (resultSet.Read()) { var co = new ContentObject(); FillContentObjectFromResultSet(co, resultSet); LoadReviews(co, conn); co.Keywords = LoadKeywords(conn, co.PID); objects.Add(co); } } } return objects; } }
public IEnumerable<ContentObject> GetContentObjectsByField(string field, string value, string identity) { System.Data.Odbc.OdbcConnection conn = GetConnection(); { List<ContentObject> objects = new List<ContentObject>(); using (var command = conn.CreateCommand()) { command.CommandType = System.Data.CommandType.StoredProcedure; command.CommandText = "{CALL GetContentObjectsByField(?,?,?)}"; command.Parameters.AddWithValue("field", field); command.Parameters.AddWithValue("val", value); command.Parameters.AddWithValue("uname", identity); using (var resultSet = command.ExecuteReader()) { while (resultSet.Read()) { var co = new ContentObject(); FillContentObjectLightLoad(co, resultSet); objects.Add(co); } } } return objects; } }
/// <summary> /// /// </summary> /// <param name="co"></param> /// <param name="resultSet"></param> private void FillContentObjectFromResultSet(ContentObject co, OdbcDataReader resultSet) { try { co.PID = resultSet["PID"].ToString(); co.ArtistName = resultSet["ArtistName"].ToString(); co.AssetType = resultSet["AssetType"].ToString(); co.CreativeCommonsLicenseURL = resultSet["CreativeCommonsLicenseURL"].ToString(); co.Description = resultSet["Description"].ToString(); co.DeveloperLogoImageFileName = resultSet["DeveloperLogoFileName"].ToString(); co.DeveloperLogoImageFileNameId = resultSet["DeveloperLogoFileId"].ToString(); co.DeveloperName = resultSet["DeveloperName"].ToString(); co.DisplayFile = resultSet["DisplayFileName"].ToString(); co.DisplayFileId = resultSet["DisplayFileId"].ToString(); co.Downloads = int.Parse(resultSet["Downloads"].ToString()); co.Format = resultSet["Format"].ToString(); co.IntentionOfTexture = resultSet["IntentionOfTexture"].ToString(); DateTime temp; if (DateTime.TryParse(resultSet["LastModified"].ToString(), out temp)) { co.LastModified = temp; } if (DateTime.TryParse(resultSet["LastViewed"].ToString(), out temp)) { co.LastViewed = temp; } co.Location = resultSet["ContentFileName"].ToString(); co.MoreInformationURL = resultSet["MoreInfoUrl"].ToString(); co.NumPolygons = int.Parse(resultSet["NumPolygons"].ToString()); co.NumTextures = int.Parse(resultSet["NumTextures"].ToString()); co.ScreenShot = resultSet["ScreenShotFileName"].ToString(); co.ScreenShotId = resultSet["ScreenShotFileId"].ToString(); co.SponsorLogoImageFileName = resultSet["SponsorLogoFileName"].ToString(); co.SponsorLogoImageFileNameId = resultSet["SponsorLogoFileId"].ToString(); co.SponsorName = resultSet["SponsorName"].ToString(); co.SubmitterEmail = resultSet["Submitter"].ToString(); co.Title = resultSet["Title"].ToString(); co.Thumbnail = resultSet["ThumbnailFileName"].ToString(); co.ThumbnailId = resultSet["ThumbnailFileId"].ToString(); co.UnitScale = resultSet["UnitScale"].ToString(); co.UpAxis = resultSet["UpAxis"].ToString(); if (DateTime.TryParse(resultSet["UploadedDate"].ToString(), out temp)) { co.UploadedDate = temp; } co.UVCoordinateChannel = resultSet["UVCoordinateChannel"].ToString(); co.Views = int.Parse(resultSet["Views"].ToString()); co.Revision = Convert.ToInt32(resultSet["Revision"].ToString()); var RequiresResubmit = resultSet["requiressubmit"].ToString(); var RequiresResubmitValue = int.Parse(RequiresResubmit); co.RequireResubmit = RequiresResubmitValue != 0; co.OriginalFileName = resultSet["OriginalFileName"].ToString(); co.OriginalFileId = resultSet["OriginalFileId"].ToString(); } catch { } }
/// <summary> /// /// </summary> /// <param name="query"></param> /// <param name="count"></param> /// <param name="start"></param> /// <returns></returns> public IEnumerable<ContentObject> GetObjectsWithRange(string query, int count, int start, SortOrder order, string username) { List<ContentObject> objects = new List<ContentObject>(); System.Data.Odbc.OdbcConnection conn = GetConnection(); { using (var command = conn.CreateCommand()) { command.CommandText = query; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("s", start); command.Parameters.AddWithValue("length", count); command.Parameters.AddWithValue("sortOrder", (order == SortOrder.Descending) ? "DESC" : "ASC"); command.Parameters.AddWithValue("uname", username); using (var resultSet = command.ExecuteReader()) { while (resultSet.Read()) { var co = new ContentObject(); FillContentObjectLightLoad(co, resultSet); LoadReviews(co, conn); objects.Add(co); } } } if(_TotalObjects < 0) setContentObjectCount(conn, username); } return objects; }
/// <summary> /// /// </summary> /// <param name="co"></param> /// <param name="filename"></param> /// <param name="type"></param> /// <param name="UVset"></param> /// <returns></returns> public bool AddMissingTexture(ContentObject co, string filename, string type, int UVset) { System.Data.Odbc.OdbcConnection connection = GetConnection(); { using (var command = connection.CreateCommand()) { //AddMissingTexture(pid,filename,texturetype,uvset) command.CommandText = "{CALL AddMissingTexture(?,?,?,?,?)}"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("filename", filename); command.Parameters.AddWithValue("texturetype", type); command.Parameters.AddWithValue("uvset", UVset); command.Parameters.AddWithValue("pid", co.PID); command.Parameters.AddWithValue("revision", co.Revision); var result = command.ExecuteReader(); co.MissingTextures.Add(new Texture(filename, type, 0)); } } return true; }
/// <summary> /// /// </summary> /// <param name="co"></param> /// <param name="filename"></param> /// <returns></returns> public bool RemoveTextureReference(ContentObject co, string filename) { System.Data.Odbc.OdbcConnection connection = GetConnection(); { using (var command = connection.CreateCommand()) { command.CommandText = "{CALL DeleteTextureReference(?,?,?)}"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("pid", co.PID); command.Parameters.AddWithValue("filename", filename); command.Parameters.AddWithValue("revision", co.Revision); var result = command.ExecuteReader(); List<Texture> remove = new List<Texture>(); foreach (Texture t in co.TextureReferences) { if (t.mFilename == filename) remove.Add(t); } foreach (Texture t in remove) { if (t.mFilename == filename) co.TextureReferences.Remove(t); } } } return true; }
/// <summary> /// /// </summary> /// <param name="data"></param> /// <param name="co"></param> /// <param name="filename"></param> /// <returns></returns> public string SetContentFile(Stream data, ContentObject co, string filename) { return(SetContentFile(data, co.PID, filename)); }
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); } }
/// <summary> /// /// </summary> /// <param name="co"></param> /// <param name="resultSet"></param> private void FillContentObjectLightLoad(ContentObject co, OdbcDataReader resultSet) { try { co.PID = resultSet["PID"].ToString(); co.Description = resultSet["Description"].ToString(); co.Title = resultSet["Title"].ToString(); co.ScreenShot = resultSet["ScreenShotFileName"].ToString(); co.ScreenShotId = resultSet["ScreenShotFileId"].ToString(); co.Views = int.Parse(resultSet["Views"].ToString()); co.ThumbnailId = resultSet["ThumbnailFileId"].ToString(); co.Thumbnail = resultSet["ThumbnailFileName"].ToString(); } catch { } }
public string AddSupportingFile(System.IO.Stream data, ContentObject co, string filename) { return(SetContentFile(data, co.PID, filename)); }
/// <summary> /// /// </summary> /// <param name="co"></param> /// <param name="connection"></param> private void LoadMissingTextures(ContentObject co, OdbcConnection connection) { using (var command = connection.CreateCommand()) { command.CommandText = "{CALL GetMissingTextures(?,?)}"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("pid", co.PID); command.Parameters.AddWithValue("revision", co.Revision); var result = command.ExecuteReader(); while (result.Read()) { co.MissingTextures.Add(new Texture(result["Filename"].ToString(), result["Type"].ToString(), int.Parse(result["UVSet"].ToString()))); } } }
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; } }
public static FileStatus DetectFormat(string filename) { FileStatus currentStatus = new FileStatus("", FormatType.UNRECOGNIZED); //The temp filename (hashname) is a sha1 hash plus a random number currentStatus.hashname = filename; currentStatus.msg = FileStatus.UnrecognizedMessage; //Check to see if it's an skp file if (string.Compare(currentStatus.hashname.Substring(currentStatus.hashname.LastIndexOf('.')), ".skp", true) == 0) { currentStatus.type = FormatType.VIEWABLE; currentStatus.extension = ".skp"; } else { int recognizedCount = 0; int viewableCount = 0; try { using (ZipFile zip = ZipFile.Read(HttpContext.Current.Server.MapPath("~/App_Data/") + currentStatus.hashname)) { int i = 0; foreach (string s in zip.EntryFileNames) { System.IO.FileInfo f = new System.IO.FileInfo(s); if (FileStatus.GetType(f.Extension) == FormatType.VIEWABLE) { if (zip.Entries[i].UncompressedSize == 0) { currentStatus.msg = FileStatus.ModelFileEmptyMessage; return currentStatus; } currentStatus.extension = f.Extension; currentStatus.type = FormatType.VIEWABLE; recognizedCount++; } else if (FileStatus.GetType(f.Extension) == FormatType.RECOGNIZED) { if (currentStatus.type != FormatType.VIEWABLE) { if (zip.Entries[i].UncompressedSize == 0) { currentStatus.msg = FileStatus.ModelFileEmptyMessage; return currentStatus; } currentStatus.extension = f.Extension; currentStatus.type = FormatType.RECOGNIZED; } currentStatus.msg = FileStatus.WarningMessage; viewableCount++; } i++; } } } catch (ZipException e) { currentStatus.msg = FileStatus.InvalidZipMessage; return currentStatus; } //Make sure there is only one recognized or viewable model format in the zip file //If multiple have been detected, set the format type and break if (viewableCount > 1) { currentStatus.type = FormatType.MULTIPLE_RECOGNIZED; currentStatus.msg = FileStatus.MultipleRecognizedMessage; } } if (currentStatus.type == FormatType.UNRECOGNIZED || currentStatus.type == FormatType.MULTIPLE_RECOGNIZED) { deleteTempFile(currentStatus.hashname); } else { HttpContext.Current.Session["fileStatus"] = currentStatus; } ContentObject tempFedoraObject = new ContentObject(); tempFedoraObject.UploadedDate = DateTime.Now; tempFedoraObject.LastModified = DateTime.Now; tempFedoraObject.Views = 0; tempFedoraObject.SubmitterEmail = HttpContext.Current.User.Identity.Name.Trim(); tempFedoraObject.Format = currentStatus.extension; HttpContext.Current.Session["contentObject"] = tempFedoraObject; return currentStatus; }
/// <summary> /// /// </summary> /// <param name="co"></param> /// <param name="filename"></param> /// <param name="type"></param> /// <param name="UVset"></param> /// <returns></returns> public bool AddMissingTexture(ContentObject co, string filename, string type, int UVset) { return(_metadataStore.AddMissingTexture(co, filename, type, UVset)); }
private void UploadSponsorLogo(vwarDAL.IDataRepository dal, ContentObject co) { if (this.SponsorLogoRadioButtonList.SelectedItem != null) { switch (this.SponsorLogoRadioButtonList.SelectedValue.Trim()) { case "0": //use profile logo //use profile logo if use current and there's an empty file name otherwise don't change if (string.IsNullOrEmpty(co.SponsorLogoImageFileName)) { DataTable dt = UserProfileDB.GetUserProfileSponsorLogoByUserName(Context.User.Identity.Name); if (dt != null && dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; if (dr["Logo"] != System.DBNull.Value && dr["LogoContentType"] != System.DBNull.Value && !string.IsNullOrEmpty(dr["LogoContentType"].ToString())) { var data = (byte[])dr["Logo"]; using (MemoryStream s = new MemoryStream()) { s.Write(data, 0, data.Length); s.Position = 0; //filename co.SponsorLogoImageFileName = "sponsor.jpg"; if (!string.IsNullOrEmpty(dr["FileName"].ToString())) { co.SponsorLogoImageFileName = dr["FileName"].ToString(); } FedoraContentObject.SponsorLogoImageFileNameId = dal.SetContentFile(s, co, co.SponsorLogoImageFileName); } } } } break; case "1": //Upload logo if (this.SponsorLogoFileUpload.FileContent.Length > 0 && !string.IsNullOrEmpty(this.SponsorLogoFileUpload.FileName)) { co.SponsorLogoImageFileName = this.SponsorLogoFileUpload.FileName; co.DeveloperLogoImageFileNameId = dal.SetContentFile(this.SponsorLogoFileUpload.FileContent, co, this.SponsorLogoFileUpload.FileName); } break; case "2": //none break; } } }
private bool httpSearch(string term, ContentObject target) { bool found = false; string urlTemplate = String.Format(_baseUrl + "/Search/{0}/json?ID={1}", term, _apiKey); List<SearchResult> results = _serializer.Deserialize<List<SearchResult>>(getRawJSON(urlTemplate)); foreach (SearchResult sr in results) { if (sr.PID.Equals(target.PID)) { found = true; break; } } return found; }
protected void PopulateValidationViewMetadata(ContentObject co) { UnitScaleTextBox.Text = co.UnitScale; try { UpAxisRadioButtonList.SelectedValue = co.UpAxis; } catch { } NumPolygonsTextBox.Text = co.NumPolygons.ToString(); NumTexturesTextBox.Text = co.NumTextures.ToString(); UVCoordinateChannelTextBox.Text = "1"; if (!String.IsNullOrEmpty(co.ScreenShot)) { ThumbnailImage.ImageUrl = Page.ResolveClientUrl("~/Public/Serve.ashx") + "?pid=" + co.PID + "&mode=GetThumbnail"; } }
/// <summary> /// /// </summary> /// <param name="co"></param> /// <param name="connection"></param> /// <returns></returns> private bool LoadSupportingFiles(ContentObject co, OdbcConnection connection) { using (var command = connection.CreateCommand()) { command.CommandText = "{CALL GetSupportingFiles(?)}"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("pid", co.PID); var result = command.ExecuteReader(); while (result.Read()) { co.SupportingFiles.Add(new SupportingFile(result["Filename"].ToString(), result["Description"].ToString(), result["dsid"].ToString())); } } return true; }
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(); }
/// <summary> /// /// </summary> /// <param name="conn"></param> /// <param name="co"></param> /// <param name="id"></param> private void SaveKeywords(OdbcConnection conn, ContentObject co, int id) { char[] delimiters = new char[] { ',' }; string[] words = co.Keywords.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); string[] oldKeywords = LoadKeywords(conn, co.PID).Split(delimiters, StringSplitOptions.RemoveEmptyEntries); List<String> wordsToSave = new List<string>(); foreach (var word in words) { bool shouldSave = true; foreach (var oldWord in oldKeywords) { if (oldWord.Equals(word, StringComparison.InvariantCultureIgnoreCase)) { shouldSave = false; break; } } if (shouldSave) { wordsToSave.Add(word); } } words = wordsToSave.ToArray(); foreach (var keyword in words) { int keywordId = 0; using (var command = conn.CreateCommand()) { command.CommandText = "{CALL InsertKeyword(?)}"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("newKeyword", keyword); keywordId = int.Parse(command.ExecuteScalar().ToString()); } using (var cm = conn.CreateCommand()) { cm.CommandText = "{CALL AssociateKeyword(?,?)}"; cm.CommandType = System.Data.CommandType.StoredProcedure; cm.Parameters.AddWithValue("coid", id); cm.Parameters.AddWithValue("kid", keywordId); cm.ExecuteNonQuery(); } } }
/// <summary> /// /// </summary> /// <param name="co"></param> /// <param name="filename"></param> /// <param name="description"></param> public void AddSupportingFile(ContentObject co, string filename, string description, string dsid) { System.Data.Odbc.OdbcConnection connection = GetConnection(); { using (var command = connection.CreateCommand()) { //AddMissingTexture(pid,filename,texturetype,uvset) command.CommandText = "{CALL AddSupportingFile(?,?,?,?)}"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("newfilename", filename); command.Parameters.AddWithValue("newdescription", description); command.Parameters.AddWithValue("newcontentobjectid", co.PID); command.Parameters.AddWithValue("newdsid", dsid); var result = command.ExecuteReader(); //while (result.Read()) //{ co.SupportingFiles.Add(new SupportingFile(filename, description,dsid)); // } } } }
/// <summary> /// /// </summary> /// <param name="co"></param> public void DeleteContentObject(ContentObject co) { System.Data.Odbc.OdbcConnection conn = GetConnection(); { using (var command = conn.CreateCommand()) { command.CommandText = "{CALL DeleteContentObject(?)}"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.Add("targetpid", System.Data.Odbc.OdbcType.VarChar, 45).Value = co.PID; command.ExecuteNonQuery(); } } }
protected void TestSettings_Click(object sender, EventArgs e) { if (GNUPG_Key_Passphrase1.Text != GNUPG_Key_Passphrase2.Text) { LRStatus.Text = "GNUPG Passpharse must match!"; return; } if (LRNodePassword1.Text != LRNodePassword2.Text) { LRStatus.Text = "LR Node Password must match!"; return; } Configuration config = WebConfigurationManager.OpenWebConfiguration("~"); AppSettingsSection section = config.GetSection("appSettings") as AppSettingsSection; if (section != null) { SetSetting(section, "LR_Integration_KeyID", GNUPG_Key_ID.Text); SetSetting(section, "LR_Integration_KeyPassPhrase", GNUPG_Key_Passphrase1.Text); SetSetting(section, "LR_Integration_GPGLocation", GNUPG_Location.Text); SetSetting(section, "LR_Integration_PublicKeyURL", GNUPG_Public_Key_URL.Text); SetSetting(section, "LR_Integration_SubmitterName", Submitter_Name.Text); SetSetting(section, "LR_Integration_SignerName", Signer_Name.Text); SetSetting(section, "LR_Integration_APIBaseURL", APIBaseURL.Text); SetSetting(section, "LR_Integration_PublishURL", PublishURL.Text); SetSetting(section, "LR_Integration_NodeUsername", LRNodeUsername.Text); SetSetting(section, "LR_Integration_NodePassword", LRNodePassword1.Text); SetSetting(section, "LR_Integration_Enabled", LRIntegrationEnabled.Text); config.Save(); } try { vwarDAL.ContentObject co = new vwarDAL.ContentObject(); co.Keywords = "test"; co.Label = "test label"; co.PID = "testPID"; co.Location = "asdf"; co.LastViewed = DateTime.Now; co.LastModified = DateTime.Now; co.ArtistName = "test"; co.AssetType = "model"; co.CreativeCommonsLicenseURL = ""; co.Description = "test description"; co.DeveloperName = ""; LRStatus.Text = LR.LR_3DR_Bridge.ModelViewedInternal(co); } catch (Exception ex) { LRStatus.Text = ex.Message; } SetSetting(section, "LR_Integration_KeyID", GetOrignialValues()[GNUPG_Key_ID.ID]); SetSetting(section, "LR_Integration_KeyPassPhrase", GetOrignialValues()[GNUPG_Key_Passphrase1.ID]); SetSetting(section, "LR_Integration_GPGLocation", GetOrignialValues()[GNUPG_Location.ID]); SetSetting(section, "LR_Integration_PublicKeyURL", GetOrignialValues()[GNUPG_Public_Key_URL.ID]); SetSetting(section, "LR_Integration_SubmitterName", GetOrignialValues()[Submitter_Name.ID]); SetSetting(section, "LR_Integration_SignerName", GetOrignialValues()[Signer_Name.ID]); SetSetting(section, "LR_Integration_APIBaseURL", GetOrignialValues()[APIBaseURL.ID]); SetSetting(section, "LR_Integration_PublishURL", GetOrignialValues()[PublishURL.ID]); SetSetting(section, "LR_Integration_NodeUsername", GetOrignialValues()[LRNodeUsername.ID]); SetSetting(section, "LR_Integration_NodePassword", GetOrignialValues()[LRNodePassword1.ID]); SetSetting(section, "LR_Integration_Enabled", GetOrignialValues()[LRIntegrationEnabled.ID]); if (LRStatus.Text.Contains("\"OK\": true")) { SaveLRSettings.Enabled = true; } Updatecheckmarks(); }
/// <summary> /// /// </summary> /// <param name="co"></param> /// <param name="filename"></param> /// <returns></returns> public bool RemoveMissingTexture(ContentObject co, string filename) { return(_metadataStore.RemoveMissingTexture(co, filename)); }