Example #1
0
    public IActionResult GetWindowsData()
    {
        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()
        };

        if (result[0].Length < 10)
        {
            return(Json(result));
        }

        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();

        return(Json(result));
    }
        public IActionResult GetOsData()
        {
            var query = ctx.OperatingSystems.GroupBy(x => new
            {
                x.Name
            }, x => x.Count).Select(g => new
            {
                g.Key.Name, Count = g.Sum()
            });

            string[][] result = new string[2][];
            result[0] = query.Select(x => x.Name).ToArray();
            result[1] = query.Select(x => x.Count.ToString()).ToArray();

            for (int i = 0; i < result[0].Length; i++)
            {
                result[0][i] = DetectOS.GetPlatformName((PlatformID)Enum.Parse(typeof(PlatformID), result[0][i]));
            }

            return(Json(result));
        }
Example #3
0
    public ActionResult Index()
    {
        ViewBag.Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

        try
        {
            if (System.IO.File.Exists(Path.Combine(_env.ContentRootPath ?? throw new InvalidOperationException(),
                                                   "Statistics", "Statistics.xml")))
            {
                try
                {
                    var statistics = new Stats();

                    var xs = new XmlSerializer(statistics.GetType());

                    FileStream fs =
                        WaitForFile(Path.Combine(_env.ContentRootPath ?? throw new InvalidOperationException(), "Statistics", "Statistics.xml"),
                                    FileMode.Open, FileAccess.Read, FileShare.Read);

                    statistics = (Stats)xs.Deserialize(fs);
                    fs.Close();

                    StatsConverter.Convert(statistics);

                    System.IO.File.Delete(Path.Combine(_env.ContentRootPath ?? throw new InvalidOperationException(),
                                                       "Statistics", "Statistics.xml"));
                }
                catch (XmlException)
                {
                    // Do nothing
                }
            }

            if (_ctx.OperatingSystems.Any())
            {
                List <NameValueStats> operatingSystems = new();

                foreach (OperatingSystem nvs in _ctx.OperatingSystems)
                {
                    operatingSystems.Add(new NameValueStats
                    {
                        name =
                            $"{DetectOS.GetPlatformName((PlatformID)Enum.Parse(typeof(PlatformID), nvs.Name), nvs.Version)}{(string.IsNullOrEmpty(nvs.Version) ? "" : " ")}{nvs.Version}",
                        Value = nvs.Count
                    });
                }

                ViewBag.repOperatingSystems = operatingSystems.OrderBy(os => os.name).ToList();
            }

            if (_ctx.Versions.Any())
            {
                List <NameValueStats> versions = new();

                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
                    });
                }

                ViewBag.repVersions = versions.OrderBy(ver => ver.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.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.Filesystems.Any())
            {
                ViewBag.repFilesystems = _ctx.Filesystems.OrderBy(filter => filter.Name).ToList();
            }

            if (_ctx.Medias.Any())
            {
                List <MediaItem> realMedia    = new();
                List <MediaItem> virtualMedia = new();

                foreach (Media nvs in _ctx.Medias)
                {
                    try
                    {
                        (string type, string subType)mediaType =
                            MediaType.MediaTypeToString((CommonTypes.MediaType)Enum.Parse(typeof(CommonTypes.MediaType),
                                                                                          nvs.Type));

                        if (nvs.Real)
                        {
                            realMedia.Add(new MediaItem
                            {
                                Type    = mediaType.type,
                                SubType = mediaType.subType,
                                Count   = nvs.Count
                            });
                        }
                        else
                        {
                            virtualMedia.Add(new MediaItem
                            {
                                Type    = mediaType.type,
                                SubType = mediaType.subType,
                                Count   = nvs.Count
                            });
                        }
                    }
                    catch
                    {
                        if (nvs.Real)
                        {
                            realMedia.Add(new MediaItem
                            {
                                Type    = nvs.Type,
                                SubType = null,
                                Count   = nvs.Count
                            });
                        }
                        else
                        {
                            virtualMedia.Add(new MediaItem
                            {
                                Type    = nvs.Type,
                                SubType = null,
                                Count   = nvs.Count
                            });
                        }
                    }
                }

                if (realMedia.Count > 0)
                {
                    ViewBag.repRealMedia = realMedia.OrderBy(media => media.Type).ThenBy(media => media.SubType).
                                           ToList();
                }

                if (virtualMedia.Count > 0)
                {
                    ViewBag.repVirtualMedia = virtualMedia.OrderBy(media => media.Type).ThenBy(media => media.SubType).
                                              ToList();
                }
            }

            if (_ctx.DeviceStats.Any())
            {
                List <DeviceItem> devices = new();

                foreach (DeviceStat device in _ctx.DeviceStats.ToList())
                {
                    string xmlFile;

                    if (!string.IsNullOrWhiteSpace(device.Manufacturer) &&
                        !string.IsNullOrWhiteSpace(device.Model) &&
                        !string.IsNullOrWhiteSpace(device.Revision))
                    {
                        xmlFile = device.Manufacturer + "_" + device.Model + "_" + device.Revision + ".xml";
                    }
                    else if (!string.IsNullOrWhiteSpace(device.Manufacturer) &&
                             !string.IsNullOrWhiteSpace(device.Model))
                    {
                        xmlFile = device.Manufacturer + "_" + device.Model + ".xml";
                    }
                    else if (!string.IsNullOrWhiteSpace(device.Model) &&
                             !string.IsNullOrWhiteSpace(device.Revision))
                    {
                        xmlFile = device.Model + "_" + device.Revision + ".xml";
                    }
                    else
                    {
                        xmlFile = device.Model + ".xml";
                    }

                    xmlFile = xmlFile.Replace('/', '_').Replace('\\', '_').Replace('?', '_');

                    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),
                                        FileMode.Open, FileAccess.Read, FileShare.Read);

                        deviceReport = (DeviceReport)xs.Deserialize(fs);
                        fs.Close();

                        var deviceReportV2 = new DeviceReportV2(deviceReport);

                        device.Report = _ctx.Devices.Add(new Device(deviceReportV2)).Entity;
                        _ctx.SaveChanges();

                        System.IO.File.
                        Delete(Path.Combine(_env.ContentRootPath ?? throw new InvalidOperationException(),
                                            "Reports", xmlFile));
                    }

                    devices.Add(new DeviceItem
                    {
                        Manufacturer = device.Manufacturer,
                        Model        = device.Model,
                        Revision     = device.Revision,
                        Bus          = device.Bus,
                        ReportId     = device.Report != null && device.Report.Id != 0 ? device.Report.Id : 0
                    });
                }

                ViewBag.repDevices = devices.OrderBy(device => device.Manufacturer).ThenBy(device => device.Model).
                                     ThenBy(device => device.Revision).ThenBy(device => device.Bus).ToList();
            }
        }
        catch (Exception)
        {
        #if DEBUG
            throw;
        #endif
            return(Content("Could not read statistics"));
        }

        return(View());
    }
