From 2280ff50c0108476a95ef478694223fded7a31dd Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Wed, 22 Jul 2020 15:26:02 +0100 Subject: [PATCH] Code style fixes. --- .editorconfig | 9 +- Aaru.Checksums | 2 +- Aaru.CommonTypes | 2 +- Aaru.Console | 2 +- Aaru.Decoders | 2 +- Aaru.Dto | 2 +- Aaru.Helpers | 2 +- Aaru.Server.Task/Program.cs | 18 +- Aaru.Server.sln.DotSettings | 17 +- .../Areas/Admin/Controllers/AtasController.cs | 52 +- .../Controllers/BlockDescriptorsController.cs | 2 +- .../Areas/Admin/Controllers/ChsController.cs | 13 +- .../Admin/Controllers/CommandsController.cs | 2 +- .../CompactDiscOffsetsController.cs | 2 +- .../Controllers/DeviceStatsController.cs | 2 +- .../Admin/Controllers/DevicesController.cs | 11 +- .../Controllers/FilesystemsController.cs | 2 +- .../Admin/Controllers/FiltersController.cs | 2 +- .../Admin/Controllers/FireWiresController.cs | 17 +- .../GdRomSwapDiscCapabilitiesController.cs | 6 +- .../Areas/Admin/Controllers/HomeController.cs | 7 +- .../Controllers/MediaFormatsController.cs | 2 +- .../Admin/Controllers/MediasController.cs | 2 +- .../Areas/Admin/Controllers/MmcController.cs | 8 +- .../Controllers/MmcFeaturesController.cs | 2 +- .../Admin/Controllers/MmcSdsController.cs | 2 +- .../Controllers/OperatingSystemsController.cs | 2 +- .../Admin/Controllers/PartitionsController.cs | 2 +- .../Admin/Controllers/PcmciasController.cs | 2 +- .../Admin/Controllers/ReportsController.cs | 4 +- .../Admin/Controllers/ScsiModesController.cs | 2 +- .../Admin/Controllers/ScsiPagesController.cs | 2 +- .../Admin/Controllers/ScsisController.cs | 17 +- .../Areas/Admin/Controllers/SscsController.cs | 12 +- .../SupportedDensitiesController.cs | 2 +- .../Controllers/TestedMediasController.cs | 22 +- .../TestedSequentialMediasController.cs | 2 +- .../Controllers/UsbProductsController.cs | 9 +- .../Admin/Controllers/UsbVendorsController.cs | 21 +- .../Areas/Admin/Controllers/UsbsController.cs | 14 +- .../Admin/Controllers/VersionsController.cs | 2 +- .../Areas/Admin/Views/Atas/Delete.cshtml | 2 +- .../Areas/Admin/Views/Atas/Details.cshtml | 2 +- .../Areas/Admin/Views/Mmc/Delete.cshtml | 2 +- .../Areas/Admin/Views/Mmc/Details.cshtml | 2 +- .../Areas/Admin/Views/MmcSds/Delete.cshtml | 2 +- .../Areas/Admin/Views/MmcSds/Details.cshtml | 2 +- .../Areas/Admin/Views/Scsis/Delete.cshtml | 2 +- .../Areas/Admin/Views/Scsis/Details.cshtml | 2 +- .../Areas/Admin/Views/Scsis/Index.cshtml | 2 +- .../Areas/Admin/Views/Shared/_Layout.cshtml | 5 +- .../Admin/Views/Shared/_LoginPartial.cshtml | 5 +- .../Areas/Admin/Views/_ViewImports.cshtml | 3 +- .../Identity/Pages/Account/Register.cshtml.cs | 2 +- Aaru.Server/BasicAuthMiddleware.cs | 22 +- Aaru.Server/Controllers/HomeController.cs | 22 +- Aaru.Server/Controllers/ReportController.cs | 36 +- Aaru.Server/Controllers/StatsController.cs | 207 ++++--- Aaru.Server/Controllers/UpdateController.cs | 16 +- .../Controllers/UploadReportController.cs | 55 +- .../Controllers/UploadStatsController.cs | 135 ++--- Aaru.Server/Core/Ata.cs | 131 +++-- Aaru.Server/Core/Hash.cs | 2 +- Aaru.Server/Core/ScsiEvpd.cs | 2 +- Aaru.Server/Core/ScsiInquiry.cs | 10 +- Aaru.Server/Core/ScsiMmcFeatures.cs | 6 +- Aaru.Server/Core/ScsiMmcMode.cs | 2 +- Aaru.Server/Core/ScsiModeSense.cs | 2 +- Aaru.Server/Core/SscTestedMedia.cs | 2 +- Aaru.Server/Core/StatsConverter.cs | 537 +++++++++--------- Aaru.Server/Core/TestedMedia.cs | 7 +- .../20191102132240_InitialMigration.cs | 462 +++++++-------- .../20191106230730_CreateIdentitySchema.cs | 68 ++- .../20191204182314_RemoteStatistics.cs | 28 +- ...0710172932_AddGdRomSwapDiscCapabilities.cs | 209 +++---- ...0710184810_AddCanReadGdRomUsingSwapDisc.cs | 3 +- .../AaruServerContextModelSnapshot.cs | 89 ++- Aaru.Server/Models/Context.cs | 51 +- Aaru.Server/Program.cs | 95 ++-- Aaru.Server/Seeder.cs | 5 +- Aaru.Server/Startup.cs | 4 +- Aaru.Server/Views/Home/CODE_OF_CONDUCT.cshtml | 3 +- Aaru.Server/Views/Home/CONTRIBUTING.cshtml | 3 +- Aaru.Server/Views/Home/Changelog.cshtml | 3 +- Aaru.Server/Views/Home/ISSUE_TEMPLATE.cshtml | 3 +- Aaru.Server/Views/Home/NEEDED.cshtml | 3 +- Aaru.Server/Views/Home/NEEDINFO.cshtml | 3 +- .../Views/Home/PULL_REQUEST_TEMPLATE.cshtml | 3 +- Aaru.Server/Views/Home/TODO.cshtml | 3 +- Aaru.Server/Views/Report/View.cshtml | 102 ++-- Aaru.Server/Views/Shared/_Layout.cshtml | 3 - Aaru.Server/Views/Stats/Index.cshtml | 8 +- Aaru.Server/Views/_ViewImports.cshtml | 3 +- CICMMetadata | 2 +- 94 files changed, 1389 insertions(+), 1299 deletions(-) diff --git a/.editorconfig b/.editorconfig index 940c6206..8b506dab 100644 --- a/.editorconfig +++ b/.editorconfig @@ -154,7 +154,7 @@ place_simple_embedded_block_on_same_line=false place_simple_anonymousmethod_on_single_line=false keep_existing_initializer_arrangement=false place_simple_initializer_on_single_line=false -wrap_object_and_collection_initializer_style=wrap_if_long +wrap_object_and_collection_initializer_style=chop_always wrap_array_initializer_style=wrap_if_long wrap_arguments_style=wrap_if_long keep_existing_invocation_parens_arrangement=false @@ -298,7 +298,7 @@ dotnet_sort_system_directives_first=true # Constants in C style, all-caps dotnet_naming_rule.constant_fields_caps.symbols = constant_fields -dotnet_naming_rule.constant_fields_caps.severity = suggestion +dotnet_naming_rule.constant_fields_caps.severity = warning dotnet_naming_rule.constant_fields_caps.style = caps_style dotnet_naming_symbols.constant_fields.applicable_kinds = field dotnet_naming_symbols.constant_fields.required_modifiers = const @@ -313,7 +313,7 @@ dotnet_naming_style.pascal_case_interface_style.required_prefix = I dotnet_naming_style.pascal_case_interface_style.capitalization = pascal_case ## internal and private fields should be _camelCase -dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion +dotnet_naming_rule.camel_case_for_private_internal_fields.severity = warning dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style dotnet_naming_symbols.private_internal_fields.applicable_kinds = field @@ -506,6 +506,7 @@ csharp_int_align_invocations=false csharp_int_align_binary_expressions=true csharp_int_align_comments=true csharp_int_align_switch_sections=true +csharp_int_align=true csharp_keep_user_linebreaks=false csharp_keep_existing_arrangement=false csharp_keep_existing_linebreaks=false @@ -559,7 +560,7 @@ csharp_place_simple_embedded_block_on_same_line=false csharp_place_simple_anonymousmethod_on_single_line=false csharp_keep_existing_initializer_arrangement=false csharp_place_simple_initializer_on_single_line=false -csharp_wrap_object_and_collection_initializer_style=wrap_if_long +csharp_wrap_object_and_collection_initializer_style=chop_always csharp_wrap_array_initializer_style=wrap_if_long csharp_wrap_arguments_style=wrap_if_long csharp_keep_existing_invocation_parens_arrangement=false diff --git a/Aaru.Checksums b/Aaru.Checksums index f0d3b2fe..b2612422 160000 --- a/Aaru.Checksums +++ b/Aaru.Checksums @@ -1 +1 @@ -Subproject commit f0d3b2fe0987999284c067b302c3b2121dcdfe2e +Subproject commit b2612422abea422c4b07419b45fd032b5b11801f diff --git a/Aaru.CommonTypes b/Aaru.CommonTypes index 875d9471..1389baf6 160000 --- a/Aaru.CommonTypes +++ b/Aaru.CommonTypes @@ -1 +1 @@ -Subproject commit 875d94716658481ab0b267b36d04fff9d33e260f +Subproject commit 1389baf6b2742edf9e90beb83905571185524817 diff --git a/Aaru.Console b/Aaru.Console index f908d537..fa739c47 160000 --- a/Aaru.Console +++ b/Aaru.Console @@ -1 +1 @@ -Subproject commit f908d537c396c1bac7d0649bf0740fc6de688a77 +Subproject commit fa739c475178569a06e666368a76a82ca0fab81c diff --git a/Aaru.Decoders b/Aaru.Decoders index adaf6909..b52d6237 160000 --- a/Aaru.Decoders +++ b/Aaru.Decoders @@ -1 +1 @@ -Subproject commit adaf6909c2f965c3a5511d991dbc2c33175facde +Subproject commit b52d623764d463e4e0dd4142bc0b4bc51203e194 diff --git a/Aaru.Dto b/Aaru.Dto index 0d88fbf3..ae5a792f 160000 --- a/Aaru.Dto +++ b/Aaru.Dto @@ -1 +1 @@ -Subproject commit 0d88fbf3dd76c1db6ab5b54d36a6813b576b4ace +Subproject commit ae5a792feca2b9b9f6a9b02c3a95ac917616ff96 diff --git a/Aaru.Helpers b/Aaru.Helpers index a90513f7..b23d976f 160000 --- a/Aaru.Helpers +++ b/Aaru.Helpers @@ -1 +1 @@ -Subproject commit a90513f70c16fc912149cd163616f8bd139d1377 +Subproject commit b23d976f9334f0bc2e59e4d61f047be65cc47500 diff --git a/Aaru.Server.Task/Program.cs b/Aaru.Server.Task/Program.cs index 7b40d416..89ea67da 100644 --- a/Aaru.Server.Task/Program.cs +++ b/Aaru.Server.Task/Program.cs @@ -142,8 +142,7 @@ namespace Aaru.Server.Task System.Console. WriteLine("{0}: Will modify product with ID {1:X4} and vendor {2} ({3:X4}) from \"{4}\" to \"{5}\"", DateTime.UtcNow, product.ProductId, product.Vendor?.Vendor ?? "null", - product.Vendor?.VendorId ?? 0, - product.Product, name); + product.Vendor?.VendorId ?? 0, product.Product, name); product.Product = name; product.ModifiedWhen = DateTime.UtcNow; @@ -399,7 +398,7 @@ namespace Aaru.Server.Task if(!int.TryParse(column2, out int submissions)) continue; - if(column3[column3.Length - 1] != '%') + if(column3[^1] != '%') continue; column3 = column3.Substring(0, column3.Length - 1); @@ -413,8 +412,12 @@ namespace Aaru.Server.Task { cdOffset = new CompactDiscOffset { - AddedWhen = DateTime.UtcNow, ModifiedWhen = DateTime.UtcNow, Agreement = percentage, - Manufacturer = manufacturer, Model = model, Offset = offset, + AddedWhen = DateTime.UtcNow, + ModifiedWhen = DateTime.UtcNow, + Agreement = percentage, + Manufacturer = manufacturer, + Model = model, + Offset = offset, Submissions = submissions }; @@ -451,10 +454,9 @@ namespace Aaru.Server.Task Devices. Where(d => d.Manufacturer == null && d.Model != null && d.Model.Trim() == model). - Union(ctx.Devices.Where(d => d.Manufacturer != null && + Union(ctx.Devices.Where(d => d.Manufacturer != null && d.Manufacturer.Trim() == manufacturer && - d.Model != null && - d.Model == model))) + d.Model != null && d.Model == model))) { if(device.CdOffset == cdOffset && device.ModifiedWhen == cdOffset.ModifiedWhen) diff --git a/Aaru.Server.sln.DotSettings b/Aaru.Server.sln.DotSettings index b904820e..873435f5 100644 --- a/Aaru.Server.sln.DotSettings +++ b/Aaru.Server.sln.DotSettings @@ -1,4 +1,19 @@  /opt/dotnet/sdk/3.0.100/MSBuild.dll 4294967295 - True \ No newline at end of file + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True \ No newline at end of file diff --git a/Aaru.Server/Areas/Admin/Controllers/AtasController.cs b/Aaru.Server/Areas/Admin/Controllers/AtasController.cs index 0a48cdd9..b8e0cca5 100644 --- a/Aaru.Server/Areas/Admin/Controllers/AtasController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/AtasController.cs @@ -3,18 +3,20 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Threading.Tasks; -using Aaru.CommonTypes.Metadata; using Aaru.CommonTypes.Structs.Devices.ATA; +using Aaru.Server.Core; using Aaru.Server.Models; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; +using Ata = Aaru.CommonTypes.Metadata.Ata; +using TestedMedia = Aaru.CommonTypes.Metadata.TestedMedia; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class AtasController : Controller + public sealed class AtasController : Controller { readonly AaruServerContext _context; @@ -32,7 +34,7 @@ namespace Aaru.Server.Areas.Admin.Controllers return NotFound(); } - CommonTypes.Metadata.Ata ata = await _context.Ata.FirstOrDefaultAsync(m => m.Id == id); + Ata ata = await _context.Ata.FirstOrDefaultAsync(m => m.Id == id); if(ata == null) { @@ -50,7 +52,7 @@ namespace Aaru.Server.Areas.Admin.Controllers return NotFound(); } - CommonTypes.Metadata.Ata ata = await _context.Ata.FirstOrDefaultAsync(m => m.Id == id); + Ata ata = await _context.Ata.FirstOrDefaultAsync(m => m.Id == id); if(ata == null) { @@ -64,7 +66,7 @@ namespace Aaru.Server.Areas.Admin.Controllers [HttpPost, ActionName("Delete"), ValidateAntiForgeryToken] public async Task DeleteConfirmed(int id) { - CommonTypes.Metadata.Ata ata = await _context.Ata.FindAsync(id); + Ata ata = await _context.Ata.FindAsync(id); _context.Ata.Remove(ata); await _context.SaveChangesAsync(); @@ -81,7 +83,7 @@ namespace Aaru.Server.Areas.Admin.Controllers for(int i = 0; i < dups.Count; i++) { - CommonTypes.Metadata.Ata unique = _context.Ata.First(a => a.Id == dups[i].Id); + Ata unique = _context.Ata.First(a => a.Id == dups[i].Id); dups[i].Description = unique.IdentifyDevice?.Model; dups[i].Duplicates = hashes.Where(h => h.Hash == dups[i].Hash).Skip(1).Select(x => x.Id).ToArray(); @@ -89,7 +91,8 @@ namespace Aaru.Server.Areas.Admin.Controllers return View(new IdHashModelForView { - List = dups, Json = JsonConvert.SerializeObject(dups) + List = dups, + Json = JsonConvert.SerializeObject(dups) }); } @@ -112,14 +115,14 @@ namespace Aaru.Server.Areas.Admin.Controllers foreach(IdHashModel duplicate in duplicates) { - CommonTypes.Metadata.Ata master = _context.Ata.FirstOrDefault(m => m.Id == duplicate.Id); + Ata master = _context.Ata.FirstOrDefault(m => m.Id == duplicate.Id); if(master is null) continue; foreach(int duplicateId in duplicate.Duplicates) { - CommonTypes.Metadata.Ata slave = _context.Ata.FirstOrDefault(m => m.Id == duplicateId); + Ata slave = _context.Ata.FirstOrDefault(m => m.Id == duplicateId); if(slave is null) continue; @@ -165,20 +168,22 @@ namespace Aaru.Server.Areas.Admin.Controllers public IActionResult ConsolidateWithIds(int masterId, int slaveId) { - CommonTypes.Metadata.Ata master = _context.Ata.FirstOrDefault(m => m.Id == masterId); + Ata master = _context.Ata.FirstOrDefault(m => m.Id == masterId); if(master is null) return RedirectToAction(nameof(Compare), new { - id = masterId, rightId = slaveId + id = masterId, + rightId = slaveId }); - CommonTypes.Metadata.Ata slave = _context.Ata.FirstOrDefault(m => m.Id == slaveId); + Ata slave = _context.Ata.FirstOrDefault(m => m.Id == slaveId); if(slave is null) return RedirectToAction(nameof(Compare), new { - id = masterId, rightId = slaveId + id = masterId, + rightId = slaveId }); foreach(Device ataDevice in _context.Devices.Where(d => d.ATA.Id == slaveId)) @@ -222,11 +227,12 @@ namespace Aaru.Server.Areas.Admin.Controllers { var model = new CompareModel { - LeftId = id, RightId = rightId + LeftId = id, + RightId = rightId }; - CommonTypes.Metadata.Ata left = _context.Ata.FirstOrDefault(l => l.Id == id); - CommonTypes.Metadata.Ata right = _context.Ata.FirstOrDefault(r => r.Id == rightId); + Ata left = _context.Ata.FirstOrDefault(l => l.Id == id); + Ata right = _context.Ata.FirstOrDefault(r => r.Id == rightId); if(left is null) { @@ -356,10 +362,10 @@ namespace Aaru.Server.Areas.Admin.Controllers public IActionResult CheckPrivate() { - List havePrivacy = new List(); - byte[] tmp; + List havePrivacy = new List(); + byte[] tmp; - foreach(CommonTypes.Metadata.Ata ata in _context.Ata) + foreach(Ata ata in _context.Ata) { Identify.IdentifyDevice? id = ata.IdentifyDevice; @@ -435,7 +441,7 @@ namespace Aaru.Server.Areas.Admin.Controllers public IActionResult ClearPrivate(int id) { - CommonTypes.Metadata.Ata ata = _context.Ata.FirstOrDefault(a => a.Id == id); + Ata ata = _context.Ata.FirstOrDefault(a => a.Id == id); if(ata is null) return RedirectToAction(nameof(CheckPrivate)); @@ -461,7 +467,7 @@ namespace Aaru.Server.Areas.Admin.Controllers public IActionResult ClearReserved(int id) { - CommonTypes.Metadata.Ata ata = _context.Ata.FirstOrDefault(a => a.Id == id); + Ata ata = _context.Ata.FirstOrDefault(a => a.Id == id); if(ata is null) return RedirectToAction(nameof(CheckPrivate)); @@ -495,7 +501,7 @@ namespace Aaru.Server.Areas.Admin.Controllers public IActionResult ClearPrivateAll() { - foreach(CommonTypes.Metadata.Ata ata in _context.Ata) + foreach(Ata ata in _context.Ata) { if(ata is null) return RedirectToAction(nameof(CheckPrivate)); @@ -523,7 +529,7 @@ namespace Aaru.Server.Areas.Admin.Controllers public IActionResult ClearReservedAll() { - foreach(CommonTypes.Metadata.Ata ata in _context.Ata) + foreach(Ata ata in _context.Ata) { // ReservedWords121 for(int i = 0; i < 10; i++) diff --git a/Aaru.Server/Areas/Admin/Controllers/BlockDescriptorsController.cs b/Aaru.Server/Areas/Admin/Controllers/BlockDescriptorsController.cs index 73804259..2a081a10 100644 --- a/Aaru.Server/Areas/Admin/Controllers/BlockDescriptorsController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/BlockDescriptorsController.cs @@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class BlockDescriptorsController : Controller + public sealed class BlockDescriptorsController : Controller { readonly AaruServerContext _context; diff --git a/Aaru.Server/Areas/Admin/Controllers/ChsController.cs b/Aaru.Server/Areas/Admin/Controllers/ChsController.cs index 16e668c4..3140b3f1 100644 --- a/Aaru.Server/Areas/Admin/Controllers/ChsController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/ChsController.cs @@ -11,7 +11,7 @@ using Newtonsoft.Json; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class ChsController : Controller + public sealed class ChsController : Controller { readonly AaruServerContext _context; @@ -26,15 +26,20 @@ namespace Aaru.Server.Areas.Admin.Controllers { List 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) }); } diff --git a/Aaru.Server/Areas/Admin/Controllers/CommandsController.cs b/Aaru.Server/Areas/Admin/Controllers/CommandsController.cs index c9787751..658ba8a6 100644 --- a/Aaru.Server/Areas/Admin/Controllers/CommandsController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/CommandsController.cs @@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class CommandsController : Controller + public sealed class CommandsController : Controller { readonly AaruServerContext _context; diff --git a/Aaru.Server/Areas/Admin/Controllers/CompactDiscOffsetsController.cs b/Aaru.Server/Areas/Admin/Controllers/CompactDiscOffsetsController.cs index 39ce74a5..5e26201b 100644 --- a/Aaru.Server/Areas/Admin/Controllers/CompactDiscOffsetsController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/CompactDiscOffsetsController.cs @@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class CompactDiscOffsetsController : Controller + public sealed class CompactDiscOffsetsController : Controller { readonly AaruServerContext _context; diff --git a/Aaru.Server/Areas/Admin/Controllers/DeviceStatsController.cs b/Aaru.Server/Areas/Admin/Controllers/DeviceStatsController.cs index 74656aa8..37935256 100644 --- a/Aaru.Server/Areas/Admin/Controllers/DeviceStatsController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/DeviceStatsController.cs @@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class DeviceStatsController : Controller + public sealed class DeviceStatsController : Controller { readonly AaruServerContext _context; diff --git a/Aaru.Server/Areas/Admin/Controllers/DevicesController.cs b/Aaru.Server/Areas/Admin/Controllers/DevicesController.cs index 76bdec78..107e05fb 100644 --- a/Aaru.Server/Areas/Admin/Controllers/DevicesController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/DevicesController.cs @@ -10,7 +10,7 @@ using Microsoft.EntityFrameworkCore; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class DevicesController : Controller + public sealed class DevicesController : Controller { readonly AaruServerContext _context; @@ -406,9 +406,12 @@ namespace Aaru.Server.Areas.Admin.Controllers var found = new FindReportModel { - Id = id, Manufacturer = manufacturer, Model = model, Revision = revision, - Bus = bus, - LikeDevices = _context.Devices.Where(r => r.Model.ToLower().Contains(model.ToLower())).ToList() + Id = id, + Manufacturer = manufacturer, + Model = model, + Revision = revision, + Bus = bus, + LikeDevices = _context.Devices.Where(r => r.Model.ToLower().Contains(model.ToLower())).ToList() }; return View(found); diff --git a/Aaru.Server/Areas/Admin/Controllers/FilesystemsController.cs b/Aaru.Server/Areas/Admin/Controllers/FilesystemsController.cs index ef4885ac..db8dbcad 100644 --- a/Aaru.Server/Areas/Admin/Controllers/FilesystemsController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/FilesystemsController.cs @@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class FilesystemsController : Controller + public sealed class FilesystemsController : Controller { readonly AaruServerContext _context; diff --git a/Aaru.Server/Areas/Admin/Controllers/FiltersController.cs b/Aaru.Server/Areas/Admin/Controllers/FiltersController.cs index a3cc0e49..61f61e11 100644 --- a/Aaru.Server/Areas/Admin/Controllers/FiltersController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/FiltersController.cs @@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class FiltersController : Controller + public sealed class FiltersController : Controller { readonly AaruServerContext _context; diff --git a/Aaru.Server/Areas/Admin/Controllers/FireWiresController.cs b/Aaru.Server/Areas/Admin/Controllers/FireWiresController.cs index 2f8e5eed..27858946 100644 --- a/Aaru.Server/Areas/Admin/Controllers/FireWiresController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/FireWiresController.cs @@ -11,7 +11,7 @@ using Newtonsoft.Json; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class FireWiresController : Controller + public sealed class FireWiresController : Controller { readonly AaruServerContext _context; @@ -112,17 +112,24 @@ namespace Aaru.Server.Areas.Admin.Controllers { List dups = _context.FireWire.GroupBy(x => new { - x.VendorID, x.ProductID, x.Manufacturer, x.Product, + x.VendorID, + x.ProductID, + x.Manufacturer, + x.Product, x.RemovableMedia }).Where(x => x.Count() > 1).Select(x => new FireWireModel { - VendorID = x.Key.VendorID, ProductID = x.Key.ProductID, Manufacturer = x.Key.Manufacturer, - Product = x.Key.Product, RemovableMedia = x.Key.RemovableMedia + VendorID = x.Key.VendorID, + ProductID = x.Key.ProductID, + Manufacturer = x.Key.Manufacturer, + Product = x.Key.Product, + RemovableMedia = x.Key.RemovableMedia }).ToList(); return View(new FireWireModelForView { - List = dups, Json = JsonConvert.SerializeObject(dups) + List = dups, + Json = JsonConvert.SerializeObject(dups) }); } diff --git a/Aaru.Server/Areas/Admin/Controllers/GdRomSwapDiscCapabilitiesController.cs b/Aaru.Server/Areas/Admin/Controllers/GdRomSwapDiscCapabilitiesController.cs index 0a393755..bedaa5d0 100644 --- a/Aaru.Server/Areas/Admin/Controllers/GdRomSwapDiscCapabilitiesController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/GdRomSwapDiscCapabilitiesController.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using System.Web; using Aaru.CommonTypes.Metadata; using Aaru.Decoders.CD; +using Aaru.Helpers; using Aaru.Server.Models; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -13,7 +14,7 @@ using Microsoft.EntityFrameworkCore; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class GdRomSwapDiscCapabilitiesController : Controller + public sealed class GdRomSwapDiscCapabilitiesController : Controller { readonly AaruServerContext _context; @@ -82,7 +83,8 @@ namespace Aaru.Server.Areas.Admin.Controllers var model = new TestedMediaDataModel { - TestedMediaId = id, DataName = data + TestedMediaId = id, + DataName = data }; byte[] buffer; diff --git a/Aaru.Server/Areas/Admin/Controllers/HomeController.cs b/Aaru.Server/Areas/Admin/Controllers/HomeController.cs index f408eda9..e126014f 100644 --- a/Aaru.Server/Areas/Admin/Controllers/HomeController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/HomeController.cs @@ -31,18 +31,13 @@ // ****************************************************************************/ using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class HomeController : Controller + public sealed class HomeController : Controller { - readonly IWebHostEnvironment _environment; - - public HomeController(IWebHostEnvironment environment) => _environment = environment; - public ActionResult Index() => View(); } } \ No newline at end of file diff --git a/Aaru.Server/Areas/Admin/Controllers/MediaFormatsController.cs b/Aaru.Server/Areas/Admin/Controllers/MediaFormatsController.cs index d2be941e..c5042f4d 100644 --- a/Aaru.Server/Areas/Admin/Controllers/MediaFormatsController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/MediaFormatsController.cs @@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class MediaFormatsController : Controller + public sealed class MediaFormatsController : Controller { readonly AaruServerContext _context; diff --git a/Aaru.Server/Areas/Admin/Controllers/MediasController.cs b/Aaru.Server/Areas/Admin/Controllers/MediasController.cs index b0c8a066..b2ada67e 100644 --- a/Aaru.Server/Areas/Admin/Controllers/MediasController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/MediasController.cs @@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class MediasController : Controller + public sealed class MediasController : Controller { readonly AaruServerContext _context; diff --git a/Aaru.Server/Areas/Admin/Controllers/MmcController.cs b/Aaru.Server/Areas/Admin/Controllers/MmcController.cs index bd5f32e7..178cd71e 100644 --- a/Aaru.Server/Areas/Admin/Controllers/MmcController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/MmcController.cs @@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class MmcController : Controller + public sealed class MmcController : Controller { readonly AaruServerContext _context; @@ -19,13 +19,15 @@ namespace Aaru.Server.Areas.Admin.Controllers public IActionResult Index() => View(_context.Mmc.Where(m => m.ModeSense2AData != null). Select(m => new MmcModelForView { - Id = m.Id, FeaturesId = m.FeaturesId, + Id = m.Id, + FeaturesId = m.FeaturesId, DataLength = m.ModeSense2AData.Length }).ToList(). Concat(_context.Mmc.Where(m => m.ModeSense2AData == null). Select(m => new MmcModelForView { - Id = m.Id, FeaturesId = m.FeaturesId, + Id = m.Id, + FeaturesId = m.FeaturesId, DataLength = 0 }).ToList()).OrderBy(m => m.Id)); diff --git a/Aaru.Server/Areas/Admin/Controllers/MmcFeaturesController.cs b/Aaru.Server/Areas/Admin/Controllers/MmcFeaturesController.cs index a3c230d9..34e44785 100644 --- a/Aaru.Server/Areas/Admin/Controllers/MmcFeaturesController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/MmcFeaturesController.cs @@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class MmcFeaturesController : Controller + public sealed class MmcFeaturesController : Controller { readonly AaruServerContext _context; diff --git a/Aaru.Server/Areas/Admin/Controllers/MmcSdsController.cs b/Aaru.Server/Areas/Admin/Controllers/MmcSdsController.cs index 3e197ed0..32d128c8 100644 --- a/Aaru.Server/Areas/Admin/Controllers/MmcSdsController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/MmcSdsController.cs @@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class MmcSdsController : Controller + public sealed class MmcSdsController : Controller { readonly AaruServerContext _context; diff --git a/Aaru.Server/Areas/Admin/Controllers/OperatingSystemsController.cs b/Aaru.Server/Areas/Admin/Controllers/OperatingSystemsController.cs index fe774281..5914844a 100644 --- a/Aaru.Server/Areas/Admin/Controllers/OperatingSystemsController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/OperatingSystemsController.cs @@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class OperatingSystemsController : Controller + public sealed class OperatingSystemsController : Controller { readonly AaruServerContext _context; diff --git a/Aaru.Server/Areas/Admin/Controllers/PartitionsController.cs b/Aaru.Server/Areas/Admin/Controllers/PartitionsController.cs index 98b5a93d..240faa4e 100644 --- a/Aaru.Server/Areas/Admin/Controllers/PartitionsController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/PartitionsController.cs @@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class PartitionsController : Controller + public sealed class PartitionsController : Controller { readonly AaruServerContext _context; diff --git a/Aaru.Server/Areas/Admin/Controllers/PcmciasController.cs b/Aaru.Server/Areas/Admin/Controllers/PcmciasController.cs index 680adf58..ccdf03a0 100644 --- a/Aaru.Server/Areas/Admin/Controllers/PcmciasController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/PcmciasController.cs @@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class PcmciasController : Controller + public sealed class PcmciasController : Controller { readonly AaruServerContext _context; diff --git a/Aaru.Server/Areas/Admin/Controllers/ReportsController.cs b/Aaru.Server/Areas/Admin/Controllers/ReportsController.cs index b46cdd37..69b4d317 100644 --- a/Aaru.Server/Areas/Admin/Controllers/ReportsController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/ReportsController.cs @@ -10,7 +10,7 @@ using Microsoft.EntityFrameworkCore.ChangeTracking; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class ReportsController : Controller + public sealed class ReportsController : Controller { readonly AaruServerContext _context; @@ -165,8 +165,6 @@ namespace Aaru.Server.Areas.Admin.Controllers return RedirectToAction(nameof(Index)); } - bool UploadedReportExists(int id) => _context.Reports.Any(e => e.Id == id); - public IActionResult Promote(int? id) { if(id == null) diff --git a/Aaru.Server/Areas/Admin/Controllers/ScsiModesController.cs b/Aaru.Server/Areas/Admin/Controllers/ScsiModesController.cs index ba380b85..c318b5c1 100644 --- a/Aaru.Server/Areas/Admin/Controllers/ScsiModesController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/ScsiModesController.cs @@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class ScsiModesController : Controller + public sealed class ScsiModesController : Controller { readonly AaruServerContext _context; diff --git a/Aaru.Server/Areas/Admin/Controllers/ScsiPagesController.cs b/Aaru.Server/Areas/Admin/Controllers/ScsiPagesController.cs index 729b035e..f583d465 100644 --- a/Aaru.Server/Areas/Admin/Controllers/ScsiPagesController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/ScsiPagesController.cs @@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class ScsiPagesController : Controller + public sealed class ScsiPagesController : Controller { readonly AaruServerContext _context; diff --git a/Aaru.Server/Areas/Admin/Controllers/ScsisController.cs b/Aaru.Server/Areas/Admin/Controllers/ScsisController.cs index 06590e2e..9af63403 100644 --- a/Aaru.Server/Areas/Admin/Controllers/ScsisController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/ScsisController.cs @@ -5,16 +5,19 @@ using System.Reflection; using System.Threading.Tasks; using Aaru.CommonTypes.Metadata; using Aaru.CommonTypes.Structs.Devices.SCSI; +using Aaru.Helpers; +using Aaru.Server.Core; using Aaru.Server.Models; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; +using TestedMedia = Aaru.CommonTypes.Metadata.TestedMedia; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class ScsisController : Controller + public sealed class ScsisController : Controller { readonly AaruServerContext _context; @@ -99,7 +102,8 @@ namespace Aaru.Server.Areas.Admin.Controllers return View(new IdHashModelForView { - List = dups, Json = JsonConvert.SerializeObject(dups) + List = dups, + Json = JsonConvert.SerializeObject(dups) }); } @@ -167,7 +171,8 @@ namespace Aaru.Server.Areas.Admin.Controllers { var model = new CompareModel { - LeftId = id, RightId = rightId + LeftId = id, + RightId = rightId }; Scsi left = _context.Scsi.FirstOrDefault(l => l.Id == id); @@ -335,7 +340,8 @@ namespace Aaru.Server.Areas.Admin.Controllers if(master is null) return RedirectToAction(nameof(Compare), new { - id = masterId, rightId = slaveId + id = masterId, + rightId = slaveId }); Scsi slave = _context.Scsi.FirstOrDefault(m => m.Id == slaveId); @@ -343,7 +349,8 @@ namespace Aaru.Server.Areas.Admin.Controllers if(slave is null) return RedirectToAction(nameof(Compare), new { - id = masterId, rightId = slaveId + id = masterId, + rightId = slaveId }); foreach(Device scsiDevice in _context.Devices.Where(d => d.SCSI.Id == slaveId)) diff --git a/Aaru.Server/Areas/Admin/Controllers/SscsController.cs b/Aaru.Server/Areas/Admin/Controllers/SscsController.cs index e85238d0..8603dcbf 100644 --- a/Aaru.Server/Areas/Admin/Controllers/SscsController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/SscsController.cs @@ -11,7 +11,7 @@ using Newtonsoft.Json; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class SscsController : Controller + public sealed class SscsController : Controller { readonly AaruServerContext _context; @@ -55,16 +55,20 @@ namespace Aaru.Server.Areas.Admin.Controllers { List 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 { - BlockSizeGranularity = x.Key.BlockSizeGranularity, MaxBlockLength = x.Key.MaxBlockLength, + BlockSizeGranularity = x.Key.BlockSizeGranularity, + MaxBlockLength = x.Key.MaxBlockLength, MinBlockLength = x.Key.MinBlockLength }).ToList(); return View(new SscModelForView { - List = dups, Json = JsonConvert.SerializeObject(dups) + List = dups, + Json = JsonConvert.SerializeObject(dups) }); } diff --git a/Aaru.Server/Areas/Admin/Controllers/SupportedDensitiesController.cs b/Aaru.Server/Areas/Admin/Controllers/SupportedDensitiesController.cs index f5ac7bbd..20b1653c 100644 --- a/Aaru.Server/Areas/Admin/Controllers/SupportedDensitiesController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/SupportedDensitiesController.cs @@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class SupportedDensitiesController : Controller + public sealed class SupportedDensitiesController : Controller { readonly AaruServerContext _context; diff --git a/Aaru.Server/Areas/Admin/Controllers/TestedMediasController.cs b/Aaru.Server/Areas/Admin/Controllers/TestedMediasController.cs index 6642fb49..a60979da 100644 --- a/Aaru.Server/Areas/Admin/Controllers/TestedMediasController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/TestedMediasController.cs @@ -1,6 +1,5 @@ using System; using System.Linq; -using System.Text; using System.Threading.Tasks; using System.Web; using Aaru.CommonTypes.Metadata; @@ -10,6 +9,7 @@ using Aaru.Decoders.Bluray; using Aaru.Decoders.CD; using Aaru.Decoders.DVD; using Aaru.Decoders.SCSI; +using Aaru.Helpers; using Aaru.Server.Models; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -22,7 +22,7 @@ using Spare = Aaru.Decoders.Bluray.Spare; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class TestedMediasController : Controller + public sealed class TestedMediasController : Controller { readonly AaruServerContext _context; @@ -140,8 +140,6 @@ namespace Aaru.Server.Areas.Admin.Controllers return RedirectToAction(nameof(Index)); } - bool TestedMediaExists(int id) => _context.TestedMedia.Any(e => e.Id == id); - public IActionResult ViewData(int id, string data) { if(string.IsNullOrWhiteSpace(data)) @@ -156,16 +154,16 @@ namespace Aaru.Server.Areas.Admin.Controllers var model = new TestedMediaDataModel { - TestedMediaId = id, DataName = data + TestedMediaId = id, + DataName = data }; - byte[] buffer; - StringBuilder sb; - byte[] sector = new byte[2352]; - byte[] subq = new byte[16]; - byte[] fullsub = new byte[96]; - bool c2Errors = false; - bool scrambled = false; + byte[] buffer; + byte[] sector = new byte[2352]; + byte[] subq = new byte[16]; + byte[] fullsub = new byte[96]; + bool c2Errors = false; + bool scrambled = false; switch(data) { diff --git a/Aaru.Server/Areas/Admin/Controllers/TestedSequentialMediasController.cs b/Aaru.Server/Areas/Admin/Controllers/TestedSequentialMediasController.cs index ca1f524c..e4646fb0 100644 --- a/Aaru.Server/Areas/Admin/Controllers/TestedSequentialMediasController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/TestedSequentialMediasController.cs @@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class TestedSequentialMediasController : Controller + public sealed class TestedSequentialMediasController : Controller { readonly AaruServerContext _context; diff --git a/Aaru.Server/Areas/Admin/Controllers/UsbProductsController.cs b/Aaru.Server/Areas/Admin/Controllers/UsbProductsController.cs index f977c8c9..2e8d43b2 100644 --- a/Aaru.Server/Areas/Admin/Controllers/UsbProductsController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/UsbProductsController.cs @@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class UsbProductsController : Controller + public sealed class UsbProductsController : Controller { readonly AaruServerContext _context; @@ -20,9 +20,10 @@ namespace Aaru.Server.Areas.Admin.Controllers OrderBy(p => p.Vendor.Vendor).ThenBy(p => p.Product). ThenBy(p => p.ProductId).Select(p => new UsbProductModel { - ProductId = p.ProductId, ProductName = p.Product, - VendorId = p.Vendor.Id, - VendorName = p.Vendor.Vendor + ProductId = p.ProductId, + ProductName = p.Product, + VendorId = p.Vendor.Id, + VendorName = p.Vendor.Vendor }).ToListAsync()); } } \ No newline at end of file diff --git a/Aaru.Server/Areas/Admin/Controllers/UsbVendorsController.cs b/Aaru.Server/Areas/Admin/Controllers/UsbVendorsController.cs index d1557e78..144ebae8 100644 --- a/Aaru.Server/Areas/Admin/Controllers/UsbVendorsController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/UsbVendorsController.cs @@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class UsbVendorsController : Controller + public sealed class UsbVendorsController : Controller { readonly AaruServerContext _context; @@ -35,17 +35,14 @@ namespace Aaru.Server.Areas.Admin.Controllers return View(new UsbVendorModel { - Vendor = usbVendor.Vendor, VendorId = usbVendor.VendorId, Products = _context. - UsbProducts. - Where(p => p.VendorId == - usbVendor.Id). - OrderBy(p => p.Product). - ThenBy(p => p.ProductId). - Select(p => new UsbProductModel - { - ProductId = p.ProductId, - ProductName = p.Product - }).ToList() + Vendor = usbVendor.Vendor, + VendorId = usbVendor.VendorId, + Products = _context.UsbProducts.Where(p => p.VendorId == usbVendor.Id).OrderBy(p => p.Product). + ThenBy(p => p.ProductId).Select(p => new UsbProductModel + { + ProductId = p.ProductId, + ProductName = p.Product + }).ToList() }); } } diff --git a/Aaru.Server/Areas/Admin/Controllers/UsbsController.cs b/Aaru.Server/Areas/Admin/Controllers/UsbsController.cs index eca8163b..5504a533 100644 --- a/Aaru.Server/Areas/Admin/Controllers/UsbsController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/UsbsController.cs @@ -11,7 +11,7 @@ using Newtonsoft.Json; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class UsbsController : Controller + public sealed class UsbsController : Controller { readonly AaruServerContext _context; @@ -73,16 +73,22 @@ namespace Aaru.Server.Areas.Admin.Controllers { List 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 { - Manufacturer = x.Key.Manufacturer, Product = x.Key.Product, VendorID = x.Key.VendorID, + Manufacturer = x.Key.Manufacturer, + Product = x.Key.Product, + VendorID = x.Key.VendorID, ProductID = x.Key.ProductID }).ToList(); return View(new UsbModelForView { - List = dups, Json = JsonConvert.SerializeObject(dups) + List = dups, + Json = JsonConvert.SerializeObject(dups) }); } diff --git a/Aaru.Server/Areas/Admin/Controllers/VersionsController.cs b/Aaru.Server/Areas/Admin/Controllers/VersionsController.cs index c5d5b294..b880b7b0 100644 --- a/Aaru.Server/Areas/Admin/Controllers/VersionsController.cs +++ b/Aaru.Server/Areas/Admin/Controllers/VersionsController.cs @@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore; namespace Aaru.Server.Areas.Admin.Controllers { [Area("Admin"), Authorize] - public class VersionsController : Controller + public sealed class VersionsController : Controller { readonly AaruServerContext _context; diff --git a/Aaru.Server/Areas/Admin/Views/Atas/Delete.cshtml b/Aaru.Server/Areas/Admin/Views/Atas/Delete.cshtml index 31dafda1..c2e78da9 100644 --- a/Aaru.Server/Areas/Admin/Views/Atas/Delete.cshtml +++ b/Aaru.Server/Areas/Admin/Views/Atas/Delete.cshtml @@ -1,5 +1,5 @@ -@using Aaru.Decoders.ATA @using Aaru.Server.Core +@using Aaru.Decoders.ATA @model Aaru.CommonTypes.Metadata.Ata @{ diff --git a/Aaru.Server/Areas/Admin/Views/Atas/Details.cshtml b/Aaru.Server/Areas/Admin/Views/Atas/Details.cshtml index 717f2af4..66435cf6 100644 --- a/Aaru.Server/Areas/Admin/Views/Atas/Details.cshtml +++ b/Aaru.Server/Areas/Admin/Views/Atas/Details.cshtml @@ -1,5 +1,5 @@ -@using Aaru.Decoders.ATA @using Aaru.Server.Core +@using Aaru.Decoders.ATA @model Aaru.CommonTypes.Metadata.Ata @{ diff --git a/Aaru.Server/Areas/Admin/Views/Mmc/Delete.cshtml b/Aaru.Server/Areas/Admin/Views/Mmc/Delete.cshtml index 82c76ed7..faf56192 100644 --- a/Aaru.Server/Areas/Admin/Views/Mmc/Delete.cshtml +++ b/Aaru.Server/Areas/Admin/Views/Mmc/Delete.cshtml @@ -1,5 +1,5 @@ -@using Aaru.Decoders.SCSI @using Aaru.Server.Core +@using Aaru.Decoders.SCSI @model Aaru.CommonTypes.Metadata.Mmc @{ diff --git a/Aaru.Server/Areas/Admin/Views/Mmc/Details.cshtml b/Aaru.Server/Areas/Admin/Views/Mmc/Details.cshtml index e0330dad..bd13d309 100644 --- a/Aaru.Server/Areas/Admin/Views/Mmc/Details.cshtml +++ b/Aaru.Server/Areas/Admin/Views/Mmc/Details.cshtml @@ -1,5 +1,5 @@ -@using Aaru.Decoders.SCSI @using Aaru.Server.Core +@using Aaru.Decoders.SCSI @model Aaru.CommonTypes.Metadata.Mmc @{ diff --git a/Aaru.Server/Areas/Admin/Views/MmcSds/Delete.cshtml b/Aaru.Server/Areas/Admin/Views/MmcSds/Delete.cshtml index 5bdb50b8..f6b8ed54 100644 --- a/Aaru.Server/Areas/Admin/Views/MmcSds/Delete.cshtml +++ b/Aaru.Server/Areas/Admin/Views/MmcSds/Delete.cshtml @@ -1,5 +1,5 @@ -@using Aaru.Decoders.SecureDigital @using Aaru.Server.Core +@using Aaru.Decoders.SecureDigital @model Aaru.CommonTypes.Metadata.MmcSd @{ diff --git a/Aaru.Server/Areas/Admin/Views/MmcSds/Details.cshtml b/Aaru.Server/Areas/Admin/Views/MmcSds/Details.cshtml index ad2b00bf..477c84ae 100644 --- a/Aaru.Server/Areas/Admin/Views/MmcSds/Details.cshtml +++ b/Aaru.Server/Areas/Admin/Views/MmcSds/Details.cshtml @@ -1,5 +1,5 @@ -@using Aaru.Decoders.SecureDigital @using Aaru.Server.Core +@using Aaru.Decoders.SecureDigital @model Aaru.CommonTypes.Metadata.MmcSd @{ diff --git a/Aaru.Server/Areas/Admin/Views/Scsis/Delete.cshtml b/Aaru.Server/Areas/Admin/Views/Scsis/Delete.cshtml index 87688cd2..6706eff9 100644 --- a/Aaru.Server/Areas/Admin/Views/Scsis/Delete.cshtml +++ b/Aaru.Server/Areas/Admin/Views/Scsis/Delete.cshtml @@ -1,5 +1,5 @@ -@using Aaru.Decoders.SCSI @using Aaru.Server.Core +@using Aaru.Decoders.SCSI @model Aaru.CommonTypes.Metadata.Scsi @{ diff --git a/Aaru.Server/Areas/Admin/Views/Scsis/Details.cshtml b/Aaru.Server/Areas/Admin/Views/Scsis/Details.cshtml index ef1b40c8..66def873 100644 --- a/Aaru.Server/Areas/Admin/Views/Scsis/Details.cshtml +++ b/Aaru.Server/Areas/Admin/Views/Scsis/Details.cshtml @@ -1,5 +1,5 @@ -@using Aaru.Decoders.SCSI @using Aaru.Server.Core +@using Aaru.Decoders.SCSI @model Aaru.CommonTypes.Metadata.Scsi @{ diff --git a/Aaru.Server/Areas/Admin/Views/Scsis/Index.cshtml b/Aaru.Server/Areas/Admin/Views/Scsis/Index.cshtml index 6b648a7b..3f7ac037 100644 --- a/Aaru.Server/Areas/Admin/Views/Scsis/Index.cshtml +++ b/Aaru.Server/Areas/Admin/Views/Scsis/Index.cshtml @@ -1,4 +1,4 @@ -@using Aaru +@using Aaru.Helpers @model IEnumerable @{ diff --git a/Aaru.Server/Areas/Admin/Views/Shared/_Layout.cshtml b/Aaru.Server/Areas/Admin/Views/Shared/_Layout.cshtml index 3cb2269e..993142a8 100644 --- a/Aaru.Server/Areas/Admin/Views/Shared/_Layout.cshtml +++ b/Aaru.Server/Areas/Admin/Views/Shared/_Layout.cshtml @@ -82,10 +82,7 @@ { diff --git a/Aaru.Server/Areas/Admin/Views/Shared/_LoginPartial.cshtml b/Aaru.Server/Areas/Admin/Views/Shared/_LoginPartial.cshtml index 357ece12..d6cb78b8 100644 --- a/Aaru.Server/Areas/Admin/Views/Shared/_LoginPartial.cshtml +++ b/Aaru.Server/Areas/Admin/Views/Shared/_LoginPartial.cshtml @@ -8,10 +8,7 @@ Hello @UserManager.GetUserName(User)! diff --git a/Aaru.Server/Areas/Admin/Views/_ViewImports.cshtml b/Aaru.Server/Areas/Admin/Views/_ViewImports.cshtml index a4320bd8..54c726d6 100644 --- a/Aaru.Server/Areas/Admin/Views/_ViewImports.cshtml +++ b/Aaru.Server/Areas/Admin/Views/_ViewImports.cshtml @@ -1,4 +1,5 @@ @using Aaru.Server @using Aaru.Server.Models -@inject Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet JavaScriptSnippet +@using Microsoft.ApplicationInsights.AspNetCore +@inject JavaScriptSnippet JavaScriptSnippet @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers \ No newline at end of file diff --git a/Aaru.Server/Areas/Identity/Pages/Account/Register.cshtml.cs b/Aaru.Server/Areas/Identity/Pages/Account/Register.cshtml.cs index c4f31100..9794552a 100644 --- a/Aaru.Server/Areas/Identity/Pages/Account/Register.cshtml.cs +++ b/Aaru.Server/Areas/Identity/Pages/Account/Register.cshtml.cs @@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Mvc.RazorPages; namespace Aaru.Server.Areas.Identity.Pages.Account { [AllowAnonymous] - public class RegisterModel : PageModel + public sealed class RegisterModel : PageModel { public IActionResult OnGetAsync(string returnUrl = null) => RedirectToPage("Login"); diff --git a/Aaru.Server/BasicAuthMiddleware.cs b/Aaru.Server/BasicAuthMiddleware.cs index 084dd5e3..0922ccf2 100644 --- a/Aaru.Server/BasicAuthMiddleware.cs +++ b/Aaru.Server/BasicAuthMiddleware.cs @@ -12,23 +12,22 @@ using Microsoft.Extensions.Configuration; namespace Aaru.Server { - public class BasicAuthMiddleware + public sealed class BasicAuthMiddleware { - readonly RequestDelegate next; - readonly string realm; + readonly RequestDelegate _next; + readonly string _realm; public BasicAuthMiddleware(RequestDelegate next, string realm) { - this.next = next; - this.realm = realm; + _next = next; + _realm = realm; } public async Task Invoke(HttpContext context) { string authHeader = context.Request.Headers["Authorization"]; - if(authHeader != null && - authHeader.StartsWith("Basic ")) + if(authHeader?.StartsWith("Basic ") == true) { // Get the encoded username and password string encodedUsernamePassword = @@ -45,7 +44,7 @@ namespace Aaru.Server // Check if login is correct if(IsAuthorized(username, password)) { - await next.Invoke(context); + await _next.Invoke(context); return; } @@ -55,9 +54,9 @@ namespace Aaru.Server context.Response.Headers["WWW-Authenticate"] = "Basic"; // Add realm if it is not null - if(!string.IsNullOrWhiteSpace(realm)) + if(!string.IsNullOrWhiteSpace(_realm)) { - context.Response.Headers["WWW-Authenticate"] += $" realm=\"{realm}\""; + context.Response.Headers["WWW-Authenticate"] += $" realm=\"{_realm}\""; } // Return unauthorized @@ -73,8 +72,7 @@ namespace Aaru.Server string validUser = configuration.GetValue("MetricsAuthentication:Username"); string validPassword = configuration.GetValue("MetricsAuthentication:Password"); - return !string.IsNullOrWhiteSpace(validUser) && - !string.IsNullOrWhiteSpace(validPassword) && + return !string.IsNullOrWhiteSpace(validUser) && !string.IsNullOrWhiteSpace(validPassword) && username.Equals(validUser, StringComparison.InvariantCultureIgnoreCase) && password.Equals(validPassword); } diff --git a/Aaru.Server/Controllers/HomeController.cs b/Aaru.Server/Controllers/HomeController.cs index 8183182b..ba1008a2 100644 --- a/Aaru.Server/Controllers/HomeController.cs +++ b/Aaru.Server/Controllers/HomeController.cs @@ -39,7 +39,7 @@ using Microsoft.AspNetCore.Mvc; namespace Aaru.Server.Controllers { - public class HomeController : Controller + public sealed class HomeController : Controller { readonly IWebHostEnvironment _environment; @@ -59,7 +59,7 @@ namespace Aaru.Server.Controllers ViewBag.Markdown = Markdown.ToHtml(mdcontent); - ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); + ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version?.ToString(); return View(); } @@ -78,7 +78,7 @@ namespace Aaru.Server.Controllers ViewBag.Markdown = Markdown.ToHtml(mdcontent); - ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); + ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version?.ToString(); return View(); } @@ -97,7 +97,7 @@ namespace Aaru.Server.Controllers ViewBag.Markdown = Markdown.ToHtml(mdcontent); - ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); + ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version?.ToString(); return View(); } @@ -116,7 +116,7 @@ namespace Aaru.Server.Controllers ViewBag.Markdown = Markdown.ToHtml(mdcontent); - ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); + ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version?.ToString(); return View(); } @@ -135,13 +135,13 @@ namespace Aaru.Server.Controllers ViewBag.Markdown = Markdown.ToHtml(mdcontent); - ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); + ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version?.ToString(); return View(); } [Route("CONTRIBUTING")] - public ActionResult CONTRIBUTING() + public ActionResult Contributing() { var sr = new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), @@ -173,7 +173,7 @@ namespace Aaru.Server.Controllers ViewBag.Markdown = Markdown.ToHtml(mdcontent); - ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); + ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version?.ToString(); return View(); } @@ -192,13 +192,13 @@ namespace Aaru.Server.Controllers ViewBag.Markdown = Markdown.ToHtml(mdcontent); - ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); + ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version?.ToString(); return View(); } [Route("TODO")] - public ActionResult TODO() + public ActionResult Todo() { var sr = new StreamReader(Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), @@ -211,7 +211,7 @@ namespace Aaru.Server.Controllers ViewBag.Markdown = Markdown.ToHtml(mdcontent); - ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); + ViewBag.lblVersion = Assembly.GetExecutingAssembly().GetName().Version?.ToString(); return View(); } diff --git a/Aaru.Server/Controllers/ReportController.cs b/Aaru.Server/Controllers/ReportController.cs index 54290662..40453454 100644 --- a/Aaru.Server/Controllers/ReportController.cs +++ b/Aaru.Server/Controllers/ReportController.cs @@ -33,19 +33,22 @@ using System; using System.Collections.Generic; using System.Linq; -using Aaru.CommonTypes.Metadata; using Aaru.CommonTypes.Structs.Devices.SCSI; using Aaru.Decoders.PCMCIA; using Aaru.Decoders.SCSI; +using Aaru.Helpers; +using Aaru.Server.Core; using Aaru.Server.Models; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Routing; +using Ata = Aaru.CommonTypes.Metadata.Ata; using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry; +using TestedMedia = Aaru.CommonTypes.Metadata.TestedMedia; using Tuple = Aaru.Decoders.PCMCIA.Tuple; namespace Aaru.Server.Controllers { - public class ReportController : Controller + public sealed class ReportController : Controller { readonly AaruServerContext _ctx; @@ -81,8 +84,7 @@ namespace Aaru.Server.Controllers string usbProductDescription = null; UsbProduct dbProduct = - _ctx.UsbProducts.FirstOrDefault(p => p.ProductId == report.USB.ProductID && - p.Vendor != null && + _ctx.UsbProducts.FirstOrDefault(p => p.ProductId == report.USB.ProductID && p.Vendor != null && p.Vendor.VendorId == report.USB.VendorID); if(dbProduct is null) @@ -100,7 +102,8 @@ namespace Aaru.Server.Controllers ViewBag.UsbItem = new Item { - Manufacturer = report.USB.Manufacturer, Product = report.USB.Product, + Manufacturer = report.USB.Manufacturer, + Product = report.USB.Product, VendorDescription = usbVendorDescription != null ? $"0x{report.USB.VendorID:x4} ({usbVendorDescription})" : $"0x{report.USB.VendorID:x4}", @@ -113,7 +116,8 @@ namespace Aaru.Server.Controllers if(report.FireWire != null) ViewBag.FireWireItem = new Item { - Manufacturer = report.FireWire.Manufacturer, Product = report.FireWire.Product, + Manufacturer = report.FireWire.Manufacturer, + Product = report.FireWire.Product, VendorDescription = $"0x{report.FireWire.VendorID:x8}", ProductDescription = $"0x{report.FireWire.ProductID:x8}" }; @@ -122,9 +126,11 @@ namespace Aaru.Server.Controllers { ViewBag.PcmciaItem = new PcmciaItem { - Manufacturer = report.PCMCIA.Manufacturer, Product = report.PCMCIA.ProductName, + Manufacturer = report.PCMCIA.Manufacturer, + Product = report.PCMCIA.ProductName, VendorDescription = $"0x{report.PCMCIA.ManufacturerCode:x4}", - ProductDescription = $"0x{report.PCMCIA.CardCode:x4}", Compliance = report.PCMCIA.Compliance + ProductDescription = $"0x{report.PCMCIA.CardCode:x4}", + Compliance = report.PCMCIA.Compliance }; Tuple[] tuples = CIS.GetTuples(report.PCMCIA.CIS); @@ -214,17 +220,15 @@ namespace Aaru.Server.Controllers bool removable = true; List testedMedia = null; - bool ata = false; bool atapi = false; bool sscMedia = false; if(report.ATA != null || report.ATAPI != null) { - ata = true; List ataOneValue = new List(); Dictionary ataTwoValue = new Dictionary(); - CommonTypes.Metadata.Ata ataReport; + Ata ataReport; if(report.ATAPI != null) { @@ -247,7 +251,8 @@ namespace Aaru.Server.Controllers else ViewBag.lblAtaDeviceType = "ATA device"; - Ata.Report(ataReport, cfa, atapi, ref removable, ref ataOneValue, ref ataTwoValue, ref testedMedia); + Core.Ata.Report(ataReport, cfa, atapi, ref removable, ref ataOneValue, ref ataTwoValue, + ref testedMedia); ViewBag.repAtaOne = ataOneValue; ViewBag.repAtaTwo = ataTwoValue; @@ -371,8 +376,7 @@ namespace Aaru.Server.Controllers 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"); else if((report.SCSI.ReadCapabilities.Blocks * report.SCSI.ReadCapabilities.BlockSize) / - 1024 / - 1024 > 1000) + 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"); else @@ -506,7 +510,7 @@ namespace Aaru.Server.Controllers testedMedia != null) { List mediaOneValue = new List(); - App_Start.TestedMedia.Report(testedMedia, ref mediaOneValue); + Core.TestedMedia.Report(testedMedia, ref mediaOneValue); if(mediaOneValue.Count > 0) ViewBag.repTestedMedia = mediaOneValue; @@ -532,7 +536,7 @@ namespace Aaru.Server.Controllers public string VendorDescription; } - public class PcmciaItem : Item + public sealed class PcmciaItem : Item { public string Compliance; } diff --git a/Aaru.Server/Controllers/StatsController.cs b/Aaru.Server/Controllers/StatsController.cs index 18f8418d..08bbf315 100644 --- a/Aaru.Server/Controllers/StatsController.cs +++ b/Aaru.Server/Controllers/StatsController.cs @@ -40,6 +40,7 @@ using System.Xml; using System.Xml.Serialization; using Aaru.CommonTypes.Interop; using Aaru.CommonTypes.Metadata; +using Aaru.Server.Core; using Aaru.Server.Models; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; @@ -50,15 +51,15 @@ using Version = Aaru.Server.Models.Version; namespace Aaru.Server.Controllers { /// Renders a page with statistics, list of media type, devices, etc - public class StatsController : Controller + public sealed class StatsController : Controller { - readonly AaruServerContext ctx; - readonly IWebHostEnvironment env; + readonly AaruServerContext _ctx; + readonly IWebHostEnvironment _env; public StatsController(IWebHostEnvironment environment, AaruServerContext context) { - env = environment; - ctx = context; + _env = environment; + _ctx = context; } public ActionResult Index() @@ -67,7 +68,7 @@ namespace Aaru.Server.Controllers try { - if(System.IO.File.Exists(Path.Combine(env.ContentRootPath ?? throw new InvalidOperationException(), + if(System.IO.File.Exists(Path.Combine(_env.ContentRootPath ?? throw new InvalidOperationException(), "Statistics", "Statistics.xml"))) try { @@ -76,7 +77,7 @@ namespace Aaru.Server.Controllers var xs = new XmlSerializer(statistics.GetType()); FileStream fs = - WaitForFile(Path.Combine(env.ContentRootPath ?? throw new InvalidOperationException(), "Statistics", "Statistics.xml"), + WaitForFile(Path.Combine(_env.ContentRootPath ?? throw new InvalidOperationException(), "Statistics", "Statistics.xml"), FileMode.Open, FileAccess.Read, FileShare.Read); statistics = (Stats)xs.Deserialize(fs); @@ -84,19 +85,20 @@ namespace Aaru.Server.Controllers StatsConverter.Convert(statistics); - System.IO.File.Delete(Path.Combine(env.ContentRootPath ?? throw new InvalidOperationException(), - "Statistics", "Statistics.xml")); + System.IO.File. + Delete(Path.Combine(_env.ContentRootPath ?? throw new InvalidOperationException(), + "Statistics", "Statistics.xml")); } catch(XmlException) { // Do nothing } - if(ctx.OperatingSystems.Any()) + if(_ctx.OperatingSystems.Any()) { List operatingSystems = new List(); - foreach(OperatingSystem nvs in ctx.OperatingSystems) + foreach(OperatingSystem nvs in _ctx.OperatingSystems) operatingSystems.Add(new NameValueStats { name = @@ -107,40 +109,41 @@ namespace Aaru.Server.Controllers ViewBag.repOperatingSystems = operatingSystems.OrderBy(os => os.name).ToList(); } - if(ctx.Versions.Any()) + if(_ctx.Versions.Any()) { List versions = new List(); - foreach(Version nvs in ctx.Versions) + foreach(Version nvs in _ctx.Versions) 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 }); ViewBag.repVersions = versions.OrderBy(ver => ver.name).ToList(); } - if(ctx.Commands.Any()) - ViewBag.repCommands = ctx.Commands.OrderBy(c => c.Name).ToList(); + if(_ctx.Commands.Any()) + ViewBag.repCommands = _ctx.Commands.OrderBy(c => c.Name).ToList(); - if(ctx.Filters.Any()) - ViewBag.repFilters = ctx.Filters.OrderBy(filter => filter.Name).ToList(); + if(_ctx.Filters.Any()) + ViewBag.repFilters = _ctx.Filters.OrderBy(filter => filter.Name).ToList(); - if(ctx.MediaFormats.Any()) - ViewBag.repMediaImages = ctx.MediaFormats.OrderBy(filter => filter.Name).ToList(); + if(_ctx.MediaFormats.Any()) + ViewBag.repMediaImages = _ctx.MediaFormats.OrderBy(filter => filter.Name).ToList(); - if(ctx.Partitions.Any()) - ViewBag.repPartitions = ctx.Partitions.OrderBy(filter => filter.Name).ToList(); + if(_ctx.Partitions.Any()) + ViewBag.repPartitions = _ctx.Partitions.OrderBy(filter => filter.Name).ToList(); - if(ctx.Filesystems.Any()) - ViewBag.repFilesystems = ctx.Filesystems.OrderBy(filter => filter.Name).ToList(); + if(_ctx.Filesystems.Any()) + ViewBag.repFilesystems = _ctx.Filesystems.OrderBy(filter => filter.Name).ToList(); - if(ctx.Medias.Any()) + if(_ctx.Medias.Any()) { List realMedia = new List(); List virtualMedia = new List(); - foreach(Media nvs in ctx.Medias) + foreach(Media nvs in _ctx.Medias) try { (string type, string subType) mediaType = @@ -150,12 +153,16 @@ namespace Aaru.Server.Controllers if(nvs.Real) 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 }); } catch @@ -163,12 +170,16 @@ namespace Aaru.Server.Controllers if(nvs.Real) 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 }); } @@ -181,11 +192,11 @@ namespace Aaru.Server.Controllers virtualMedia.OrderBy(media => media.Type).ThenBy(media => media.SubType).ToList(); } - if(ctx.DeviceStats.Any()) + if(_ctx.DeviceStats.Any()) { List devices = new List(); - foreach(DeviceStat device in ctx.DeviceStats.ToList()) + foreach(DeviceStat device in _ctx.DeviceStats.ToList()) { string xmlFile; @@ -204,14 +215,14 @@ namespace Aaru.Server.Controllers xmlFile = xmlFile.Replace('/', '_').Replace('\\', '_').Replace('?', '_'); - if(System.IO.File.Exists(Path.Combine(env.ContentRootPath, "Reports", xmlFile))) + if(System.IO.File.Exists(Path.Combine(_env.ContentRootPath, "Reports", xmlFile))) { var deviceReport = new DeviceReport(); var xs = new XmlSerializer(deviceReport.GetType()); FileStream fs = - WaitForFile(Path.Combine(env.ContentRootPath ?? throw new InvalidOperationException(), "Reports", xmlFile), + WaitForFile(Path.Combine(_env.ContentRootPath ?? throw new InvalidOperationException(), "Reports", xmlFile), FileMode.Open, FileAccess.Read, FileShare.Read); deviceReport = (DeviceReport)xs.Deserialize(fs); @@ -219,17 +230,19 @@ namespace Aaru.Server.Controllers var deviceReportV2 = new DeviceReportV2(deviceReport); - device.Report = ctx.Devices.Add(new Device(deviceReportV2)).Entity; - ctx.SaveChanges(); + device.Report = _ctx.Devices.Add(new Device(deviceReportV2)).Entity; + _ctx.SaveChanges(); System.IO.File. - Delete(Path.Combine(env.ContentRootPath ?? throw new InvalidOperationException(), + Delete(Path.Combine(_env.ContentRootPath ?? throw new InvalidOperationException(), "Reports", xmlFile)); } devices.Add(new DeviceItem { - Manufacturer = device.Manufacturer, Model = device.Model, Revision = device.Revision, + Manufacturer = device.Manufacturer, + Model = device.Model, + Revision = device.Revision, Bus = device.Bus, ReportId = device.Report != null && device.Report.Id != 0 ? device.Report.Id : 0 }); @@ -275,12 +288,13 @@ namespace Aaru.Server.Controllers public IActionResult GetOsData() { - var query = ctx.OperatingSystems.GroupBy(x => new + var query = _ctx.OperatingSystems.GroupBy(x => new { x.Name }, x => x.Count).Select(g => new { - g.Key.Name, Count = g.Sum() + g.Key.Name, + Count = g.Sum() }); string[][] result = new string[2][]; @@ -297,13 +311,13 @@ namespace Aaru.Server.Controllers { string[][] result = { - ctx.OperatingSystems.Where(o => o.Name == PlatformID.Linux.ToString()).OrderByDescending(o => o.Count). - Take(10). - Select(x => - $"{DetectOS.GetPlatformName(PlatformID.Linux, x.Version)}{(string.IsNullOrEmpty(x.Version) ? "" : " ")}{x.Version}"). - ToArray(), - ctx.OperatingSystems.Where(o => o.Name == PlatformID.Linux.ToString()).OrderByDescending(o => o.Count). - Take(10).Select(x => x.Count.ToString()).ToArray() + _ctx.OperatingSystems.Where(o => o.Name == PlatformID.Linux.ToString()).OrderByDescending(o => o.Count). + Take(10). + Select(x => + $"{DetectOS.GetPlatformName(PlatformID.Linux, x.Version)}{(string.IsNullOrEmpty(x.Version) ? "" : " ")}{x.Version}"). + ToArray(), + _ctx.OperatingSystems.Where(o => o.Name == PlatformID.Linux.ToString()).OrderByDescending(o => o.Count). + Take(10).Select(x => x.Count.ToString()).ToArray() }; if(result[0].Length < 10) @@ -311,7 +325,7 @@ namespace Aaru.Server.Controllers result[0][9] = "Other"; - result[1][9] = (ctx.OperatingSystems.Where(o => o.Name == PlatformID.Linux.ToString()).Sum(o => o.Count) - + result[1][9] = (_ctx.OperatingSystems.Where(o => o.Name == PlatformID.Linux.ToString()).Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)).ToString(); return Json(result); @@ -321,13 +335,13 @@ namespace Aaru.Server.Controllers { string[][] result = { - ctx.OperatingSystems.Where(o => o.Name == PlatformID.MacOSX.ToString()).OrderByDescending(o => o.Count). - Take(10). - Select(x => - $"{DetectOS.GetPlatformName(PlatformID.MacOSX, x.Version)}{(string.IsNullOrEmpty(x.Version) ? "" : " ")}{x.Version}"). - ToArray(), - ctx.OperatingSystems.Where(o => o.Name == PlatformID.MacOSX.ToString()).OrderByDescending(o => o.Count). - Take(10).Select(x => x.Count.ToString()).ToArray() + _ctx.OperatingSystems.Where(o => o.Name == PlatformID.MacOSX.ToString()). + OrderByDescending(o => o.Count).Take(10). + Select(x => + $"{DetectOS.GetPlatformName(PlatformID.MacOSX, x.Version)}{(string.IsNullOrEmpty(x.Version) ? "" : " ")}{x.Version}"). + ToArray(), + _ctx.OperatingSystems.Where(o => o.Name == PlatformID.MacOSX.ToString()). + OrderByDescending(o => o.Count).Take(10).Select(x => x.Count.ToString()).ToArray() }; if(result[0].Length < 10) @@ -335,7 +349,7 @@ namespace Aaru.Server.Controllers result[0][9] = "Other"; - result[1][9] = (ctx.OperatingSystems.Where(o => o.Name == PlatformID.MacOSX.ToString()).Sum(o => o.Count) - + result[1][9] = (_ctx.OperatingSystems.Where(o => o.Name == PlatformID.MacOSX.ToString()).Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)).ToString(); return Json(result); @@ -345,13 +359,13 @@ namespace Aaru.Server.Controllers { string[][] result = { - ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString()). - OrderByDescending(o => o.Count).Take(10). - Select(x => - $"{DetectOS.GetPlatformName(PlatformID.Win32NT, x.Version)}{(string.IsNullOrEmpty(x.Version) ? "" : " ")}{x.Version}"). - ToArray(), - ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString()). - OrderByDescending(o => o.Count).Take(10).Select(x => x.Count.ToString()).ToArray() + _ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString()). + OrderByDescending(o => o.Count).Take(10). + Select(x => + $"{DetectOS.GetPlatformName(PlatformID.Win32NT, x.Version)}{(string.IsNullOrEmpty(x.Version) ? "" : " ")}{x.Version}"). + ToArray(), + _ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString()). + OrderByDescending(o => o.Count).Take(10).Select(x => x.Count.ToString()).ToArray() }; if(result[0].Length < 10) @@ -359,8 +373,9 @@ namespace Aaru.Server.Controllers result[0][9] = "Other"; - result[1][9] = (ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString()).Sum(o => o.Count) - - result[1].Take(9).Sum(long.Parse)).ToString(); + result[1][9] = + (_ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString()).Sum(o => o.Count) - + result[1].Take(9).Sum(long.Parse)).ToString(); return Json(result); } @@ -369,9 +384,9 @@ namespace Aaru.Server.Controllers { string[][] result = { - ctx.Versions.OrderByDescending(o => o.Count).Take(10). - Select(v => v.Name == "previous" ? "Previous than 3.4.99.0" : v.Name).ToArray(), - ctx.Versions.OrderByDescending(o => o.Count).Take(10).Select(x => x.Count.ToString()).ToArray() + _ctx.Versions.OrderByDescending(o => o.Count).Take(10). + Select(v => v.Name == "previous" ? "Previous than 3.4.99.0" : v.Name).ToArray(), + _ctx.Versions.OrderByDescending(o => o.Count).Take(10).Select(x => x.Count.ToString()).ToArray() }; if(result[0].Length < 10) @@ -379,7 +394,7 @@ namespace Aaru.Server.Controllers result[0][9] = "Other"; - result[1][9] = (ctx.Versions.Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)).ToString(); + result[1][9] = (_ctx.Versions.Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)).ToString(); return Json(result); } @@ -388,8 +403,8 @@ namespace Aaru.Server.Controllers { string[][] result = { - ctx.Commands.OrderByDescending(o => o.Count).Take(10).Select(v => v.Name).ToArray(), - ctx.Commands.OrderByDescending(o => o.Count).Take(10).Select(x => x.Count.ToString()).ToArray() + _ctx.Commands.OrderByDescending(o => o.Count).Take(10).Select(v => v.Name).ToArray(), + _ctx.Commands.OrderByDescending(o => o.Count).Take(10).Select(x => x.Count.ToString()).ToArray() }; if(result[0].Length < 10) @@ -397,7 +412,7 @@ namespace Aaru.Server.Controllers result[0][9] = "Other"; - result[1][9] = (ctx.Commands.Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)).ToString(); + result[1][9] = (_ctx.Commands.Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)).ToString(); return Json(result); } @@ -406,8 +421,8 @@ namespace Aaru.Server.Controllers { string[][] result = { - ctx.Filters.OrderByDescending(o => o.Count).Take(10).Select(v => v.Name).ToArray(), - ctx.Filters.OrderByDescending(o => o.Count).Take(10).Select(x => x.Count.ToString()).ToArray() + _ctx.Filters.OrderByDescending(o => o.Count).Take(10).Select(v => v.Name).ToArray(), + _ctx.Filters.OrderByDescending(o => o.Count).Take(10).Select(x => x.Count.ToString()).ToArray() }; if(result[0].Length < 10) @@ -415,7 +430,7 @@ namespace Aaru.Server.Controllers result[0][9] = "Other"; - result[1][9] = (ctx.Filters.Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)).ToString(); + result[1][9] = (_ctx.Filters.Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)).ToString(); return Json(result); } @@ -424,8 +439,8 @@ namespace Aaru.Server.Controllers { string[][] result = { - ctx.MediaFormats.OrderByDescending(o => o.Count).Take(10).Select(v => v.Name).ToArray(), - ctx.MediaFormats.OrderByDescending(o => o.Count).Take(10).Select(x => x.Count.ToString()).ToArray() + _ctx.MediaFormats.OrderByDescending(o => o.Count).Take(10).Select(v => v.Name).ToArray(), + _ctx.MediaFormats.OrderByDescending(o => o.Count).Take(10).Select(x => x.Count.ToString()).ToArray() }; if(result[0].Length < 10) @@ -433,7 +448,7 @@ namespace Aaru.Server.Controllers result[0][9] = "Other"; - result[1][9] = (ctx.MediaFormats.Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)).ToString(); + result[1][9] = (_ctx.MediaFormats.Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)).ToString(); return Json(result); } @@ -442,8 +457,8 @@ namespace Aaru.Server.Controllers { string[][] result = { - ctx.Partitions.OrderByDescending(o => o.Count).Take(10).Select(v => v.Name).ToArray(), - ctx.Partitions.OrderByDescending(o => o.Count).Take(10).Select(x => x.Count.ToString()).ToArray() + _ctx.Partitions.OrderByDescending(o => o.Count).Take(10).Select(v => v.Name).ToArray(), + _ctx.Partitions.OrderByDescending(o => o.Count).Take(10).Select(x => x.Count.ToString()).ToArray() }; if(result[0].Length < 10) @@ -451,7 +466,7 @@ namespace Aaru.Server.Controllers result[0][9] = "Other"; - result[1][9] = (ctx.Partitions.Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)).ToString(); + result[1][9] = (_ctx.Partitions.Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)).ToString(); return Json(result); } @@ -460,8 +475,8 @@ namespace Aaru.Server.Controllers { string[][] result = { - ctx.Filesystems.OrderByDescending(o => o.Count).Take(10).Select(v => v.Name).ToArray(), - ctx.Filesystems.OrderByDescending(o => o.Count).Take(10).Select(x => x.Count.ToString()).ToArray() + _ctx.Filesystems.OrderByDescending(o => o.Count).Take(10).Select(v => v.Name).ToArray(), + _ctx.Filesystems.OrderByDescending(o => o.Count).Take(10).Select(x => x.Count.ToString()).ToArray() }; if(result[0].Length < 10) @@ -469,14 +484,14 @@ namespace Aaru.Server.Controllers result[0][9] = "Other"; - result[1][9] = (ctx.Filesystems.Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)).ToString(); + result[1][9] = (_ctx.Filesystems.Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)).ToString(); return Json(result); } public IActionResult GetVirtualMediaData() { - Media[] virtualMedias = ctx.Medias.Where(o => !o.Real).OrderByDescending(o => o.Count).Take(10).ToArray(); + Media[] virtualMedias = _ctx.Medias.Where(o => !o.Real).OrderByDescending(o => o.Count).Take(10).ToArray(); foreach(Media media in virtualMedias) { @@ -504,7 +519,7 @@ namespace Aaru.Server.Controllers result[0][9] = "Other"; - result[1][9] = (ctx.Medias.Where(o => !o.Real).Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)). + result[1][9] = (_ctx.Medias.Where(o => !o.Real).Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)). ToString(); return Json(result); @@ -512,7 +527,7 @@ namespace Aaru.Server.Controllers public IActionResult GetRealMediaData() { - Media[] realMedias = ctx.Medias.Where(o => o.Real).OrderByDescending(o => o.Count).Take(10).ToArray(); + Media[] realMedias = _ctx.Medias.Where(o => o.Real).OrderByDescending(o => o.Count).Take(10).ToArray(); foreach(Media media in realMedias) { @@ -540,7 +555,7 @@ namespace Aaru.Server.Controllers result[0][9] = "Other"; - result[1][9] = (ctx.Medias.Where(o => o.Real).Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)). + result[1][9] = (_ctx.Medias.Where(o => o.Real).Sum(o => o.Count) - result[1].Take(9).Sum(long.Parse)). ToString(); return Json(result); @@ -548,12 +563,14 @@ namespace Aaru.Server.Controllers public IActionResult GetDevicesByBusData() { - var data = ctx.DeviceStats.Select(d => d.Bus).Distinct().Select(deviceBus => new + var data = _ctx.DeviceStats.Select(d => d.Bus).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(); string[][] result = @@ -574,14 +591,16 @@ namespace Aaru.Server.Controllers public IActionResult GetDevicesByManufacturerData() { - List devices = ctx.Devices.Where(d => d.Manufacturer != null && d.Manufacturer != "").ToList(); + List devices = _ctx.Devices.Where(d => d.Manufacturer != null && d.Manufacturer != "").ToList(); var data = devices.Select(d => d.Manufacturer.ToLowerInvariant()).Distinct().Select(manufacturer => new { - manufacturer, manufacturerCount = devices.Count(d => d.Manufacturer?.ToLowerInvariant() == manufacturer) + manufacturer, + manufacturerCount = devices.Count(d => d.Manufacturer?.ToLowerInvariant() == manufacturer) }).Select(t => new { - Name = t.manufacturer, Count = t.manufacturerCount + Name = t.manufacturer, + Count = t.manufacturerCount }).ToList(); string[][] result = diff --git a/Aaru.Server/Controllers/UpdateController.cs b/Aaru.Server/Controllers/UpdateController.cs index b959abbc..4a439a38 100644 --- a/Aaru.Server/Controllers/UpdateController.cs +++ b/Aaru.Server/Controllers/UpdateController.cs @@ -37,6 +37,7 @@ using System.Linq; using System.Net; using Aaru.CommonTypes.Metadata; using Aaru.Dto; +using Aaru.Helpers; using Aaru.Server.Models; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -44,7 +45,7 @@ using Newtonsoft.Json; namespace Aaru.Server.Controllers { - public class UpdateController : Controller + public sealed class UpdateController : Controller { readonly AaruServerContext _ctx; @@ -63,7 +64,8 @@ namespace Aaru.Server.Controllers foreach(UsbVendor vendor in _ctx.UsbVendors.Where(v => v.ModifiedWhen > lastSync)) sync.UsbVendors.Add(new UsbVendorDto { - VendorId = vendor.VendorId, Vendor = vendor.Vendor + VendorId = vendor.VendorId, + Vendor = vendor.Vendor }); sync.UsbProducts = new List(); @@ -71,8 +73,10 @@ namespace Aaru.Server.Controllers foreach(UsbProduct product in _ctx.UsbProducts.Include(p => p.Vendor).Where(p => p.ModifiedWhen > lastSync)) sync.UsbProducts.Add(new UsbProductDto { - Id = product.Id, Product = product.Product, ProductId = product.ProductId, - VendorId = product.Vendor.VendorId + Id = product.Id, + Product = product.Product, + ProductId = product.ProductId, + VendorId = product.Vendor.VendorId }); sync.Offsets = new List(); @@ -103,7 +107,9 @@ namespace Aaru.Server.Controllers return new ContentResult { - StatusCode = (int)HttpStatusCode.OK, Content = sw.ToString(), ContentType = "application/json" + StatusCode = (int)HttpStatusCode.OK, + Content = sw.ToString(), + ContentType = "application/json" }; } } diff --git a/Aaru.Server/Controllers/UploadReportController.cs b/Aaru.Server/Controllers/UploadReportController.cs index 927f0ba7..e27434fa 100644 --- a/Aaru.Server/Controllers/UploadReportController.cs +++ b/Aaru.Server/Controllers/UploadReportController.cs @@ -50,7 +50,7 @@ using Newtonsoft.Json; namespace Aaru.Server.Controllers { - public class UploadReportController : Controller + public sealed class UploadReportController : Controller { readonly AaruServerContext _ctx; readonly IWebHostEnvironment _environment; @@ -68,7 +68,8 @@ namespace Aaru.Server.Controllers { var response = new ContentResult { - StatusCode = (int)HttpStatusCode.OK, ContentType = "text/plain" + StatusCode = (int)HttpStatusCode.OK, + ContentType = "text/plain" }; try @@ -92,10 +93,11 @@ namespace Aaru.Server.Controllers var reportV2 = new DeviceReportV2(newReport); var jsonSw = new StringWriter(); - jsonSw.Write(JsonConvert.SerializeObject(reportV2, Formatting.Indented, new JsonSerializerSettings - { - NullValueHandling = NullValueHandling.Ignore - })); + await jsonSw.WriteAsync(JsonConvert.SerializeObject(reportV2, Formatting.Indented, + new JsonSerializerSettings + { + NullValueHandling = NullValueHandling.Ignore + })); string reportV2String = jsonSw.ToString(); jsonSw.Close(); @@ -185,23 +187,24 @@ namespace Aaru.Server.Controllers } } - _ctx.Reports.Add(newUploadedReport); - _ctx.SaveChanges(); + await _ctx.Reports.AddAsync(newUploadedReport); + await _ctx.SaveChangesAsync(); 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")); + await pgp.EncryptAsync(pgpIn, pgpOut, + Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), + "public.asc")); pgpOut.Position = 0; reportV2String = Encoding.UTF8.GetString(pgpOut.ToArray()); var message = new MimeMessage { - Subject = "New device report (old version)", Body = new TextPart("plain") + Subject = "New device report (old version)", + Body = new TextPart("plain") { Text = reportV2String } @@ -212,9 +215,9 @@ namespace Aaru.Server.Controllers using(var client = new SmtpClient()) { - client.Connect("mail.claunia.com", 25, false); - client.Send(message); - client.Disconnect(true); + await client.ConnectAsync("mail.claunia.com", 25, false); + await client.SendAsync(message); + await client.DisconnectAsync(true); } response.Content = "ok"; @@ -242,7 +245,8 @@ namespace Aaru.Server.Controllers { var response = new ContentResult { - StatusCode = (int)HttpStatusCode.OK, ContentType = "text/plain" + StatusCode = (int)HttpStatusCode.OK, + ContentType = "text/plain" }; try @@ -345,23 +349,24 @@ namespace Aaru.Server.Controllers } } - _ctx.Reports.Add(newUploadedReport); - _ctx.SaveChanges(); + await _ctx.Reports.AddAsync(newUploadedReport); + await _ctx.SaveChangesAsync(); 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")); + await pgp.EncryptAsync(pgpIn, pgpOut, + Path.Combine(_environment.ContentRootPath ?? throw new InvalidOperationException(), + "public.asc")); pgpOut.Position = 0; reportJson = Encoding.UTF8.GetString(pgpOut.ToArray()); var message = new MimeMessage { - Subject = "New device report", Body = new TextPart("plain") + Subject = "New device report", + Body = new TextPart("plain") { Text = reportJson } @@ -372,9 +377,9 @@ namespace Aaru.Server.Controllers using(var client = new SmtpClient()) { - client.Connect("mail.claunia.com", 25, false); - client.Send(message); - client.Disconnect(true); + await client.ConnectAsync("mail.claunia.com", 25, false); + await client.SendAsync(message); + await client.DisconnectAsync(true); } response.Content = "ok"; diff --git a/Aaru.Server/Controllers/UploadStatsController.cs b/Aaru.Server/Controllers/UploadStatsController.cs index 17f7cca7..b12bcbbc 100644 --- a/Aaru.Server/Controllers/UploadStatsController.cs +++ b/Aaru.Server/Controllers/UploadStatsController.cs @@ -35,12 +35,11 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Net; -using System.Threading; using System.Threading.Tasks; using System.Xml.Serialization; using Aaru.CommonTypes.Metadata; +using Aaru.Server.Core; using Aaru.Server.Models; -using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; @@ -49,16 +48,11 @@ using Version = Aaru.Server.Models.Version; namespace Aaru.Server.Controllers { - public class UploadStatsController : Controller + public sealed class UploadStatsController : Controller { readonly AaruServerContext _ctx; - IWebHostEnvironment _environment; - public UploadStatsController(IWebHostEnvironment environment, AaruServerContext ctx) - { - _environment = environment; - _ctx = ctx; - } + public UploadStatsController(AaruServerContext ctx) => _ctx = ctx; /// Receives statistics from Aaru.Core, processes them and adds them to a server-side global statistics XML /// HTTP response @@ -67,7 +61,8 @@ namespace Aaru.Server.Controllers { var response = new ContentResult { - StatusCode = (int)HttpStatusCode.OK, ContentType = "text/plain" + StatusCode = (int)HttpStatusCode.OK, + ContentType = "text/plain" }; try @@ -93,7 +88,7 @@ namespace Aaru.Server.Controllers return response; } - catch(Exception ex) + catch(Exception) { #if DEBUG if(Debugger.IsAttached) @@ -112,7 +107,8 @@ namespace Aaru.Server.Controllers { var response = new ContentResult { - StatusCode = (int)HttpStatusCode.OK, ContentType = "text/plain" + StatusCode = (int)HttpStatusCode.OK, + ContentType = "text/plain" }; try @@ -136,9 +132,10 @@ namespace Aaru.Server.Controllers Command existing = _ctx.Commands.FirstOrDefault(c => c.Name == nvs.name); if(existing == null) - _ctx.Commands.Add(new Command + await _ctx.Commands.AddAsync(new Command { - Name = nvs.name, Count = nvs.Value + Name = nvs.name, + Count = nvs.Value }); else existing.Count += nvs.Value; @@ -150,9 +147,10 @@ namespace Aaru.Server.Controllers Version existing = _ctx.Versions.FirstOrDefault(c => c.Name == nvs.name); if(existing == null) - _ctx.Versions.Add(new Version + await _ctx.Versions.AddAsync(new Version { - Name = nvs.name, Count = nvs.Value + Name = nvs.name, + Count = nvs.Value }); else existing.Count += nvs.Value; @@ -164,9 +162,10 @@ namespace Aaru.Server.Controllers Filesystem existing = _ctx.Filesystems.FirstOrDefault(c => c.Name == nvs.name); if(existing == null) - _ctx.Filesystems.Add(new Filesystem + await _ctx.Filesystems.AddAsync(new Filesystem { - Name = nvs.name, Count = nvs.Value + Name = nvs.name, + Count = nvs.Value }); else existing.Count += nvs.Value; @@ -178,9 +177,10 @@ namespace Aaru.Server.Controllers Partition existing = _ctx.Partitions.FirstOrDefault(c => c.Name == nvs.name); if(existing == null) - _ctx.Partitions.Add(new Partition + await _ctx.Partitions.AddAsync(new Partition { - Name = nvs.name, Count = nvs.Value + Name = nvs.name, + Count = nvs.Value }); else existing.Count += nvs.Value; @@ -192,9 +192,10 @@ namespace Aaru.Server.Controllers MediaFormat existing = _ctx.MediaFormats.FirstOrDefault(c => c.Name == nvs.name); if(existing == null) - _ctx.MediaFormats.Add(new MediaFormat + await _ctx.MediaFormats.AddAsync(new MediaFormat { - Name = nvs.name, Count = nvs.Value + Name = nvs.name, + Count = nvs.Value }); else existing.Count += nvs.Value; @@ -206,9 +207,10 @@ namespace Aaru.Server.Controllers Filter existing = _ctx.Filters.FirstOrDefault(c => c.Name == nvs.name); if(existing == null) - _ctx.Filters.Add(new Filter + await _ctx.Filters.AddAsync(new Filter { - Name = nvs.name, Count = nvs.Value + Name = nvs.name, + Count = nvs.Value }); else existing.Count += nvs.Value; @@ -222,10 +224,11 @@ namespace Aaru.Server.Controllers c.Version == operatingSystem.version); if(existing == null) - _ctx.OperatingSystems.Add(new OperatingSystem + await _ctx.OperatingSystems.AddAsync(new OperatingSystem { - Name = operatingSystem.name, Version = operatingSystem.version, - Count = operatingSystem.Value + Name = operatingSystem.name, + Version = operatingSystem.version, + Count = operatingSystem.Value }); else existing.Count += operatingSystem.Value; @@ -237,29 +240,33 @@ namespace Aaru.Server.Controllers Media existing = _ctx.Medias.FirstOrDefault(c => c.Type == media.type && c.Real == media.real); if(existing == null) - _ctx.Medias.Add(new Media + 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 existing.Count += media.Value; } if(newstats.Devices != null) - foreach(DeviceStats device in newstats.Devices) + foreach(DeviceStats device in from device in newstats.Devices let existing = + _ctx.DeviceStats.FirstOrDefault(c => c.Bus == device.Bus && + c.Manufacturer == + device.Manufacturer && + c.Model == device.Model && + c.Revision == + device.Revision) + where existing == null select device) { - DeviceStat existing = - _ctx.DeviceStats.FirstOrDefault(c => c.Bus == device.Bus && - c.Manufacturer == device.Manufacturer && - c.Model == device.Model && - c.Revision == device.Revision); - - if(existing == null) - _ctx.DeviceStats.Add(new DeviceStat - { - Bus = device.Bus, Manufacturer = device.Manufacturer, Model = device.Model, - Revision = device.Revision - }); + await _ctx.DeviceStats.AddAsync(new DeviceStat + { + Bus = device.Bus, + Manufacturer = device.Manufacturer, + Model = device.Model, + Revision = device.Revision + }); } if(newstats.RemoteApplications != null) @@ -270,9 +277,11 @@ namespace Aaru.Server.Controllers c.Version == application.version); if(existing == null) - _ctx.RemoteApplications.Add(new RemoteApplication + 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 existing.Count += application.Value; @@ -284,9 +293,10 @@ namespace Aaru.Server.Controllers RemoteArchitecture existing = _ctx.RemoteArchitectures.FirstOrDefault(c => c.Name == nvs.name); if(existing == null) - _ctx.RemoteArchitectures.Add(new RemoteArchitecture + await _ctx.RemoteArchitectures.AddAsync(new RemoteArchitecture { - Name = nvs.name, Count = nvs.Value + Name = nvs.name, + Count = nvs.Value }); else existing.Count += nvs.Value; @@ -300,16 +310,17 @@ namespace Aaru.Server.Controllers c.Version == remoteOperatingSystem.version); if(existing == null) - _ctx.RemoteOperatingSystems.Add(new RemoteOperatingSystem + await _ctx.RemoteOperatingSystems.AddAsync(new RemoteOperatingSystem { - Name = remoteOperatingSystem.name, Version = remoteOperatingSystem.version, - Count = remoteOperatingSystem.Value + Name = remoteOperatingSystem.name, + Version = remoteOperatingSystem.version, + Count = remoteOperatingSystem.Value }); else existing.Count += remoteOperatingSystem.Value; } - _ctx.SaveChanges(); + await _ctx.SaveChangesAsync(); response.Content = "ok"; @@ -328,29 +339,5 @@ namespace Aaru.Server.Controllers return response; } } - - FileStream WaitForFile(string fullPath, FileMode mode, FileAccess access, FileShare share) - { - for(int numTries = 0; numTries < 100; numTries++) - { - FileStream fs = null; - - try - { - fs = new FileStream(fullPath, mode, access, share); - - return fs; - } - catch(IOException) - { - if(fs != null) - fs.Dispose(); - - Thread.Sleep(50); - } - } - - return null; - } } } \ No newline at end of file diff --git a/Aaru.Server/Core/Ata.cs b/Aaru.Server/Core/Ata.cs index a2d8d6d9..56e9fe07 100644 --- a/Aaru.Server/Core/Ata.cs +++ b/Aaru.Server/Core/Ata.cs @@ -31,11 +31,10 @@ // ****************************************************************************/ using System.Collections.Generic; -using Aaru.CommonTypes.Metadata; using Aaru.CommonTypes.Structs.Devices.ATA; using Aaru.CommonTypes.Structs.Devices.SCSI; -namespace Aaru.Server +namespace Aaru.Server.Core { public static class Ata { @@ -52,9 +51,9 @@ namespace Aaru.Server /// List of tested media public static void Report(CommonTypes.Metadata.Ata ataReport, bool cfa, bool atapi, ref bool removable, ref List ataOneValue, ref Dictionary ataTwoValue, - ref List testedMedia) + ref List testedMedia) { - uint logicalsectorsize = 0; + uint logicalSectorSize = 0; Identify.IdentifyDevice? ataIdentifyNullable = Identify.Decode(ataReport.Identify); @@ -117,113 +116,111 @@ namespace Aaru.Server acs4 |= ataIdentify.MajorVersion.HasFlag(Identify.MajorVersionBit.ACS4); } - int maxatalevel = 0; - int minatalevel = 255; + int maxAtaLevel = 0; + int minAtaLevel = 255; string tmpString = ""; if(ata1) { tmpString += "ATA-1 "; - maxatalevel = 1; - - if(minatalevel > 1) - minatalevel = 1; + maxAtaLevel = 1; + minAtaLevel = 1; } if(ata2) { tmpString += "ATA-2 "; - maxatalevel = 2; + maxAtaLevel = 2; - if(minatalevel > 2) - minatalevel = 2; + if(minAtaLevel > 2) + minAtaLevel = 2; } if(ata3) { tmpString += "ATA-3 "; - maxatalevel = 3; + maxAtaLevel = 3; - if(minatalevel > 3) - minatalevel = 3; + if(minAtaLevel > 3) + minAtaLevel = 3; } if(ata4) { tmpString += "ATA/ATAPI-4 "; - maxatalevel = 4; + maxAtaLevel = 4; - if(minatalevel > 4) - minatalevel = 4; + if(minAtaLevel > 4) + minAtaLevel = 4; } if(ata5) { tmpString += "ATA/ATAPI-5 "; - maxatalevel = 5; + maxAtaLevel = 5; - if(minatalevel > 5) - minatalevel = 5; + if(minAtaLevel > 5) + minAtaLevel = 5; } if(ata6) { tmpString += "ATA/ATAPI-6 "; - maxatalevel = 6; + maxAtaLevel = 6; - if(minatalevel > 6) - minatalevel = 6; + if(minAtaLevel > 6) + minAtaLevel = 6; } if(ata7) { tmpString += "ATA/ATAPI-7 "; - maxatalevel = 7; + maxAtaLevel = 7; - if(minatalevel > 7) - minatalevel = 7; + if(minAtaLevel > 7) + minAtaLevel = 7; } if(acs) { tmpString += "ATA8-ACS "; - maxatalevel = 8; + maxAtaLevel = 8; - if(minatalevel > 8) - minatalevel = 8; + if(minAtaLevel > 8) + minAtaLevel = 8; } if(acs2) { tmpString += "ATA8-ACS2 "; - maxatalevel = 9; + maxAtaLevel = 9; - if(minatalevel > 9) - minatalevel = 9; + if(minAtaLevel > 9) + minAtaLevel = 9; } if(acs3) { tmpString += "ATA8-ACS3 "; - maxatalevel = 10; + maxAtaLevel = 10; - if(minatalevel > 10) - minatalevel = 10; + if(minAtaLevel > 10) + minAtaLevel = 10; } if(acs4) { tmpString += "ATA8-ACS4 "; - maxatalevel = 11; + maxAtaLevel = 11; - if(minatalevel > 11) - minatalevel = 11; + if(minAtaLevel > 11) + minAtaLevel = 11; } if(tmpString != "") ataTwoValue.Add("Supported ATA versions", tmpString); - if(maxatalevel >= 3) + if(maxAtaLevel >= 3) { switch(ataIdentify.MinorVersion) { @@ -613,7 +610,7 @@ namespace Aaru.Server } else if(!cfa) { - if(minatalevel >= 5) + if(minAtaLevel >= 5) if(ataIdentify.GeneralConfiguration.HasFlag(Identify.GeneralConfigurationBit.IncompleteResponse)) ataOneValue.Add("Incomplete identify response"); @@ -623,7 +620,7 @@ namespace Aaru.Server if(ataIdentify.GeneralConfiguration.HasFlag(Identify.GeneralConfigurationBit.Removable)) ataOneValue.Add("Device is removable"); - if(minatalevel <= 5) + if(minAtaLevel <= 5) if(ataIdentify.GeneralConfiguration.HasFlag(Identify.GeneralConfigurationBit.Fixed)) ataOneValue.Add("Device is fixed"); @@ -708,29 +705,29 @@ namespace Aaru.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; } ataOneValue.Add("Device capabilities:"); - if(ataIdentify.Capabilities.HasFlag(Identify.CapabilitiesBit.StandardStanbyTimer)) + if(ataIdentify.Capabilities.HasFlag(Identify.CapabilitiesBit.StandardStandbyTimer)) ataOneValue.Add("Standby time values are standard"); if(ataIdentify.Capabilities.HasFlag(Identify.CapabilitiesBit.IORDY)) @@ -776,7 +773,7 @@ namespace Aaru.Server if(ataIdentify.TrustedComputing.HasFlag(Identify.TrustedComputingBit.TrustedComputing)) ataOneValue.Add("Device supports doubleword I/O"); - if(minatalevel <= 3) + if(minAtaLevel <= 3) { if(ataIdentify.PIOTransferTimingMode > 0) ataTwoValue.Add("PIO timing mode", $"{ataIdentify.PIOTransferTimingMode}"); @@ -814,7 +811,7 @@ namespace Aaru.Server if(!string.IsNullOrEmpty(tmpString)) ataTwoValue.Add("Advanced PIO", tmpString); - if(minatalevel <= 3 && + if(minAtaLevel <= 3 && !atapi) { tmpString = ""; @@ -1119,7 +1116,7 @@ namespace Aaru.Server if(ataIdentify.InterseekDelay != 0x0000 && ataIdentify.InterseekDelay != 0xFFFF) ataOneValue. - Add($"{ataIdentify.InterseekDelay} microseconds of interseek delay for ISO-7779 accoustic testing"); + Add($"{ataIdentify.InterseekDelay} microseconds of interseek delay for ISO-7779 acoustic testing"); if((ushort)ataIdentify.DeviceFormFactor != 0x0000 && (ushort)ataIdentify.DeviceFormFactor != 0xFFFF) @@ -1498,7 +1495,7 @@ namespace Aaru.Server } if(!ata1 && - maxatalevel >= 8) + maxAtaLevel >= 8) if(ataIdentify.TrustedComputing.HasFlag(Identify.TrustedComputingBit.Set) && !ataIdentify.TrustedComputing.HasFlag(Identify.TrustedComputingBit.Clear) && ataIdentify.TrustedComputing.HasFlag(Identify.TrustedComputingBit.TrustedComputing)) @@ -1600,7 +1597,7 @@ namespace Aaru.Server ? "Security is frozen" : "Security is not frozen"); ataOneValue.Add(ataIdentify.SecurityStatus.HasFlag(Identify.SecurityStatusBit.Expired) - ? "Security count has expired" : "Security count has notexpired"); + ? "Security count has expired" : "Security count has not expired"); ataOneValue.Add(ataIdentify.SecurityStatus.HasFlag(Identify.SecurityStatusBit.Maximum) ? "Security level is maximum" : "Security level is high"); @@ -1668,7 +1665,7 @@ namespace Aaru.Server ataOneValue.Add($"Version {(ataIdentify.NVCacheCaps & 0x0F00) >> 8}"); } - ataOneValue.Add($"Non-Volatile Cache is {ataIdentify.NVCacheSize * logicalsectorsize} bytes"); + ataOneValue.Add($"Non-Volatile Cache is {ataIdentify.NVCacheSize * logicalSectorSize} bytes"); } if(ataReport.ReadCapabilities != null) @@ -1687,7 +1684,7 @@ namespace Aaru.Server if(ataReport.ReadCapabilities.BlockSize != null) { ataTwoValue.Add("Logical sector size", $"{ataReport.ReadCapabilities.BlockSize} bytes"); - logicalsectorsize = ataReport.ReadCapabilities.BlockSize.Value; + logicalSectorSize = ataReport.ReadCapabilities.BlockSize.Value; } if(ataReport.ReadCapabilities.PhysicalBlockSize != null) @@ -1726,7 +1723,7 @@ namespace Aaru.Server $"{ataReport.ReadCapabilities.CHS.Cylinders * ataReport.ReadCapabilities.CHS.Heads * ataReport.ReadCapabilities.CHS.Sectors} max., {currentSectors} current"); ataTwoValue.Add("Device size in CHS mode", - $"{(ulong)currentSectors * logicalsectorsize} bytes, {((ulong)currentSectors * logicalsectorsize) / 1000 / 1000} Mb, {(double)((ulong)currentSectors * logicalsectorsize) / 1024 / 1024:F2} MiB"); + $"{(ulong)currentSectors * logicalSectorSize} bytes, {((ulong)currentSectors * logicalSectorSize) / 1000 / 1000} Mb, {(double)((ulong)currentSectors * logicalSectorSize) / 1024 / 1024:F2} MiB"); } else if(ataReport.ReadCapabilities.CHS != null) { @@ -1740,7 +1737,7 @@ namespace Aaru.Server ataTwoValue.Add("Sectors addressable in CHS mode", $"{currentSectors}"); ataTwoValue.Add("Device size in CHS mode", - $"{(ulong)currentSectors * logicalsectorsize} bytes, {((ulong)currentSectors * logicalsectorsize) / 1000 / 1000} Mb, {(double)((ulong)currentSectors * logicalsectorsize) / 1024 / 1024:F2} MiB"); + $"{(ulong)currentSectors * logicalSectorSize} bytes, {((ulong)currentSectors * logicalSectorSize) / 1000 / 1000} Mb, {(double)((ulong)currentSectors * logicalSectorSize) / 1024 / 1024:F2} MiB"); } if(ataReport.ReadCapabilities.LBASectors != null) @@ -1748,15 +1745,15 @@ namespace Aaru.Server ataTwoValue.Add("Sectors addressable in sectors in 28-bit LBA mode", $"{ataReport.ReadCapabilities.LBASectors}"); - if(((ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize) / 1024 / 1024 > 1000000) + if(((ulong)ataReport.ReadCapabilities.LBASectors * logicalSectorSize) / 1024 / 1024 > 1000000) ataTwoValue.Add("Device size in 28-bit LBA mode", - $"{(ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize} bytes, {((ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize) / 1000 / 1000 / 1000 / 1000} Tb, {(double)((ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize) / 1024 / 1024 / 1024 / 1024:F2} TiB"); - else if(((ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize) / 1024 / 1024 > 1000) + $"{(ulong)ataReport.ReadCapabilities.LBASectors * logicalSectorSize} bytes, {((ulong)ataReport.ReadCapabilities.LBASectors * logicalSectorSize) / 1000 / 1000 / 1000 / 1000} Tb, {(double)((ulong)ataReport.ReadCapabilities.LBASectors * logicalSectorSize) / 1024 / 1024 / 1024 / 1024:F2} TiB"); + else if(((ulong)ataReport.ReadCapabilities.LBASectors * logicalSectorSize) / 1024 / 1024 > 1000) ataTwoValue.Add("Device size in 28-bit LBA mode", - $"{(ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize} bytes, {((ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize) / 1000 / 1000 / 1000} Gb, {(double)((ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize) / 1024 / 1024 / 1024:F2} GiB"); + $"{(ulong)ataReport.ReadCapabilities.LBASectors * logicalSectorSize} bytes, {((ulong)ataReport.ReadCapabilities.LBASectors * logicalSectorSize) / 1000 / 1000 / 1000} Gb, {(double)((ulong)ataReport.ReadCapabilities.LBASectors * logicalSectorSize) / 1024 / 1024 / 1024:F2} GiB"); else ataTwoValue.Add("Device size in 28-bit LBA mode", - $"{(ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize} bytes, {((ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize) / 1000 / 1000} Mb, {(double)((ulong)ataReport.ReadCapabilities.LBASectors * logicalsectorsize) / 1024 / 1024:F2} MiB"); + $"{(ulong)ataReport.ReadCapabilities.LBASectors * logicalSectorSize} bytes, {((ulong)ataReport.ReadCapabilities.LBASectors * logicalSectorSize) / 1000 / 1000} Mb, {(double)((ulong)ataReport.ReadCapabilities.LBASectors * logicalSectorSize) / 1024 / 1024:F2} MiB"); } if(ataReport.ReadCapabilities.LBA48Sectors != null) @@ -1764,15 +1761,15 @@ namespace Aaru.Server ataTwoValue.Add("Sectors addressable in sectors in 48-bit LBA mode", $"{ataReport.ReadCapabilities.LBA48Sectors}"); - if((ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize) / 1024 / 1024 > 1000000) + if((ataReport.ReadCapabilities.LBA48Sectors * logicalSectorSize) / 1024 / 1024 > 1000000) ataTwoValue.Add("Device size in 48-bit LBA mode", - $"{ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize} bytes, {(ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize) / 1000 / 1000 / 1000 / 1000} Tb, {(double)(ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize) / 1024 / 1024 / 1024 / 1024:F2} TiB"); - else if((ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize) / 1024 / 1024 > 1000) + $"{ataReport.ReadCapabilities.LBA48Sectors * logicalSectorSize} bytes, {(ataReport.ReadCapabilities.LBA48Sectors * logicalSectorSize) / 1000 / 1000 / 1000 / 1000} Tb, {(double)(ataReport.ReadCapabilities.LBA48Sectors * logicalSectorSize) / 1024 / 1024 / 1024 / 1024:F2} TiB"); + else if((ataReport.ReadCapabilities.LBA48Sectors * logicalSectorSize) / 1024 / 1024 > 1000) ataTwoValue.Add("Device size in 48-bit LBA mode", - $"{ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize} bytes, {(ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize) / 1000 / 1000 / 1000} Gb, {(double)(ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize) / 1024 / 1024 / 1024:F2} GiB"); + $"{ataReport.ReadCapabilities.LBA48Sectors * logicalSectorSize} bytes, {(ataReport.ReadCapabilities.LBA48Sectors * logicalSectorSize) / 1000 / 1000 / 1000} Gb, {(double)(ataReport.ReadCapabilities.LBA48Sectors * logicalSectorSize) / 1024 / 1024 / 1024:F2} GiB"); else ataTwoValue.Add("Device size in 48-bit LBA mode", - $"{ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize} bytes, {(ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize) / 1000 / 1000} Mb, {(double)(ataReport.ReadCapabilities.LBA48Sectors * logicalsectorsize) / 1024 / 1024:F2} MiB"); + $"{ataReport.ReadCapabilities.LBA48Sectors * logicalSectorSize} bytes, {(ataReport.ReadCapabilities.LBA48Sectors * logicalSectorSize) / 1000 / 1000} Mb, {(double)(ataReport.ReadCapabilities.LBA48Sectors * logicalSectorSize) / 1024 / 1024:F2} MiB"); } if(ata1 || cfa) diff --git a/Aaru.Server/Core/Hash.cs b/Aaru.Server/Core/Hash.cs index 4d162ff9..17445087 100644 --- a/Aaru.Server/Core/Hash.cs +++ b/Aaru.Server/Core/Hash.cs @@ -1,6 +1,6 @@ using System.Security.Cryptography; -namespace Aaru.Server +namespace Aaru.Server.Core { public static class Hash { diff --git a/Aaru.Server/Core/ScsiEvpd.cs b/Aaru.Server/Core/ScsiEvpd.cs index 339a5cf0..3b0fcaec 100644 --- a/Aaru.Server/Core/ScsiEvpd.cs +++ b/Aaru.Server/Core/ScsiEvpd.cs @@ -34,7 +34,7 @@ using System.Collections.Generic; using Aaru.CommonTypes.Metadata; using Aaru.Decoders.SCSI; -namespace Aaru.Server +namespace Aaru.Server.Core { public static class ScsiEvpd { diff --git a/Aaru.Server/Core/ScsiInquiry.cs b/Aaru.Server/Core/ScsiInquiry.cs index 1ace0c1c..5009f628 100644 --- a/Aaru.Server/Core/ScsiInquiry.cs +++ b/Aaru.Server/Core/ScsiInquiry.cs @@ -33,7 +33,7 @@ using System.Collections.Generic; using Aaru.CommonTypes.Structs.Devices.SCSI; -namespace Aaru.Server +namespace Aaru.Server.Core { internal static class ScsiInquiry { @@ -328,19 +328,19 @@ namespace Aaru.Server switch((TGPSValues)inquiry.TPGS) { case TGPSValues.NotSupported: - scsiOneValue.Add("Device does not support assymetrical access"); + scsiOneValue.Add("Device does not support asymmetrical access"); break; case TGPSValues.OnlyImplicit: - scsiOneValue.Add("Device only supports implicit assymetrical access"); + scsiOneValue.Add("Device only supports implicit asymmetrical access"); break; case TGPSValues.OnlyExplicit: - scsiOneValue.Add("Device only supports explicit assymetrical access"); + scsiOneValue.Add("Device only supports explicit asymmetrical access"); break; case TGPSValues.Both: - scsiOneValue.Add("Device supports implicit and explicit assymetrical access"); + scsiOneValue.Add("Device supports implicit and explicit asymmetrical access"); break; default: diff --git a/Aaru.Server/Core/ScsiMmcFeatures.cs b/Aaru.Server/Core/ScsiMmcFeatures.cs index d9e226a3..81f99962 100644 --- a/Aaru.Server/Core/ScsiMmcFeatures.cs +++ b/Aaru.Server/Core/ScsiMmcFeatures.cs @@ -34,7 +34,7 @@ using System.Collections.Generic; using Aaru.CommonTypes.Metadata; using Aaru.CommonTypes.Structs.Devices.SCSI; -namespace Aaru.Server +namespace Aaru.Server.Core { public static class ScsiMmcFeatures { @@ -121,7 +121,7 @@ namespace Aaru.Server mmcOneValue.Add("Drive has an analogue audio output"); if(ftr.CanPseudoOverwriteBDR) - mmcOneValue.Add("Drive can write BD-R on Pseudo-OVerwrite SRM mode"); + mmcOneValue.Add("Drive can write BD-R on Pseudo-OverWrite SRM mode"); if(ftr.CanReadAllDualR) mmcOneValue.Add("Drive can read DVD-R DL from all recording modes"); @@ -431,7 +431,7 @@ namespace Aaru.Server if(ftr.SupportsCPRM && ftr.CPRMVersion.HasValue) - mmcOneValue.Add($"Drive supports DVD CPPM version {ftr.CPRMVersion}"); + mmcOneValue.Add($"Drive supports DVD CPRM version {ftr.CPRMVersion}"); else if(ftr.SupportsCPRM) mmcOneValue.Add("Drive supports DVD CPRM"); diff --git a/Aaru.Server/Core/ScsiMmcMode.cs b/Aaru.Server/Core/ScsiMmcMode.cs index 9b32ac06..1d2c43ac 100644 --- a/Aaru.Server/Core/ScsiMmcMode.cs +++ b/Aaru.Server/Core/ScsiMmcMode.cs @@ -34,7 +34,7 @@ using System.Collections.Generic; using System.Linq; using Aaru.CommonTypes.Structs.Devices.SCSI.Modes; -namespace Aaru.Server +namespace Aaru.Server.Core { public static class ScsiMmcMode { diff --git a/Aaru.Server/Core/ScsiModeSense.cs b/Aaru.Server/Core/ScsiModeSense.cs index 8191016f..0793557c 100644 --- a/Aaru.Server/Core/ScsiModeSense.cs +++ b/Aaru.Server/Core/ScsiModeSense.cs @@ -35,7 +35,7 @@ using Aaru.CommonTypes.Metadata; using Aaru.CommonTypes.Structs.Devices.SCSI; using Aaru.Decoders.SCSI; -namespace Aaru.Server +namespace Aaru.Server.Core { public static class ScsiModeSense { diff --git a/Aaru.Server/Core/SscTestedMedia.cs b/Aaru.Server/Core/SscTestedMedia.cs index de7286b8..510cd69d 100644 --- a/Aaru.Server/Core/SscTestedMedia.cs +++ b/Aaru.Server/Core/SscTestedMedia.cs @@ -33,7 +33,7 @@ using System.Collections.Generic; using Aaru.CommonTypes.Metadata; -namespace Aaru.Server +namespace Aaru.Server.Core { public static class SscTestedMedia { diff --git a/Aaru.Server/Core/StatsConverter.cs b/Aaru.Server/Core/StatsConverter.cs index ec81b1b7..6616017f 100644 --- a/Aaru.Server/Core/StatsConverter.cs +++ b/Aaru.Server/Core/StatsConverter.cs @@ -35,7 +35,7 @@ using Aaru.CommonTypes.Metadata; using Aaru.Server.Models; using Version = Aaru.Server.Models.Version; -namespace Aaru.Server +namespace Aaru.Server.Core { public static class StatsConverter { @@ -43,280 +43,298 @@ namespace Aaru.Server { var ctx = new AaruServerContext(); - if(newStats.Commands != null) + if(newStats.Commands?.Analyze > 0) { - if(newStats.Commands.Analyze > 0) - { - Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "analyze"); + Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "analyze"); - if(existing == null) - ctx.Commands.Add(new Command - { - Count = newStats.Commands.Analyze, Name = "analyze" - }); - else - existing.Count += newStats.Commands.Analyze; - } + if(existing == null) + ctx.Commands.Add(new Command + { + Count = newStats.Commands.Analyze, + Name = "analyze" + }); + else + existing.Count += newStats.Commands.Analyze; + } - if(newStats.Commands.Benchmark > 0) - { - Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "benchmark"); + if(newStats.Commands?.Benchmark > 0) + { + Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "benchmark"); - if(existing == null) - ctx.Commands.Add(new Command - { - Count = newStats.Commands.Benchmark, Name = "benchmark" - }); - else - existing.Count += newStats.Commands.Benchmark; - } + if(existing == null) + ctx.Commands.Add(new Command + { + Count = newStats.Commands.Benchmark, + Name = "benchmark" + }); + else + existing.Count += newStats.Commands.Benchmark; + } - if(newStats.Commands.Checksum > 0) - { - Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "checksum"); + if(newStats.Commands?.Checksum > 0) + { + Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "checksum"); - if(existing == null) - ctx.Commands.Add(new Command - { - Count = newStats.Commands.Checksum, Name = "checksum" - }); - else - existing.Count += newStats.Commands.Checksum; - } + if(existing == null) + ctx.Commands.Add(new Command + { + Count = newStats.Commands.Checksum, + Name = "checksum" + }); + else + existing.Count += newStats.Commands.Checksum; + } - if(newStats.Commands.Compare > 0) - { - Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "compare"); + if(newStats.Commands?.Compare > 0) + { + Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "compare"); - if(existing == null) - ctx.Commands.Add(new Command - { - Count = newStats.Commands.Compare, Name = "compare" - }); - else - existing.Count += newStats.Commands.Compare; - } + if(existing == null) + ctx.Commands.Add(new Command + { + Count = newStats.Commands.Compare, + Name = "compare" + }); + else + existing.Count += newStats.Commands.Compare; + } - if(newStats.Commands.CreateSidecar > 0) - { - Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "create-sidecar"); + if(newStats.Commands?.CreateSidecar > 0) + { + Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "create-sidecar"); - if(existing == null) - ctx.Commands.Add(new Command - { - Count = newStats.Commands.CreateSidecar, Name = "create-sidecar" - }); - else - existing.Count += newStats.Commands.CreateSidecar; - } + if(existing == null) + ctx.Commands.Add(new Command + { + Count = newStats.Commands.CreateSidecar, + Name = "create-sidecar" + }); + else + existing.Count += newStats.Commands.CreateSidecar; + } - if(newStats.Commands.Decode > 0) - { - Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "decode"); + if(newStats.Commands?.Decode > 0) + { + Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "decode"); - if(existing == null) - ctx.Commands.Add(new Command - { - Count = newStats.Commands.Decode, Name = "decode" - }); - else - existing.Count += newStats.Commands.Decode; - } + if(existing == null) + ctx.Commands.Add(new Command + { + Count = newStats.Commands.Decode, + Name = "decode" + }); + else + existing.Count += newStats.Commands.Decode; + } - if(newStats.Commands.DeviceInfo > 0) - { - Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "device-info"); + if(newStats.Commands?.DeviceInfo > 0) + { + Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "device-info"); - if(existing == null) - ctx.Commands.Add(new Command - { - Count = newStats.Commands.DeviceInfo, Name = "device-info" - }); - else - existing.Count += newStats.Commands.DeviceInfo; - } + if(existing == null) + ctx.Commands.Add(new Command + { + Count = newStats.Commands.DeviceInfo, + Name = "device-info" + }); + else + existing.Count += newStats.Commands.DeviceInfo; + } - if(newStats.Commands.DeviceReport > 0) - { - Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "device-report"); + if(newStats.Commands?.DeviceReport > 0) + { + Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "device-report"); - if(existing == null) - ctx.Commands.Add(new Command - { - Count = newStats.Commands.DeviceReport, Name = "device-report" - }); - else - existing.Count += newStats.Commands.DeviceReport; - } + if(existing == null) + ctx.Commands.Add(new Command + { + Count = newStats.Commands.DeviceReport, + Name = "device-report" + }); + else + existing.Count += newStats.Commands.DeviceReport; + } - if(newStats.Commands.DumpMedia > 0) - { - Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "dump-media"); + if(newStats.Commands?.DumpMedia > 0) + { + Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "dump-media"); - if(existing == null) - ctx.Commands.Add(new Command - { - Count = newStats.Commands.DumpMedia, Name = "dump-media" - }); - else - existing.Count += newStats.Commands.DumpMedia; - } + if(existing == null) + ctx.Commands.Add(new Command + { + Count = newStats.Commands.DumpMedia, + Name = "dump-media" + }); + else + existing.Count += newStats.Commands.DumpMedia; + } - if(newStats.Commands.Entropy > 0) - { - Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "entropy"); + if(newStats.Commands?.Entropy > 0) + { + Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "entropy"); - if(existing == null) - ctx.Commands.Add(new Command - { - Count = newStats.Commands.Entropy, Name = "entropy" - }); - else - existing.Count += newStats.Commands.Entropy; - } + if(existing == null) + ctx.Commands.Add(new Command + { + Count = newStats.Commands.Entropy, + Name = "entropy" + }); + else + existing.Count += newStats.Commands.Entropy; + } - if(newStats.Commands.Formats > 0) - { - Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "formats"); + if(newStats.Commands?.Formats > 0) + { + Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "formats"); - if(existing == null) - ctx.Commands.Add(new Command - { - Count = newStats.Commands.Formats, Name = "formats" - }); - else - existing.Count += newStats.Commands.Formats; - } + if(existing == null) + ctx.Commands.Add(new Command + { + Count = newStats.Commands.Formats, + Name = "formats" + }); + else + existing.Count += newStats.Commands.Formats; + } - if(newStats.Commands.MediaInfo > 0) - { - Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "media-info"); + if(newStats.Commands?.MediaInfo > 0) + { + Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "media-info"); - if(existing == null) - ctx.Commands.Add(new Command - { - Count = newStats.Commands.MediaInfo, Name = "media-info" - }); - else - existing.Count += newStats.Commands.MediaInfo; - } + if(existing == null) + ctx.Commands.Add(new Command + { + Count = newStats.Commands.MediaInfo, + Name = "media-info" + }); + else + existing.Count += newStats.Commands.MediaInfo; + } - if(newStats.Commands.MediaScan > 0) - { - Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "media-scan"); + if(newStats.Commands?.MediaScan > 0) + { + Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "media-scan"); - if(existing == null) - ctx.Commands.Add(new Command - { - Count = newStats.Commands.MediaScan, Name = "media-scan" - }); - else - existing.Count += newStats.Commands.MediaScan; - } + if(existing == null) + ctx.Commands.Add(new Command + { + Count = newStats.Commands.MediaScan, + Name = "media-scan" + }); + else + existing.Count += newStats.Commands.MediaScan; + } - if(newStats.Commands.PrintHex > 0) - { - Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "printhex"); + if(newStats.Commands?.PrintHex > 0) + { + Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "printhex"); - if(existing == null) - ctx.Commands.Add(new Command - { - Count = newStats.Commands.PrintHex, Name = "printhex" - }); - else - existing.Count += newStats.Commands.PrintHex; - } + if(existing == null) + ctx.Commands.Add(new Command + { + Count = newStats.Commands.PrintHex, + Name = "printhex" + }); + else + existing.Count += newStats.Commands.PrintHex; + } - if(newStats.Commands.Verify > 0) - { - Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "verify"); + if(newStats.Commands?.Verify > 0) + { + Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "verify"); - if(existing == null) - ctx.Commands.Add(new Command - { - Count = newStats.Commands.Verify, Name = "verify" - }); - else - existing.Count += newStats.Commands.Verify; - } + if(existing == null) + ctx.Commands.Add(new Command + { + Count = newStats.Commands.Verify, + Name = "verify" + }); + else + existing.Count += newStats.Commands.Verify; + } - if(newStats.Commands.Ls > 0) - { - Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "ls"); + if(newStats.Commands?.Ls > 0) + { + Command 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; - } + if(existing == null) + ctx.Commands.Add(new Command + { + Count = newStats.Commands.Ls, + Name = "ls" + }); + else + existing.Count += newStats.Commands.Ls; + } - if(newStats.Commands.ExtractFiles > 0) - { - Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "extract-files"); + if(newStats.Commands?.ExtractFiles > 0) + { + Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "extract-files"); - if(existing == null) - ctx.Commands.Add(new Command - { - Count = newStats.Commands.ExtractFiles, Name = "extract-files" - }); - else - existing.Count += newStats.Commands.ExtractFiles; - } + if(existing == null) + ctx.Commands.Add(new Command + { + Count = newStats.Commands.ExtractFiles, + Name = "extract-files" + }); + else + existing.Count += newStats.Commands.ExtractFiles; + } - if(newStats.Commands.ListDevices > 0) - { - Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "list-devices"); + if(newStats.Commands?.ListDevices > 0) + { + Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "list-devices"); - if(existing == null) - ctx.Commands.Add(new Command - { - Count = newStats.Commands.ListDevices, Name = "list-devices" - }); - else - existing.Count += newStats.Commands.ListDevices; - } + if(existing == null) + ctx.Commands.Add(new Command + { + Count = newStats.Commands.ListDevices, + Name = "list-devices" + }); + else + existing.Count += newStats.Commands.ListDevices; + } - if(newStats.Commands.ListEncodings > 0) - { - Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "list-encodings"); + if(newStats.Commands?.ListEncodings > 0) + { + Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "list-encodings"); - if(existing == null) - ctx.Commands.Add(new Command - { - Count = newStats.Commands.ListEncodings, Name = "list-encodings" - }); - else - existing.Count += newStats.Commands.ListEncodings; - } + if(existing == null) + ctx.Commands.Add(new Command + { + Count = newStats.Commands.ListEncodings, + Name = "list-encodings" + }); + else + existing.Count += newStats.Commands.ListEncodings; + } - if(newStats.Commands.ConvertImage > 0) - { - Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "convert-image"); + if(newStats.Commands?.ConvertImage > 0) + { + Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "convert-image"); - if(existing == null) - ctx.Commands.Add(new Command - { - Count = newStats.Commands.ConvertImage, Name = "convert-image" - }); - else - existing.Count += newStats.Commands.ConvertImage; - } + if(existing == null) + ctx.Commands.Add(new Command + { + Count = newStats.Commands.ConvertImage, + Name = "convert-image" + }); + else + existing.Count += newStats.Commands.ConvertImage; + } - if(newStats.Commands.ImageInfo > 0) - { - Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "image-info"); + if(newStats.Commands?.ImageInfo > 0) + { + Command existing = ctx.Commands.FirstOrDefault(c => c.Name == "image-info"); - if(existing == null) - ctx.Commands.Add(new Command - { - Count = newStats.Commands.ImageInfo, Name = "image-info" - }); - else - existing.Count += newStats.Commands.ImageInfo; - } + if(existing == null) + ctx.Commands.Add(new Command + { + Count = newStats.Commands.ImageInfo, + Name = "image-info" + }); + else + existing.Count += newStats.Commands.ImageInfo; } if(newStats.OperatingSystems != null) @@ -334,7 +352,8 @@ namespace Aaru.Server if(existing == null) ctx.OperatingSystems.Add(new OperatingSystem { - Count = operatingSystem.Value, Name = operatingSystem.name, + Count = operatingSystem.Value, + Name = operatingSystem.name, Version = operatingSystem.version }); else @@ -349,7 +368,8 @@ namespace Aaru.Server if(existing == null) ctx.OperatingSystems.Add(new OperatingSystem { - Count = 1, Name = "Linux" + Count = 1, + Name = "Linux" }); else existing.Count++; @@ -367,7 +387,8 @@ namespace Aaru.Server if(existing == null) ctx.Versions.Add(new Version { - Count = nvs.Value, Name = nvs.name + Count = nvs.Value, + Name = nvs.name }); else existing.Count += nvs.Value; @@ -380,7 +401,8 @@ namespace Aaru.Server if(existing == null) ctx.Versions.Add(new Version { - Count = 1, Name = "previous" + Count = 1, + Name = "previous" }); else existing.Count++; @@ -397,7 +419,8 @@ namespace Aaru.Server if(existing == null) ctx.Filesystems.Add(new Filesystem { - Count = nvs.Value, Name = nvs.name + Count = nvs.Value, + Name = nvs.name }); else existing.Count += nvs.Value; @@ -414,7 +437,8 @@ namespace Aaru.Server if(existing == null) ctx.Partitions.Add(new Partition { - Count = nvs.Value, Name = nvs.name + Count = nvs.Value, + Name = nvs.name }); else existing.Count += nvs.Value; @@ -431,7 +455,8 @@ namespace Aaru.Server if(existing == null) ctx.MediaFormats.Add(new MediaFormat { - Count = nvs.Value, Name = nvs.name + Count = nvs.Value, + Name = nvs.name }); else existing.Count += nvs.Value; @@ -448,25 +473,29 @@ namespace Aaru.Server if(existing == null) ctx.Filters.Add(new Filter { - Count = nvs.Value, Name = nvs.name + Count = nvs.Value, + Name = nvs.name }); else existing.Count += nvs.Value; } if(newStats.Devices != null) - foreach(DeviceStats device in newStats.Devices) + foreach(DeviceStats device in newStats. + Devices.Where(device => !string.IsNullOrWhiteSpace(device.Model)). + Where(device => !ctx.DeviceStats.Any(c => c.Bus == device.Bus && + c.Manufacturer == + device.Manufacturer && + c.Model == device.Model && + c.Revision == device.Revision))) { - if(string.IsNullOrWhiteSpace(device.Model)) - continue; - - if(!ctx.DeviceStats.Any(c => c.Bus == device.Bus && c.Manufacturer == device.Manufacturer && - c.Model == device.Model && c.Revision == device.Revision)) - ctx.DeviceStats.Add(new DeviceStat - { - Bus = device.Bus, Manufacturer = device.Manufacturer, Model = device.Model, - Revision = device.Revision - }); + ctx.DeviceStats.Add(new DeviceStat + { + Bus = device.Bus, + Manufacturer = device.Manufacturer, + Model = device.Model, + Revision = device.Revision + }); } if(newStats.Medias != null) @@ -480,7 +509,9 @@ namespace Aaru.Server if(existing == null) ctx.Medias.Add(new Media { - Count = media.Value, Real = media.real, Type = media.type + Count = media.Value, + Real = media.real, + Type = media.type }); else existing.Count += media.Value; diff --git a/Aaru.Server/Core/TestedMedia.cs b/Aaru.Server/Core/TestedMedia.cs index 8f3e2f3f..f12e24d8 100644 --- a/Aaru.Server/Core/TestedMedia.cs +++ b/Aaru.Server/Core/TestedMedia.cs @@ -32,12 +32,11 @@ using System.Collections.Generic; -namespace Aaru.Server.App_Start +namespace Aaru.Server.Core { public static class TestedMedia { /// Takes the tested media from a device report and prints it as a list of values - /// true if device report is from an ATA device /// List to put values on /// List of tested media public static void Report(List testedMedias, ref List mediaOneValue) @@ -276,7 +275,7 @@ namespace Aaru.Server.App_Start mediaOneValue.Add("Device can use the PLEXTOR vendor READ CD-DA command with this medium"); if(testedMedia.SupportsPlextorReadRawDVD == true) - mediaOneValue.Add("Device can use the PLEXOR vendor READ DVD (RAW) command with this medium"); + mediaOneValue.Add("Device can use the PLEXTOR vendor READ DVD (RAW) command with this medium"); if(testedMedia.CanReadAACS == true) mediaOneValue.Add("Device can read the Advanced Access Content System from this medium"); @@ -310,7 +309,7 @@ namespace Aaru.Server.App_Start mediaOneValue.Add("Device can read the Disc Definition Structure from this medium"); if(testedMedia.CanReadDMI == true) - mediaOneValue.Add("Device can read the Disc Manufacurer Information from this medium"); + mediaOneValue.Add("Device can read the Disc Manufacturer Information from this medium"); if(testedMedia.CanReadDiscInformation == true) mediaOneValue.Add("Device can read the Disc Information from this medium"); diff --git a/Aaru.Server/Migrations/20191102132240_InitialMigration.cs b/Aaru.Server/Migrations/20191102132240_InitialMigration.cs index 36a6b122..62280ac6 100644 --- a/Aaru.Server/Migrations/20191102132240_InitialMigration.cs +++ b/Aaru.Server/Migrations/20191102132240_InitialMigration.cs @@ -10,53 +10,53 @@ namespace Aaru.Server.Migrations protected override void Up(MigrationBuilder migrationBuilder) { #region Check for old tables - bool AtasExists = AaruServerContext.TableExists("Atas"); - bool BlockDescriptorsExists = AaruServerContext.TableExists("BlockDescriptors"); - bool ChsExists = AaruServerContext.TableExists("Chs"); - bool CommandsExists = AaruServerContext.TableExists("Commands"); - bool CompactDiscOffsetsExists = AaruServerContext.TableExists("CompactDiscOffsets"); - bool DensityCodesExists = AaruServerContext.TableExists("DensityCodes"); - bool DevicesExists = AaruServerContext.TableExists("Devices"); - bool DeviceStatsExists = AaruServerContext.TableExists("DeviceStats"); - bool FilesystemsExists = AaruServerContext.TableExists("Filesystems"); - bool FiltersExists = AaruServerContext.TableExists("Filters"); - bool FireWiresExists = AaruServerContext.TableExists("FireWires"); - bool MediaExists = AaruServerContext.TableExists("Media"); - bool MediaFormatsExists = AaruServerContext.TableExists("MediaFormats"); - bool MmcFeaturesExists = AaruServerContext.TableExists("MmcFeatures"); - bool MmcsExists = AaruServerContext.TableExists("Mmcs"); - bool MmcSdsExists = AaruServerContext.TableExists("MmcSds"); - bool OperatingSystemsExists = AaruServerContext.TableExists("OperatingSystems"); - bool PartitionsExists = AaruServerContext.TableExists("Partitions"); - bool PcmciasExists = AaruServerContext.TableExists("Pcmcias"); - bool ScsiModesExists = AaruServerContext.TableExists("ScsiModes"); - bool ScsiPagesExists = AaruServerContext.TableExists("ScsiPages"); - bool ScsisExists = AaruServerContext.TableExists("Scsis"); - bool SscsExists = AaruServerContext.TableExists("Sscs"); - bool SscSupportedMediasExists = AaruServerContext.TableExists("SscSupportedMedias"); - bool SupportedDensitiesExists = AaruServerContext.TableExists("SupportedDensities"); - bool TestedMediasExists = AaruServerContext.TableExists("TestedMedias"); - bool TestedSequentialMediasExists = AaruServerContext.TableExists("TestedSequentialMedias"); - bool UploadedReportsExists = AaruServerContext.TableExists("UploadedReports"); - bool UsbProductsExists = AaruServerContext.TableExists("UsbProducts"); - bool UsbsExists = AaruServerContext.TableExists("Usbs"); - bool UsbVendorsExists = AaruServerContext.TableExists("UsbVendors"); - bool VersionsExists = AaruServerContext.TableExists("Versions"); - bool EFExists = AaruServerContext.TableExists("__MigrationHistory"); + bool atasExists = AaruServerContext.TableExists("Atas"); + bool blockDescriptorsExists = AaruServerContext.TableExists("BlockDescriptors"); + bool chsExists = AaruServerContext.TableExists("Chs"); + bool commandsExists = AaruServerContext.TableExists("Commands"); + bool compactDiscOffsetsExists = AaruServerContext.TableExists("CompactDiscOffsets"); + bool densityCodesExists = AaruServerContext.TableExists("DensityCodes"); + bool devicesExists = AaruServerContext.TableExists("Devices"); + bool deviceStatsExists = AaruServerContext.TableExists("DeviceStats"); + bool filesystemsExists = AaruServerContext.TableExists("Filesystems"); + bool filtersExists = AaruServerContext.TableExists("Filters"); + bool fireWiresExists = AaruServerContext.TableExists("FireWires"); + bool mediaExists = AaruServerContext.TableExists("Media"); + bool mediaFormatsExists = AaruServerContext.TableExists("MediaFormats"); + bool mmcFeaturesExists = AaruServerContext.TableExists("MmcFeatures"); + bool mmcsExists = AaruServerContext.TableExists("Mmcs"); + bool mmcSdsExists = AaruServerContext.TableExists("MmcSds"); + bool operatingSystemsExists = AaruServerContext.TableExists("OperatingSystems"); + bool partitionsExists = AaruServerContext.TableExists("Partitions"); + bool pcmciasExists = AaruServerContext.TableExists("Pcmcias"); + bool scsiModesExists = AaruServerContext.TableExists("ScsiModes"); + bool scsiPagesExists = AaruServerContext.TableExists("ScsiPages"); + bool scsisExists = AaruServerContext.TableExists("Scsis"); + bool sscsExists = AaruServerContext.TableExists("Sscs"); + bool sscSupportedMediasExists = AaruServerContext.TableExists("SscSupportedMedias"); + bool supportedDensitiesExists = AaruServerContext.TableExists("SupportedDensities"); + bool testedMediasExists = AaruServerContext.TableExists("TestedMedias"); + bool testedSequentialMediasExists = AaruServerContext.TableExists("TestedSequentialMedias"); + bool uploadedReportsExists = AaruServerContext.TableExists("UploadedReports"); + bool usbProductsExists = AaruServerContext.TableExists("UsbProducts"); + bool usbsExists = AaruServerContext.TableExists("Usbs"); + bool usbVendorsExists = AaruServerContext.TableExists("UsbVendors"); + bool versionsExists = AaruServerContext.TableExists("Versions"); + bool efExists = AaruServerContext.TableExists("__MigrationHistory"); #endregion #region Drop old restrictions - if(AtasExists) + if(atasExists) migrationBuilder.DropForeignKey("FK_Atas_TestedMedias_ReadCapabilities_Id", "Atas"); - if(BlockDescriptorsExists) + if(blockDescriptorsExists) migrationBuilder.DropForeignKey("FK_BlockDescriptors_ScsiModes_ScsiMode_Id", "BlockDescriptors"); - if(DensityCodesExists) + if(densityCodesExists) migrationBuilder.DropForeignKey("FK_DensityCodes_SscSupportedMedias_SscSupportedMedia_Id", "DensityCodes"); - if(DevicesExists) + if(devicesExists) { migrationBuilder.DropForeignKey("FK_Devices_Atas_ATA_Id", "Devices"); migrationBuilder.DropForeignKey("FK_Devices_Atas_ATAPI_Id", "Devices"); @@ -69,19 +69,19 @@ namespace Aaru.Server.Migrations migrationBuilder.DropForeignKey("FK_Devices_Usbs_USB_Id", "Devices"); } - if(DeviceStatsExists) + if(deviceStatsExists) migrationBuilder.DropForeignKey("FK_DeviceStats_Devices_Report_Id", "DeviceStats"); - if(MmcsExists) + if(mmcsExists) migrationBuilder.DropForeignKey("FK_Mmcs_MmcFeatures_Features_Id", "Mmcs"); - if(ScsiPagesExists) + if(scsiPagesExists) { migrationBuilder.DropForeignKey("FK_ScsiPages_ScsiModes_ScsiMode_Id", "ScsiPages"); migrationBuilder.DropForeignKey("FK_ScsiPages_Scsis_Scsi_Id", "ScsiPages"); } - if(ScsisExists) + if(scsisExists) { migrationBuilder.DropForeignKey("FK_Scsis_Mmcs_MultiMediaDevice_Id", "Scsis"); migrationBuilder.DropForeignKey("FK_Scsis_ScsiModes_ModeSense_Id", "Scsis"); @@ -89,19 +89,19 @@ namespace Aaru.Server.Migrations migrationBuilder.DropForeignKey("FK_Scsis_TestedMedias_ReadCapabilities_Id", "Scsis"); } - if(SscSupportedMediasExists) + if(sscSupportedMediasExists) { migrationBuilder.DropForeignKey("FK_a812ec60296b45bcb3d245a5c6d01d73", "SscSupportedMedias"); migrationBuilder.DropForeignKey("FK_SscSupportedMedias_Sscs_Ssc_Id", "SscSupportedMedias"); } - if(SupportedDensitiesExists) + if(supportedDensitiesExists) { migrationBuilder.DropForeignKey("FK_783f1b3552774280af1caf44fb27e285", "SupportedDensities"); migrationBuilder.DropForeignKey("FK_SupportedDensities_Sscs_Ssc_Id", "SupportedDensities"); } - if(TestedMediasExists) + if(testedMediasExists) { migrationBuilder.DropForeignKey("FK_TestedMedias_Atas_Ata_Id", "TestedMedias"); migrationBuilder.DropForeignKey("FK_TestedMedias_Chs_CHS_Id", "TestedMedias"); @@ -110,10 +110,10 @@ namespace Aaru.Server.Migrations migrationBuilder.DropForeignKey("FK_TestedMedias_Scsis_Scsi_Id", "TestedMedias"); } - if(TestedSequentialMediasExists) + if(testedSequentialMediasExists) migrationBuilder.DropForeignKey("FK_TestedSequentialMedias_Sscs_Ssc_Id", "TestedSequentialMedias"); - if(UploadedReportsExists) + if(uploadedReportsExists) { migrationBuilder.DropForeignKey("FK_UploadedReports_Atas_ATA_Id", "UploadedReports"); migrationBuilder.DropForeignKey("FK_UploadedReports_Atas_ATAPI_Id", "UploadedReports"); @@ -125,7 +125,7 @@ namespace Aaru.Server.Migrations migrationBuilder.DropForeignKey("FK_UploadedReports_Usbs_USB_Id", "UploadedReports"); } - if(UsbProductsExists) + if(usbProductsExists) migrationBuilder.DropForeignKey("FK_UsbProducts_UsbVendors_VendorId", "UsbProducts"); #endregion @@ -134,16 +134,16 @@ namespace Aaru.Server.Migrations { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Manufacturer = table.Column(nullable: true), Model = table.Column(nullable: true), - Offset = table.Column(), Submissions = table.Column(), + Manufacturer = table.Column(nullable: true), + Model = table.Column(nullable: true), + Offset = table.Column(), + Submissions = table.Column(), Agreement = table.Column(), - AddedWhen = table.Column(), ModifiedWhen = table.Column() - }, constraints: table => - { - table.PrimaryKey("PK_CdOffsets", x => x.Id); - }); + AddedWhen = table.Column(), + ModifiedWhen = table.Column() + }, constraints: table => table.PrimaryKey("PK_CdOffsets", x => x.Id)); - if(CompactDiscOffsetsExists) + if(compactDiscOffsetsExists) { migrationBuilder. Sql("INSERT INTO CdOffsets (Id, Manufacturer, Model, Offset, Submissions, Agreement, AddedWhen, ModifiedWhen) SELECT Id, Manufacturer, Model, Offset, Submissions, Agreement, AddedWhen, ModifiedWhen FROM CompactDiscOffsets"); @@ -153,23 +153,22 @@ namespace Aaru.Server.Migrations #endregion #region TABLE: Chs - if(ChsExists) + if(chsExists) migrationBuilder.RenameTable("Chs", newName: "Chs_old"); migrationBuilder.CreateTable("Chs", table => new { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Cylinders = table.Column(), Heads = table.Column(), + Cylinders = table.Column(), + Heads = table.Column(), Sectors = table.Column(), - CylindersSql = table.Column(), HeadsSql = table.Column(), + CylindersSql = table.Column(), + HeadsSql = table.Column(), SectorsSql = table.Column() - }, constraints: table => - { - table.PrimaryKey("PK_Chs", x => x.Id); - }); + }, constraints: table => table.PrimaryKey("PK_Chs", x => x.Id)); - if(ChsExists) + if(chsExists) { migrationBuilder. Sql("INSERT INTO Chs (Id, Cylinders, Heads, Sectors, CylindersSql, HeadsSql, SectorsSql) SELECT Id, CylindersSql AS Cylinders, HeadsSql AS Heads, SectorsSql AS Sectors, CylindersSql, HeadsSql, SectorsSql FROM Chs_old"); @@ -179,20 +178,18 @@ namespace Aaru.Server.Migrations #endregion #region TABLE: Commands - if(CommandsExists) + if(commandsExists) migrationBuilder.RenameTable("Commands", newName: "Commands_old"); migrationBuilder.CreateTable("Commands", table => new { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(nullable: true), Count = table.Column() - }, constraints: table => - { - table.PrimaryKey("PK_Commands", x => x.Id); - }); + Name = table.Column(nullable: true), + Count = table.Column() + }, constraints: table => table.PrimaryKey("PK_Commands", x => x.Id)); - if(CommandsExists) + if(commandsExists) { migrationBuilder.Sql("INSERT INTO Commands (Id, Name, Count) SELECT Id, Name, Count FROM Commands_old"); migrationBuilder.DropTable("Commands_old"); @@ -200,20 +197,18 @@ namespace Aaru.Server.Migrations #endregion #region TABLE: Filesystems - if(FilesystemsExists) + if(filesystemsExists) migrationBuilder.RenameTable("Filesystems", newName: "Filesystems_old"); migrationBuilder.CreateTable("Filesystems", table => new { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(nullable: true), Count = table.Column() - }, constraints: table => - { - table.PrimaryKey("PK_Filesystems", x => x.Id); - }); + Name = table.Column(nullable: true), + Count = table.Column() + }, constraints: table => table.PrimaryKey("PK_Filesystems", x => x.Id)); - if(FilesystemsExists) + if(filesystemsExists) { migrationBuilder. Sql("INSERT INTO Filesystems (Id, Name, Count) SELECT Id, Name, Count FROM Filesystems_old"); @@ -223,20 +218,18 @@ namespace Aaru.Server.Migrations #endregion #region TABLE: Filters - if(FiltersExists) + if(filtersExists) migrationBuilder.RenameTable("Filters", newName: "Filters_old"); migrationBuilder.CreateTable("Filters", table => new { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(nullable: true), Count = table.Column() - }, constraints: table => - { - table.PrimaryKey("PK_Filters", x => x.Id); - }); + Name = table.Column(nullable: true), + Count = table.Column() + }, constraints: table => table.PrimaryKey("PK_Filters", x => x.Id)); - if(FiltersExists) + if(filtersExists) { migrationBuilder.Sql("INSERT INTO Filters (Id, Name, Count) SELECT Id, Name, Count FROM Filters_old"); migrationBuilder.DropTable("Filters_old"); @@ -248,16 +241,16 @@ namespace Aaru.Server.Migrations { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - VendorID = table.Column(), ProductID = table.Column(), - Manufacturer = table.Column(nullable: true), Product = table.Column(nullable: true), - RemovableMedia = table.Column(), VendorIDSql = table.Column(), + VendorID = table.Column(), + ProductID = table.Column(), + Manufacturer = table.Column(nullable: true), + Product = table.Column(nullable: true), + RemovableMedia = table.Column(), + VendorIDSql = table.Column(), ProductIDSql = table.Column() - }, constraints: table => - { - table.PrimaryKey("PK_FireWire", x => x.Id); - }); + }, constraints: table => table.PrimaryKey("PK_FireWire", x => x.Id)); - if(FireWiresExists) + if(fireWiresExists) { migrationBuilder. Sql("INSERT INTO FireWire (Id, VendorID, ProductID, Manufacturer, Product, RemovableMedia, VendorIDSql, ProductIDSql) SELECT Id, VendorIDSql AS VendorID, ProductIDSql AS ProductID, Manufacturer, Product, RemovableMedia, VendorIDSql, ProductIDSql FROM FireWires"); @@ -267,20 +260,18 @@ namespace Aaru.Server.Migrations #endregion #region TABLE: MediaFormats - if(MediaFormatsExists) + if(mediaFormatsExists) migrationBuilder.RenameTable("MediaFormats", newName: "MediaFormats_old"); migrationBuilder.CreateTable("MediaFormats", table => new { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(nullable: true), Count = table.Column() - }, constraints: table => - { - table.PrimaryKey("PK_MediaFormats", x => x.Id); - }); + Name = table.Column(nullable: true), + Count = table.Column() + }, constraints: table => table.PrimaryKey("PK_MediaFormats", x => x.Id)); - if(MediaFormatsExists) + if(mediaFormatsExists) { migrationBuilder. Sql("INSERT INTO MediaFormats (Id, Name, Count) SELECT Id, Name, Count FROM MediaFormats_old"); @@ -294,13 +285,12 @@ namespace Aaru.Server.Migrations { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Type = table.Column(nullable: true), Real = table.Column(), Count = table.Column() - }, constraints: table => - { - table.PrimaryKey("PK_Medias", x => x.Id); - }); + Type = table.Column(nullable: true), + Real = table.Column(), + Count = table.Column() + }, constraints: table => table.PrimaryKey("PK_Medias", x => x.Id)); - if(MediaExists) + if(mediaExists) { migrationBuilder. Sql("INSERT INTO Medias (`Id`, `Type`, `Real`, `Count`) SELECT `Id`, `Type`, `Real`, `Count` FROM Media"); @@ -310,7 +300,7 @@ namespace Aaru.Server.Migrations #endregion #region TABLE: MmcFeatures - if(MmcFeaturesExists) + if(mmcFeaturesExists) migrationBuilder.RenameTable("MmcFeatures", newName: "MmcFeatures_old"); migrationBuilder.CreateTable("MmcFeatures", table => new @@ -445,12 +435,9 @@ namespace Aaru.Server.Migrations LogicalBlockSizeSql = table.Column(nullable: true), PhysicalInterfaceStandardNumberSql = table.Column(nullable: true), VolumeLevelsSql = table.Column(nullable: true) - }, constraints: table => - { - table.PrimaryKey("PK_MmcFeatures", x => x.Id); - }); + }, constraints: table => table.PrimaryKey("PK_MmcFeatures", x => x.Id)); - if(MmcFeaturesExists) + if(mmcFeaturesExists) { migrationBuilder.Sql(@"INSERT INTO MmcFeatures (AACSVersion, AGIDs, @@ -973,15 +960,14 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - CID = table.Column(nullable: true), CSD = table.Column(nullable: true), - OCR = table.Column(nullable: true), SCR = table.Column(nullable: true), + CID = table.Column(nullable: true), + CSD = table.Column(nullable: true), + OCR = table.Column(nullable: true), + SCR = table.Column(nullable: true), ExtendedCSD = table.Column(nullable: true) - }, constraints: table => - { - table.PrimaryKey("PK_MmcSd", x => x.Id); - }); + }, constraints: table => table.PrimaryKey("PK_MmcSd", x => x.Id)); - if(MmcSdsExists) + if(mmcSdsExists) { migrationBuilder. Sql("INSERT INTO MmcSd (Id, CID, CSD, OCR, SCR, ExtendedCSD) SELECT Id, CID, CSD, OCR, SCR, ExtendedCSD FROM MmcSds"); @@ -991,21 +977,19 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); #endregion #region TABLE: OperatingSystems - if(OperatingSystemsExists) + if(operatingSystemsExists) migrationBuilder.RenameTable("OperatingSystems", newName: "OperatingSystems_old"); migrationBuilder.CreateTable("OperatingSystems", table => new { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(nullable: true), Version = table.Column(nullable: true), - Count = table.Column() - }, constraints: table => - { - table.PrimaryKey("PK_OperatingSystems", x => x.Id); - }); + Name = table.Column(nullable: true), + Version = table.Column(nullable: true), + Count = table.Column() + }, constraints: table => table.PrimaryKey("PK_OperatingSystems", x => x.Id)); - if(OperatingSystemsExists) + if(operatingSystemsExists) { migrationBuilder. Sql("INSERT INTO OperatingSystems (Id, Name, Version, Count) SELECT Id, Name, Version, Count FROM OperatingSystems_old"); @@ -1015,20 +999,18 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); #endregion #region TABLE: Partitions - if(PartitionsExists) + if(partitionsExists) migrationBuilder.RenameTable("Partitions", newName: "Partitions_old"); migrationBuilder.CreateTable("Partitions", table => new { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(nullable: true), Count = table.Column() - }, constraints: table => - { - table.PrimaryKey("PK_Partitions", x => x.Id); - }); + Name = table.Column(nullable: true), + Count = table.Column() + }, constraints: table => table.PrimaryKey("PK_Partitions", x => x.Id)); - if(PartitionsExists) + if(partitionsExists) { migrationBuilder. Sql("INSERT INTO Partitions (Id, Name, Count) SELECT Id, Name, Count FROM Partitions_old"); @@ -1050,12 +1032,9 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); ProductName = table.Column(nullable: true), ManufacturerCodeSql = table.Column(nullable: true), CardCodeSql = table.Column(nullable: true) - }, constraints: table => - { - table.PrimaryKey("PK_Pcmcia", x => x.Id); - }); + }, constraints: table => table.PrimaryKey("PK_Pcmcia", x => x.Id)); - if(PcmciasExists) + if(pcmciasExists) { migrationBuilder. Sql("INSERT INTO Pcmcia (Id, CIS, Compliance, ManufacturerCode, CardCode, Manufacturer, ProductName, ManufacturerCodeSql, CardCodeSql) SELECT Id, CIS, Compliance, ManufacturerCodeSql AS ManufacturerCode, CardCodeSql AS CardCode, Manufacturer, ProductName, ManufacturerCodeSql, CardCodeSql FROM Pcmcias"); @@ -1069,16 +1048,15 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - MediumType = table.Column(nullable: true), WriteProtected = table.Column(), + MediumType = table.Column(nullable: true), + WriteProtected = table.Column(), Speed = table.Column(nullable: true), BufferedMode = table.Column(nullable: true), - BlankCheckEnabled = table.Column(), DPOandFUA = table.Column() - }, constraints: table => - { - table.PrimaryKey("PK_ScsiMode", x => x.Id); - }); + BlankCheckEnabled = table.Column(), + DPOandFUA = table.Column() + }, constraints: table => table.PrimaryKey("PK_ScsiMode", x => x.Id)); - if(ScsiModesExists) + if(scsiModesExists) { migrationBuilder. Sql("INSERT INTO ScsiMode (Id, MediumType, WriteProtected, Speed, BufferedMode, BlankCheckEnabled, DPOandFUA) SELECT Id, MediumType, WriteProtected, Speed, BufferedMode, BlankCheckEnabled, DPOandFUA FROM ScsiModes"); @@ -1097,12 +1075,9 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); MinBlockLength = table.Column(nullable: true), MaxBlockLengthSql = table.Column(nullable: true), MinBlockLengthSql = table.Column(nullable: true) - }, constraints: table => - { - table.PrimaryKey("PK_Ssc", x => x.Id); - }); + }, constraints: table => table.PrimaryKey("PK_Ssc", x => x.Id)); - if(SscsExists) + if(sscsExists) { migrationBuilder. Sql("INSERT INTO Ssc (Id, BlockSizeGranularity, MaxBlockLength, MinBlockLength, MaxBlockLengthSql, MinBlockLengthSql) SELECT Id, BlockSizeGranularity, MaxBlockLengthSql AS MaxBlockLength, MinBlockLengthSql AS MinBlockLength, MaxBlockLengthSql, MinBlockLengthSql FROM Sscs"); @@ -1116,16 +1091,17 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - VendorID = table.Column(), ProductID = table.Column(), - Manufacturer = table.Column(nullable: true), Product = table.Column(nullable: true), - RemovableMedia = table.Column(), Descriptors = table.Column(nullable: true), - VendorIDSql = table.Column(), ProductIDSql = table.Column() - }, constraints: table => - { - table.PrimaryKey("PK_Usb", x => x.Id); - }); + VendorID = table.Column(), + ProductID = table.Column(), + Manufacturer = table.Column(nullable: true), + Product = table.Column(nullable: true), + RemovableMedia = table.Column(), + Descriptors = table.Column(nullable: true), + VendorIDSql = table.Column(), + ProductIDSql = table.Column() + }, constraints: table => table.PrimaryKey("PK_Usb", x => x.Id)); - if(UsbsExists) + if(usbsExists) { migrationBuilder. Sql("INSERT INTO Usb (Id, VendorID, ProductID, Manufacturer, Product, RemovableMedia, Descriptors, VendorIDSql, ProductIDSql) SELECT Id, VendorIDSql AS VendorID, ProductIDSql AS ProductID, Manufacturer, Product, RemovableMedia, Descriptors, VendorIDSql, ProductIDSql FROM Usbs WHERE VendorIDSql >= 0 AND ProductIDSql >= 0"); @@ -1144,21 +1120,20 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); #endregion #region TABLE: UsbVendors - if(UsbVendorsExists) + if(usbVendorsExists) migrationBuilder.RenameTable("UsbVendors", newName: "UsbVendors_old"); migrationBuilder.CreateTable("UsbVendors", table => new { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - VendorId = table.Column(), Vendor = table.Column(nullable: true), - AddedWhen = table.Column(), ModifiedWhen = table.Column() - }, constraints: table => - { - table.PrimaryKey("PK_UsbVendors", x => x.Id); - }); + VendorId = table.Column(), + Vendor = table.Column(nullable: true), + AddedWhen = table.Column(), + ModifiedWhen = table.Column() + }, constraints: table => table.PrimaryKey("PK_UsbVendors", x => x.Id)); - if(UsbVendorsExists) + if(usbVendorsExists) { migrationBuilder. Sql("INSERT INTO UsbVendors (Id, VendorId, Vendor, AddedWhen, ModifiedWhen) SELECT Id, VendorId, Vendor, AddedWhen, ModifiedWhen FROM UsbVendors_old"); @@ -1168,20 +1143,18 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); #endregion #region TABLE: Versions - if(VersionsExists) + if(versionsExists) migrationBuilder.RenameTable("Versions", newName: "Versions_old"); migrationBuilder.CreateTable("Versions", table => new { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Value = table.Column(nullable: true), Count = table.Column() - }, constraints: table => - { - table.PrimaryKey("PK_Versions", x => x.Id); - }); + Value = table.Column(nullable: true), + Count = table.Column() + }, constraints: table => table.PrimaryKey("PK_Versions", x => x.Id)); - if(VersionsExists) + if(versionsExists) { migrationBuilder. Sql("INSERT INTO Versions (`Id`, `Value`, `Count`) SELECT `Id`, `Value`, `Count` FROM Versions_old"); @@ -1195,7 +1168,8 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - FeaturesId = table.Column(nullable: true), ModeSense2AData = table.Column(nullable: true) + FeaturesId = table.Column(nullable: true), + ModeSense2AData = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Mmc", x => x.Id); @@ -1204,7 +1178,7 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); onDelete: ReferentialAction.Restrict); }); - if(MmcsExists) + if(mmcsExists) { migrationBuilder. Sql("INSERT INTO Mmc (Id, FeaturesId, ModeSense2AData) SELECT Id, Features_Id, ModeSense2AData FROM Mmcs WHERE EXISTS(SELECT 1 FROM MmcFeatures WHERE MmcFeatures.Id = Features_Id) OR Features_Id IS NULL"); @@ -1218,9 +1192,12 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Density = table.Column(), Blocks = table.Column(nullable: true), - BlockLength = table.Column(nullable: true), BlocksSql = table.Column(nullable: true), - BlockLengthSql = table.Column(nullable: true), ScsiModeId = table.Column(nullable: true) + Density = table.Column(), + Blocks = table.Column(nullable: true), + BlockLength = table.Column(nullable: true), + BlocksSql = table.Column(nullable: true), + BlockLengthSql = table.Column(nullable: true), + ScsiModeId = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_BlockDescriptor", x => x.Id); @@ -1229,7 +1206,7 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); onDelete: ReferentialAction.Restrict); }); - if(BlockDescriptorsExists) + if(blockDescriptorsExists) { migrationBuilder. Sql("INSERT INTO BlockDescriptor (Id, Density, Blocks, BlocksSql, BlockLength, BlockLengthSql, ScsiModeId) SELECT Id, Density, BlocksSql AS Blocks, BlocksSql, BlockLengthSql AS BlockLength, BlockLengthSql, ScsiMode_Id FROM BlockDescriptors"); @@ -1245,7 +1222,8 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), CanReadMediaSerial = table.Column(nullable: true), Density = table.Column(nullable: true), - Manufacturer = table.Column(nullable: true), MediaIsRecognized = table.Column(), + Manufacturer = table.Column(nullable: true), + MediaIsRecognized = table.Column(), MediumType = table.Column(nullable: true), MediumTypeName = table.Column(nullable: true), Model = table.Column(nullable: true), @@ -1260,7 +1238,7 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); onDelete: ReferentialAction.Restrict); }); - if(TestedSequentialMediasExists) + if(testedSequentialMediasExists) { migrationBuilder. Sql("INSERT INTO TestedSequentialMedia (Id, CanReadMediaSerial, Density, Manufacturer, MediaIsRecognized, MediumType, MediumTypeName, Model, ModeSense6Data, ModeSense10Data, SscId) SELECT Id, CanReadMediaSerial, Density, Manufacturer, MediaIsRecognized, MediumType, MediumTypeName, Model, ModeSense6Data, ModeSense10Data, Ssc_Id FROM TestedSequentialMedias"); @@ -1270,16 +1248,18 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); #endregion #region TABLE: UsbProducts - if(UsbProductsExists) + if(usbProductsExists) migrationBuilder.RenameTable("UsbProducts", newName: "UsbProducts_old"); migrationBuilder.CreateTable("UsbProducts", table => new { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ProductId = table.Column(), Product = table.Column(nullable: true), - AddedWhen = table.Column(), ModifiedWhen = table.Column(), - VendorId = table.Column() + ProductId = table.Column(), + Product = table.Column(nullable: true), + AddedWhen = table.Column(), + ModifiedWhen = table.Column(), + VendorId = table.Column() }, constraints: table => { table.PrimaryKey("PK_UsbProducts", x => x.Id); @@ -1288,7 +1268,7 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); onDelete: ReferentialAction.Cascade); }); - if(UsbProductsExists) + if(usbProductsExists) { migrationBuilder. Sql("INSERT INTO UsbProducts (Id, ProductId, Product, AddedWhen, ModifiedWhen, VendorId) SELECT Id, ProductId, Product, AddedWhen, ModifiedWhen, VendorId FROM UsbProducts_old"); @@ -1302,11 +1282,13 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - MediumType = table.Column(), Width = table.Column(), + MediumType = table.Column(), + Width = table.Column(), Length = table.Column(), Organization = table.Column(nullable: true), Name = table.Column(nullable: true), - Description = table.Column(nullable: true), WidthSql = table.Column(), + Description = table.Column(nullable: true), + WidthSql = table.Column(), LengthSql = table.Column(), SscId = table.Column(nullable: true), TestedSequentialMediaId = table.Column(nullable: true) @@ -1322,7 +1304,7 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); onDelete: ReferentialAction.Restrict); }); - if(SscSupportedMediasExists) + if(sscSupportedMediasExists) { migrationBuilder. Sql("INSERT INTO SscSupportedMedia (Id, MediumType, Width, Length, Organization, Name, Description, WidthSql, LengthSql, SscId, TestedSequentialMediaId) SELECT Id, MediumType, WidthSql AS Width, LengthSql AS Length, Organization, Name, Description, WidthSql, LengthSql, Ssc_Id, TestedSequentialMedia_Id FROM SscSupportedMedias"); @@ -1336,15 +1318,21 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - PrimaryCode = table.Column(), SecondaryCode = table.Column(), - Writable = table.Column(), Duplicate = table.Column(), - DefaultDensity = table.Column(), BitsPerMm = table.Column(), + PrimaryCode = table.Column(), + SecondaryCode = table.Column(), + Writable = table.Column(), + Duplicate = table.Column(), + DefaultDensity = table.Column(), + BitsPerMm = table.Column(), Width = table.Column(), - Tracks = table.Column(), Capacity = table.Column(), + Tracks = table.Column(), + Capacity = table.Column(), Organization = table.Column(nullable: true), Name = table.Column(nullable: true), - Description = table.Column(nullable: true), BitsPerMmSql = table.Column(), - WidthSql = table.Column(), TracksSql = table.Column(), + Description = table.Column(nullable: true), + BitsPerMmSql = table.Column(), + WidthSql = table.Column(), + TracksSql = table.Column(), CapacitySql = table.Column(), SscId = table.Column(nullable: true), TestedSequentialMediaId = table.Column(nullable: true) @@ -1360,7 +1348,7 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); onDelete: ReferentialAction.Restrict); }); - if(SupportedDensitiesExists) + if(supportedDensitiesExists) { migrationBuilder. Sql("INSERT INTO SupportedDensity (PrimaryCode, SecondaryCode, Writable, Duplicate, DefaultDensity, BitsPerMm, Width, Tracks, Capacity, Organization, Name, Description, BitsPerMmSql, WidthSql, TracksSql, CapacitySql, SscId, TestedSequentialMediaId) SELECT PrimaryCode, SecondaryCode, Writable, Duplicate, DefaultDensity, BitsPerMmSql AS BitsPerMm, WidthSql AS Width, TracksSql AS Tracks, CapacitySql AS Capacity, Organization, Name, Description, BitsPerMmSql, WidthSql, TracksSql, CapacitySql, Ssc_Id, TestedSequentialMedia_Id FROM SupportedDensities"); @@ -1374,7 +1362,8 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Code = table.Column(), SscSupportedMediaId = table.Column(nullable: true) + Code = table.Column(), + SscSupportedMediaId = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_DensityCode", x => x.Id); @@ -1383,7 +1372,7 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); "SscSupportedMedia", "Id", onDelete: ReferentialAction.Restrict); }); - if(DensityCodesExists) + if(densityCodesExists) { migrationBuilder. Sql("INSERT INTO DensityCode (Id, Code, SscSupportedMediaId) SELECT Id, Code, SscSupportedMedia_Id FROM DensityCodes"); @@ -1393,27 +1382,30 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); #endregion #region TABLE: Devices - if(DevicesExists) + if(devicesExists) migrationBuilder.RenameTable("Devices", newName: "Devices_old"); migrationBuilder.CreateTable("Devices", table => new { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - USBId = table.Column(nullable: true), - FireWireId = table.Column(nullable: true), - PCMCIAId = table.Column(nullable: true), CompactFlash = table.Column(), - ATAId = table.Column(nullable: true), - ATAPIId = table.Column(nullable: true), - SCSIId = table.Column(nullable: true), - MultiMediaCardId = table.Column(nullable: true), - SecureDigitalId = table.Column(nullable: true), - Manufacturer = table.Column(nullable: true), - Model = table.Column(nullable: true), - Revision = table.Column(nullable: true), Type = table.Column(), - AddedWhen = table.Column(), - ModifiedWhen = table.Column(nullable: true), - CdOffsetId = table.Column(nullable: true), OptimalMultipleSectorsRead = table.Column() + USBId = table.Column(nullable: true), + FireWireId = table.Column(nullable: true), + PCMCIAId = table.Column(nullable: true), + CompactFlash = table.Column(), + ATAId = table.Column(nullable: true), + ATAPIId = table.Column(nullable: true), + SCSIId = table.Column(nullable: true), + MultiMediaCardId = table.Column(nullable: true), + SecureDigitalId = table.Column(nullable: true), + Manufacturer = table.Column(nullable: true), + Model = table.Column(nullable: true), + Revision = table.Column(nullable: true), + Type = table.Column(), + AddedWhen = table.Column(), + ModifiedWhen = table.Column(nullable: true), + CdOffsetId = table.Column(nullable: true), + OptimalMultipleSectorsRead = table.Column() }, constraints: table => { table.PrimaryKey("PK_Devices", x => x.Id); @@ -1437,7 +1429,7 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); onDelete: ReferentialAction.Restrict); }); - if(DevicesExists) + if(devicesExists) { migrationBuilder. Sql("INSERT INTO Devices (Id, USBId, FireWireId, PCMCIAId, CompactFlash, ATAId, ATAPIId, SCSIId, MultiMediaCardId, SecureDigitalId, Manufacturer, Model, Revision, Type, AddedWhen, ModifiedWhen, CdOffsetId, OptimalMultipleSectorsRead) SELECT Id, USB_Id, FireWire_Id, PCMCIA_Id, CompactFlash, ATA_Id, ATAPI_Id, SCSI_Id, MultiMediaCard_Id, SecureDigital_Id, Manufacturer, Model, Revision, Type, AddedWhen, ModifiedWhen, CdOffset_Id, OptimalMultipleSectorsRead FROM Devices_old"); @@ -1447,15 +1439,17 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); #endregion #region TABLE: DeviceStats - if(DeviceStatsExists) + if(deviceStatsExists) migrationBuilder.RenameTable("DeviceStats", newName: "DeviceStats_old"); migrationBuilder.CreateTable("DeviceStats", table => new { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Manufacturer = table.Column(nullable: true), Model = table.Column(nullable: true), - Revision = table.Column(nullable: true), Bus = table.Column(nullable: true), + Manufacturer = table.Column(nullable: true), + Model = table.Column(nullable: true), + Revision = table.Column(nullable: true), + Bus = table.Column(nullable: true), ReportId = table.Column(nullable: true) }, constraints: table => { @@ -1465,7 +1459,7 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); onDelete: ReferentialAction.Restrict); }); - if(DeviceStatsExists) + if(deviceStatsExists) { migrationBuilder. Sql("INSERT INTO DeviceStats (Id, Manufacturer, Model, Revision, Bus, ReportId) SELECT Id, Manufacturer, Model, Revision, Bus, Report_Id FROM DeviceStats_old"); @@ -1481,14 +1475,17 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), USBId = table.Column(nullable: true), FireWireId = table.Column(nullable: true), - PCMCIAId = table.Column(nullable: true), CompactFlash = table.Column(), + PCMCIAId = table.Column(nullable: true), + CompactFlash = table.Column(), ATAId = table.Column(nullable: true), ATAPIId = table.Column(nullable: true), SCSIId = table.Column(nullable: true), MultiMediaCardId = table.Column(nullable: true), SecureDigitalId = table.Column(nullable: true), - Manufacturer = table.Column(nullable: true), Model = table.Column(nullable: true), - Revision = table.Column(nullable: true), Type = table.Column(), + Manufacturer = table.Column(nullable: true), + Model = table.Column(nullable: true), + Revision = table.Column(nullable: true), + Type = table.Column(), UploadedWhen = table.Column() }, constraints: table => { @@ -1510,7 +1507,7 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); onDelete: ReferentialAction.Restrict); }); - if(UploadedReportsExists) + if(uploadedReportsExists) { migrationBuilder. Sql("INSERT INTO Reports (Id, USBId, FireWireId, PCMCIAId, CompactFlash, ATAId, ATAPIId, SCSIId, MultiMediaCardId, SecureDigitalId, Manufacturer, Model, Revision, Type, UploadedWhen) SELECT Id, USB_Id, FireWire_Id, PCMCIA_Id, CompactFlash, ATA_Id, ATAPI_Id, SCSI_Id, MultiMediaCard_Id, SecureDigital_Id, Manufacturer, Model, Revision, Type, UploadedWhen FROM UploadedReports"); @@ -1703,7 +1700,7 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); onDelete: ReferentialAction.Restrict); }); - if(TestedMediasExists) + if(testedMediasExists) { string preFormat = @"INSERT INTO TestedMedia (Id, IdentifyData, Blocks, BlockSize, CanReadAACS, CanReadADIP, @@ -1792,7 +1789,8 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Identify = table.Column(nullable: true), ReadCapabilitiesId = table.Column(nullable: true) + Identify = table.Column(nullable: true), + ReadCapabilitiesId = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Ata", x => x.Id); @@ -1801,7 +1799,7 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); "Id", onDelete: ReferentialAction.Restrict); }); - if(AtasExists) + if(atasExists) { migrationBuilder. Sql("INSERT INTO Ata (Id, Identify, ReadCapabilitiesId) SELECT Id, Identify, ReadCapabilities_Id FROM Atas"); @@ -1846,7 +1844,7 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); onDelete: ReferentialAction.Restrict); }); - if(ScsisExists) + if(scsisExists) { migrationBuilder.Sql( "INSERT INTO Scsi (Id, InquiryData, SupportsModeSense6, SupportsModeSense10, SupportsModeSubpages, ModeSenseId, MultiMediaDeviceId, ReadCapabilitiesId, SequentialDeviceId, ModeSense6Data, ModeSense10Data, ModeSense6CurrentData, ModeSense10CurrentData, ModeSense6ChangeableData, ModeSense10ChangeableData) SELECT Id, InquiryData, SupportsModeSense6, SupportsModeSense10, SupportsModeSubpages, ModeSense_Id, MultiMediaDevice_Id, ReadCapabilities_Id, SequentialDevice_Id, ModeSense6Data, ModeSense10Data, ModeSense6CurrentData, ModeSense10CurrentData, ModeSense6ChangeableData, ModeSense10ChangeableData FROM Scsis WHERE EXISTS(SELECT 1 from Mmc WHERE Mmc.Id = Scsis.MultiMediaDevice_Id) OR MultiMediaDevice_Id IS NULL"); @@ -1860,8 +1858,10 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - page = table.Column(), subpage = table.Column(nullable: true), - value = table.Column(nullable: true), ScsiId = table.Column(nullable: true), + page = table.Column(), + subpage = table.Column(nullable: true), + value = table.Column(nullable: true), + ScsiId = table.Column(nullable: true), ScsiModeId = table.Column(nullable: true) }, constraints: table => { @@ -1874,7 +1874,7 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); onDelete: ReferentialAction.Restrict); }); - if(ScsiPagesExists) + if(scsiPagesExists) { migrationBuilder. Sql("INSERT INTO ScsiPage (Id, page, subpage, value, ScsiId, ScsiModeId) SELECT Id, page, subpage, value, Scsi_Id, ScsiMode_Id FROM ScsiPages"); @@ -2002,7 +2002,7 @@ VolumeLevelsSql FROM MmcFeatures_old WHERE VolumeLevelsSql < 0"); migrationBuilder.AddForeignKey("FK_TestedMedia_Scsi_ScsiId", "TestedMedia", "ScsiId", "Scsi", principalColumn: "Id", onDelete: ReferentialAction.Restrict); - if(EFExists) + if(efExists) migrationBuilder.DropTable("__MigrationHistory"); } diff --git a/Aaru.Server/Migrations/20191106230730_CreateIdentitySchema.cs b/Aaru.Server/Migrations/20191106230730_CreateIdentitySchema.cs index ba3b0de6..9b5e2c30 100644 --- a/Aaru.Server/Migrations/20191106230730_CreateIdentitySchema.cs +++ b/Aaru.Server/Migrations/20191106230730_CreateIdentitySchema.cs @@ -10,38 +10,37 @@ namespace Aaru.Server.Migrations { migrationBuilder.CreateTable("AspNetRoles", table => new { - Id = table.Column(), Name = table.Column(maxLength: 256, nullable: true), + Id = table.Column(), + Name = table.Column(maxLength: 256, nullable: true), NormalizedName = table.Column(maxLength: 256, nullable: true), ConcurrencyStamp = table.Column(nullable: true) - }, constraints: table => - { - table.PrimaryKey("PK_AspNetRoles", x => x.Id); - }); + }, constraints: table => table.PrimaryKey("PK_AspNetRoles", x => x.Id)); migrationBuilder.CreateTable("AspNetUsers", table => new { - Id = table.Column(), - UserName = table.Column(maxLength: 256, nullable: true), - NormalizedUserName = table.Column(maxLength: 256, nullable: true), - Email = table.Column(maxLength: 256, nullable: true), - NormalizedEmail = table.Column(maxLength: 256, nullable: true), - EmailConfirmed = table.Column(), PasswordHash = table.Column(nullable: true), - SecurityStamp = table.Column(nullable: true), - ConcurrencyStamp = table.Column(nullable: true), - PhoneNumber = table.Column(nullable: true), PhoneNumberConfirmed = table.Column(), - TwoFactorEnabled = table.Column(), - LockoutEnd = table.Column(nullable: true), - LockoutEnabled = table.Column(), AccessFailedCount = table.Column() - }, constraints: table => - { - table.PrimaryKey("PK_AspNetUsers", x => x.Id); - }); + Id = table.Column(), + UserName = table.Column(maxLength: 256, nullable: true), + NormalizedUserName = table.Column(maxLength: 256, nullable: true), + Email = table.Column(maxLength: 256, nullable: true), + NormalizedEmail = table.Column(maxLength: 256, nullable: true), + EmailConfirmed = table.Column(), + PasswordHash = table.Column(nullable: true), + SecurityStamp = table.Column(nullable: true), + ConcurrencyStamp = table.Column(nullable: true), + PhoneNumber = table.Column(nullable: true), + PhoneNumberConfirmed = table.Column(), + TwoFactorEnabled = table.Column(), + LockoutEnd = table.Column(nullable: true), + LockoutEnabled = table.Column(), + AccessFailedCount = table.Column() + }, constraints: table => table.PrimaryKey("PK_AspNetUsers", x => x.Id)); migrationBuilder.CreateTable("AspNetRoleClaims", table => new { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - RoleId = table.Column(), ClaimType = table.Column(nullable: true), + RoleId = table.Column(), + ClaimType = table.Column(nullable: true), ClaimValue = table.Column(nullable: true) }, constraints: table => { @@ -55,7 +54,8 @@ namespace Aaru.Server.Migrations { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - UserId = table.Column(), ClaimType = table.Column(nullable: true), + UserId = table.Column(), + ClaimType = table.Column(nullable: true), ClaimValue = table.Column(nullable: true) }, constraints: table => { @@ -69,12 +69,14 @@ namespace Aaru.Server.Migrations { LoginProvider = table.Column(maxLength: 128), ProviderKey = table.Column(maxLength: 128), - ProviderDisplayName = table.Column(nullable: true), UserId = table.Column() + ProviderDisplayName = table.Column(nullable: true), + UserId = table.Column() }, constraints: table => { table.PrimaryKey("PK_AspNetUserLogins", x => new { - x.LoginProvider, x.ProviderKey + x.LoginProvider, + x.ProviderKey }); table.ForeignKey("FK_AspNetUserLogins_AspNetUsers_UserId", x => x.UserId, "AspNetUsers", "Id", @@ -83,12 +85,14 @@ namespace Aaru.Server.Migrations migrationBuilder.CreateTable("AspNetUserRoles", table => new { - UserId = table.Column(), RoleId = table.Column() + UserId = table.Column(), + RoleId = table.Column() }, constraints: table => { table.PrimaryKey("PK_AspNetUserRoles", x => new { - x.UserId, x.RoleId + x.UserId, + x.RoleId }); table.ForeignKey("FK_AspNetUserRoles_AspNetRoles_RoleId", x => x.RoleId, "AspNetRoles", "Id", @@ -100,13 +104,17 @@ namespace Aaru.Server.Migrations migrationBuilder.CreateTable("AspNetUserTokens", table => new { - UserId = table.Column(), LoginProvider = table.Column(maxLength: 128), - Name = table.Column(maxLength: 128), Value = table.Column(nullable: true) + UserId = table.Column(), + LoginProvider = table.Column(maxLength: 128), + Name = table.Column(maxLength: 128), + Value = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AspNetUserTokens", x => new { - x.UserId, x.LoginProvider, x.Name + x.UserId, + x.LoginProvider, + x.Name }); table.ForeignKey("FK_AspNetUserTokens_AspNetUsers_UserId", x => x.UserId, "AspNetUsers", "Id", diff --git a/Aaru.Server/Migrations/20191204182314_RemoteStatistics.cs b/Aaru.Server/Migrations/20191204182314_RemoteStatistics.cs index 2ca2f0a8..dfe607d9 100644 --- a/Aaru.Server/Migrations/20191204182314_RemoteStatistics.cs +++ b/Aaru.Server/Migrations/20191204182314_RemoteStatistics.cs @@ -11,33 +11,27 @@ namespace Aaru.Server.Migrations { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(nullable: true), Version = table.Column(nullable: true), - Count = table.Column() - }, constraints: table => - { - table.PrimaryKey("PK_RemoteApplications", x => x.Id); - }); + Name = table.Column(nullable: true), + Version = table.Column(nullable: true), + Count = table.Column() + }, constraints: table => table.PrimaryKey("PK_RemoteApplications", x => x.Id)); migrationBuilder.CreateTable("RemoteArchitectures", table => new { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(nullable: true), Count = table.Column() - }, constraints: table => - { - table.PrimaryKey("PK_RemoteArchitectures", x => x.Id); - }); + Name = table.Column(nullable: true), + Count = table.Column() + }, constraints: table => table.PrimaryKey("PK_RemoteArchitectures", x => x.Id)); migrationBuilder.CreateTable("RemoteOperatingSystems", table => new { Id = table.Column(). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - Name = table.Column(nullable: true), Version = table.Column(nullable: true), - Count = table.Column() - }, constraints: table => - { - table.PrimaryKey("PK_RemoteOperatingSystems", x => x.Id); - }); + Name = table.Column(nullable: true), + Version = table.Column(nullable: true), + Count = table.Column() + }, constraints: table => table.PrimaryKey("PK_RemoteOperatingSystems", x => x.Id)); } protected override void Down(MigrationBuilder migrationBuilder) diff --git a/Aaru.Server/Migrations/20200710172932_AddGdRomSwapDiscCapabilities.cs b/Aaru.Server/Migrations/20200710172932_AddGdRomSwapDiscCapabilities.cs index baf8f03c..f0665676 100644 --- a/Aaru.Server/Migrations/20200710172932_AddGdRomSwapDiscCapabilities.cs +++ b/Aaru.Server/Migrations/20200710172932_AddGdRomSwapDiscCapabilities.cs @@ -15,112 +15,113 @@ namespace Aaru.Server.Migrations { Id = table.Column(nullable: false). Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - RecognizedSwapDisc = table.Column(nullable: false), - SwapDiscLeadOutPMIN = table.Column(nullable: false), - SwapDiscLeadOutPSEC = table.Column(nullable: false), - SwapDiscLeadOutPFRAM = table.Column(nullable: false), - SwapDiscLeadOutStart = table.Column(nullable: false), - Lba0Readable = table.Column(nullable: false), Lba0Data = table.Column(nullable: true), - Lba0Sense = table.Column(nullable: true), - Lba0DecodedSense = table.Column(nullable: true), - Lba0ScrambledReadable = table.Column(nullable: false), - Lba0ScrambledData = table.Column(nullable: true), - Lba0ScrambledSense = table.Column(nullable: true), - Lba0ScrambledDecodedSense = table.Column(nullable: true), - Lba44990Readable = table.Column(nullable: false), - Lba44990Data = table.Column(nullable: true), - Lba44990Sense = table.Column(nullable: true), - Lba44990DecodedSense = table.Column(nullable: true), - Lba44990ReadableCluster = table.Column(nullable: false), - Lba45000Readable = table.Column(nullable: false), - Lba45000Data = table.Column(nullable: true), - Lba45000Sense = table.Column(nullable: true), - Lba45000DecodedSense = table.Column(nullable: true), - Lba45000ReadableCluster = table.Column(nullable: false), - Lba50000Readable = table.Column(nullable: false), - Lba50000Data = table.Column(nullable: true), - Lba50000Sense = table.Column(nullable: true), - Lba50000DecodedSense = table.Column(nullable: true), - Lba50000ReadableCluster = table.Column(nullable: false), - Lba100000Readable = table.Column(nullable: false), - Lba100000Data = table.Column(nullable: true), - Lba100000Sense = table.Column(nullable: true), - Lba100000DecodedSense = table.Column(nullable: true), - Lba100000ReadableCluster = table.Column(nullable: false), - Lba400000Readable = table.Column(nullable: false), - Lba400000Data = table.Column(nullable: true), - Lba400000Sense = table.Column(nullable: true), - Lba400000DecodedSense = table.Column(nullable: true), - Lba400000ReadableCluster = table.Column(nullable: false), - Lba450000Readable = table.Column(nullable: false), - Lba450000Data = table.Column(nullable: true), - Lba450000Sense = table.Column(nullable: true), - Lba450000DecodedSense = table.Column(nullable: true), - Lba450000ReadableCluster = table.Column(nullable: false), - Lba44990PqReadable = table.Column(nullable: false), - Lba44990PqData = table.Column(nullable: true), - Lba44990PqSense = table.Column(nullable: true), - Lba44990PqDecodedSense = table.Column(nullable: true), - Lba44990PqReadableCluster = table.Column(nullable: false), - Lba45000PqReadable = table.Column(nullable: false), - Lba45000PqData = table.Column(nullable: true), - Lba45000PqSense = table.Column(nullable: true), - Lba45000PqDecodedSense = table.Column(nullable: true), - Lba45000PqReadableCluster = table.Column(nullable: false), - Lba50000PqReadable = table.Column(nullable: false), - Lba50000PqData = table.Column(nullable: true), - Lba50000PqSense = table.Column(nullable: true), - Lba50000PqDecodedSense = table.Column(nullable: true), - Lba50000PqReadableCluster = table.Column(nullable: false), - Lba100000PqReadable = table.Column(nullable: false), - Lba100000PqData = table.Column(nullable: true), - Lba100000PqSense = table.Column(nullable: true), - Lba100000PqDecodedSense = table.Column(nullable: true), - Lba100000PqReadableCluster = table.Column(nullable: false), - Lba400000PqReadable = table.Column(nullable: false), - Lba400000PqData = table.Column(nullable: true), - Lba400000PqSense = table.Column(nullable: true), - Lba400000PqDecodedSense = table.Column(nullable: true), - Lba400000PqReadableCluster = table.Column(nullable: false), - Lba450000PqReadable = table.Column(nullable: false), - Lba450000PqData = table.Column(nullable: true), - Lba450000PqSense = table.Column(nullable: true), - Lba450000PqDecodedSense = table.Column(nullable: true), - Lba450000PqReadableCluster = table.Column(nullable: false), - Lba44990RwReadable = table.Column(nullable: false), - Lba44990RwData = table.Column(nullable: true), - Lba44990RwSense = table.Column(nullable: true), - Lba44990RwDecodedSense = table.Column(nullable: true), - Lba44990RwReadableCluster = table.Column(nullable: false), - Lba45000RwReadable = table.Column(nullable: false), - Lba45000RwData = table.Column(nullable: true), - Lba45000RwSense = table.Column(nullable: true), - Lba45000RwDecodedSense = table.Column(nullable: true), - Lba45000RwReadableCluster = table.Column(nullable: false), - Lba50000RwReadable = table.Column(nullable: false), - Lba50000RwData = table.Column(nullable: true), - Lba50000RwSense = table.Column(nullable: true), - Lba50000RwDecodedSense = table.Column(nullable: true), - Lba50000RwReadableCluster = table.Column(nullable: false), - Lba100000RwReadable = table.Column(nullable: false), - Lba100000RwData = table.Column(nullable: true), - Lba100000RwSense = table.Column(nullable: true), - Lba100000RwDecodedSense = table.Column(nullable: true), - Lba100000RwReadableCluster = table.Column(nullable: false), - Lba400000RwReadable = table.Column(nullable: false), - Lba400000RwData = table.Column(nullable: true), - Lba400000RwSense = table.Column(nullable: true), - Lba400000RwDecodedSense = table.Column(nullable: true), - Lba400000RwReadableCluster = table.Column(nullable: false), - Lba450000RwReadable = table.Column(nullable: false), - Lba450000RwData = table.Column(nullable: true), - Lba450000RwSense = table.Column(nullable: true), - Lba450000RwDecodedSense = table.Column(nullable: true), - Lba450000RwReadableCluster = table.Column(nullable: false), + RecognizedSwapDisc = table.Column(nullable: false), + SwapDiscLeadOutPMIN = table.Column(nullable: false), + SwapDiscLeadOutPSEC = table.Column(nullable: false), + SwapDiscLeadOutPFRAM = table.Column(nullable: false), + SwapDiscLeadOutStart = table.Column(nullable: false), + Lba0Readable = table.Column(nullable: false), + Lba0Data = table.Column(nullable: true), + Lba0Sense = table.Column(nullable: true), + Lba0DecodedSense = table.Column(nullable: true), + Lba0ScrambledReadable = table.Column(nullable: false), + Lba0ScrambledData = table.Column(nullable: true), + Lba0ScrambledSense = table.Column(nullable: true), + Lba0ScrambledDecodedSense = table.Column(nullable: true), + Lba44990Readable = table.Column(nullable: false), + Lba44990Data = table.Column(nullable: true), + Lba44990Sense = table.Column(nullable: true), + Lba44990DecodedSense = table.Column(nullable: true), + Lba44990ReadableCluster = table.Column(nullable: false), + Lba45000Readable = table.Column(nullable: false), + Lba45000Data = table.Column(nullable: true), + Lba45000Sense = table.Column(nullable: true), + Lba45000DecodedSense = table.Column(nullable: true), + Lba45000ReadableCluster = table.Column(nullable: false), + Lba50000Readable = table.Column(nullable: false), + Lba50000Data = table.Column(nullable: true), + Lba50000Sense = table.Column(nullable: true), + Lba50000DecodedSense = table.Column(nullable: true), + Lba50000ReadableCluster = table.Column(nullable: false), + Lba100000Readable = table.Column(nullable: false), + Lba100000Data = table.Column(nullable: true), + Lba100000Sense = table.Column(nullable: true), + Lba100000DecodedSense = table.Column(nullable: true), + Lba100000ReadableCluster = table.Column(nullable: false), + Lba400000Readable = table.Column(nullable: false), + Lba400000Data = table.Column(nullable: true), + Lba400000Sense = table.Column(nullable: true), + Lba400000DecodedSense = table.Column(nullable: true), + Lba400000ReadableCluster = table.Column(nullable: false), + Lba450000Readable = table.Column(nullable: false), + Lba450000Data = table.Column(nullable: true), + Lba450000Sense = table.Column(nullable: true), + Lba450000DecodedSense = table.Column(nullable: true), + Lba450000ReadableCluster = table.Column(nullable: false), + Lba44990PqReadable = table.Column(nullable: false), + Lba44990PqData = table.Column(nullable: true), + Lba44990PqSense = table.Column(nullable: true), + Lba44990PqDecodedSense = table.Column(nullable: true), + Lba44990PqReadableCluster = table.Column(nullable: false), + Lba45000PqReadable = table.Column(nullable: false), + Lba45000PqData = table.Column(nullable: true), + Lba45000PqSense = table.Column(nullable: true), + Lba45000PqDecodedSense = table.Column(nullable: true), + Lba45000PqReadableCluster = table.Column(nullable: false), + Lba50000PqReadable = table.Column(nullable: false), + Lba50000PqData = table.Column(nullable: true), + Lba50000PqSense = table.Column(nullable: true), + Lba50000PqDecodedSense = table.Column(nullable: true), + Lba50000PqReadableCluster = table.Column(nullable: false), + Lba100000PqReadable = table.Column(nullable: false), + Lba100000PqData = table.Column(nullable: true), + Lba100000PqSense = table.Column(nullable: true), + Lba100000PqDecodedSense = table.Column(nullable: true), + Lba100000PqReadableCluster = table.Column(nullable: false), + Lba400000PqReadable = table.Column(nullable: false), + Lba400000PqData = table.Column(nullable: true), + Lba400000PqSense = table.Column(nullable: true), + Lba400000PqDecodedSense = table.Column(nullable: true), + Lba400000PqReadableCluster = table.Column(nullable: false), + Lba450000PqReadable = table.Column(nullable: false), + Lba450000PqData = table.Column(nullable: true), + Lba450000PqSense = table.Column(nullable: true), + Lba450000PqDecodedSense = table.Column(nullable: true), + Lba450000PqReadableCluster = table.Column(nullable: false), + Lba44990RwReadable = table.Column(nullable: false), + Lba44990RwData = table.Column(nullable: true), + Lba44990RwSense = table.Column(nullable: true), + Lba44990RwDecodedSense = table.Column(nullable: true), + Lba44990RwReadableCluster = table.Column(nullable: false), + Lba45000RwReadable = table.Column(nullable: false), + Lba45000RwData = table.Column(nullable: true), + Lba45000RwSense = table.Column(nullable: true), + Lba45000RwDecodedSense = table.Column(nullable: true), + Lba45000RwReadableCluster = table.Column(nullable: false), + Lba50000RwReadable = table.Column(nullable: false), + Lba50000RwData = table.Column(nullable: true), + Lba50000RwSense = table.Column(nullable: true), + Lba50000RwDecodedSense = table.Column(nullable: true), + Lba50000RwReadableCluster = table.Column(nullable: false), + Lba100000RwReadable = table.Column(nullable: false), + Lba100000RwData = table.Column(nullable: true), + Lba100000RwSense = table.Column(nullable: true), + Lba100000RwDecodedSense = table.Column(nullable: true), + Lba100000RwReadableCluster = table.Column(nullable: false), + Lba400000RwReadable = table.Column(nullable: false), + Lba400000RwData = table.Column(nullable: true), + Lba400000RwSense = table.Column(nullable: true), + Lba400000RwDecodedSense = table.Column(nullable: true), + Lba400000RwReadableCluster = table.Column(nullable: false), + Lba450000RwReadable = table.Column(nullable: false), + Lba450000RwData = table.Column(nullable: true), + Lba450000RwSense = table.Column(nullable: true), + Lba450000RwDecodedSense = table.Column(nullable: true), + Lba450000RwReadableCluster = table.Column(nullable: false), MinimumReadableSectorInHdArea = table.Column(nullable: false), MaximumReadableSectorInHdArea = table.Column(nullable: false), - MaximumReadablePqInHdArea = table.Column(nullable: true), - MaximumReadableRwInHdArea = table.Column(nullable: true) + MaximumReadablePqInHdArea = table.Column(nullable: true), + MaximumReadableRwInHdArea = table.Column(nullable: true) }, constraints: table => table.PrimaryKey("PK_GdRomSwapDiscCapabilities", x => x.Id)); migrationBuilder.CreateIndex("IX_Reports_GdRomSwapDiscCapabilitiesId", "Reports", diff --git a/Aaru.Server/Migrations/20200710184810_AddCanReadGdRomUsingSwapDisc.cs b/Aaru.Server/Migrations/20200710184810_AddCanReadGdRomUsingSwapDisc.cs index 06e75887..bd0345c9 100644 --- a/Aaru.Server/Migrations/20200710184810_AddCanReadGdRomUsingSwapDisc.cs +++ b/Aaru.Server/Migrations/20200710184810_AddCanReadGdRomUsingSwapDisc.cs @@ -5,7 +5,8 @@ namespace Aaru.Server.Migrations public partial class AddCanReadGdRomUsingSwapDisc : Migration { protected override void Up(MigrationBuilder migrationBuilder) => - migrationBuilder.AddColumn("CanReadGdRomUsingSwapDisc", "Devices", nullable: true, defaultValue: null); + migrationBuilder.AddColumn("CanReadGdRomUsingSwapDisc", "Devices", nullable: true, + defaultValue: null); protected override void Down(MigrationBuilder migrationBuilder) => migrationBuilder.DropColumn("CanReadGdRomUsingSwapDisc", "Devices"); diff --git a/Aaru.Server/Migrations/AaruServerContextModelSnapshot.cs b/Aaru.Server/Migrations/AaruServerContextModelSnapshot.cs index 4878f779..a17c8248 100644 --- a/Aaru.Server/Migrations/AaruServerContextModelSnapshot.cs +++ b/Aaru.Server/Migrations/AaruServerContextModelSnapshot.cs @@ -1895,29 +1895,22 @@ namespace Aaru.Server.Migrations b.ToTable("AspNetUserTokens"); }); - modelBuilder.Entity("Aaru.CommonTypes.Metadata.Ata", b => - { - b.HasOne("Aaru.CommonTypes.Metadata.TestedMedia", "ReadCapabilities").WithMany(). - HasForeignKey("ReadCapabilitiesId").OnDelete(DeleteBehavior.SetNull); - }); + modelBuilder.Entity("Aaru.CommonTypes.Metadata.Ata", + b => b.HasOne("Aaru.CommonTypes.Metadata.TestedMedia", "ReadCapabilities").WithMany(). + HasForeignKey("ReadCapabilitiesId").OnDelete(DeleteBehavior.SetNull)); - modelBuilder.Entity("Aaru.CommonTypes.Metadata.BlockDescriptor", b => - { - b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode", null).WithMany("BlockDescriptors"). - HasForeignKey("ScsiModeId").OnDelete(DeleteBehavior.Cascade); - }); + modelBuilder.Entity("Aaru.CommonTypes.Metadata.BlockDescriptor", + b => b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode", null).WithMany("BlockDescriptors"). + HasForeignKey("ScsiModeId").OnDelete(DeleteBehavior.Cascade)); - modelBuilder.Entity("Aaru.CommonTypes.Metadata.DensityCode", b => - { - b.HasOne("Aaru.CommonTypes.Metadata.SscSupportedMedia", null).WithMany("DensityCodes"). - HasForeignKey("SscSupportedMediaId").OnDelete(DeleteBehavior.Cascade); - }); + modelBuilder.Entity("Aaru.CommonTypes.Metadata.DensityCode", + b => b.HasOne("Aaru.CommonTypes.Metadata.SscSupportedMedia", null). + WithMany("DensityCodes").HasForeignKey("SscSupportedMediaId"). + OnDelete(DeleteBehavior.Cascade)); - modelBuilder.Entity("Aaru.CommonTypes.Metadata.Mmc", b => - { - b.HasOne("Aaru.CommonTypes.Metadata.MmcFeatures", "Features").WithMany().HasForeignKey("FeaturesId"). - OnDelete(DeleteBehavior.SetNull); - }); + modelBuilder.Entity("Aaru.CommonTypes.Metadata.Mmc", + b => b.HasOne("Aaru.CommonTypes.Metadata.MmcFeatures", "Features").WithMany(). + HasForeignKey("FeaturesId").OnDelete(DeleteBehavior.SetNull)); modelBuilder.Entity("Aaru.CommonTypes.Metadata.Scsi", b => { @@ -1979,11 +1972,9 @@ namespace Aaru.Server.Migrations OnDelete(DeleteBehavior.SetNull); }); - modelBuilder.Entity("Aaru.CommonTypes.Metadata.TestedSequentialMedia", b => - { - b.HasOne("Aaru.CommonTypes.Metadata.Ssc", null).WithMany("TestedMedia").HasForeignKey("SscId"). - OnDelete(DeleteBehavior.SetNull); - }); + modelBuilder.Entity("Aaru.CommonTypes.Metadata.TestedSequentialMedia", + b => b.HasOne("Aaru.CommonTypes.Metadata.Ssc", null).WithMany("TestedMedia"). + HasForeignKey("SscId").OnDelete(DeleteBehavior.SetNull)); modelBuilder.Entity("Aaru.Server.Models.Device", b => { @@ -2018,11 +2009,9 @@ namespace Aaru.Server.Migrations OnDelete(DeleteBehavior.SetNull); }); - modelBuilder.Entity("Aaru.Server.Models.DeviceStat", b => - { - b.HasOne("Aaru.Server.Models.Device", "Report").WithMany().HasForeignKey("ReportId"). - OnDelete(DeleteBehavior.SetNull); - }); + modelBuilder.Entity("Aaru.Server.Models.DeviceStat", + b => b.HasOne("Aaru.Server.Models.Device", "Report").WithMany(). + HasForeignKey("ReportId").OnDelete(DeleteBehavior.SetNull)); modelBuilder.Entity("Aaru.Server.Models.UploadedReport", b => { @@ -2054,29 +2043,21 @@ namespace Aaru.Server.Migrations OnDelete(DeleteBehavior.SetNull); }); - modelBuilder.Entity("Aaru.Server.Models.UsbProduct", b => - { - b.HasOne("Aaru.Server.Models.UsbVendor", "Vendor").WithMany("Products").HasForeignKey("VendorId"). - OnDelete(DeleteBehavior.Cascade).IsRequired(); - }); + modelBuilder.Entity("Aaru.Server.Models.UsbProduct", + b => b.HasOne("Aaru.Server.Models.UsbVendor", "Vendor").WithMany("Products"). + HasForeignKey("VendorId").OnDelete(DeleteBehavior.Cascade).IsRequired()); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null).WithMany().HasForeignKey("RoleId"). - OnDelete(DeleteBehavior.Cascade).IsRequired(); - }); + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", + b => b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null).WithMany(). + HasForeignKey("RoleId").OnDelete(DeleteBehavior.Cascade).IsRequired()); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null).WithMany().HasForeignKey("UserId"). - OnDelete(DeleteBehavior.Cascade).IsRequired(); - }); + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", + b => b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null).WithMany(). + HasForeignKey("UserId").OnDelete(DeleteBehavior.Cascade).IsRequired()); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null).WithMany().HasForeignKey("UserId"). - OnDelete(DeleteBehavior.Cascade).IsRequired(); - }); + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", + b => b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null).WithMany(). + HasForeignKey("UserId").OnDelete(DeleteBehavior.Cascade).IsRequired()); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => { @@ -2087,11 +2068,9 @@ namespace Aaru.Server.Migrations OnDelete(DeleteBehavior.Cascade).IsRequired(); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null).WithMany().HasForeignKey("UserId"). - OnDelete(DeleteBehavior.Cascade).IsRequired(); - }); + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", + b => b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null).WithMany(). + HasForeignKey("UserId").OnDelete(DeleteBehavior.Cascade).IsRequired()); #pragma warning restore 612, 618 } } diff --git a/Aaru.Server/Models/Context.cs b/Aaru.Server/Models/Context.cs index 1f39c640..c372fcd2 100644 --- a/Aaru.Server/Models/Context.cs +++ b/Aaru.Server/Models/Context.cs @@ -59,7 +59,7 @@ namespace Aaru.Server.Models public DbSet UsbVendors { get; set; } public DbSet UsbProducts { get; set; } public DbSet CdOffsets { get; set; } - public DbSet Ata { get; set; } + public DbSet Ata { get; set; } public DbSet BlockDescriptor { get; set; } public DbSet Chs { get; set; } public DbSet FireWire { get; set; } @@ -94,29 +94,22 @@ namespace Aaru.Server.Models { base.OnModelCreating(modelBuilder); - modelBuilder.Entity("Aaru.CommonTypes.Metadata.Ata", b => - { - b.HasOne("Aaru.CommonTypes.Metadata.TestedMedia", "ReadCapabilities").WithMany(). - HasForeignKey("ReadCapabilitiesId").OnDelete(DeleteBehavior.SetNull); - }); + modelBuilder.Entity("Aaru.CommonTypes.Metadata.Ata", + b => b.HasOne("Aaru.CommonTypes.Metadata.TestedMedia", "ReadCapabilities").WithMany(). + HasForeignKey("ReadCapabilitiesId").OnDelete(DeleteBehavior.SetNull)); - modelBuilder.Entity("Aaru.CommonTypes.Metadata.BlockDescriptor", b => - { - b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode", null).WithMany("BlockDescriptors"). - HasForeignKey("ScsiModeId").OnDelete(DeleteBehavior.Cascade); - }); + modelBuilder.Entity("Aaru.CommonTypes.Metadata.BlockDescriptor", + b => b.HasOne("Aaru.CommonTypes.Metadata.ScsiMode", null).WithMany("BlockDescriptors"). + HasForeignKey("ScsiModeId").OnDelete(DeleteBehavior.Cascade)); - modelBuilder.Entity("Aaru.CommonTypes.Metadata.DensityCode", b => - { - b.HasOne("Aaru.CommonTypes.Metadata.SscSupportedMedia", null).WithMany("DensityCodes"). - HasForeignKey("SscSupportedMediaId").OnDelete(DeleteBehavior.Cascade); - }); + modelBuilder.Entity("Aaru.CommonTypes.Metadata.DensityCode", + b => b.HasOne("Aaru.CommonTypes.Metadata.SscSupportedMedia", null). + WithMany("DensityCodes").HasForeignKey("SscSupportedMediaId"). + OnDelete(DeleteBehavior.Cascade)); - modelBuilder.Entity("Aaru.CommonTypes.Metadata.Mmc", b => - { - b.HasOne("Aaru.CommonTypes.Metadata.MmcFeatures", "Features").WithMany().HasForeignKey("FeaturesId"). - OnDelete(DeleteBehavior.SetNull); - }); + modelBuilder.Entity("Aaru.CommonTypes.Metadata.Mmc", + b => b.HasOne("Aaru.CommonTypes.Metadata.MmcFeatures", "Features").WithMany(). + HasForeignKey("FeaturesId").OnDelete(DeleteBehavior.SetNull)); modelBuilder.Entity("Aaru.CommonTypes.Metadata.Scsi", b => { @@ -178,11 +171,9 @@ namespace Aaru.Server.Models OnDelete(DeleteBehavior.SetNull); }); - modelBuilder.Entity("Aaru.CommonTypes.Metadata.TestedSequentialMedia", b => - { - b.HasOne("Aaru.CommonTypes.Metadata.Ssc", null).WithMany("TestedMedia").HasForeignKey("SscId"). - OnDelete(DeleteBehavior.SetNull); - }); + modelBuilder.Entity("Aaru.CommonTypes.Metadata.TestedSequentialMedia", + b => b.HasOne("Aaru.CommonTypes.Metadata.Ssc", null).WithMany("TestedMedia"). + HasForeignKey("SscId").OnDelete(DeleteBehavior.SetNull)); modelBuilder.Entity("Aaru.Server.Models.Device", b => { @@ -214,11 +205,9 @@ namespace Aaru.Server.Models OnDelete(DeleteBehavior.SetNull); }); - modelBuilder.Entity("Aaru.Server.Models.DeviceStat", b => - { - b.HasOne("Aaru.Server.Models.Device", "Report").WithMany().HasForeignKey("ReportId"). - OnDelete(DeleteBehavior.SetNull); - }); + modelBuilder.Entity("Aaru.Server.Models.DeviceStat", + b => b.HasOne("Aaru.Server.Models.Device", "Report").WithMany(). + HasForeignKey("ReportId").OnDelete(DeleteBehavior.SetNull)); modelBuilder.Entity("Aaru.Server.Models.UploadedReport", b => { diff --git a/Aaru.Server/Program.cs b/Aaru.Server/Program.cs index 30272021..e56b32f1 100644 --- a/Aaru.Server/Program.cs +++ b/Aaru.Server/Program.cs @@ -9,7 +9,7 @@ using Version = Aaru.CommonTypes.Interop.Version; namespace Aaru.Server { - public class Program + public sealed class Program { public static void Main(string[] args) { @@ -19,55 +19,46 @@ namespace Aaru.Server System.Console.Clear(); System.Console.Write( - "\u001b[32m . ,,\n" + - "\u001b[32m ;,. '0d.\n" + - "\u001b[32m oc oWd \u001b[31m" + - @"__/\\\\\\\\\\\\_____/\\\\\\\\\\\________/\\\\\\\\\_ " + - "\n\u001b[0m" + - "\u001b[32m ;X. 'WN' \u001b[31m" + - @" _\/\\\////////\\\__\/////\\\///______/\\\////////__ " + - "\n\u001b[0m" + - "\u001b[32m oMo cMM: \u001b[31m" + - @" _\/\\\______\//\\\_____\/\\\_______/\\\/___________ " + - "\n\u001b[0m" + - "\u001b[32m ;MM. .MMM; \u001b[31m" + - @" _\/\\\_______\/\\\_____\/\\\______/\\\_____________ " + - "\n\u001b[0m" + - "\u001b[32m NMM WMMW \u001b[31m" + - @" _\/\\\_______\/\\\_____\/\\\_____\/\\\_____________ " + - "\n\u001b[0m" + - "\u001b[32m 'MMM MMMM; \u001b[31m" + - @" _\/\\\_______\/\\\_____\/\\\_____\//\\\____________ " + - "\n\u001b[0m" + - "\u001b[32m ,MMM: dMMMM: \u001b[31m" + - @" _\/\\\_______/\\\______\/\\\______\///\\\__________ " + - "\n\u001b[0m" + - "\u001b[32m .MMMW. :MMMMM. \u001b[31m" + - @" _\/\\\\\\\\\\\\/____/\\\\\\\\\\\____\////\\\\\\\\\_ " + - "\n\u001b[0m" + - "\u001b[32m XMMMW: .:xKNMMMMMMN0d, lMMMMMd \u001b[31m" + - @" _\////////////_____\///////////________\/////////__" + - "\n\u001b[0m" + - "\u001b[32m :MMMMMK; cWMNkl:;;;:lxKMXc .0MMMMMO\u001b[0m\n" + - "\u001b[32m ..KMMMMMMNo,. ,OMMMMMMW:,. \u001b[37;1m Aaru Website\u001b[0m\n" + - "\u001b[32m .;d0NMMMMMMMMMMMMMMW0d:' .;lOWMMMMMMMMMMMMMXkl. \u001b[37;1m Version \u001b[0m\u001b[33m{0}\u001b[37;1m-\u001b[0m\u001b[31m{1}\u001b[0m\n" + - "\u001b[32m :KMMMMMMMMMMMMMMMMMMMMMMMMc WMMMMMMMMMMMMMMMMMMMMMMWk'\u001b[0m\n" + + "\u001b[32m . ,,\n" + + "\u001b[32m ;,. '0d.\n" + + "\u001b[32m oc oWd \u001b[31m" + + @"__/\\\\\\\\\\\\_____/\\\\\\\\\\\________/\\\\\\\\\_ " + "\n\u001b[0m" + + "\u001b[32m ;X. 'WN' \u001b[31m" + + @" _\/\\\////////\\\__\/////\\\///______/\\\////////__ " + "\n\u001b[0m" + + "\u001b[32m oMo cMM: \u001b[31m" + + @" _\/\\\______\//\\\_____\/\\\_______/\\\/___________ " + "\n\u001b[0m" + + "\u001b[32m ;MM. .MMM; \u001b[31m" + + @" _\/\\\_______\/\\\_____\/\\\______/\\\_____________ " + "\n\u001b[0m" + + "\u001b[32m NMM WMMW \u001b[31m" + + @" _\/\\\_______\/\\\_____\/\\\_____\/\\\_____________ " + "\n\u001b[0m" + + "\u001b[32m 'MMM MMMM; \u001b[31m" + + @" _\/\\\_______\/\\\_____\/\\\_____\//\\\____________ " + "\n\u001b[0m" + + "\u001b[32m ,MMM: dMMMM: \u001b[31m" + + @" _\/\\\_______/\\\______\/\\\______\///\\\__________ " + "\n\u001b[0m" + + "\u001b[32m .MMMW. :MMMMM. \u001b[31m" + + @" _\/\\\\\\\\\\\\/____/\\\\\\\\\\\____\////\\\\\\\\\_ " + "\n\u001b[0m" + + "\u001b[32m XMMMW: .:xKNMMMMMMN0d, lMMMMMd \u001b[31m" + + @" _\////////////_____\///////////________\/////////__" + "\n\u001b[0m" + + "\u001b[32m :MMMMMK; cWMNkl:;;;:lxKMXc .0MMMMMO\u001b[0m\n" + + "\u001b[32m ..KMMMMMMNo,. ,OMMMMMMW:,. \u001b[37;1m Aaru Website\u001b[0m\n" + + "\u001b[32m .;d0NMMMMMMMMMMMMMMW0d:' .;lOWMMMMMMMMMMMMMXkl. \u001b[37;1m Version \u001b[0m\u001b[33m{0}\u001b[37;1m-\u001b[0m\u001b[31m{1}\u001b[0m\n" + + "\u001b[32m :KMMMMMMMMMMMMMMMMMMMMMMMMc WMMMMMMMMMMMMMMMMMMMMMMWk'\u001b[0m\n" + "\u001b[32m ;NMMMMWX0kkkkO0XMMMMMMMMMMM0' dNMMMMMMMMMMW0xl:;,;:oOWMMX; \u001b[37;1m Running under \u001b[35;1m{2}\u001b[37;1m, \u001b[35m{3}-bit\u001b[37;1m in \u001b[35m{4}-bit\u001b[37;1m mode.\u001b[0m\n" + - "\u001b[32m xMMWk:. .c0MMMMMW' OMMMMMM0c'.. .oNMO \u001b[37;1m Using \u001b[33;1m{5}\u001b[37;1m version \u001b[31;1m{6}\u001b[0m\n" + - "\u001b[32m OMNc .MNc oWMMk 'WMMNl. .MMK ;KX.\u001b[0m\n" + - "\u001b[32m xMO WMN ; ., , ': ,MMx lK\u001b[0m\n" + - "\u001b[32m ,Md cMMl .XMMMWWMMMO XMW. :\u001b[0m\n" + - "\u001b[32m Ok xMMl XMMMMMMMMc 0MW,\u001b[0m\n" + - "\u001b[32m 0 oMM0' lMMMMMMMM. :NMN'\u001b[0m\n" + - "\u001b[32m . .0MMKl ;MMMMMMMM oNMWd\u001b[0m\n" + - "\u001b[32m .dNW cMMMMMMMM, XKl\u001b[0m\n" + - "\u001b[32m 0MMMMMMMMK\u001b[0m\n" + - "\u001b[32m ;MMMMMMMMMMO \u001b[37;1m Proudly presented to you by:\u001b[0m\n" + - "\u001b[32m 'WMMMMKxMMMMM0 \u001b[34;1m Natalia Portillo\u001b[0m\n" + - "\u001b[32m oMMMMNc :WMMMMN:\u001b[0m\n" + - "\u001b[32m .dWMMM0; dWMMMMXl. \u001b[37;1m Thanks to all contributors, collaborators, translators, donators and friends.\u001b[0m\n" + - "\u001b[32m .......,cd0WMMNk: c0MMMMMWKkolc:clodc'\u001b[0m\n" + - "\u001b[32m .';loddol:'. ':oxkkOkkxoc,.\u001b[0m\n" + + "\u001b[32m xMMWk:. .c0MMMMMW' OMMMMMM0c'.. .oNMO \u001b[37;1m Using \u001b[33;1m{5}\u001b[37;1m version \u001b[31;1m{6}\u001b[0m\n" + + "\u001b[32m OMNc .MNc oWMMk 'WMMNl. .MMK ;KX.\u001b[0m\n" + + "\u001b[32m xMO WMN ; ., , ': ,MMx lK\u001b[0m\n" + + "\u001b[32m ,Md cMMl .XMMMWWMMMO XMW. :\u001b[0m\n" + + "\u001b[32m Ok xMMl XMMMMMMMMc 0MW,\u001b[0m\n" + + "\u001b[32m 0 oMM0' lMMMMMMMM. :NMN'\u001b[0m\n" + + "\u001b[32m . .0MMKl ;MMMMMMMM oNMWd\u001b[0m\n" + + "\u001b[32m .dNW cMMMMMMMM, XKl\u001b[0m\n" + + "\u001b[32m 0MMMMMMMMK\u001b[0m\n" + + "\u001b[32m ;MMMMMMMMMMO \u001b[37;1m Proudly presented to you by:\u001b[0m\n" + + "\u001b[32m 'WMMMMKxMMMMM0 \u001b[34;1m Natalia Portillo\u001b[0m\n" + + "\u001b[32m oMMMMNc :WMMMMN:\u001b[0m\n" + + "\u001b[32m .dWMMM0; dWMMMMXl. \u001b[37;1m Thanks to all contributors, collaborators, translators, donators and friends.\u001b[0m\n" + + "\u001b[32m .......,cd0WMMNk: c0MMMMMWKkolc:clodc'\u001b[0m\n" + + "\u001b[32m .';loddol:'. ':oxkkOkkxoc,.\u001b[0m\n" + "\u001b[0m\n", Version.GetVersion(), #if DEBUG "DEBUG" @@ -122,8 +113,8 @@ namespace Aaru.Server public static IHostBuilder CreateHostBuilder(string[] args) => Host. CreateDefaultBuilder(args). ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }); + webBuilder. + UseStartup< + Startup>()); } } \ No newline at end of file diff --git a/Aaru.Server/Seeder.cs b/Aaru.Server/Seeder.cs index 15aeed4c..403a0ac1 100644 --- a/Aaru.Server/Seeder.cs +++ b/Aaru.Server/Seeder.cs @@ -26,7 +26,10 @@ namespace Aaru.Server var user = new IdentityUser { - Email = email, NormalizedEmail = email, EmailConfirmed = true, UserName = email, + Email = email, + NormalizedEmail = email, + EmailConfirmed = true, + UserName = email, NormalizedUserName = email }; diff --git a/Aaru.Server/Startup.cs b/Aaru.Server/Startup.cs index 736a5ffb..9b7b6112 100644 --- a/Aaru.Server/Startup.cs +++ b/Aaru.Server/Startup.cs @@ -12,7 +12,7 @@ using Prometheus; namespace Aaru.Server { - public class Startup + public sealed class Startup { public Startup(IConfiguration configuration) => Configuration = configuration; @@ -33,7 +33,7 @@ namespace Aaru.Server }).AddEntityFrameworkStores(); services.AddApplicationInsightsTelemetry(); - + services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0); } diff --git a/Aaru.Server/Views/Home/CODE_OF_CONDUCT.cshtml b/Aaru.Server/Views/Home/CODE_OF_CONDUCT.cshtml index fab78cee..a91eb4ba 100644 --- a/Aaru.Server/Views/Home/CODE_OF_CONDUCT.cshtml +++ b/Aaru.Server/Views/Home/CODE_OF_CONDUCT.cshtml @@ -36,7 +36,8 @@ // ****************************************************************************/ }

