Exemple #1
0
        public override string DoJob()
        {
            var finishedMessage = string.Empty;
             try
             {
            var itemCount = 0;

            GetCandidates();
            var collector = new Collector();
            foreach (var f in Candidates)
            {
               File.SetAttributes(f, FileAttributes.Normal);
               itemCount++;
               Logger.Trace( string.Format( "Candidate: {0} ", f ) );
               var mi = new MediaInfo(f);
               if ( !mi.IsValid )
               {
                  Logger.Trace( string.Format( "{0} is invalid", f) );
                  continue;
               }

               if (!mi.HasValidExt())
               {
                  Logger.Trace( string.Format( "{0} has invalid ext", f ) );
                  continue;
               }

               mi.MagazineFolder = MagazineCollectionFolder;
               mi.Analyse();

               if (mi.IsTV)
               {
                  if (!collector.HaveIt( mi )) continue;
                  var newFile = collector.AddToTvCollection(mi);
                  Logger.Info( string.Format( "  Adding TV     - {0} ", newFile));
               }
               else if (mi.IsMagazine)
               {
                  var newFile = collector.MoveToMagQueue(mi);
                  Logger.Info(string.Format("  Queing Mag    - {0} ", newFile));
               }
               else if (mi.IsBook)
               {
                  var newFile = collector.MoveToViewQueue(mi);
                  Logger.Info( string.Format( "  Queing Book   - {0} ", newFile));
               }
               else if ( mi.IsNfl )
               {
                  var newFile = collector.AddToNflCollection( mi );
                  Logger.Info( string.Format( "  Adding NFL    - {0} ", newFile ) );
               }
               else if ( mi.IsSoccer )
               {
                  var newFile = collector.AddToSoccerCollection( mi );
                  Logger.Info( string.Format( "  Adding Soccer - {0} ", newFile ) );
               }
               else if ( mi.IsMovie )
               {
                  var newFile = collector.AddToMovieCollection( mi );
                  Logger.Info( string.Format( "  Adding Movie  - {0} ", newFile ) );
               }
               else
               {
                  Logger.Trace( string.Format( "   Not Recognised {0}", f ) );
               }
            }
            finishedMessage = string.Format("{0} items processed", itemCount);
             }
             catch (Exception ex)
             {
            Logger.Error(ex.StackTrace);
            throw;
             }
             Logger.Info("  {0}", finishedMessage);
             return finishedMessage;
        }