示例#1
0
        private async void ImportOptionToggleCommandExecute(Device device)
        {
            try
            {
                //get the device by id from data-store
                var storedDevice = await _deviceService.GetDeviceById(device.Id);

                //update the check-field
                storedDevice.ImportOption = (device.ImportOption == DeviceImportOption.Always ?
                                             DeviceImportOption.Never : DeviceImportOption.Always);

                //update same in db.
                await _deviceService.UpdateDevice(storedDevice);

                //_deviceService.SetImportOption(storedDevice.Id, storedDevice.ImportOption);


                await RefreshStoredDevices();

                //if importoption toggled to active for any device,check status change
                if (storedDevice.ImportOption == DeviceImportOption.Always)
                {
                    CheckDeviceStatusChange();
                }
                else if (_activeDevice != null && _activeDevice.Id.Equals(storedDevice.Id))
                {
                    _activeDevice.ImportOption = storedDevice.ImportOption;
                }
            }
            catch (Exception ex)
            {
                Utility.LogException(ex);
            }
        }
示例#2
0
 //[Not used]
 void _driveDetector_QueryRemove(object sender, DriveDetectorEventArgs e)
 {
     try
     {
         Utility.LogMessage("QueryRemove");
     }
     catch (Exception ex)
     {
         Utility.LogException(ex);
     }
 }
示例#3
0
 //[Not used]
 void _driveDetector_DeviceRemoved(object sender, DriveDetectorEventArgs e)
 {
     try
     {
         Utility.LogMessage("Device removed");
     }
     catch (Exception ex)
     {
         Utility.LogException(ex);
     }
 }
示例#4
0
 //remove device from db
 private async void ClearDeviceCommandExecute(Device device)
 {
     try
     {
         await _deviceService.RemoveDevice(device);
         await RefreshStoredDevices();
     }
     catch (Exception ex)
     {
         Utility.LogException(ex);
     }
 }
示例#5
0
 private void BrowseMediaBackupPathCommandExecute()
 {
     try
     {
         Messenger.Default.Send(new SelectFolderPathMessage((path) =>
         {
             OnMediaFolderSelected(path);
         }));
     }
     catch (Exception ex)
     {
         Utility.LogException(ex);
     }
 }
示例#6
0
 void _driveDetector_DeviceStatusChanged(object sender, DriveDetectorEventArgs e)
 {
     try
     {
         CheckDeviceStatusChange();
     }
     catch (Exception ex)
     {
         Utility.LogException(ex);
     }
     finally
     {
         _progressFlag = false;
     }
 }
示例#7
0
        private void CopyDeviceContents(Device device)
        {
            //if (System.Threading.Thread.CurrentThread.IsBackground)
            //    Utility.LogMessage("[CopyDeviceContents] [Task] [IsBackground][Device::{0}]",device.DisplayName);

            PortableDevice portableDevice = null;

            try
            {
                if (_connectedDeviceCollection != null &&
                    _connectedDeviceCollection.Count > 0)
                {
                    //get the connect device of same Id
                    portableDevice = _connectedDeviceCollection.
                                     SingleOrDefault(p => p.DeviceId.Equals(device.Id));

                    if (portableDevice != null)
                    {
                        portableDevice.Connect();

                        //set active device to current-device
                        Utility.LogMessage(@"[CopyDeviceContents] [Setting_ActiveDevice] [{0}]", device.DisplayName);
                        _activeDevice = device;

                        PortableDeviceFolder deviceFolder = portableDevice.GetContents();
                        FetchContents(portableDevice, deviceFolder);
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.LogException(ex);
            }
            finally
            {
                if (portableDevice != null)
                {
                    portableDevice.Disconnect();
                }

                Utility.LogMessage(@"[CopyDeviceContents] [Finally] [Setting_ActiveDevice][NULL]");
                _activeDevice = null;
            }
        }