Refactor.

This commit is contained in:
2019-11-02 21:37:09 +00:00
parent f653af2059
commit d4020f1a3f
52 changed files with 4207 additions and 4095 deletions

16
.editorconfig Normal file
View File

@@ -0,0 +1,16 @@
[*]
charset=utf-8
end_of_line=lf
trim_trailing_whitespace=true
insert_final_newline=false
indent_style=space
indent_size=4
[{.babelrc,.stylelintrc,.eslintrc,jest.config,*.uplugin,*.bowerrc,*.jsb3,*.jsb2,*.json}]
indent_style=space
indent_size=2
[{*.yml,*.yaml}]
indent_style=space
indent_size=2

View File

@@ -57,10 +57,10 @@ namespace DiscImageChef.Server
{ {
uint logicalsectorsize = 0; uint logicalsectorsize = 0;
Identify.IdentifyDevice? ataIdentifyNullable = Identify.Decode(ataReport.Identify); var ataIdentifyNullable = Identify.Decode(ataReport.Identify);
if (!ataIdentifyNullable.HasValue) return; if (!ataIdentifyNullable.HasValue) return;
Identify.IdentifyDevice ataIdentify = ataIdentifyNullable.Value; var ataIdentify = ataIdentifyNullable.Value;
if (!string.IsNullOrEmpty(ataIdentify.Model)) ataTwoValue.Add("Model", ataIdentify.Model); if (!string.IsNullOrEmpty(ataIdentify.Model)) ataTwoValue.Add("Model", ataIdentify.Model);
if (!string.IsNullOrEmpty(ataIdentify.FirmwareRevision)) if (!string.IsNullOrEmpty(ataIdentify.FirmwareRevision))
@@ -114,9 +114,9 @@ namespace DiscImageChef.Server
acs4 |= ataIdentify.MajorVersion.HasFlag(Identify.MajorVersionBit.ACS4); acs4 |= ataIdentify.MajorVersion.HasFlag(Identify.MajorVersionBit.ACS4);
} }
int maxatalevel = 0; var maxatalevel = 0;
int minatalevel = 255; var minatalevel = 255;
string tmpString = ""; var tmpString = "";
if (ata1) if (ata1)
{ {
tmpString += "ATA-1 "; tmpString += "ATA-1 ";
@@ -447,7 +447,8 @@ namespace DiscImageChef.Server
break; break;
default: default:
ataOneValue ataOneValue
.Add($"ATAPI Unknown device type field value 0x{((ushort)ataIdentify.GeneralConfiguration & 0x1F00) >> 8:X2}"); .Add(
$"ATAPI Unknown device type field value 0x{((ushort) ataIdentify.GeneralConfiguration & 0x1F00) >> 8:X2}");
break; break;
} }
@@ -465,7 +466,8 @@ namespace DiscImageChef.Server
break; break;
default: default:
ataOneValue ataOneValue
.Add($"Unknown ATAPI DRQ behaviour code {((ushort)ataIdentify.GeneralConfiguration & 0x60) >> 5}"); .Add(
$"Unknown ATAPI DRQ behaviour code {((ushort) ataIdentify.GeneralConfiguration & 0x60) >> 5}");
break; break;
} }
@@ -543,15 +545,18 @@ namespace DiscImageChef.Server
break; break;
case Identify.SpecificConfigurationEnum.NotRequiresSetIncompleteResponse: case Identify.SpecificConfigurationEnum.NotRequiresSetIncompleteResponse:
ataOneValue ataOneValue
.Add("Device does not require SET FEATURES to spin up and IDENTIFY DEVICE response is incomplete."); .Add(
"Device does not require SET FEATURES to spin up and IDENTIFY DEVICE response is incomplete.");
break; break;
case Identify.SpecificConfigurationEnum.NotRequiresSetCompleteResponse: case Identify.SpecificConfigurationEnum.NotRequiresSetCompleteResponse:
ataOneValue ataOneValue
.Add("Device does not require SET FEATURES to spin up and IDENTIFY DEVICE response is complete."); .Add(
"Device does not require SET FEATURES to spin up and IDENTIFY DEVICE response is complete.");
break; break;
default: default:
ataOneValue ataOneValue
.Add($"Unknown device specific configuration 0x{(ushort)ataIdentify.SpecificConfiguration:X4}"); .Add(
$"Unknown device specific configuration 0x{(ushort) ataIdentify.SpecificConfiguration:X4}");
break; break;
} }
@@ -562,19 +567,23 @@ namespace DiscImageChef.Server
{ {
case 1: case 1:
ataOneValue ataOneValue
.Add($"{ataIdentify.BufferSize * logicalsectorsize / 1024} KiB of single ported single sector buffer"); .Add(
$"{ataIdentify.BufferSize * logicalsectorsize / 1024} KiB of single ported single sector buffer");
break; break;
case 2: case 2:
ataOneValue ataOneValue
.Add($"{ataIdentify.BufferSize * logicalsectorsize / 1024} KiB of dual ported multi sector buffer"); .Add(
$"{ataIdentify.BufferSize * logicalsectorsize / 1024} KiB of dual ported multi sector buffer");
break; break;
case 3: case 3:
ataOneValue ataOneValue
.Add($"{ataIdentify.BufferSize * logicalsectorsize / 1024} KiB of dual ported multi sector buffer with read caching"); .Add(
$"{ataIdentify.BufferSize * logicalsectorsize / 1024} KiB of dual ported multi sector buffer with read caching");
break; break;
default: default:
ataOneValue ataOneValue
.Add($"{ataIdentify.BufferSize * logicalsectorsize / 1024} KiB of unknown type {ataIdentify.BufferType} buffer"); .Add(
$"{ataIdentify.BufferSize * logicalsectorsize / 1024} KiB of unknown type {ataIdentify.BufferType} buffer");
break; break;
} }
@@ -609,7 +618,8 @@ namespace DiscImageChef.Server
if (ataIdentify.Capabilities3.HasFlag(Identify.CapabilitiesBit3.MultipleValid)) if (ataIdentify.Capabilities3.HasFlag(Identify.CapabilitiesBit3.MultipleValid))
{ {
ataOneValue.Add($"A maximum of {ataIdentify.MultipleSectorNumber} sectors can be transferred per interrupt on READ/WRITE MULTIPLE"); ataOneValue.Add(
$"A maximum of {ataIdentify.MultipleSectorNumber} sectors can be transferred per interrupt on READ/WRITE MULTIPLE");
ataOneValue.Add($"Device supports setting a maximum of {ataIdentify.MultipleMaxSectors} sectors"); ataOneValue.Add($"Device supports setting a maximum of {ataIdentify.MultipleMaxSectors} sectors");
} }
@@ -795,13 +805,16 @@ namespace DiscImageChef.Server
if (!string.IsNullOrEmpty(tmpString)) ataTwoValue.Add("Ultra DMA", tmpString); if (!string.IsNullOrEmpty(tmpString)) ataTwoValue.Add("Ultra DMA", tmpString);
if (ataIdentify.MinMDMACycleTime != 0 && ataIdentify.RecMDMACycleTime != 0) if (ataIdentify.MinMDMACycleTime != 0 && ataIdentify.RecMDMACycleTime != 0)
ataOneValue.Add($"At minimum {ataIdentify.MinMDMACycleTime} ns. transfer cycle time per word in MDMA, " + ataOneValue.Add(
$"At minimum {ataIdentify.MinMDMACycleTime} ns. transfer cycle time per word in MDMA, " +
$"{ataIdentify.RecMDMACycleTime} ns. recommended"); $"{ataIdentify.RecMDMACycleTime} ns. recommended");
if (ataIdentify.MinPIOCycleTimeNoFlow != 0) if (ataIdentify.MinPIOCycleTimeNoFlow != 0)
ataOneValue.Add($"At minimum {ataIdentify.MinPIOCycleTimeNoFlow} ns. transfer cycle time per word in PIO, " + ataOneValue.Add(
$"At minimum {ataIdentify.MinPIOCycleTimeNoFlow} ns. transfer cycle time per word in PIO, " +
"without flow control"); "without flow control");
if (ataIdentify.MinPIOCycleTimeFlow != 0) if (ataIdentify.MinPIOCycleTimeFlow != 0)
ataOneValue.Add($"At minimum {ataIdentify.MinPIOCycleTimeFlow} ns. transfer cycle time per word in PIO, " + ataOneValue.Add(
$"At minimum {ataIdentify.MinPIOCycleTimeFlow} ns. transfer cycle time per word in PIO, " +
"with IORDY flow control"); "with IORDY flow control");
if (ataIdentify.MaxQueueDepth != 0) if (ataIdentify.MaxQueueDepth != 0)
@@ -869,7 +882,8 @@ namespace DiscImageChef.Server
} }
if (ataIdentify.InterseekDelay != 0x0000 && ataIdentify.InterseekDelay != 0xFFFF) if (ataIdentify.InterseekDelay != 0x0000 && ataIdentify.InterseekDelay != 0xFFFF)
ataOneValue.Add($"{ataIdentify.InterseekDelay} microseconds of interseek delay for ISO-7779 accoustic testing"); ataOneValue.Add(
$"{ataIdentify.InterseekDelay} microseconds of interseek delay for ISO-7779 accoustic testing");
if ((ushort) ataIdentify.DeviceFormFactor != 0x0000 && (ushort) ataIdentify.DeviceFormFactor != 0xFFFF) if ((ushort) ataIdentify.DeviceFormFactor != 0x0000 && (ushort) ataIdentify.DeviceFormFactor != 0xFFFF)
switch (ataIdentify.DeviceFormFactor) switch (ataIdentify.DeviceFormFactor)
@@ -1268,7 +1282,8 @@ namespace DiscImageChef.Server
if (ataIdentify.DataSetMgmt.HasFlag(Identify.DataSetMgmtBit.Trim)) ataOneValue.Add("TRIM is supported"); if (ataIdentify.DataSetMgmt.HasFlag(Identify.DataSetMgmtBit.Trim)) ataOneValue.Add("TRIM is supported");
if (ataIdentify.DataSetMgmtSize > 0) if (ataIdentify.DataSetMgmtSize > 0)
ataOneValue.Add($"DATA SET MANAGEMENT can receive a maximum of {ataIdentify.DataSetMgmtSize} blocks of 512 bytes"); ataOneValue.Add(
$"DATA SET MANAGEMENT can receive a maximum of {ataIdentify.DataSetMgmtSize} blocks of 512 bytes");
if (ataIdentify.SecurityStatus.HasFlag(Identify.SecurityStatusBit.Supported)) if (ataIdentify.SecurityStatus.HasFlag(Identify.SecurityStatusBit.Supported))
{ {
@@ -1292,7 +1307,10 @@ namespace DiscImageChef.Server
? "Security level is maximum" ? "Security level is maximum"
: "Security level is high"); : "Security level is high");
} }
else ataOneValue.Add("Security is not enabled"); else
{
ataOneValue.Add("Security is not enabled");
}
if (ataIdentify.SecurityStatus.HasFlag(Identify.SecurityStatusBit.Enhanced)) if (ataIdentify.SecurityStatus.HasFlag(Identify.SecurityStatusBit.Enhanced))
ataOneValue.Add("Supports enhanced security erase"); ataOneValue.Add("Supports enhanced security erase");
@@ -1381,11 +1399,12 @@ namespace DiscImageChef.Server
(ataReport.ReadCapabilities.LogicalAlignment & 0x8000) == 0x0000 && (ataReport.ReadCapabilities.LogicalAlignment & 0x8000) == 0x0000 &&
(ataReport.ReadCapabilities.LogicalAlignment & 0x4000) == 0x4000) (ataReport.ReadCapabilities.LogicalAlignment & 0x4000) == 0x4000)
ataOneValue ataOneValue
.Add($"Logical sector starts at offset {ataReport.ReadCapabilities.LogicalAlignment & 0x3FFF} from physical sector"); .Add(
$"Logical sector starts at offset {ataReport.ReadCapabilities.LogicalAlignment & 0x3FFF} from physical sector");
if (ataReport.ReadCapabilities.CHS != null && ataReport.ReadCapabilities.CurrentCHS != null) if (ataReport.ReadCapabilities.CHS != null && ataReport.ReadCapabilities.CurrentCHS != null)
{ {
int currentSectors = ataReport.ReadCapabilities.CurrentCHS.Cylinders * var currentSectors = ataReport.ReadCapabilities.CurrentCHS.Cylinders *
ataReport.ReadCapabilities.CurrentCHS.Heads * ataReport.ReadCapabilities.CurrentCHS.Heads *
ataReport.ReadCapabilities.CurrentCHS.Sectors; ataReport.ReadCapabilities.CurrentCHS.Sectors;
ataTwoValue.Add("Cylinders", ataTwoValue.Add("Cylinders",
@@ -1401,7 +1420,7 @@ namespace DiscImageChef.Server
} }
else if (ataReport.ReadCapabilities.CHS != null) else if (ataReport.ReadCapabilities.CHS != null)
{ {
int currentSectors = ataReport.ReadCapabilities.CHS.Cylinders * var currentSectors = ataReport.ReadCapabilities.CHS.Cylinders *
ataReport.ReadCapabilities.CHS.Heads * ataReport.ReadCapabilities.CHS.Heads *
ataReport.ReadCapabilities.CHS.Sectors; ataReport.ReadCapabilities.CHS.Sectors;
ataTwoValue.Add("Cylinders", ataTwoValue.Add("Cylinders",
@@ -1492,7 +1511,10 @@ namespace DiscImageChef.Server
if (ataReport.ReadCapabilities.SupportsSeekLba == true) if (ataReport.ReadCapabilities.SupportsSeekLba == true)
ataOneValue.Add("Device supports SEEK command in 28-bit LBA mode"); ataOneValue.Add("Device supports SEEK command in 28-bit LBA mode");
} }
else testedMedia = ataReport.RemovableMedias; else
{
testedMedia = ataReport.RemovableMedias;
}
} }
} }
} }

View File

