General refactor and cleanup.

This commit is contained in:
2024-04-30 13:42:23 +01:00
parent b0131fbd5c
commit 7e04bb70a7
17 changed files with 162 additions and 88 deletions

View File

@@ -76,7 +76,8 @@ public sealed class AtasController : Controller
return View(new IdHashModelForView
{
List = dups, Json = JsonConvert.SerializeObject(dups)
List = dups,
Json = JsonConvert.SerializeObject(dups)
});
}
@@ -149,7 +150,8 @@ public sealed class AtasController : Controller
return RedirectToAction(nameof(Compare),
new
{
id = masterId, rightId = slaveId
id = masterId,
rightId = slaveId
});
}
@@ -160,7 +162,8 @@ public sealed class AtasController : Controller
return RedirectToAction(nameof(Compare),
new
{
id = masterId, rightId = slaveId
id = masterId,
rightId = slaveId
});
}
@@ -193,7 +196,8 @@ public sealed class AtasController : Controller
{
var model = new CompareModel
{
LeftId = id, RightId = rightId
LeftId = id,
RightId = rightId
};
Ata left = _context.Ata.FirstOrDefault(l => l.Id == id);

View File

@@ -21,18 +21,23 @@ public sealed class ChsController : Controller
{
var dups = _context.Chs.GroupBy(x => new
{
x.Cylinders, x.Heads, x.Sectors
x.Cylinders,
x.Heads,
x.Sectors
})
.Where(x => x.Count() > 1)
.Select(x => new ChsModel
{
Cylinders = x.Key.Cylinders, Heads = x.Key.Heads, Sectors = x.Key.Sectors
Cylinders = x.Key.Cylinders,
Heads = x.Key.Heads,
Sectors = x.Key.Sectors
})
.ToList();
return View(new ChsModelForView
{
List = dups, Json = JsonConvert.SerializeObject(dups)
List = dups,
Json = JsonConvert.SerializeObject(dups)
});
}

View File

@@ -112,7 +112,8 @@ public sealed class FireWiresController : Controller
return View(new FireWireModelForView
{
List = dups, Json = JsonConvert.SerializeObject(dups)
List = dups,
Json = JsonConvert.SerializeObject(dups)
});
}

View File

@@ -61,7 +61,8 @@ public sealed class GdRomSwapDiscCapabilitiesController : Controller
var model = new TestedMediaDataModel
{
TestedMediaId = id, DataName = data
TestedMediaId = id,
DataName = data
};
byte[] buffer;

View File

@@ -85,7 +85,8 @@ public sealed class ScsisController : Controller
return View(new IdHashModelForView
{
List = dups, Json = JsonConvert.SerializeObject(dups)
List = dups,
Json = JsonConvert.SerializeObject(dups)
});
}
@@ -147,7 +148,8 @@ public sealed class ScsisController : Controller
{
var model = new CompareModel
{
LeftId = id, RightId = rightId
LeftId = id,
RightId = rightId
};
Scsi left = _context.Scsi.FirstOrDefault(l => l.Id == id);
@@ -311,7 +313,8 @@ public sealed class ScsisController : Controller
return RedirectToAction(nameof(Compare),
new
{
id = masterId, rightId = slaveId
id = masterId,
rightId = slaveId
});
}
@@ -322,7 +325,8 @@ public sealed class ScsisController : Controller
return RedirectToAction(nameof(Compare),
new
{
id = masterId, rightId = slaveId
id = masterId,
rightId = slaveId
});
}

View File

@@ -46,7 +46,9 @@ public sealed class SscsController : Controller
{
var dups = _context.Ssc.GroupBy(x => new
{
x.BlockSizeGranularity, x.MaxBlockLength, x.MinBlockLength
x.BlockSizeGranularity,
x.MaxBlockLength,
x.MinBlockLength
})
.Where(x => x.Count() > 1)
.Select(x => new SscModel
@@ -59,7 +61,8 @@ public sealed class SscsController : Controller
return View(new SscModelForView
{
List = dups, Json = JsonConvert.SerializeObject(dups)
List = dups,
Json = JsonConvert.SerializeObject(dups)
});
}

View File

@@ -128,7 +128,8 @@ public sealed class TestedMediasController : Controller
var model = new TestedMediaDataModel
{
TestedMediaId = id, DataName = data
TestedMediaId = id,
DataName = data
};
byte[] buffer;

View File

@@ -30,7 +30,8 @@ public sealed class UsbVendorsController : Controller
.ThenBy(p => p.ProductId)
.Select(p => new UsbProductModel
{
ProductId = p.ProductId, ProductName = p.Product
ProductId = p.ProductId,
ProductName = p.Product
})
.ToList()
});

