internal OriginedGroupedTrack(Album ial, IList<Track> iTracks, AlbumTarget at) { Tracks = iTracks; OriginAlbum = ial; Complete = ial.Tracks.Count == Tracks.Count; NewTarget = at; }
//private void MemoryClean(IImportContext Context) //{ // if (this.ID != 0) // { // //Element deja persiste, je l'ajoute a la transaction // Context.AddForRemove(this); // return; // } // else // { // //element jamais persiste // //tres probablement lie a rollback de creation // //je clean la session de l'object sans le detruire de la DB // (this as ISessionPersistentObject).UnRegisterFromSession(Context); // (this as ISessionPersistentObject).SetInternalState(ObjectState.Removed, Context); // } //} internal void RemoveAlbum(Album al, IImportContext Context) { AlbumHandler.ModelCollection.Remove(al); // Artist remove handled by NHibernate now: cascade alldeleteOrphan // easier and prevent when artist are switched beetween albums // in the same transaction //if (AlbumHandler.ModelCollection.Count == 0) //{ // MemoryClean(Context); //} }
//private string _NormalizedName; //public string NormalizedName //{ // get // { // //if (_NormalizedName == null) // // _NormalizedName = _Name==null ? null: _Name.NormalizeSpace().ToLower().WithoutAccent(); // //return _NormalizedName; // return (_Name == null) ? null : _Name.NormalizeSpace().ToLower().WithoutAccent(); // } //} internal void AddAlbum(Album al,IImportContext Context) { if (AlbumHandler.ModelCollection.Contains(al)) { return; } AlbumHandler.ModelCollection.Add(al); if (AlbumHandler.ModelCollection.Count == 1) { Context.Publish(this); } }
private ExportAlbum(Album al, bool Copyall) { _Al = al; Artist = al.Author; Genre = al.Genre; IDs = al.CDIDs; TracksNumber = al.Interface.TracksNumber; Name = al.Name; Year = al.Interface.Year; DateAdded = al.Interface.DateAdded; if (Copyall) { Tracks = (from tr in al.RawTracks select new ExportTrack(tr, this)).ToList(); Images = (from im in al.ModifiableImages select new ImageInfo() { ID = im.Rank, Path = im.GetPath() }).ToList(); Thumbnail = al.ImageCachePath; } }
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; }
internal AlbumModifier(Album iAM, bool resetCorruptedImage, IImportContext IT) { _AM = iAM; _IT = IT; _AlbumImages = iAM.RawImages; _AlbumImages.MofifiableCollection.CollectionChanged += OnImagesChanged; _Artists = iAM.GetArtistModifier(); _Artists.MofifiableCollection.CollectionChanged += MofifiableCollection_CollectionChanged; _Artists.OnCommit += new EventHandler<EventArgs>(_Artists_OnCommit); _OldArtist = _Artists.MofifiableCollection.ToList(); if (resetCorruptedImage) { Stack<int> IndexToRemove = new Stack<int>(); for (int i=0;i<_AlbumImages.MofifiableCollection.Count;i++) { if (_AlbumImages.MofifiableCollection[i] == null) IndexToRemove.Push(i); } while (IndexToRemove.Count > 0) { _AlbumImages.MofifiableCollection.RemoveAt(IndexToRemove.Pop()); } foreach (IAlbumPicture pic in (from im in _AlbumImages.MofifiableCollection where im.IsBroken select im).ToList()) { Images.Remove(pic); } } }
internal void UpdateImagesFrom(Album other) { int k = this.ModifiableImages.Count; bool ud = false; foreach (AlbumImage ai in other.ModifiableImages.Where(im => !im.IsBroken)) { if (!this.ModifiableImages.Contains(ai, ai.Comparer)) { AlbumImage nai = ai.Clone(this); nai.Rank = k++; this.ModifiableImages.Add(nai); ud = true; } } if (ud) { CachedImage.Update(); PropertyHasChangedUIOnly(_ImagesProperty); PropertyHasChangedUIOnly(_FrontImageProperty); } }
static internal AlbumDescriptor BuildForExport(Album al, bool Copyall, bool CopyImage) { var res = new AlbumDescriptor(); res.Artist = al.Author; res.Genre = al.Genre; res.RawIDs = al.CDIDs; res.TracksNumber = al.Interface.TracksNumber; res.Name = al.Name; res.Year = al.Interface.Year; res.DateAdded = al.Interface.DateAdded; if (Copyall) { res.RawTrackDescriptors = (from tr in al.RawTracks select new TrackDescriptor(res, tr)).ToList(); if (CopyImage) res.RawImages = (from im in al.ModifiableImages select new AImage(BufferFactory.GetBufferProviderFromFile(im.GetPath()), im.Rank)).ToList(); res.Thumbnail = al.ImageCachePath; } return res; }
static internal AlbumDescriptor DuplicateFromAlbum(Album al) { return BuildForExport(al, false, false); }
static internal AlbumDescriptor CopyAlbum(Album al, bool CopyImage = true) { return BuildForExport(al, true, CopyImage); }
static internal ExportAlbum DuplicateFromAlbum(Album al) { return new ExportAlbum(al, false); }
static internal ExportAlbum CopyAlbum(Album al) { return new ExportAlbum(al, true); }
internal ImageCache(Album Father, IBufferProvider iBp) { _Father = Father; _Buffer = iBp; }
internal ImageCache(Album Father) { _Father = Father; Update(); }
internal AlbumStatus(Album Ial, AlbumInfo ai) { Found = Ial; Status = ai; switch (ai) { case AlbumInfo.NewToTransaction: case AlbumInfo.ValidatedByEU: if (Found == null) throw new Exception(); break; case AlbumInfo.RefusedByEU: if (Found!=null) throw new Exception(); break; } }