@@ -47,7 +47,7 @@ namespace DiscImageChef.Server
/// <param name="evpdPages">List to put the key=value pairs on</param> /// <param name="evpdPages">List to put the key=value pairs on</param>
public static void Report(IEnumerable<ScsiPage> pages, string vendor, ref Dictionary<string, string> evpdPages) public static void Report(IEnumerable<ScsiPage> pages, string vendor, ref Dictionary<string, string> evpdPages)
{ {
foreach(ScsiPage evpd in pages) foreach (var evpd in pages)
{ {
string decoded; string decoded;
if (evpd.page >= 0x01 && evpd.page <= 0x7F) decoded = EVPD.DecodeASCIIPage(evpd.value); if (evpd.page >= 0x01 && evpd.page <= 0x7F) decoded = EVPD.DecodeASCIIPage(evpd.value);

View File

@@ -35,7 +35,7 @@ using DiscImageChef.Decoders.SCSI;
namespace DiscImageChef.Server namespace DiscImageChef.Server
{ {
static class ScsiInquiry internal static class ScsiInquiry
{ {
/// <summary> /// <summary>
/// Takes the SCSI INQUIRY part of a device report and prints it as a list of values to be sequenced by ASP.NET in the /// Takes the SCSI INQUIRY part of a device report and prints it as a list of values to be sequenced by ASP.NET in the
@@ -45,11 +45,11 @@ namespace DiscImageChef.Server
/// <returns>List of values</returns> /// <returns>List of values</returns>
internal static IEnumerable<string> Report(Inquiry.SCSIInquiry? inquiryNullable) internal static IEnumerable<string> Report(Inquiry.SCSIInquiry? inquiryNullable)
{ {
List<string> scsiOneValue = new List<string>(); var scsiOneValue = new List<string>();
if (!inquiryNullable.HasValue) return scsiOneValue; if (!inquiryNullable.HasValue) return scsiOneValue;
Inquiry.SCSIInquiry inquiry = inquiryNullable.Value; var inquiry = inquiryNullable.Value;
switch ((PeripheralQualifiers) inquiry.PeripheralQualifier) switch ((PeripheralQualifiers) inquiry.PeripheralQualifier)
{ {
@@ -171,7 +171,8 @@ namespace DiscImageChef.Server
break; break;
default: default:
scsiOneValue scsiOneValue
.Add($"Device claims to comply with unknown SCSI ANSI standard value 0x{inquiry.ANSIVersion:X2})"); .Add(
$"Device claims to comply with unknown SCSI ANSI standard value 0x{inquiry.ANSIVersion:X2})");
break; break;
} }
@@ -185,7 +186,8 @@ namespace DiscImageChef.Server
break; break;
default: default:
scsiOneValue scsiOneValue
.Add($"Device claims to comply with unknown SCSI ECMA standard value 0x{inquiry.ECMAVersion:X2})"); .Add(
$"Device claims to comply with unknown SCSI ECMA standard value 0x{inquiry.ECMAVersion:X2})");
break; break;
} }
@@ -199,7 +201,8 @@ namespace DiscImageChef.Server
break; break;
default: default:
scsiOneValue scsiOneValue
.Add($"Device claims to comply with unknown SCSI ISO/IEC standard value 0x{inquiry.ISOVersion:X2})"); .Add(
$"Device claims to comply with unknown SCSI ISO/IEC standard value 0x{inquiry.ISOVersion:X2})");
break; break;
} }
@@ -270,7 +273,7 @@ namespace DiscImageChef.Server
if (inquiry.VersionDescriptors == null) return scsiOneValue; if (inquiry.VersionDescriptors == null) return scsiOneValue;
foreach(ushort versionDescriptor in inquiry.VersionDescriptors) foreach (var versionDescriptor in inquiry.VersionDescriptors)
switch (versionDescriptor) switch (versionDescriptor)
{ {
case 0xFFFF: case 0xFFFF:
@@ -403,7 +406,8 @@ namespace DiscImageChef.Server
break; break;
case 0x01DD: case 0x01DD:
scsiOneValue scsiOneValue
.Add("Device complies with SES T10/1212 revision 08b w/ Amendment ANSI INCITS.305/AM1-2000"); .Add(
"Device complies with SES T10/1212 revision 08b w/ Amendment ANSI INCITS.305/AM1-2000");
break; break;
case 0x01DE: case 0x01DE:
scsiOneValue scsiOneValue
@@ -744,7 +748,8 @@ namespace DiscImageChef.Server
break; break;
case 0x04E7: case 0x04E7:
scsiOneValue scsiOneValue
.Add("Device complies with MMC-6 ANSI INCITS 468-2010 + MMC-6/AM1 ANSI INCITS 468-2010/AM 1"); .Add(
"Device complies with MMC-6 ANSI INCITS 468-2010 + MMC-6/AM1 ANSI INCITS 468-2010/AM 1");
break; break;
case 0x0500: case 0x0500:
scsiOneValue.Add("Device complies with ADC-3 (no version claimed)"); scsiOneValue.Add("Device complies with ADC-3 (no version claimed)");
@@ -1033,7 +1038,8 @@ namespace DiscImageChef.Server
break; break;
case 0x0ABC: case 0x0ABC:
scsiOneValue scsiOneValue
.Add("Device complies with SPI ANSI INCITS 253-1995 with SPI Amnd ANSI INCITS 253/AM1-1998"); .Add(
"Device complies with SPI ANSI INCITS 253-1995 with SPI Amnd ANSI INCITS 253/AM1-1998");
break; break;
case 0x0AC0: case 0x0AC0:
scsiOneValue.Add("Device complies with Fast-20 (no version claimed)"); scsiOneValue.Add("Device complies with Fast-20 (no version claimed)");
@@ -1175,7 +1181,8 @@ namespace DiscImageChef.Server
break; break;
case 0x0C4F: case 0x0C4F:
scsiOneValue scsiOneValue
.Add("Device complies with SAS-2.1 ANSI INCITS 478-2011 w/ Amnd 1 ANSI INCITS 478/AM1-2014"); .Add(
"Device complies with SAS-2.1 ANSI INCITS 478-2011 w/ Amnd 1 ANSI INCITS 478/AM1-2014");
break; break;
case 0x0C52: case 0x0C52:
scsiOneValue.Add("Device complies with SAS-2.1 ISO/IEC 14776-153"); scsiOneValue.Add("Device complies with SAS-2.1 ISO/IEC 14776-153");
@@ -1203,7 +1210,8 @@ namespace DiscImageChef.Server
break; break;
case 0x0D3C: case 0x0D3C:
scsiOneValue scsiOneValue
.Add("Device complies with FC-PH ANSI INCITS 230-1994 with Amnd 1 ANSI INCITS 230/AM1-1996"); .Add(
"Device complies with FC-PH ANSI INCITS 230-1994 with Amnd 1 ANSI INCITS 230/AM1-1996");
break; break;
case 0x0D40: case 0x0D40:
scsiOneValue.Add("Device complies with FC-AL (no version claimed)"); scsiOneValue.Add("Device complies with FC-AL (no version claimed)");
@@ -1334,7 +1342,8 @@ namespace DiscImageChef.Server
break; break;
case 0x0EA6: case 0x0EA6:
scsiOneValue scsiOneValue
.Add("Device complies with FC 10GFC ANSI INCITS 364-2003 with AM1 ANSI INCITS 364/AM1-2007"); .Add(
"Device complies with FC 10GFC ANSI INCITS 364-2003 with AM1 ANSI INCITS 364/AM1-2007");
break; break;
case 0x0EC0: case 0x0EC0:
scsiOneValue.Add("Device complies with FC-SP-2 (no version claimed)"); scsiOneValue.Add("Device complies with FC-SP-2 (no version claimed)");
@@ -1523,7 +1532,8 @@ namespace DiscImageChef.Server
break; break;
case 0x1623: case 0x1623:
scsiOneValue scsiOneValue
.Add("Device complies with ATA/ATAPI-8 ATA8-ACS ATA/ATAPI Command Set (no version claimed)"); .Add(
"Device complies with ATA/ATAPI-8 ATA8-ACS ATA/ATAPI Command Set (no version claimed)");
break; break;
case 0x1628: case 0x1628:
scsiOneValue.Add("Device complies with ATA/ATAPI-8 ATA8-AAM ANSI INCITS 451-2008"); scsiOneValue.Add("Device complies with ATA/ATAPI-8 ATA8-AAM ANSI INCITS 451-2008");

View File

@@ -60,12 +60,14 @@ namespace DiscImageChef.Server
if (ftr.BlocksPerReadableUnit > 1) if (ftr.BlocksPerReadableUnit > 1)
mmcOneValue.Add($"{ftr.BlocksPerReadableUnit} logical blocks per media writable unit"); mmcOneValue.Add($"{ftr.BlocksPerReadableUnit} logical blocks per media writable unit");
if (ftr.BufferUnderrunFreeInDVD) mmcOneValue.Add("Drive supports zero loss linking writing DVDs"); if (ftr.BufferUnderrunFreeInDVD) mmcOneValue.Add("Drive supports zero loss linking writing DVDs");
if(ftr.BufferUnderrunFreeInSAO) mmcOneValue.Add("Drive supports zero loss linking in Session at Once Mode"); if (ftr.BufferUnderrunFreeInSAO)
mmcOneValue.Add("Drive supports zero loss linking in Session at Once Mode");
if (ftr.BufferUnderrunFreeInTAO) mmcOneValue.Add("Drive supports zero loss linking in Track at Once Mode"); if (ftr.BufferUnderrunFreeInTAO) mmcOneValue.Add("Drive supports zero loss linking in Track at Once Mode");
if (ftr.CanAudioScan) mmcOneValue.Add("Drive supports the SCAN command"); if (ftr.CanAudioScan) mmcOneValue.Add("Drive supports the SCAN command");
if (ftr.CanEject) mmcOneValue.Add("Drive can eject media"); if (ftr.CanEject) mmcOneValue.Add("Drive can eject media");
if (ftr.CanEraseSector) mmcOneValue.Add("Drive supports media that require erasing before writing"); if (ftr.CanEraseSector) mmcOneValue.Add("Drive supports media that require erasing before writing");
if(ftr.CanExpandBDRESpareArea) mmcOneValue.Add("Drive can expand the spare area on a formatted BD-RE disc"); if (ftr.CanExpandBDRESpareArea)
mmcOneValue.Add("Drive can expand the spare area on a formatted BD-RE disc");
if (ftr.CanFormat) mmcOneValue.Add("Drive can format media into logical blocks"); if (ftr.CanFormat) mmcOneValue.Add("Drive can format media into logical blocks");
if (ftr.CanFormatBDREWithoutSpare) mmcOneValue.Add("Drive can format BD-RE with no spares allocated"); if (ftr.CanFormatBDREWithoutSpare) mmcOneValue.Add("Drive can format BD-RE with no spares allocated");
if (ftr.CanFormatQCert) mmcOneValue.Add("Drive can format BD-RE discs with quick certification"); if (ftr.CanFormatQCert) mmcOneValue.Add("Drive can format BD-RE discs with quick certification");
@@ -129,7 +131,8 @@ namespace DiscImageChef.Server
if (ftr.Locked) mmcOneValue.Add("Drive can lock media"); if (ftr.Locked) mmcOneValue.Add("Drive can lock media");
if (ftr.LogicalBlockSize > 0) mmcOneValue.Add($"{ftr.LogicalBlockSize} bytes per logical block"); if (ftr.LogicalBlockSize > 0) mmcOneValue.Add($"{ftr.LogicalBlockSize} bytes per logical block");
if (ftr.MultiRead) if (ftr.MultiRead)
mmcOneValue.Add("Drive claims capability to read all CD formats according to OSTA Multi-Read Specification"); mmcOneValue.Add(
"Drive claims capability to read all CD formats according to OSTA Multi-Read Specification");
if (ftr.PhysicalInterfaceStandard.HasValue) if (ftr.PhysicalInterfaceStandard.HasValue)
switch (ftr.PhysicalInterfaceStandard) switch (ftr.PhysicalInterfaceStandard)

View File

@@ -90,9 +90,11 @@ namespace DiscImageChef.Server
: "Drive is not locked, media can be ejected and inserted"); : "Drive is not locked, media can be ejected and inserted");
} }
else else
{
mmcOneValue.Add(mode.LockState mmcOneValue.Add(mode.LockState
? "Drive is locked, media cannot be ejected, but if empty, can be inserted" ? "Drive is locked, media cannot be ejected, but if empty, can be inserted"
: "Drive is not locked, media can be ejected and inserted"); : "Drive is not locked, media can be ejected and inserted");
}
if (mode.Eject) mmcOneValue.Add("Drive can eject media"); if (mode.Eject) mmcOneValue.Add("Drive can eject media");
@@ -132,10 +134,12 @@ namespace DiscImageChef.Server
{ {
if (mode.RotationControlSelected == 0) if (mode.RotationControlSelected == 0)
mmcOneValue mmcOneValue
.Add($"Drive's current writing speed is {mode.CurrentWriteSpeedSelected} Kbyte/sec. in CLV mode"); .Add(
$"Drive's current writing speed is {mode.CurrentWriteSpeedSelected} Kbyte/sec. in CLV mode");
else if (mode.RotationControlSelected == 1) else if (mode.RotationControlSelected == 1)
mmcOneValue mmcOneValue
.Add($"Drive's current writing speed is {mode.CurrentWriteSpeedSelected} Kbyte/sec. in pure CAV mode"); .Add(
$"Drive's current writing speed is {mode.CurrentWriteSpeedSelected} Kbyte/sec. in pure CAV mode");
} }
else else
{ {
@@ -146,7 +150,7 @@ namespace DiscImageChef.Server
} }
if (mode.WriteSpeedPerformanceDescriptors != null) if (mode.WriteSpeedPerformanceDescriptors != null)
foreach(Modes.ModePage_2A_WriteDescriptor descriptor in foreach (var descriptor in
mode.WriteSpeedPerformanceDescriptors.Where(descriptor => descriptor.WriteSpeed > 0)) mode.WriteSpeedPerformanceDescriptors.Where(descriptor => descriptor.WriteSpeed > 0))
if (descriptor.RotationControl == 0) if (descriptor.RotationControl == 0)
mmcOneValue.Add($"Drive supports writing at {descriptor.WriteSpeed} Kbyte/sec. in CLV mode"); mmcOneValue.Add($"Drive supports writing at {descriptor.WriteSpeed} Kbyte/sec. in CLV mode");

View File

@@ -54,10 +54,11 @@ namespace DiscImageChef.Server
if (modeSense.MediumType.HasValue) scsiOneValue.Add($"Medium type is {modeSense.MediumType:X2}h"); if (modeSense.MediumType.HasValue) scsiOneValue.Add($"Medium type is {modeSense.MediumType:X2}h");
if (modeSense.WriteProtected) scsiOneValue.Add("Device is write protected."); if (modeSense.WriteProtected) scsiOneValue.Add("Device is write protected.");
if (modeSense.BlockDescriptors != null) if (modeSense.BlockDescriptors != null)
foreach(BlockDescriptor descriptor in modeSense.BlockDescriptors) foreach (var descriptor in modeSense.BlockDescriptors)
if (descriptor.Blocks.HasValue && descriptor.BlockLength.HasValue) if (descriptor.Blocks.HasValue && descriptor.BlockLength.HasValue)
scsiOneValue scsiOneValue
.Add($"Density code {descriptor.Density:X2}h has {descriptor.Blocks} blocks of {descriptor.BlockLength} bytes each"); .Add(
$"Density code {descriptor.Density:X2}h has {descriptor.Blocks} blocks of {descriptor.BlockLength} bytes each");
else else
scsiOneValue.Add($"Density code {descriptor.Density:X2}h"); scsiOneValue.Add($"Density code {descriptor.Density:X2}h");
@@ -82,7 +83,7 @@ namespace DiscImageChef.Server
if (modeSense.ModePages == null) return; if (modeSense.ModePages == null) return;
foreach(ScsiPage page in modeSense.ModePages) foreach (var page in modeSense.ModePages)
switch (page.page) switch (page.page)
{ {
case 0x00: case 0x00:
@@ -91,7 +92,10 @@ namespace DiscImageChef.Server
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_00_SFF(page.value)); modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_00_SFF(page.value));
else else
modePages modePages
.Add(page.subpage != 0 ? $"MODE page {page.page:X2}h subpage {page.subpage:X2}h" : $"MODE page {page.page:X2}h", .Add(
page.subpage != 0
? $"MODE page {page.page:X2}h subpage {page.subpage:X2}h"
: $"MODE page {page.page:X2}h",
"Unknown vendor mode page"); "Unknown vendor mode page");
break; break;
} }
@@ -364,14 +368,17 @@ namespace DiscImageChef.Server
} }
default: default:
{ {
modePages.Add(page.subpage != 0 ? $"MODE page {page.page:X2}h subpage {page.subpage:X2}h" : $"MODE page {page.page:X2}h", modePages.Add(
page.subpage != 0
? $"MODE page {page.page:X2}h subpage {page.subpage:X2}h"
: $"MODE page {page.page:X2}h",
"Unknown mode page"); "Unknown mode page");
} }
break; break;
} }
Dictionary<string, string> newModePages = new Dictionary<string, string>(); var newModePages = new Dictionary<string, string>();
foreach(KeyValuePair<string, string> kvp in modePages) foreach (var kvp in modePages)
newModePages.Add(kvp.Key, newModePages.Add(kvp.Key,
string.IsNullOrWhiteSpace(kvp.Value) ? "Undecoded" : kvp.Value.Replace("\n", "<br/>")); string.IsNullOrWhiteSpace(kvp.Value) ? "Undecoded" : kvp.Value.Replace("\n", "<br/>"));

View File

