Ejemplo n.º 1
0
        /// <summary>
        /// Gets a detailed information about the computer configuration.
        /// </summary>
        public static ComputerConfiguration GetComputerConfiguration()
        {
            var os = GetOperatingSystem();
            var processors = GetProcessors();
            var memoryBanks = GetMemory();
            var storages = GetStorageDevices();

            ComputerConfiguration configuration = new ComputerConfiguration();
            configuration.OperatingSystem = os;
            configuration.Processors = processors;
            configuration.MemoryModules = memoryBanks;
            configuration.StorageDevices = storages;

            return configuration;
        }
Ejemplo n.º 2
0
        public static JsonObjectCollection ConvertToJson(ComputerConfiguration configuration)
        {
            var jsonOS             = ConvertToJson(configuration.OperatingSystem);
            var jsonProcessors     = ConvertToJson(configuration.Processors);
            var jsonMemoryModules  = ConvertToJson(configuration.MemoryModules);
            var jsonStorageDevices = ConvertToJson(configuration.StorageDevices);

            JsonObjectCollection jsonConfiguration = new JsonObjectCollection("ComputerConfiguration");

            jsonConfiguration.Add(jsonOS);
            jsonConfiguration.Add(jsonProcessors);
            jsonConfiguration.Add(jsonMemoryModules);
            jsonConfiguration.Add(jsonStorageDevices);

            return(jsonConfiguration);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets a detailed information about the computer configuration.
        /// </summary>
        public static ComputerConfiguration GetComputerConfiguration()
        {
            var os          = GetOperatingSystem();
            var processors  = GetProcessors();
            var memoryBanks = GetMemory();
            var storages    = GetStorageDevices();

            ComputerConfiguration configuration = new ComputerConfiguration();

            configuration.OperatingSystem = os;
            configuration.Processors      = processors;
            configuration.MemoryModules   = memoryBanks;
            configuration.StorageDevices  = storages;

            return(configuration);
        }
Ejemplo n.º 4
0
        private void PopulateHardwareInfo()
        {
            Configuration = SystemUtils.GetComputerConfiguration();

            OperatingSystemInfo      operatingSystem = Configuration.OperatingSystem;
            List <CpuInfo>           processors      = Configuration.Processors;
            List <RamInfo>           memory          = Configuration.MemoryModules;
            List <StorageDeviceInfo> storage         = Configuration.StorageDevices;

            // OS
            txtBoxOsName.Text = operatingSystem.Name;
            txtBoxOsType.Text = operatingSystem.Is64bit ? "64 bit" : "32 bit";

            // CPU
            CpuInfo cpu = processors.First();

            txtBoxCpuName.Text      = cpu.Name;
            txtBoxCpuFrequency.Text = String.Format("{0} MHz", cpu.MaxClockSpeed);
            txtBoxCpuThreads.Text   = cpu.Threads.ToString();
            txtBoxCpuCount.Text     = processors.Count.ToString();

            // RAM
            RamInfo ram = memory.First();

            int capacity = 0;

            foreach (var bank in memory)
            {
                capacity += bank.Capacity;
            }

            txtBoxMemoryCapacity.Text  = String.Format("{0} GB", capacity);
            txtBoxMemoryType.Text      = ram.MemoryType.ToString();
            txtBoxMemoryFrequency.Text = String.Format("{0} MHz", ram.Speed);
            txtBoxMemoryBanks.Text     = memory.Count.ToString();

            // STORAGE
            string            benchmarkDataDirectoryRoot = Path.GetPathRoot(BenchmarkTests.First().Database.DataDirectory);
            StorageDeviceInfo dataDrive = storage.Find(drive => drive.DriveLetters.Contains(benchmarkDataDirectoryRoot.Trim('\\')));

            comboBoxStorageModel.Items.AddRange(storage.Select(device => device.Model).ToArray());
            int selectedIndex = comboBoxStorageModel.Items.IndexOf(dataDrive.Model);

            comboBoxStorageModel.SelectedIndex = selectedIndex;

            txtBoxHddSize.Text = String.Format("{0} GB", dataDrive.Size);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Exports the given data into a JSON file.
        /// </summary>
        public static void ExportToJson(string path, ComputerConfiguration configuration, List <BenchmarkTest> benchmarks, ReportType type)
        {
            List <JsonObjectCollection> collection = new List <JsonObjectCollection>();

            collection.Add(ConvertToJson(configuration));

            foreach (var benchmark in benchmarks)
            {
                collection.Add(ConvertToJson(benchmark, type));
            }

            using (FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write))
            {
                StreamWriter writer = new StreamWriter(stream);

                JsonObjectCollection json = new JsonObjectCollection(collection);
                json.WriteTo(writer);

                writer.Flush();
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Convert the data into a JSON format.
        /// </summary>
        public static JsonObjectCollection ConvertToJson(UserInfo user, ComputerConfiguration configuration, List<BenchmarkTest> benchmarks)
        {
            List<JsonObjectCollection> jsonData = new List<JsonObjectCollection>();

            // User.
            var jsonUser = ConvertToJson(user);
            jsonData.Add(jsonUser);

            // Computer configuration.
            var jsonComputer = ConvertToJson(configuration);
            jsonData.Add(jsonComputer);

            // Benchmark test.
            foreach (var benchmark in benchmarks)
            {
                var jsonTest = ConvertToJson(benchmark, ReportType.Detailed);
                jsonData.Add(jsonTest);
            }

            return new JsonObjectCollection(jsonData);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Convert the data into a JSON format.
        /// </summary>
        public static JsonObjectCollection ConvertToJson(UserInfo user, ComputerConfiguration configuration, List <BenchmarkTest> benchmarks)
        {
            List <JsonObjectCollection> jsonData = new List <JsonObjectCollection>();

            // User.
            var jsonUser = ConvertToJson(user);

            jsonData.Add(jsonUser);

            // Computer configuration.
            var jsonComputer = ConvertToJson(configuration);

            jsonData.Add(jsonComputer);

            // Benchmark test.
            foreach (var benchmark in benchmarks)
            {
                var jsonTest = ConvertToJson(benchmark, ReportType.Detailed);
                jsonData.Add(jsonTest);
            }

            return(new JsonObjectCollection(jsonData));
        }
Ejemplo n.º 8
0
        public static void Export(string file, Dictionary<TestMethod, StepFrame> frames, int flowCount, long recordCount, float randomness, ComputerConfiguration computerInfo, ReportType type)
        {
            var doc = new Document(PageSize.A4);

            if (File.Exists(file))
                File.Delete(file);

            var fileStream = new FileStream(file, FileMode.OpenOrCreate);
            PdfWriter.GetInstance(doc, fileStream);
            doc.Open();

            // Add header page.
            PdfPTable firstPageTable = new PdfPTable(1);
            firstPageTable.WidthPercentage = 100;

            PdfPCell title = new PdfPCell();
            title.VerticalAlignment = Element.ALIGN_MIDDLE;
            title.HorizontalAlignment = Element.ALIGN_CENTER;
            title.MinimumHeight = doc.PageSize.Height - (doc.BottomMargin + doc.TopMargin);
            title.AddElement(Image.GetInstance((System.Drawing.Image)DatabaseBenchmark.Properties.Resources.logo_01, Color.WHITE));

            firstPageTable.AddCell(title);
            doc.Add(firstPageTable);

            int chapterCount = 1;
            Font chapterFont = new Font(Font.TIMES_ROMAN, 16f, Font.TIMES_ROMAN, new Color(System.Drawing.Color.CornflowerBlue));

            Chapter benchamrkConfiguration = new Chapter(new Paragraph("Benchmark parameters.", chapterFont), chapterCount++);
            benchamrkConfiguration.Add(new Chunk("\n"));

            ExportTestSettings(benchamrkConfiguration, chapterFont, flowCount, recordCount, randomness);
            ExportComputerSpecification(benchamrkConfiguration, chapterFont, computerInfo);

            doc.Add(benchamrkConfiguration);

            foreach (var fr in frames)
            {
                StepFrame frame = fr.Value;
                List<BarChart> barCharts;

                if (type == ReportType.Summary)
                    barCharts = frame.GetSummaryBarCharts();
                else
                    barCharts = frame.GetAllBarCharts();

                string chapterTitle = fr.Key == TestMethod.SecondaryRead ? "Secondary read" : fr.Key.ToString();
                Chapter chapter = new Chapter(new Paragraph(chapterTitle, chapterFont), chapterCount++);
                chapter.Add(new Chunk("\n"));

                for (int i = 0; i < barCharts.Count; i++)
                {
                    Image image = Image.GetInstance(barCharts[i].ConvertToByteArray());
                    image.Alignment = Element.ALIGN_CENTER;

                    if (type == ReportType.Summary)
                        image.ScaleToFit(doc.PageSize.Width - 20, 271);
                    else
                        image.ScalePercent(100);

                    chapter.Add(image);
                }

                if (type == ReportType.Detailed)
                {
                    PdfPTable table = new PdfPTable(1);
                    table.WidthPercentage = 100;

                    AddCellToTable(table, "Average Speed:", frame.lineChartAverageSpeed.ConvertToByteArray);
                    AddCellToTable(table, "Moment Speed:", frame.lineChartMomentSpeed.ConvertToByteArray);
                    AddCellToTable(table, "Average Memory:", frame.lineChartMomentMemory.ConvertToByteArray);
                    //AddCellToTable(table, "Average CPU:", frame.lineChartAverageCPU.ConvertToByteArray);
                    //AddCellToTable(table, "Average I/O:", frame.lineChartAverageIO.ConvertToByteArray);

                    chapter.Add(table);
                }

                doc.Add(chapter);
            }

            doc.Close();

            foreach (var item in frames)
                item.Value.ResetColumnStyle();
        }
Ejemplo n.º 9
0
        public static void ExportComputerSpecification(Chapter chapter, Font font, ComputerConfiguration computerInfo)
        {
            Section sectionPC = chapter.AddSection(new Paragraph("Computer specification.", font));
            sectionPC.Add(new Chunk("\n"));

            Section osSection = sectionPC.AddSection(new Paragraph("Operating System.", font));
            string bits = computerInfo.OperatingSystem.Is64bit ? " 64bit" : "32bit";
            osSection.Add(new Paragraph(String.Format("\t \t {0} {1}", computerInfo.OperatingSystem.Name, bits)));

            sectionPC.Add(new Chunk("\n"));

            Section processor = sectionPC.AddSection(new Paragraph("Processors.", font));
            foreach (var pr in computerInfo.Processors)
            {
                processor.Add(new Paragraph(String.Format("\t \t Name: {0}", pr.Name)));
                processor.Add(new Paragraph(String.Format("\t \t Threads: {0}", pr.Threads)));
                processor.Add(new Paragraph(String.Format("\t \t Max clock speed: {0} MHz", pr.MaxClockSpeed)));
            }

            sectionPC.Add(new Chunk("\n"));

            Section memory = sectionPC.AddSection(new Paragraph("Memory modules.", font));
            PdfPTable table = new PdfPTable(3);

            table.AddCell(CreateHeaderPdfPCell("Type"));
            table.AddCell(CreateHeaderPdfPCell("Capacity (GB)"));
            table.AddCell(CreateHeaderPdfPCell("Speed (MHz)"));

            foreach (var mem in computerInfo.MemoryModules)
            {
                table.AddCell(new PdfPCell(new Phrase(mem.MemoryType.ToString())));
                table.AddCell(new PdfPCell(new Phrase(mem.Capacity.ToString())) { HorizontalAlignment = Element.ALIGN_RIGHT });
                table.AddCell(new PdfPCell(new Phrase(mem.Speed.ToString())) { HorizontalAlignment = Element.ALIGN_RIGHT });
            }

            memory.Add(new Chunk("\n"));
            memory.Add(table);

            sectionPC.Add(new Chunk("\n"));

            Section storage = sectionPC.AddSection(new Paragraph("Storages.", font));
            table = new PdfPTable(3);

            table.AddCell(CreateHeaderPdfPCell("Model"));
            table.AddCell(CreateHeaderPdfPCell("Size (GB)"));
            table.AddCell(CreateHeaderPdfPCell("Partitions"));

            foreach (var stor in computerInfo.StorageDevices)
            {
                table.AddCell(new PdfPCell(new Phrase(stor.Model)));
                table.AddCell(new PdfPCell(new Phrase(stor.Size.ToString())) { HorizontalAlignment = Element.ALIGN_RIGHT });
                table.AddCell(new PdfPCell(new Phrase(string.Join(",", stor.DriveLetters.Select(x => x.Replace(":", ""))))));
            }

            storage.Add(new Chunk("\n"));
            storage.Add(table);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Exports the given data into a JSON file.
        /// </summary>
        public static void ExportToJson(string path, ComputerConfiguration configuration, List<BenchmarkTest> benchmarks, ReportType type)
        {
            List<JsonObjectCollection> collection = new List<JsonObjectCollection>();

            collection.Add(ConvertToJson(configuration));

            foreach (var benchmark in benchmarks)
                collection.Add(ConvertToJson(benchmark, type));

            using (FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write))
            {
                StreamWriter writer = new StreamWriter(stream);

                JsonObjectCollection json = new JsonObjectCollection(collection);
                json.WriteTo(writer);

                writer.Flush();
            }
        }
Ejemplo n.º 11
0
        public static JsonObjectCollection ConvertToJson(ComputerConfiguration configuration)
        {
            var jsonOS = ConvertToJson(configuration.OperatingSystem);
            var jsonProcessors = ConvertToJson(configuration.Processors);
            var jsonMemoryModules = ConvertToJson(configuration.MemoryModules);
            var jsonStorageDevices = ConvertToJson(configuration.StorageDevices);

            JsonObjectCollection jsonConfiguration = new JsonObjectCollection("ComputerConfiguration");

            jsonConfiguration.Add(jsonOS);
            jsonConfiguration.Add(jsonProcessors);
            jsonConfiguration.Add(jsonMemoryModules);
            jsonConfiguration.Add(jsonStorageDevices);

            return jsonConfiguration;
        }
Ejemplo n.º 12
0
        public static void Export(string file, Dictionary <TestMethod, StepFrame> frames, int flowCount, long recordCount, float randomness, ComputerConfiguration computerInfo, ReportType type)
        {
            var doc = new Document(PageSize.A4);

            if (File.Exists(file))
            {
                File.Delete(file);
            }

            var fileStream = new FileStream(file, FileMode.OpenOrCreate);

            PdfWriter.GetInstance(doc, fileStream);
            doc.Open();

            // Add header page.
            PdfPTable firstPageTable = new PdfPTable(1);

            firstPageTable.WidthPercentage = 100;

            PdfPCell title = new PdfPCell();

            title.VerticalAlignment   = Element.ALIGN_MIDDLE;
            title.HorizontalAlignment = Element.ALIGN_CENTER;
            title.MinimumHeight       = doc.PageSize.Height - (doc.BottomMargin + doc.TopMargin);
            title.AddElement(Image.GetInstance((System.Drawing.Image)DatabaseBenchmark.Properties.Resources.logo_01, Color.WHITE));

            firstPageTable.AddCell(title);
            doc.Add(firstPageTable);

            int  chapterCount = 1;
            Font chapterFont  = new Font(Font.TIMES_ROMAN, 16f, Font.TIMES_ROMAN, new Color(System.Drawing.Color.CornflowerBlue));

            Chapter benchamrkConfiguration = new Chapter(new Paragraph("Benchmark parameters.", chapterFont), chapterCount++);

            benchamrkConfiguration.Add(new Chunk("\n"));

            ExportTestSettings(benchamrkConfiguration, chapterFont, flowCount, recordCount, randomness);
            ExportComputerSpecification(benchamrkConfiguration, chapterFont, computerInfo);

            doc.Add(benchamrkConfiguration);

            foreach (var fr in frames)
            {
                StepFrame       frame = fr.Value;
                List <BarChart> barCharts;

                if (type == ReportType.Summary)
                {
                    barCharts = frame.GetSummaryBarCharts();
                }
                else
                {
                    barCharts = frame.GetAllBarCharts();
                }

                string  chapterTitle = fr.Key == TestMethod.SecondaryRead ? "Secondary read" : fr.Key.ToString();
                Chapter chapter      = new Chapter(new Paragraph(chapterTitle, chapterFont), chapterCount++);
                chapter.Add(new Chunk("\n"));

                for (int i = 0; i < barCharts.Count; i++)
                {
                    Image image = Image.GetInstance(barCharts[i].ConvertToByteArray());
                    image.Alignment = Element.ALIGN_CENTER;

                    if (type == ReportType.Summary)
                    {
                        image.ScaleToFit(doc.PageSize.Width - 20, 271);
                    }
                    else
                    {
                        image.ScalePercent(100);
                    }

                    chapter.Add(image);
                }

                if (type == ReportType.Detailed)
                {
                    PdfPTable table = new PdfPTable(1);
                    table.WidthPercentage = 100;

                    AddCellToTable(table, "Average Speed:", frame.lineChartAverageSpeed.ConvertToByteArray);
                    AddCellToTable(table, "Moment Speed:", frame.lineChartMomentSpeed.ConvertToByteArray);
                    AddCellToTable(table, "Average Memory:", frame.lineChartMomentMemory.ConvertToByteArray);
                    //AddCellToTable(table, "Average CPU:", frame.lineChartAverageCPU.ConvertToByteArray);
                    //AddCellToTable(table, "Average I/O:", frame.lineChartAverageIO.ConvertToByteArray);

                    chapter.Add(table);
                }

                doc.Add(chapter);
            }

            doc.Close();

            foreach (var item in frames)
            {
                item.Value.ResetColumnStyle();
            }
        }
Ejemplo n.º 13
0
        public static void ExportComputerSpecification(Chapter chapter, Font font, ComputerConfiguration computerInfo)
        {
            Section sectionPC = chapter.AddSection(new Paragraph("Computer specification.", font));

            sectionPC.Add(new Chunk("\n"));

            Section osSection = sectionPC.AddSection(new Paragraph("Operating System.", font));
            string  bits      = computerInfo.OperatingSystem.Is64bit ? " 64bit" : "32bit";

            osSection.Add(new Paragraph(String.Format("\t \t {0} {1}", computerInfo.OperatingSystem.Name, bits)));

            sectionPC.Add(new Chunk("\n"));

            Section processor = sectionPC.AddSection(new Paragraph("Processors.", font));

            foreach (var pr in computerInfo.Processors)
            {
                processor.Add(new Paragraph(String.Format("\t \t Name: {0}", pr.Name)));
                processor.Add(new Paragraph(String.Format("\t \t Threads: {0}", pr.Threads)));
                processor.Add(new Paragraph(String.Format("\t \t Max clock speed: {0} MHz", pr.MaxClockSpeed)));
            }

            sectionPC.Add(new Chunk("\n"));

            Section   memory = sectionPC.AddSection(new Paragraph("Memory modules.", font));
            PdfPTable table  = new PdfPTable(3);

            table.AddCell(CreateHeaderPdfPCell("Type"));
            table.AddCell(CreateHeaderPdfPCell("Capacity (GB)"));
            table.AddCell(CreateHeaderPdfPCell("Speed (MHz)"));

            foreach (var mem in computerInfo.MemoryModules)
            {
                table.AddCell(new PdfPCell(new Phrase(mem.MemoryType.ToString())));
                table.AddCell(new PdfPCell(new Phrase(mem.Capacity.ToString()))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT
                });
                table.AddCell(new PdfPCell(new Phrase(mem.Speed.ToString()))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT
                });
            }

            memory.Add(new Chunk("\n"));
            memory.Add(table);

            sectionPC.Add(new Chunk("\n"));

            Section storage = sectionPC.AddSection(new Paragraph("Storages.", font));

            table = new PdfPTable(3);

            table.AddCell(CreateHeaderPdfPCell("Model"));
            table.AddCell(CreateHeaderPdfPCell("Size (GB)"));
            table.AddCell(CreateHeaderPdfPCell("Partitions"));

            foreach (var stor in computerInfo.StorageDevices)
            {
                table.AddCell(new PdfPCell(new Phrase(stor.Model)));
                table.AddCell(new PdfPCell(new Phrase(stor.Size.ToString()))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT
                });
                table.AddCell(new PdfPCell(new Phrase(string.Join(",", stor.DriveLetters.Select(x => x.Replace(":", ""))))));
            }

            storage.Add(new Chunk("\n"));
            storage.Add(table);
        }
Ejemplo n.º 14
0
        private void PopulateHardwareInfo()
        {
            Configuration = SystemUtils.GetComputerConfiguration();

            OperatingSystemInfo operatingSystem = Configuration.OperatingSystem;
            List<CpuInfo> processors = Configuration.Processors;
            List<RamInfo> memory = Configuration.MemoryModules;
            List<StorageDeviceInfo> storage = Configuration.StorageDevices;

            // OS
            txtBoxOsName.Text = operatingSystem.Name;
            txtBoxOsType.Text = operatingSystem.Is64bit ? "64 bit" : "32 bit";

            // CPU
            CpuInfo cpu = processors.First();
            txtBoxCpuName.Text = cpu.Name;
            txtBoxCpuFrequency.Text = String.Format("{0} MHz", cpu.MaxClockSpeed);
            txtBoxCpuThreads.Text = cpu.Threads.ToString();
            txtBoxCpuCount.Text = processors.Count.ToString();

            // RAM
            RamInfo ram = memory.First();

            int capacity = 0;
            foreach (var bank in memory)
                capacity += bank.Capacity;

            txtBoxMemoryCapacity.Text = String.Format("{0} GB", capacity);
            txtBoxMemoryType.Text = ram.MemoryType.ToString();
            txtBoxMemoryFrequency.Text = String.Format("{0} MHz", ram.Speed);
            txtBoxMemoryBanks.Text = memory.Count.ToString();

            // TODO: Fix this.
            // STORAGE
            //string benchmarkDataDirectoryRoot = Path.GetPathRoot(BenchmarkSessions.First().Database.DataDirectory);
            //StorageDeviceInfo dataDrive = storage.Find(drive => drive.DriveLetters.Contains(benchmarkDataDirectoryRoot.Trim('\\')));

            //comboBoxStorageModel.Items.AddRange(storage.Select(device => device.Model).ToArray());
            //int selectedIndex = comboBoxStorageModel.Items.IndexOf(dataDrive.Model);
            //comboBoxStorageModel.SelectedIndex = selectedIndex;

            //txtBoxHddSize.Text = String.Format("{0} GB", dataDrive.Size);
        }
Ejemplo n.º 15
0
        public static void ExportComputerConfiguration(StreamWriter writer, ComputerConfiguration computerInfo)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("Computer specification:");
            builder.AppendLine("Operating system:;;;Processors:;;;;Memory modules:;;;;Storages:");
            builder.AppendLine("Name;Is64Bit;;Name;Threads;Max clock speed (MHz);;Type;Capacity (GB);Speed (MHz);;Model;Size (GB);Partitions;");

            builder.Append(computerInfo.OperatingSystem.Name + ";");
            builder.Append(computerInfo.OperatingSystem.Is64bit + ";;");

            CpuInfo firstProcessor = computerInfo.Processors.First();

            builder.Append(firstProcessor.Name + ";");
            builder.Append(firstProcessor.Threads + ";");
            builder.Append(firstProcessor.MaxClockSpeed + ";;");

            RamInfo firstRam = computerInfo.MemoryModules.First();

            builder.Append(firstRam.MemoryType + ";");
            builder.Append(firstRam.Capacity + ";");
            builder.Append(firstRam.Speed + ";;");

            StorageDeviceInfo firstStorage = computerInfo.StorageDevices.First();

            builder.Append(firstStorage.Model + ";");
            builder.Append(firstStorage.Size + ";");
            firstStorage.DriveLetters.ForEach(x => builder.Append(x.Replace(":", "")));

            builder.Append(Environment.NewLine);

            int count = Math.Max(Math.Max(computerInfo.Processors.Count, computerInfo.MemoryModules.Count), computerInfo.StorageDevices.Count);

            for (int i = 1; i < count; i++)
            {
                builder.Append(";;;");

                if (computerInfo.Processors.Count <= i)
                {
                    builder.Append(";;;;");
                }
                else
                {
                    CpuInfo info = computerInfo.Processors[i];

                    builder.Append(info.Name + ";");
                    builder.Append(info.Threads + ";");
                    builder.Append(info.MaxClockSpeed + ";;");
                }

                if (computerInfo.MemoryModules.Count <= i)
                {
                    builder.Append(";;;;");
                }
                else
                {
                    RamInfo info = computerInfo.MemoryModules[i];

                    builder.Append(firstRam.MemoryType + ";");
                    builder.Append(firstRam.Capacity + ";");
                    builder.Append(firstRam.Speed + ";;");
                }

                if (computerInfo.StorageDevices.Count <= i)
                {
                    builder.Append(";;;;");
                }
                else
                {
                    StorageDeviceInfo info = computerInfo.StorageDevices[i];
                    builder.Append(info.Model + ";");
                    builder.Append(info.Size + ";");
                    info.DriveLetters.ForEach(x => builder.Append(x));
                }
            }

            writer.WriteLine(builder.ToString());
        }