View File

@@ -59,7 +59,10 @@ public sealed class UsbsController : Controller
{
var dups = _context.Usb.GroupBy(x => new
{
x.Manufacturer, x.Product, x.VendorID, x.ProductID
x.Manufacturer,
x.Product,
x.VendorID,
x.ProductID
})
.Where(x => x.Count() > 1)
.Select(x => new UsbModel
@@ -73,7 +76,8 @@ public sealed class UsbsController : Controller
return View(new UsbModelForView
{
List = dups, Json = JsonConvert.SerializeObject(dups)
List = dups,
Json = JsonConvert.SerializeObject(dups)
});
}
@@ -112,9 +116,8 @@ public sealed class UsbsController : Controller
.ToArray())
{
if(slave.Descriptors != null && master.Descriptors != null)
{
if(!master.Descriptors.SequenceEqual(slave.Descriptors)) continue;
}
if(!master.Descriptors.SequenceEqual(slave.Descriptors))
continue;
foreach(Device device in _context.Devices.Where(d => d.USB.Id == slave.Id)) device.USB = master;

View File

@@ -121,7 +121,8 @@ public sealed class StatsController : Controller
{
versions.Add(new NameValueStats
{
name = nvs.Name == "previous" ? "Previous than 3.4.99.0" : nvs.Name, Value = nvs.Count
name = nvs.Name == "previous" ? "Previous than 3.4.99.0" : nvs.Name,
Value = nvs.Count
});
}
@@ -157,14 +158,18 @@ public sealed class StatsController : Controller
{
realMedia.Add(new MediaItem
{
Type = mediaType.type, SubType = mediaType.subType, Count = nvs.Count
Type = mediaType.type,
SubType = mediaType.subType,
Count = nvs.Count
});
}
else
{
virtualMedia.Add(new MediaItem
{
Type = mediaType.type, SubType = mediaType.subType, Count = nvs.Count
Type = mediaType.type,
SubType = mediaType.subType,
Count = nvs.Count
});
}
}
@@ -174,14 +179,18 @@ public sealed class StatsController : Controller
{
realMedia.Add(new MediaItem
{
Type = nvs.Type, SubType = null, Count = nvs.Count
Type = nvs.Type,
SubType = null,
Count = nvs.Count
});
}
else
{
virtualMedia.Add(new MediaItem
{
Type = nvs.Type, SubType = null, Count = nvs.Count
Type = nvs.Type,
SubType = null,
Count = nvs.Count
});
}
}
@@ -309,7 +318,8 @@ public sealed class StatsController : Controller
x => x.Count)
.Select(g => new
{
g.Key.Name, Count = g.Sum()
g.Key.Name,
Count = g.Sum()
});
var result = new string[2][];
@@ -584,11 +594,13 @@ public sealed class StatsController : Controller
.Distinct()
.Select(deviceBus => new
{
deviceBus, deviceBusCount = _ctx.DeviceStats.Count(d => d.Bus == deviceBus)
deviceBus,
deviceBusCount = _ctx.DeviceStats.Count(d => d.Bus == deviceBus)
})
.Select(t => new
{
Name = t.deviceBus, Count = t.deviceBusCount
Name = t.deviceBus,
Count = t.deviceBusCount
})
.ToList();
@@ -621,7 +633,8 @@ public sealed class StatsController : Controller
})
.Select(t => new
{
Name = t.manufacturer, Count = t.manufacturerCount
Name = t.manufacturer,
Count = t.manufacturerCount
})
.ToList();

View File

@@ -60,7 +60,8 @@ public sealed class UpdateController : Controller
{
sync.UsbVendors.Add(new UsbVendorDto
{
VendorId = vendor.VendorId, Vendor = vendor.Vendor
VendorId = vendor.VendorId,
Vendor = vendor.Vendor
});
}
@@ -128,7 +129,9 @@ public sealed class UpdateController : Controller
return new ContentResult
{
StatusCode = (int)HttpStatusCode.OK, Content = sw.ToString(), ContentType = "application/json"
StatusCode = (int)HttpStatusCode.OK,
Content = sw.ToString(),
ContentType = "application/json"
};
}
}

