コード例 #1
0
 internal TrackStatus(Track tr,AlbumStatus Ial)
 {
     Found = tr;
     AlbumInfo = Ial;
     Exist = false;
 }
コード例 #2
0
        private bool CommitChanges()
        {
            if (Context == null)
                return false;

            if (!AlbumModified && !SingleTrackUpdateNeeded)
            {
                //OnEdit();
                return false;
            }

            AlbumTargets = AlbumTarget.FromListAndTargets(Tracks, Artists, AlbumName, Genre, Year);

            if (!AlbumModified || (!IsModifiable))
            {
                if (SingleTrackUpdateNeeded)
                {
                    using (IMusicTransaction IMut = Context.CreateTransaction())
                    {
                        Tracks.Apply(t => { Context.AddForUpdate(t); UpdateTrack(t); });

                        IMut.Commit();
                    }
                    //reinjecter md dans la d

                    Tracks.Apply(t => t.SavetoDisk(Context));

                }

                return true;
            }

            using (IMusicTransaction IMut = Context.CreateTransaction())
            {

                foreach (AlbumTarget at in AlbumTargets)
                {
                    AlbumStatus ass = null;

                    Album res = at.TrivialAlbum;
                    if (res == null)
                    {
                        ass = Album.GetAvailableAlbumFromTrackDescriptor(new AlbumDescriptorDecorator(at, Context));
                    }
                    else
                    {
                        ass = new AlbumStatus(res, AlbumInfo.ValidatedByEU);
                        Context.AddForUpdate(res);
                    }

                    if (!ass.Continue)
                        continue;

                    Album nn = ass.Found;
                    at.AlbumNewAlbum = nn;


                    if (ass.Status == AlbumInfo.ValidatedByEU)
                    {
                        if (Genre != null)
                        {
                            nn.Genre = Genre;
                        }
                        if (Year != null)
                        {
                            nn.Year = (int)Year;
                        }
                    }
                    else
                    {
                        nn.DateAdded = at.OrderedTrack[0].OriginAlbum.DateAdded;
                        nn.ClearImages();
                    }

                    at.OrderedTrack.Apply(ott =>
                    {
                        if ((ott.OriginAlbum != nn))
                        {
                           //ordre important ici
                            //1
                            ott.Tracks.Apply(tr => nn.CloneTrack(tr, Context));
                            //2
                            if (ott.Complete) Context.AddForRemove(ott.OriginAlbum); else Context.AddForUpdate(ott.OriginAlbum);

                            nn.UpdateImagesFrom(ott.OriginAlbum);
                        }
                    });
                }

                //aditional change on track if needed
                Tracks.Apply(UpdateTrack);

                IMut.Commit();

                //reinjecter md dans la d
                AlbumTargets.Apply(ate => { if (ate.AlbumNewAlbum != null) ate.AlbumNewAlbum.RawTracks.Apply(t => t.SavetoDisk(Context)); });
            }
            //change year and genre on 2 phase

            return true;
        }
コード例 #3
0
 internal TrackStatus(AlbumStatus Ial)
 {
     Found = null;
     AlbumInfo = Ial;
     Exist = false;
 }