Ejemplo n.º 16
0
        public static void ExportComputerConfiguration(StreamWriter writer, ComputerConfiguration computerInfo)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("Computer specification:");
            builder.AppendLine("Operating system:;;;Processors:;;;;Memory modules:;;;;Storages:");
            builder.AppendLine("Name;Is64Bit;;Name;Threads;Max clock speed (MHz);;Type;Capacity (GB);Speed (MHz);;Model;Size (GB);Partitions;");

            builder.Append(computerInfo.OperatingSystem.Name + ";");
            builder.Append(computerInfo.OperatingSystem.Is64bit + ";;");

            CpuInfo firstProcessor = computerInfo.Processors.First();
            builder.Append(firstProcessor.Name + ";");
            builder.Append(firstProcessor.Threads + ";");
            builder.Append(firstProcessor.MaxClockSpeed + ";;");

            RamInfo firstRam = computerInfo.MemoryModules.First();
            builder.Append(firstRam.MemoryType + ";");
            builder.Append(firstRam.Capacity + ";");
            builder.Append(firstRam.Speed + ";;");

            StorageDeviceInfo firstStorage = computerInfo.StorageDevices.First();
            builder.Append(firstStorage.Model + ";");
            builder.Append(firstStorage.Size + ";");
            firstStorage.DriveLetters.ForEach(x => builder.Append(x.Replace(":", "")));

            builder.Append(Environment.NewLine);

            int count = Math.Max(Math.Max(computerInfo.Processors.Count, computerInfo.MemoryModules.Count), computerInfo.StorageDevices.Count);

            for (int i = 1; i < count; i++)
            {
                builder.Append(";;;");

                if (computerInfo.Processors.Count <= i)
                    builder.Append(";;;;");
                else
                {
                    CpuInfo info = computerInfo.Processors[i];

                    builder.Append(info.Name + ";");
                    builder.Append(info.Threads + ";");
                    builder.Append(info.MaxClockSpeed + ";;");
                }

                if (computerInfo.MemoryModules.Count <= i)
                    builder.Append(";;;;");
                else
                {
                    RamInfo info = computerInfo.MemoryModules[i];

                    builder.Append(firstRam.MemoryType + ";");
                    builder.Append(firstRam.Capacity + ";");
                    builder.Append(firstRam.Speed + ";;");
                }

                if (computerInfo.StorageDevices.Count <= i)
                    builder.Append(";;;;");
                else
                {
                    StorageDeviceInfo info = computerInfo.StorageDevices[i];
                    builder.Append(info.Model + ";");
                    builder.Append(info.Size + ";");
                    info.DriveLetters.ForEach(x => builder.Append(x));
                }
            }

            writer.WriteLine(builder.ToString());
        }