mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Update database from server.
This commit is contained in:
5
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
5
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
@@ -42,6 +42,7 @@
|
|||||||
<e p="MediaScan.cs" t="Include" />
|
<e p="MediaScan.cs" t="Include" />
|
||||||
<e p="PrintHex.cs" t="Include" />
|
<e p="PrintHex.cs" t="Include" />
|
||||||
<e p="Statistics.cs" t="Include" />
|
<e p="Statistics.cs" t="Include" />
|
||||||
|
<e p="Update.cs" t="Include" />
|
||||||
<e p="Verify.cs" t="Include" />
|
<e p="Verify.cs" t="Include" />
|
||||||
</e>
|
</e>
|
||||||
<e p="DiscImageChef.csproj" t="IncludeRecursive" />
|
<e p="DiscImageChef.csproj" t="IncludeRecursive" />
|
||||||
@@ -295,9 +296,6 @@
|
|||||||
</e>
|
</e>
|
||||||
<e p="DiscImageChef.Database" t="IncludeRecursive">
|
<e p="DiscImageChef.Database" t="IncludeRecursive">
|
||||||
<e p="Context.cs" t="Include" />
|
<e p="Context.cs" t="Include" />
|
||||||
<e p="DTOs" t="Include">
|
|
||||||
<e p="SyncDTO.cs" t="Include" />
|
|
||||||
</e>
|
|
||||||
<e p="DiscImageChef.Database.csproj" t="IncludeRecursive" />
|
<e p="DiscImageChef.Database.csproj" t="IncludeRecursive" />
|
||||||
<e p="Migrations" t="Include">
|
<e p="Migrations" t="Include">
|
||||||
<e p="20181126222301_DeviceReportV2.Designer.cs" t="Include" />
|
<e p="20181126222301_DeviceReportV2.Designer.cs" t="Include" />
|
||||||
@@ -1821,7 +1819,6 @@
|
|||||||
<e p="UploadReportController.cs" t="Include" />
|
<e p="UploadReportController.cs" t="Include" />
|
||||||
<e p="UploadStatsController.cs" t="Include" />
|
<e p="UploadStatsController.cs" t="Include" />
|
||||||
</e>
|
</e>
|
||||||
<e p="DTOs" t="Include" />
|
|
||||||
<e p="DiscImageChef.Server.csproj" t="IncludeRecursive" />
|
<e p="DiscImageChef.Server.csproj" t="IncludeRecursive" />
|
||||||
<e p="Global.asax" t="Include" />
|
<e p="Global.asax" t="Include" />
|
||||||
<e p="Global.asax.cs" t="Include" />
|
<e p="Global.asax.cs" t="Include" />
|
||||||
|
|||||||
@@ -112,6 +112,7 @@
|
|||||||
<Name>DiscImageChef.Console</Name>
|
<Name>DiscImageChef.Console</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\DiscImageChef.Database\DiscImageChef.Database.csproj" />
|
<ProjectReference Include="..\DiscImageChef.Database\DiscImageChef.Database.csproj" />
|
||||||
|
<ProjectReference Include="..\DiscImageChef.Dto\DiscImageChef.Dto.csproj" />
|
||||||
<ProjectReference Include="..\DiscImageChef.Filesystems\DiscImageChef.Filesystems.csproj">
|
<ProjectReference Include="..\DiscImageChef.Filesystems\DiscImageChef.Filesystems.csproj">
|
||||||
<Project>{D7016DF2-5A5E-4524-B40D-BA2D59576688}</Project>
|
<Project>{D7016DF2-5A5E-4524-B40D-BA2D59576688}</Project>
|
||||||
<Name>DiscImageChef.Filesystems</Name>
|
<Name>DiscImageChef.Filesystems</Name>
|
||||||
|
|||||||
@@ -31,13 +31,21 @@
|
|||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using DiscImageChef.CommonTypes.Metadata;
|
using DiscImageChef.CommonTypes.Metadata;
|
||||||
|
using DiscImageChef.Console;
|
||||||
|
using DiscImageChef.Database;
|
||||||
|
using DiscImageChef.Database.Models;
|
||||||
|
using DiscImageChef.Dto;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using CdOffset = DiscImageChef.Database.Models.CdOffset;
|
||||||
using Version = DiscImageChef.CommonTypes.Metadata.Version;
|
using Version = DiscImageChef.CommonTypes.Metadata.Version;
|
||||||
|
|
||||||
namespace DiscImageChef.Core
|
namespace DiscImageChef.Core
|
||||||
@@ -162,5 +170,200 @@ namespace DiscImageChef.Core
|
|||||||
});
|
});
|
||||||
submitThread.Start();
|
submitThread.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void UpdateMasterDatabase(bool create)
|
||||||
|
{
|
||||||
|
DicContext mctx = DicContext.Create(Settings.Settings.MasterDbPath);
|
||||||
|
mctx.Database.Migrate();
|
||||||
|
mctx.SaveChanges();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
long lastUpdate = 0;
|
||||||
|
DateTime latest = DateTime.MinValue;
|
||||||
|
|
||||||
|
if(!create)
|
||||||
|
{
|
||||||
|
List<DateTime> latestAll = new List<DateTime>();
|
||||||
|
if(mctx.UsbVendors.Any()) latestAll.Add(mctx.UsbVendors.Max(v => v.ModifiedWhen));
|
||||||
|
if(mctx.UsbProducts.Any()) latestAll.Add(mctx.UsbProducts.Max(p => p.ModifiedWhen));
|
||||||
|
if(mctx.CdOffsets.Any()) latestAll.Add(mctx.CdOffsets.Max(o => o.ModifiedWhen));
|
||||||
|
if(mctx.Devices.Any()) latestAll.Add(mctx.Devices.Max(d => d.LastSynchronized));
|
||||||
|
|
||||||
|
if(latestAll.Any())
|
||||||
|
{
|
||||||
|
latest = latestAll.Max(t => t);
|
||||||
|
lastUpdate = (latest.ToFileTimeUtc() - new DateTime(1970, 1, 1).ToFileTimeUtc()) / 10000000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(lastUpdate == 0)
|
||||||
|
{
|
||||||
|
create = true;
|
||||||
|
DicConsole.WriteLine("Creating master database");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DicConsole.WriteLine("Updating master database");
|
||||||
|
DicConsole.WriteLine("Last update: {0}", latest);
|
||||||
|
}
|
||||||
|
|
||||||
|
DateTime updateStart = DateTime.UtcNow;
|
||||||
|
|
||||||
|
WebRequest request =
|
||||||
|
WebRequest.Create($"http://discimagechef.claunia.com/api/update?timestamp={lastUpdate}");
|
||||||
|
((HttpWebRequest)request).UserAgent = $"DiscImageChef {typeof(Version).Assembly.GetName().Version}";
|
||||||
|
request.Method = "GET";
|
||||||
|
request.ContentType = "application/json";
|
||||||
|
WebResponse response = request.GetResponse();
|
||||||
|
|
||||||
|
if(((HttpWebResponse)response).StatusCode != HttpStatusCode.OK)
|
||||||
|
{
|
||||||
|
DicConsole.ErrorWriteLine("Error {0} when trying to get updated entities.",
|
||||||
|
((HttpWebResponse)response).StatusCode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Stream data = response.GetResponseStream();
|
||||||
|
StreamReader reader = new StreamReader(data ?? throw new InvalidOperationException());
|
||||||
|
SyncDto sync = JsonConvert.DeserializeObject<SyncDto>(reader.ReadToEnd());
|
||||||
|
|
||||||
|
if(create)
|
||||||
|
{
|
||||||
|
DicConsole.WriteLine("Adding USB vendors");
|
||||||
|
foreach(UsbVendorDto vendor in sync.UsbVendors)
|
||||||
|
mctx.UsbVendors.Add(new UsbVendor(vendor.VendorId, vendor.Vendor));
|
||||||
|
|
||||||
|
DicConsole.WriteLine("Added {0} usb vendors", sync.UsbVendors.Count);
|
||||||
|
|
||||||
|
DicConsole.WriteLine("Adding USB products");
|
||||||
|
foreach(UsbProductDto product in sync.UsbProducts)
|
||||||
|
mctx.UsbProducts.Add(new UsbProduct(product.VendorId, product.ProductId, product.Product));
|
||||||
|
|
||||||
|
DicConsole.WriteLine("Added {0} usb products", sync.UsbProducts.Count);
|
||||||
|
|
||||||
|
DicConsole.WriteLine("Adding CompactDisc read offsets");
|
||||||
|
foreach(CdOffsetDto offset in sync.Offsets)
|
||||||
|
mctx.CdOffsets.Add(new CdOffset(offset) {Id = offset.Id});
|
||||||
|
|
||||||
|
DicConsole.WriteLine("Added {0} CompactDisc read offsets", sync.Offsets.Count);
|
||||||
|
|
||||||
|
DicConsole.WriteLine("Adding known devices");
|
||||||
|
foreach(DeviceDto device in sync.Devices) mctx.Devices.Add(new Device(device) {Id = device.Id});
|
||||||
|
|
||||||
|
DicConsole.WriteLine("Added {0} known devices", sync.Devices.Count);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
long addedVendors = 0;
|
||||||
|
long addedProducts = 0;
|
||||||
|
long addedOffsets = 0;
|
||||||
|
long addedDevices = 0;
|
||||||
|
long modifiedVendors = 0;
|
||||||
|
long modifiedProducts = 0;
|
||||||
|
long modifiedOffsets = 0;
|
||||||
|
long modifiedDevices = 0;
|
||||||
|
|
||||||
|
DicConsole.WriteLine("Updating USB vendors");
|
||||||
|
foreach(UsbVendorDto vendor in sync.UsbVendors)
|
||||||
|
{
|
||||||
|
UsbVendor existing = mctx.UsbVendors.FirstOrDefault(v => v.Id == vendor.VendorId);
|
||||||
|
|
||||||
|
if(existing != null)
|
||||||
|
{
|
||||||
|
modifiedVendors++;
|
||||||
|
existing.Vendor = vendor.Vendor;
|
||||||
|
existing.ModifiedWhen = updateStart;
|
||||||
|
mctx.UsbVendors.Update(existing);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
addedVendors++;
|
||||||
|
mctx.UsbVendors.Add(new UsbVendor(vendor.VendorId, vendor.Vendor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DicConsole.WriteLine("Added {0} USB vendors", addedVendors);
|
||||||
|
DicConsole.WriteLine("Modified {0} USB vendors", modifiedVendors);
|
||||||
|
|
||||||
|
DicConsole.WriteLine("Updating USB products");
|
||||||
|
foreach(UsbProductDto product in sync.UsbProducts)
|
||||||
|
{
|
||||||
|
UsbProduct existing =
|
||||||
|
mctx.UsbProducts.FirstOrDefault(p => p.VendorId == product.VendorId &&
|
||||||
|
p.ProductId == product.ProductId);
|
||||||
|
|
||||||
|
if(existing != null)
|
||||||
|
{
|
||||||
|
modifiedProducts++;
|
||||||
|
existing.Product = product.Product;
|
||||||
|
existing.ModifiedWhen = updateStart;
|
||||||
|
mctx.UsbProducts.Update(existing);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
addedProducts++;
|
||||||
|
mctx.UsbProducts.Add(new UsbProduct(product.VendorId, product.ProductId, product.Product));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DicConsole.WriteLine("Added {0} USB products", addedProducts);
|
||||||
|
DicConsole.WriteLine("Modified {0} USB products", modifiedProducts);
|
||||||
|
|
||||||
|
DicConsole.WriteLine("Updating CompactDisc read offsets");
|
||||||
|
foreach(CdOffsetDto offset in sync.Offsets)
|
||||||
|
{
|
||||||
|
CdOffset existing = mctx.CdOffsets.FirstOrDefault(o => o.Id == offset.Id);
|
||||||
|
|
||||||
|
if(existing != null)
|
||||||
|
{
|
||||||
|
modifiedOffsets++;
|
||||||
|
existing.Agreement = offset.Agreement;
|
||||||
|
existing.Manufacturer = offset.Manufacturer;
|
||||||
|
existing.Model = offset.Model;
|
||||||
|
existing.Submissions = offset.Submissions;
|
||||||
|
existing.Offset = offset.Offset;
|
||||||
|
existing.ModifiedWhen = updateStart;
|
||||||
|
mctx.CdOffsets.Update(existing);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
addedOffsets++;
|
||||||
|
mctx.CdOffsets.Add(new CdOffset(offset) {Id = offset.Id});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DicConsole.WriteLine("Added {0} CompactDisc read offsets", addedOffsets);
|
||||||
|
DicConsole.WriteLine("Modified {0} CompactDisc read offsets", modifiedOffsets);
|
||||||
|
|
||||||
|
DicConsole.WriteLine("Updating known devices");
|
||||||
|
foreach(DeviceDto device in sync.Devices)
|
||||||
|
{
|
||||||
|
Device existing = mctx.Devices.FirstOrDefault(d => d.Id == device.Id);
|
||||||
|
|
||||||
|
if(existing != null)
|
||||||
|
{
|
||||||
|
modifiedDevices++;
|
||||||
|
existing = new Device(device) {Id = device.Id};
|
||||||
|
mctx.Devices.Update(existing);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
addedDevices++;
|
||||||
|
mctx.Devices.Add(new Device(device) {Id = device.Id});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DicConsole.WriteLine("Added {0} known devices", addedDevices);
|
||||||
|
DicConsole.WriteLine("Modified {0} known devices", modifiedDevices);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception ex) { DicConsole.ErrorWriteLine("Exception {0} when updating database.", ex); }
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DicConsole.WriteLine("Saving changes...");
|
||||||
|
mctx.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,7 +65,7 @@ namespace DiscImageChef.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void LoadStats()
|
public static void LoadStats()
|
||||||
{
|
{
|
||||||
DicContext ctx = DicContext.Create(Settings.Settings.DbPath);
|
DicContext ctx = DicContext.Create(Settings.Settings.LocalDbPath);
|
||||||
|
|
||||||
if(File.Exists(Path.Combine(Settings.Settings.StatsPath, "Statistics.xml")))
|
if(File.Exists(Path.Combine(Settings.Settings.StatsPath, "Statistics.xml")))
|
||||||
try
|
try
|
||||||
@@ -444,7 +444,7 @@ namespace DiscImageChef.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void SaveStats()
|
public static void SaveStats()
|
||||||
{
|
{
|
||||||
DicContext ctx = DicContext.Create(Settings.Settings.DbPath);
|
DicContext ctx = DicContext.Create(Settings.Settings.LocalDbPath);
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
if(Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.ShareStats) SubmitStats();
|
if(Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.ShareStats) SubmitStats();
|
||||||
}
|
}
|
||||||
@@ -456,7 +456,7 @@ namespace DiscImageChef.Core
|
|||||||
{
|
{
|
||||||
Thread submitThread = new Thread(() =>
|
Thread submitThread = new Thread(() =>
|
||||||
{
|
{
|
||||||
DicContext ctx = DicContext.Create(Settings.Settings.DbPath);
|
DicContext ctx = DicContext.Create(Settings.Settings.LocalDbPath);
|
||||||
|
|
||||||
if(ctx.Commands.Any(c => !c.Synchronized) || ctx.Filesystems.Any(c => !c.Synchronized) ||
|
if(ctx.Commands.Any(c => !c.Synchronized) || ctx.Filesystems.Any(c => !c.Synchronized) ||
|
||||||
ctx.Filters.Any(c => !c.Synchronized) || ctx.MediaFormats.Any(c => !c.Synchronized) ||
|
ctx.Filters.Any(c => !c.Synchronized) || ctx.MediaFormats.Any(c => !c.Synchronized) ||
|
||||||
@@ -878,7 +878,7 @@ namespace DiscImageChef.Core
|
|||||||
|
|
||||||
if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.DeviceStats) return;
|
if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.DeviceStats) return;
|
||||||
|
|
||||||
DicContext ctx = DicContext.Create(Settings.Settings.DbPath);
|
DicContext ctx = DicContext.Create(Settings.Settings.LocalDbPath);
|
||||||
ctx.Commands.Add(new Command {Name = command, Synchronized = false, Count = 1});
|
ctx.Commands.Add(new Command {Name = command, Synchronized = false, Count = 1});
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
}
|
}
|
||||||
@@ -893,7 +893,7 @@ namespace DiscImageChef.Core
|
|||||||
|
|
||||||
if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.FilesystemStats) return;
|
if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.FilesystemStats) return;
|
||||||
|
|
||||||
DicContext ctx = DicContext.Create(Settings.Settings.DbPath);
|
DicContext ctx = DicContext.Create(Settings.Settings.LocalDbPath);
|
||||||
ctx.Filesystems.Add(new Filesystem {Name = filesystem, Synchronized = false, Count = 1});
|
ctx.Filesystems.Add(new Filesystem {Name = filesystem, Synchronized = false, Count = 1});
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
}
|
}
|
||||||
@@ -908,7 +908,7 @@ namespace DiscImageChef.Core
|
|||||||
|
|
||||||
if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.PartitionStats) return;
|
if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.PartitionStats) return;
|
||||||
|
|
||||||
DicContext ctx = DicContext.Create(Settings.Settings.DbPath);
|
DicContext ctx = DicContext.Create(Settings.Settings.LocalDbPath);
|
||||||
ctx.Partitions.Add(new Partition {Name = partition, Synchronized = false, Count = 1});
|
ctx.Partitions.Add(new Partition {Name = partition, Synchronized = false, Count = 1});
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
}
|
}
|
||||||
@@ -923,7 +923,7 @@ namespace DiscImageChef.Core
|
|||||||
|
|
||||||
if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.FilterStats) return;
|
if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.FilterStats) return;
|
||||||
|
|
||||||
DicContext ctx = DicContext.Create(Settings.Settings.DbPath);
|
DicContext ctx = DicContext.Create(Settings.Settings.LocalDbPath);
|
||||||
ctx.Filters.Add(new Filter {Name = filter, Synchronized = false, Count = 1});
|
ctx.Filters.Add(new Filter {Name = filter, Synchronized = false, Count = 1});
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
}
|
}
|
||||||
@@ -938,7 +938,7 @@ namespace DiscImageChef.Core
|
|||||||
|
|
||||||
if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.MediaImageStats) return;
|
if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.MediaImageStats) return;
|
||||||
|
|
||||||
DicContext ctx = DicContext.Create(Settings.Settings.DbPath);
|
DicContext ctx = DicContext.Create(Settings.Settings.LocalDbPath);
|
||||||
ctx.MediaFormats.Add(new MediaFormat {Name = format, Synchronized = false, Count = 1});
|
ctx.MediaFormats.Add(new MediaFormat {Name = format, Synchronized = false, Count = 1});
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
}
|
}
|
||||||
@@ -956,7 +956,7 @@ namespace DiscImageChef.Core
|
|||||||
else if(dev.IsFireWire) deviceBus = "FireWire";
|
else if(dev.IsFireWire) deviceBus = "FireWire";
|
||||||
else deviceBus = dev.Type.ToString();
|
else deviceBus = dev.Type.ToString();
|
||||||
|
|
||||||
DicContext ctx = DicContext.Create(Settings.Settings.DbPath);
|
DicContext ctx = DicContext.Create(Settings.Settings.LocalDbPath);
|
||||||
ctx.SeenDevices.Add(new DeviceStat
|
ctx.SeenDevices.Add(new DeviceStat
|
||||||
{
|
{
|
||||||
Bus = deviceBus,
|
Bus = deviceBus,
|
||||||
@@ -977,7 +977,7 @@ namespace DiscImageChef.Core
|
|||||||
{
|
{
|
||||||
if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.MediaStats) return;
|
if(Settings.Settings.Current.Stats == null || !Settings.Settings.Current.Stats.MediaStats) return;
|
||||||
|
|
||||||
DicContext ctx = DicContext.Create(Settings.Settings.DbPath);
|
DicContext ctx = DicContext.Create(Settings.Settings.LocalDbPath);
|
||||||
ctx.Medias.Add(new Database.Models.Media
|
ctx.Medias.Add(new Database.Models.Media
|
||||||
{
|
{
|
||||||
Real = real, Synchronized = false, Type = type.ToString(), Count = 1
|
Real = real, Synchronized = false, Type = type.ToString(), Count = 1
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using DiscImageChef.Database.Models;
|
|
||||||
|
|
||||||
namespace DiscImageChef.Database.DTOs
|
|
||||||
{
|
|
||||||
public class SyncDTO
|
|
||||||
{
|
|
||||||
List<UsbProduct> UsbProducts;
|
|
||||||
List<UsbVendor> UsbVendors;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -58,7 +58,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Context.cs" />
|
<Compile Include="Context.cs" />
|
||||||
<Compile Include="DTOs\SyncDTO.cs" />
|
|
||||||
<Compile Include="Migrations\20181126222301_DeviceReportV2.cs" />
|
<Compile Include="Migrations\20181126222301_DeviceReportV2.cs" />
|
||||||
<Compile Include="Migrations\20181126222301_DeviceReportV2.Designer.cs" />
|
<Compile Include="Migrations\20181126222301_DeviceReportV2.Designer.cs" />
|
||||||
<Compile Include="Migrations\20181127001622_AddDeviceBasicFields.cs" />
|
<Compile Include="Migrations\20181127001622_AddDeviceBasicFields.cs" />
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ namespace DiscImageChef.Dto
|
|||||||
{
|
{
|
||||||
public class DeviceDto : DeviceReportV2
|
public class DeviceDto : DeviceReportV2
|
||||||
{
|
{
|
||||||
|
public DeviceDto() { }
|
||||||
|
|
||||||
public DeviceDto(DeviceReportV2 report)
|
public DeviceDto(DeviceReportV2 report)
|
||||||
{
|
{
|
||||||
ATA = report.ATA;
|
ATA = report.ATA;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace DiscImageChef.Gui.Dialogs
|
|||||||
{
|
{
|
||||||
XamlReader.Load(this);
|
XamlReader.Load(this);
|
||||||
|
|
||||||
DicContext ctx = DicContext.Create(Settings.Settings.DbPath);
|
DicContext ctx = DicContext.Create(Settings.Settings.LocalDbPath);
|
||||||
|
|
||||||
if(ctx.Commands.Any())
|
if(ctx.Commands.Any())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -597,7 +597,7 @@ namespace DiscImageChef.Gui.Forms
|
|||||||
|
|
||||||
protected void OnMenuStatistics(object sender, EventArgs e)
|
protected void OnMenuStatistics(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
DicContext ctx = DicContext.Create(Settings.Settings.DbPath);
|
DicContext ctx = DicContext.Create(Settings.Settings.LocalDbPath);
|
||||||
|
|
||||||
if(!ctx.Commands.Any() && !ctx.Filesystems.Any() && !ctx.Filters.Any() && !ctx.MediaFormats.Any() &&
|
if(!ctx.Commands.Any() && !ctx.Filesystems.Any() && !ctx.Filters.Any() && !ctx.MediaFormats.Any() &&
|
||||||
!ctx.Medias.Any() && !ctx.Partitions.Any() && !ctx.SeenDevices.Any())
|
!ctx.Medias.Any() && !ctx.Partitions.Any() && !ctx.SeenDevices.Any())
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ namespace DiscImageChef.Server.Controllers
|
|||||||
Id = product.Id,
|
Id = product.Id,
|
||||||
Product = product.Product,
|
Product = product.Product,
|
||||||
ProductId = (ushort)product.ProductId,
|
ProductId = (ushort)product.ProductId,
|
||||||
VendorId = (ushort)product.VendorId
|
VendorId = (ushort)product.Vendor.VendorId
|
||||||
});
|
});
|
||||||
|
|
||||||
sync.Offsets = new List<CdOffsetDto>();
|
sync.Offsets = new List<CdOffsetDto>();
|
||||||
|
|||||||
@@ -381,9 +381,6 @@
|
|||||||
<DependentUpon>201812252219066_StoreReadResultsInReportDatabase.cs</DependentUpon>
|
<DependentUpon>201812252219066_StoreReadResultsInReportDatabase.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="DTOs" />
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
|||||||
@@ -155,7 +155,8 @@ namespace DiscImageChef.Settings
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static string StatsPath { get; private set; }
|
public static string StatsPath { get; private set; }
|
||||||
|
|
||||||
public static string DbPath { get; private set; }
|
public static string LocalDbPath { get; private set; }
|
||||||
|
public static string MasterDbPath { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads settings
|
/// Loads settings
|
||||||
@@ -165,7 +166,8 @@ namespace DiscImageChef.Settings
|
|||||||
Current = new DicSettings();
|
Current = new DicSettings();
|
||||||
PlatformID ptId = DetectOS.GetRealPlatformID();
|
PlatformID ptId = DetectOS.GetRealPlatformID();
|
||||||
string homePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
string homePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
||||||
DbPath = "discimagechef.db";
|
LocalDbPath = "local.db";
|
||||||
|
MasterDbPath = "master.db";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -183,7 +185,8 @@ namespace DiscImageChef.Settings
|
|||||||
string dicPath = Path.Combine(appSupportPath, "DiscImageChef");
|
string dicPath = Path.Combine(appSupportPath, "DiscImageChef");
|
||||||
if(!Directory.Exists(dicPath)) Directory.CreateDirectory(dicPath);
|
if(!Directory.Exists(dicPath)) Directory.CreateDirectory(dicPath);
|
||||||
|
|
||||||
DbPath = Path.Combine(dicPath, DbPath);
|
LocalDbPath = Path.Combine(dicPath, LocalDbPath);
|
||||||
|
MasterDbPath = Path.Combine(dicPath, MasterDbPath);
|
||||||
|
|
||||||
ReportsPath = Path.Combine(dicPath, "Reports");
|
ReportsPath = Path.Combine(dicPath, "Reports");
|
||||||
if(!Directory.Exists(ReportsPath)) Directory.CreateDirectory(ReportsPath);
|
if(!Directory.Exists(ReportsPath)) Directory.CreateDirectory(ReportsPath);
|
||||||
@@ -207,7 +210,8 @@ namespace DiscImageChef.Settings
|
|||||||
string dicPath = Path.Combine(appSupportPath, "DiscImageChef");
|
string dicPath = Path.Combine(appSupportPath, "DiscImageChef");
|
||||||
if(!Directory.Exists(dicPath)) Directory.CreateDirectory(dicPath);
|
if(!Directory.Exists(dicPath)) Directory.CreateDirectory(dicPath);
|
||||||
|
|
||||||
DbPath = Path.Combine(dicPath, DbPath);
|
LocalDbPath = Path.Combine(dicPath, LocalDbPath);
|
||||||
|
MasterDbPath = Path.Combine(dicPath, MasterDbPath);
|
||||||
|
|
||||||
ReportsPath = Path.Combine(dicPath, "Reports");
|
ReportsPath = Path.Combine(dicPath, "Reports");
|
||||||
if(!Directory.Exists(ReportsPath)) Directory.CreateDirectory(ReportsPath);
|
if(!Directory.Exists(ReportsPath)) Directory.CreateDirectory(ReportsPath);
|
||||||
@@ -234,7 +238,8 @@ namespace DiscImageChef.Settings
|
|||||||
|
|
||||||
if(!Directory.Exists(dicPath)) Directory.CreateDirectory(dicPath);
|
if(!Directory.Exists(dicPath)) Directory.CreateDirectory(dicPath);
|
||||||
|
|
||||||
DbPath = Path.Combine(dicPath, DbPath);
|
LocalDbPath = Path.Combine(dicPath, LocalDbPath);
|
||||||
|
MasterDbPath = Path.Combine(dicPath, MasterDbPath);
|
||||||
|
|
||||||
ReportsPath = Path.Combine(dicPath, "Reports");
|
ReportsPath = Path.Combine(dicPath, "Reports");
|
||||||
if(!Directory.Exists(ReportsPath)) Directory.CreateDirectory(ReportsPath);
|
if(!Directory.Exists(ReportsPath)) Directory.CreateDirectory(ReportsPath);
|
||||||
|
|||||||
@@ -924,7 +924,7 @@ namespace DiscImageChef.Commands
|
|||||||
|
|
||||||
Core.Statistics.AddCommand("device-report");
|
Core.Statistics.AddCommand("device-report");
|
||||||
|
|
||||||
using(DicContext ctx = DicContext.Create(Settings.Settings.DbPath))
|
using(DicContext ctx = DicContext.Create(Settings.Settings.LocalDbPath))
|
||||||
{
|
{
|
||||||
ctx.Reports.Add(new Report(report));
|
ctx.Reports.Add(new Report(report));
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace DiscImageChef.Commands
|
|||||||
{
|
{
|
||||||
internal static void ShowStats()
|
internal static void ShowStats()
|
||||||
{
|
{
|
||||||
DicContext ctx = DicContext.Create(Settings.Settings.DbPath);
|
DicContext ctx = DicContext.Create(Settings.Settings.LocalDbPath);
|
||||||
|
|
||||||
if(!ctx.Commands.Any() && !ctx.Filesystems.Any() && !ctx.Filters.Any() && !ctx.MediaFormats.Any() &&
|
if(!ctx.Commands.Any() && !ctx.Filesystems.Any() && !ctx.Filters.Any() && !ctx.MediaFormats.Any() &&
|
||||||
!ctx.Medias.Any() && !ctx.Partitions.Any() && !ctx.SeenDevices.Any())
|
!ctx.Medias.Any() && !ctx.Partitions.Any() && !ctx.SeenDevices.Any())
|
||||||
|
|||||||
54
DiscImageChef/Commands/Update.cs
Normal file
54
DiscImageChef/Commands/Update.cs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
// /***************************************************************************
|
||||||
|
// The Disc Image Chef
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Filename : ListDevices.cs
|
||||||
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||||
|
//
|
||||||
|
// Component : Verbs.
|
||||||
|
//
|
||||||
|
// --[ Description ] ----------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Implements the 'media-info' verb.
|
||||||
|
//
|
||||||
|
// --[ License ] --------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Copyright © 2011-2019 Natalia Portillo
|
||||||
|
// ****************************************************************************/
|
||||||
|
|
||||||
|
using DiscImageChef.Console;
|
||||||
|
using DiscImageChef.Core;
|
||||||
|
|
||||||
|
namespace DiscImageChef.Commands
|
||||||
|
{
|
||||||
|
static class Update
|
||||||
|
{
|
||||||
|
internal static void DoUpdate(UpdateOptions options)
|
||||||
|
{
|
||||||
|
DicConsole.DebugWriteLine("Media-Info command", "--debug={0}", options.Debug);
|
||||||
|
DicConsole.DebugWriteLine("Media-Info command", "--verbose={0}", options.Verbose);
|
||||||
|
|
||||||
|
DoUpdate(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void DoUpdate(bool create)
|
||||||
|
{
|
||||||
|
Remote.UpdateMasterDatabase(create);
|
||||||
|
Core.Statistics.AddCommand("update");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,6 +55,7 @@
|
|||||||
<Compile Include="Commands\ConvertImage.cs" />
|
<Compile Include="Commands\ConvertImage.cs" />
|
||||||
<Compile Include="Commands\ImageInfo.cs" />
|
<Compile Include="Commands\ImageInfo.cs" />
|
||||||
<Compile Include="Commands\ListOptions.cs" />
|
<Compile Include="Commands\ListOptions.cs" />
|
||||||
|
<Compile Include="Commands\Update.cs" />
|
||||||
<Compile Include="Main.cs" />
|
<Compile Include="Main.cs" />
|
||||||
<Compile Include="Options.cs" />
|
<Compile Include="Options.cs" />
|
||||||
<Compile Include="Commands\Formats.cs" />
|
<Compile Include="Commands\Formats.cs" />
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
// ****************************************************************************/
|
// ****************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using CommandLine;
|
using CommandLine;
|
||||||
@@ -57,10 +58,21 @@ namespace DiscImageChef
|
|||||||
|
|
||||||
Settings.Settings.LoadSettings();
|
Settings.Settings.LoadSettings();
|
||||||
|
|
||||||
DicContext ctx = DicContext.Create(Settings.Settings.DbPath);
|
DicContext ctx = DicContext.Create(Settings.Settings.LocalDbPath);
|
||||||
ctx.Database.Migrate();
|
ctx.Database.Migrate();
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
|
|
||||||
|
bool masterDbUpdate = false;
|
||||||
|
if(!File.Exists(Settings.Settings.MasterDbPath))
|
||||||
|
{
|
||||||
|
masterDbUpdate = true;
|
||||||
|
Update.DoUpdate(masterDbUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
DicContext mctx = DicContext.Create(Settings.Settings.MasterDbPath);
|
||||||
|
mctx.Database.Migrate();
|
||||||
|
mctx.SaveChanges();
|
||||||
|
|
||||||
if((args.Length < 1 || args[0].ToLowerInvariant() != "gui") &&
|
if((args.Length < 1 || args[0].ToLowerInvariant() != "gui") &&
|
||||||
Settings.Settings.Current.GdprCompliance < DicSettings.GdprLevel) Configure.DoConfigure(true);
|
Settings.Settings.Current.GdprCompliance < DicSettings.GdprLevel) Configure.DoConfigure(true);
|
||||||
Statistics.LoadStats();
|
Statistics.LoadStats();
|
||||||
@@ -75,8 +87,8 @@ namespace DiscImageChef
|
|||||||
typeof(FormatsOptions), typeof(ImageInfoOptions), typeof(ListDevicesOptions),
|
typeof(FormatsOptions), typeof(ImageInfoOptions), typeof(ListDevicesOptions),
|
||||||
typeof(ListEncodingsOptions), typeof(ListOptionsOptions), typeof(LsOptions),
|
typeof(ListEncodingsOptions), typeof(ListOptionsOptions), typeof(LsOptions),
|
||||||
typeof(MediaInfoOptions), typeof(MediaScanOptions), typeof(PrintHexOptions),
|
typeof(MediaInfoOptions), typeof(MediaScanOptions), typeof(PrintHexOptions),
|
||||||
typeof(StatsOptions), typeof(VerifyOptions), typeof(GuiOptions))
|
typeof(StatsOptions), typeof(VerifyOptions), typeof(GuiOptions),
|
||||||
.WithParsed<AnalyzeOptions>(opts =>
|
typeof(UpdateOptions)).WithParsed<AnalyzeOptions>(opts =>
|
||||||
{
|
{
|
||||||
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||||
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||||
@@ -222,6 +234,15 @@ namespace DiscImageChef
|
|||||||
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||||
|
|
||||||
new Application(Platform.Detect).Run(new frmMain(opts.Debug, opts.Verbose));
|
new Application(Platform.Detect).Run(new frmMain(opts.Debug, opts.Verbose));
|
||||||
|
}).WithParsed<UpdateOptions>(opts =>
|
||||||
|
{
|
||||||
|
if(!masterDbUpdate)
|
||||||
|
{
|
||||||
|
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||||
|
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||||
|
|
||||||
|
Update.DoUpdate(opts);
|
||||||
|
}
|
||||||
}).WithNotParsed(errs => Environment.Exit(1));
|
}).WithNotParsed(errs => Environment.Exit(1));
|
||||||
|
|
||||||
Statistics.SaveStats();
|
Statistics.SaveStats();
|
||||||
|
|||||||
@@ -459,4 +459,7 @@ namespace DiscImageChef
|
|||||||
|
|
||||||
[Verb("gui", HelpText = "Opens the in-progress GUI.")]
|
[Verb("gui", HelpText = "Opens the in-progress GUI.")]
|
||||||
public class GuiOptions : CommonOptions { }
|
public class GuiOptions : CommonOptions { }
|
||||||
|
|
||||||
|
[Verb("update", HelpText = "Updates the database.")]
|
||||||
|
public class UpdateOptions : CommonOptions { }
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user