示例#1
0
        protected virtual void AddTrackList(object cached_list)
        {
            CachedList <DatabaseTrackInfo> list = cached_list as CachedList <DatabaseTrackInfo>;

            is_adding          = true;
            AddTrackJob.Total += (int)list.Count;

            foreach (DatabaseTrackInfo track in list)
            {
                if (AddTrackJob.IsCancelRequested)
                {
                    AddTrackJob.Finish();
                    IncrementAddedTracks();
                    break;
                }

                if (track == null)
                {
                    IncrementAddedTracks();
                    continue;
                }

                try {
                    AddTrackJob.Status = String.Format("{0} - {1}", track.ArtistName, track.TrackTitle);
                    AddTrackAndIncrementCount(track);
                } catch (Exception e) {
                    IncrementAddedTracks();
                    Log.Exception(e);
                    ErrorSource.AddMessage(e.Message, track.Uri.ToString());
                }
            }
            is_adding = false;
        }
示例#2
0
        public void AddRemove()
        {
            var sm = new SourceManager ();
            var src = new ErrorSource ("Foo");
            sm.AddSource (src, false);
            Assert.AreEqual (sm.Sources.Count, 1);

            var src2 = new ErrorSource ("Bar");
            sm.AddSource (src2, true);
            Assert.IsTrue (sm.Sources.Count == 2);
            Assert.AreEqual (src2, sm.DefaultSource);
            Assert.AreEqual (src2, sm.ActiveSource);

            sm.SetActiveSource (src);
            Assert.AreEqual (src, sm.ActiveSource);

            sm.RemoveSource (src);
            Assert.IsTrue (sm.Sources.Count == 1);
        }
示例#3
0
        public void AddRemove()
        {
            var sm  = new SourceManager();
            var src = new ErrorSource("Foo");

            sm.AddSource(src, false);
            Assert.AreEqual(sm.Sources.Count, 1);

            var src2 = new ErrorSource("Bar");

            sm.AddSource(src2, true);
            Assert.IsTrue(sm.Sources.Count == 2);
            Assert.AreEqual(src2, sm.DefaultSource);
            Assert.AreEqual(src2, sm.ActiveSource);

            sm.SetActiveSource(src);
            Assert.AreEqual(src, sm.ActiveSource);

            sm.RemoveSource(src);
            Assert.IsTrue(sm.Sources.Count == 1);
        }
 public DatabaseImportManager (ErrorSource error_source, TrackPrimarySourceChooser chooser,
     int [] primarySourceIds, string baseDirectory) : this (chooser)
 {
     this.error_source = error_source;
     primary_source_ids = primarySourceIds;
     base_directory = baseDirectory;
 }
示例#5
0
        protected virtual void DeleteTrackList(CachedList <DatabaseTrackInfo> list)
        {
            is_deleting           = true;
            DeleteTrackJob.Total += (int)list.Count;
            List <DatabaseTrackInfo> skip_deletion = null;

            // Remove from file system
            foreach (DatabaseTrackInfo track in list)
            {
                if (track == null)
                {
                    DeleteTrackJob.Completed++;
                    continue;
                }

                try {
                    DeleteTrackJob.Status = String.Format("{0} - {1}", track.ArtistName, track.TrackTitle);
                    if (!DeleteTrack(track))
                    {
                        if (skip_deletion == null)
                        {
                            skip_deletion = new List <DatabaseTrackInfo> ();
                        }
                        skip_deletion.Add(track);
                    }
                } catch (Exception e) {
                    Log.Exception(e);
                    ErrorSource.AddMessage(e.Message, track.Uri.ToString());
                }

                DeleteTrackJob.Completed++;
                if (DeleteTrackJob.Completed % 10 == 0 && !DeleteTrackJob.IsFinished)
                {
                    OnTracksDeleted();
                }
            }

            is_deleting = false;

            if (DeleteTrackJob.Total == DeleteTrackJob.Completed)
            {
                delete_track_job.Finish();
                delete_track_job = null;
            }

            if (skip_deletion != null)
            {
                list.Remove(skip_deletion);
                skip_deletion.Clear();
                skip_deletion = null;
            }

            // Remove from database
            if (list.Count > 0)
            {
                ServiceManager.DbConnection.Execute(remove_list_command, DateTime.Now, list.CacheId, list.CacheId);
            }

            ThreadAssist.ProxyToMain(delegate {
                OnTracksDeleted();
                OnUserNotifyUpdated();
                OnUpdated();
            });
        }