- @Html.ActionLink("Return to main page.", "Index")
+ @Html.ActionLink("Return to main page.", "Index") +
Aaru's code of conduct:

@Html.Raw(ViewBag.Markdown)
\ No newline at end of file diff --git a/Aaru.Server/Views/Home/CONTRIBUTING.cshtml b/Aaru.Server/Views/Home/CONTRIBUTING.cshtml index d017c240..b0e276d4 100644 --- a/Aaru.Server/Views/Home/CONTRIBUTING.cshtml +++ b/Aaru.Server/Views/Home/CONTRIBUTING.cshtml @@ -36,7 +36,8 @@ // ****************************************************************************/ }

- @Html.ActionLink("Return to main page.", "Index")
+ @Html.ActionLink("Return to main page.", "Index") +
How to contribute to DiscImageChef:

@Html.Raw(ViewBag.Markdown)
\ No newline at end of file diff --git a/Aaru.Server/Views/Home/Changelog.cshtml b/Aaru.Server/Views/Home/Changelog.cshtml index a22ce141..bae0c9b8 100644 --- a/Aaru.Server/Views/Home/Changelog.cshtml +++ b/Aaru.Server/Views/Home/Changelog.cshtml @@ -36,7 +36,8 @@ // ****************************************************************************/ }

- @Html.ActionLink("Return to main page.", "Index")
+ @Html.ActionLink("Return to main page.", "Index") +
Aaru list of changes:

@Html.Raw(ViewBag.Markdown)
\ No newline at end of file diff --git a/Aaru.Server/Views/Home/ISSUE_TEMPLATE.cshtml b/Aaru.Server/Views/Home/ISSUE_TEMPLATE.cshtml index 39b07a29..5565e6bc 100644 --- a/Aaru.Server/Views/Home/ISSUE_TEMPLATE.cshtml +++ b/Aaru.Server/Views/Home/ISSUE_TEMPLATE.cshtml @@ -36,7 +36,8 @@ // ****************************************************************************/ }

- @Html.ActionLink("Return to main page.", "Index")
+ @Html.ActionLink("Return to main page.", "Index") +
DiscImageChef's template for issue reports:

@Html.Raw(ViewBag.Markdown)
\ No newline at end of file diff --git a/Aaru.Server/Views/Home/NEEDED.cshtml b/Aaru.Server/Views/Home/NEEDED.cshtml index 8eb032bd..006c9577 100644 --- a/Aaru.Server/Views/Home/NEEDED.cshtml +++ b/Aaru.Server/Views/Home/NEEDED.cshtml @@ -36,7 +36,8 @@ // ****************************************************************************/ }

- @Html.ActionLink("Return to main page.", "Index")
+ @Html.ActionLink("Return to main page.", "Index") +
Aaru list of hardware and software needed:

