mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Moved statistics to metadata.
This commit is contained in:
@@ -34,145 +34,32 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
using DiscImageChef.Metadata;
|
||||
using System.Net;
|
||||
using DiscImageChef.Console;
|
||||
using System.Threading;
|
||||
|
||||
namespace DiscImageChef.Core
|
||||
{
|
||||
[XmlRoot("DicStats", Namespace = "", IsNullable = false)]
|
||||
public class Stats
|
||||
{
|
||||
public CommandsStats Commands;
|
||||
[XmlArrayItem("Filesystem")]
|
||||
public List<NameValueStats> Filesystems;
|
||||
[XmlArrayItem("Scheme")]
|
||||
public List<NameValueStats> Partitions;
|
||||
[XmlArrayItem("Format")]
|
||||
public List<NameValueStats> MediaImages;
|
||||
[XmlArrayItem("Filter", IsNullable = true)]
|
||||
public List<NameValueStats> Filters;
|
||||
[XmlArrayItem("Device", IsNullable = true)]
|
||||
public List<DeviceStats> Devices;
|
||||
[XmlArrayItem("Media")]
|
||||
public List<MediaStats> Medias;
|
||||
public BenchmarkStats Benchmark;
|
||||
public MediaScanStats MediaScan;
|
||||
public VerifyStats Verify;
|
||||
}
|
||||
|
||||
public class CommandsStats
|
||||
{
|
||||
public long Analyze;
|
||||
public long Benchmark;
|
||||
public long Checksum;
|
||||
public long Compare;
|
||||
public long CreateSidecar;
|
||||
public long Decode;
|
||||
public long DeviceInfo;
|
||||
public long DeviceReport;
|
||||
public long DumpMedia;
|
||||
public long Entropy;
|
||||
public long Formats;
|
||||
public long MediaInfo;
|
||||
public long MediaScan;
|
||||
public long PrintHex;
|
||||
public long Verify;
|
||||
}
|
||||
|
||||
public class VerifiedItems
|
||||
{
|
||||
public long Correct;
|
||||
public long Failed;
|
||||
}
|
||||
|
||||
public class VerifyStats
|
||||
{
|
||||
public VerifiedItems MediaImages;
|
||||
public ScannedSectors Sectors;
|
||||
}
|
||||
|
||||
public class ScannedSectors
|
||||
{
|
||||
public long Total;
|
||||
public long Error;
|
||||
public long Correct;
|
||||
public long Unverifiable;
|
||||
}
|
||||
|
||||
public class TimeStats
|
||||
{
|
||||
public long LessThan3ms;
|
||||
public long LessThan10ms;
|
||||
public long LessThan50ms;
|
||||
public long LessThan150ms;
|
||||
public long LessThan500ms;
|
||||
public long MoreThan500ms;
|
||||
}
|
||||
|
||||
public class MediaScanStats
|
||||
{
|
||||
public ScannedSectors Sectors;
|
||||
public TimeStats Times;
|
||||
}
|
||||
|
||||
public class ChecksumStats
|
||||
{
|
||||
[XmlAttribute]
|
||||
public string algorithm;
|
||||
[XmlText]
|
||||
public double Value;
|
||||
}
|
||||
|
||||
public class BenchmarkStats
|
||||
{
|
||||
[XmlElement("Checksum")]
|
||||
public List<ChecksumStats> Checksum;
|
||||
public double Entropy;
|
||||
public double All;
|
||||
public double Sequential;
|
||||
public long MaxMemory;
|
||||
public long MinMemory;
|
||||
}
|
||||
|
||||
public class MediaStats
|
||||
{
|
||||
[XmlAttribute]
|
||||
public bool real;
|
||||
[XmlAttribute]
|
||||
public string type;
|
||||
[XmlText]
|
||||
public long Value;
|
||||
}
|
||||
|
||||
public class DeviceStats
|
||||
{
|
||||
public string Manufacturer;
|
||||
public string Model;
|
||||
public string Revision;
|
||||
public string Bus;
|
||||
|
||||
[XmlIgnore]
|
||||
public bool ManufacturerSpecified;
|
||||
}
|
||||
|
||||
public class NameValueStats
|
||||
{
|
||||
[XmlAttribute]
|
||||
public string name;
|
||||
[XmlText]
|
||||
public long Value;
|
||||
}
|
||||
|
||||
public static class Statistics
|
||||
{
|
||||
public static Stats AllStats;
|
||||
public static Stats CurrentStats;
|
||||
|
||||
static bool submitStatsLock;
|
||||
|
||||
public static void LoadStats()
|
||||
{
|
||||
if(File.Exists(Path.Combine(Settings.Settings.StatsPath, "Statistics.xml")))
|
||||
{
|
||||
AllStats = new Stats();
|
||||
CurrentStats = new Stats();
|
||||
|
||||
CurrentStats = new Stats()
|
||||
{
|
||||
OperatingSystems = new List<NameValueStats>
|
||||
{
|
||||
new NameValueStats { name = Interop.DetectOS.GetRealPlatformID().ToString(), Value = 1 }
|
||||
}
|
||||
};
|
||||
XmlSerializer xs = new XmlSerializer(AllStats.GetType());
|
||||
StreamReader sr = new StreamReader(Path.Combine(Settings.Settings.StatsPath, "Statistics.xml"));
|
||||
AllStats = (Stats)xs.Deserialize(sr);
|
||||
@@ -181,7 +68,13 @@ namespace DiscImageChef.Core
|
||||
else if(Settings.Settings.Current.Stats != null)
|
||||
{
|
||||
AllStats = new Stats();
|
||||
CurrentStats = new Stats();
|
||||
CurrentStats = new Stats()
|
||||
{
|
||||
OperatingSystems = new List<NameValueStats>
|
||||
{
|
||||
new NameValueStats { name = Interop.DetectOS.GetRealPlatformID().ToString(), Value = 1 }
|
||||
}
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -194,6 +87,27 @@ namespace DiscImageChef.Core
|
||||
{
|
||||
if(AllStats != null)
|
||||
{
|
||||
if(AllStats.OperatingSystems != null)
|
||||
{
|
||||
long count = 0;
|
||||
|
||||
NameValueStats old = null;
|
||||
foreach(NameValueStats nvs in AllStats.OperatingSystems)
|
||||
{
|
||||
if(nvs.name == Interop.DetectOS.GetRealPlatformID().ToString())
|
||||
{
|
||||
count = nvs.Value;
|
||||
old = nvs;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(old != null)
|
||||
AllStats.OperatingSystems.Remove(old);
|
||||
|
||||
count++;
|
||||
AllStats.OperatingSystems.Add(new NameValueStats { name = Interop.DetectOS.GetRealPlatformID().ToString(), Value = count });
|
||||
}
|
||||
FileStream fs = new FileStream(Path.Combine(Settings.Settings.StatsPath, "Statistics.xml"), FileMode.Create);
|
||||
XmlSerializer xs = new XmlSerializer(AllStats.GetType());
|
||||
xs.Serialize(fs, AllStats);
|
||||
|
||||
@@ -30,12 +30,134 @@
|
||||
// Copyright © 2011-2017 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace DiscImageChef.Metadata
|
||||
{
|
||||
public class Statistics
|
||||
[XmlRoot("DicStats", Namespace = "", IsNullable = false)]
|
||||
public class Stats
|
||||
{
|
||||
public Statistics()
|
||||
{
|
||||
}
|
||||
[XmlArrayItem("OperatingSystem")]
|
||||
public List<NameValueStats> OperatingSystems { get; set; }
|
||||
public CommandsStats Commands;
|
||||
[XmlArrayItem("Filesystem")]
|
||||
public List<NameValueStats> Filesystems { get; set; }
|
||||
[XmlArrayItem("Scheme")]
|
||||
public List<NameValueStats> Partitions { get; set; }
|
||||
[XmlArrayItem("Format")]
|
||||
public List<NameValueStats> MediaImages { get; set; }
|
||||
[XmlArrayItem("Filter", IsNullable = true)]
|
||||
public List<NameValueStats> Filters { get; set; }
|
||||
[XmlArrayItem("Device", IsNullable = true)]
|
||||
public List<DeviceStats> Devices { get; set; }
|
||||
[XmlArrayItem("Media")]
|
||||
public List<MediaStats> Medias { get; set; }
|
||||
public BenchmarkStats Benchmark { get; set; }
|
||||
public MediaScanStats MediaScan { get; set; }
|
||||
public VerifyStats Verify { get; set; }
|
||||
}
|
||||
|
||||
public class CommandsStats
|
||||
{
|
||||
public long Analyze;
|
||||
public long Benchmark;
|
||||
public long Checksum;
|
||||
public long Compare;
|
||||
public long CreateSidecar;
|
||||
public long Decode;
|
||||
public long DeviceInfo;
|
||||
public long DeviceReport;
|
||||
public long DumpMedia;
|
||||
public long Entropy;
|
||||
public long Formats;
|
||||
public long MediaInfo;
|
||||
public long MediaScan;
|
||||
public long PrintHex;
|
||||
public long Verify;
|
||||
}
|
||||
|
||||
public class VerifiedItems
|
||||
{
|
||||
public long Correct;
|
||||
public long Failed;
|
||||
}
|
||||
|
||||
public class VerifyStats
|
||||
{
|
||||
public VerifiedItems MediaImages;
|
||||
public ScannedSectors Sectors;
|
||||
}
|
||||
|
||||
public class ScannedSectors
|
||||
{
|
||||
public long Total;
|
||||
public long Error;
|
||||
public long Correct;
|
||||
public long Unverifiable;
|
||||
}
|
||||
|
||||
public class TimeStats
|
||||
{
|
||||
public long LessThan3ms;
|
||||
public long LessThan10ms;
|
||||
public long LessThan50ms;
|
||||
public long LessThan150ms;
|
||||
public long LessThan500ms;
|
||||
public long MoreThan500ms;
|
||||
}
|
||||
|
||||
public class MediaScanStats
|
||||
{
|
||||
public ScannedSectors Sectors;
|
||||
public TimeStats Times;
|
||||
}
|
||||
|
||||
public class ChecksumStats
|
||||
{
|
||||
[XmlAttribute]
|
||||
public string algorithm;
|
||||
[XmlText]
|
||||
public double Value;
|
||||
}
|
||||
|
||||
public class BenchmarkStats
|
||||
{
|
||||
[XmlElement("Checksum")]
|
||||
public List<ChecksumStats> Checksum;
|
||||
public double Entropy;
|
||||
public double All;
|
||||
public double Sequential;
|
||||
public long MaxMemory;
|
||||
public long MinMemory;
|
||||
}
|
||||
|
||||
public class MediaStats
|
||||
{
|
||||
[XmlAttribute]
|
||||
public bool real;
|
||||
[XmlAttribute]
|
||||
public string type;
|
||||
[XmlText]
|
||||
public long Value;
|
||||
}
|
||||
|
||||
public class DeviceStats
|
||||
{
|
||||
public string Manufacturer { get; set; }
|
||||
public string Model { get; set; }
|
||||
public string Revision { get; set; }
|
||||
public string Bus { get; set; }
|
||||
|
||||
[XmlIgnore]
|
||||
public bool ManufacturerSpecified;
|
||||
}
|
||||
|
||||
public class NameValueStats
|
||||
{
|
||||
[XmlAttribute]
|
||||
public string name { get; set; }
|
||||
[XmlText]
|
||||
public long Value { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user