public VolumeDescriptor( VolumeEventController eventController, string volName, string volFilename )
        {
            mEventController = eventController;
            mName = volName;
            mVolumeFilename = volFilename;

            mVolume = CreateVolume();
        }
        public VolumeDescriptor( VolumeEventController eventController, string volName, string volFilename, VolumeSource source, BaseArchive archive )
        {
            mEventController = eventController;
            mName = volName;
            mVolumeFilename = volFilename;

            mVolume = new Volume( mEventController, this, source, archive );
            ConnectToVolumeEvents( mVolume );
            mIsAvailable = true;
            SaveVolumeData();
        }
 public void InvokeRestoreStarted( Volume volume, VolumeSnapshot snapshot )
 {
     if ( RestoreStarted != null )
         RestoreStarted( volume, snapshot );
 }
 public void InvokeRestoreProgress( Volume volume, VolumeSnapshot snapshot, ulong fileNum, ulong fileCount, ulong bytesTranferred, ulong totalBytes )
 {
     if ( RestoreProgress != null )
         RestoreProgress( volume, snapshot, fileNum, fileCount, bytesTranferred, totalBytes );
 }
 public void InvokeBackupStarted( Volume volume, VolumeSnapshot snapshot, bool firstBackupOnLoad )
 {
     if ( BackupStarted != null )
         BackupStarted( volume, snapshot, false, firstBackupOnLoad );
 }
 public void InvokeBackupFinished( Volume volume, VolumeSnapshot snapshot, bool snapshotHasBeenSaved, bool firstBackupOnLoad )
 {
     if ( BackupFinished != null )
         BackupFinished( volume, snapshot, snapshotHasBeenSaved, firstBackupOnLoad );
 }
 public void InvokeVolumeSourceActiveStateChanged( Volume volume, bool isActive )
 {
     if ( VolumeSourceActiveStateChanged != null )
         VolumeSourceActiveStateChanged( volume, isActive );
 }
Beispiel #8
0
 public void BackupVolume( Volume volume, bool firstBackupOnLoad )
 {
     if ( volume.Descriptor.ReadyForBackup )
         volume.DoBackup();
 }
        public void ForceBackup( Volume volume, bool firstBackupOnLoad )
        {
            if ( volume.Descriptor.ReadyForBackup )
            {
                Log.WriteLine( LogType.TextLogVerbose, "Adding QueuedBackup (" + volume.Descriptor.VolumeName + ")" );

                QueuedBackupInfo qbi = new QueuedBackupInfo();
                qbi.mVolume = volume;
                qbi.mFirstBackupOnLoad = firstBackupOnLoad;

                mWorkerThread.RegisterOneShotTask( new PWLib.BackgroundWorkerThread.TaskPredicate( OnWorkerPredicate ),
                    new PWLib.BackgroundWorkerThread.Task( OnWorkerBackup ), new PWLib.BackgroundWorkerThread.TaskError( OnWorkerError ), qbi );
            }
        }
 public void ForceBackup( Volume volume )
 {
     ForceBackup( volume, false );
 }
 void mVolumeEventController_VolumeSourceActiveStateChanged( Volume volume, bool isActive )
 {
     // Find relevant VolumeSource, then do a backup (if enabled on that particular volume)
     try
     {
         if ( isActive )
         {
             lock ( VolumeDescriptorList.Instance.Descriptors )
             {
                 if ( volume.Descriptor.ReadyForBackup )
                 {
                     // kick off first insert backup
                     Log.WriteLine( LogType.TextLogVerbose, "Backing up volume by volume source state change (normally usb stick being plugged in)" );
                     ForceBackup( volume );
                 }
             }
         }
     }
     catch ( System.Exception e )
     {
         Log.WriteException( "DeviceInserted failed", e );
     }
 }
 void mVolume_OutputToXmlRequired( Volume volume )
 {
     SaveVolumeData();
 }
        Volume CreateVolume()
        {
            if ( PWLib.Platform.Windows.File.Exists( mVolumeFilename ) )
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load( mVolumeFilename );
                XmlNode mainNode = PWLib.XmlHelp.GetFirstChildWithName( xmlDoc, "Volume" );

                mName = PWLib.XmlHelp.DirtyString( PWLib.XmlHelp.GetAttribute( mainNode, "name", "" ) );
                mRevisionsToKeep = PWLib.XmlHelp.GetAttributeInt( mainNode, "revisionsToKeep", 1 );
                long timePeriodTicks = 0;
                long.TryParse( PWLib.XmlHelp.GetAttribute( mainNode, "timePeriodToMonitor", "" ), out timePeriodTicks );
                mTimePeriodToMonitor = TimeSpan.FromTicks( timePeriodTicks );

                long lastAttemptedBackupTicks = 0;
                long.TryParse( PWLib.XmlHelp.GetAttribute( mainNode, "lastattemptedbackup", "" ), out lastAttemptedBackupTicks );
                LastAttemptedBackup = new DateTime( lastAttemptedBackupTicks );

                mTotalDatabaseSize = 0;
                ulong.TryParse( PWLib.XmlHelp.GetAttribute( mainNode, "totaldatabasesize", "" ), out mTotalDatabaseSize );

                Volume volume = new Volume( mEventController, this, mainNode );
                ConnectToVolumeEvents( volume );
                mIsAvailable = true;
                return volume;
            }
            else
                return null;
        }
 void ConnectToVolumeEvents( Volume volume )
 {
     volume.OutputToXmlRequired += new AutoUSBBackup.Volume.OutputToXmlRequiredDelegate( mVolume_OutputToXmlRequired );
 }
 public void CheckAvailability()
 {
     bool fileExists = PWLib.Platform.Windows.File.Exists( mVolumeFilename );
     if ( fileExists && !mIsAvailable )
     {
         if ( mVolume != null )
             mVolume.Dispose();
         mVolume = CreateVolume();
         mIsAvailable = true;
         mEventController.InvokeVolumeDescriptorActiveStateChanged( this, true );
     }
     else if ( !fileExists && mIsAvailable )
     {
         mIsAvailable = false;
         mEventController.InvokeVolumeDescriptorActiveStateChanged( this, false );
     }
 }