@Html.Raw(ViewBag.Markdown)
\ No newline at end of file diff --git a/Aaru.Server/Views/Home/NEEDINFO.cshtml b/Aaru.Server/Views/Home/NEEDINFO.cshtml index b3bc9840..c706b26b 100644 --- a/Aaru.Server/Views/Home/NEEDINFO.cshtml +++ b/Aaru.Server/Views/Home/NEEDINFO.cshtml @@ -36,7 +36,8 @@ // ****************************************************************************/ }

- @Html.ActionLink("Return to main page.", "Index")
+ @Html.ActionLink("Return to main page.", "Index") +
DiscImageChef list of information needed:

@Html.Raw(ViewBag.Markdown)
\ No newline at end of file diff --git a/Aaru.Server/Views/Home/PULL_REQUEST_TEMPLATE.cshtml b/Aaru.Server/Views/Home/PULL_REQUEST_TEMPLATE.cshtml index 7b639a64..ecda190b 100644 --- a/Aaru.Server/Views/Home/PULL_REQUEST_TEMPLATE.cshtml +++ b/Aaru.Server/Views/Home/PULL_REQUEST_TEMPLATE.cshtml @@ -36,7 +36,8 @@ // ****************************************************************************/ }

- @Html.ActionLink("Return to main page.", "Index")
+ @Html.ActionLink("Return to main page.", "Index") +
Aaru's template for pull requests:

