Exemplo n.º 1
0
        public void Start()
        {
            running = true;

            // Read ROM drives to backup
            DriveInfo[] allDrives = DriveInfo.GetDrives();
            foreach (DriveInfo driveInfo in allDrives)
            {
                try
                {
                    if (driveInfo.DriveType == DriveType.CDRom && driveInfo.VolumeLabel != null)
                    {
                        // Run MakeMKV to backup movie
                        Job job = null;
                        if (GlobalBackupMethod == BackupMode.MakeMKV)
                        {
                            job = new BackupDiskMakeMKVJob(makeMKVService, handBrakeService, driveInfo.Name, MakeMkvKeepFiles, GlobalMinMovieLen);
                        }
                        else if (GlobalBackupMethod == BackupMode.HandBrake)
                        {
                            job = new BackupDiskHandBrakeJob(handBrakeService, driveInfo.Name.Replace("\\", ""), GlobalBackupAll, GlobalMinMovieLen);
                        }

                        if (job != null)
                        {
                            // move backups to the top of the queue
                            jobQueue.AddJob(job, true);
                        }
                    }
                }
                catch (IOException)
                {
                    // skip for device not ready
                }
            }

            // Setup Monitoring
            SetupDriveMonitoring();

            // Read in existing files for encode
            AddEncodingJobs(HandBrakeSourceDir);


            // Start file monitoring
            SetupFileMonitoring(HandBrakeSourceDir);

            progressReporter.Shutdown = false;

            jobThread = new Thread(new ThreadStart(JobRunner))
            {
                Name = "JobRunner"
            };
            jobThread.Start();
        }
Exemplo n.º 2
0
        private void CDREventArrived(object sender, EventArrivedEventArgs e)
        {
            // New Disk!
            Debug.WriteLine("BackupService starting");
            // Get the Event object and display it
            PropertyData pd = e.NewEvent.Properties["TargetInstance"];

            if (pd != null)
            {
                ManagementBaseObject mbo = pd.Value as ManagementBaseObject;

                // if CD removed VolumeName == null
                if (mbo.Properties["DeviceID"].Value != null)
                {
                    if (mbo.Properties["VolumeName"].Value != null)
                    {
                        Debug.WriteLine("CD has been inserted: " + mbo.Properties["VolumeName"].Value);
                        // Run MakeMKV to backup movie
                        Job job = null;
                        if (GlobalBackupMethod == BackupMode.MakeMKV)
                        {
                            job = new BackupDiskMakeMKVJob(makeMKVService, handBrakeService, (string)mbo.Properties["DeviceID"].Value, MakeMkvKeepFiles, GlobalMinMovieLen);
                        }
                        else if (GlobalBackupMethod == BackupMode.HandBrake)
                        {
                            job = new BackupDiskHandBrakeJob(handBrakeService, mbo.Properties["DeviceID"].Value.ToString().Replace("\\", ""), GlobalBackupAll, GlobalMinMovieLen);
                        }
                        if (job != null)
                        {
                            jobQueue.AddJob(job, true);
                        }
                    }
                    else
                    {
                        Debug.WriteLine("CD has been removed: " + mbo.Properties["DeviceID"].Value);
                    }
                }
                else
                {
                    Console.WriteLine("CD has been ejected");
                }
            }
        }