Example #4
0
        public ActionResult Index()
        {
            ViewBag.Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            try
            {
                if (
                    System.IO.File
                    .Exists(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(),
                                         "Statistics", "Statistics.xml")))
                {
                    try
                    {
                        Stats statistics = new Stats();

                        XmlSerializer xs = new XmlSerializer(statistics.GetType());
                        FileStream    fs =
                            WaitForFile(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "Statistics", "Statistics.xml"),
                                        FileMode.Open, FileAccess.Read, FileShare.Read);
                        statistics = (Stats)xs.Deserialize(fs);
                        fs.Close();

                        StatsConverter.Convert(statistics);

                        System.IO.File
                        .Delete(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(),
                                             "Statistics", "Statistics.xml"));
                    }
                    catch (XmlException)
                    {
                        // Do nothing
                    }
                }

                if (ctx.OperatingSystems.Any())
                {
                    operatingSystems = new List <NameValueStats>();
                    foreach (OperatingSystem nvs in ctx.OperatingSystems)
                    {
                        operatingSystems.Add(new NameValueStats
                        {
                            name =
                                $"{DetectOS.GetPlatformName((PlatformID)Enum.Parse(typeof(PlatformID), nvs.Name), nvs.Version)}{(string.IsNullOrEmpty(nvs.Version) ? "" : " ")}{nvs.Version}",
                            Value = nvs.Count
                        });
                    }

                    ViewBag.repOperatingSystems = operatingSystems.OrderBy(os => os.name).ToList();

                    List <PieSeriesData> osPieData = new List <PieSeriesData>();

                    decimal totalOsCount = ctx.OperatingSystems.Sum(o => o.Count);
                    foreach (string os in ctx.OperatingSystems.Select(o => o.Name).Distinct().ToList())
                    {
                        decimal osCount = ctx.OperatingSystems.Where(o => o.Name == os).Sum(o => o.Count);

                        osPieData.Add(new PieSeriesData
                        {
                            Name =
                                DetectOS.GetPlatformName((PlatformID)Enum.Parse(typeof(PlatformID),
                                                                                os)),
                            Y        = (double?)(osCount / totalOsCount),
                            Sliced   = os == "Linux",
                            Selected = os == "Linux"
                        });
                    }

                    ViewData["osPieData"] = osPieData;

                    List <PieSeriesData> linuxPieData = new List <PieSeriesData>();

                    decimal linuxCount = ctx.OperatingSystems.Where(o => o.Name == PlatformID.Linux.ToString())
                                         .Sum(o => o.Count);
                    foreach (OperatingSystem version in
                             ctx.OperatingSystems.Where(o => o.Name == PlatformID.Linux.ToString()))
                    {
                        linuxPieData.Add(new PieSeriesData
                        {
                            Name =
                                $"{DetectOS.GetPlatformName(PlatformID.Linux, version.Version)}{(string.IsNullOrEmpty(version.Version) ? "" : " ")}{version.Version}",
                            Y = (double?)(version.Count / linuxCount)
                        });
                    }

                    ViewData["linuxPieData"] = linuxPieData;

                    List <PieSeriesData> macosPieData = new List <PieSeriesData>();

                    decimal macosCount = ctx.OperatingSystems.Where(o => o.Name == PlatformID.MacOSX.ToString())
                                         .Sum(o => o.Count);
                    foreach (OperatingSystem version in
                             ctx.OperatingSystems.Where(o => o.Name == PlatformID.MacOSX.ToString()))
                    {
                        macosPieData.Add(new PieSeriesData
                        {
                            Name =
                                $"{DetectOS.GetPlatformName(PlatformID.MacOSX, version.Version)}{(string.IsNullOrEmpty(version.Version) ? "" : " ")}{version.Version}",
                            Y = (double?)(version.Count / macosCount)
                        });
                    }

                    ViewData["macosPieData"] = macosPieData;

                    List <PieSeriesData> windowsPieData = new List <PieSeriesData>();

                    decimal windowsCount = ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString())
                                           .Sum(o => o.Count);
                    foreach (OperatingSystem version in
                             ctx.OperatingSystems.Where(o => o.Name == PlatformID.Win32NT.ToString()))
                    {
                        windowsPieData.Add(new PieSeriesData
                        {
                            Name =
                                $"{DetectOS.GetPlatformName(PlatformID.Win32NT, version.Version)}{(string.IsNullOrEmpty(version.Version) ? "" : " ")}{version.Version}",
                            Y = (double?)(version.Count / windowsCount)
                        });
                    }

                    ViewData["windowsPieData"] = windowsPieData;
                }

                if (ctx.Versions.Any())
                {
                    versions = new List <NameValueStats>();
                    foreach (Version nvs in ctx.Versions)
                    {
                        versions.Add(new NameValueStats
                        {
                            name  = nvs.Value == "previous" ? "Previous than 3.4.99.0" : nvs.Value,
                            Value = nvs.Count
                        });
                    }

                    ViewBag.repVersions = versions.OrderBy(ver => ver.name).ToList();

                    decimal totalVersionCount = ctx.Versions.Sum(o => o.Count);

                    ViewData["versionsPieData"] = ctx.Versions.Select(version => new PieSeriesData
                    {
                        Name =
                            version.Value == "previous"
                                ? "Previous than 3.4.99.0"
                                : version.Value,
                        Y = (double?)(version.Count /
                                      totalVersionCount),
                        Sliced   = version.Value == "previous",
                        Selected = version.Value == "previous"
                    }).ToList();
                }

                if (ctx.Commands.Any())
                {
                    ViewBag.repCommands = ctx.Commands.OrderBy(c => c.Name).ToList();

                    decimal totalCommandCount = ctx.Commands.Sum(o => o.Count);

                    ViewData["commandsPieData"] = ctx
                                                  .Commands.Select(command => new PieSeriesData
                    {
                        Name = command.Name,
                        Y    = (double?)(command.Count /
                                         totalCommandCount),
                        Sliced   = command.Name == "analyze",
                        Selected = command.Name == "analyze"
                    }).ToList();
                }

                if (ctx.Filters.Any())
                {
                    ViewBag.repFilters = ctx.Filters.OrderBy(filter => filter.Name).ToList();

                    List <PieSeriesData> filtersPieData = new List <PieSeriesData>();

                    decimal totalFiltersCount = ctx.Filters.Sum(o => o.Count);
                    foreach (Filter filter in ctx.Filters.ToList())
                    {
                        filtersPieData.Add(new PieSeriesData
                        {
                            Name     = filter.Name,
                            Y        = (double?)(filter.Count / totalFiltersCount),
                            Sliced   = filter.Name == "No filter",
                            Selected = filter.Name == "No filter"
                        });
                    }

                    ViewData["filtersPieData"] = filtersPieData;
                }

                if (ctx.MediaFormats.Any())
                {
                    ViewBag.repMediaImages = ctx.MediaFormats.OrderBy(filter => filter.Name).ToList();

                    List <PieSeriesData> formatsPieData = new List <PieSeriesData>();

                    decimal totalFormatsCount = ctx.MediaFormats.Sum(o => o.Count);
                    decimal top10FormatCount  = 0;

                    foreach (MediaFormat format in ctx.MediaFormats.OrderByDescending(o => o.Count).Take(10))
                    {
                        top10FormatCount += format.Count;

                        formatsPieData.Add(new PieSeriesData
                        {
                            Name = format.Name, Y = (double?)(format.Count / totalFormatsCount)
                        });
                    }

                    formatsPieData.Add(new PieSeriesData
                    {
                        Name = "Other",
                        Y    = (double?)((totalFormatsCount - top10FormatCount) /
                                         totalFormatsCount),
                        Sliced   = true,
                        Selected = true
                    });

                    ViewData["formatsPieData"] = formatsPieData;
                }

                if (ctx.Partitions.Any())
                {
                    ViewBag.repPartitions = ctx.Partitions.OrderBy(filter => filter.Name).ToList();

                    List <PieSeriesData> partitionsPieData = new List <PieSeriesData>();

                    decimal totalPartitionsCount = ctx.Partitions.Sum(o => o.Count);
                    decimal top10PartitionCount  = 0;

                    foreach (Partition partition in ctx.Partitions.OrderByDescending(o => o.Count).Take(10))
                    {
                        top10PartitionCount += partition.Count;

                        partitionsPieData.Add(new PieSeriesData
                        {
                            Name = partition.Name,
                            Y    = (double?)(partition.Count / totalPartitionsCount)
                        });
                    }

                    partitionsPieData.Add(new PieSeriesData
                    {
                        Name = "Other",
                        Y    = (double?)((totalPartitionsCount - top10PartitionCount) /
                                         totalPartitionsCount),
                        Sliced   = true,
                        Selected = true
                    });

                    ViewData["partitionsPieData"] = partitionsPieData;
                }

                if (ctx.Filesystems.Any())
                {
                    ViewBag.repFilesystems = ctx.Filesystems.OrderBy(filter => filter.Name).ToList();

                    List <PieSeriesData> filesystemsPieData = new List <PieSeriesData>();

                    decimal totalFilesystemsCount = ctx.Filesystems.Sum(o => o.Count);
                    decimal top10FilesystemCount  = 0;

                    foreach (Filesystem filesystem in ctx.Filesystems.OrderByDescending(o => o.Count).Take(10))
                    {
                        top10FilesystemCount += filesystem.Count;

                        filesystemsPieData.Add(new PieSeriesData
                        {
                            Name = filesystem.Name,
                            Y    = (double?)(filesystem.Count / totalFilesystemsCount)
                        });
                    }

                    filesystemsPieData.Add(new PieSeriesData
                    {
                        Name = "Other",
                        Y    = (double?)((totalFilesystemsCount - top10FilesystemCount) /
                                         totalFilesystemsCount),
                        Sliced   = true,
                        Selected = true
                    });

                    ViewData["filesystemsPieData"] = filesystemsPieData;
                }

                if (ctx.Medias.Any())
                {
                    realMedia    = new List <MediaItem>();
                    virtualMedia = new List <MediaItem>();
                    foreach (Media nvs in ctx.Medias)
                    {
                        try
                        {
                            MediaType
                            .MediaTypeToString((CommonTypes.MediaType)Enum.Parse(typeof(CommonTypes.MediaType), nvs.Type),
                                               out string type, out string subtype);

                            if (nvs.Real)
                            {
                                realMedia.Add(new MediaItem {
                                    Type = type, SubType = subtype, Count = nvs.Count
                                });
                            }
                            else
                            {
                                virtualMedia.Add(new MediaItem {
                                    Type = type, SubType = subtype, Count = nvs.Count
                                });
                            }
                        }
                        catch
                        {
                            if (nvs.Real)
                            {
                                realMedia.Add(new MediaItem {
                                    Type = nvs.Type, SubType = null, Count = nvs.Count
                                });
                            }
                            else
                            {
                                virtualMedia.Add(new MediaItem {
                                    Type = nvs.Type, SubType = null, Count = nvs.Count
                                });
                            }
                        }
                    }

                    if (realMedia.Count > 0)
                    {
                        ViewBag.repRealMedia =
                            realMedia.OrderBy(media => media.Type).ThenBy(media => media.SubType).ToList();

                        List <PieSeriesData> realMediaPieData = new List <PieSeriesData>();

                        decimal totalRealMediaCount = realMedia.Sum(o => o.Count);
                        decimal top10RealMediaCount = 0;

                        foreach (MediaItem realMediaItem in realMedia.OrderByDescending(o => o.Count).Take(10))
                        {
                            top10RealMediaCount += realMediaItem.Count;

                            realMediaPieData.Add(new PieSeriesData
                            {
                                Name = $"{realMediaItem.Type} ({realMediaItem.SubType})",
                                Y    = (double?)(realMediaItem.Count / totalRealMediaCount)
                            });
                        }

                        realMediaPieData.Add(new PieSeriesData
                        {
                            Name = "Other",
                            Y    = (double?)((totalRealMediaCount - top10RealMediaCount) /
                                             totalRealMediaCount),
                            Sliced   = true,
                            Selected = true
                        });

                        ViewData["realMediaPieData"] = realMediaPieData;
                    }

                    if (virtualMedia.Count > 0)
                    {
                        ViewBag.repVirtualMedia =
                            virtualMedia.OrderBy(media => media.Type).ThenBy(media => media.SubType).ToList();

                        List <PieSeriesData> virtualMediaPieData = new List <PieSeriesData>();

                        decimal totalVirtualMediaCount = virtualMedia.Sum(o => o.Count);
                        decimal top10VirtualMediaCount = 0;

                        foreach (MediaItem virtualMediaItem in virtualMedia.OrderByDescending(o => o.Count).Take(10))
                        {
                            top10VirtualMediaCount += virtualMediaItem.Count;

                            virtualMediaPieData.Add(new PieSeriesData
                            {
                                Name =
                                    $"{virtualMediaItem.Type} ({virtualMediaItem.SubType})",
                                Y = (double?)(virtualMediaItem.Count /
                                              totalVirtualMediaCount)
                            });
                        }

                        virtualMediaPieData.Add(new PieSeriesData
                        {
                            Name = "Other",
                            Y    = (double?)
                                   ((totalVirtualMediaCount - top10VirtualMediaCount) /
                                    totalVirtualMediaCount),
                            Sliced   = true,
                            Selected = true
                        });

                        ViewData["virtualMediaPieData"] = virtualMediaPieData;
                    }
                }

                if (ctx.DeviceStats.Any())
                {
                    devices = new List <DeviceItem>();
                    foreach (DeviceStat device in ctx.DeviceStats.ToList())
                    {
                        string xmlFile;
                        if (!string.IsNullOrWhiteSpace(device.Manufacturer) &&
                            !string.IsNullOrWhiteSpace(device.Model) &&
                            !string.IsNullOrWhiteSpace(device.Revision))
                        {
                            xmlFile = device.Manufacturer + "_" + device.Model + "_" + device.Revision + ".xml";
                        }
                        else if (!string.IsNullOrWhiteSpace(device.Manufacturer) &&
                                 !string.IsNullOrWhiteSpace(device.Model))
                        {
                            xmlFile = device.Manufacturer + "_" + device.Model + ".xml";
                        }
                        else if (!string.IsNullOrWhiteSpace(device.Model) && !string.IsNullOrWhiteSpace(device.Revision))
                        {
                            xmlFile = device.Model + "_" + device.Revision + ".xml";
                        }
                        else
                        {
                            xmlFile = device.Model + ".xml";
                        }

                        xmlFile = xmlFile.Replace('/', '_').Replace('\\', '_').Replace('?', '_');

                        if (System.IO.File.Exists(Path.Combine(HostingEnvironment.MapPath("~"), "Reports", xmlFile)))
                        {
                            DeviceReport deviceReport = new DeviceReport();

                            XmlSerializer xs = new XmlSerializer(deviceReport.GetType());
                            FileStream    fs =
                                WaitForFile(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "Reports", xmlFile),
                                            FileMode.Open, FileAccess.Read, FileShare.Read);
                            deviceReport = (DeviceReport)xs.Deserialize(fs);
                            fs.Close();

                            DeviceReportV2 deviceReportV2 = new DeviceReportV2(deviceReport);

                            device.Report = ctx.Devices.Add(new Device(deviceReportV2));
                            ctx.SaveChanges();

                            System.IO.File
                            .Delete(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(),
                                                 "Reports", xmlFile));
                        }

                        devices.Add(new DeviceItem
                        {
                            Manufacturer = device.Manufacturer,
                            Model        = device.Model,
                            Revision     = device.Revision,
                            Bus          = device.Bus,
                            ReportId     = device.Report != null && device.Report.Id != 0
                                           ? device.Report.Id
                                           : 0
                        });
                    }

                    ViewBag.repDevices = devices.OrderBy(device => device.Manufacturer).ThenBy(device => device.Model)
                                         .ThenBy(device => device.Revision).ThenBy(device => device.Bus)
                                         .ToList();

                    ViewData["devicesBusPieData"] = (from deviceBus in devices.Select(d => d.Bus).Distinct()
                                                     let deviceBusCount = devices.Count(d => d.Bus == deviceBus)
                                                                          select new PieSeriesData
                    {
                        Name = deviceBus,
                        Y = deviceBusCount / (double)devices.Count
                    }).ToList();

                    ViewData["devicesManufacturerPieData"] =
                        (from manufacturer in
                         devices.Where(d => d.Manufacturer != null).Select(d => d.Manufacturer.ToLowerInvariant())
                         .Distinct()
                         let manufacturerCount = devices.Count(d => d.Manufacturer?.ToLowerInvariant() == manufacturer)
                                                 select new PieSeriesData {
                        Name = manufacturer, Y = manufacturerCount / (double)devices.Count
                    })
                        .ToList();
                }
            }
            catch (Exception)
            {
                #if DEBUG
                throw;
                #endif
                return(Content("Could not read statistics"));
            }

            return(View());
        }