View File

@@ -64,7 +64,8 @@ public sealed class UploadReportController : Controller
{
var response = new ContentResult
{
StatusCode = (int)HttpStatusCode.OK, ContentType = "text/plain"
StatusCode = (int)HttpStatusCode.OK,
ContentType = "text/plain"
};
try
@@ -228,7 +229,8 @@ public sealed class UploadReportController : Controller
{
var response = new ContentResult
{
StatusCode = (int)HttpStatusCode.OK, ContentType = "text/plain"
StatusCode = (int)HttpStatusCode.OK,
ContentType = "text/plain"
};
try

View File

@@ -57,7 +57,8 @@ public sealed class UploadStatsController : Controller
{
var response = new ContentResult
{
StatusCode = (int)HttpStatusCode.OK, ContentType = "text/plain"
StatusCode = (int)HttpStatusCode.OK,
ContentType = "text/plain"
};
try
@@ -101,7 +102,8 @@ public sealed class UploadStatsController : Controller
{
var response = new ContentResult
{
StatusCode = (int)HttpStatusCode.OK, ContentType = "text/plain"
StatusCode = (int)HttpStatusCode.OK,
ContentType = "text/plain"
};
try
@@ -131,7 +133,8 @@ public sealed class UploadStatsController : Controller
{
await _ctx.Commands.AddAsync(new Command
{
Name = nvs.name, Count = nvs.Value
Name = nvs.name,
Count = nvs.Value
});
}
else
@@ -149,7 +152,8 @@ public sealed class UploadStatsController : Controller
{
await _ctx.Versions.AddAsync(new Version
{
Name = nvs.name, Count = nvs.Value
Name = nvs.name,
Count = nvs.Value
});
}
else
@@ -167,7 +171,8 @@ public sealed class UploadStatsController : Controller
{
await _ctx.Filesystems.AddAsync(new Filesystem
{
Name = nvs.name, Count = nvs.Value
Name = nvs.name,
Count = nvs.Value
});
}
else
@@ -185,7 +190,8 @@ public sealed class UploadStatsController : Controller
{
await _ctx.Partitions.AddAsync(new Partition
{
Name = nvs.name, Count = nvs.Value
Name = nvs.name,
Count = nvs.Value
});
}
else
@@ -203,7 +209,8 @@ public sealed class UploadStatsController : Controller
{
await _ctx.MediaFormats.AddAsync(new MediaFormat
{
Name = nvs.name, Count = nvs.Value
Name = nvs.name,
Count = nvs.Value
});
}
else
@@ -221,7 +228,8 @@ public sealed class UploadStatsController : Controller
{
await _ctx.Filters.AddAsync(new Filter
{
Name = nvs.name, Count = nvs.Value
Name = nvs.name,
Count = nvs.Value
});
}
else
@@ -261,7 +269,9 @@ public sealed class UploadStatsController : Controller
{
await _ctx.Medias.AddAsync(new Media
{
Type = media.type, Real = media.real, Count = media.Value
Type = media.type,
Real = media.real,
Count = media.Value
});
}
else
@@ -302,7 +312,9 @@ public sealed class UploadStatsController : Controller
{
await _ctx.RemoteApplications.AddAsync(new RemoteApplication
{
Name = application.name, Version = application.version, Count = application.Value
Name = application.name,
Version = application.version,
Count = application.Value
});
}
else
@@ -320,7 +332,8 @@ public sealed class UploadStatsController : Controller
{
await _ctx.RemoteArchitectures.AddAsync(new RemoteArchitecture
{
Name = nvs.name, Count = nvs.Value
Name = nvs.name,
Count = nvs.Value
});
}
else

View File

@@ -1065,9 +1065,7 @@ public static class Ata
}
if(ataIdentify.InterseekDelay != 0x0000 && ataIdentify.InterseekDelay != 0xFFFF)
{
ataOneValue.Add($"{ataIdentify.InterseekDelay} microseconds of interseek delay for ISO-7779 acoustic testing");
}
if((ushort)ataIdentify.DeviceFormFactor != 0x0000 && (ushort)ataIdentify.DeviceFormFactor != 0xFFFF)
{
@@ -1669,9 +1667,7 @@ public static class Ata
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");
}
if(ataIdentify.SecurityStatus.HasFlag(Identify.SecurityStatusBit.Supported))
{
@@ -1706,9 +1702,7 @@ public static class Ata
ataOneValue.Add($"{ataIdentify.SecurityEraseTime * 2} minutes to complete secure erase");
if(ataIdentify.SecurityStatus.HasFlag(Identify.SecurityStatusBit.Enhanced))
{
ataOneValue.Add($"{ataIdentify.EnhancedSecurityEraseTime * 2} minutes to complete enhanced secure erase");
}
ataOneValue.Add($"Master password revision code: {ataIdentify.MasterPasswordRevisionCode}");
}

View File

@@ -189,9 +189,7 @@ public static class ScsiMmcFeatures
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");
}
if(ftr.PhysicalInterfaceStandard.HasValue)
{

View File

@@ -153,13 +153,9 @@ public static class ScsiMmcMode
if(mode.CurrentWriteSpeedSelected > 0)
{
if(mode.RotationControlSelected == 0)
{
mmcOneValue.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");
}
}
else
{

View File

@@ -50,7 +50,8 @@ public static class StatsConverter
{
ctx.Commands.Add(new Command
{
Count = newStats.Commands.Analyze, Name = "fs-info"
Count = newStats.Commands.Analyze,
Name = "fs-info"
});
}
else
@@ -65,7 +66,8 @@ public static class StatsConverter
{
ctx.Commands.Add(new Command
{
Count = newStats.Commands.Benchmark, Name = "benchmark"
Count = newStats.Commands.Benchmark,
Name = "benchmark"
});
}
else
@@ -80,7 +82,8 @@ public static class StatsConverter
{
ctx.Commands.Add(new Command
{
Count = newStats.Commands.Checksum, Name = "checksum"
Count = newStats.Commands.Checksum,
Name = "checksum"
});
}
else
@@ -95,7 +98,8 @@ public static class StatsConverter
{
ctx.Commands.Add(new Command
{
Count = newStats.Commands.Compare, Name = "compare"
Count = newStats.Commands.Compare,
Name = "compare"
});
}
else
@@ -110,7 +114,8 @@ public static class StatsConverter
{
ctx.Commands.Add(new Command
{
Count = newStats.Commands.CreateSidecar, Name = "create-sidecar"
Count = newStats.Commands.CreateSidecar,
Name = "create-sidecar"
});
}
else
@@ -125,7 +130,8 @@ public static class StatsConverter
{
ctx.Commands.Add(new Command
{
Count = newStats.Commands.Decode, Name = "decode"
Count = newStats.Commands.Decode,
Name = "decode"
});
}
else
@@ -140,7 +146,8 @@ public static class StatsConverter
{
ctx.Commands.Add(new Command
{
Count = newStats.Commands.DeviceInfo, Name = "device-info"
Count = newStats.Commands.DeviceInfo,
Name = "device-info"
});
}
else
@@ -155,7 +162,8 @@ public static class StatsConverter
{
ctx.Commands.Add(new Command
{
Count = newStats.Commands.DeviceReport, Name = "device-report"
Count = newStats.Commands.DeviceReport,
Name = "device-report"
});
}
else
@@ -170,7 +178,8 @@ public static class StatsConverter
{
ctx.Commands.Add(new Command
{
Count = newStats.Commands.DumpMedia, Name = "dump-media"
Count = newStats.Commands.DumpMedia,
Name = "dump-media"
});
}
else
@@ -185,7 +194,8 @@ public static class StatsConverter
{
ctx.Commands.Add(new Command
{
Count = newStats.Commands.Entropy, Name = "entropy"
Count = newStats.Commands.Entropy,
Name = "entropy"
});
}
else
@@ -200,7 +210,8 @@ public static class StatsConverter
{
ctx.Commands.Add(new Command
{
Count = newStats.Commands.Formats, Name = "formats"
Count = newStats.Commands.Formats,
Name = "formats"
});
}
else
@@ -215,7 +226,8 @@ public static class StatsConverter
{
ctx.Commands.Add(new Command
{
Count = newStats.Commands.MediaInfo, Name = "media-info"
Count = newStats.Commands.MediaInfo,
Name = "media-info"
});
}
else
@@ -230,7 +242,8 @@ public static class StatsConverter
{
ctx.Commands.Add(new Command
{
Count = newStats.Commands.MediaScan, Name = "media-scan"
Count = newStats.Commands.MediaScan,
Name = "media-scan"
});
}
else
@@ -245,7 +258,8 @@ public static class StatsConverter
{
ctx.Commands.Add(new Command
{
Count = newStats.Commands.PrintHex, Name = "printhex"
Count = newStats.Commands.PrintHex,
Name = "printhex"
});
}
else
@@ -260,7 +274,8 @@ public static class StatsConverter
{
ctx.Commands.Add(new Command
{
Count = newStats.Commands.Verify, Name = "verify"
Count = newStats.Commands.Verify,
Name = "verify"
});
}
else
@@ -275,7 +290,8 @@ public static class StatsConverter
{
ctx.Commands.Add(new Command
{
Count = newStats.Commands.Ls, Name = "ls"
Count = newStats.Commands.Ls,
Name = "ls"
});
}
else
@@ -290,7 +306,8 @@ public static class StatsConverter
{
ctx.Commands.Add(new Command
{
Count = newStats.Commands.ExtractFiles, Name = "extract-files"
Count = newStats.Commands.ExtractFiles,
Name = "extract-files"
});
}
else
@@ -305,7 +322,8 @@ public static class StatsConverter
{
ctx.Commands.Add(new Command
{
Count = newStats.Commands.ListDevices, Name = "list-devices"
Count = newStats.Commands.ListDevices,
Name = "list-devices"
});
}
else
@@ -320,7 +338,8 @@ public static class StatsConverter
{
ctx.Commands.Add(new Command
{
Count = newStats.Commands.ListEncodings, Name = "list-encodings"
Count = newStats.Commands.ListEncodings,
Name = "list-encodings"
});
}
else
@@ -335,7 +354,8 @@ public static class StatsConverter
{
ctx.Commands.Add(new Command
{
Count = newStats.Commands.ConvertImage, Name = "convert-image"
Count = newStats.Commands.ConvertImage,
Name = "convert-image"
});
}
else
@@ -350,7 +370,8 @@ public static class StatsConverter
{
ctx.Commands.Add(new Command
{
Count = newStats.Commands.ImageInfo, Name = "image-info"
Count = newStats.Commands.ImageInfo,
Name = "image-info"
});
}
else
@@ -373,7 +394,9 @@ public static class StatsConverter
{
ctx.OperatingSystems.Add(new OperatingSystem
{
Count = operatingSystem.Value, Name = operatingSystem.name, Version = operatingSystem.version
Count = operatingSystem.Value,
Name = operatingSystem.name,
Version = operatingSystem.version
});
}
else
@@ -388,7 +411,8 @@ public static class StatsConverter
{
ctx.OperatingSystems.Add(new OperatingSystem
{
Count = 1, Name = "Linux"
Count = 1,
Name = "Linux"
});
}
else
@@ -407,7 +431,8 @@ public static class StatsConverter
{
ctx.Versions.Add(new Version
{
Count = nvs.Value, Name = nvs.name
Count = nvs.Value,
Name = nvs.name
});
}
else
@@ -422,7 +447,8 @@ public static class StatsConverter
{
ctx.Versions.Add(new Version
{
Count = 1, Name = "previous"
Count = 1,
Name = "previous"
});
}
else
@@ -441,7 +467,8 @@ public static class StatsConverter
{
ctx.Filesystems.Add(new Filesystem
{
Count = nvs.Value, Name = nvs.name
Count = nvs.Value,
Name = nvs.name
});
}
else
@@ -461,7 +488,8 @@ public static class StatsConverter
{
ctx.Partitions.Add(new Partition
{
Count = nvs.Value, Name = nvs.name
Count = nvs.Value,
Name = nvs.name
});
}
else
@@ -481,7 +509,8 @@ public static class StatsConverter
{
ctx.MediaFormats.Add(new MediaFormat
{
Count = nvs.Value, Name = nvs.name
Count = nvs.Value,
Name = nvs.name
});
}
else
@@ -501,7 +530,8 @@ public static class StatsConverter
{
ctx.Filters.Add(new Filter
{
Count = nvs.Value, Name = nvs.name
Count = nvs.Value,
Name = nvs.name
});
}
else
@@ -539,7 +569,9 @@ public static class StatsConverter
{
ctx.Medias.Add(new Media
{
Count = media.Value, Real = media.real, Type = media.type
Count = media.Value,
Real = media.real,
Type = media.type
});
}
else