@@ -44,7 +44,7 @@ namespace DiscImageChef.Server
/// <param name="testedMedia">List of tested media</param> /// <param name="testedMedia">List of tested media</param>
public static void Report(IEnumerable<TestedSequentialMedia> testedMedia, ref List<string> mediaOneValue) public static void Report(IEnumerable<TestedSequentialMedia> testedMedia, ref List<string> mediaOneValue)
{ {
foreach(TestedSequentialMedia media in testedMedia) foreach (var media in testedMedia)
{ {
if (!string.IsNullOrWhiteSpace(media.MediumTypeName)) if (!string.IsNullOrWhiteSpace(media.MediumTypeName))
{ {
@@ -52,8 +52,13 @@ namespace DiscImageChef.Server
if (media.MediumType.HasValue) mediaOneValue.Add($"Medium type code: {media.MediumType:X2}h"); if (media.MediumType.HasValue) mediaOneValue.Add($"Medium type code: {media.MediumType:X2}h");
} }
else if (media.MediumType.HasValue) else if (media.MediumType.HasValue)
{
mediaOneValue.Add($"<i>Information for medium type {media.MediumType:X2}h</i>"); mediaOneValue.Add($"<i>Information for medium type {media.MediumType:X2}h</i>");
else mediaOneValue.Add("<i>Information for unknown medium type</i>"); }
else
{
mediaOneValue.Add("<i>Information for unknown medium type</i>");
}
if (!string.IsNullOrWhiteSpace(media.Manufacturer)) if (!string.IsNullOrWhiteSpace(media.Manufacturer))
mediaOneValue.Add($"Medium manufactured by: {media.Manufacturer}"); mediaOneValue.Add($"Medium manufactured by: {media.Manufacturer}");

View File

@@ -41,13 +41,13 @@ namespace DiscImageChef.Server
{ {
public static void Convert(Stats newStats) public static void Convert(Stats newStats)
{ {
DicServerContext ctx = new DicServerContext(); var ctx = new DicServerContext();
if (newStats.Commands != null) if (newStats.Commands != null)
{ {
if (newStats.Commands.Analyze > 0) if (newStats.Commands.Analyze > 0)
{ {
Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "analyze"); var existing = ctx.Commands.FirstOrDefault(c => c.Name == "analyze");
if (existing == null) if (existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.Analyze, Name = "analyze"}); ctx.Commands.Add(new Command {Count = newStats.Commands.Analyze, Name = "analyze"});
@@ -56,7 +56,7 @@ namespace DiscImageChef.Server
if (newStats.Commands.Benchmark > 0) if (newStats.Commands.Benchmark > 0)
{ {
Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "benchmark"); var existing = ctx.Commands.FirstOrDefault(c => c.Name == "benchmark");
if (existing == null) if (existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.Benchmark, Name = "benchmark"}); ctx.Commands.Add(new Command {Count = newStats.Commands.Benchmark, Name = "benchmark"});
@@ -65,7 +65,7 @@ namespace DiscImageChef.Server
if (newStats.Commands.Checksum > 0) if (newStats.Commands.Checksum > 0)
{ {
Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "checksum"); var existing = ctx.Commands.FirstOrDefault(c => c.Name == "checksum");
if (existing == null) if (existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.Checksum, Name = "checksum"}); ctx.Commands.Add(new Command {Count = newStats.Commands.Checksum, Name = "checksum"});
@@ -74,7 +74,7 @@ namespace DiscImageChef.Server
if (newStats.Commands.Compare > 0) if (newStats.Commands.Compare > 0)
{ {
Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "compare"); var existing = ctx.Commands.FirstOrDefault(c => c.Name == "compare");
if (existing == null) if (existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.Compare, Name = "compare"}); ctx.Commands.Add(new Command {Count = newStats.Commands.Compare, Name = "compare"});
@@ -83,7 +83,7 @@ namespace DiscImageChef.Server
if (newStats.Commands.CreateSidecar > 0) if (newStats.Commands.CreateSidecar > 0)
{ {
Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "create-sidecar"); var existing = ctx.Commands.FirstOrDefault(c => c.Name == "create-sidecar");
if (existing == null) if (existing == null)
ctx.Commands.Add(new Command ctx.Commands.Add(new Command
@@ -95,7 +95,7 @@ namespace DiscImageChef.Server
if (newStats.Commands.Decode > 0) if (newStats.Commands.Decode > 0)
{ {
Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "decode"); var existing = ctx.Commands.FirstOrDefault(c => c.Name == "decode");
if (existing == null) if (existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.Decode, Name = "decode"}); ctx.Commands.Add(new Command {Count = newStats.Commands.Decode, Name = "decode"});
@@ -104,7 +104,7 @@ namespace DiscImageChef.Server
if (newStats.Commands.DeviceInfo > 0) if (newStats.Commands.DeviceInfo > 0)
{ {
Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "device-info"); var existing = ctx.Commands.FirstOrDefault(c => c.Name == "device-info");
if (existing == null) if (existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.DeviceInfo, Name = "device-info"}); ctx.Commands.Add(new Command {Count = newStats.Commands.DeviceInfo, Name = "device-info"});
@@ -113,7 +113,7 @@ namespace DiscImageChef.Server
if (newStats.Commands.DeviceReport > 0) if (newStats.Commands.DeviceReport > 0)
{ {
Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "device-report"); var existing = ctx.Commands.FirstOrDefault(c => c.Name == "device-report");
if (existing == null) if (existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.DeviceReport, Name = "device-report"}); ctx.Commands.Add(new Command {Count = newStats.Commands.DeviceReport, Name = "device-report"});
@@ -122,7 +122,7 @@ namespace DiscImageChef.Server
if (newStats.Commands.DumpMedia > 0) if (newStats.Commands.DumpMedia > 0)
{ {
Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "dump-media"); var existing = ctx.Commands.FirstOrDefault(c => c.Name == "dump-media");
if (existing == null) if (existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.DumpMedia, Name = "dump-media"}); ctx.Commands.Add(new Command {Count = newStats.Commands.DumpMedia, Name = "dump-media"});
@@ -131,7 +131,7 @@ namespace DiscImageChef.Server
if (newStats.Commands.Entropy > 0) if (newStats.Commands.Entropy > 0)
{ {
Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "entropy"); var existing = ctx.Commands.FirstOrDefault(c => c.Name == "entropy");
if (existing == null) if (existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.Entropy, Name = "entropy"}); ctx.Commands.Add(new Command {Count = newStats.Commands.Entropy, Name = "entropy"});
@@ -140,7 +140,7 @@ namespace DiscImageChef.Server
if (newStats.Commands.Formats > 0) if (newStats.Commands.Formats > 0)
{ {
Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "formats"); var existing = ctx.Commands.FirstOrDefault(c => c.Name == "formats");
if (existing == null) if (existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.Formats, Name = "formats"}); ctx.Commands.Add(new Command {Count = newStats.Commands.Formats, Name = "formats"});
@@ -149,7 +149,7 @@ namespace DiscImageChef.Server
if (newStats.Commands.MediaInfo > 0) if (newStats.Commands.MediaInfo > 0)
{ {
Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "media-info"); var existing = ctx.Commands.FirstOrDefault(c => c.Name == "media-info");
if (existing == null) if (existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.MediaInfo, Name = "media-info"}); ctx.Commands.Add(new Command {Count = newStats.Commands.MediaInfo, Name = "media-info"});
@@ -158,7 +158,7 @@ namespace DiscImageChef.Server
if (newStats.Commands.MediaScan > 0) if (newStats.Commands.MediaScan > 0)
{ {
Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "media-scan"); var existing = ctx.Commands.FirstOrDefault(c => c.Name == "media-scan");
if (existing == null) if (existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.MediaScan, Name = "media-scan"}); ctx.Commands.Add(new Command {Count = newStats.Commands.MediaScan, Name = "media-scan"});
@@ -167,7 +167,7 @@ namespace DiscImageChef.Server
if (newStats.Commands.PrintHex > 0) if (newStats.Commands.PrintHex > 0)
{ {
Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "printhex"); var existing = ctx.Commands.FirstOrDefault(c => c.Name == "printhex");
if (existing == null) if (existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.PrintHex, Name = "printhex"}); ctx.Commands.Add(new Command {Count = newStats.Commands.PrintHex, Name = "printhex"});
@@ -176,7 +176,7 @@ namespace DiscImageChef.Server
if (newStats.Commands.Verify > 0) if (newStats.Commands.Verify > 0)
{ {
Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "verify"); var existing = ctx.Commands.FirstOrDefault(c => c.Name == "verify");
if (existing == null) if (existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.Verify, Name = "verify"}); ctx.Commands.Add(new Command {Count = newStats.Commands.Verify, Name = "verify"});
@@ -185,7 +185,7 @@ namespace DiscImageChef.Server
if (newStats.Commands.Ls > 0) if (newStats.Commands.Ls > 0)
{ {
Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "ls"); var existing = ctx.Commands.FirstOrDefault(c => c.Name == "ls");
if (existing == null) ctx.Commands.Add(new Command {Count = newStats.Commands.Ls, Name = "ls"}); if (existing == null) ctx.Commands.Add(new Command {Count = newStats.Commands.Ls, Name = "ls"});
else existing.Count += newStats.Commands.Ls; else existing.Count += newStats.Commands.Ls;
@@ -193,7 +193,7 @@ namespace DiscImageChef.Server
if (newStats.Commands.ExtractFiles > 0) if (newStats.Commands.ExtractFiles > 0)
{ {
Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "extract-files"); var existing = ctx.Commands.FirstOrDefault(c => c.Name == "extract-files");
if (existing == null) if (existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.ExtractFiles, Name = "extract-files"}); ctx.Commands.Add(new Command {Count = newStats.Commands.ExtractFiles, Name = "extract-files"});
@@ -202,7 +202,7 @@ namespace DiscImageChef.Server
if (newStats.Commands.ListDevices > 0) if (newStats.Commands.ListDevices > 0)
{ {
Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "list-devices"); var existing = ctx.Commands.FirstOrDefault(c => c.Name == "list-devices");
if (existing == null) if (existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.ListDevices, Name = "list-devices"}); ctx.Commands.Add(new Command {Count = newStats.Commands.ListDevices, Name = "list-devices"});
@@ -211,7 +211,7 @@ namespace DiscImageChef.Server
if (newStats.Commands.ListEncodings > 0) if (newStats.Commands.ListEncodings > 0)
{ {
Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "list-encodings"); var existing = ctx.Commands.FirstOrDefault(c => c.Name == "list-encodings");
if (existing == null) if (existing == null)
ctx.Commands.Add(new Command ctx.Commands.Add(new Command
@@ -223,7 +223,7 @@ namespace DiscImageChef.Server
if (newStats.Commands.ConvertImage > 0) if (newStats.Commands.ConvertImage > 0)
{ {
Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "convert-image"); var existing = ctx.Commands.FirstOrDefault(c => c.Name == "convert-image");
if (existing == null) if (existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.ConvertImage, Name = "convert-image"}); ctx.Commands.Add(new Command {Count = newStats.Commands.ConvertImage, Name = "convert-image"});
@@ -232,7 +232,7 @@ namespace DiscImageChef.Server
if (newStats.Commands.ImageInfo > 0) if (newStats.Commands.ImageInfo > 0)
{ {
Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "image-info"); var existing = ctx.Commands.FirstOrDefault(c => c.Name == "image-info");
if (existing == null) if (existing == null)
ctx.Commands.Add(new Command {Count = newStats.Commands.ImageInfo, Name = "image-info"}); ctx.Commands.Add(new Command {Count = newStats.Commands.ImageInfo, Name = "image-info"});
@@ -241,12 +241,13 @@ namespace DiscImageChef.Server
} }
if (newStats.OperatingSystems != null) if (newStats.OperatingSystems != null)
foreach(OsStats operatingSystem in newStats.OperatingSystems) {
foreach (var operatingSystem in newStats.OperatingSystems)
{ {
if (string.IsNullOrWhiteSpace(operatingSystem.name) || if (string.IsNullOrWhiteSpace(operatingSystem.name) ||
string.IsNullOrWhiteSpace(operatingSystem.version)) continue; string.IsNullOrWhiteSpace(operatingSystem.version)) continue;
OperatingSystem existing = var existing =
ctx.OperatingSystems.FirstOrDefault(c => c.Name == operatingSystem.name && ctx.OperatingSystems.FirstOrDefault(c => c.Name == operatingSystem.name &&
c.Version == operatingSystem.version); c.Version == operatingSystem.version);
@@ -259,9 +260,10 @@ namespace DiscImageChef.Server
}); });
else existing.Count += operatingSystem.Value; else existing.Count += operatingSystem.Value;
} }
}
else else
{ {
OperatingSystem existing = var existing =
ctx.OperatingSystems.FirstOrDefault(c => c.Name == "Linux" && c.Version == null); ctx.OperatingSystems.FirstOrDefault(c => c.Name == "Linux" && c.Version == null);
if (existing == null) ctx.OperatingSystems.Add(new OperatingSystem {Count = 1, Name = "Linux"}); if (existing == null) ctx.OperatingSystems.Add(new OperatingSystem {Count = 1, Name = "Linux"});
@@ -269,69 +271,71 @@ namespace DiscImageChef.Server
} }
if (newStats.Versions != null) if (newStats.Versions != null)
foreach(NameValueStats nvs in newStats.Versions) {
foreach (var nvs in newStats.Versions)
{ {
if (string.IsNullOrWhiteSpace(nvs.name)) continue; if (string.IsNullOrWhiteSpace(nvs.name)) continue;
Version existing = ctx.Versions.FirstOrDefault(c => c.Value == nvs.name); var existing = ctx.Versions.FirstOrDefault(c => c.Value == nvs.name);
if (existing == null) ctx.Versions.Add(new Version {Count = nvs.Value, Value = nvs.name}); if (existing == null) ctx.Versions.Add(new Version {Count = nvs.Value, Value = nvs.name});
else existing.Count += nvs.Value; else existing.Count += nvs.Value;
} }
}
else else
{ {
Version existing = ctx.Versions.FirstOrDefault(c => c.Value == "previous"); var existing = ctx.Versions.FirstOrDefault(c => c.Value == "previous");
if (existing == null) ctx.Versions.Add(new Version {Count = 1, Value = "previous"}); if (existing == null) ctx.Versions.Add(new Version {Count = 1, Value = "previous"});
else existing.Count++; else existing.Count++;
} }
if (newStats.Filesystems != null) if (newStats.Filesystems != null)
foreach(NameValueStats nvs in newStats.Filesystems) foreach (var nvs in newStats.Filesystems)
{ {
if (string.IsNullOrWhiteSpace(nvs.name)) continue; if (string.IsNullOrWhiteSpace(nvs.name)) continue;
Filesystem existing = ctx.Filesystems.FirstOrDefault(c => c.Name == nvs.name); var existing = ctx.Filesystems.FirstOrDefault(c => c.Name == nvs.name);
if (existing == null) ctx.Filesystems.Add(new Filesystem {Count = nvs.Value, Name = nvs.name}); if (existing == null) ctx.Filesystems.Add(new Filesystem {Count = nvs.Value, Name = nvs.name});
else existing.Count += nvs.Value; else existing.Count += nvs.Value;
} }
if (newStats.Partitions != null) if (newStats.Partitions != null)
foreach(NameValueStats nvs in newStats.Partitions) foreach (var nvs in newStats.Partitions)
{ {
if (string.IsNullOrWhiteSpace(nvs.name)) continue; if (string.IsNullOrWhiteSpace(nvs.name)) continue;
Partition existing = ctx.Partitions.FirstOrDefault(c => c.Name == nvs.name); var existing = ctx.Partitions.FirstOrDefault(c => c.Name == nvs.name);
if (existing == null) ctx.Partitions.Add(new Partition {Count = nvs.Value, Name = nvs.name}); if (existing == null) ctx.Partitions.Add(new Partition {Count = nvs.Value, Name = nvs.name});
else existing.Count += nvs.Value; else existing.Count += nvs.Value;
} }
if (newStats.MediaImages != null) if (newStats.MediaImages != null)
foreach(NameValueStats nvs in newStats.MediaImages) foreach (var nvs in newStats.MediaImages)
{ {
if (string.IsNullOrWhiteSpace(nvs.name)) continue; if (string.IsNullOrWhiteSpace(nvs.name)) continue;
MediaFormat existing = ctx.MediaFormats.FirstOrDefault(c => c.Name == nvs.name); var existing = ctx.MediaFormats.FirstOrDefault(c => c.Name == nvs.name);
if (existing == null) ctx.MediaFormats.Add(new MediaFormat {Count = nvs.Value, Name = nvs.name}); if (existing == null) ctx.MediaFormats.Add(new MediaFormat {Count = nvs.Value, Name = nvs.name});
else existing.Count += nvs.Value; else existing.Count += nvs.Value;
} }
if (newStats.Filters != null) if (newStats.Filters != null)
foreach(NameValueStats nvs in newStats.Filters) foreach (var nvs in newStats.Filters)
{ {
if (string.IsNullOrWhiteSpace(nvs.name)) continue; if (string.IsNullOrWhiteSpace(nvs.name)) continue;
Filter existing = ctx.Filters.FirstOrDefault(c => c.Name == nvs.name); var existing = ctx.Filters.FirstOrDefault(c => c.Name == nvs.name);
if (existing == null) ctx.Filters.Add(new Filter {Count = nvs.Value, Name = nvs.name}); if (existing == null) ctx.Filters.Add(new Filter {Count = nvs.Value, Name = nvs.name});
else existing.Count += nvs.Value; else existing.Count += nvs.Value;
} }
if (newStats.Devices != null) if (newStats.Devices != null)
foreach(DeviceStats device in newStats.Devices) foreach (var device in newStats.Devices)
{ {
if (string.IsNullOrWhiteSpace(device.Model)) continue; if (string.IsNullOrWhiteSpace(device.Model)) continue;
@@ -347,11 +351,11 @@ namespace DiscImageChef.Server
} }
if (newStats.Medias != null) if (newStats.Medias != null)
foreach(MediaStats media in newStats.Medias) foreach (var media in newStats.Medias)
{ {
if (string.IsNullOrWhiteSpace(media.type)) continue; if (string.IsNullOrWhiteSpace(media.type)) continue;
Media existing = ctx.Medias.FirstOrDefault(c => c.Type == media.type && c.Real == media.real); var existing = ctx.Medias.FirstOrDefault(c => c.Type == media.type && c.Real == media.real);
if (existing == null) if (existing == null)
ctx.Medias.Add(new Media {Count = media.Value, Real = media.real, Type = media.type}); ctx.Medias.Add(new Media {Count = media.Value, Real = media.real, Type = media.type});

View File

@@ -44,7 +44,7 @@ namespace DiscImageChef.Server.App_Start
/// <param name="testedMedias">List of tested media</param> /// <param name="testedMedias">List of tested media</param>
public static void Report(List<CommonTypes.Metadata.TestedMedia> testedMedias, ref List<string> mediaOneValue) public static void Report(List<CommonTypes.Metadata.TestedMedia> testedMedias, ref List<string> mediaOneValue)
{ {
foreach(CommonTypes.Metadata.TestedMedia testedMedia in testedMedias) foreach (var testedMedia in testedMedias)
{ {
if (!string.IsNullOrWhiteSpace(testedMedia.MediumTypeName)) if (!string.IsNullOrWhiteSpace(testedMedia.MediumTypeName))
{ {
@@ -53,8 +53,13 @@ namespace DiscImageChef.Server.App_Start
mediaOneValue.Add($"Medium type code: {testedMedia.MediumType:X2}h"); mediaOneValue.Add($"Medium type code: {testedMedia.MediumType:X2}h");
} }
else if (testedMedia.MediumType != null) else if (testedMedia.MediumType != null)
{
mediaOneValue.Add($"<i>Information for medium type {testedMedia.MediumType:X2}h</i>"); mediaOneValue.Add($"<i>Information for medium type {testedMedia.MediumType:X2}h</i>");
else mediaOneValue.Add("<i>Information for unknown medium type</i>"); }
else
{
mediaOneValue.Add("<i>Information for unknown medium type</i>");
}
mediaOneValue.Add(testedMedia.MediaIsRecognized mediaOneValue.Add(testedMedia.MediaIsRecognized
? "Drive recognizes this medium." ? "Drive recognizes this medium."
@@ -79,38 +84,46 @@ namespace DiscImageChef.Server.App_Start
if (testedMedia.Blocks * testedMedia.BlockSize / 1024 / 1024 > 1000000) if (testedMedia.Blocks * testedMedia.BlockSize / 1024 / 1024 > 1000000)
mediaOneValue mediaOneValue
.Add($"Medium size: {testedMedia.Blocks * testedMedia.BlockSize} bytes, {testedMedia.Blocks * testedMedia.BlockSize / 1000 / 1000 / 1000 / 1000} Tb, {(double)(testedMedia.Blocks * testedMedia.BlockSize) / 1024 / 1024 / 1024 / 1024:F2} TiB"); .Add(
$"Medium size: {testedMedia.Blocks * testedMedia.BlockSize} bytes, {testedMedia.Blocks * testedMedia.BlockSize / 1000 / 1000 / 1000 / 1000} Tb, {(double) (testedMedia.Blocks * testedMedia.BlockSize) / 1024 / 1024 / 1024 / 1024:F2} TiB");
else if (testedMedia.Blocks * testedMedia.BlockSize / 1024 / 1024 > 1000) else if (testedMedia.Blocks * testedMedia.BlockSize / 1024 / 1024 > 1000)
mediaOneValue mediaOneValue
.Add($"Medium size: {testedMedia.Blocks * testedMedia.BlockSize} bytes, {testedMedia.Blocks * testedMedia.BlockSize / 1000 / 1000 / 1000} Gb, {(double)(testedMedia.Blocks * testedMedia.BlockSize) / 1024 / 1024 / 1024:F2} GiB"); .Add(
$"Medium size: {testedMedia.Blocks * testedMedia.BlockSize} bytes, {testedMedia.Blocks * testedMedia.BlockSize / 1000 / 1000 / 1000} Gb, {(double) (testedMedia.Blocks * testedMedia.BlockSize) / 1024 / 1024 / 1024:F2} GiB");
else else
mediaOneValue mediaOneValue
.Add($"Medium size: {testedMedia.Blocks * testedMedia.BlockSize} bytes, {testedMedia.Blocks * testedMedia.BlockSize / 1000 / 1000} Mb, {(double)(testedMedia.Blocks * testedMedia.BlockSize) / 1024 / 1024:F2} MiB"); .Add(
$"Medium size: {testedMedia.Blocks * testedMedia.BlockSize} bytes, {testedMedia.Blocks * testedMedia.BlockSize / 1000 / 1000} Mb, {(double) (testedMedia.Blocks * testedMedia.BlockSize) / 1024 / 1024:F2} MiB");
} }
if (testedMedia.CHS != null && testedMedia.CurrentCHS != null) if (testedMedia.CHS != null && testedMedia.CurrentCHS != null)
{ {
int currentSectors = testedMedia.CurrentCHS.Cylinders * testedMedia.CurrentCHS.Heads * var currentSectors = testedMedia.CurrentCHS.Cylinders * testedMedia.CurrentCHS.Heads *
testedMedia.CurrentCHS.Sectors; testedMedia.CurrentCHS.Sectors;
mediaOneValue mediaOneValue
.Add($"Cylinders: {testedMedia.CHS.Cylinders} max., {testedMedia.CurrentCHS.Cylinders} current"); .Add(
$"Cylinders: {testedMedia.CHS.Cylinders} max., {testedMedia.CurrentCHS.Cylinders} current");
mediaOneValue.Add($"Heads: {testedMedia.CHS.Heads} max., {testedMedia.CurrentCHS.Heads} current"); mediaOneValue.Add($"Heads: {testedMedia.CHS.Heads} max., {testedMedia.CurrentCHS.Heads} current");
mediaOneValue mediaOneValue
.Add($"Sectors per track: {testedMedia.CHS.Sectors} max., {testedMedia.CurrentCHS.Sectors} current"); .Add(
$"Sectors per track: {testedMedia.CHS.Sectors} max., {testedMedia.CurrentCHS.Sectors} current");
mediaOneValue mediaOneValue
.Add($"Sectors addressable in CHS mode: {testedMedia.CHS.Cylinders * testedMedia.CHS.Heads * testedMedia.CHS.Sectors} max., {currentSectors} current"); .Add(
$"Sectors addressable in CHS mode: {testedMedia.CHS.Cylinders * testedMedia.CHS.Heads * testedMedia.CHS.Sectors} max., {currentSectors} current");
mediaOneValue mediaOneValue
.Add($"Medium size in CHS mode: {(ulong)currentSectors * testedMedia.BlockSize} bytes, {(ulong)currentSectors * testedMedia.BlockSize / 1000 / 1000} Mb, {(double)((ulong)currentSectors * testedMedia.BlockSize) / 1024 / 1024:F2} MiB"); .Add(
$"Medium size in CHS mode: {(ulong) currentSectors * testedMedia.BlockSize} bytes, {(ulong) currentSectors * testedMedia.BlockSize / 1000 / 1000} Mb, {(double) ((ulong) currentSectors * testedMedia.BlockSize) / 1024 / 1024:F2} MiB");
} }
else if (testedMedia.CHS != null) else if (testedMedia.CHS != null)
{ {
int currentSectors = testedMedia.CHS.Cylinders * testedMedia.CHS.Heads * testedMedia.CHS.Sectors; var currentSectors = testedMedia.CHS.Cylinders * testedMedia.CHS.Heads * testedMedia.CHS.Sectors;
mediaOneValue.Add($"Cylinders: {testedMedia.CHS.Cylinders}"); mediaOneValue.Add($"Cylinders: {testedMedia.CHS.Cylinders}");
mediaOneValue.Add($"Heads: {testedMedia.CHS.Heads}"); mediaOneValue.Add($"Heads: {testedMedia.CHS.Heads}");
mediaOneValue.Add($"Sectors per track: {testedMedia.CHS.Sectors}"); mediaOneValue.Add($"Sectors per track: {testedMedia.CHS.Sectors}");
mediaOneValue.Add($"Sectors addressable in CHS mode: {currentSectors}"); mediaOneValue.Add($"Sectors addressable in CHS mode: {currentSectors}");
mediaOneValue mediaOneValue
.Add($"Medium size in CHS mode: {(ulong)currentSectors * testedMedia.BlockSize} bytes, {(ulong)currentSectors * testedMedia.BlockSize / 1000 / 1000} Mb, {(double)((ulong)currentSectors * testedMedia.BlockSize) / 1024 / 1024:F2} MiB"); .Add(
$"Medium size in CHS mode: {(ulong) currentSectors * testedMedia.BlockSize} bytes, {(ulong) currentSectors * testedMedia.BlockSize / 1000 / 1000} Mb, {(double) ((ulong) currentSectors * testedMedia.BlockSize) / 1024 / 1024:F2} MiB");
} }
if (testedMedia.LBASectors != null) if (testedMedia.LBASectors != null)
@@ -119,13 +132,16 @@ namespace DiscImageChef.Server.App_Start
if ((ulong) testedMedia.LBASectors * testedMedia.BlockSize / 1024 / 1024 > 1000000) if ((ulong) testedMedia.LBASectors * testedMedia.BlockSize / 1024 / 1024 > 1000000)
mediaOneValue mediaOneValue
.Add($"Medium size in 28-bit LBA mode: {(ulong)testedMedia.LBASectors * testedMedia.BlockSize} bytes, {(ulong)testedMedia.LBASectors * testedMedia.BlockSize / 1000 / 1000 / 1000 / 1000} Tb, {(double)((ulong)testedMedia.LBASectors * testedMedia.BlockSize) / 1024 / 1024 / 1024 / 1024:F2} TiB"); .Add(
$"Medium size in 28-bit LBA mode: {(ulong) testedMedia.LBASectors * testedMedia.BlockSize} bytes, {(ulong) testedMedia.LBASectors * testedMedia.BlockSize / 1000 / 1000 / 1000 / 1000} Tb, {(double) ((ulong) testedMedia.LBASectors * testedMedia.BlockSize) / 1024 / 1024 / 1024 / 1024:F2} TiB");
else if ((ulong) testedMedia.LBASectors * testedMedia.BlockSize / 1024 / 1024 > 1000) else if ((ulong) testedMedia.LBASectors * testedMedia.BlockSize / 1024 / 1024 > 1000)
mediaOneValue mediaOneValue
.Add($"Medium size in 28-bit LBA mode: {(ulong)testedMedia.LBASectors * testedMedia.BlockSize} bytes, {(ulong)testedMedia.LBASectors * testedMedia.BlockSize / 1000 / 1000 / 1000} Gb, {(double)((ulong)testedMedia.LBASectors * testedMedia.BlockSize) / 1024 / 1024 / 1024:F2} GiB"); .Add(
$"Medium size in 28-bit LBA mode: {(ulong) testedMedia.LBASectors * testedMedia.BlockSize} bytes, {(ulong) testedMedia.LBASectors * testedMedia.BlockSize / 1000 / 1000 / 1000} Gb, {(double) ((ulong) testedMedia.LBASectors * testedMedia.BlockSize) / 1024 / 1024 / 1024:F2} GiB");
else else
mediaOneValue mediaOneValue
.Add($"Medium size in 28-bit LBA mode: {(ulong)testedMedia.LBASectors * testedMedia.BlockSize} bytes, {(ulong)testedMedia.LBASectors * testedMedia.BlockSize / 1000 / 1000} Mb, {(double)((ulong)testedMedia.LBASectors * testedMedia.BlockSize) / 1024 / 1024:F2} MiB"); .Add(
$"Medium size in 28-bit LBA mode: {(ulong) testedMedia.LBASectors * testedMedia.BlockSize} bytes, {(ulong) testedMedia.LBASectors * testedMedia.BlockSize / 1000 / 1000} Mb, {(double) ((ulong) testedMedia.LBASectors * testedMedia.BlockSize) / 1024 / 1024:F2} MiB");
} }
if (testedMedia.LBA48Sectors != null) if (testedMedia.LBA48Sectors != null)
@@ -134,13 +150,16 @@ namespace DiscImageChef.Server.App_Start
if (testedMedia.LBA48Sectors * testedMedia.BlockSize / 1024 / 1024 > 1000000) if (testedMedia.LBA48Sectors * testedMedia.BlockSize / 1024 / 1024 > 1000000)
mediaOneValue mediaOneValue
.Add($"Medium size in 48-bit LBA mode: {testedMedia.LBA48Sectors * testedMedia.BlockSize} bytes, {testedMedia.LBA48Sectors * testedMedia.BlockSize / 1000 / 1000 / 1000 / 1000} Tb, {(double)(testedMedia.LBA48Sectors * testedMedia.BlockSize) / 1024 / 1024 / 1024 / 1024:F2} TiB"); .Add(
$"Medium size in 48-bit LBA mode: {testedMedia.LBA48Sectors * testedMedia.BlockSize} bytes, {testedMedia.LBA48Sectors * testedMedia.BlockSize / 1000 / 1000 / 1000 / 1000} Tb, {(double) (testedMedia.LBA48Sectors * testedMedia.BlockSize) / 1024 / 1024 / 1024 / 1024:F2} TiB");
else if (testedMedia.LBA48Sectors * testedMedia.BlockSize / 1024 / 1024 > 1000) else if (testedMedia.LBA48Sectors * testedMedia.BlockSize / 1024 / 1024 > 1000)
mediaOneValue mediaOneValue
.Add($"Medium size in 48-bit LBA mode: {testedMedia.LBA48Sectors * testedMedia.BlockSize} bytes, {testedMedia.LBA48Sectors * testedMedia.BlockSize / 1000 / 1000 / 1000} Gb, {(double)(testedMedia.LBA48Sectors * testedMedia.BlockSize) / 1024 / 1024 / 1024:F2} GiB"); .Add(
$"Medium size in 48-bit LBA mode: {testedMedia.LBA48Sectors * testedMedia.BlockSize} bytes, {testedMedia.LBA48Sectors * testedMedia.BlockSize / 1000 / 1000 / 1000} Gb, {(double) (testedMedia.LBA48Sectors * testedMedia.BlockSize) / 1024 / 1024 / 1024:F2} GiB");
else else
mediaOneValue mediaOneValue
.Add($"Medium size in 48-bit LBA mode: {testedMedia.LBA48Sectors * testedMedia.BlockSize} bytes, {testedMedia.LBA48Sectors * testedMedia.BlockSize / 1000 / 1000} Mb, {(double)(testedMedia.LBA48Sectors * testedMedia.BlockSize) / 1024 / 1024:F2} MiB"); .Add(
$"Medium size in 48-bit LBA mode: {testedMedia.LBA48Sectors * testedMedia.BlockSize} bytes, {testedMedia.LBA48Sectors * testedMedia.BlockSize / 1000 / 1000} Mb, {(double) (testedMedia.LBA48Sectors * testedMedia.BlockSize) / 1024 / 1024:F2} MiB");
} }
if (testedMedia.NominalRotationRate != null && testedMedia.NominalRotationRate != 0x0000 && if (testedMedia.NominalRotationRate != null && testedMedia.NominalRotationRate != 0x0000 &&
@@ -155,7 +174,8 @@ namespace DiscImageChef.Server.App_Start
(testedMedia.LogicalAlignment & 0x8000) == 0x0000 && (testedMedia.LogicalAlignment & 0x8000) == 0x0000 &&
(testedMedia.LogicalAlignment & 0x4000) == 0x4000) (testedMedia.LogicalAlignment & 0x4000) == 0x4000)
mediaOneValue mediaOneValue
.Add($"Logical sector starts at offset {testedMedia.LogicalAlignment & 0x3FFF} from physical sector"); .Add(
$"Logical sector starts at offset {testedMedia.LogicalAlignment & 0x3FFF} from physical sector");
if (testedMedia.SupportsReadSectors == true) if (testedMedia.SupportsReadSectors == true)
mediaOneValue.Add("Device can use the READ SECTOR(S) command in CHS mode with this medium"); mediaOneValue.Add("Device can use the READ SECTOR(S) command in CHS mode with this medium");
@@ -217,10 +237,12 @@ namespace DiscImageChef.Server.App_Start
mediaOneValue.Add("Device can use the READ CD command with MM:SS:FF addressing with this medium"); mediaOneValue.Add("Device can use the READ CD command with MM:SS:FF addressing with this medium");
if (testedMedia.SupportsReadCdRaw == true) if (testedMedia.SupportsReadCdRaw == true)
mediaOneValue mediaOneValue
.Add("Device can use the READ CD command with LBA addressing with this medium to read raw sector"); .Add(
"Device can use the READ CD command with LBA addressing with this medium to read raw sector");
if (testedMedia.SupportsReadCdMsfRaw == true) if (testedMedia.SupportsReadCdMsfRaw == true)
mediaOneValue mediaOneValue
.Add("Device can use the READ CD command with MM:SS:FF addressing with this medium read raw sector"); .Add(
"Device can use the READ CD command with MM:SS:FF addressing with this medium read raw sector");
if (testedMedia.SupportsHLDTSTReadRawDVD == true) if (testedMedia.SupportsHLDTSTReadRawDVD == true)
mediaOneValue.Add("Device can use the HL-DT-ST vendor READ DVD (RAW) command with this medium"); mediaOneValue.Add("Device can use the HL-DT-ST vendor READ DVD (RAW) command with this medium");
@@ -268,7 +290,8 @@ namespace DiscImageChef.Server.App_Start
mediaOneValue.Add("Device can read the layer capacity from this medium"); mediaOneValue.Add("Device can read the layer capacity from this medium");
if (testedMedia.CanReadFirstTrackPreGap == true) if (testedMedia.CanReadFirstTrackPreGap == true)
mediaOneValue.Add("Device can read the first track's pregap data"); mediaOneValue.Add("Device can read the first track's pregap data");
if(testedMedia.CanReadLeadIn == true) mediaOneValue.Add("Device can read the Lead-In from this medium"); if (testedMedia.CanReadLeadIn == true)
mediaOneValue.Add("Device can read the Lead-In from this medium");
if (testedMedia.CanReadLeadOut == true) if (testedMedia.CanReadLeadOut == true)
mediaOneValue.Add("Device can read the Lead-Out from this medium"); mediaOneValue.Add("Device can read the Lead-Out from this medium");
if (testedMedia.CanReadMediaID == true) if (testedMedia.CanReadMediaID == true)

View File

@@ -41,7 +41,7 @@ namespace DiscImageChef.Server.Controllers
{ {
public class HomeController : Controller public class HomeController : Controller
{ {
private IWebHostEnvironment _environment; private readonly IWebHostEnvironment _environment;
public HomeController(IWebHostEnvironment environment) public HomeController(IWebHostEnvironment environment)
{ {
@@ -52,10 +52,10 @@ namespace DiscImageChef.Server.Controllers
[Route("README")] [Route("README")]
public ActionResult Index() public ActionResult Index()
{ {
StreamReader sr = var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "README.md")); "docs", "README.md"));
string mdcontent = sr.ReadToEnd(); var mdcontent = sr.ReadToEnd();
sr.Close(); sr.Close();
mdcontent = mdcontent.Replace(".md)", ")"); mdcontent = mdcontent.Replace(".md)", ")");
@@ -70,10 +70,10 @@ namespace DiscImageChef.Server.Controllers
[Route("Changelog")] [Route("Changelog")]
public ActionResult Changelog() public ActionResult Changelog()
{ {
StreamReader sr = var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "Changelog.md")); "docs", "Changelog.md"));
string mdcontent = sr.ReadToEnd(); var mdcontent = sr.ReadToEnd();
sr.Close(); sr.Close();
mdcontent = mdcontent.Replace(".md)", ")"); mdcontent = mdcontent.Replace(".md)", ")");
@@ -88,10 +88,10 @@ namespace DiscImageChef.Server.Controllers
[Route("CODE_OF_CONDUCT")] [Route("CODE_OF_CONDUCT")]
public ActionResult CODE_OF_CONDUCT() public ActionResult CODE_OF_CONDUCT()
{ {
StreamReader sr = var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "CODE_OF_CONDUCT.md")); "docs", "CODE_OF_CONDUCT.md"));
string mdcontent = sr.ReadToEnd(); var mdcontent = sr.ReadToEnd();
sr.Close(); sr.Close();
mdcontent = mdcontent.Replace(".md)", ")").Replace("(.github/", "("); mdcontent = mdcontent.Replace(".md)", ")").Replace("(.github/", "(");
@@ -106,10 +106,10 @@ namespace DiscImageChef.Server.Controllers
[Route("PULL_REQUEST_TEMPLATE")] [Route("PULL_REQUEST_TEMPLATE")]
public ActionResult PULL_REQUEST_TEMPLATE() public ActionResult PULL_REQUEST_TEMPLATE()
{ {
StreamReader sr = var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "PULL_REQUEST_TEMPLATE.md")); "docs", "PULL_REQUEST_TEMPLATE.md"));
string mdcontent = sr.ReadToEnd(); var mdcontent = sr.ReadToEnd();
sr.Close(); sr.Close();
mdcontent = mdcontent.Replace(".md)", ")").Replace("(.github/", "("); mdcontent = mdcontent.Replace(".md)", ")").Replace("(.github/", "(");
@@ -124,10 +124,10 @@ namespace DiscImageChef.Server.Controllers
[Route("ISSUE_TEMPLATE")] [Route("ISSUE_TEMPLATE")]
public ActionResult ISSUE_TEMPLATE() public ActionResult ISSUE_TEMPLATE()
{ {
StreamReader sr = var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "ISSUE_TEMPLATE.md")); "docs", "ISSUE_TEMPLATE.md"));
string mdcontent = sr.ReadToEnd(); var mdcontent = sr.ReadToEnd();
sr.Close(); sr.Close();
mdcontent = mdcontent.Replace(".md)", ")").Replace("(.github/", "("); mdcontent = mdcontent.Replace(".md)", ")").Replace("(.github/", "(");
@@ -142,10 +142,10 @@ namespace DiscImageChef.Server.Controllers
[Route("CONTRIBUTING")] [Route("CONTRIBUTING")]
public ActionResult CONTRIBUTING() public ActionResult CONTRIBUTING()
{ {
StreamReader sr = var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "CONTRIBUTING.md")); "docs", "CONTRIBUTING.md"));
string mdcontent = sr.ReadToEnd(); var mdcontent = sr.ReadToEnd();
sr.Close(); sr.Close();
mdcontent = mdcontent.Replace(".md)", ")").Replace("(.github/", "("); mdcontent = mdcontent.Replace(".md)", ")").Replace("(.github/", "(");
@@ -160,10 +160,10 @@ namespace DiscImageChef.Server.Controllers
[Route("DONATING")] [Route("DONATING")]
public ActionResult DONATING() public ActionResult DONATING()
{ {
StreamReader sr = var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "DONATING.md")); "docs", "DONATING.md"));
string mdcontent = sr.ReadToEnd(); var mdcontent = sr.ReadToEnd();
sr.Close(); sr.Close();
mdcontent = mdcontent.Replace(".md)", ")"); mdcontent = mdcontent.Replace(".md)", ")");
@@ -178,10 +178,10 @@ namespace DiscImageChef.Server.Controllers
[Route("TODO")] [Route("TODO")]
public ActionResult TODO() public ActionResult TODO()
{ {
StreamReader sr = var sr =
new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"docs", "TODO.md")); "docs", "TODO.md"));
string mdcontent = sr.ReadToEnd(); var mdcontent = sr.ReadToEnd();
sr.Close(); sr.Close();
mdcontent = mdcontent.Replace(".md)", ")"); mdcontent = mdcontent.Replace(".md)", ")");

View File

@@ -39,20 +39,22 @@ using DiscImageChef.Decoders.SCSI;
using DiscImageChef.Server.Models; using DiscImageChef.Server.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.Routing;
using Tuple = DiscImageChef.Decoders.PCMCIA.Tuple;
namespace DiscImageChef.Server.Controllers namespace DiscImageChef.Server.Controllers
{ {
public class ReportController : Controller public class ReportController : Controller
{ {
private DicServerContext _ctx; private readonly DicServerContext _ctx;
public ReportController(DicServerContext context) public ReportController(DicServerContext context)
{ {
_ctx = context; _ctx = context;
} }
public ActionResult Index() => RedirectToAction("View", "Report", new RouteValueDictionary {{"id", 1}}); public ActionResult Index()
{
return RedirectToAction("View", "Report", new RouteValueDictionary {{"id", 1}});
}
public ActionResult View(int? id) public ActionResult View(int? id)
{ {
@@ -60,7 +62,7 @@ namespace DiscImageChef.Server.Controllers
try try
{ {
Device report = _ctx.Devices.FirstOrDefault(d => d.Id == id); var report = _ctx.Devices.FirstOrDefault(d => d.Id == id);
if (report is null) return Content("Cannot find requested report"); if (report is null) return Content("Cannot find requested report");
@@ -73,14 +75,14 @@ namespace DiscImageChef.Server.Controllers
string usbVendorDescription = null; string usbVendorDescription = null;
string usbProductDescription = null; string usbProductDescription = null;
UsbProduct dbProduct = var dbProduct =
_ctx.UsbProducts.FirstOrDefault(p => p.ProductId == report.USB.ProductID && _ctx.UsbProducts.FirstOrDefault(p => p.ProductId == report.USB.ProductID &&
p.Vendor != null && p.Vendor != null &&
p.Vendor.VendorId == report.USB.VendorID); p.Vendor.VendorId == report.USB.VendorID);
if (dbProduct is null) if (dbProduct is null)
{ {
UsbVendor dbVendor = _ctx.UsbVendors.FirstOrDefault(v => v.VendorId == report.USB.VendorID); var dbVendor = _ctx.UsbVendors.FirstOrDefault(v => v.VendorId == report.USB.VendorID);
if (!(dbVendor is null)) usbVendorDescription = dbVendor.Vendor; if (!(dbVendor is null)) usbVendorDescription = dbVendor.Vendor;
} }
@@ -124,11 +126,11 @@ namespace DiscImageChef.Server.Controllers
Compliance = report.PCMCIA.Compliance Compliance = report.PCMCIA.Compliance
}; };
Tuple[] tuples = CIS.GetTuples(report.PCMCIA.CIS); var tuples = CIS.GetTuples(report.PCMCIA.CIS);
if (tuples != null) if (tuples != null)
{ {
Dictionary<string, string> decodedTuples = new Dictionary<string, string>(); var decodedTuples = new Dictionary<string, string>();
foreach(Tuple tuple in tuples) foreach (var tuple in tuples)
switch (tuple.Code) switch (tuple.Code)
{ {
case TupleCodes.CISTPL_NULL: case TupleCodes.CISTPL_NULL:
@@ -137,9 +139,9 @@ namespace DiscImageChef.Server.Controllers
case TupleCodes.CISTPL_VERS_1: break; case TupleCodes.CISTPL_VERS_1: break;
case TupleCodes.CISTPL_DEVICEGEO: case TupleCodes.CISTPL_DEVICEGEO:
case TupleCodes.CISTPL_DEVICEGEO_A: case TupleCodes.CISTPL_DEVICEGEO_A:
DeviceGeometryTuple geom = CIS.DecodeDeviceGeometryTuple(tuple.Data); var geom = CIS.DecodeDeviceGeometryTuple(tuple.Data);
if (geom?.Geometries != null) if (geom?.Geometries != null)
foreach(DeviceGeometry geometry in geom.Geometries) foreach (var geometry in geom.Geometries)
{ {
decodedTuples.Add("Device width", decodedTuples.Add("Device width",
$"{(1 << (geometry.CardInterface - 1)) * 8} bits"); $"{(1 << (geometry.CardInterface - 1)) * 8} bits");
@@ -199,17 +201,17 @@ namespace DiscImageChef.Server.Controllers
} }
} }
bool removable = true; var removable = true;
List<TestedMedia> testedMedia = null; List<TestedMedia> testedMedia = null;
bool ata = false; var ata = false;
bool atapi = false; var atapi = false;
bool sscMedia = false; var sscMedia = false;
if (report.ATA != null || report.ATAPI != null) if (report.ATA != null || report.ATAPI != null)
{ {
ata = true; ata = true;
List<string> ataOneValue = new List<string>(); var ataOneValue = new List<string>();
Dictionary<string, string> ataTwoValue = new Dictionary<string, string>(); var ataTwoValue = new Dictionary<string, string>();
CommonTypes.Metadata.Ata ataReport; CommonTypes.Metadata.Ata ataReport;
if (report.ATAPI != null) if (report.ATAPI != null)
@@ -224,7 +226,7 @@ namespace DiscImageChef.Server.Controllers
ataReport = report.ATA; ataReport = report.ATA;
} }
bool cfa = report.CompactFlash; var cfa = report.CompactFlash;
if (atapi && !cfa) ViewBag.lblAtaDeviceType = "ATAPI device"; if (atapi && !cfa) ViewBag.lblAtaDeviceType = "ATAPI device";
else if (!atapi && cfa) ViewBag.lblAtaDeviceType = "CompactFlash device"; else if (!atapi && cfa) ViewBag.lblAtaDeviceType = "CompactFlash device";
@@ -238,14 +240,14 @@ namespace DiscImageChef.Server.Controllers
if (report.SCSI != null) if (report.SCSI != null)
{ {
List<string> scsiOneValue = new List<string>(); var scsiOneValue = new List<string>();
Dictionary<string, string> modePages = new Dictionary<string, string>(); var modePages = new Dictionary<string, string>();
Dictionary<string, string> evpdPages = new Dictionary<string, string>(); var evpdPages = new Dictionary<string, string>();
string vendorId = StringHandlers.CToString(report.SCSI.Inquiry?.VendorIdentification); var vendorId = StringHandlers.CToString(report.SCSI.Inquiry?.VendorIdentification);
if (report.SCSI.Inquiry != null) if (report.SCSI.Inquiry != null)
{ {
Inquiry.SCSIInquiry inq = report.SCSI.Inquiry.Value; var inq = report.SCSI.Inquiry.Value;
ViewBag.lblScsiVendor = VendorString.Prettify(vendorId) != vendorId ViewBag.lblScsiVendor = VendorString.Prettify(vendorId) != vendorId
? $"{vendorId} ({VendorString.Prettify(vendorId)})" ? $"{vendorId} ({VendorString.Prettify(vendorId)})"
: vendorId; : vendorId;
@@ -261,7 +263,7 @@ namespace DiscImageChef.Server.Controllers
if (report.SCSI.ModeSense != null) if (report.SCSI.ModeSense != null)
{ {
PeripheralDeviceTypes devType = PeripheralDeviceTypes.DirectAccess; var devType = PeripheralDeviceTypes.DirectAccess;
if (report.SCSI.Inquiry != null) if (report.SCSI.Inquiry != null)
devType = (PeripheralDeviceTypes) report.SCSI.Inquiry.Value.PeripheralDeviceType; devType = (PeripheralDeviceTypes) report.SCSI.Inquiry.Value.PeripheralDeviceType;
ScsiModeSense.Report(report.SCSI.ModeSense, vendorId, devType, ref scsiOneValue, ref modePages); ScsiModeSense.Report(report.SCSI.ModeSense, vendorId, devType, ref scsiOneValue, ref modePages);
@@ -279,14 +281,14 @@ namespace DiscImageChef.Server.Controllers
if (report.SCSI.MultiMediaDevice.ModeSense2A != null) if (report.SCSI.MultiMediaDevice.ModeSense2A != null)
{ {
List<string> mmcModeOneValue = new List<string>(); var mmcModeOneValue = new List<string>();
ScsiMmcMode.Report(report.SCSI.MultiMediaDevice.ModeSense2A, ref mmcModeOneValue); ScsiMmcMode.Report(report.SCSI.MultiMediaDevice.ModeSense2A, ref mmcModeOneValue);
if (mmcModeOneValue.Count > 0) ViewBag.repScsiMmcMode = mmcModeOneValue; if (mmcModeOneValue.Count > 0) ViewBag.repScsiMmcMode = mmcModeOneValue;
} }
if (report.SCSI.MultiMediaDevice.Features != null) if (report.SCSI.MultiMediaDevice.Features != null)
{ {
List<string> mmcFeaturesOneValue = new List<string>(); var mmcFeaturesOneValue = new List<string>();
ScsiMmcFeatures.Report(report.SCSI.MultiMediaDevice.Features, ref mmcFeaturesOneValue); ScsiMmcFeatures.Report(report.SCSI.MultiMediaDevice.Features, ref mmcFeaturesOneValue);
if (mmcFeaturesOneValue.Count > 0) ViewBag.repScsiMmcFeatures = mmcFeaturesOneValue; if (mmcFeaturesOneValue.Count > 0) ViewBag.repScsiMmcFeatures = mmcFeaturesOneValue;
} }
@@ -312,7 +314,7 @@ namespace DiscImageChef.Server.Controllers
if (report.SCSI.SequentialDevice.TestedMedia != null) if (report.SCSI.SequentialDevice.TestedMedia != null)
{ {
List<string> mediaOneValue = new List<string>(); var mediaOneValue = new List<string>();
SscTestedMedia.Report(report.SCSI.SequentialDevice.TestedMedia, ref mediaOneValue); SscTestedMedia.Report(report.SCSI.SequentialDevice.TestedMedia, ref mediaOneValue);
if (mediaOneValue.Count > 0) if (mediaOneValue.Count > 0)
{ {
@@ -330,20 +332,24 @@ namespace DiscImageChef.Server.Controllers
report.SCSI.ReadCapabilities.BlockSize.HasValue) report.SCSI.ReadCapabilities.BlockSize.HasValue)
{ {
scsiOneValue scsiOneValue
.Add($"Device has {report.SCSI.ReadCapabilities.Blocks} blocks of {report.SCSI.ReadCapabilities.BlockSize} bytes each"); .Add(
$"Device has {report.SCSI.ReadCapabilities.Blocks} blocks of {report.SCSI.ReadCapabilities.BlockSize} bytes each");
if (report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize / 1024 / if (report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize / 1024 /
1024 > 1000000) 1024 > 1000000)
scsiOneValue scsiOneValue
.Add($"Device size: {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize} bytes, {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize / 1000 / 1000 / 1000 / 1000} Tb, {(double)(report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize) / 1024 / 1024 / 1024 / 1024:F2} TiB"); .Add(
$"Device size: {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize} bytes, {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize / 1000 / 1000 / 1000 / 1000} Tb, {(double) (report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize) / 1024 / 1024 / 1024 / 1024:F2} TiB");
else if (report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize / else if (report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize /
1024 / 1024 /
1024 > 1000) 1024 > 1000)
scsiOneValue scsiOneValue
.Add($"Device size: {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize} bytes, {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize / 1000 / 1000 / 1000} Gb, {(double)(report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize) / 1024 / 1024 / 1024:F2} GiB"); .Add(
$"Device size: {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize} bytes, {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize / 1000 / 1000 / 1000} Gb, {(double) (report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize) / 1024 / 1024 / 1024:F2} GiB");
else else
scsiOneValue scsiOneValue
.Add($"Device size: {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize} bytes, {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize / 1000 / 1000} Mb, {(double)(report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize) / 1024 / 1024:F2} MiB"); .Add(
$"Device size: {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize} bytes, {report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize / 1000 / 1000} Mb, {(double) (report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize) / 1024 / 1024:F2} MiB");
} }
if (report.SCSI.ReadCapabilities.MediumType.HasValue) if (report.SCSI.ReadCapabilities.MediumType.HasValue)
@@ -371,14 +377,17 @@ namespace DiscImageChef.Server.Controllers
if (report.SCSI.ReadCapabilities.SupportsReadLong16 == true) if (report.SCSI.ReadCapabilities.SupportsReadLong16 == true)
scsiOneValue.Add("Device supports READ LONG (16) command."); scsiOneValue.Add("Device supports READ LONG (16) command.");
} }
else testedMedia = report.SCSI.RemovableMedias; else
{
testedMedia = report.SCSI.RemovableMedias;
}
ViewBag.repScsi = scsiOneValue; ViewBag.repScsi = scsiOneValue;
} }
if (report.MultiMediaCard != null) if (report.MultiMediaCard != null)
{ {
List<string> mmcOneValue = new List<string>(); var mmcOneValue = new List<string>();
if (report.MultiMediaCard.CID != null) if (report.MultiMediaCard.CID != null)
{ {
@@ -413,7 +422,7 @@ namespace DiscImageChef.Server.Controllers
if (report.SecureDigital != null) if (report.SecureDigital != null)
{ {
List<string> sdOneValue = new List<string>(); var sdOneValue = new List<string>();
if (report.SecureDigital.CID != null) if (report.SecureDigital.CID != null)
{ {
@@ -448,7 +457,7 @@ namespace DiscImageChef.Server.Controllers
if (removable && !sscMedia && testedMedia != null) if (removable && !sscMedia && testedMedia != null)
{ {
List<string> mediaOneValue = new List<string>(); var mediaOneValue = new List<string>();
App_Start.TestedMedia.Report(testedMedia, ref mediaOneValue); App_Start.TestedMedia.Report(testedMedia, ref mediaOneValue);
if (mediaOneValue.Count > 0) ViewBag.repTestedMedia = mediaOneValue; if (mediaOneValue.Count > 0) ViewBag.repTestedMedia = mediaOneValue;
} }

View File

@@ -44,11 +44,7 @@ using DiscImageChef.Server.Models;
using Highsoft.Web.Mvc.Charts; using Highsoft.Web.Mvc.Charts;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Hosting.Internal;
using Filter = DiscImageChef.Server.Models.Filter;
using OperatingSystem = DiscImageChef.Server.Models.OperatingSystem;
using PlatformID = DiscImageChef.CommonTypes.Interop.PlatformID; using PlatformID = DiscImageChef.CommonTypes.Interop.PlatformID;
using Version = DiscImageChef.Server.Models.Version;
namespace DiscImageChef.Server.Controllers namespace DiscImageChef.Server.Controllers
{ {
@@ -57,13 +53,13 @@ namespace DiscImageChef.Server.Controllers
/// </summary> /// </summary>
public class StatsController : Controller public class StatsController : Controller
{ {
DicServerContext ctx; private readonly IWebHostEnvironment _environment;
List<DeviceItem> devices; private readonly DicServerContext ctx;
List<NameValueStats> operatingSystems; private List<DeviceItem> devices;
List<MediaItem> realMedia; private List<NameValueStats> operatingSystems;
List<NameValueStats> versions; private List<MediaItem> realMedia;
List<MediaItem> virtualMedia; private List<NameValueStats> versions;
private IWebHostEnvironment _environment; private List<MediaItem> virtualMedia;
public StatsController(IWebHostEnvironment environment, DicServerContext context) public StatsController(IWebHostEnvironment environment, DicServerContext context)
{ {
@@ -83,11 +79,13 @@ namespace DiscImageChef.Server.Controllers
"Statistics", "Statistics.xml"))) "Statistics", "Statistics.xml")))
try try
{ {
Stats statistics = new Stats(); var statistics = new Stats();
XmlSerializer xs = new XmlSerializer(statistics.GetType()); var xs = new XmlSerializer(statistics.GetType());
FileStream fs = var fs =
WaitForFile(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), "Statistics", "Statistics.xml"), WaitForFile(
Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"Statistics", "Statistics.xml"),
FileMode.Open, FileAccess.Read, FileShare.Read); FileMode.Open, FileAccess.Read, FileShare.Read);
statistics = (Stats) xs.Deserialize(fs); statistics = (Stats) xs.Deserialize(fs);
fs.Close(); fs.Close();
@@ -106,7 +104,7 @@ namespace DiscImageChef.Server.Controllers
if (ctx.OperatingSystems.Any()) if (ctx.OperatingSystems.Any())
{ {
operatingSystems = new List<NameValueStats>(); operatingSystems = new List<NameValueStats>();
foreach(OperatingSystem nvs in ctx.OperatingSystems) foreach (var nvs in ctx.OperatingSystems)
operatingSystems.Add(new NameValueStats operatingSystems.Add(new NameValueStats
{ {
name = name =
@@ -116,10 +114,10 @@ namespace DiscImageChef.Server.Controllers
ViewBag.repOperatingSystems = operatingSystems.OrderBy(os => os.name).ToList(); ViewBag.repOperatingSystems = operatingSystems.OrderBy(os => os.name).ToList();
List<PieSeriesData> osPieData = new List<PieSeriesData>(); var osPieData = new List<PieSeriesData>();
decimal totalOsCount = ctx.OperatingSystems.Sum(o => o.Count); decimal totalOsCount = ctx.OperatingSystems.Sum(o => o.Count);
foreach(string os in ctx.OperatingSystems.Select(o => o.Name).Distinct().ToList()) foreach (var os in ctx.OperatingSystems.Select(o => o.Name).Distinct().ToList())
{ {
decimal osCount = ctx.OperatingSystems.Where(o => o.Name == os).Sum(o => o.Count); decimal osCount = ctx.OperatingSystems.Where(o => o.Name == os).Sum(o => o.Count);
@@ -136,11 +134,11 @@ namespace DiscImageChef.Server.Controllers
ViewData["osPieData"] = osPieData; ViewData["osPieData"] = osPieData;
List<PieSeriesData> linuxPieData = new List<PieSeriesData>(); var linuxPieData = new List<PieSeriesData>();
decimal linuxCount = ctx.OperatingSystems.Where(o => o.Name == PlatformID.Linux.ToString()) decimal linuxCount = ctx.OperatingSystems.Where(o => o.Name == PlatformID.Linux.ToString())
.Sum(o => o.Count); .Sum(o => o.Count);
foreach(OperatingSystem version in foreach (var version in
ctx.OperatingSystems.Where(o => o.Name == PlatformID.Linux.ToString())) ctx.OperatingSystems.Where(o => o.Name == PlatformID.Linux.ToString()))
linuxPieData.Add(new PieSeriesData linuxPieData.Add(new PieSeriesData
{ {
@@ -151,11 +149,11 @@ namespace DiscImageChef.Server.Controllers
ViewData["linuxPieData"] = linuxPieData; ViewData["linuxPieData"] = linuxPieData;
List<PieSeriesData> macosPieData = new List<PieSeriesData>(); var macosPieData = new List<PieSeriesData>();
decimal macosCount = ctx.OperatingSystems.Where(o => o.Name == PlatformID.MacOSX.ToString()) decimal macosCount = ctx.OperatingSystems.Where(o => o.Name == PlatformID.MacOSX.ToString())
.Sum(o => o.Count); .Sum(o => o.Count);
foreach(OperatingSystem version in foreach (var version in
ctx.OperatingSystems.Where(o => o.Name == PlatformID.MacOSX.ToString())) ctx.OperatingSystems.Where(o => o.Name == PlatformID.MacOSX.ToString()))
macosPieData.Add(new PieSeriesData macosPieData.Add(new PieSeriesData
{ {
@@ -166,11 +164,11 @@ namespace DiscImageChef.Server.Controllers
ViewData["macosPieData"] = macosPieData; ViewData["macosPieData"] = macosPieData;
List<PieSeriesData> windowsPieData = new List<PieSeriesData>(); var windowsPieData = new List<PieSeriesData>();
decimal windowsCount = ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString()) decimal windowsCount = ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString())
.Sum(o => o.Count); .Sum(o => o.Count);
foreach(OperatingSystem version in foreach (var version in
ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString())) ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString()))
windowsPieData.Add(new PieSeriesData windowsPieData.Add(new PieSeriesData
{ {
@@ -185,7 +183,7 @@ namespace DiscImageChef.Server.Controllers
if (ctx.Versions.Any()) if (ctx.Versions.Any())
{ {
versions = new List<NameValueStats>(); versions = new List<NameValueStats>();
foreach(Version nvs in ctx.Versions) foreach (var nvs in ctx.Versions)
versions.Add(new NameValueStats versions.Add(new NameValueStats
{ {
name = nvs.Value == "previous" ? "Previous than 3.4.99.0" : nvs.Value, name = nvs.Value == "previous" ? "Previous than 3.4.99.0" : nvs.Value,
@@ -230,10 +228,10 @@ namespace DiscImageChef.Server.Controllers
{ {
ViewBag.repFilters = ctx.Filters.OrderBy(filter => filter.Name).ToList(); ViewBag.repFilters = ctx.Filters.OrderBy(filter => filter.Name).ToList();
List<PieSeriesData> filtersPieData = new List<PieSeriesData>(); var filtersPieData = new List<PieSeriesData>();
decimal totalFiltersCount = ctx.Filters.Sum(o => o.Count); decimal totalFiltersCount = ctx.Filters.Sum(o => o.Count);
foreach(Filter filter in ctx.Filters.ToList()) foreach (var filter in ctx.Filters.ToList())
filtersPieData.Add(new PieSeriesData filtersPieData.Add(new PieSeriesData
{ {
Name = filter.Name, Name = filter.Name,
@@ -249,12 +247,12 @@ namespace DiscImageChef.Server.Controllers
{ {
ViewBag.repMediaImages = ctx.MediaFormats.OrderBy(filter => filter.Name).ToList(); ViewBag.repMediaImages = ctx.MediaFormats.OrderBy(filter => filter.Name).ToList();
List<PieSeriesData> formatsPieData = new List<PieSeriesData>(); var formatsPieData = new List<PieSeriesData>();
decimal totalFormatsCount = ctx.MediaFormats.Sum(o => o.Count); decimal totalFormatsCount = ctx.MediaFormats.Sum(o => o.Count);
decimal top10FormatCount = 0; decimal top10FormatCount = 0;
foreach(MediaFormat format in ctx.MediaFormats.OrderByDescending(o => o.Count).Take(10)) foreach (var format in ctx.MediaFormats.OrderByDescending(o => o.Count).Take(10))
{ {
top10FormatCount += format.Count; top10FormatCount += format.Count;
@@ -280,12 +278,12 @@ namespace DiscImageChef.Server.Controllers
{ {
ViewBag.repPartitions = ctx.Partitions.OrderBy(filter => filter.Name).ToList(); ViewBag.repPartitions = ctx.Partitions.OrderBy(filter => filter.Name).ToList();
List<PieSeriesData> partitionsPieData = new List<PieSeriesData>(); var partitionsPieData = new List<PieSeriesData>();
decimal totalPartitionsCount = ctx.Partitions.Sum(o => o.Count); decimal totalPartitionsCount = ctx.Partitions.Sum(o => o.Count);
decimal top10PartitionCount = 0; decimal top10PartitionCount = 0;
foreach(Partition partition in ctx.Partitions.OrderByDescending(o => o.Count).Take(10)) foreach (var partition in ctx.Partitions.OrderByDescending(o => o.Count).Take(10))
{ {
top10PartitionCount += partition.Count; top10PartitionCount += partition.Count;
@@ -312,12 +310,12 @@ namespace DiscImageChef.Server.Controllers
{ {
ViewBag.repFilesystems = ctx.Filesystems.OrderBy(filter => filter.Name).ToList(); ViewBag.repFilesystems = ctx.Filesystems.OrderBy(filter => filter.Name).ToList();
List<PieSeriesData> filesystemsPieData = new List<PieSeriesData>(); var filesystemsPieData = new List<PieSeriesData>();
decimal totalFilesystemsCount = ctx.Filesystems.Sum(o => o.Count); decimal totalFilesystemsCount = ctx.Filesystems.Sum(o => o.Count);
decimal top10FilesystemCount = 0; decimal top10FilesystemCount = 0;
foreach(Filesystem filesystem in ctx.Filesystems.OrderByDescending(o => o.Count).Take(10)) foreach (var filesystem in ctx.Filesystems.OrderByDescending(o => o.Count).Take(10))
{ {
top10FilesystemCount += filesystem.Count; top10FilesystemCount += filesystem.Count;
@@ -344,12 +342,13 @@ namespace DiscImageChef.Server.Controllers
{ {
realMedia = new List<MediaItem>(); realMedia = new List<MediaItem>();
virtualMedia = new List<MediaItem>(); virtualMedia = new List<MediaItem>();
foreach(Media nvs in ctx.Medias) foreach (var nvs in ctx.Medias)
try try
{ {
MediaType MediaType
.MediaTypeToString((CommonTypes.MediaType)Enum.Parse(typeof(CommonTypes.MediaType), nvs.Type), .MediaTypeToString(
out string type, out string subtype); (CommonTypes.MediaType) Enum.Parse(typeof(CommonTypes.MediaType), nvs.Type),
out var type, out var subtype);
if (nvs.Real) if (nvs.Real)
realMedia.Add(new MediaItem {Type = type, SubType = subtype, Count = nvs.Count}); realMedia.Add(new MediaItem {Type = type, SubType = subtype, Count = nvs.Count});
@@ -367,12 +366,12 @@ namespace DiscImageChef.Server.Controllers
ViewBag.repRealMedia = ViewBag.repRealMedia =
realMedia.OrderBy(media => media.Type).ThenBy(media => media.SubType).ToList(); realMedia.OrderBy(media => media.Type).ThenBy(media => media.SubType).ToList();
List<PieSeriesData> realMediaPieData = new List<PieSeriesData>(); var realMediaPieData = new List<PieSeriesData>();
decimal totalRealMediaCount = realMedia.Sum(o => o.Count); decimal totalRealMediaCount = realMedia.Sum(o => o.Count);
decimal top10RealMediaCount = 0; decimal top10RealMediaCount = 0;
foreach(MediaItem realMediaItem in realMedia.OrderByDescending(o => o.Count).Take(10)) foreach (var realMediaItem in realMedia.OrderByDescending(o => o.Count).Take(10))
{ {
top10RealMediaCount += realMediaItem.Count; top10RealMediaCount += realMediaItem.Count;
@@ -400,12 +399,12 @@ namespace DiscImageChef.Server.Controllers
ViewBag.repVirtualMedia = ViewBag.repVirtualMedia =
virtualMedia.OrderBy(media => media.Type).ThenBy(media => media.SubType).ToList(); virtualMedia.OrderBy(media => media.Type).ThenBy(media => media.SubType).ToList();
List<PieSeriesData> virtualMediaPieData = new List<PieSeriesData>(); var virtualMediaPieData = new List<PieSeriesData>();
decimal totalVirtualMediaCount = virtualMedia.Sum(o => o.Count); decimal totalVirtualMediaCount = virtualMedia.Sum(o => o.Count);
decimal top10VirtualMediaCount = 0; decimal top10VirtualMediaCount = 0;
foreach(MediaItem virtualMediaItem in virtualMedia.OrderByDescending(o => o.Count).Take(10)) foreach (var virtualMediaItem in virtualMedia.OrderByDescending(o => o.Count).Take(10))
{ {
top10VirtualMediaCount += virtualMediaItem.Count; top10VirtualMediaCount += virtualMediaItem.Count;
@@ -435,7 +434,7 @@ namespace DiscImageChef.Server.Controllers
if (ctx.DeviceStats.Any()) if (ctx.DeviceStats.Any())
{ {
devices = new List<DeviceItem>(); devices = new List<DeviceItem>();
foreach(DeviceStat device in ctx.DeviceStats.ToList()) foreach (var device in ctx.DeviceStats.ToList())
{ {
string xmlFile; string xmlFile;
if (!string.IsNullOrWhiteSpace(device.Manufacturer) && if (!string.IsNullOrWhiteSpace(device.Manufacturer) &&
@@ -445,7 +444,8 @@ namespace DiscImageChef.Server.Controllers
else if (!string.IsNullOrWhiteSpace(device.Manufacturer) && else if (!string.IsNullOrWhiteSpace(device.Manufacturer) &&
!string.IsNullOrWhiteSpace(device.Model)) !string.IsNullOrWhiteSpace(device.Model))
xmlFile = device.Manufacturer + "_" + device.Model + ".xml"; xmlFile = device.Manufacturer + "_" + device.Model + ".xml";
else if(!string.IsNullOrWhiteSpace(device.Model) && !string.IsNullOrWhiteSpace(device.Revision)) else if (!string.IsNullOrWhiteSpace(device.Model) &&
!string.IsNullOrWhiteSpace(device.Revision))
xmlFile = device.Model + "_" + device.Revision + ".xml"; xmlFile = device.Model + "_" + device.Revision + ".xml";
else xmlFile = device.Model + ".xml"; else xmlFile = device.Model + ".xml";
@@ -453,22 +453,25 @@ namespace DiscImageChef.Server.Controllers
if (System.IO.File.Exists(Path.Combine(_environment.ContentRootPath, "Reports", xmlFile))) if (System.IO.File.Exists(Path.Combine(_environment.ContentRootPath, "Reports", xmlFile)))
{ {
DeviceReport deviceReport = new DeviceReport(); var deviceReport = new DeviceReport();
XmlSerializer xs = new XmlSerializer(deviceReport.GetType()); var xs = new XmlSerializer(deviceReport.GetType());
FileStream fs = var fs =
WaitForFile(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), "Reports", xmlFile), WaitForFile(
Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"Reports", xmlFile),
FileMode.Open, FileAccess.Read, FileShare.Read); FileMode.Open, FileAccess.Read, FileShare.Read);
deviceReport = (DeviceReport) xs.Deserialize(fs); deviceReport = (DeviceReport) xs.Deserialize(fs);
fs.Close(); fs.Close();
DeviceReportV2 deviceReportV2 = new DeviceReportV2(deviceReport); var deviceReportV2 = new DeviceReportV2(deviceReport);
device.Report = ctx.Devices.Add(new Device(deviceReportV2)).Entity; device.Report = ctx.Devices.Add(new Device(deviceReportV2)).Entity;
ctx.SaveChanges(); ctx.SaveChanges();
System.IO.File System.IO.File
.Delete(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), .Delete(Path.Combine(
_environment.ContentRootPath ?? throw new InvalidOperationException(),
"Reports", xmlFile)); "Reports", xmlFile));
} }
@@ -498,10 +501,13 @@ namespace DiscImageChef.Server.Controllers
ViewData["devicesManufacturerPieData"] = ViewData["devicesManufacturerPieData"] =
(from manufacturer in (from manufacturer in
devices.Where(d => d.Manufacturer != null).Select(d => d.Manufacturer.ToLowerInvariant()) devices.Where(d => d.Manufacturer != null)
.Select(d => d.Manufacturer.ToLowerInvariant())
.Distinct() .Distinct()
let manufacturerCount = devices.Count(d => d.Manufacturer?.ToLowerInvariant() == manufacturer) let manufacturerCount =
select new PieSeriesData {Name = manufacturer, Y = manufacturerCount / (double)devices.Count}) devices.Count(d => d.Manufacturer?.ToLowerInvariant() == manufacturer)
select new PieSeriesData
{Name = manufacturer, Y = manufacturerCount / (double) devices.Count})
.ToList(); .ToList();
} }
} }
@@ -516,9 +522,9 @@ namespace DiscImageChef.Server.Controllers
return View(); return View();
} }
static FileStream WaitForFile(string fullPath, FileMode mode, FileAccess access, FileShare share) private static FileStream WaitForFile(string fullPath, FileMode mode, FileAccess access, FileShare share)
{ {
for(int numTries = 0; numTries < 100; numTries++) for (var numTries = 0; numTries < 100; numTries++)
{ {
FileStream fs = null; FileStream fs = null;
try try

View File

@@ -30,13 +30,10 @@
// Copyright © 2011-2019 Natalia Portillo // Copyright © 2011-2019 Natalia Portillo
// ****************************************************************************/ // ****************************************************************************/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Net.Http;
using System.Text;
using DiscImageChef.CommonTypes.Metadata; using DiscImageChef.CommonTypes.Metadata;
using DiscImageChef.Dto; using DiscImageChef.Dto;
using DiscImageChef.Server.Models; using DiscImageChef.Server.Models;
@@ -48,7 +45,7 @@ namespace DiscImageChef.Server.Controllers
{ {
public class UpdateController : Controller public class UpdateController : Controller
{ {
private DicServerContext _ctx; private readonly DicServerContext _ctx;
public UpdateController(DicServerContext ctx) public UpdateController(DicServerContext ctx)
{ {
@@ -63,15 +60,15 @@ namespace DiscImageChef.Server.Controllers
[HttpGet] [HttpGet]
public ActionResult Update(long timestamp) public ActionResult Update(long timestamp)
{ {
SyncDto sync = new SyncDto(); var sync = new SyncDto();
DateTime lastSync = DateHandlers.UnixToDateTime(timestamp); var lastSync = DateHandlers.UnixToDateTime(timestamp);
sync.UsbVendors = new List<UsbVendorDto>(); sync.UsbVendors = new List<UsbVendorDto>();
foreach(UsbVendor vendor in _ctx.UsbVendors.Where(v => v.ModifiedWhen > lastSync)) foreach (var vendor in _ctx.UsbVendors.Where(v => v.ModifiedWhen > lastSync))
sync.UsbVendors.Add(new UsbVendorDto {VendorId = (ushort) vendor.VendorId, Vendor = vendor.Vendor}); sync.UsbVendors.Add(new UsbVendorDto {VendorId = (ushort) vendor.VendorId, Vendor = vendor.Vendor});
sync.UsbProducts = new List<UsbProductDto>(); sync.UsbProducts = new List<UsbProductDto>();
foreach(UsbProduct product in _ctx.UsbProducts.Include(p => p.Vendor).Where(p => p.ModifiedWhen > lastSync)) foreach (var product in _ctx.UsbProducts.Include(p => p.Vendor).Where(p => p.ModifiedWhen > lastSync))
sync.UsbProducts.Add(new UsbProductDto sync.UsbProducts.Add(new UsbProductDto
{ {
Id = product.Id, Id = product.Id,
@@ -81,17 +78,20 @@ namespace DiscImageChef.Server.Controllers
}); });
sync.Offsets = new List<CdOffsetDto>(); sync.Offsets = new List<CdOffsetDto>();
foreach(CompactDiscOffset offset in _ctx.CdOffsets.Where(o => o.ModifiedWhen > lastSync)) foreach (var offset in _ctx.CdOffsets.Where(o => o.ModifiedWhen > lastSync))
sync.Offsets.Add(new CdOffsetDto(offset, offset.Id)); sync.Offsets.Add(new CdOffsetDto(offset, offset.Id));
sync.Devices = new List<DeviceDto>(); sync.Devices = new List<DeviceDto>();
foreach(Device device in _ctx.Devices.Where(d => d.ModifiedWhen > lastSync).ToList()) foreach (var device in _ctx.Devices.Where(d => d.ModifiedWhen > lastSync).ToList())
sync.Devices.Add(new sync.Devices.Add(new
DeviceDto(JsonConvert.DeserializeObject<DeviceReportV2>(JsonConvert.SerializeObject(device, Formatting.None, new JsonSerializerSettings {ReferenceLoopHandling = ReferenceLoopHandling.Ignore})), DeviceDto(
JsonConvert.DeserializeObject<DeviceReportV2>(JsonConvert.SerializeObject(device,
Formatting.None,
new JsonSerializerSettings {ReferenceLoopHandling = ReferenceLoopHandling.Ignore})),
device.Id, device.OptimalMultipleSectorsRead)); device.Id, device.OptimalMultipleSectorsRead));
JsonSerializer js = JsonSerializer.Create(); var js = JsonSerializer.Create();
StringWriter sw = new StringWriter(); var sw = new StringWriter();
js.Serialize(sw, sync); js.Serialize(sw, sync);
return new ContentResult return new ContentResult

View File

@@ -34,19 +34,15 @@ using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Net.Http;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web;
using System.Xml.Serialization; using System.Xml.Serialization;
using Cinchoo.PGP; using Cinchoo.PGP;
using DiscImageChef.CommonTypes.Metadata; using DiscImageChef.CommonTypes.Metadata;
using DiscImageChef.Server.Models; using DiscImageChef.Server.Models;
using MailKit.Net.Smtp; using MailKit.Net.Smtp;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Hosting.Internal;
using MimeKit; using MimeKit;
using Newtonsoft.Json; using Newtonsoft.Json;
@@ -54,8 +50,8 @@ namespace DiscImageChef.Server.Controllers
{ {
public class UploadReportController : Controller public class UploadReportController : Controller
{ {
private DicServerContext ctx; private readonly IWebHostEnvironment _environment;
private IWebHostEnvironment _environment; private readonly DicServerContext ctx;
public UploadReportController(IWebHostEnvironment environment, DicServerContext _ctx) public UploadReportController(IWebHostEnvironment environment, DicServerContext _ctx)
{ {
@@ -71,15 +67,16 @@ namespace DiscImageChef.Server.Controllers
[HttpPost] [HttpPost]
public async Task<IActionResult> UploadReport() public async Task<IActionResult> UploadReport()
{ {
ContentResult response = new ContentResult {StatusCode = (int)HttpStatusCode.OK, ContentType = "text/plain"}; var response = new ContentResult {StatusCode = (int) HttpStatusCode.OK, ContentType = "text/plain"};
try try
{ {
DeviceReport newReport = new DeviceReport(); var newReport = new DeviceReport();
HttpRequest request = HttpContext.Request; var request = HttpContext.Request;
XmlSerializer xs = new XmlSerializer(newReport.GetType()); var xs = new XmlSerializer(newReport.GetType());
newReport = (DeviceReport) xs.Deserialize(new StringReader(await new StreamReader(request.Body).ReadToEndAsync())); newReport = (DeviceReport) xs.Deserialize(
new StringReader(await new StreamReader(request.Body).ReadToEndAsync()));
if (newReport == null) if (newReport == null)
{ {
@@ -87,29 +84,29 @@ namespace DiscImageChef.Server.Controllers
return response; return response;
} }
DeviceReportV2 reportV2 = new DeviceReportV2(newReport); var reportV2 = new DeviceReportV2(newReport);
StringWriter jsonSw = new StringWriter(); var jsonSw = new StringWriter();
jsonSw.Write(JsonConvert.SerializeObject(reportV2, Formatting.Indented, jsonSw.Write(JsonConvert.SerializeObject(reportV2, Formatting.Indented,
new JsonSerializerSettings new JsonSerializerSettings
{ {
NullValueHandling = NullValueHandling.Ignore NullValueHandling = NullValueHandling.Ignore
})); }));
string reportV2String = jsonSw.ToString(); var reportV2String = jsonSw.ToString();
jsonSw.Close(); jsonSw.Close();
ctx.Reports.Add(new UploadedReport(reportV2)); ctx.Reports.Add(new UploadedReport(reportV2));
ctx.SaveChanges(); ctx.SaveChanges();
MemoryStream pgpIn = new MemoryStream(Encoding.UTF8.GetBytes(reportV2String)); var pgpIn = new MemoryStream(Encoding.UTF8.GetBytes(reportV2String));
MemoryStream pgpOut = new MemoryStream(); var pgpOut = new MemoryStream();
ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt(); var pgp = new ChoPGPEncryptDecrypt();
pgp.Encrypt(pgpIn, pgpOut, pgp.Encrypt(pgpIn, pgpOut,
Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"public.asc"), true); "public.asc"));
pgpOut.Position = 0; pgpOut.Position = 0;
reportV2String = Encoding.UTF8.GetString(pgpOut.ToArray()); reportV2String = Encoding.UTF8.GetString(pgpOut.ToArray());
MimeMessage message = new MimeMessage var message = new MimeMessage
{ {
Subject = "New device report (old version)", Subject = "New device report (old version)",
Body = new TextPart("plain") {Text = reportV2String} Body = new TextPart("plain") {Text = reportV2String}
@@ -117,7 +114,7 @@ namespace DiscImageChef.Server.Controllers
message.From.Add(new MailboxAddress("DiscImageChef", "dic@claunia.com")); message.From.Add(new MailboxAddress("DiscImageChef", "dic@claunia.com"));
message.To.Add(new MailboxAddress("Natalia Portillo", "claunia@claunia.com")); message.To.Add(new MailboxAddress("Natalia Portillo", "claunia@claunia.com"));
using(SmtpClient client = new SmtpClient()) using (var client = new SmtpClient())
{ {
client.Connect("mail.claunia.com", 25, false); client.Connect("mail.claunia.com", 25, false);
client.Send(message); client.Send(message);
@@ -146,15 +143,15 @@ namespace DiscImageChef.Server.Controllers
[HttpPost] [HttpPost]
public async Task<IActionResult> UploadReportV2() public async Task<IActionResult> UploadReportV2()
{ {
ContentResult response = new ContentResult {StatusCode = (int)HttpStatusCode.OK, ContentType = "text/plain"}; var response = new ContentResult {StatusCode = (int) HttpStatusCode.OK, ContentType = "text/plain"};
try try
{ {
HttpRequest request = HttpContext.Request; var request = HttpContext.Request;
StreamReader sr = new StreamReader(request.Body); var sr = new StreamReader(request.Body);
string reportJson = await sr.ReadToEndAsync(); var reportJson = await sr.ReadToEndAsync();
DeviceReportV2 newReport = JsonConvert.DeserializeObject<DeviceReportV2>(reportJson); var newReport = JsonConvert.DeserializeObject<DeviceReportV2>(reportJson);
if (newReport == null) if (newReport == null)
{ {
@@ -165,23 +162,23 @@ namespace DiscImageChef.Server.Controllers
ctx.Reports.Add(new UploadedReport(newReport)); ctx.Reports.Add(new UploadedReport(newReport));
ctx.SaveChanges(); ctx.SaveChanges();
MemoryStream pgpIn = new MemoryStream(Encoding.UTF8.GetBytes(reportJson)); var pgpIn = new MemoryStream(Encoding.UTF8.GetBytes(reportJson));
MemoryStream pgpOut = new MemoryStream(); var pgpOut = new MemoryStream();
ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt(); var pgp = new ChoPGPEncryptDecrypt();
pgp.Encrypt(pgpIn, pgpOut, pgp.Encrypt(pgpIn, pgpOut,
Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"public.asc"), true); "public.asc"));
pgpOut.Position = 0; pgpOut.Position = 0;
reportJson = Encoding.UTF8.GetString(pgpOut.ToArray()); reportJson = Encoding.UTF8.GetString(pgpOut.ToArray());
MimeMessage message = new MimeMessage var message = new MimeMessage
{ {
Subject = "New device report", Body = new TextPart("plain") {Text = reportJson} Subject = "New device report", Body = new TextPart("plain") {Text = reportJson}
}; };
message.From.Add(new MailboxAddress("DiscImageChef", "dic@claunia.com")); message.From.Add(new MailboxAddress("DiscImageChef", "dic@claunia.com"));
message.To.Add(new MailboxAddress("Natalia Portillo", "claunia@claunia.com")); message.To.Add(new MailboxAddress("Natalia Portillo", "claunia@claunia.com"));
using(SmtpClient client = new SmtpClient()) using (var client = new SmtpClient())
{ {
client.Connect("mail.claunia.com", 25, false); client.Connect("mail.claunia.com", 25, false);
client.Send(message); client.Send(message);

View File

@@ -35,16 +35,12 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web;
using System.Xml.Serialization; using System.Xml.Serialization;
using DiscImageChef.CommonTypes.Metadata; using DiscImageChef.CommonTypes.Metadata;
using DiscImageChef.Server.Models; using DiscImageChef.Server.Models;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json; using Newtonsoft.Json;
using OperatingSystem = DiscImageChef.Server.Models.OperatingSystem; using OperatingSystem = DiscImageChef.Server.Models.OperatingSystem;
@@ -54,7 +50,7 @@ namespace DiscImageChef.Server.Controllers
{ {
public class UploadStatsController : Controller public class UploadStatsController : Controller
{ {
DicServerContext _ctx; private readonly DicServerContext _ctx;
private IWebHostEnvironment _environment; private IWebHostEnvironment _environment;
public UploadStatsController(IWebHostEnvironment environment, DicServerContext ctx) public UploadStatsController(IWebHostEnvironment environment, DicServerContext ctx)
@@ -62,6 +58,7 @@ namespace DiscImageChef.Server.Controllers
_environment = environment; _environment = environment;
_ctx = ctx; _ctx = ctx;
} }
/// <summary> /// <summary>
/// Receives statistics from DiscImageChef.Core, processes them and adds them to a server-side global statistics XML /// Receives statistics from DiscImageChef.Core, processes them and adds them to a server-side global statistics XML
/// </summary> /// </summary>
@@ -70,15 +67,16 @@ namespace DiscImageChef.Server.Controllers
[HttpPost] [HttpPost]
public async Task<IActionResult> UploadStats() public async Task<IActionResult> UploadStats()
{ {
ContentResult response = new ContentResult {StatusCode = (int)HttpStatusCode.OK, ContentType = "text/plain"}; var response = new ContentResult {StatusCode = (int) HttpStatusCode.OK, ContentType = "text/plain"};
try try
{ {
Stats newStats = new Stats(); var newStats = new Stats();
HttpRequest request = HttpContext.Request; var request = HttpContext.Request;
XmlSerializer xs = new XmlSerializer(newStats.GetType()); var xs = new XmlSerializer(newStats.GetType());
newStats = (Stats) xs.Deserialize(new StringReader(await new StreamReader(request.Body).ReadToEndAsync())); newStats = (Stats) xs.Deserialize(
new StringReader(await new StreamReader(request.Body).ReadToEndAsync()));
if (newStats == null) if (newStats == null)
{ {
@@ -109,15 +107,15 @@ namespace DiscImageChef.Server.Controllers
[HttpPost] [HttpPost]
public async Task<IActionResult> UploadStatsV2() public async Task<IActionResult> UploadStatsV2()
{ {
ContentResult response = new ContentResult {StatusCode = (int)HttpStatusCode.OK, ContentType = "text/plain"}; var response = new ContentResult {StatusCode = (int) HttpStatusCode.OK, ContentType = "text/plain"};
try try
{ {
HttpRequest request = HttpContext.Request; var request = HttpContext.Request;
StreamReader sr = new StreamReader(request.Body); var sr = new StreamReader(request.Body);
var statsString = await sr.ReadToEndAsync(); var statsString = await sr.ReadToEndAsync();
StatsDto newstats = JsonConvert.DeserializeObject<StatsDto>(statsString); var newstats = JsonConvert.DeserializeObject<StatsDto>(statsString);
if (newstats == null) if (newstats == null)
{ {
@@ -126,63 +124,64 @@ namespace DiscImageChef.Server.Controllers
} }
if (newstats.Commands != null) if (newstats.Commands != null)
foreach(NameValueStats nvs in newstats.Commands) foreach (var nvs in newstats.Commands)
{ {
Command existing = _ctx.Commands.FirstOrDefault(c => c.Name == nvs.name); var existing = _ctx.Commands.FirstOrDefault(c => c.Name == nvs.name);
if (existing == null) _ctx.Commands.Add(new Command {Name = nvs.name, Count = nvs.Value}); if (existing == null) _ctx.Commands.Add(new Command {Name = nvs.name, Count = nvs.Value});
else existing.Count += nvs.Value; else existing.Count += nvs.Value;
} }
if (newstats.Versions != null) if (newstats.Versions != null)
foreach(NameValueStats nvs in newstats.Versions) foreach (var nvs in newstats.Versions)
{ {
Version existing = _ctx.Versions.FirstOrDefault(c => c.Value == nvs.name); var existing = _ctx.Versions.FirstOrDefault(c => c.Value == nvs.name);
if (existing == null) _ctx.Versions.Add(new Version {Value = nvs.name, Count = nvs.Value}); if (existing == null) _ctx.Versions.Add(new Version {Value = nvs.name, Count = nvs.Value});
else existing.Count += nvs.Value; else existing.Count += nvs.Value;
} }
if (newstats.Filesystems != null) if (newstats.Filesystems != null)
foreach(NameValueStats nvs in newstats.Filesystems) foreach (var nvs in newstats.Filesystems)
{ {
Filesystem existing = _ctx.Filesystems.FirstOrDefault(c => c.Name == nvs.name); var existing = _ctx.Filesystems.FirstOrDefault(c => c.Name == nvs.name);
if (existing == null) _ctx.Filesystems.Add(new Filesystem {Name = nvs.name, Count = nvs.Value}); if (existing == null) _ctx.Filesystems.Add(new Filesystem {Name = nvs.name, Count = nvs.Value});
else existing.Count += nvs.Value; else existing.Count += nvs.Value;
} }
if (newstats.Partitions != null) if (newstats.Partitions != null)
foreach(NameValueStats nvs in newstats.Partitions) foreach (var nvs in newstats.Partitions)
{ {
Partition existing = _ctx.Partitions.FirstOrDefault(c => c.Name == nvs.name); var existing = _ctx.Partitions.FirstOrDefault(c => c.Name == nvs.name);
if (existing == null) _ctx.Partitions.Add(new Partition {Name = nvs.name, Count = nvs.Value}); if (existing == null) _ctx.Partitions.Add(new Partition {Name = nvs.name, Count = nvs.Value});
else existing.Count += nvs.Value; else existing.Count += nvs.Value;
} }
if (newstats.MediaFormats != null) if (newstats.MediaFormats != null)
foreach(NameValueStats nvs in newstats.MediaFormats) foreach (var nvs in newstats.MediaFormats)
{ {
MediaFormat existing = _ctx.MediaFormats.FirstOrDefault(c => c.Name == nvs.name); var existing = _ctx.MediaFormats.FirstOrDefault(c => c.Name == nvs.name);
if(existing == null) _ctx.MediaFormats.Add(new MediaFormat {Name = nvs.name, Count = nvs.Value}); if (existing == null)
_ctx.MediaFormats.Add(new MediaFormat {Name = nvs.name, Count = nvs.Value});
else existing.Count += nvs.Value; else existing.Count += nvs.Value;
} }
if (newstats.Filters != null) if (newstats.Filters != null)
foreach(NameValueStats nvs in newstats.Filters) foreach (var nvs in newstats.Filters)
{ {
Filter existing = _ctx.Filters.FirstOrDefault(c => c.Name == nvs.name); var existing = _ctx.Filters.FirstOrDefault(c => c.Name == nvs.name);
if (existing == null) _ctx.Filters.Add(new Filter {Name = nvs.name, Count = nvs.Value}); if (existing == null) _ctx.Filters.Add(new Filter {Name = nvs.name, Count = nvs.Value});
else existing.Count += nvs.Value; else existing.Count += nvs.Value;
} }
if (newstats.OperatingSystems != null) if (newstats.OperatingSystems != null)
foreach(OsStats operatingSystem in newstats.OperatingSystems) foreach (var operatingSystem in newstats.OperatingSystems)
{ {
OperatingSystem existing = var existing =
_ctx.OperatingSystems.FirstOrDefault(c => c.Name == operatingSystem.name && _ctx.OperatingSystems.FirstOrDefault(c => c.Name == operatingSystem.name &&
c.Version == operatingSystem.version); c.Version == operatingSystem.version);
@@ -197,9 +196,9 @@ namespace DiscImageChef.Server.Controllers
} }
if (newstats.Medias != null) if (newstats.Medias != null)
foreach(MediaStats media in newstats.Medias) foreach (var media in newstats.Medias)
{ {
Media existing = _ctx.Medias.FirstOrDefault(c => c.Type == media.type && c.Real == media.real); var existing = _ctx.Medias.FirstOrDefault(c => c.Type == media.type && c.Real == media.real);
if (existing == null) if (existing == null)
_ctx.Medias.Add(new Media {Type = media.type, Real = media.real, Count = media.Value}); _ctx.Medias.Add(new Media {Type = media.type, Real = media.real, Count = media.Value});
@@ -207,9 +206,9 @@ namespace DiscImageChef.Server.Controllers
} }
if (newstats.Devices != null) if (newstats.Devices != null)
foreach(DeviceStats device in newstats.Devices) foreach (var device in newstats.Devices)
{ {
DeviceStat existing = var existing =
_ctx.DeviceStats.FirstOrDefault(c => c.Bus == device.Bus && _ctx.DeviceStats.FirstOrDefault(c => c.Bus == device.Bus &&
c.Manufacturer == device.Manufacturer && c.Manufacturer == device.Manufacturer &&
c.Model == device.Model && c.Model == device.Model &&
@@ -241,9 +240,9 @@ namespace DiscImageChef.Server.Controllers
} }
} }
FileStream WaitForFile(string fullPath, FileMode mode, FileAccess access, FileShare share) private FileStream WaitForFile(string fullPath, FileMode mode, FileAccess access, FileShare share)
{ {
for(int numTries = 0; numTries < 100; numTries++) for (var numTries = 0; numTries < 100; numTries++)
{ {
FileStream fs = null; FileStream fs = null;
try try

View File

@@ -1,14 +1,14 @@
// <auto-generated /> // <auto-generated />
using System; using System;
using DiscImageChef.Server.Models; using DiscImageChef.Server.Models;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace DiscImageChef.Server.Migrations namespace DiscImageChef.Server.Migrations
{ {
[DbContext(typeof(DicServerContext))] [DbContext(typeof(DicServerContext))]
partial class DicServerContextModelSnapshot : ModelSnapshot internal class DicServerContextModelSnapshot : ModelSnapshot
{ {
protected override void BuildModel(ModelBuilder modelBuilder) protected override void BuildModel(ModelBuilder modelBuilder)
{ {

View File

@@ -32,14 +32,15 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using DiscImageChef.CommonTypes.Metadata; using DiscImageChef.CommonTypes.Metadata;
namespace DiscImageChef.Server.Models namespace DiscImageChef.Server.Models
{ {
public class CompactDiscOffset : CdOffset public class CompactDiscOffset : CdOffset
{ {
public CompactDiscOffset() { } public CompactDiscOffset()
{
}
public CompactDiscOffset(string manufacturer, string model, short offset, int submissions, float agreement) public CompactDiscOffset(string manufacturer, string model, short offset, int submissions, float agreement)
{ {

View File

@@ -36,8 +36,8 @@ namespace DiscImageChef.Server.Models
{ {
public class Command public class Command
{ {
[Key] [Key] public int Id { get; set; }
public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public long Count { get; set; } public long Count { get; set; }
} }

View File

@@ -37,6 +37,14 @@ namespace DiscImageChef.Server.Models
{ {
public sealed class DicServerContext : DbContext public sealed class DicServerContext : DbContext
{ {
public DicServerContext()
{
}
public DicServerContext(DbContextOptions<DicServerContext> options) : base(options)
{
}
public DbSet<Device> Devices { get; set; } public DbSet<Device> Devices { get; set; }
public DbSet<UploadedReport> Reports { get; set; } public DbSet<UploadedReport> Reports { get; set; }
public DbSet<Command> Commands { get; set; } public DbSet<Command> Commands { get; set; }
@@ -52,10 +60,6 @@ namespace DiscImageChef.Server.Models
public DbSet<UsbProduct> UsbProducts { get; set; } public DbSet<UsbProduct> UsbProducts { get; set; }
public DbSet<CompactDiscOffset> CdOffsets { get; set; } public DbSet<CompactDiscOffset> CdOffsets { get; set; }
public DicServerContext() { }
public DicServerContext(DbContextOptions<DicServerContext> options) : base(options) { }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{ {
if (optionsBuilder.IsConfigured) return; if (optionsBuilder.IsConfigured) return;

View File

@@ -32,7 +32,6 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using DiscImageChef.CommonTypes.Metadata; using DiscImageChef.CommonTypes.Metadata;
namespace DiscImageChef.Server.Models namespace DiscImageChef.Server.Models
@@ -66,7 +65,7 @@ namespace DiscImageChef.Server.Models
public DateTime AddedWhen { get; set; } public DateTime AddedWhen { get; set; }
public DateTime? ModifiedWhen { get; set; } public DateTime? ModifiedWhen { get; set; }
public virtual CompactDiscOffset CdOffset { get; set; } public virtual CompactDiscOffset CdOffset { get; set; }
[DefaultValue(0)]
public int OptimalMultipleSectorsRead { get; set; } [DefaultValue(0)] public int OptimalMultipleSectorsRead { get; set; }
} }
} }

View File

@@ -36,8 +36,8 @@ namespace DiscImageChef.Server.Models
{ {
public class DeviceStat public class DeviceStat
{ {
[Key] [Key] public int Id { get; set; }
public int Id { get; set; }
public string Manufacturer { get; set; } public string Manufacturer { get; set; }
public string Model { get; set; } public string Model { get; set; }
public string Revision { get; set; } public string Revision { get; set; }

View File

@@ -1,5 +1,3 @@
using System;
namespace DiscImageChef.Server.Models namespace DiscImageChef.Server.Models
{ {
public class ErrorViewModel public class ErrorViewModel

View File

@@ -36,8 +36,8 @@ namespace DiscImageChef.Server.Models
{ {
public class Filesystem public class Filesystem
{ {
[Key] [Key] public int Id { get; set; }
public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public long Count { get; set; } public long Count { get; set; }
} }

View File

@@ -36,8 +36,8 @@ namespace DiscImageChef.Server.Models
{ {
public class Filter public class Filter
{ {
[Key] [Key] public int Id { get; set; }
public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public long Count { get; set; } public long Count { get; set; }
} }

View File

@@ -36,8 +36,8 @@ namespace DiscImageChef.Server.Models
{ {
public class Media public class Media
{ {
[Key] [Key] public int Id { get; set; }
public int Id { get; set; }
public string Type { get; set; } public string Type { get; set; }
public bool Real { get; set; } public bool Real { get; set; }
public long Count { get; set; } public long Count { get; set; }

View File

@@ -36,8 +36,8 @@ namespace DiscImageChef.Server.Models
{ {
public class MediaFormat public class MediaFormat
{ {
[Key] [Key] public int Id { get; set; }
public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public long Count { get; set; } public long Count { get; set; }
} }

View File

@@ -36,8 +36,8 @@ namespace DiscImageChef.Server.Models
{ {
public class OperatingSystem public class OperatingSystem
{ {
[Key] [Key] public int Id { get; set; }
public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public string Version { get; set; } public string Version { get; set; }
public long Count { get; set; } public long Count { get; set; }

View File

@@ -36,8 +36,8 @@ namespace DiscImageChef.Server.Models
{ {
public class Partition public class Partition
{ {
[Key] [Key] public int Id { get; set; }
public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public long Count { get; set; } public long Count { get; set; }
} }

View File

@@ -32,14 +32,15 @@
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace DiscImageChef.Server.Models namespace DiscImageChef.Server.Models
{ {
public class UsbProduct public class UsbProduct
{ {
public UsbProduct() { } public UsbProduct()
{
}
public UsbProduct(UsbVendor vendor, ushort id, string product) public UsbProduct(UsbVendor vendor, ushort id, string product)
{ {
@@ -49,14 +50,14 @@ namespace DiscImageChef.Server.Models
Vendor = vendor; Vendor = vendor;
} }
[Key] [Key] public int Id { get; set; }
public int Id { get; set; }
public int ProductId { get; set; } public int ProductId { get; set; }
public string Product { get; set; } public string Product { get; set; }
public DateTime AddedWhen { get; set; } public DateTime AddedWhen { get; set; }
public DateTime ModifiedWhen { get; set; } public DateTime ModifiedWhen { get; set; }
public int VendorId { get; set; } public int VendorId { get; set; }
[JsonIgnore]
public virtual UsbVendor Vendor { get; set; } [JsonIgnore] public virtual UsbVendor Vendor { get; set; }
} }
} }

View File

@@ -33,14 +33,15 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace DiscImageChef.Server.Models namespace DiscImageChef.Server.Models
{ {
public class UsbVendor public class UsbVendor
{ {
public UsbVendor() { } public UsbVendor()
{
}
public UsbVendor(ushort id, string vendor) public UsbVendor(ushort id, string vendor)
{ {
@@ -49,14 +50,13 @@ namespace DiscImageChef.Server.Models
AddedWhen = ModifiedWhen = DateTime.UtcNow; AddedWhen = ModifiedWhen = DateTime.UtcNow;
} }
[Key] [Key] public int Id { get; set; }
public int Id { get; set; }
public int VendorId { get; set; } public int VendorId { get; set; }
public string Vendor { get; set; } public string Vendor { get; set; }
public DateTime AddedWhen { get; set; } public DateTime AddedWhen { get; set; }
public DateTime ModifiedWhen { get; set; } public DateTime ModifiedWhen { get; set; }
[JsonIgnore] [JsonIgnore] public virtual ICollection<UsbProduct> Products { get; set; }
public virtual ICollection<UsbProduct> Products { get; set; }
} }
} }

View File

@@ -36,8 +36,8 @@ namespace DiscImageChef.Server.Models
{ {
public class Version public class Version
{ {
[Key] [Key] public int Id { get; set; }
public int Id { get; set; }
public string Value { get; set; } public string Value { get; set; }
public long Count { get; set; } public long Count { get; set; }
} }

View File

@@ -1,14 +1,11 @@
using System; using System;
using System.Collections.Generic; using DiscImageChef.CommonTypes.Interop;
using System.Linq;
using System.Threading.Tasks;
using DiscImageChef.Server.Models; using DiscImageChef.Server.Models;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Version = DiscImageChef.CommonTypes.Interop.Version;
namespace DiscImageChef.Server namespace DiscImageChef.Server
{ {
@@ -71,16 +68,16 @@ namespace DiscImageChef.Server
"\u001b[32m .dWMMM0; dWMMMMXl. \u001b[37;1m Thanks to all contributors, collaborators, translators, donators and friends.\u001b[0m\n" + "\u001b[32m .dWMMM0; dWMMMMXl. \u001b[37;1m Thanks to all contributors, collaborators, translators, donators and friends.\u001b[0m\n" +
"\u001b[32m .......,cd0WMMNk: c0MMMMMWKkolc:clodc'\u001b[0m\n" + "\u001b[32m .......,cd0WMMNk: c0MMMMMWKkolc:clodc'\u001b[0m\n" +
"\u001b[32m .';loddol:'. ':oxkkOkkxoc,.\u001b[0m\n" + "\u001b[32m .';loddol:'. ':oxkkOkkxoc,.\u001b[0m\n" +
"\u001b[0m\n", DiscImageChef.CommonTypes.Interop.Version.GetVersion(), "\u001b[0m\n", Version.GetVersion(),
#if DEBUG #if DEBUG
"DEBUG" "DEBUG"
#else #else
"RELEASE" "RELEASE"
#endif #endif
, DiscImageChef.CommonTypes.Interop.DetectOS.GetPlatformName(DiscImageChef.CommonTypes.Interop.DetectOS.GetRealPlatformID()), , DetectOS.GetPlatformName(DetectOS.GetRealPlatformID()),
Environment.Is64BitOperatingSystem ? 64 : 32, Environment.Is64BitProcess ? 64 : 32, Environment.Is64BitOperatingSystem ? 64 : 32, Environment.Is64BitProcess ? 64 : 32,
DiscImageChef.CommonTypes.Interop.DetectOS.IsMono ? "Mono" : ".NET Core", DetectOS.IsMono ? "Mono" : ".NET Core",
DiscImageChef.CommonTypes.Interop.DetectOS.IsMono ? DiscImageChef.CommonTypes.Interop.Version.GetMonoVersion() : DiscImageChef.CommonTypes.Interop.Version.GetNetCoreVersion()); DetectOS.IsMono ? Version.GetMonoVersion() : Version.GetNetCoreVersion());
var host = CreateHostBuilder(args).Build(); var host = CreateHostBuilder(args).Build();
@@ -98,7 +95,6 @@ namespace DiscImageChef.Server
end = DateTime.Now; end = DateTime.Now;
System.Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m", System.Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m",
(end - start).TotalSeconds); (end - start).TotalSeconds);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -114,8 +110,10 @@ namespace DiscImageChef.Server
host.Run(); host.Run();
} }
public static IHostBuilder CreateHostBuilder(string[] args) => public static IHostBuilder CreateHostBuilder(string[] args)
Host.CreateDefaultBuilder(args) {
return Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); }); .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
} }
} }
}

View File

@@ -1,11 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DiscImageChef.Server.Models; using DiscImageChef.Server.Models;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
@@ -56,8 +51,8 @@ namespace DiscImageChef.Server
app.UseEndpoints(endpoints => app.UseEndpoints(endpoints =>
{ {
endpoints.MapControllerRoute( endpoints.MapControllerRoute(
name: "default", "default",
pattern: "{controller=Home}/{action=Index}/{id?}"); "{controller=Home}/{action=Index}/{id?}");
}); });
} }
} }

View File

@@ -1,9 +1,4 @@
@using System.Collections
@using DiscImageChef.CommonTypes.Metadata @using DiscImageChef.CommonTypes.Metadata
@using DiscImageChef.Server.Models
@using Highsoft.Web.Mvc.Charts
@using Chart = Highsoft.Web.Mvc.Charts.Chart
@using Filter = DiscImageChef.Server.Models.Filter
@{ @{
// /*************************************************************************** // /***************************************************************************
// The Disc Image Chef // The Disc Image Chef
@@ -644,7 +639,9 @@
<text>@Html.ActionLink("Yes", "View", "Report", new {id = device.ReportId}, new {target = "_blank"})</text> <text>@Html.ActionLink("Yes", "View", "Report", new {id = device.ReportId}, new {target = "_blank"})</text>
} }
else else
{ <text>No</text> } {
<text>No</text>
}
</td> </td>
</tr> </tr>
} }