Example #5
0
        public static void Main(string[] args)
        {
            Console.Clear();

            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[37;1m          MARECHAI\u001b[0m\n" +
                "\u001b[32m                   ..KMMMMMMNo,.             ,OMMMMMMW:,.                 \u001b[37;1m          Master repository of computing history artifacts information\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[0m\n", Version.GetVersion(),
                      #if DEBUG
                "DEBUG"
                      #else
                "RELEASE"
                      #endif
                , DetectOS.GetPlatformName(DetectOS.GetRealPlatformID()),
                Environment.Is64BitOperatingSystem ? 64 : 32, Environment.Is64BitProcess ? 64 : 32,
                DetectOS.IsMono ? "Mono" : ".NET Core",
                DetectOS.IsMono ? Version.GetMonoVersion() : Version.GetNetCoreVersion());

            Console.WriteLine("\u001b[31;1mUpdating MySQL database without Entity Framework if it exists...\u001b[0m");
            Database = new Mysql();

            IConfigurationBuilder builder       = new ConfigurationBuilder().AddJsonFile("appsettings.json");
            IConfigurationRoot    configuration = builder.Build();
            string connectionString             = configuration.GetConnectionString("DefaultConnection");

            if (connectionString is null)
            {
                Console.WriteLine("\u001b[31;1mCould not find a correct connection string...\u001b[0m");
            }
            else
            {
                string   server = null, user = null, database = null, password = null;
                ushort   port   = 0;
                string[] pieces = connectionString.Split(";");

                foreach (string piece in pieces)
                {
                    if (piece.StartsWith("server=", StringComparison.Ordinal))
                    {
                        server = piece.Substring(7);
                    }
                    else if (piece.StartsWith("user="******"password="******"database=", StringComparison.Ordinal))
                    {
                        database = piece.Substring(9);
                    }
                    else if (piece.StartsWith("port=", StringComparison.Ordinal))
                    {
                        string portString = piece.Substring(5);

                        ushort.TryParse(portString, out port);
                    }
                }

                if (server is null ||
                    user is null ||
                    database is null ||
                    password is null ||
                    port == 0)
                {
                    Console.WriteLine("\u001b[31;1mCould not find a correct connection string...\u001b[0m");
                }
Example #6
0
        /// <summary>Initializes the dump log</summary>
        /// <param name="outputFile">Output log file</param>
        /// <param name="dev">Device</param>
        /// <param name="private">Disable saving paths or serial numbers in log</param>
        public DumpLog(string outputFile, Device dev, bool @private)
        {
            if (string.IsNullOrEmpty(outputFile))
            {
                return;
            }

            _logSw = new StreamWriter(outputFile, true);

            _logSw.WriteLine("Start logging at {0}", DateTime.Now);

            PlatformID platId  = DetectOS.GetRealPlatformID();
            string     platVer = DetectOS.GetVersion();

            var assemblyVersion =
                Attribute.GetCustomAttribute(typeof(DumpLog).Assembly, typeof(AssemblyInformationalVersionAttribute)) as
                AssemblyInformationalVersionAttribute;

            _logSw.WriteLine("################# System information #################");

            _logSw.WriteLine("{0} {1} ({2}-bit)", DetectOS.GetPlatformName(platId, platVer), platVer,
                             Environment.Is64BitOperatingSystem ? 64 : 32);

            if (DetectOS.IsMono)
            {
                _logSw.WriteLine("Mono {0}", Version.GetMonoVersion());
            }
            else if (DetectOS.IsNetCore)
            {
                _logSw.WriteLine(".NET Core {0}", Version.GetNetCoreVersion());
            }
            else
            {
                _logSw.WriteLine(RuntimeInformation.FrameworkDescription);
            }

            _logSw.WriteLine();

            _logSw.WriteLine("################# Program information ################");
            _logSw.WriteLine("Aaru {0}", assemblyVersion?.InformationalVersion);
            _logSw.WriteLine("Running in {0}-bit", Environment.Is64BitProcess ? 64 : 32);
            _logSw.WriteLine("Running as superuser: {0}", DetectOS.IsAdmin ? "Yes" : "No");
        #if DEBUG
            _logSw.WriteLine("DEBUG version");
        #endif
            if (@private)
            {
                string[] args = Environment.GetCommandLineArgs();

                for (int i = 0; i < args.Length; i++)
                {
                    if (args[i].StartsWith("/dev", StringComparison.OrdinalIgnoreCase) ||
                        args[i].StartsWith("aaru://", StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }

                    try
                    {
                        args[i] = Path.GetFileName(args[i]);
                    }
                    catch
                    {
                        // Do nothing
                    }
                }

                _logSw.WriteLine("Command line: {0}", string.Join(" ", args));
            }
            else
            {
                _logSw.WriteLine("Command line: {0}", Environment.CommandLine);
            }

            _logSw.WriteLine();

            if (dev.IsRemote)
            {
                _logSw.WriteLine("################# Remote information #################");
                _logSw.WriteLine("Server: {0}", dev.RemoteApplication);
                _logSw.WriteLine("Version: {0}", dev.RemoteVersion);

                _logSw.WriteLine("Operating system: {0} {1}", dev.RemoteOperatingSystem,
                                 dev.RemoteOperatingSystemVersion);

                _logSw.WriteLine("Architecture: {0}", dev.RemoteArchitecture);
                _logSw.WriteLine("Protocol version: {0}", dev.RemoteProtocolVersion);
                _logSw.WriteLine("Running as superuser: {0}", dev.IsRemoteAdmin ? "Yes" : "No");
                _logSw.WriteLine("######################################################");
            }

            _logSw.WriteLine("################# Device information #################");
            _logSw.WriteLine("Manufacturer: {0}", dev.Manufacturer);
            _logSw.WriteLine("Model: {0}", dev.Model);
            _logSw.WriteLine("Firmware revision: {0}", dev.FirmwareRevision);

            if (!@private)
            {
                _logSw.WriteLine("Serial number: {0}", dev.Serial);
            }

            _logSw.WriteLine("Removable device: {0}", dev.IsRemovable);
            _logSw.WriteLine("Device type: {0}", dev.Type);
            _logSw.WriteLine("CompactFlash device: {0}", dev.IsCompactFlash);
            _logSw.WriteLine("PCMCIA device: {0}", dev.IsPcmcia);
            _logSw.WriteLine("USB device: {0}", dev.IsUsb);

            if (dev.IsUsb)
            {
                _logSw.WriteLine("USB manufacturer: {0}", dev.UsbManufacturerString);
                _logSw.WriteLine("USB product: {0}", dev.UsbProductString);

                if (!@private)
                {
                    _logSw.WriteLine("USB serial: {0}", dev.UsbSerialString);
                }

                _logSw.WriteLine("USB vendor ID: {0:X4}h", dev.UsbVendorId);
                _logSw.WriteLine("USB product ID: {0:X4}h", dev.UsbProductId);
            }

            _logSw.WriteLine("FireWire device: {0}", dev.IsFireWire);

            if (dev.IsFireWire)
            {
                _logSw.WriteLine("FireWire vendor: {0}", dev.FireWireVendorName);
                _logSw.WriteLine("FireWire model: {0}", dev.FireWireModelName);

                if (!@private)
                {
                    _logSw.WriteLine("FireWire GUID: 0x{0:X16}", dev.FireWireGuid);
                }

                _logSw.WriteLine("FireWire vendor ID: 0x{0:X8}", dev.FireWireVendor);
                _logSw.WriteLine("FireWire product ID: 0x{0:X8}", dev.FireWireModel);
            }

            _logSw.WriteLine("######################################################");

            _logSw.WriteLine();
            _logSw.WriteLine("################ Dumping progress log ################");
            _logSw.Flush();
        }
        public static void Main(string[] args)
        {
            DateTime start;
            DateTime end;

            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          DiscImageChef 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[0m\n", Version.GetVersion(),
                             #if DEBUG
                "DEBUG"
                             #else
                "RELEASE"
                             #endif
                , DetectOS.GetPlatformName(DetectOS.GetRealPlatformID()),
                Environment.Is64BitOperatingSystem ? 64 : 32, Environment.Is64BitProcess ? 64 : 32,
                DetectOS.IsMono ? "Mono" : ".NET Core",
                DetectOS.IsMono ? Version.GetMonoVersion() : Version.GetNetCoreVersion());

            IHost host = CreateHostBuilder(args).Build();

            using (IServiceScope scope = host.Services.CreateScope())
            {
                IServiceProvider services = scope.ServiceProvider;

                try
                {
                    start = DateTime.Now;
                    System.Console.WriteLine("\u001b[31;1mUpdating database with Entity Framework...\u001b[0m");
                    var context = services.GetRequiredService <DicServerContext>();
                    context.Database.Migrate();
                    end = DateTime.Now;

                    System.Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m",
                                             (end - start).TotalSeconds);
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine("\u001b[31;1mCould not open database...\u001b[0m");
                #if DEBUG
                    System.Console.WriteLine("\u001b[31;1mException: {0}\u001b[0m", ex.Message);
                #endif
                    return;
                }
            }

            System.Console.WriteLine("\u001b[31;1mStarting web server...\u001b[0m");
            host.Run();
        }
Example #8
0
        /// <summary>Initializes the dump log</summary>
        /// <param name="outputFile">Output log file</param>
        /// <param name="dev">Device</param>
        public DumpLog(string outputFile, Device dev)
        {
            if (string.IsNullOrEmpty(outputFile))
            {
                return;
            }

            logSw = new StreamWriter(outputFile, true);

            logSw.WriteLine("Start logging at {0}", DateTime.Now);

            PlatformID platId  = DetectOS.GetRealPlatformID();
            string     platVer = DetectOS.GetVersion();

            var assemblyVersion =
                Attribute.GetCustomAttribute(typeof(DumpLog).Assembly, typeof(AssemblyInformationalVersionAttribute)) as
                AssemblyInformationalVersionAttribute;

            logSw.WriteLine("################# System information #################");

            logSw.WriteLine("{0} {1} ({2}-bit)", DetectOS.GetPlatformName(platId, platVer), platVer,
                            Environment.Is64BitOperatingSystem ? 64 : 32);

            if (DetectOS.IsMono)
            {
                logSw.WriteLine("Mono {0}", Version.GetMonoVersion());
            }
            else if (DetectOS.IsNetCore)
            {
                logSw.WriteLine(".NET Core {0}", Version.GetNetCoreVersion());
            }
            else
            {
                logSw.WriteLine(RuntimeInformation.FrameworkDescription);
            }

            logSw.WriteLine();

            logSw.WriteLine("################# Program information ################");
            logSw.WriteLine("DiscImageChef {0}", assemblyVersion?.InformationalVersion);
            logSw.WriteLine("Running in {0}-bit", Environment.Is64BitProcess ? 64 : 32);
        #if DEBUG
            logSw.WriteLine("DEBUG version");
        #endif
            logSw.WriteLine("Command line: {0}", Environment.CommandLine);
            logSw.WriteLine();

            if (dev.IsRemote)
            {
                logSw.WriteLine("################# Remote information #################");
                logSw.WriteLine("Server: {0}", dev.RemoteApplication);
                logSw.WriteLine("Version: {0}", dev.RemoteVersion);

                logSw.WriteLine("Operating system: {0} {1}", dev.RemoteOperatingSystem,
                                dev.RemoteOperatingSystemVersion);

                logSw.WriteLine("Architecture: {0}", dev.RemoteArchitecture);
                logSw.WriteLine("Protocol version: {0}", dev.RemoteProtocolVersion);
                logSw.WriteLine("######################################################");
            }

            logSw.WriteLine("################# Device information #################");
            logSw.WriteLine("Manufacturer: {0}", dev.Manufacturer);
            logSw.WriteLine("Model: {0}", dev.Model);
            logSw.WriteLine("Firmware revision: {0}", dev.FirmwareRevision);
            logSw.WriteLine("Serial number: {0}", dev.Serial);
            logSw.WriteLine("Removable device: {0}", dev.IsRemovable);
            logSw.WriteLine("Device type: {0}", dev.Type);
            logSw.WriteLine("CompactFlash device: {0}", dev.IsCompactFlash);
            logSw.WriteLine("PCMCIA device: {0}", dev.IsPcmcia);
            logSw.WriteLine("USB device: {0}", dev.IsUsb);

            if (dev.IsUsb)
            {
                logSw.WriteLine("USB manufacturer: {0}", dev.UsbManufacturerString);
                logSw.WriteLine("USB product: {0}", dev.UsbProductString);
                logSw.WriteLine("USB serial: {0}", dev.UsbSerialString);
                logSw.WriteLine("USB vendor ID: {0:X4}h", dev.UsbVendorId);
                logSw.WriteLine("USB product ID: {0:X4}h", dev.UsbProductId);
            }

            logSw.WriteLine("FireWire device: {0}", dev.IsFireWire);

            if (dev.IsFireWire)
            {
                logSw.WriteLine("FireWire vendor: {0}", dev.FireWireVendorName);
                logSw.WriteLine("FireWire model: {0}", dev.FireWireModelName);
                logSw.WriteLine("FireWire GUID: 0x{0:X16}", dev.FireWireGuid);
                logSw.WriteLine("FireWire vendor ID: 0x{0:X8}", dev.FireWireVendor);
                logSw.WriteLine("FireWire product ID: 0x{0:X8}", dev.FireWireModel);
            }

            logSw.WriteLine("######################################################");

            logSw.WriteLine();
            logSw.WriteLine("################ Dumping progress log ################");
            logSw.Flush();
        }
Example #9
0
    public static void Main(string[] args)
    {
        DateTime start;
        DateTime end;

        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        ;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[0m\n", Version.GetVersion(),
                         #if DEBUG
            "DEBUG"
                         #else
            "RELEASE"
                         #endif
            , DetectOS.GetPlatformName(DetectOS.GetRealPlatformID()),
            Environment.Is64BitOperatingSystem ? 64 : 32, Environment.Is64BitProcess ? 64 : 32,
            DetectOS.IsMono ? "Mono" : ".NET Core",
            DetectOS.IsMono ? Version.GetMonoVersion() : Version.GetNetCoreVersion());

        System.Console.WriteLine("\u001b[31;1mBuilding web application...\u001b[0m");

        WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

        builder.Services.AddDbContext <AaruServerContext>(options => options.
                                                          UseMySql(builder.Configuration.GetConnectionString("DefaultConnection"),
                                                                   new
                                                                   MariaDbServerVersion(new System.
                                                                                        Version(10, 4, 0))).
                                                          UseLazyLoadingProxies());

        builder.Services.AddDefaultIdentity <IdentityUser>(options =>
        {
            options.SignIn.RequireConfirmedAccount = true;
            options.User.RequireUniqueEmail        = true;
        }).AddEntityFrameworkStores <AaruServerContext>();

        builder.Services.AddApplicationInsightsTelemetry();

        builder.Services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);

        WebApplication app = builder.Build();

        app.UseForwardedHeaders(new ForwardedHeadersOptions
        {
            ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
        });

        app.UseHttpMetrics();

        if (builder.Environment.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");

            // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
            app.UseHsts();
        }

        app.UseDefaultFiles();
        app.UseStaticFiles();

        // Add other security headers
        app.UseMiddleware <SecurityHeadersMiddleware>();

        app.UseRouting();

        app.UseAuthentication();
        app.UseAuthorization();

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllerRoute("areas", "{area}/{controller=Home}/{action=Index}/{id?}");
            endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
            endpoints.MapRazorPages();
        });

        app.Map("/metrics", metricsApp =>
        {
            metricsApp.UseMiddleware <BasicAuthMiddleware>("Aaru");

            // We already specified URL prefix in .Map() above, no need to specify it again here.
            metricsApp.UseMetricServer("");
        });

        using (IServiceScope scope = app.Services.CreateScope())
        {
            IServiceProvider services = scope.ServiceProvider;

            try
            {
                start = DateTime.Now;
                System.Console.WriteLine("\u001b[31;1mUpdating database with Entity Framework...\u001b[0m");
                AaruServerContext context = services.GetRequiredService <AaruServerContext>();
                context.Database.Migrate();
                end = DateTime.Now;

                System.Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m",
                                         (end - start).TotalSeconds);

                start = DateTime.Now;
                System.Console.WriteLine("\u001b[31;1mSeeding Identity...\u001b[0m");
                Seeder.Seed(context, services);
                context.Database.Migrate();
                end = DateTime.Now;

                System.Console.WriteLine("\u001b[31;1mTook \u001b[32;1m{0} seconds\u001b[31;1m...\u001b[0m",
                                         (end - start).TotalSeconds);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("\u001b[31;1mCould not open database...\u001b[0m");
            #if DEBUG
                System.Console.WriteLine("\u001b[31;1mException: {0}\u001b[0m", ex.Message);
            #endif
                return;
            }
        }

        System.Console.WriteLine("\u001b[31;1mStarting web server...\u001b[0m");

        app.Run();
    }
