mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Add update endpoint.
This commit is contained in:
24
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
24
.idea/.idea.DiscImageChef/.idea/contentModel.xml
generated
@@ -295,6 +295,9 @@
|
||||
</e>
|
||||
<e p="DiscImageChef.Database" t="IncludeRecursive">
|
||||
<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="Migrations" t="Include">
|
||||
<e p="20181126222301_DeviceReportV2.Designer.cs" t="Include" />
|
||||
@@ -1142,6 +1145,25 @@
|
||||
</e>
|
||||
</e>
|
||||
</e>
|
||||
<e p="DiscImageChef.Dto" t="IncludeRecursive">
|
||||
<e p="CdOffsetDto.cs" t="Include" />
|
||||
<e p="DeviceDto.cs" t="Include" />
|
||||
<e p="DiscImageChef.Dto.csproj" t="IncludeRecursive" />
|
||||
<e p="SyncDto.cs" t="Include" />
|
||||
<e p="UsbProductDto.cs" t="Include" />
|
||||
<e p="UsbVendorDto.cs" t="Include" />
|
||||
<e p="bin" t="ExcludeRecursive" />
|
||||
<e p="obj" t="ExcludeRecursive">
|
||||
<e p="Debug" t="Include">
|
||||
<e p="net461" t="Include">
|
||||
<e p="DiscImageChef.Dto.AssemblyInfo.cs" t="Include" />
|
||||
</e>
|
||||
<e p="netstandard2.0" t="Include">
|
||||
<e p="DiscImageChef.Dto.AssemblyInfo.cs" t="Include" />
|
||||
</e>
|
||||
</e>
|
||||
</e>
|
||||
</e>
|
||||
<e p="DiscImageChef.EntityFramework" t="IncludeRecursive">
|
||||
<e p="DiscImageChef.EntityFramework.csproj" t="IncludeRecursive" />
|
||||
<e p="Program.cs" t="Include" />
|
||||
@@ -1795,9 +1817,11 @@
|
||||
<e p="HomeController.cs" t="Include" />
|
||||
<e p="ReportController.cs" t="Include" />
|
||||
<e p="StatsController.cs" t="Include" />
|
||||
<e p="UpdateController.cs" t="Include" />
|
||||
<e p="UploadReportController.cs" t="Include" />
|
||||
<e p="UploadStatsController.cs" t="Include" />
|
||||
</e>
|
||||
<e p="DTOs" t="Include" />
|
||||
<e p="DiscImageChef.Server.csproj" t="IncludeRecursive" />
|
||||
<e p="Global.asax" t="Include" />
|
||||
<e p="Global.asax.cs" t="Include" />
|
||||
|
||||
11
DiscImageChef.Database/DTOs/SyncDTO.cs
Normal file
11
DiscImageChef.Database/DTOs/SyncDTO.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using DiscImageChef.Database.Models;
|
||||
|
||||
namespace DiscImageChef.Database.DTOs
|
||||
{
|
||||
public class SyncDTO
|
||||
{
|
||||
List<UsbProduct> UsbProducts;
|
||||
List<UsbVendor> UsbVendors;
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Context.cs" />
|
||||
<Compile Include="DTOs\SyncDTO.cs" />
|
||||
<Compile Include="Migrations\20181126222301_DeviceReportV2.cs" />
|
||||
<Compile Include="Migrations\20181126222301_DeviceReportV2.Designer.cs" />
|
||||
<Compile Include="Migrations\20181127001622_AddDeviceBasicFields.cs" />
|
||||
|
||||
@@ -49,6 +49,16 @@ namespace DiscImageChef.Database.Models
|
||||
AddedWhen = ModifiedWhen = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public CdOffset(CommonTypes.Metadata.CdOffset offset)
|
||||
{
|
||||
Manufacturer = offset.Manufacturer;
|
||||
Model = offset.Model;
|
||||
Offset = offset.Offset;
|
||||
Submissions = offset.Submissions;
|
||||
Agreement = offset.Agreement;
|
||||
AddedWhen = ModifiedWhen = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public int Id { get; set; }
|
||||
public DateTime AddedWhen { get; set; }
|
||||
[Index]
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace DiscImageChef.Database.Models
|
||||
|
||||
public UsbProduct(ushort vendorId, ushort id, string product)
|
||||
{
|
||||
VendorId = vendorId;
|
||||
ProductId = id;
|
||||
Product = product;
|
||||
AddedWhen = ModifiedWhen = DateTime.UtcNow;
|
||||
|
||||
53
DiscImageChef.Dto/CdOffsetDto.cs
Normal file
53
DiscImageChef.Dto/CdOffsetDto.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : CdOffset.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Database.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Model for storing Compact Disc read offsets in database.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; either version 2.1 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This library 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
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2019 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using DiscImageChef.CommonTypes.Metadata;
|
||||
|
||||
namespace DiscImageChef.Dto
|
||||
{
|
||||
public class CdOffsetDto : CdOffset
|
||||
{
|
||||
public CdOffsetDto() { }
|
||||
|
||||
public CdOffsetDto(CdOffset offset, int id)
|
||||
{
|
||||
Manufacturer = offset.Manufacturer;
|
||||
Model = offset.Model;
|
||||
Offset = offset.Offset;
|
||||
Submissions = offset.Submissions;
|
||||
Agreement = offset.Agreement;
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
||||
225
DiscImageChef.Dto/DeviceDto.cs
Normal file
225
DiscImageChef.Dto/DeviceDto.cs
Normal file
@@ -0,0 +1,225 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : Device.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : DiscImageChef Server.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Model for storing processed device reports in database.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; either version 2.1 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This library 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
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2019 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using DiscImageChef.CommonTypes.Metadata;
|
||||
|
||||
// ReSharper disable VirtualMemberCallInConstructor
|
||||
|
||||
namespace DiscImageChef.Server.Models
|
||||
{
|
||||
public class DeviceDto : DeviceReportV2
|
||||
{
|
||||
public DeviceDto(DeviceReportV2 report)
|
||||
{
|
||||
ATA = report.ATA;
|
||||
ATAPI = report.ATAPI;
|
||||
CompactFlash = report.CompactFlash;
|
||||
FireWire = report.FireWire;
|
||||
MultiMediaCard = report.MultiMediaCard;
|
||||
PCMCIA = report.PCMCIA;
|
||||
SCSI = report.SCSI;
|
||||
SecureDigital = report.SecureDigital;
|
||||
USB = report.USB;
|
||||
Manufacturer = report.Manufacturer;
|
||||
Model = report.Model;
|
||||
Revision = report.Revision;
|
||||
Type = report.Type;
|
||||
}
|
||||
|
||||
public DeviceDto(DeviceReportV2 report, int id)
|
||||
{
|
||||
ATA = report.ATA;
|
||||
ATAPI = report.ATAPI;
|
||||
CompactFlash = report.CompactFlash;
|
||||
FireWire = report.FireWire;
|
||||
MultiMediaCard = report.MultiMediaCard;
|
||||
PCMCIA = report.PCMCIA;
|
||||
SCSI = report.SCSI;
|
||||
SecureDigital = report.SecureDigital;
|
||||
USB = report.USB;
|
||||
Manufacturer = report.Manufacturer;
|
||||
Model = report.Model;
|
||||
Revision = report.Revision;
|
||||
Type = report.Type;
|
||||
|
||||
if(ATA != null)
|
||||
{
|
||||
ATA.Identify = null;
|
||||
ATA.ReadCapabilities = ClearBinaries(ATA.ReadCapabilities);
|
||||
if(ATA.RemovableMedias != null)
|
||||
{
|
||||
TestedMedia[] medias = ATA.RemovableMedias.ToArray();
|
||||
ATA.RemovableMedias = new List<TestedMedia>();
|
||||
foreach(TestedMedia media in medias) ATA.RemovableMedias.Add(ClearBinaries(media));
|
||||
}
|
||||
}
|
||||
|
||||
if(ATAPI != null)
|
||||
{
|
||||
ATAPI.Identify = null;
|
||||
ATAPI.ReadCapabilities = ClearBinaries(ATAPI.ReadCapabilities);
|
||||
if(ATAPI.RemovableMedias != null)
|
||||
{
|
||||
TestedMedia[] medias = ATAPI.RemovableMedias.ToArray();
|
||||
ATAPI.RemovableMedias = new List<TestedMedia>();
|
||||
foreach(TestedMedia media in medias) ATAPI.RemovableMedias.Add(ClearBinaries(media));
|
||||
}
|
||||
}
|
||||
|
||||
if(PCMCIA != null)
|
||||
{
|
||||
PCMCIA.AdditionalInformation = null;
|
||||
PCMCIA.CIS = null;
|
||||
}
|
||||
|
||||
MultiMediaCard = null;
|
||||
SecureDigital = null;
|
||||
|
||||
if(SCSI != null)
|
||||
{
|
||||
SCSI.EVPDPages = null;
|
||||
SCSI.InquiryData = null;
|
||||
SCSI.ModeSense6Data = null;
|
||||
SCSI.ModeSense10Data = null;
|
||||
SCSI.ReadCapabilities = ClearBinaries(SCSI.ReadCapabilities);
|
||||
|
||||
if(SCSI.ModeSense != null)
|
||||
{
|
||||
SCSI.ModeSense.BlockDescriptors = null;
|
||||
SCSI.ModeSense.ModePages = null;
|
||||
}
|
||||
|
||||
if(SCSI.RemovableMedias != null)
|
||||
{
|
||||
TestedMedia[] medias = SCSI.RemovableMedias.ToArray();
|
||||
SCSI.RemovableMedias = new List<TestedMedia>();
|
||||
foreach(TestedMedia media in medias) SCSI.RemovableMedias.Add(ClearBinaries(media));
|
||||
}
|
||||
|
||||
if(SCSI.MultiMediaDevice != null)
|
||||
{
|
||||
SCSI.MultiMediaDevice.ModeSense2AData = null;
|
||||
|
||||
if(SCSI.MultiMediaDevice.Features != null) SCSI.MultiMediaDevice.Features.BinaryData = null;
|
||||
|
||||
if(SCSI.MultiMediaDevice.TestedMedia != null)
|
||||
{
|
||||
TestedMedia[] medias = SCSI.MultiMediaDevice.TestedMedia.ToArray();
|
||||
SCSI.MultiMediaDevice.TestedMedia = new List<TestedMedia>();
|
||||
foreach(TestedMedia media in medias)
|
||||
SCSI.MultiMediaDevice.TestedMedia.Add(ClearBinaries(media));
|
||||
}
|
||||
}
|
||||
|
||||
SCSI.SequentialDevice = null;
|
||||
}
|
||||
|
||||
if(USB != null) USB.Descriptors = null;
|
||||
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public new int Id { get; set; }
|
||||
|
||||
static TestedMedia ClearBinaries(TestedMedia media)
|
||||
{
|
||||
if(media is null) return null;
|
||||
|
||||
media.AdipData = null;
|
||||
media.AtipData = null;
|
||||
media.BluBcaData = null;
|
||||
media.BluDdsData = null;
|
||||
media.BluDiData = null;
|
||||
media.BluPacData = null;
|
||||
media.BluSaiData = null;
|
||||
media.C2PointersData = null;
|
||||
media.CmiData = null;
|
||||
media.CorrectedSubchannelData = null;
|
||||
media.CorrectedSubchannelWithC2Data = null;
|
||||
media.DcbData = null;
|
||||
media.DmiData = null;
|
||||
media.DvdAacsData = null;
|
||||
media.DvdBcaData = null;
|
||||
media.DvdDdsData = null;
|
||||
media.DvdLayerData = null;
|
||||
media.DvdSaiData = null;
|
||||
media.EmbossedPfiData = null;
|
||||
media.FullTocData = null;
|
||||
media.HdCmiData = null;
|
||||
media.HLDTSTReadRawDVDData = null;
|
||||
media.IdentifyData = null;
|
||||
media.LeadInData = null;
|
||||
media.LeadOutData = null;
|
||||
media.ModeSense6Data = null;
|
||||
media.ModeSense10Data = null;
|
||||
media.NecReadCddaData = null;
|
||||
media.PfiData = null;
|
||||
media.PioneerReadCddaData = null;
|
||||
media.PioneerReadCddaMsfData = null;
|
||||
media.PlextorReadCddaData = null;
|
||||
media.PlextorReadRawDVDData = null;
|
||||
media.PmaData = null;
|
||||
media.PQSubchannelData = null;
|
||||
media.PQSubchannelWithC2Data = null;
|
||||
media.PriData = null;
|
||||
media.Read6Data = null;
|
||||
media.Read10Data = null;
|
||||
media.Read12Data = null;
|
||||
media.Read16Data = null;
|
||||
media.ReadCdData = null;
|
||||
media.ReadCdFullData = null;
|
||||
media.ReadCdMsfData = null;
|
||||
media.ReadCdMsfFullData = null;
|
||||
media.ReadDmaData = null;
|
||||
media.ReadDmaLba48Data = null;
|
||||
media.ReadDmaLbaData = null;
|
||||
media.ReadDmaRetryData = null;
|
||||
media.ReadLba48Data = null;
|
||||
media.ReadLbaData = null;
|
||||
media.ReadLong10Data = null;
|
||||
media.ReadLong16Data = null;
|
||||
media.ReadLongData = null;
|
||||
media.ReadLongLbaData = null;
|
||||
media.ReadLongRetryData = null;
|
||||
media.ReadLongRetryLbaData = null;
|
||||
media.ReadRetryLbaData = null;
|
||||
media.ReadSectorsData = null;
|
||||
media.ReadSectorsRetryData = null;
|
||||
media.RWSubchannelData = null;
|
||||
media.RWSubchannelWithC2Data = null;
|
||||
media.TocData = null;
|
||||
media.Track1PregapData = null;
|
||||
return media;
|
||||
}
|
||||
}
|
||||
}
|
||||
77
DiscImageChef.Dto/DiscImageChef.Dto.csproj
Normal file
77
DiscImageChef.Dto/DiscImageChef.Dto.csproj
Normal file
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{F4399FF5-9BD0-475A-9EA7-3DAE45291FE2}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>DiscImageChef.Dto</RootNamespace>
|
||||
<AssemblyName>DiscImageChef.Dto</AssemblyName>
|
||||
<ReleaseVersion>$(Version)</ReleaseVersion>
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||
<Version>4.5.99.1693</Version>
|
||||
<Company>Claunia.com</Company>
|
||||
<Copyright>Copyright © 2011-2019 Natalia Portillo</Copyright>
|
||||
<Product>The Disc Image Chef</Product>
|
||||
<Title>DiscImageChef.Dto</Title>
|
||||
<ApplicationVersion>$(Version)</ApplicationVersion>
|
||||
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<NrtRevisionFormat>$(Version)-{chash:8} built by {mname} in $(Configuration){!:, modified}</NrtRevisionFormat>
|
||||
<NrtResolveSimpleAttributes>true</NrtResolveSimpleAttributes>
|
||||
<NrtShowRevision>true</NrtShowRevision>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="..\LICENSE.LGPL">
|
||||
<Link>LICENSE.LGPL</Link>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.2.5" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CdOffsetDto.cs" />
|
||||
<Compile Include="DeviceDto.cs" />
|
||||
<Compile Include="SyncDto.cs" />
|
||||
<Compile Include="UsbProductDto.cs" />
|
||||
<Compile Include="UsbVendorDto.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DiscImageChef.CommonTypes\DiscImageChef.CommonTypes.csproj" />
|
||||
</ItemGroup>
|
||||
<ProjectExtensions>
|
||||
<MonoDevelop>
|
||||
<Properties>
|
||||
<Policies>
|
||||
<StandardHeader IncludeInNewFiles="True" Text="/***************************************************************************
The Disc Image Chef
----------------------------------------------------------------------------
 
Filename : ${FileName}
Author(s) : ${AuthorName} <${AuthorEmail}>

Component : Component
 
--[ Description ] ----------------------------------------------------------
 
 Description
 
--[ License ] --------------------------------------------------------------
 
 This library is free software; you can redistribute it and/or modify
 it under the terms of the GNU Lesser General Public License as
 published by the Free Software Foundation; either version 2.1 of the
 License, or (at your option) any later version.

 This library 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
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, see <http://www.gnu.org/licenses/>.

----------------------------------------------------------------------------
Copyright © 2011-${Year} ${CopyrightHolder}
****************************************************************************/" />
|
||||
<TextStylePolicy FileWidth="120" TabWidth="4" IndentWidth="4" RemoveTrailingWhitespace="True" NoTabsAfterNonTabs="False" EolMarker="Native" TabsToSpaces="True" scope="text/x-csharp" />
|
||||
<CSharpFormattingPolicy IndentBlock="True" IndentBraces="False" IndentSwitchSection="True" IndentSwitchCaseSection="True" LabelPositioning="OneLess" NewLinesForBracesInTypes="True" NewLinesForBracesInMethods="True" NewLinesForBracesInProperties="True" NewLinesForBracesInAccessors="True" NewLinesForBracesInAnonymousMethods="True" NewLinesForBracesInControlBlocks="True" NewLinesForBracesInAnonymousTypes="True" NewLinesForBracesInObjectCollectionArrayInitializers="True" NewLinesForBracesInLambdaExpressionBody="True" NewLineForElse="True" NewLineForCatch="True" NewLineForFinally="True" NewLineForMembersInObjectInit="True" NewLineForMembersInAnonymousTypes="True" NewLineForClausesInQuery="True" SpacingAfterMethodDeclarationName="False" SpaceWithinMethodDeclarationParenthesis="False" SpaceBetweenEmptyMethodDeclarationParentheses="False" SpaceAfterMethodCallName="False" SpaceWithinMethodCallParentheses="False" SpaceBetweenEmptyMethodCallParentheses="False" SpaceWithinExpressionParentheses="False" SpaceWithinCastParentheses="False" SpaceWithinOtherParentheses="False" SpaceAfterCast="False" SpacesIgnoreAroundVariableDeclaration="False" SpaceBeforeOpenSquareBracket="False" SpaceBetweenEmptySquareBrackets="False" SpaceWithinSquareBrackets="False" SpaceAfterColonInBaseTypeDeclaration="True" SpaceAfterComma="True" SpaceAfterDot="False" SpaceAfterSemicolonsInForStatement="True" SpaceBeforeColonInBaseTypeDeclaration="True" SpaceBeforeComma="False" SpaceBeforeDot="False" SpaceBeforeSemicolonsInForStatement="False" SpacingAroundBinaryOperator="Single" WrappingPreserveSingleLine="True" WrappingKeepStatementsOnSingleLine="True" PlaceSystemDirectiveFirst="True" SpaceAfterControlFlowStatementKeyword="False" scope="text/x-csharp" />
|
||||
</Policies>
|
||||
</Properties>
|
||||
</MonoDevelop>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
||||
13
DiscImageChef.Dto/SyncDto.cs
Normal file
13
DiscImageChef.Dto/SyncDto.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
using DiscImageChef.Server.Models;
|
||||
|
||||
namespace DiscImageChef.Dto
|
||||
{
|
||||
public class SyncDto
|
||||
{
|
||||
public List<UsbVendorDto> UsbVendors { get; set; }
|
||||
public List<UsbProductDto> UsbProducts { get; set; }
|
||||
public List<CdOffsetDto> Offsets { get; set; }
|
||||
public List<DeviceDto> Devices { get; set; }
|
||||
}
|
||||
}
|
||||
42
DiscImageChef.Dto/UsbProductDto.cs
Normal file
42
DiscImageChef.Dto/UsbProductDto.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : UsbProduct.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : DiscImageChef Server.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Model for storing USB product identifiers in database.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; either version 2.1 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This library 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
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2019 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace DiscImageChef.Dto
|
||||
{
|
||||
public class UsbProductDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public ushort ProductId { get; set; }
|
||||
public string Product { get; set; }
|
||||
public ushort VendorId { get; set; }
|
||||
}
|
||||
}
|
||||
40
DiscImageChef.Dto/UsbVendorDto.cs
Normal file
40
DiscImageChef.Dto/UsbVendorDto.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : UsbVendor.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : DiscImageChef Server.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Model for storing USB vendor identifiers in database.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; either version 2.1 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This library 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
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2019 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
namespace DiscImageChef.Dto
|
||||
{
|
||||
public class UsbVendorDto
|
||||
{
|
||||
public ushort VendorId { get; set; }
|
||||
public string Vendor { get; set; }
|
||||
}
|
||||
}
|
||||
98
DiscImageChef.Server/Controllers/UpdateController.cs
Normal file
98
DiscImageChef.Server/Controllers/UpdateController.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
// /***************************************************************************
|
||||
// The Disc Image Chef
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// Filename : UploadReportController.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : DiscImageChef Server.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Handles report uploads.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; either version 2.1 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This library 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
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2019 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Web.Http;
|
||||
using DiscImageChef.CommonTypes.Metadata;
|
||||
using DiscImageChef.Dto;
|
||||
using DiscImageChef.Server.Models;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace DiscImageChef.Server.Controllers
|
||||
{
|
||||
public class UpdateController : ApiController
|
||||
{
|
||||
/// <summary>
|
||||
/// Receives a report from DiscImageChef.Core, verifies it's in the correct format and stores it on the server
|
||||
/// </summary>
|
||||
/// <returns>HTTP response</returns>
|
||||
[Route("api/update")]
|
||||
[HttpGet]
|
||||
public HttpResponseMessage UploadReport(long timestamp)
|
||||
{
|
||||
DicServerContext ctx = new DicServerContext();
|
||||
|
||||
SyncDto sync = new SyncDto();
|
||||
DateTime lastSync = DateHandlers.UnixToDateTime(timestamp);
|
||||
|
||||
sync.UsbVendors = new List<UsbVendorDto>();
|
||||
foreach(UsbVendor vendor in ctx.UsbVendors.Where(v => v.ModifiedWhen > lastSync))
|
||||
sync.UsbVendors.Add(new UsbVendorDto {VendorId = (ushort)vendor.VendorId, Vendor = vendor.Vendor});
|
||||
|
||||
sync.UsbProducts = new List<UsbProductDto>();
|
||||
foreach(UsbProduct product in ctx.UsbProducts.Where(p => p.ModifiedWhen > lastSync))
|
||||
sync.UsbProducts.Add(new UsbProductDto
|
||||
{
|
||||
Id = product.Id,
|
||||
Product = product.Product,
|
||||
ProductId = (ushort)product.ProductId,
|
||||
VendorId = (ushort)product.VendorId
|
||||
});
|
||||
|
||||
sync.Offsets = new List<CdOffsetDto>();
|
||||
foreach(CompactDiscOffset offset in ctx.CdOffsets.Where(o => o.ModifiedWhen > lastSync))
|
||||
sync.Offsets.Add(new CdOffsetDto(offset, offset.Id));
|
||||
|
||||
sync.Devices = new List<DeviceDto>();
|
||||
foreach(Device device in ctx.Devices.Where(d => d.ModifiedWhen > lastSync).ToList())
|
||||
sync.Devices.Add(new
|
||||
DeviceDto(JsonConvert.DeserializeObject<DeviceReportV2>(JsonConvert.SerializeObject(device)),
|
||||
device.Id));
|
||||
|
||||
JsonSerializer js = JsonSerializer.Create();
|
||||
StringWriter sw = new StringWriter();
|
||||
js.Serialize(sw, sync);
|
||||
|
||||
return new HttpResponseMessage
|
||||
{
|
||||
StatusCode = HttpStatusCode.OK,
|
||||
Content = new StringContent(sw.ToString(), Encoding.UTF8, "application/json")
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -210,6 +210,7 @@
|
||||
<Compile Include="Controllers\ReportController.cs" />
|
||||
<Compile Include="Controllers\StatsController.cs" />
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
<Compile Include="Controllers\UpdateController.cs" />
|
||||
<Compile Include="Controllers\UploadReportController.cs" />
|
||||
<Compile Include="Controllers\UploadStatsController.cs" />
|
||||
<Compile Include="Global.asax.cs">
|
||||
@@ -336,6 +337,10 @@
|
||||
<Project>{0beb3088-b634-4289-ae17-cdf2d25d00d5}</Project>
|
||||
<Name>DiscImageChef.Decoders</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DiscImageChef.Dto\DiscImageChef.Dto.csproj">
|
||||
<Project>{f4399ff5-9bd0-475a-9ea7-3dae45291fe2}</Project>
|
||||
<Name>DiscImageChef.Dto</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\DiscImageChef.Helpers\DiscImageChef.Helpers.csproj">
|
||||
<Project>{f8bdf57b-1571-4cd0-84b3-b422088d359a}</Project>
|
||||
<Name>DiscImageChef.Helpers</Name>
|
||||
@@ -376,6 +381,9 @@
|
||||
<DependentUpon>201812252219066_StoreReadResultsInReportDatabase.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="DTOs" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
|
||||
@@ -51,6 +51,16 @@ namespace DiscImageChef.Server.Models
|
||||
AddedWhen = ModifiedWhen = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public CompactDiscOffset(CdOffset offset)
|
||||
{
|
||||
Manufacturer = offset.Manufacturer;
|
||||
Model = offset.Model;
|
||||
Offset = offset.Offset;
|
||||
Submissions = offset.Submissions;
|
||||
Agreement = offset.Agreement;
|
||||
AddedWhen = ModifiedWhen = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public int Id { get; set; }
|
||||
public DateTime AddedWhen { get; set; }
|
||||
[Index]
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace DiscImageChef.Server.Models
|
||||
{
|
||||
@@ -57,7 +58,8 @@ namespace DiscImageChef.Server.Models
|
||||
[Index]
|
||||
public DateTime ModifiedWhen { get; set; }
|
||||
[Index]
|
||||
public int VendorId { get; set; }
|
||||
public int VendorId { get; set; }
|
||||
[JsonIgnore]
|
||||
public virtual UsbVendor Vendor { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace DiscImageChef.Server.Models
|
||||
{
|
||||
@@ -57,6 +58,7 @@ namespace DiscImageChef.Server.Models
|
||||
[Index]
|
||||
public DateTime ModifiedWhen { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual ICollection<UsbProduct> Products { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscImageChef.Server", "Dis
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscImageChef.Server.Task", "DiscImageChef.Server.Task\DiscImageChef.Server.Task.csproj", "{79D6A54E-47B6-4D0A-ABEB-4FA7B5ADF4B2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DiscImageChef.Dto", "DiscImageChef.Dto\DiscImageChef.Dto.csproj", "{F4399FF5-9BD0-475A-9EA7-3DAE45291FE2}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -221,6 +223,14 @@ Global
|
||||
{79D6A54E-47B6-4D0A-ABEB-4FA7B5ADF4B2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{79D6A54E-47B6-4D0A-ABEB-4FA7B5ADF4B2}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{79D6A54E-47B6-4D0A-ABEB-4FA7B5ADF4B2}.Release|x86.Build.0 = Release|Any CPU
|
||||
{F4399FF5-9BD0-475A-9EA7-3DAE45291FE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F4399FF5-9BD0-475A-9EA7-3DAE45291FE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F4399FF5-9BD0-475A-9EA7-3DAE45291FE2}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{F4399FF5-9BD0-475A-9EA7-3DAE45291FE2}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{F4399FF5-9BD0-475A-9EA7-3DAE45291FE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F4399FF5-9BD0-475A-9EA7-3DAE45291FE2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F4399FF5-9BD0-475A-9EA7-3DAE45291FE2}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{F4399FF5-9BD0-475A-9EA7-3DAE45291FE2}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
Reference in New Issue
Block a user