Esempio n. 1
0
        //Get the metadata object for a conten object
        public Metadata GetMetadata(string pid, string key)
        {
            if (!CheckKey(key))
                return null;
            try
            {

                //Metadata to return
                Metadata map = new Metadata();
                pid = pid.Replace('_', ':');
                //Get the content object

                vwarDAL.PermissionsManager perm = new vwarDAL.PermissionsManager();
                vwarDAL.ModelPermissionLevel plevel = perm.GetPermissionLevel(vwarDAL.DefaultUsers.Anonymous[0], pid);
                perm.Dispose();
                //Check the permissions
                if (!DoValidate(Security.TransactionType.Query, pid))
                {
                    ReleaseRepo();
                    return null;
                }

                //removing to deal with stale issues when the GUI is used to update metadata.
                Metadata fromcache = null;// CacheManager.CheckCache<Metadata>(new CacheIdentifier(pid, "", CacheIdentifier.FILETYPE.METADATA));
                if (fromcache != null)
                    return fromcache;

                vwarDAL.ContentObject co = GetRepo().GetContentObjectById(pid, false);

                //If there is no location, dont return data
                if (co.Location != "")
                {
                    map.ConversionAvailable = co.DisplayFileId != "" && co.DisplayFileId != null;
                    map.AnonymousDownloadAvailable = plevel >= vwarDAL.ModelPermissionLevel.Fetchable;
                    map.PID = co.PID;
                    map.Title = co.Title;
                    map.Keywords = co.Keywords;
                    map.Format = co.Format;
                    map.Downloads = co.Downloads.ToString();
                    map.DeveloperName = co.DeveloperName;
                    map.Description = co.Description;
                    map.ArtistName = co.ArtistName;
                    map.AssetType = co.AssetType;
                    map.NumPolygons = co.NumPolygons.ToString();
                    map.NumTextures = co.NumTextures.ToString();
                    map.SponsorName = co.SponsorName;
                    map.UnitScale = co.UnitScale;
                    map.UpAxis = co.UpAxis;
                    map.UploadedDate = co.UploadedDate.ToString();
                    map.Views = co.Views.ToString();
                    map.Revision = co.Revision.ToString();
                    map.TotalRevisions = co.NumberOfRevisions.ToString();
                    map.MoreInformationURL = co.MoreInformationURL;
                    map.License = co.CreativeCommonsLicenseURL;
                    map.Distribution_Contolling_Office = co.Distribution_Contolling_Office;
                    map.Distribution_Determination_Date = co.Distribution_Determination_Date.ToShortDateString();
                    map.Distribution_Grade = Enum.GetName(typeof(vwarDAL.DistributionGrade), co.Distribution_Grade);
                    map.Distribution_Reason = co.Distribution_Reason;
                    map.Distribution_Regulation = co.Distribution_Regulation;
                    map.RequiresResubmit = co.RequireResubmit;
                    // map.License = co.CreativeCommonsLicenseURL;
                    //Get the supporting files, and copy to a serializable class
                    map.SupportingFiles = new List<SupportingFile>();
                    foreach (vwarDAL.SupportingFile i in co.SupportingFiles)
                    {
                        SupportingFile f2 = new SupportingFile();
                        f2.Filename = i.Filename;
                        f2.Description = i.Description;

                        map.SupportingFiles.Add(f2);
                    }

                    //Get the texture references and copy to a serializable class
                    map.TextureReferences = new List<Texture>();
                    foreach (vwarDAL.Texture i in co.TextureReferences)
                    {
                        Texture f2 = new Texture();
                        f2.mFilename = i.mFilename;
                        f2.mType = i.mType;
                        f2.mUVSet = i.mUVSet;

                        map.TextureReferences.Add(f2);
                    }

                    //Get the missing textures, and copy to a serializable class
                    map.MissingTextures = new List<Texture>();
                    foreach (vwarDAL.Texture i in co.MissingTextures)
                    {
                        Texture f2 = new Texture();
                        f2.mFilename = i.mFilename;
                        f2.mType = i.mType;
                        f2.mUVSet = i.mUVSet;

                        map.MissingTextures.Add(f2);
                    }

                    CacheManager.Cache<Metadata>(ref map, new CacheIdentifier(pid, "", CacheIdentifier.FILETYPE.METADATA));

                }
                //Return the data
                ReleaseRepo();
                return map;
            }
            catch (Exception ex)
            {
                return new Metadata { Title = ex.Message };
            }
            ReleaseRepo();
            return new Metadata { Title = "got here" };
        }
