Esempio n. 1
0
        /// <summary>
        /// Load
        /// </summary>
        /// <returns></returns>
        public static Records Load(Stream stream = null)
        {
            Records tmpRecords = null;

            if (stream != null)
            {
                //data
                tmpRecords = Deserialize(stream);
                tmpRecords.Size = stream.Length;
                stream.Dispose();
            }

            if (tmpRecords == null)
            {
                //new data
                tmpRecords = new Records();

                tmpRecords.GpsAllowed = true;
                tmpRecords.ObdAllowed = true;
                tmpRecords.DriveModeAllowed = true;
                tmpRecords.BackupOnStart = false;
                tmpRecords.Id = newGuid();

                tmpRecords.Backup = new BackupInfo();
                tmpRecords.Backup.Url = String.Empty;
                tmpRecords.Backup.Date = DateTime.Now;
                tmpRecords.Backup.Id = String.Empty;

                tmpRecords.Currency = Currency.USD;
                tmpRecords.Distance = Distance.Mi;
                tmpRecords.Unit = Unit.Liters;
                tmpRecords.Consumption = Consumption.LitersPer100Distance;
                tmpRecords.ObdDevice = String.Empty;

                tmpRecords.States = new ObservableCollection<State>();
                tmpRecords.Videos = new ObservableCollection<Video>();
                tmpRecords.Pictures = new ObservableCollection<Picture>();
                tmpRecords.Fills = new ObservableCollection<Fill>();
                tmpRecords.Repairs = new ObservableCollection<Repair>();
                tmpRecords.Maintenances = new ObservableCollection<Maintenance>();

                tmpRecords.Times = new Times();
                tmpRecords.Times.Circuits = new ObservableCollection<Circuit>();
            }

            return tmpRecords;
        }
Esempio n. 2
0
 /// <summary>
 /// From backup
 /// </summary>
 public void FromBackup(string path)
 {
     var stream = this.openStreamForRead(path);
     //file main
     if (path == DATA_FILE)
     {
         this.baseData = Records.Load(stream);
         //set globals
         RateExchange.CurrentCurrency = this.Currency;
         DistanceExchange.CurrentDistance = this.Distance;
         UnitExchange.CurrentUnit = this.Unit;
         //refresh
         RaisePropertiesChanged();
         //Start timer again
         StartTimer();
     }
     //speedway main
     if (path == SPEEDWAY_FILE)
     {
         this.speedwayData = Records.Load(stream);
         //refresh
         RaisePropertiesChanged();
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Data collector
 /// </summary>
 public Data()
 {
     Stream stream;
     //load file
     stream = this.openStreamForRead(DATA_FILE);
     baseData = Records.Load(stream);
     //load speedway file
     stream = this.openStreamForRead(SPEEDWAY_FILE);
     speedwayData = Records.Load(stream);
 }