Example #10
0
        public Remote(string host)
        {
            _host = host;
            IPHostEntry ipHostEntry = Dns.GetHostEntry(host);

            IPAddress ipAddress =
                ipHostEntry.AddressList.FirstOrDefault(a => a.AddressFamily == AddressFamily.InterNetwork);

            if (ipAddress is null)
            {
                AaruConsole.ErrorWriteLine("Host not found");

                throw new SocketException(11001);
            }

            var ipEndPoint = new IPEndPoint(ipAddress, 6666);

            _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            _socket.Connect(ipEndPoint);

            AaruConsole.WriteLine("Connected to {0}", host);

            byte[] hdrBuf = new byte[Marshal.SizeOf <AaruPacketHeader>()];

            int len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek);

            if (len < hdrBuf.Length)
            {
                AaruConsole.ErrorWriteLine("Could not read from the network...");

                throw new IOException();
            }

            AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian <AaruPacketHeader>(hdrBuf);

            if (hdr.remote_id != Consts.RemoteId ||
                hdr.packet_id != Consts.PacketId)
            {
                AaruConsole.ErrorWriteLine("Received data is not an Aaru Remote Packet...");

                throw new ArgumentException();
            }

            byte[] buf;

            if (hdr.packetType != AaruPacketType.Hello)
            {
                if (hdr.packetType != AaruPacketType.Nop)
                {
                    AaruConsole.ErrorWriteLine("Expected Hello Packet, got packet type {0}...", hdr.packetType);

                    throw new ArgumentException();
                }

                buf = new byte[hdr.len];
                len = Receive(_socket, buf, buf.Length, SocketFlags.None);

                if (len < buf.Length)
                {
                    AaruConsole.ErrorWriteLine("Could not read from the network...");

                    throw new IOException();
                }

                AaruPacketNop nop = Marshal.ByteArrayToStructureLittleEndian <AaruPacketNop>(buf);

                AaruConsole.ErrorWriteLine($"{nop.reason}");

                throw new ArgumentException();
            }

            if (hdr.version != Consts.PacketVersion)
            {
                AaruConsole.ErrorWriteLine("Unrecognized packet version...");

                throw new ArgumentException();
            }

            buf = new byte[hdr.len];
            len = Receive(_socket, buf, buf.Length, SocketFlags.None);

            if (len < buf.Length)
            {
                AaruConsole.ErrorWriteLine("Could not read from the network...");

                throw new IOException();
            }

            AaruPacketHello serverHello = Marshal.ByteArrayToStructureLittleEndian <AaruPacketHello>(buf);

            ServerApplication            = serverHello.application;
            ServerVersion                = serverHello.version;
            ServerOperatingSystem        = serverHello.sysname;
            ServerOperatingSystemVersion = serverHello.release;
            ServerArchitecture           = serverHello.machine;
            ServerProtocolVersion        = serverHello.maxProtocol;

            var clientHello = new AaruPacketHello
            {
                application = "Aaru", version = Version.GetVersion(), maxProtocol = Consts.MaxProtocol,
                sysname     = DetectOS.GetPlatformName(DetectOS.GetRealPlatformID(), DetectOS.GetVersion()),
                release     = DetectOS.GetVersion(), machine = RuntimeInformation.ProcessArchitecture.ToString(), hdr =
                    new AaruPacketHeader
                {
                    remote_id  = Consts.RemoteId, packet_id = Consts.PacketId,
                    len        = (uint)Marshal.SizeOf <AaruPacketHello>(), version = Consts.PacketVersion,
                    packetType = AaruPacketType.Hello
                }
            };

            buf = Marshal.StructureToByteArrayLittleEndian(clientHello);

            len = _socket.Send(buf, SocketFlags.None);

            if (len >= buf.Length)
            {
                return;
            }

            AaruConsole.ErrorWriteLine("Could not write to the network...");

            throw new IOException();
        }