@Html.Raw(ViewBag.Markdown)
\ No newline at end of file diff --git a/Aaru.Server/Views/Home/TODO.cshtml b/Aaru.Server/Views/Home/TODO.cshtml index 03b55bf4..1e8743e9 100644 --- a/Aaru.Server/Views/Home/TODO.cshtml +++ b/Aaru.Server/Views/Home/TODO.cshtml @@ -36,7 +36,8 @@ // ****************************************************************************/ }

- @Html.ActionLink("Return to main page.", "Index")
+ @Html.ActionLink("Return to main page.", "Index") +
Aaru list of things to do:

@Html.Raw(ViewBag.Markdown)
\ No newline at end of file diff --git a/Aaru.Server/Views/Report/View.cshtml b/Aaru.Server/Views/Report/View.cshtml index 953f7a9f..0da7e972 100644 --- a/Aaru.Server/Views/Report/View.cshtml +++ b/Aaru.Server/Views/Report/View.cshtml @@ -48,9 +48,12 @@ Aaru Report for
USB characteristics:
- Manufacturer: @ViewBag.UsbItem.Manufacturer
- Product: @ViewBag.UsbItem.Product
- Vendor ID: @ViewBag.UsbItem.VendorDescription
+ Manufacturer: @ViewBag.UsbItem.Manufacturer +
+ Product: @ViewBag.UsbItem.Product +
+ Vendor ID: @ViewBag.UsbItem.VendorDescription +
Product ID: @ViewBag.UsbItem.ProductDescription } @@ -61,9 +64,12 @@ Aaru Report for
FireWire characteristics:
- Manufacturer: @ViewBag.FireWire.Manufacturer
- Product: @ViewBag.FireWire.Product
- Vendor ID: @ViewBag.FireWire.VendorDescription
+ Manufacturer: @ViewBag.FireWire.Manufacturer +
+ Product: @ViewBag.FireWire.Product +
+ Vendor ID: @ViewBag.FireWire.VendorDescription +
Product ID: @ViewBag.FireWire.ProductDescription } @@ -74,17 +80,23 @@ Aaru Report for
PCMCIA characteristics:
- Manufacturer: @ViewBag.PcmciaItem.Manufacturer
- Product: @ViewBag.PcmciaItem.ProductName
- Manufacturer code: @ViewBag.PcmciaItem.VendorDescription
- Card code: @ViewBag.PcmciaItem.CardCode
- Compliance: @ViewBag.PcmciaItem.Compliance
+ Manufacturer: @ViewBag.PcmciaItem.Manufacturer +
+ Product: @ViewBag.PcmciaItem.ProductName +
+ Manufacturer code: @ViewBag.PcmciaItem.VendorDescription +
+ Card code: @ViewBag.PcmciaItem.CardCode +
+ Compliance: @ViewBag.PcmciaItem.Compliance +
@if(ViewBag.repPcmciaTuples != null) { foreach(KeyValuePair kvp in ViewBag.repPcmciaTuples) { - @kvp.Key: @kvp.Value
+ @kvp.Key: @kvp.Value +
} } @@ -98,16 +110,19 @@ Aaru Report for @ViewBag.AtaItem characteristics:
- @ViewBag.lblAtaDeviceType
+ @ViewBag.lblAtaDeviceType +
@foreach(KeyValuePair kvp in ViewBag.repAtaTwo) { - @kvp.Key: @kvp.Value
+ @kvp.Key: @kvp.Value +
}
@foreach(string item in ViewBag.repAtaOne) { - @Html.Raw(item)
+ @Html.Raw(item) +
} } @@ -117,12 +132,16 @@ Aaru Report for
SCSI characteristics:
- Vendor: @ViewBag.lblScsiVendor
- Product: @ViewBag.lblScsiProduct
- Revision: @ViewBag.lblScsiRevision
+ Vendor: @ViewBag.lblScsiVendor +
+ Product: @ViewBag.lblScsiProduct +
+ Revision: @ViewBag.lblScsiRevision +
@foreach(string item in ViewBag.repScsi) { - @Html.Raw(item)
+ @Html.Raw(item) +
} @if(ViewBag.repModeSense != null) { @@ -180,7 +199,8 @@ Aaru Report for
@foreach(string item in ViewBag.repScsiMmcMode) { - @Html.Raw(item)
+ @Html.Raw(item) +
} } @@ -192,7 +212,8 @@ Aaru Report for
@foreach(string item in ViewBag.repScsiMmcFeatures) { - @Html.Raw(item)
+ @Html.Raw(item) +
} } @@ -202,7 +223,8 @@ Aaru Report for
SCSI Streaming device capabilities:
- Block size granularity: @ViewBag.lblScsiSscGranularity
+ Block size granularity: @ViewBag.lblScsiSscGranularity +
Maximum block length: @ViewBag.lblScsiSscMaxBlock bytes
Minimum block length: @ViewBag.lblScsiSscMinBlock bytes @@ -217,13 +239,19 @@ Aaru Report for Information for supported density with primary code @($"{density.PrimaryCode:X2}h") and secondary code @($"{density.SecondaryCode:X2}h")
- Drive can write this density: @density.Writable
- Duplicate density: @density.Duplicate
- Default density: @density.DefaultDensity
+ Drive can write this density: @density.Writable +
+ Duplicate density: @density.Duplicate +
+ Default density: @density.DefaultDensity +
Density has @density.BitsPerMm bits per mm, with @density.Tracks tracks in a @density.Width mm width tape - Name: @density.Name
- Organization: @density.Organization
- Description: @density.Description
+ Name: @density.Name +
+ Organization: @density.Organization +
+ Description: @density.Description +
Maximum capacity: @density.Capacity megabytes
@@ -240,9 +268,12 @@ Aaru Report for
Media is @media.Length m long in a @media.Width mm width tape - Name: @media.Name
- Organization: @media.Organization
- Description: @media.Description
+ Name: @media.Name +
+ Organization: @media.Organization +
+ Description: @media.Description +
} } @@ -258,7 +289,8 @@ Aaru Report for
@foreach(string item in ViewBag.repTestedMedia) { - @Html.Raw(item)
+ @Html.Raw(item) +
} } @@ -270,7 +302,8 @@ Aaru Report for
@foreach(string item in ViewBag.repMMC) { - @Html.Raw(item)
+ @Html.Raw(item) +
} } @@ -282,7 +315,8 @@ Aaru Report for
@foreach(string item in ViewBag.repSD) { - @Html.Raw(item)
+ @Html.Raw(item) +
} } diff --git a/Aaru.Server/Views/Shared/_Layout.cshtml b/Aaru.Server/Views/Shared/_Layout.cshtml index 8c3f124a..02d99188 100644 --- a/Aaru.Server/Views/Shared/_Layout.cshtml +++ b/Aaru.Server/Views/Shared/_Layout.cshtml @@ -80,16 +80,13 @@ // 24th January, Macintosh launch case 24: @Html.Raw("Fonts are © 2014 Robin Casady") - ; break; // 23rd July, Amiga launch case 204: @Html.Raw("Fonts are © 2013 TrueSchool Ascii") - ; break; default: @Html.Raw("Fonts are © 2015 - 2016 VileR") - ; break; }
diff --git a/Aaru.Server/Views/Stats/Index.cshtml b/Aaru.Server/Views/Stats/Index.cshtml index b0615703..7785ebba 100644 --- a/Aaru.Server/Views/Stats/Index.cshtml +++ b/Aaru.Server/Views/Stats/Index.cshtml @@ -496,13 +496,7 @@ @if(device.ReportId != 0) { - @Html.ActionLink("Yes", "View", "Report", new - { - id = device.ReportId - }, new - { - target = "_blank" - }) + @Html.ActionLink("Yes", "View", "Report", new { id = device.ReportId }, new { target = "_blank" }) } else { diff --git a/Aaru.Server/Views/_ViewImports.cshtml b/Aaru.Server/Views/_ViewImports.cshtml index a4320bd8..54c726d6 100644 --- a/Aaru.Server/Views/_ViewImports.cshtml +++ b/Aaru.Server/Views/_ViewImports.cshtml @@ -1,4 +1,5 @@ @using Aaru.Server @using Aaru.Server.Models -@inject Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet JavaScriptSnippet +@using Microsoft.ApplicationInsights.AspNetCore +@inject JavaScriptSnippet JavaScriptSnippet @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers \ No newline at end of file diff --git a/CICMMetadata b/CICMMetadata index 7bd4cef5..7944bca8 160000 --- a/CICMMetadata +++ b/CICMMetadata @@ -1 +1 @@ -Subproject commit 7bd4cef56856778274b66d06e8e83de6d5c994ff +Subproject commit 7944bca8e6051f7294f19863a7447e40d797abf7