Exemple #1
0
        /// <summary>
        /// Sets a single property value for a media object.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="property">The property.</param>
        /// <param name="value">The value.</param>
        /// <remarks>Documented by Dev02, 2008-08-07</remarks>
        /// <remarks>Documented by Dev03, 2009-01-13</remarks>
        public void SetPropertyValue(int id, MediaProperty property, string value)
        {
            using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser))
            {
                NpgsqlTransaction tran = con.BeginTransaction();

                using (NpgsqlCommand cmd = con.CreateCommand())
                {
                    if (GetPropertyValue(id, property) == null)
                    {
                        cmd.CommandText = "INSERT INTO \"MediaProperties\" (media_id, property, \"value\") VALUES (:media_id, :property, :value);";
                    }
                    else
                    {
                        cmd.CommandText = "UPDATE \"MediaProperties\" SET \"value\"=:value WHERE media_id=:media_id AND property=:property;";
                    }

                    cmd.Parameters.Add("media_id", id);
                    cmd.Parameters.Add("property", property.ToString());
                    cmd.Parameters.Add("value", value);
                    PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser);
                }

                tran.Commit();
            }
        }
Exemple #2
0
        public Video(string filePath)
        {
            ShellFile file = ShellFile.FromFilePath(filePath);

            FilePath = filePath;
            FileName = file.Properties.System.FileName.Value;

            Tags     = new ArrayMediaProperty(file.Properties.System.Keywords.Value, MediaSection.Description);
            Subtitle = new MediaProperty(file.Properties.System.Media.Subtitle.Value, MediaSection.Description);
            Comments = new MediaProperty(file.Properties.System.Comment.Value, MediaSection.Description);
            Rating   = new UintMediaProperty(file.Properties.System.Rating.Value, MediaSection.Description);
            Title    = new MediaProperty(file.Properties.System.Title.Value, MediaSection.Description);

            Directors      = new ArrayMediaProperty(file.Properties.System.Video.Director.Value, MediaSection.Origin);
            Producers      = new ArrayMediaProperty(file.Properties.System.Media.Producer.Value, MediaSection.Origin);
            Writers        = new ArrayMediaProperty(file.Properties.System.Media.Writer.Value, MediaSection.Origin);
            MediaCreated   = new DateTimeMediaProperty(file.Properties.System.DateCreated.Value, MediaSection.Origin);
            AuthorURL      = new MediaProperty(file.Properties.System.Media.AuthorUrl.Value, MediaSection.Origin);
            PromotionalURL = new MediaProperty(file.Properties.System.Media.PromotionUrl.Value, MediaSection.Origin);
            Publisher      = new MediaProperty(file.Properties.System.Media.Publisher.Value, MediaSection.Origin);

            ContributingArtists = new ArrayMediaProperty(file.Properties.System.Music.Artist.Value, MediaSection.Media);
            Genre = new ArrayMediaProperty(file.Properties.System.Music.Genre.Value, MediaSection.Media);
            Year  = new UintMediaProperty(file.Properties.System.Media.Year.Value, MediaSection.Media);
        }
Exemple #3
0
        public Audio(string filePath)
        {
            ShellFile file = ShellFile.FromFilePath(filePath);

            FilePath = filePath;
            FileName = file.Properties.System.FileName.Value;

            BPM      = new MediaProperty(file.Properties.System.Music.BeatsPerMinute.Value, MediaSection.Content);
            Composer = new ArrayMediaProperty(file.Properties.System.Music.Composer.Value, MediaSection.Content);

            AlbumArtist         = new MediaProperty(file.Properties.System.Music.AlbumArtist.Value, MediaSection.Media);
            Album               = new MediaProperty(file.Properties.System.Music.AlbumTitle.Value, MediaSection.Media);
            TrackNumber         = new UintMediaProperty(file.Properties.System.Music.TrackNumber.Value, MediaSection.Media);
            ContributingArtists = new ArrayMediaProperty(file.Properties.System.Music.Artist.Value, MediaSection.Media);
            Genre               = new ArrayMediaProperty(file.Properties.System.Music.Genre.Value, MediaSection.Media);

            Comments = new MediaProperty(file.Properties.System.Comment.Value, MediaSection.Description);
            Rating   = new UintMediaProperty(file.Properties.System.Rating.Value, MediaSection.Description);
            Title    = new MediaProperty(file.Properties.System.Title.Value, MediaSection.Description);
            Subtitle = new MediaProperty(file.Properties.System.Media.Subtitle.Value, MediaSection.Description);

            Publisher = new MediaProperty(file.Properties.System.Media.Publisher.Value, MediaSection.Origin);
            AuthorURL = new MediaProperty(file.Properties.System.Media.AuthorUrl.Value, MediaSection.Origin);
            //Copyright               = new MediaProperty(file.Properties.System.Copyright.Value;
            //Creator                 = file.Properties.System.Media.Creator.Value; WTF WHERE DID THIS GO?!
        }
