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;
Identify.IdentifyDevice? ataIdentifyNullable = Identify.Decode(ataReport.Identify);
var ataIdentifyNullable = Identify.Decode(ataReport.Identify);
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.FirmwareRevision))
@@ -114,9 +114,9 @@ namespace DiscImageChef.Server
acs4 |= ataIdentify.MajorVersion.HasFlag(Identify.MajorVersionBit.ACS4);
}
int maxatalevel = 0;
int minatalevel = 255;
string tmpString = "";
var maxatalevel = 0;
var minatalevel = 255;
var tmpString = "";
if (ata1)
{
tmpString += "ATA-1 ";
@@ -447,7 +447,8 @@ namespace DiscImageChef.Server
break;
default:
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;
}
@@ -465,7 +466,8 @@ namespace DiscImageChef.Server
break;
default:
ataOneValue
.Add($"Unknown ATAPI DRQ behaviour code {((ushort)ataIdentify.GeneralConfiguration & 0x60) >> 5}");
.Add(
$"Unknown ATAPI DRQ behaviour code {((ushort) ataIdentify.GeneralConfiguration & 0x60) >> 5}");
break;
}
@@ -543,15 +545,18 @@ namespace DiscImageChef.Server
break;
case Identify.SpecificConfigurationEnum.NotRequiresSetIncompleteResponse:
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;
case Identify.SpecificConfigurationEnum.NotRequiresSetCompleteResponse:
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;
default:
ataOneValue
.Add($"Unknown device specific configuration 0x{(ushort)ataIdentify.SpecificConfiguration:X4}");
.Add(
$"Unknown device specific configuration 0x{(ushort) ataIdentify.SpecificConfiguration:X4}");
break;
}
@@ -562,19 +567,23 @@ namespace DiscImageChef.Server
{
case 1:
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;
case 2:
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;
case 3:
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;
default:
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;
}
@@ -609,7 +618,8 @@ namespace DiscImageChef.Server
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");
}
@@ -795,13 +805,16 @@ namespace DiscImageChef.Server
if (!string.IsNullOrEmpty(tmpString)) ataTwoValue.Add("Ultra DMA", tmpString);
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");
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");
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");
if (ataIdentify.MaxQueueDepth != 0)
@@ -869,7 +882,8 @@ namespace DiscImageChef.Server
}
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)
switch (ataIdentify.DeviceFormFactor)
@@ -1268,7 +1282,8 @@ namespace DiscImageChef.Server
if (ataIdentify.DataSetMgmt.HasFlag(Identify.DataSetMgmtBit.Trim)) ataOneValue.Add("TRIM is supported");
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))
{
@@ -1292,7 +1307,10 @@ namespace DiscImageChef.Server
? "Security level is maximum"
: "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))
ataOneValue.Add("Supports enhanced security erase");
@@ -1381,11 +1399,12 @@ namespace DiscImageChef.Server
(ataReport.ReadCapabilities.LogicalAlignment & 0x8000) == 0x0000 &&
(ataReport.ReadCapabilities.LogicalAlignment & 0x4000) == 0x4000)
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)
{
int currentSectors = ataReport.ReadCapabilities.CurrentCHS.Cylinders *
var currentSectors = ataReport.ReadCapabilities.CurrentCHS.Cylinders *
ataReport.ReadCapabilities.CurrentCHS.Heads *
ataReport.ReadCapabilities.CurrentCHS.Sectors;
ataTwoValue.Add("Cylinders",
@@ -1401,7 +1420,7 @@ namespace DiscImageChef.Server
}
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.Sectors;
ataTwoValue.Add("Cylinders",
@@ -1492,7 +1511,10 @@ namespace DiscImageChef.Server
if (ataReport.ReadCapabilities.SupportsSeekLba == true)
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>
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;
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
{
static class ScsiInquiry
internal static class ScsiInquiry
{
/// <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
@@ -45,11 +45,11 @@ namespace DiscImageChef.Server
/// <returns>List of values</returns>
internal static IEnumerable<string> Report(Inquiry.SCSIInquiry? inquiryNullable)
{
List<string> scsiOneValue = new List<string>();
var scsiOneValue = new List<string>();
if (!inquiryNullable.HasValue) return scsiOneValue;
Inquiry.SCSIInquiry inquiry = inquiryNullable.Value;
var inquiry = inquiryNullable.Value;
switch ((PeripheralQualifiers) inquiry.PeripheralQualifier)
{
@@ -171,7 +171,8 @@ namespace DiscImageChef.Server
break;
default:
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;
}
@@ -185,7 +186,8 @@ namespace DiscImageChef.Server
break;
default:
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;
}
@@ -199,7 +201,8 @@ namespace DiscImageChef.Server
break;
default:
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;
}
@@ -270,7 +273,7 @@ namespace DiscImageChef.Server
if (inquiry.VersionDescriptors == null) return scsiOneValue;
foreach(ushort versionDescriptor in inquiry.VersionDescriptors)
foreach (var versionDescriptor in inquiry.VersionDescriptors)
switch (versionDescriptor)
{
case 0xFFFF:
@@ -403,7 +406,8 @@ namespace DiscImageChef.Server
break;
case 0x01DD:
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;
case 0x01DE:
scsiOneValue
@@ -744,7 +748,8 @@ namespace DiscImageChef.Server
break;
case 0x04E7:
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;
case 0x0500:
scsiOneValue.Add("Device complies with ADC-3 (no version claimed)");
@@ -1033,7 +1038,8 @@ namespace DiscImageChef.Server
break;
case 0x0ABC:
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;
case 0x0AC0:
scsiOneValue.Add("Device complies with Fast-20 (no version claimed)");
@@ -1175,7 +1181,8 @@ namespace DiscImageChef.Server
break;
case 0x0C4F:
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;
case 0x0C52:
scsiOneValue.Add("Device complies with SAS-2.1 ISO/IEC 14776-153");
@@ -1203,7 +1210,8 @@ namespace DiscImageChef.Server
break;
case 0x0D3C:
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;
case 0x0D40:
scsiOneValue.Add("Device complies with FC-AL (no version claimed)");
@@ -1334,7 +1342,8 @@ namespace DiscImageChef.Server
break;
case 0x0EA6:
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;
case 0x0EC0:
scsiOneValue.Add("Device complies with FC-SP-2 (no version claimed)");
@@ -1523,7 +1532,8 @@ namespace DiscImageChef.Server
break;
case 0x1623:
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;
case 0x1628:
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)
mmcOneValue.Add($"{ftr.BlocksPerReadableUnit} logical blocks per media writable unit");
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.CanAudioScan) mmcOneValue.Add("Drive supports the SCAN command");
if (ftr.CanEject) mmcOneValue.Add("Drive can eject media");
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.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");
@@ -129,7 +131,8 @@ namespace DiscImageChef.Server
if (ftr.Locked) mmcOneValue.Add("Drive can lock media");
if (ftr.LogicalBlockSize > 0) mmcOneValue.Add($"{ftr.LogicalBlockSize} bytes per logical block");
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)
switch (ftr.PhysicalInterfaceStandard)

View File

@@ -90,9 +90,11 @@ namespace DiscImageChef.Server
: "Drive is not locked, media can be ejected and inserted");
}
else
{
mmcOneValue.Add(mode.LockState
? "Drive is locked, media cannot be ejected, but if empty, can be inserted"
: "Drive is not locked, media can be ejected and inserted");
}
if (mode.Eject) mmcOneValue.Add("Drive can eject media");
@@ -132,10 +134,12 @@ namespace DiscImageChef.Server
{
if (mode.RotationControlSelected == 0)
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)
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
{
@@ -146,7 +150,7 @@ namespace DiscImageChef.Server
}
if (mode.WriteSpeedPerformanceDescriptors != null)
foreach(Modes.ModePage_2A_WriteDescriptor descriptor in
foreach (var descriptor in
mode.WriteSpeedPerformanceDescriptors.Where(descriptor => descriptor.WriteSpeed > 0))
if (descriptor.RotationControl == 0)
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.WriteProtected) scsiOneValue.Add("Device is write protected.");
if (modeSense.BlockDescriptors != null)
foreach(BlockDescriptor descriptor in modeSense.BlockDescriptors)
foreach (var descriptor in modeSense.BlockDescriptors)
if (descriptor.Blocks.HasValue && descriptor.BlockLength.HasValue)
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
scsiOneValue.Add($"Density code {descriptor.Density:X2}h");
@@ -82,7 +83,7 @@ namespace DiscImageChef.Server
if (modeSense.ModePages == null) return;
foreach(ScsiPage page in modeSense.ModePages)
foreach (var page in modeSense.ModePages)
switch (page.page)
{
case 0x00:
@@ -91,7 +92,10 @@ namespace DiscImageChef.Server
modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_00_SFF(page.value));
else
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");
break;
}
@@ -364,14 +368,17 @@ namespace DiscImageChef.Server
}
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");
}
break;
}
Dictionary<string, string> newModePages = new Dictionary<string, string>();
foreach(KeyValuePair<string, string> kvp in modePages)
var newModePages = new Dictionary<string, string>();
foreach (var kvp in modePages)
newModePages.Add(kvp.Key,
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>
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))
{
@@ -52,8 +52,13 @@ namespace DiscImageChef.Server
if (media.MediumType.HasValue) mediaOneValue.Add($"Medium type code: {media.MediumType:X2}h");
}
else if (media.MediumType.HasValue)
{
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))
mediaOneValue.Add($"Medium manufactured by: {media.Manufacturer}");