Esempio n. 2
0
        //Get the metadata object for a conten object
        public Metadata GetMetadata(string pid, string key)
        {
            if (!CheckKey(key))
                return null;
            try
            {

                //Metadata to return
                Metadata map = new Metadata();
                pid = pid.Replace('_', ':');
                //Get the content object
                vwarDAL.ContentObject co = GetRepo().GetContentObjectById(pid, false);
                vwarDAL.PermissionsManager perm = new vwarDAL.PermissionsManager();
                vwarDAL.ModelPermissionLevel plevel = perm.GetPermissionLevel(vwarDAL.DefaultUsers.Anonymous[0], co.PID);
                perm.Dispose();
                //Check the permissions
                if (!DoValidate(Security.TransactionType.Query, co))
                {
                    ReleaseRepo();
                    return null;
                }

                //If there is no location, dont return data
                if (co.Location != "")
                {
                    map.ConversionAvailable = co.DisplayFileId != "" && co.DisplayFileId != null;
                    map.AnonymousDownloadAvailable = plevel >= vwarDAL.ModelPermissionLevel.Fetchable;
                    map.PID = co.PID;
                    map.Title = co.Title;
                    map.Keywords = co.Keywords;
                    map.Format = co.Format;
                    map.Downloads = co.Downloads.ToString();
                    map.DeveloperName = co.DeveloperName;
                    map.Description = co.Description;
                    map.ArtistName = co.ArtistName;
                    map.AssetType = co.AssetType;
                    map.NumPolygons = co.NumPolygons.ToString();
                    map.NumTextures = co.NumTextures.ToString();
                    map.SponsorName = co.SponsorName;
                    map.UnitScale = co.UnitScale;
                    map.UpAxis = co.UpAxis;
                    map.UploadedDate = co.UploadedDate.ToString();
                    map.Views = co.Views.ToString();
                    map.Revision = co.Revision.ToString();
                    map.TotalRevisions = co.NumberOfRevisions.ToString();
                    map.MoreInformationURL = co.MoreInformationURL;
                    map.License = co.CreativeCommonsLicenseURL;

                   // map.License = co.CreativeCommonsLicenseURL;
                    //Get the supporting files, and copy to a serializable class
                    map.SupportingFiles = new List<SupportingFile>();
                    foreach (vwarDAL.SupportingFile i in co.SupportingFiles)
                    {
                        SupportingFile f2 = new SupportingFile();
                        f2.Filename = i.Filename;
                        f2.Description = i.Description;

                        map.SupportingFiles.Add(f2);
                    }

                    //Get the texture references and copy to a serializable class
                    map.TextureReferences = new List<Texture>();
                    foreach (vwarDAL.Texture i in co.TextureReferences)
                    {
                        Texture f2 = new Texture();
                        f2.mFilename = i.mFilename;
                        f2.mType = i.mType;
                        f2.mUVSet = i.mUVSet;

                        map.TextureReferences.Add(f2);
                    }

                    //Get the missing textures, and copy to a serializable class
                    map.MissingTextures = new List<Texture>();
                    foreach (vwarDAL.Texture i in co.MissingTextures)
                    {
                        Texture f2 = new Texture();
                        f2.mFilename = i.mFilename;
                        f2.mType = i.mType;
                        f2.mUVSet = i.mUVSet;

                        map.MissingTextures.Add(f2);
                    }

                }
                //Return the data
                ReleaseRepo();
                return map;
            }
            catch (Exception ex)
            {
                return new Metadata { Title = ex.Message };
            }
            ReleaseRepo();
            return new Metadata { Title = "got here" };
        }