Exemple #4
0
        public Picture()
        {
            FilePath = null;
            FileName = null;

            Comments = new MediaProperty(String.Empty, MediaSection.Description);
            Title    = new MediaProperty(String.Empty, MediaSection.Description);
            Tags     = new ArrayMediaProperty(Array.Empty <string>(), MediaSection.Description);
            Subject  = new MediaProperty(String.Empty, MediaSection.Description);
            Rating   = new UintMediaProperty(null, MediaSection.Description);

            Authors      = new ArrayMediaProperty(Array.Empty <string>(), MediaSection.Origin);
            ProgramName  = new MediaProperty(String.Empty, MediaSection.Origin);
            DateAcquired = new DateTimeMediaProperty(null, MediaSection.Origin);
            DateTaken    = new DateTimeMediaProperty(null, MediaSection.Origin);
        }
Exemple #5
0
 /// <summary>
 /// 视频信息浏览窗体加载
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void frmVideoInfoScan_Load(object sender, EventArgs e)
 {
     try
     {
         //////////////////////////////////////////////////////////////////////////在控件中显示视频文件的各种属性
         MediaProperty mediaProperty = MediaDescription.GetMediaProperty(videoFileName);
         propertyGrid_Media.SelectedObject = mediaProperty;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         this.Close();
         this.Dispose();
         GC.Collect();
     }
 }
Exemple #6
0
        //public String Copyright         { get; set; }
        #endregion

        public Picture(string filePath)
        {
            ShellFile file = ShellFile.FromFilePath(filePath);

            FilePath = filePath;
            FileName = file.Properties.System.FileName.Value;

            Comments = new MediaProperty(file.Properties.System.Comment.Value, MediaSection.Description);
            Title    = new MediaProperty(file.Properties.System.Title.Value, MediaSection.Description);
            Tags     = new ArrayMediaProperty(file.Properties.System.Keywords.Value, MediaSection.Description);
            Subject  = new MediaProperty(file.Properties.System.Subject.Value, MediaSection.Description);
            Rating   = new UintMediaProperty(file.Properties.System.Rating.Value, MediaSection.Description);

            Authors      = new ArrayMediaProperty(file.Properties.System.Author.Value, MediaSection.Origin);
            ProgramName  = new MediaProperty(file.Properties.System.ApplicationName.Value, MediaSection.Origin);
            DateAcquired = new DateTimeMediaProperty(file.Properties.System.DateAcquired.Value, MediaSection.Origin);
            DateTaken    = new DateTimeMediaProperty(file.Properties.System.Photo.DateTaken.Value, MediaSection.Origin);

            //Copyright       = file.Properties.System.Copyright.Value;
        }
Exemple #7
0
        public Video()
        {
            FilePath = null;
            FileName = null;

            Tags     = new ArrayMediaProperty(Array.Empty <string>(), MediaSection.Description);
            Subtitle = new MediaProperty(String.Empty, MediaSection.Description);
            Comments = new MediaProperty(String.Empty, MediaSection.Description);
            Rating   = new UintMediaProperty(null, MediaSection.Description);
            Title    = new MediaProperty(String.Empty, MediaSection.Description);

            Directors      = new ArrayMediaProperty(Array.Empty <string>(), MediaSection.Origin);
            Producers      = new ArrayMediaProperty(Array.Empty <string>(), MediaSection.Origin);
            Writers        = new ArrayMediaProperty(Array.Empty <string>(), MediaSection.Origin);
            MediaCreated   = new DateTimeMediaProperty(null, MediaSection.Origin);
            AuthorURL      = new MediaProperty(String.Empty, MediaSection.Origin);
            PromotionalURL = new MediaProperty(String.Empty, MediaSection.Origin);
            Publisher      = new MediaProperty(String.Empty, MediaSection.Origin);

            ContributingArtists = new ArrayMediaProperty(Array.Empty <string>(), MediaSection.Media);
            Genre = new ArrayMediaProperty(Array.Empty <string>(), MediaSection.Media);
            Year  = new UintMediaProperty(null, MediaSection.Media);
        }