Example #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lblVersion.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            try
            {
                if (!File.Exists(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(),
                                              "Statistics", "Statistics.xml")))
                {
                    #if DEBUG
                    content.InnerHtml =
                        $"<b>Sorry, cannot load data file \"{Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "Statistics", "Statistics.xml")}\"</b>";
                    #else
                    content.InnerHtml = "<b>Sorry, cannot load data file</b>";
                    #endif
                    return;
                }

                statistics = new Stats();

                XmlSerializer xs = new XmlSerializer(statistics.GetType());
                FileStream    fs =
                    WaitForFile(Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(), "Statistics", "Statistics.xml"),
                                FileMode.Open, FileAccess.Read, FileShare.Read);
                statistics = (Stats)xs.Deserialize(fs);
                fs.Close();

                if (statistics.OperatingSystems != null)
                {
                    operatingSystems = new List <NameValueStats>();
                    foreach (OsStats nvs in statistics.OperatingSystems)
                    {
                        operatingSystems.Add(new NameValueStats
                        {
                            name =
                                $"{DetectOS.GetPlatformName((PlatformID)Enum.Parse(typeof(PlatformID), nvs.name), nvs.version)}{(string.IsNullOrEmpty(nvs.version) ? "" : " ")}{nvs.version}",
                            Value = nvs.Value
                        });
                    }

                    repOperatingSystems.DataSource = operatingSystems.OrderBy(os => os.name).ToList();
                    repOperatingSystems.DataBind();
                }
                else
                {
                    divOperatingSystems.Visible = false;
                }

                if (statistics.Versions != null)
                {
                    versions = new List <NameValueStats>();
                    foreach (NameValueStats nvs in statistics.Versions)
                    {
                        versions.Add(nvs.name == "previous"
                                         ? new NameValueStats {
                            name = "Previous than 3.4.99.0", Value = nvs.Value
                        }
                                         : nvs);
                    }

                    repVersions.DataSource = versions.OrderBy(ver => ver.name).ToList();
                    repVersions.DataBind();
                }
                else
                {
                    divVersions.Visible = false;
                }

                if (statistics.Commands != null)
                {
                    lblAnalyze.Text       = statistics.Commands.Analyze.ToString();
                    lblCompare.Text       = statistics.Commands.Compare.ToString();
                    lblChecksum.Text      = statistics.Commands.Checksum.ToString();
                    lblEntropy.Text       = statistics.Commands.Entropy.ToString();
                    lblVerify.Text        = statistics.Commands.Verify.ToString();
                    lblPrintHex.Text      = statistics.Commands.PrintHex.ToString();
                    lblDecode.Text        = statistics.Commands.Decode.ToString();
                    lblDeviceInfo.Text    = statistics.Commands.DeviceInfo.ToString();
                    lblMediaInfo.Text     = statistics.Commands.MediaInfo.ToString();
                    lblMediaScan.Text     = statistics.Commands.MediaScan.ToString();
                    lblFormats.Text       = statistics.Commands.Formats.ToString();
                    lblBenchmark.Text     = statistics.Commands.Benchmark.ToString();
                    lblCreateSidecar.Text = statistics.Commands.CreateSidecar.ToString();
                    lblDumpMedia.Text     = statistics.Commands.DumpMedia.ToString();
                    lblDeviceReport.Text  = statistics.Commands.DeviceReport.ToString();
                    lblLs.Text            = statistics.Commands.Ls.ToString();
                    lblExtractFiles.Text  = statistics.Commands.ExtractFiles.ToString();
                    lblListDevices.Text   = statistics.Commands.ListDevices.ToString();
                    lblListEncodings.Text = statistics.Commands.ListEncodings.ToString();
                    lblConvertImage.Text  = statistics.Commands.ConvertImage.ToString();
                    lblImageInfo.Text     = statistics.Commands.ImageInfo.ToString();
                }
                else
                {
                    divCommands.Visible = false;
                }

                if (statistics.Filters != null)
                {
                    repFilters.DataSource = statistics.Filters.OrderBy(filter => filter.name).ToList();
                    repFilters.DataBind();
                }
                else
                {
                    divFilters.Visible = false;
                }

                if (statistics.MediaImages != null)
                {
                    repMediaImages.DataSource = statistics.MediaImages.OrderBy(filter => filter.name).ToList();
                    repMediaImages.DataBind();
                }
                else
                {
                    divMediaImages.Visible = false;
                }

                if (statistics.Partitions != null)
                {
                    repPartitions.DataSource = statistics.Partitions.OrderBy(filter => filter.name).ToList();
                    repPartitions.DataBind();
                }
                else
                {
                    divPartitions.Visible = false;
                }

                if (statistics.Filesystems != null)
                {
                    repFilesystems.DataSource = statistics.Filesystems.OrderBy(filter => filter.name).ToList();
                    repFilesystems.DataBind();
                }
                else
                {
                    divFilesystems.Visible = false;
                }

                if (statistics.Medias != null)
                {
                    realMedia    = new List <MediaItem>();
                    virtualMedia = new List <MediaItem>();
                    foreach (MediaStats nvs in statistics.Medias)
                    {
                        MediaType
                        .MediaTypeToString((CommonTypes.MediaType)Enum.Parse(typeof(CommonTypes.MediaType), nvs.type),
                                           out string type, out string subtype);

                        if (nvs.real)
                        {
                            realMedia.Add(new MediaItem {
                                Type = type, SubType = subtype, Count = nvs.Value
                            });
                        }
                        else
                        {
                            virtualMedia.Add(new MediaItem {
                                Type = type, SubType = subtype, Count = nvs.Value
                            });
                        }
                    }

                    if (realMedia.Count > 0)
                    {
                        repRealMedia.DataSource =
                            realMedia.OrderBy(media => media.Type).ThenBy(media => media.SubType).ToList();
                        repRealMedia.DataBind();
                    }
                    else
                    {
                        divRealMedia.Visible = false;
                    }

                    if (virtualMedia.Count > 0)
                    {
                        repVirtualMedia.DataSource =
                            virtualMedia.OrderBy(media => media.Type).ThenBy(media => media.SubType).ToList();
                        repVirtualMedia.DataBind();
                    }
                    else
                    {
                        divVirtualMedia.Visible = false;
                    }
                }
                else
                {
                    divRealMedia.Visible    = false;
                    divVirtualMedia.Visible = false;
                }

                if (statistics.Devices != null)
                {
                    devices = new List <DeviceItem>();
                    foreach (DeviceStats device in statistics.Devices)
                    {
                        string url;
                        string xmlFile;
                        if (!string.IsNullOrWhiteSpace(device.Manufacturer) &&
                            !string.IsNullOrWhiteSpace(device.Model) &&
                            !string.IsNullOrWhiteSpace(device.Revision))
                        {
                            xmlFile = device.Manufacturer + "_" + device.Model + "_" + device.Revision + ".xml";
                            url     =
                                $"ViewReport.aspx?manufacturer={HttpUtility.UrlPathEncode(device.Manufacturer)}&model={HttpUtility.UrlPathEncode(device.Model)}&revision={HttpUtility.UrlPathEncode(device.Revision)}";
                        }
                        else if (!string.IsNullOrWhiteSpace(device.Manufacturer) &&
                                 !string.IsNullOrWhiteSpace(device.Model))
                        {
                            xmlFile = device.Manufacturer + "_" + device.Model + ".xml";
                            url     =
                                $"ViewReport.aspx?manufacturer={HttpUtility.UrlPathEncode(device.Manufacturer)}&model={HttpUtility.UrlPathEncode(device.Model)}";
                        }
                        else if (!string.IsNullOrWhiteSpace(device.Model) && !string.IsNullOrWhiteSpace(device.Revision))
                        {
                            xmlFile = device.Model + "_" + device.Revision + ".xml";
                            url     =
                                $"ViewReport.aspx?model={HttpUtility.UrlPathEncode(device.Model)}&revision={HttpUtility.UrlPathEncode(device.Revision)}";
                        }
                        else
                        {
                            xmlFile = device.Model + ".xml";
                            url     = $"ViewReport.aspx?model={HttpUtility.UrlPathEncode(device.Model)}";
                        }

                        xmlFile = xmlFile.Replace('/', '_').Replace('\\', '_').Replace('?', '_');

                        if (!File.Exists(Path.Combine(HostingEnvironment.MapPath("~"), "Reports", xmlFile)))
                        {
                            url = null;
                        }

                        devices.Add(new DeviceItem
                        {
                            Manufacturer = device.Manufacturer,
                            Model        = device.Model,
                            Revision     = device.Revision,
                            Bus          = device.Bus,
                            ReportLink   = url == null ? "No" : $"<a href=\"{url}\" target=\"_blank\">Yes</a>"
                        });
                    }

                    repDevices.DataSource = devices.OrderBy(device => device.Manufacturer)
                                            .ThenBy(device => device.Model).ThenBy(device => device.Revision)
                                            .ThenBy(device => device.Bus).ToList();
                    repDevices.DataBind();
                }
                else
                {
                    divDevices.Visible = false;
                }
            }
            catch (Exception)
            {
                content.InnerHtml = "<b>Could not load statistics</b>";
                #if DEBUG
                throw;
                #endif
            }
        }
