private static bool AlbumMerge(Album Changing, AlbumModifier AM, IImportContext IT, IProgress<ImportExportError> progress)
        {
            try
            {
                AM._UnderTrans = true;

                if (!Changing.Images.SequenceEqual(AM._AM.Images, (im1, im2) => im1.CompareContent(im2)))
                {
                    int i = 0;
                    foreach (AlbumImage im in Changing.Images)
                    {
                        AM.Images.Insert(i++, im.Clone(AM._AM));
                    }
                }

                //forceons l'ecriture des infos albums pour les tracks migres
                AM.Name = AM.Name;
                AM.ForceAuthorReWrite();

                if (AM._AM.Genre == null)
                    AM.Genre = Changing.Genre;

                if (AM._AM.Interface.Year == 0)
                    AM.Year = Changing.Interface.Year;

                IList<Track> tracks = Changing.RawTracks.ToList();

                using (IMusicTransaction IMut = IT.CreateTransaction())
                {
                    foreach (Track tr in tracks)
                    {
                        AM.Tracks.Add(new TrackModifier(tr.CloneTo(IT, AM._AM), AM));
                    }

                    AM.TrivialCommit(IMut, progress);

                    IT.AddForRemove(Changing);

                    IMut.Commit();
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine("Problem during Album Merge: " + e.ToString());
            }

            AM._UnderTrans = false;
            AM._AM.Context = null;

            return true;
        }
Exemplo n.º 2
0
        internal void ResetChanges(AlbumModifier AM)
        {
            lock (_Lockobject)
            {
                if (_Modifier == null)
                    return;

                if (_Modifier != AM)
                    throw new InvalidOperationException();

                _Modifier = null;
            }
        }
Exemplo n.º 3
0
        internal AlbumModifier GetModifiableAlbum(bool resetCorruptedImage, IImportContext IT)
        {
            if (_Modifier != null)
                return null;

            AlbumModifier Modifier = null;

            if ((IT == null) || (!object.ReferenceEquals(IT, _Context) && (_Context != null)))
                throw new Exception("Session Management");

            if (_Modifier == null)
            {
                Modifier = new AlbumModifier(this, resetCorruptedImage, IT);
            }

            lock (_Lockobject)
            {
                if (_Modifier == null)
                {
                    _Modifier = Modifier;
                    return _Modifier;
                }
                else
                    return null;
            }

        }
Exemplo n.º 4
0
        internal IIsolatedMofiableList<IModifiableTrack> GetTrackModifier(AlbumModifier am)
        {
            //UpdateTracks();

            SafeCollectionModifierConverter<Track, IModifiableTrack> res =
                new SafeCollectionModifierConverter<Track, IModifiableTrack>(ModifiableSortedTracks, ((t) => new TrackModifier(t, am)), ((t) => (t as TrackModifier).Track));


            res.OnBeforeChangedCommited += OnBeforeTrackModifiedCommitted;
            //res.OnCommit += OnTrackModifiedCommitted;

            return res;
        }
Exemplo n.º 5
0
        internal bool Modify(AlbumModifier AM)
        {
            lock (_Lockobject)//todo readerslim
            {

                try
                {

                    if (AM.IsAlbumOnlyModified)
                    {

                        if (AM.NewGenre != null)
                        {
                            Genre = AM.NewGenre;
                        }

                        if (AM.NewYear != null)
                        {
                            Year = (int)AM.NewYear;
                        }
                    }

                    foreach (IModifiableTrack TN in AM.Tracks)
                    {
                        (TN as TrackModifier).CommitChanges();
                    }

                    SortList();

                    return true;
                }
                catch (Exception e)
                {
                    Trace.WriteLine(e);
                    return false;
                }
            }//+		[System.IO.IOException]	{"The process cannot access the file 'C:\\Documents and Settings\\DEM\\My Documents\\My Music\\Music Collection\\ddd\\0\\Copy of Copy of Copy of Unknown Album 1\\1-Track 1.mp3' because it is being used by another process."}	System.IO.IOException

        }