Exemple #8
0
        public Audio()
        {
            FilePath = null;
            FileName = null;

            BPM      = new MediaProperty(String.Empty, MediaSection.Content);
            Composer = new ArrayMediaProperty(Array.Empty <string>(), MediaSection.Content);

            AlbumArtist         = new MediaProperty(String.Empty, MediaSection.Media);
            Album               = new MediaProperty(String.Empty, MediaSection.Media);
            TrackNumber         = new UintMediaProperty(null, MediaSection.Media);
            ContributingArtists = new ArrayMediaProperty(Array.Empty <string>(), MediaSection.Media);
            Genre               = new ArrayMediaProperty(Array.Empty <string>(), MediaSection.Media);

            Comments = new MediaProperty(String.Empty, MediaSection.Description);
            Rating   = new UintMediaProperty(null, MediaSection.Description);
            Title    = new MediaProperty(String.Empty, MediaSection.Description);
            Subtitle = new MediaProperty(String.Empty, MediaSection.Description);

            Publisher = new MediaProperty(String.Empty, MediaSection.Origin);
            AuthorURL = new MediaProperty(String.Empty, MediaSection.Origin);
            //Copyright               = new MediaProperty(file.Properties.System.Copyright.Value;
            //Creator                 = file.Properties.System.Media.Creator.Value; WTF WHERE DID THIS GO?!
        }
Exemple #9
0
        /// <summary>
        /// Gets a single property value for a media object.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="property">The property.</param>
        /// <returns></returns>
        /// <remarks>Documented by Dev02, 2008-08-07</remarks>
        /// <remarks>Documented by Dev03, 2009-01-13</remarks>
        public string GetPropertyValue(int id, MediaProperty property)
        {
            Dictionary <MediaProperty, string> properties = Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.GetIdentifier(CacheObject.MediaProperties, id)] as Dictionary <MediaProperty, string>;

            if (properties != null && properties.ContainsKey(property))
            {
                return(properties[property]);
            }

            using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser))
            {
                using (NpgsqlCommand cmd = con.CreateCommand())
                {
                    cmd.CommandText = "SELECT property, value FROM \"MediaProperties\" WHERE media_id=:id";
                    cmd.Parameters.Add("id", id);
                    NpgsqlDataReader reader = PostgreSQLConn.ExecuteReader(cmd, Parent.CurrentUser);

                    properties = new Dictionary <MediaProperty, string>();
                    while (reader.Read())
                    {
                        properties[(MediaProperty)Enum.Parse(typeof(MediaProperty), reader["property"].ToString())] = reader["value"].ToString();
                    }

                    Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.MediaProperties, id, new TimeSpan(1, 0, 0))] = properties;

                    if (properties.ContainsKey(property))
                    {
                        return(properties[property]);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
        }
        /// <summary>
        /// Sets a single property value for a media object.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="property">The property.</param>
        /// <param name="value">The value.</param>
        /// <remarks>Documented by Dev02, 2008-08-07</remarks>
        /// <remarks>Documented by Dev03, 2009-01-13</remarks>
        public void SetPropertyValue(int id, MediaProperty property, string value)
        {
            using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser))
            {
                NpgsqlTransaction tran = con.BeginTransaction();

                using (NpgsqlCommand cmd = con.CreateCommand())
                {
                    if (GetPropertyValue(id, property) == null)
                        cmd.CommandText = "INSERT INTO \"MediaProperties\" (media_id, property, \"value\") VALUES (:media_id, :property, :value);";
                    else
                        cmd.CommandText = "UPDATE \"MediaProperties\" SET \"value\"=:value WHERE media_id=:media_id AND property=:property;";

                    cmd.Parameters.Add("media_id", id);
                    cmd.Parameters.Add("property", property.ToString());
                    cmd.Parameters.Add("value", value);
                    PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser);
                }

                tran.Commit();
            }
        }
        /// <summary>
        /// Gets a single property value for a media object.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="property">The property.</param>
        /// <returns></returns>
        /// <remarks>Documented by Dev02, 2008-08-07</remarks>
        /// <remarks>Documented by Dev03, 2009-01-13</remarks>
        public string GetPropertyValue(int id, MediaProperty property)
        {
            Dictionary<MediaProperty, string> properties = Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.GetIdentifier(CacheObject.MediaProperties, id)] as Dictionary<MediaProperty, string>;
            if (properties != null && properties.ContainsKey(property))
                return properties[property];

            using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser))
            {
                using (NpgsqlCommand cmd = con.CreateCommand())
                {
                    cmd.CommandText = "SELECT property, value FROM \"MediaProperties\" WHERE media_id=:id";
                    cmd.Parameters.Add("id", id);
                    NpgsqlDataReader reader = PostgreSQLConn.ExecuteReader(cmd, Parent.CurrentUser);

                    properties = new Dictionary<MediaProperty, string>();
                    while (reader.Read())
                        properties[(MediaProperty)Enum.Parse(typeof(MediaProperty), reader["property"].ToString())] = reader["value"].ToString();

                    Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.MediaProperties, id, new TimeSpan(1, 0, 0))] = properties;

                    if (properties.ContainsKey(property))
                        return properties[property];
                    else
                        return null;
                }
            }
        }
Exemple #12
0
 public static MediaSection GetMediaSection(MediaProperty property)
 {
     return(property.MediaSection);
 }
Exemple #13
0
 set => this.SetValue(MediaProperty, value);