Пример #1
0
 public static void LogErr(string text, string trace)
 {
     lock (_lockObject)
     {
         if (_instError == null)
         {
             _instError = new ErrorLog(_errLogFileName);
         }
         _instError.Log(text, trace);
         _instError.Close();
         _instError = null;
     }
 }
Пример #2
0
        /// <summary>Starts dumping with the established fields and autodetecting the device type</summary>
        public void Start()
        {
            // Open main database
            _ctx = AaruContext.Create(Settings.Settings.MainDbPath);

            // Search for device in main database
            _dbDev = _ctx.Devices.FirstOrDefault(d => d.Manufacturer == _dev.Manufacturer && d.Model == _dev.Model &&
                                                 d.Revision == _dev.FirmwareRevision);

            if (_dbDev is null)
            {
                _dumpLog.WriteLine("Device not in database, please create a device report and attach it to a Github issue.");

                UpdateStatus?.
                Invoke("Device not in database, please create a device report and attach it to a Github issue.");
            }
            else
            {
                _dumpLog.WriteLine($"Device in database since {_dbDev.LastSynchronized}.");
                UpdateStatus?.Invoke($"Device in database since {_dbDev.LastSynchronized}.");

                if (_dbDev.OptimalMultipleSectorsRead > 0)
                {
                    _maximumReadable = (uint)_dbDev.OptimalMultipleSectorsRead;
                }
            }

            if (_dev.IsUsb &&
                _dev.UsbVendorId == 0x054C &&
                (_dev.UsbProductId == 0x01C8 || _dev.UsbProductId == 0x01C9 || _dev.UsbProductId == 0x02D2))
            {
                PlayStationPortable();
            }
            else
            {
                switch (_dev.Type)
                {
                case DeviceType.ATA:
                    Ata();

                    break;

                case DeviceType.MMC:
                case DeviceType.SecureDigital:
                    SecureDigital();

                    break;

                case DeviceType.NVMe:
                    NVMe();

                    break;

                case DeviceType.ATAPI:
                case DeviceType.SCSI:
                    Scsi();

                    break;

                default:
                    _dumpLog.WriteLine("Unknown device type.");
                    _dumpLog.Close();
                    StoppingErrorMessage?.Invoke("Unknown device type.");

                    return;
                }
            }

            _errorLog.Close();
            _dumpLog.Close();

            if (_resume == null ||
                !_doResume)
            {
                return;
            }

            _resume.LastWriteDate = DateTime.UtcNow;
            _resume.BadBlocks.Sort();

            if (File.Exists(_outputPrefix + ".resume.xml"))
            {
                File.Delete(_outputPrefix + ".resume.xml");
            }

            var fs = new FileStream(_outputPrefix + ".resume.xml", FileMode.Create, FileAccess.ReadWrite);
            var xs = new XmlSerializer(_resume.GetType());

            xs.Serialize(fs, _resume);
            fs.Close();
        }