Example #12
0
        protected void OnBtnSaveClicked(object sender, EventArgs e)
        {
            var dlgSave = new SaveFileDialog
            {
                CheckFileExists = true
            };

            dlgSave.Filters.Add(new FileFilter
            {
                Extensions = new[]
                {
                    "log"
                },
                Name = "Log files"
            });

            DialogResult result = dlgSave.ShowDialog(this);

            if (result != DialogResult.Ok)
            {
                return;
            }

            try
            {
                var logFs = new FileStream(dlgSave.FileName, FileMode.Create, FileAccess.ReadWrite);
                var logSw = new StreamWriter(logFs);

                logSw.WriteLine("Log saved at {0}", DateTime.Now);

                PlatformID platId  = DetectOS.GetRealPlatformID();
                string     platVer = DetectOS.GetVersion();

                var assemblyVersion =
                    Attribute.GetCustomAttribute(typeof(AaruConsole).Assembly,
                                                 typeof(AssemblyInformationalVersionAttribute)) as
                    AssemblyInformationalVersionAttribute;

                logSw.WriteLine("################# System information #################");

                logSw.WriteLine("{0} {1} ({2}-bit)", DetectOS.GetPlatformName(platId, platVer), platVer,
                                Environment.Is64BitOperatingSystem ? 64 : 32);

                if (DetectOS.IsMono)
                {
                    logSw.WriteLine("Mono {0}", Version.GetMonoVersion());
                }
                else if (DetectOS.IsNetCore)
                {
                    logSw.WriteLine(".NET Core {0}", Version.GetNetCoreVersion());
                }
                else
                {
                    logSw.WriteLine(RuntimeInformation.FrameworkDescription);
                }

                logSw.WriteLine();

                logSw.WriteLine("################# Program information ################");
                logSw.WriteLine("Aaru {0}", assemblyVersion?.InformationalVersion);
                logSw.WriteLine("Running in {0}-bit", Environment.Is64BitProcess ? 64 : 32);
                logSw.WriteLine("Running GUI mode using {0}", Application.Instance.Platform.ID);
            #if DEBUG
                logSw.WriteLine("DEBUG version");
            #endif
                logSw.WriteLine("Command line: {0}", Environment.CommandLine);
                logSw.WriteLine();

                logSw.WriteLine("################# Console ################");

                foreach (LogEntry entry in ConsoleHandler.Entries)
                {
                    if (entry.Type != "Info")
                    {
                        logSw.WriteLine("{0}: ({1}) {2}", entry.Timestamp, entry.Type.ToLower(), entry.Message);
                    }
                    else
                    {
                        logSw.WriteLine("{0}: {1}", entry.Timestamp, entry.Message);
                    }
                }

                logSw.Close();
                logFs.Close();
            }
            catch (Exception exception)
            {
                MessageBox.Show("Exception {0} trying to save logfile, details has been sent to console.",
                                exception.Message);

                AaruConsole.ErrorWriteLine("Console", exception.Message);
                AaruConsole.ErrorWriteLine("Console", exception.StackTrace);
            }
        }