Beispiel #1
0
        public void SaveMediaToLibrary(List <MediaItem> pMediaItems)
        {
            NHibernate.ISession dbSession = DatabaseInterface.DataSession;

            // MediaGroupCreater mediaGroupCreater = new MediaGroupCreater();

            // retreive all stores and display them
            using (dbSession.BeginTransaction())
            {
                foreach (MediaItem item in pMediaItems)
                {
                    DigitalMediaLibrary dml = new DigitalMediaLibrary();

                    dml.Artist    = item.Artist;
                    dml.Album     = item.Album;
                    dml.FileName  = item.FileName;
                    dml.Frequency = item.Frequency;
                    dml.Genre     = item.Genre;
                    dml.Kbps      = item.Kbps;
                    dml.Path      = item.Path;
                    dml.Title     = item.Title;
                    dml.Track     = item.Track;
                    dml.DeviceId  = item.DeviceId;

                    try
                    {
                        dbSession.Save(dml);
                    }
                    catch
                    {
                    }
                    //mediaGroupCreater.AddMediaItem(dml);
                }
                try
                {
                    dbSession.Transaction.Commit();
                }
                catch (Exception ex) { DebugHandler.HandleException(ex); }

                //{
                //    DebugHandler.DebugPrint("Cannot save Media list: " + dmls.ErrorString);
                //}
            }
        }
Beispiel #2
0
        private MediaItem GetMediaItemFromMediaLibrary(DigitalMediaItem pMediaItem)
        {
            DigitalMediaLibrary item = null;

            if (pMediaItem.LibraryItem != null)
            {
                item = pMediaItem.LibraryItem;
            }
            else
            {
                item = GetDigitalMedia(pMediaItem.TargetId);
            }
            MediaItem mediaItem = new MediaItem();

            mediaItem.Artist = item.Artist;
            mediaItem.Album  = item.Album;
            mediaItem.Title  = item.Title;
            mediaItem.Path   = item.Path;
            mediaItem.Track  = item.Track;
            mediaItem.Genre  = item.Genre;

            return(mediaItem);
        }