Exemplo n.º 1
0
        //========================================================================================
        // Execute()
        //========================================================================================

        /// <summary>
        /// Execute the scanner.
        /// </summary>

        public override void Execute()
        {
            Logger.WriteLine(base.name,
                             String.Format("Import beginning, path '{0}'", playlistPath));

            reader = PlaylistProviderFactory.CreateReader(playlistPath);

            try
            {
                ExecuteInternal();
            }
            catch (Exception exc)
            {
                Logger.WriteLine(base.name, exc);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Dispose();
                    reader = null;
                }

                base.ProgressPercentage = 100;
                UpdateProgress(Resx.Completed);

                Logger.WriteLine(base.name, "Import completed");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initialize the environment for an export or synchronize operation.
        /// </summary>

        private void Initialize()
        {
            Logger.WriteLine(base.name,
                             String.Format("Export beginning, using encoder '{0}'",
                                           encoder == null ? "(skip)" : encoder.Name));

            // attach COM status handlers
            base.EnableInterrupt(controller);

            // override current encoder if different than requested
            if ((encoder != null) && !encoder.IsEmpty)
            {
                if (!controller.CurrentEncoder.Name.Equals(encoder.Name))
                {
                    // remember user's preferred encoder
                    saveEncoder = controller.CurrentEncoder;

                    // set the temporary encoder for this playlist
                    controller.CurrentEncoder = encoder;
                }
            }

            // ensure that 'location' exists before continuing.  This will be more efficient
            // for cases that do not require further subdirectories but also sets the stage...

            if (!Directory.Exists(location))
            {
                if (ScannerBase.isLive)
                {
                    Directory.CreateDirectory(location);
                }
            }

            // if we do want subdirectories then ensure we can create them
            if (!createSubdirectories)
            {
                createSubdirectories = EnsureFolderCapability();
            }

            // initialize and open the playlist writer if a playlist is requested
            if (ScannerBase.isLive && !playlistFormat.Equals(PlaylistProviderFactory.NoFormat))
            {
                writer = PlaylistProviderFactory.CreateWriter(
                    playlistFormat, location, exportPIDs.Name, createSubdirectories);
            }

            // this ManualResetEvent is used to synchronize sequential processing of iTunes
            // tracks as they are encoded.  iTunes encoding is an asynchronous procedure
            // however, iTunes does not allow concurrent encodings to occur.

            reset   = new ManualResetEvent(false);
            exports = new StringCollection();
        }