View File

@@ -41,13 +41,13 @@ namespace DiscImageChef.Server
{
public static void Convert(Stats newStats)
{
DicServerContext ctx = new DicServerContext();
var ctx = new DicServerContext();
if (newStats.Commands != null)
{
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)
ctx.Commands.Add(new Command {Count = newStats.Commands.Analyze, Name = "analyze"});
@@ -56,7 +56,7 @@ namespace DiscImageChef.Server
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)
ctx.Commands.Add(new Command {Count = newStats.Commands.Benchmark, Name = "benchmark"});
@@ -65,7 +65,7 @@ namespace DiscImageChef.Server
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)
ctx.Commands.Add(new Command {Count = newStats.Commands.Checksum, Name = "checksum"});
@@ -74,7 +74,7 @@ namespace DiscImageChef.Server
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)
ctx.Commands.Add(new Command {Count = newStats.Commands.Compare, Name = "compare"});
@@ -83,7 +83,7 @@ namespace DiscImageChef.Server
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)
ctx.Commands.Add(new Command
@@ -95,7 +95,7 @@ namespace DiscImageChef.Server
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)
ctx.Commands.Add(new Command {Count = newStats.Commands.Decode, Name = "decode"});
@@ -104,7 +104,7 @@ namespace DiscImageChef.Server
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)
ctx.Commands.Add(new Command {Count = newStats.Commands.DeviceInfo, Name = "device-info"});
@@ -113,7 +113,7 @@ namespace DiscImageChef.Server
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)
ctx.Commands.Add(new Command {Count = newStats.Commands.DeviceReport, Name = "device-report"});
@@ -122,7 +122,7 @@ namespace DiscImageChef.Server
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)
ctx.Commands.Add(new Command {Count = newStats.Commands.DumpMedia, Name = "dump-media"});
@@ -131,7 +131,7 @@ namespace DiscImageChef.Server
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)
ctx.Commands.Add(new Command {Count = newStats.Commands.Entropy, Name = "entropy"});
@@ -140,7 +140,7 @@ namespace DiscImageChef.Server
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)
ctx.Commands.Add(new Command {Count = newStats.Commands.Formats, Name = "formats"});
@@ -149,7 +149,7 @@ namespace DiscImageChef.Server
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)
ctx.Commands.Add(new Command {Count = newStats.Commands.MediaInfo, Name = "media-info"});
@@ -158,7 +158,7 @@ namespace DiscImageChef.Server
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)
ctx.Commands.Add(new Command {Count = newStats.Commands.MediaScan, Name = "media-scan"});
@@ -167,7 +167,7 @@ namespace DiscImageChef.Server
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)
ctx.Commands.Add(new Command {Count = newStats.Commands.PrintHex, Name = "printhex"});
@@ -176,7 +176,7 @@ namespace DiscImageChef.Server
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)
ctx.Commands.Add(new Command {Count = newStats.Commands.Verify, Name = "verify"});
@@ -185,7 +185,7 @@ namespace DiscImageChef.Server
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"});
else existing.Count += newStats.Commands.Ls;
@@ -193,7 +193,7 @@ namespace DiscImageChef.Server
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)
ctx.Commands.Add(new Command {Count = newStats.Commands.ExtractFiles, Name = "extract-files"});
@@ -202,7 +202,7 @@ namespace DiscImageChef.Server
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)
ctx.Commands.Add(new Command {Count = newStats.Commands.ListDevices, Name = "list-devices"});
@@ -211,7 +211,7 @@ namespace DiscImageChef.Server
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)
ctx.Commands.Add(new Command
@@ -223,7 +223,7 @@ namespace DiscImageChef.Server
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)
ctx.Commands.Add(new Command {Count = newStats.Commands.ConvertImage, Name = "convert-image"});
@@ -232,7 +232,7 @@ namespace DiscImageChef.Server
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)
ctx.Commands.Add(new Command {Count = newStats.Commands.ImageInfo, Name = "image-info"});
@@ -241,12 +241,13 @@ namespace DiscImageChef.Server
}
if (newStats.OperatingSystems != null)
foreach(OsStats operatingSystem in newStats.OperatingSystems)
{
foreach (var operatingSystem in newStats.OperatingSystems)
{
if (string.IsNullOrWhiteSpace(operatingSystem.name) ||
string.IsNullOrWhiteSpace(operatingSystem.version)) continue;
OperatingSystem existing =
var existing =
ctx.OperatingSystems.FirstOrDefault(c => c.Name == operatingSystem.name &&
c.Version == operatingSystem.version);
@@ -259,9 +260,10 @@ namespace DiscImageChef.Server
});
else existing.Count += operatingSystem.Value;
}
}
else
{
OperatingSystem existing =
var existing =
ctx.OperatingSystems.FirstOrDefault(c => c.Name == "Linux" && c.Version == null);
if (existing == null) ctx.OperatingSystems.Add(new OperatingSystem {Count = 1, Name = "Linux"});
@@ -269,69 +271,71 @@ namespace DiscImageChef.Server
}
if (newStats.Versions != null)
foreach(NameValueStats nvs in newStats.Versions)
{
foreach (var nvs in newStats.Versions)
{
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});
else existing.Count += nvs.Value;
}
}
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"});
else existing.Count++;
}
if (newStats.Filesystems != null)
foreach(NameValueStats nvs in newStats.Filesystems)
foreach (var nvs in newStats.Filesystems)
{
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});
else existing.Count += nvs.Value;
}
if (newStats.Partitions != null)
foreach(NameValueStats nvs in newStats.Partitions)
foreach (var nvs in newStats.Partitions)
{
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});
else existing.Count += nvs.Value;
}
if (newStats.MediaImages != null)
foreach(NameValueStats nvs in newStats.MediaImages)
foreach (var nvs in newStats.MediaImages)
{
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});
else existing.Count += nvs.Value;
}
if (newStats.Filters != null)
foreach(NameValueStats nvs in newStats.Filters)
foreach (var nvs in newStats.Filters)
{
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});
else existing.Count += nvs.Value;
}
if (newStats.Devices != null)
foreach(DeviceStats device in newStats.Devices)
foreach (var device in newStats.Devices)
{
if (string.IsNullOrWhiteSpace(device.Model)) continue;
@@ -347,11 +351,11 @@ namespace DiscImageChef.Server
}
if (newStats.Medias != null)
foreach(MediaStats media in newStats.Medias)
foreach (var media in newStats.Medias)
{
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)
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>
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))
{
@@ -53,8 +53,13 @@ namespace DiscImageChef.Server.App_Start
mediaOneValue.Add($"Medium type code: {testedMedia.MediumType:X2}h");
}
else if (testedMedia.MediumType != null)
{
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
? "Drive recognizes this medium."
@@ -79,38 +84,46 @@ namespace DiscImageChef.Server.App_Start
if (testedMedia.Blocks * testedMedia.BlockSize / 1024 / 1024 > 1000000)
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)
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
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)
{
int currentSectors = testedMedia.CurrentCHS.Cylinders * testedMedia.CurrentCHS.Heads *
var currentSectors = testedMedia.CurrentCHS.Cylinders * testedMedia.CurrentCHS.Heads *
testedMedia.CurrentCHS.Sectors;
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($"Sectors per track: {testedMedia.CHS.Sectors} max., {testedMedia.CurrentCHS.Sectors} current");
.Add(
$"Sectors per track: {testedMedia.CHS.Sectors} max., {testedMedia.CurrentCHS.Sectors} current");
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
.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)
{
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($"Heads: {testedMedia.CHS.Heads}");
mediaOneValue.Add($"Sectors per track: {testedMedia.CHS.Sectors}");
mediaOneValue.Add($"Sectors addressable in CHS mode: {currentSectors}");
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)
@@ -119,13 +132,16 @@ namespace DiscImageChef.Server.App_Start
if ((ulong) testedMedia.LBASectors * testedMedia.BlockSize / 1024 / 1024 > 1000000)
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)
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
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)
@@ -134,13 +150,16 @@ namespace DiscImageChef.Server.App_Start
if (testedMedia.LBA48Sectors * testedMedia.BlockSize / 1024 / 1024 > 1000000)
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)
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
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 &&
@@ -155,7 +174,8 @@ namespace DiscImageChef.Server.App_Start
(testedMedia.LogicalAlignment & 0x8000) == 0x0000 &&
(testedMedia.LogicalAlignment & 0x4000) == 0x4000)
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)
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");
if (testedMedia.SupportsReadCdRaw == true)
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)
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)
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");
if (testedMedia.CanReadFirstTrackPreGap == true)
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)
mediaOneValue.Add("Device can read the Lead-Out from this medium");
if (testedMedia.CanReadMediaID == true)

