Пример #1
0
        public void DoWork(IList <Set> sets, IList <DataAction> actions, string imageCacheFolder)
        {
            var applicationSettings = new ApplicationSettings();

            var localCardData  = new LocalCardData(applicationSettings.DetectionDataPath);
            var remoteCardData = new RemoteCardData(new RemoteDataFileClient(applicationSettings));

            var imageSource = new DualImageSource(imageCacheFolder);
            var logger      = new Logging();

            Synchronous.ForEach(actions, action =>
            {
                try
                {
                    action.Execute(localCardData, logger, imageSource, remoteCardData);
                }
                finally
                {
                    Interlocked.Increment(ref currentItem);
                }
            });

            logger.Close();
            localCardData.Close();
        }
Пример #2
0
 public override void Execute(LocalCardData localCardData, Logging logger, DualImageSource imageSource,
                              RemoteCardData remoteCardData)
 {
     try
     {
         localCardData.DeleteSetAndAssociatedCards(Set);
     }
     catch (SQLiteException e3)
     {
         logger.WriteLine($"SET={Set.Code},{Set.Name};EXCEPTION={e3.GetType()},{e3.Message}");
     }
 }
Пример #3
0
        public override void Execute(LocalCardData localCardData, Logging logger, DualImageSource imageSource,
                                     RemoteCardData remoteCardData)
        {
            try
            {
                var cards = remoteCardData.GetCards(Set);
                localCardData.AddSet(Set);

                Parallel.ForEach(cards, card =>
                {
                    try
                    {
                        var image = imageSource.GetImage(card, Set);

                        var imageHashing = new pHash();
                        if (image != null)
                        {
                            card.pHash = imageHashing.ImageHash(image);
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.WriteLine($"CARD={card.Name};SET={Set.Code};EXCEPTION={ex.GetType()},{ex.Message}");
                    }

                    try
                    {
                        localCardData.AddCard(card);
                    }
                    catch (SQLiteException e4)
                    {
                        logger.WriteLine(
                            $"CARD={card.MultiverseId},{card.Name};SET={Set.Code},{Set.Name};EXCEPTION={e4.GetType()},{e4.Message}");
                    }
                });
            }
            catch (JsonReaderException e1)
            {
                logger.WriteLine($"SET={Set.Code},{Set.Name};EXCEPTION={e1.GetType()},{e1.Message}");
            }
            catch (WebException e2)
            {
                logger.WriteLine($"SET={Set.Code},{Set.Name};EXCEPTION={e2.GetType()},{e2.Message}");
            }
            catch (SQLiteException e3)
            {
                logger.WriteLine($"SET={Set.Code},{Set.Name};EXCEPTION={e3.GetType()},{e3.Message}");
            }
        }
Пример #4
0
 public abstract void Execute(LocalCardData localCardData, Logging logger, DualImageSource imageSource,
                              RemoteCardData remoteCardData);