コード例 #1
0
        public static void AddMetadata(FileInfo fileInfo, int fileId)
        {
            string ext = Util.GetFileExtension(fileInfo.Extension);

            List <string> txt = new List <string> {
                "Length", "Name", "CreationTime", "IsReadOnly", "LastAccessTime", "LastWriteTime", "Attributes"
            };
            List <string> jpg = new List <string> {
                "Length", "Name", "CreationTime", "IsReadOnly", "LastAccessTime", "LastWriteTime", "Attributes"
            };
            List <string> pdf = new List <string> {
                "Length", "Name", "CreationTime", "IsReadOnly", "LastAccessTime", "LastWriteTime", "Attributes"
            };

            //if the set of metadatas for the new extension does not exist in the database use the defaultList of metadata
            List <string> defaultList = new List <string> {
                "Length", "Name", "CreationTime", "IsReadOnly", "LastAccessTime", "LastWriteTime", "Attributes"
            };


            //all the metadata extensions
            Dictionary <string, List <string> > extensions = new Dictionary <string, List <string> >()
            {
                { "default", defaultList },
                { "txt", txt },
                { "jpg", jpg },
                { "pdf", pdf }
            };

            ext = extensions.ContainsKey(ext) ? ext : "default";
            foreach (string metadataTypeName in extensions[ext])
            {
                var metadata = new Model.Metadata();
                metadata.Value = ReflectPropertyValuefileInfo(fileInfo, metadataTypeName).ToString();

                RepositoryMetadata.SaveMetadataToDb(metadata, GetMetadataTypeId(metadataTypeName), fileId);
            }
        }
コード例 #2
0
 public static void SaveMetadataIntoDb(Metadata metadata, string metadataTypeName, int fileId)
 {
     RepositoryMetadata.SaveMetadataToDb(metadata, GetMetadataTypeId(metadataTypeName), fileId);
 }