View File

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

View File

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

View File

@@ -44,11 +44,7 @@ using DiscImageChef.Server.Models;
using Highsoft.Web.Mvc.Charts;
using Microsoft.AspNetCore.Hosting;
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 Version = DiscImageChef.Server.Models.Version;
namespace DiscImageChef.Server.Controllers
{
@@ -57,13 +53,13 @@ namespace DiscImageChef.Server.Controllers
/// </summary>
public class StatsController : Controller
{
DicServerContext ctx;
List<DeviceItem> devices;
List<NameValueStats> operatingSystems;
List<MediaItem> realMedia;
List<NameValueStats> versions;
List<MediaItem> virtualMedia;
private IWebHostEnvironment _environment;
private readonly IWebHostEnvironment _environment;
private readonly DicServerContext ctx;
private List<DeviceItem> devices;
private List<NameValueStats> operatingSystems;
private List<MediaItem> realMedia;
private List<NameValueStats> versions;
private List<MediaItem> virtualMedia;
public StatsController(IWebHostEnvironment environment, DicServerContext context)
{
@@ -83,11 +79,13 @@ namespace DiscImageChef.Server.Controllers
"Statistics", "Statistics.xml")))
try
{
Stats statistics = new Stats();
var statistics = new Stats();
XmlSerializer xs = new XmlSerializer(statistics.GetType());
FileStream fs =
WaitForFile(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), "Statistics", "Statistics.xml"),
var xs = new XmlSerializer(statistics.GetType());
var fs =
WaitForFile(
Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"Statistics", "Statistics.xml"),
FileMode.Open, FileAccess.Read, FileShare.Read);
statistics = (Stats) xs.Deserialize(fs);
fs.Close();
@@ -106,7 +104,7 @@ namespace DiscImageChef.Server.Controllers
if (ctx.OperatingSystems.Any())
{
operatingSystems = new List<NameValueStats>();
foreach(OperatingSystem nvs in ctx.OperatingSystems)
foreach (var nvs in ctx.OperatingSystems)
operatingSystems.Add(new NameValueStats
{
name =
@@ -116,10 +114,10 @@ namespace DiscImageChef.Server.Controllers
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);
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);
@@ -136,11 +134,11 @@ namespace DiscImageChef.Server.Controllers
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())
.Sum(o => o.Count);
foreach(OperatingSystem version in
foreach (var version in
ctx.OperatingSystems.Where(o => o.Name == PlatformID.Linux.ToString()))
linuxPieData.Add(new PieSeriesData
{
@@ -151,11 +149,11 @@ namespace DiscImageChef.Server.Controllers
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())
.Sum(o => o.Count);
foreach(OperatingSystem version in
foreach (var version in
ctx.OperatingSystems.Where(o => o.Name == PlatformID.MacOSX.ToString()))
macosPieData.Add(new PieSeriesData
{
@@ -166,11 +164,11 @@ namespace DiscImageChef.Server.Controllers
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())
.Sum(o => o.Count);
foreach(OperatingSystem version in
foreach (var version in
ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString()))
windowsPieData.Add(new PieSeriesData
{
@@ -185,7 +183,7 @@ namespace DiscImageChef.Server.Controllers
if (ctx.Versions.Any())
{
versions = new List<NameValueStats>();
foreach(Version nvs in ctx.Versions)
foreach (var nvs in ctx.Versions)
versions.Add(new NameValueStats
{
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();
List<PieSeriesData> filtersPieData = new List<PieSeriesData>();
var filtersPieData = new List<PieSeriesData>();
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
{
Name = filter.Name,
@@ -249,12 +247,12 @@ namespace DiscImageChef.Server.Controllers
{
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 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;
@@ -280,12 +278,12 @@ namespace DiscImageChef.Server.Controllers
{
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 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;
@@ -312,12 +310,12 @@ namespace DiscImageChef.Server.Controllers
{
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 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;
@@ -344,12 +342,13 @@ namespace DiscImageChef.Server.Controllers
{
realMedia = new List<MediaItem>();
virtualMedia = new List<MediaItem>();
foreach(Media nvs in ctx.Medias)
foreach (var nvs in ctx.Medias)
try
{
MediaType
.MediaTypeToString((CommonTypes.MediaType)Enum.Parse(typeof(CommonTypes.MediaType), nvs.Type),
out string type, out string subtype);
.MediaTypeToString(
(CommonTypes.MediaType) Enum.Parse(typeof(CommonTypes.MediaType), nvs.Type),
out var type, out var subtype);
if (nvs.Real)
realMedia.Add(new MediaItem {Type = type, SubType = subtype, Count = nvs.Count});
@@ -367,12 +366,12 @@ namespace DiscImageChef.Server.Controllers
ViewBag.repRealMedia =
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 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;
@@ -400,12 +399,12 @@ namespace DiscImageChef.Server.Controllers
ViewBag.repVirtualMedia =
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 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;
@@ -435,7 +434,7 @@ namespace DiscImageChef.Server.Controllers
if (ctx.DeviceStats.Any())
{
devices = new List<DeviceItem>();
foreach(DeviceStat device in ctx.DeviceStats.ToList())
foreach (var device in ctx.DeviceStats.ToList())
{
string xmlFile;
if (!string.IsNullOrWhiteSpace(device.Manufacturer) &&
@@ -445,7 +444,8 @@ namespace DiscImageChef.Server.Controllers
else if (!string.IsNullOrWhiteSpace(device.Manufacturer) &&
!string.IsNullOrWhiteSpace(device.Model))
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";
else xmlFile = device.Model + ".xml";
@@ -453,22 +453,25 @@ namespace DiscImageChef.Server.Controllers
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());
FileStream fs =
WaitForFile(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), "Reports", xmlFile),
var xs = new XmlSerializer(deviceReport.GetType());
var fs =
WaitForFile(
Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
"Reports", xmlFile),
FileMode.Open, FileAccess.Read, FileShare.Read);
deviceReport = (DeviceReport) xs.Deserialize(fs);
fs.Close();
DeviceReportV2 deviceReportV2 = new DeviceReportV2(deviceReport);
var deviceReportV2 = new DeviceReportV2(deviceReport);
device.Report = ctx.Devices.Add(new Device(deviceReportV2)).Entity;
ctx.SaveChanges();
System.IO.File
.Delete(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(),
.Delete(Path.Combine(
_environment.ContentRootPath ?? throw new InvalidOperationException(),
"Reports", xmlFile));
}
@@ -498,10 +501,13 @@ namespace DiscImageChef.Server.Controllers
ViewData["devicesManufacturerPieData"] =
(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()
let manufacturerCount = devices.Count(d => d.Manufacturer?.ToLowerInvariant() == manufacturer)
select new PieSeriesData {Name = manufacturer, Y = manufacturerCount / (double)devices.Count})
let manufacturerCount =
devices.Count(d => d.Manufacturer?.ToLowerInvariant() == manufacturer)
select new PieSeriesData
{Name = manufacturer, Y = manufacturerCount / (double) devices.Count})
.ToList();
}
}
@@ -516,9 +522,9 @@ namespace DiscImageChef.Server.Controllers
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;
try

View File

@@ -30,13 +30,10 @@
// Copyright © 2011-2019 Natalia Portillo
// ****************************************************************************/
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using DiscImageChef.CommonTypes.Metadata;
using DiscImageChef.Dto;
using DiscImageChef.Server.Models;
@@ -48,7 +45,7 @@ namespace DiscImageChef.Server.Controllers
{
public class UpdateController : Controller
{
private DicServerContext _ctx;
private readonly DicServerContext _ctx;
public UpdateController(DicServerContext ctx)
{
@@ -63,15 +60,15 @@ namespace DiscImageChef.Server.Controllers
[HttpGet]
public ActionResult Update(long timestamp)
{
SyncDto sync = new SyncDto();
DateTime lastSync = DateHandlers.UnixToDateTime(timestamp);
var sync = new SyncDto();
var lastSync = DateHandlers.UnixToDateTime(timestamp);
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.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
{
Id = product.Id,
@@ -81,17 +78,20 @@ namespace DiscImageChef.Server.Controllers
});
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.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
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));
JsonSerializer js = JsonSerializer.Create();
StringWriter sw = new StringWriter();
var js = JsonSerializer.Create();
var sw = new StringWriter();
js.Serialize(sw, sync);
return new ContentResult

View File

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

View File

@@ -35,16 +35,12 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using System.Xml.Serialization;
using DiscImageChef.CommonTypes.Metadata;
using DiscImageChef.Server.Models;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using OperatingSystem = DiscImageChef.Server.Models.OperatingSystem;
@@ -54,7 +50,7 @@ namespace DiscImageChef.Server.Controllers
{
public class UploadStatsController : Controller
{
DicServerContext _ctx;
private readonly DicServerContext _ctx;
private IWebHostEnvironment _environment;
public UploadStatsController(IWebHostEnvironment environment, DicServerContext ctx)
@@ -62,6 +58,7 @@ namespace DiscImageChef.Server.Controllers
_environment = environment;
_ctx = ctx;
}
/// <summary>
/// Receives statistics from DiscImageChef.Core, processes them and adds them to a server-side global statistics XML
/// </summary>
@@ -70,15 +67,16 @@ namespace DiscImageChef.Server.Controllers
[HttpPost]
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
{
Stats newStats = new Stats();
HttpRequest request = HttpContext.Request;
var newStats = new Stats();
var request = HttpContext.Request;
XmlSerializer xs = new XmlSerializer(newStats.GetType());
newStats = (Stats) xs.Deserialize(new StringReader(await new StreamReader(request.Body).ReadToEndAsync()));
var xs = new XmlSerializer(newStats.GetType());
newStats = (Stats) xs.Deserialize(
new StringReader(await new StreamReader(request.Body).ReadToEndAsync()));
if (newStats == null)
{
@@ -109,15 +107,15 @@ namespace DiscImageChef.Server.Controllers
[HttpPost]
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
{
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();
StatsDto newstats = JsonConvert.DeserializeObject<StatsDto>(statsString);
var newstats = JsonConvert.DeserializeObject<StatsDto>(statsString);
if (newstats == null)
{
@@ -126,63 +124,64 @@ namespace DiscImageChef.Server.Controllers
}
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});
else existing.Count += nvs.Value;
}
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});
else existing.Count += nvs.Value;
}
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});
else existing.Count += nvs.Value;
}
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});
else existing.Count += nvs.Value;
}
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;
}
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});
else existing.Count += nvs.Value;
}
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 &&
c.Version == operatingSystem.version);
@@ -197,9 +196,9 @@ namespace DiscImageChef.Server.Controllers
}
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)
_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)
foreach(DeviceStats device in newstats.Devices)
foreach (var device in newstats.Devices)
{
DeviceStat existing =
var existing =
_ctx.DeviceStats.FirstOrDefault(c => c.Bus == device.Bus &&
c.Manufacturer == device.Manufacturer &&
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;
try

View File

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

View File

@@ -32,14 +32,15 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using DiscImageChef.CommonTypes.Metadata;
namespace DiscImageChef.Server.Models
{
public class CompactDiscOffset : CdOffset
{
public CompactDiscOffset() { }
public CompactDiscOffset()
{
}
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
{
[Key]
public int Id { get; set; }
[Key] public int Id { get; set; }
public string Name { get; set; }
public long Count { get; set; }
}

View File

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

View File

@@ -32,7 +32,6 @@
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using DiscImageChef.CommonTypes.Metadata;
namespace DiscImageChef.Server.Models
@@ -66,7 +65,7 @@ namespace DiscImageChef.Server.Models
public DateTime AddedWhen { get; set; }
public DateTime? ModifiedWhen { 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
{
[Key]
public int Id { get; set; }
[Key] public int Id { get; set; }
public string Manufacturer { get; set; }
public string Model { get; set; }
public string Revision { get; set; }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,14 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DiscImageChef.CommonTypes.Interop;
using DiscImageChef.Server.Models;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Version = DiscImageChef.CommonTypes.Interop.Version;
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 .......,cd0WMMNk: c0MMMMMWKkolc:clodc'\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
"DEBUG"
#else
"RELEASE"
#endif
, DiscImageChef.CommonTypes.Interop.DetectOS.GetPlatformName(DiscImageChef.CommonTypes.Interop.DetectOS.GetRealPlatformID()),
, DetectOS.GetPlatformName(DetectOS.GetRealPlatformID()),
Environment.Is64BitOperatingSystem ? 64 : 32, Environment.Is64BitProcess ? 64 : 32,
DiscImageChef.CommonTypes.Interop.DetectOS.IsMono ? "Mono" : ".NET Core",
DiscImageChef.CommonTypes.Interop.DetectOS.IsMono ? DiscImageChef.CommonTypes.Interop.Version.GetMonoVersion() : DiscImageChef.CommonTypes.Interop.Version.GetNetCoreVersion());
DetectOS.IsMono ? "Mono" : ".NET Core",
DetectOS.IsMono ? Version.GetMonoVersion() : Version.GetNetCoreVersion());
var host = CreateHostBuilder(args).Build();
@@ -98,7 +95,6 @@ namespace DiscImageChef.Server
end = DateTime.Now;
System.Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m",
(end - start).TotalSeconds);
}
catch (Exception ex)
{
@@ -114,8 +110,10 @@ namespace DiscImageChef.Server
host.Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
public static IHostBuilder CreateHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
.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 Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
@@ -56,8 +51,8 @@ namespace DiscImageChef.Server
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
"default",
"{controller=Home}/{action=Index}/{id?}");
});
}
}

View File

@@ -1,9 +1,4 @@
@using System.Collections
@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
@@ -644,7 +639,9 @@
<text>@Html.ActionLink("Yes", "View", "Report", new {id = device.ReportId}, new {target = "_blank"})</text>
}
else
{ <text>No</text> }
{
<text>No</text>
}
</td>
</tr>
}