Ejemplo n.º 1
0
 public Computer(string hostName, string description, CPU cpu, RAM ram, HDD hdd)
 {
     HostName = hostName;
     Description = description;
     this.Cpu =cpu;
     this.Ram = ram;
     this.Hdd = hdd;
 }
Ejemplo n.º 2
0
 public Computer DeepClone()
 {
     Computer other = (Computer) this.MemberwiseClone();
     HostName = other.HostName;
     Description = other.Description;
     Cpu = other.Cpu.Clone() as CPU;
     Ram = other.Ram.Clone() as RAM;
     Hdd = other.Hdd.Clone() as HDD;
     return other;
 }
 public async Task <IEnumerable <HDD> > PutHDD(int id, [FromBody] HDD value)
 {
     if (User.Identity.IsAuthenticated)
     {
         value.ID = id;
         return(await _componentService.ReplaceHDD(new UpdateHDDRequest(value)));
     }
     else
     {
         throw new UnauthorizedAccessException("Only admin can make changes. Have a nice day and f**k off ;)");
     }
 }
Ejemplo n.º 4
0
        public static void TotalMemory()
        {
            Storage[] storage = new Storage[3];
            storage[0] = new Flash("Флэшка", "3.0", 200, 8);
            storage[1] = new DVD("DVD", "5/1", 400, Model.Type.oneside);
            storage[2] = new HDD("HDD", "6/4", 800, 10, 300, 15);
            double sum = 0;

            for (int i = 0; i < 3; i++)
            {
                sum += storage[i].GetMemory();
            }
            Console.WriteLine("Общее количество памяти всех устройств = {0}", sum);
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            HDD       hdd       = new HDD("BarraCuda", "Seagate", 0.256, 7200);
            Videocard videocard = new Videocard("GTX 1080 Ti", "NVIDIA", false, 8);
            CPU       cpu       = new CPU("I7-7500U", 4, 2.7, CPU.CPUType.INTEL);
            RAM       ram       = new RAM("Crucial", "Ballistix", 16, 3200);

            Computer computer = new Computer(hdd, cpu, ram, videocard);

            //computer.Viewer = new OldViewer();      // By default
            computer.Viewer = new NormalViewer();
            computer.Viewer = new GamingViewer();
            computer.ShowInfo();
        }
Ejemplo n.º 6
0
 public DesktopPC(Case pcCase, Cooler cooler, CPU cpu, GPU gpu, HDD hdd, Keyboard keyboard, Monitor monitor, MotherBoard motherBoard, Mouse mouse, PSU psu, RAM ram)
 {
     Case        = pcCase;
     Cooler      = cooler;
     CPU         = cpu;
     GPU         = gpu;
     HDD         = hdd;
     Keyboard    = keyboard;
     Monitor     = monitor;
     MotherBoard = motherBoard;
     Mouse       = mouse;
     PSU         = psu;
     RAM         = ram;
 }
Ejemplo n.º 7
0
 private void CreateHDD(int hDDCount)
 {
     for (int i = 0; i < hDDCount; i++)
     {
         HDD disk = new HDD();
         disk.manufacturer   = "Disk" + i;
         disk.title          = "NewDisk" + i;
         disk.price          = _ran.Next(250, 400);
         disk.id_number      = _ran.Next(1, 25324);
         disk.stock_amount   = _ran.Next(15);
         disk.capacity       = _ran.Next(250, 750);
         disk.rotation_speed = _ran.Next(2400, 20000);
         _products.Add(disk);
     }
 }
Ejemplo n.º 8
0
        public ListViewItem GetListViewItem()
        {
            var listItem = new ListViewItem(Code);

            listItem.SubItems.Add(new ListViewItem.ListViewSubItem(listItem, Manufacturer));
            listItem.SubItems.Add(new ListViewItem.ListViewSubItem(listItem, Proc));
            listItem.SubItems.Add(new ListViewItem.ListViewSubItem(listItem, Freq.ToString()));
            listItem.SubItems.Add(new ListViewItem.ListViewSubItem(listItem, Mem.ToString()));
            listItem.SubItems.Add(new ListViewItem.ListViewSubItem(listItem, HDD.ToString()));
            listItem.SubItems.Add(new ListViewItem.ListViewSubItem(listItem, Video.ToString()));
            listItem.SubItems.Add(new ListViewItem.ListViewSubItem(listItem, Price.ToString()));
            listItem.SubItems.Add(new ListViewItem.ListViewSubItem(listItem, Count.ToString()));
            listItem.SubItems.Add(new ListViewItem.ListViewSubItem(listItem, Proc));
            return(listItem);
        }
        private bool IsFreeSpaceInstallation(Collection <ListBoxObject> collection, HDD hdd, string problem_report)
        {
            bool isValid = false;

            if (GetCount(collection, "case") == 0 ||
                GetCount(collection, hdd.GetTypeValue()) < ((GetSingleItem(collection, "case") as Case).GetCountCompatiblePlaces(hdd.Properties.FormFactor)))
            {
                isValid = true;
            }
            else
            {
                ProblemReport(problem_report);
            }
            return(isValid);
        }
Ejemplo n.º 10
0
        public XElement GetXElement()
        {
            var element = new XElement("PC");

            element.SetAttributeValue("Code", Code);
            element.SetAttributeValue("Manufacturer", Manufacturer);
            element.SetAttributeValue("Proc", Proc);
            element.SetAttributeValue("Freq", Freq.ToString());
            element.SetAttributeValue("Mem", Mem.ToString());
            element.SetAttributeValue("HDD", HDD.ToString());
            element.SetAttributeValue("Video", Video.ToString());
            element.SetAttributeValue("Price", Price);
            element.SetAttributeValue("Count", Count);
            return(element);
        }
Ejemplo n.º 11
0
        public static void TimeCount()
        {
            Storage[] storage = new Storage[3];
            storage[0] = new Flash("Флэшка", "3.0", 200, 8);
            storage[1] = new DVD("DVD", "5/1", 400, Model.Type.oneside);
            storage[2] = new HDD("HDD", "6/4", 800, 10, 300, 15);
            Stopwatch sw = Stopwatch.StartNew();

            for (int i = 0; i < 1; i++)
            {
                storage[i].CopyInfo();
                Console.WriteLine("Итого времени на копирование по всем устройствам: {0} секунд", sw.ElapsedMilliseconds / 1000);
            }
            sw.Stop();
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            float fcpu = CPU.NextValue();
            float fram = Ram.NextValue();
            float hdd  = HDD.NextValue();

            bunifuCircleProgressbar1.Value = (int)fcpu;
            bunifuCustomLabel3.Text        = "CPU" + " " + fcpu.ToString() + " " + "%";

            bunifuCircleProgressbar2.Value = (int)fram;
            bunifuCustomLabel5.Text        = "Boş Ram Alanı : " + " " + fram.ToString() + " " + "MB";

            bunifuCircleProgressbar4.Value = (int)hdd;
            bunifuCustomLabel6.Text        = "HDD Kullanımı :" + " " + hdd.ToString() + " " + "%";
        }
Ejemplo n.º 13
0
        public HWID()
        {
            BIOS = GetWMIIdent("Win32_BIOS", "Manufacturer", "SMBIOSBIOSVersion", "IdentificationCode");
            CPU  = GetWMIIdent("Win32_Processor", "ProcessorId", "UniqueId", "Name");
            HDD  = GetWMIIdent("Win32_DiskDrive", "Model", "TotalHeads");
            GPU  = GetWMIIdent("Win32_VideoController", "DriverVersion", "Name");
            MAC  = GetWMIIdent("Win32_NetworkAdapterConfiguration", "MACAddress");
            OS   = GetWMIIdent("Win32_OperatingSystem", "SerialNumber", "Name");
            SCSI = GetWMIIdent("Win32_SCSIController", "DeviceID", "Name");

            // checking if system is a server. scsi indicates a server system
            IsServer = HDD.Contains("SCSI");

            HardwareID = Build();
        }
Ejemplo n.º 14
0
        public void ShowComputerSpecs()
        {
            StringBuilder manufAndModel = new StringBuilder();

            manufAndModel.Append(Manufacturer);
            manufAndModel.Append(" ");
            manufAndModel.Append(Model);
            manufAndModel.Append(" Specs:");
            Console.WriteLine(manufAndModel);
            CPU.ToString();
            GPU.ToString();
            HDD.ToString();
            Monitor.ToString();
            MotherBoard.ToString();
            RAM.ToString();
        }
Ejemplo n.º 15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="element">Element to be added</param>
        public AddHddRequest(HDD element)
        {
            _element = element;

            _parameters = new List <SqlParameter>
            {
                new SqlParameter("@series", _element.Series)
            };

            if (Validate <string>(_element.Title, "element.Title"))
            {
                _parameters.Add(new SqlParameter("@title", _element.Title));
            }

            if (Validate <string>(_element.Company, "element.Company"))
            {
                _parameters.Add(new SqlParameter("@company", _element.Company));
            }

            if (Validate <string>(_element.Formfactor, "element.Formfactor"))
            {
                _parameters.Add(new SqlParameter("@formfactor", _element.Formfactor));
            }

            if (Validate <int>(_element.Capacity, "element.Capacity"))
            {
                _parameters.Add(new SqlParameter("@volume", _element.Capacity));
            }

            if (Validate <int>(_element.BufferVolume, "element.BufferVolume"))
            {
                _parameters.Add(new SqlParameter("@buffer", _element.BufferVolume));
            }

            if (Validate <int>(_element.Speed, "element.Speed"))
            {
                _parameters.Add(new SqlParameter("@speed", _element.Speed));
            }

            for (int i = 0; i < _element.Interface.Count; i++)
            {
                Expression += $"INSERT INTO HDD_INTERFACE VALUES (SELECT TOP 1 ID FROM HDD WHERE TITLE = @title, @interface{i});";
                _parameters.Add(new SqlParameter($"@interface{i}", _element.Interface[i]));
            }
        }
Ejemplo n.º 16
0
    public Computer build()
    {
        Computer pc = new Computer();

        ComputerCase pc_case       = new ComputerCase("NZXT");
        HDD          hard_drive    = new HDD("1TB");
        Fans         silent_fan    = new Fans(1000);
        CPU          cpu           = new CPU("Intel Pentium");
        GPU          graphics_card = new GPU("GT1030");

        pc.component.Add(pc_case);
        pc.component.Add(hard_drive);
        pc.component.Add(silent_fan);
        pc.component.Add(cpu);
        pc.component.Add(graphics_card);

        return(pc);
    }
        private bool IsFreeSlotsInstallation(Collection <ListBoxObject> collection, HDD hdd, string problem_report)
        {
            bool isValid          = false;
            int  count_interfaces = 0;

            for (int i = 0; i > (collection.Where(m => m.Item.GetTypeValue() == "optical_drive" || m.Item.GetTypeValue() == "hdd").Count()); i++)
            {
                if (collection[i].Item.Type == "optical_drive")
                {
                    OpticalDrive od = collection[i].IObject as OpticalDrive;
                    if ((hdd.Properties.Interface == HDDInterface.sata_20 || hdd.Properties.Interface == HDDInterface.sata_30) &&
                        od.Properties.Interface == OpticalDriveInterface.SATA)
                    {
                        count_interfaces++;
                    }
                    else if (hdd.Properties.Interface == HDDInterface.IDE && od.Properties.Interface == OpticalDriveInterface.IDE)
                    {
                        count_interfaces++;
                    }
                }
                else if (collection[i].Item.Type == "hdd")
                {
                    HDD lhdd = collection[i].IObject as HDD;
                    if ((hdd.Properties.Interface == HDDInterface.sata_20 || hdd.Properties.Interface == HDDInterface.sata_30) &&
                        (lhdd.Properties.Interface == HDDInterface.sata_20 || lhdd.Properties.Interface == HDDInterface.sata_30))
                    {
                        count_interfaces++;
                    }
                    else if (hdd.Properties.Interface == HDDInterface.IDE && lhdd.Properties.Interface == HDDInterface.IDE)
                    {
                        count_interfaces++;
                    }
                }
            }
            if (count_interfaces < hdd.Compatibility((GetSingleItem(collection, "motherboard") as Motherboard).Properties))
            {
                isValid = true;
            }
            if (!isValid)
            {
                ProblemReport(problem_report);
            }
            return(isValid);
        }
Ejemplo n.º 18
0
        public static void Main(string[] args)
        {
            //Inode i = new Inode();
            Inode f = new Inode(1);
            //f.SetArrayBlock(0, 3);
            int i = f.GetArrayBlock(0);

            byte[] b = new byte ["fooooooo".Length];
            HDD.Read(ref b, SuperBlock.BlockSize * i + SuperBlock.BlockStart);

            while (!HDD.isNullReadHandler())
            {
                ;
            }
            string s = System.Text.Encoding.ASCII.GetString(b);

            Console.WriteLine(s);
            // HDD.Write(b, SuperBlock.BlockSize * 3 + SuperBlock.BlockStart);
        }
Ejemplo n.º 19
0
        public IActionResult Create(HDDViewModel model)
        {
            if (ModelState.IsValid)
            {
                var helper = new ImageHelper(_webHostEnvironment);
                var image  = helper.GetUploadedFile(model.Image, "HDD");
                var hdd    = new HDD()
                {
                    Name = model.Name,
                    OuterMemoryInterfaceId  = model.OuterMemoryInterfaceId,
                    MemorySize              = model.MemorySize,
                    Description             = model.Description,
                    OuterMemoryFormFactorId = model.OuterMemoryFormFactorId,
                    BufferSize              = model.BufferSize,
                    DataTransferSpeed       = model.DataTransferSpeed,
                    ManufacturerId          = model.ManufacturerId,
                    Price = model.Price,
                    Image = image
                };

                var result = _hddService.CreateHDD(hdd);

                model.Id    = hdd.Id;
                model.Image = null;

                if (result.Succedeed)
                {
                    return(View("../Catalog/Index", new { startView = "HDD" }));
                }

                return(NotFound(result));
            }
            var outerMemoryInterfaces = _outerMemoryInterfaceService.GetOuterMemoryInterfaces();

            ViewBag.OuterMemoryInterfaces = new SelectList(outerMemoryInterfaces, "Id", "Name");
            var outerMemoryFormFactors = _outerMemoryFormFactorService.GetOuterMemoryFormFactors();

            ViewBag.OuterMemoryFormFactors = new SelectList(outerMemoryFormFactors, "Id", "Name");
            var manufacturers = _manufacturerService.GetManufacturers();

            ViewBag.Manufacturers = new SelectList(manufacturers, "Id", "Name");
            return(View(model));
        }
Ejemplo n.º 20
0
        public override string ToString()
        {
            var           itemToString = string.Empty;
            StringBuilder sb           = new StringBuilder();

            sb.Append("Desktop PC Specs:");
            sb.Append(string.Format("\t {0}", Case.ToString()));
            sb.Append(string.Format("\t {0}", Cooler.ToString()));
            sb.Append(string.Format("\t {0}", CPU.ToString()));
            sb.Append(string.Format("\t {0}", GPU.ToString()));
            sb.Append(string.Format("\t {0}", HDD.ToString()));
            sb.Append(string.Format("\t {0}", Keyboard.ToString()));
            sb.Append(string.Format("\t {0}", Monitor.ToString()));
            sb.Append(string.Format("\t {0}", MotherBoard.ToString()));
            sb.Append(string.Format("\t {0}", Mouse.ToString()));
            sb.Append(string.Format("\t {0}", PSU.ToString()));
            sb.Append(string.Format("\t {0}", RAM.ToString()));
            itemToString = sb.ToString();
            return(itemToString);
        }
Ejemplo n.º 21
0
 public ActionResult HDDEdit([Bind(Include = "ProductId,TypeID,Manufacturer,Name,Price,Speed,Capacity,Description,Image")] HDDViewModel product, HttpPostedFileBase uploadImage)
 {
     if (product.Price < 1)
     {
         ModelState.AddModelError(string.Empty, "Цена не может быть негативной");
     }
     if (ModelState.IsValid)
     {
         byte[] imageData = null;
         if (uploadImage != null)
         {
             using (var binaryReader = new BinaryReader(uploadImage.InputStream))
             {
                 imageData     = binaryReader.ReadBytes(uploadImage.ContentLength);
                 product.Image = imageData;
             }
         }
         Product newP = new Product
         {
             ProductId    = product.ProductId,
             Manufacturer = product.Manufacturer,
             Name         = product.Name,
             Price        = product.Price,
             TypeID       = product.TypeID,
             Image        = product.Image,
             Description  = product.Description
         };
         HDD newH = new HDD
         {
             ProductId = product.ProductId,
             Capacity  = product.Capacity,
             Speed     = product.Speed
         };
         db.Entry(newP).State = EntityState.Modified;
         db.SaveChanges();
         db.Entry(newH).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(product));
 }
Ejemplo n.º 22
0
    //void renderInfoPane(float left, float top, float width, float height
    Motherboard fabricateDebugRig()
    {
        Motherboard returnMobo = new Motherboard();

        returnMobo.name = "Mother of All Boards";

        CPU         debugCPU        = new CPU           ("Hammond DebugHammer 750XL",           Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 30, 0, 1, 6, 32);
        GPU         debugGPU        = new GPU           ("Zhu Industries Mothra 8800",          Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 20, 0, 3, 1);
        HDD         debugHDD        = new HDD           ("DataPlatter Stack 5",                 Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 2, 0, 10, 8);
        RAM         debugRAM        = new RAM           ("RYAM Interceptor 1 MB",               Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 1, 0, 1, 10, 1);
        PowerSupply debugPower      = new PowerSupply   ("ArEmEs 200W Power Supply",            Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 0, 0, 200);
        CompInput   debugInput      = new CompInput     ("Cobra Katana",                        Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 0, 0, 50, 60, false);
        CompOutput  debugOutput     = new CompOutput    ("AudiVisual AV2350",                   Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 0, 0, 320, 30, 5);
        CompNetwork debugNet        = new CompNetwork   ("Digiline Dial-up Package",            Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 0, 0, NetworkType.DIALUP, 40, 4);
        Chassis     debugChassis    = new Chassis       ("CompuTech Tower of Power",            Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 0, 0, 10);

        GPU         badGPU          = new GPU           ("Bad GPU",                             Company.COMPUTECH, 125.0f, "Pudding Cup Interface", 20, 0, 3, 1);

        returnMobo.CPUInterface         = DEBUG_INTERFACE;
        returnMobo.GPUInterface         = DEBUG_INTERFACE;
        returnMobo.HDDInterface         = DEBUG_INTERFACE;
        returnMobo.RAMInterface         = DEBUG_INTERFACE;
        returnMobo.powerInterface       = DEBUG_INTERFACE;
        returnMobo.compInputInterface   = DEBUG_INTERFACE;
        returnMobo.compOutputInterface  = DEBUG_INTERFACE;
        returnMobo.networkInterface     = DEBUG_INTERFACE;
        returnMobo.formFactor           = DEBUG_INTERFACE;

        returnMobo.plugIn(debugCPU);
        returnMobo.plugIn(debugGPU);
        returnMobo.plugIn(debugHDD);
        returnMobo.plugIn(debugRAM);
        returnMobo.plugIn(debugInput);
        returnMobo.plugIn(debugOutput);
        returnMobo.plugIn(debugNet);
        returnMobo.plugIn(debugPower);
        returnMobo.plugIn(debugChassis);

        return returnMobo;
    }
Ejemplo n.º 23
0
        public static void Main(string[] args)
        {
            Clock.SetTimer();
            int intValue = 82;

            byte[] intValueOnByteArray = BitConverter.GetBytes(intValue);

            HDD.Write(intValueOnByteArray, 25);

            intValue = 19;
            //intValueOnByteArray = BitConverter.GetBytes(intValue);
            //HDD.Write(intValueOnByteArray, 24);


            byte[] h = new byte[40];

            byte[] stringOnBytes;

            string s = "hes1a ";

            for (int i = 0; i < s.Length; i++)
            {
                stringOnBytes = BitConverter.GetBytes(s[i]);
                HDD.Write(stringOnBytes, i);
            }

            HDD.Read(ref h, 0, 40);



            while (!HDD.isNullReadHandler())
            {
                ;
            }
            for (int i = 0; i < h.Length; i++)
            {
                Console.Write(i); Console.WriteLine("  " + h[i]);
            }
        }
Ejemplo n.º 24
0
        public static void StartCopy()
        {
            Storage[] storage = new Storage[3];
            storage[0] = new Flash("Флэшка", "3.0", 200, 8);
            storage[1] = new DVD("DVD", "5/1", 400, Model.Type.oneside);
            storage[2] = new HDD("HDD", "6/4", 800, 10, 300, 15);
again:
            Console.WriteLine("Выберите для какого устройства начать копирование: (1-Флэшка, 2-DVD, 3-HDD)");
            int ch = int.Parse(Console.ReadLine());

            switch (ch)
            {
            case 1:
            {
                storage[0].CopyInfo();
            }
            break;

            case 2:
            {
                storage[1].CopyInfo();
            }
            break;

            case 3:
            {
                storage[2].CopyInfo();
            }
            break;

            default:
            {
                Console.WriteLine("Неверно выбрано устройство.");
                goto again;
            }
            break;
            }
        }
Ejemplo n.º 25
0
        private List <HDD> setAllHDD()
        {
            List <HDD> hddList = new List <HDD>(6);
            DataTable  dtbl    = initializeDataTable("SELECT * FROM HDD");

            foreach (DataRow row in dtbl.Rows)
            {
                HDD h = new HDD
                {
                    ID         = Convert.ToInt32(row[0]),
                    Producator = Convert.ToString(row[1]),
                    Serie      = Convert.ToString(row[2]),
                    Interfata  = Convert.ToString(row[3]),
                    Capacitate = Convert.ToString(row[4]),
                    Buffer     = Convert.ToInt32(row[5]),
                    Viteza     = Convert.ToInt32(row[6]),
                    FormFactor = Convert.ToDouble(row[7]),
                    Pret       = Convert.ToDouble(row[8]),
                };
                hddList.Add(h);
            }
            return(hddList);
        }
Ejemplo n.º 26
0
        static void Main(string[] args)
        {
            //Flash s = new Flash("Fleshcard", "HP", 4000);
            //s.CopyDataToDevice(2000);
            //s.CopyDataToDevice(2002);
            //s.GetDeviceFullInfo();
            //s.GetInfoforDeviceFreeSpace();
            //DVD d = new DVD("DVD", "HP", classes.Type.oneSided);
            //Console.WriteLine(d.Name);
            //d.CopyDataToDevice(3000);
            //d.CopyDataToDevice(3000);
            //d.GetInfoforDeviceFreeSpace();
            //d.GetDeviceFullInfo();
            //HDD h = new HDD("HDD", "HP", 6, 100);
            //h.GetDeviceFullInfo();
            //h.CopyDataToDevice(700);
            //h.GetDeviceFullInfo();
            List <Storage> devices = new List <Storage>();
            Flash          s       = new Flash("Fleshcard", "HP", 4000);
            DVD            d       = new DVD("DVD", "HP", classes.Type.oneSided);
            DVD            d1      = new DVD("DVD-R", "Samsung", classes.Type.twoSided);
            HDD            h       = new HDD("HDD", "HP", 6, 200);

            devices.Add(s);
            devices.Add(d);
            devices.Add(d1);
            devices.Add(h);
            foreach (Storage item in devices)
            {
                item.GetDeviceFullInfo();
                Console.WriteLine();
                item.CopyDataToDevice(3000);
                Console.WriteLine();
                item.GetDeviceFullInfo();
                Console.WriteLine();
            }
        }
Ejemplo n.º 27
0
Archivo: Parts.cs Proyecto: rhyok/hue-r
    public bool plugIn(Part part)
    {
        bool returnValue = false;

        if (part.GetType() == typeof(CPU))
        {
            if (part.partInterface == CPUInterface)
            {
                this.cpu = (CPU) part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(GPU))
        {
            if (part.partInterface == GPUInterface)
            {
                this.gpu = (GPU)part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(HDD))
        {
            if (part.partInterface == HDDInterface)
            {
                this.hdd = (HDD)part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(RAM))
        {
            if (part.partInterface == RAMInterface)
            {
                this.ram = (RAM)part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(CompInput))
        {
            if (part.partInterface == compInputInterface)
            {
                this.input = (CompInput)part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(CompOutput))
        {
            if (part.partInterface == compOutputInterface)
            {
                this.output = (CompOutput)part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(CompNetwork))
        {
            if (part.partInterface == networkInterface)
            {
                this.network = (CompNetwork) part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(PowerSupply))
        {
            if (part.partInterface == powerInterface)
            {
                this.pSupply = (PowerSupply)part;
                returnValue = true;
            }
        }
        if (part.GetType() == typeof(Chassis))
        {
            if (part.partInterface == formFactor)
            {
                this.chassis = (Chassis)part;
                returnValue = true;
            }
        }

        return returnValue;
    }
Ejemplo n.º 28
0
    public object generatePart(Type partType, Company company)
    {
        object returnPart = null;
        if (partType == typeof(CPU))
        {
            /*
            CPU = new CPU(
                generatePartName(partType, company),
                companyToString(company),
                499.0f,
                "Generic Interface",
                100,
                1
                )
             * */

            returnPart = new CPU(generatePartName(partType, company),
                company,
                500.0f * (float)CPU[company] * (float)CPU[company],
                "Debug",
                100 * (int)((float)CPU[company] * 100.0f) / 100,
                1.0f,
                rand.Next(ranges.PE1980.cpu_CoresRange.getLeft(), ranges.PE1980.cpu_CoresRange.getRight() + 1),
                rand.Next(ranges.PE1980.cpu_ClockRange.getLeft(), ranges.PE1980.cpu_ClockRange.getRight() + 1),
                rand.Next(ranges.PE1980.cpu_BitsRange.getLeft(), ranges.PE1980.cpu_BitsRange.getRight() + 1)
                );

            //returnPart = new CPU(generatePartName(partType, company),
            //    company,
            //    500.0f * (float)CPU[company] * (float)CPU[company],
            //    "Debug",
            //    100 * (int)((float)CPU[company] * 100.0f) / 100,
            //    1.0f,
            //    rand.Next(ranges.PE1980.cpu_CoresRange.getLeft(), ranges.PE1980.cpu_CoresRange.getRight() + 1), 1, 1);

        }
        else if (partType == typeof(GPU))
        {
            returnPart = new GPU(generatePartName(partType, company),
                company,
                 500.0f * (float)GPU[company] * (float)GPU[company],
                "Debug",
                200 * (int)((float)GPU[company] * 100.0f) / 100,
                1.0f,
                rand.Next(ranges.PE1980.gpu_MegaflopsRange.getLeft(), ranges.PE1980.gpu_MegaflopsRange.getRight() + 1),
                rand.Next(ranges.PE1980.gpu_MemoryRange.getLeft(), ranges.PE1980.gpu_MemoryRange.getRight() + 1)
                );
        }
        else if (partType == typeof(HDD))
        {
            returnPart = new HDD(generatePartName(partType, company),
                company,
                 500.0f * (float)HDD[company] * (float)HDD[company],
                "Debug",
                5 * (int)((float)HDD[company] * 100.0f) / 100,
                1.0f,
                rand.Next(ranges.PE1980.hdd_SizeRange.getLeft(), ranges.PE1980.hdd_SizeRange.getRight() + 1),
                rand.Next(ranges.PE1980.hdd_SpeedRange.getLeft(), ranges.PE1980.hdd_SpeedRange.getRight() + 1)
                );
        }
        else if (partType == typeof(RAM))
        {
            returnPart = new RAM(generatePartName(partType, company),
                company,
                 500.0f * (float)RAM[company] * (float)RAM[company],
                "Debug",
                5 * (int)((float)RAM[company] * 100.0f) / 100,
                1.0f,
                rand.Next(ranges.PE1980.ram_SizeRange.getLeft(), ranges.PE1980.ram_SizeRange.getRight() + 1),
                rand.Next(ranges.PE1980.ram_SpeedRange.getLeft(), ranges.PE1980.ram_SpeedRange.getRight() + 1),
                rand.Next(ranges.PE1980.ram_ChannelsRange.getLeft(), ranges.PE1980.ram_ChannelsRange.getRight() + 1)
                );
        }
        else if (partType == typeof(CompInput))
        {
            returnPart = new CompInput(generatePartName(partType, company),
                company,
                 500.0f * (float)INPUT[company] * (float)INPUT[company],
                "Debug",
                5 * (int)((float)INPUT[company] * 100.0f) / 100,
                1.0f,
                rand.Next(ranges.PE1980.input_DPIRange.getLeft(), ranges.PE1980.input_DPIRange.getRight() + 1),
                rand.Next(ranges.PE1980.input_PollingRange.getLeft(), ranges.PE1980.input_PollingRange.getRight() + 1),
                rand.Next(10) <= 7 ? false : true
                );
        }
        else if (partType == typeof(CompOutput))
        {
            returnPart = new CompOutput(generatePartName(partType, company),
                company,
                 500.0f * (float)OUTPUT[company] * (float)OUTPUT[company],
                "Debug",
                50 * (int)((float)OUTPUT[company] * 100.0f) / 100,
                1.0f,
                rand.Next(ranges.PE1980.output_ResolutionRange.getLeft(), ranges.PE1980.output_ResolutionRange.getRight() + 1),
                rand.Next(ranges.PE1980.output_RefreshRange.getLeft(), ranges.PE1980.output_RefreshRange.getRight() + 1),
                rand.Next(ranges.PE1980.output_SQRange.getLeft(), ranges.PE1980.output_SQRange.getRight() + 1)
                );
        }
        else if (partType == typeof(CompNetwork))
        {
            returnPart = new CompNetwork(generatePartName(partType, company),
                company,
                 500.0f * (float)NETWORK[company] * (float)NETWORK[company],
                "Debug",
                0,
                1.0f,
                rand.Next(2) == 0 ? ranges.PE1980.network_TypeRange.getLeft() : ranges.PE1980.network_TypeRange.getRight(),
                rand.Next(ranges.PE1980.network_PingRange.getLeft(), ranges.PE1980.network_PingRange.getRight() + 1),
                rand.Next(ranges.PE1980.network_BandwidthRange.getLeft(), ranges.PE1980.network_BandwidthRange.getRight() + 1)
                );
        }
        else if (partType == typeof(PowerSupply))
        {
            returnPart = new PowerSupply(generatePartName(partType, company),
                company,
                 500.0f * (float)PSU[company] * (float)PSU[company],
                "Debug",
                0,
                1.0f,
                rand.Next(ranges.PE1980.pSupply_WattageRange.getLeft(), ranges.PE1980.pSupply_WattageRange.getRight() + 1)
                );
        }
        else if (partType == typeof(Chassis))
        {
            returnPart = new Chassis(generatePartName(partType, company),
                company,
                 500.0f * (float)CHASSIS[company] * (float)CHASSIS[company],
                "Debug",
                0,
                1.0f,
                rand.Next(ranges.PE1980.chassis_CoolRange.getLeft(), ranges.PE1980.chassis_CoolRange.getRight() + 1)
                );
        }
        else if (partType == typeof(Motherboard))
        {
            returnPart = new Motherboard(generatePartName(partType, company),
                500.0f * (float)MOBO[company] * (float)MOBO[company],
                1.0f,
                "Debug",
                "Debug",
                "Debug",
                "Debug",
                "Debug",
                "Debug",
                "Debug",
                "Debug",
                "Debug",
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null
                );
        }
        return returnPart;
    }
Ejemplo n.º 29
0
Archivo: Parts.cs Proyecto: rhyok/hue-r
 public Motherboard(string name, float price, float defectiveChance, string CPUI, string GPUI, string HDDI, string RAMI, 
     string powerI, string compInputI, string compOutputI, string networkI, string formFactor,
     CPU cpu, GPU gpu, HDD hdd, RAM ram, CompInput input, CompOutput output, CompNetwork network,
     PowerSupply pSupply, Chassis chassis)
 {
     this.name                   = name;
     this.price                  = price;
     this.defectiveChance        = defectiveChance;
     this.CPUInterface           = CPUI;
     this.GPUInterface           = GPUI;
     this.HDDInterface           = HDDI;
     this.RAMInterface           = RAMI;
     this.powerInterface         = powerI;
     this.compInputInterface     = compInputI;
     this.compOutputInterface    = compOutputI;
     this.networkInterface       = networkI;
     this.formFactor             = formFactor;
     this.cpu                    = cpu;
     this.gpu                    = gpu;
     this.hdd                    = hdd;
     this.ram                    = ram;
     this.input                  = input;
     this.output                 = output;
     this.network                = network;
     this.pSupply                = pSupply;
     this.chassis                = chassis;
 }
Ejemplo n.º 30
0
        public Smart()
        {
            InitializeComponent();
            this.Icon = MainWindow.CreateBitmapSourceFromGdiBitmap(Properties.Resources.pc);

            try
            {
                var dicDrives = new Dictionary<int, HDD>();
                var wdSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
                int iDriveIndex = 0;
                foreach (ManagementObject drive in wdSearcher.Get())
                {
                    var hdd = new HDD();
                    hdd.Model = drive["Model"].ToString().Trim();
                    hdd.Type = drive["InterfaceType"].ToString().Trim();
                    dicDrives.Add(iDriveIndex, hdd);
                    iDriveIndex++;
                }

                var pmsearcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia");

                iDriveIndex = 0;
                foreach (ManagementObject drive in pmsearcher.Get())
                {
                    if (iDriveIndex >= dicDrives.Count)
                        break;

                    dicDrives[iDriveIndex].Serial = drive["SerialNumber"] == null ? "None" : drive["SerialNumber"].ToString().Trim();
                    iDriveIndex++;
                }

                var searcher = new ManagementObjectSearcher("Select * from Win32_DiskDrive");
                searcher.Scope = new ManagementScope(@"\root\wmi");

                searcher.Query = new ObjectQuery("Select * from MSStorageDriver_FailurePredictStatus");
                iDriveIndex = 0;
                foreach (ManagementObject drive in searcher.Get())
                {
                    dicDrives[iDriveIndex].IsOK = (bool)drive.Properties["PredictFailure"].Value == false;
                    iDriveIndex++;
                }

                searcher.Query = new ObjectQuery("Select * from MSStorageDriver_FailurePredictData");
                iDriveIndex = 0;
                foreach (ManagementObject data in searcher.Get())
                {
                    Byte[] bytes = (Byte[])data.Properties["VendorSpecific"].Value;
                    for (int i = 0; i < 30; ++i)
                    {
                        try
                        {
                            int id = bytes[i * 12 + 2];

                            int flags = bytes[i * 12 + 4];
                            bool failureImminent = (flags & 0x1) == 0x1;

                            int value = bytes[i * 12 + 5];
                            int worst = bytes[i * 12 + 6];
                            int vendordata = BitConverter.ToInt32(bytes, i * 12 + 7);
                            if (id == 0) continue;

                            var attr = dicDrives[iDriveIndex].Attributes[id];
                            attr.Current = value;
                            attr.Worst = worst;
                            attr.Data = vendordata;
                            attr.IsOK = failureImminent == false;
                        }
                        catch
                        {
                        }
                    }
                    iDriveIndex++;
                }

                searcher.Query = new ObjectQuery("Select * from MSStorageDriver_FailurePredictThresholds");
                iDriveIndex = 0;
                foreach (ManagementObject data in searcher.Get())
                {
                    Byte[] bytes = (Byte[])data.Properties["VendorSpecific"].Value;
                    for (int i = 0; i < 30; ++i)
                    {
                        try
                        {

                            int id = bytes[i * 12 + 2];
                            int thresh = bytes[i * 12 + 3];
                            if (id == 0) continue;

                            var attr = dicDrives[iDriveIndex].Attributes[id];
                            attr.Threshold = thresh;
                        }
                        catch
                        {
                        }
                    }

                    iDriveIndex++;
                }

              
               
                foreach (var drive in dicDrives)
                {


                    foreach (var attr in drive.Value.Attributes)
                    {
                        Console.WriteLine("Init started");
                        if (attr.Value.HasData)
                        {
                            String s = (attr.Value.IsOK) ? "OK" : "";
                            Console.WriteLine(attr.Value.Attribute  + "   "  + " : " + attr.Value.Data);
                          
                            smartListView.Items.Add( new SMARTListItem() {
                                id = attr.Value.Attribute,
                                current = attr.Value.Current,
                                worst = attr.Value.Worst,
                                threshold = attr.Value.Threshold,
                                data = attr.Value.Data,
                                status = s
                            });

                        }
                    }

                }
            }
            catch (ManagementException ex)
            {
                MessageBox.Show("Перезапустіть програму з правами адміністратора");
            }
               
            catch(System.NullReferenceException e)
            {
                MessageBox.Show("Помилка виводу");
            }
           
            
        }
Ejemplo n.º 31
0
 public void Dispose()
 {
     HDD.Dispose();
 }
 public HDDShortModel(HDD hdd)
 {
     HDDId    = hdd.Id;
     HDDName  = hdd.Name;
     HDDImage = "/Images/HDD/" + hdd.Image;
 }
Ejemplo n.º 33
0
        public static async void TopAchatExtractor(string rootUrl, ObservableCollection <HDD> LstProd)
        {
            string UrlBase = "https://www.topachat.com";

            List <string> LstPage = new List <string>();

            ScrapySharp.Network.ScrapingBrowser browser = new ScrapySharp.Network.ScrapingBrowser();
            var res = await browser.NavigateToPageAsync(new Uri(rootUrl));

            LstPage.Add(rootUrl);
            var pagin = res.Html.CssSelect(".pagination");

            foreach (HtmlNode elem in pagin.Last().ChildNodes.Where(n => n.Attributes.Any(a => a.Name == "href")))
            {
                LstPage.Add(elem.Attributes.Where(at => at.Name == "href").First().Value);
            }

            LstPage.Remove(LstPage.Last());
            LstPage[0] = LstPage.First().Replace(UrlBase, "");

            foreach (string elem in LstPage)
            {
                var rslt = await browser.NavigateToPageAsync(new Uri(UrlBase + elem));

                foreach (HtmlAgilityPack.HtmlNode prod in rslt.Html.CssSelect(".grille-produit"))
                {
                    HDD   tmp        = new HDD();
                    var   price      = prod.CssSelect(".price").FirstOrDefault()?.InnerText;
                    float finalprice = 0.0f;
                    Regex regex      = new Regex(@"(\d+.\d\d)&nbsp;&euro;");
                    if (price != null)
                    {
                        Match match = regex.Match(price);
                        if (match.Success)
                        {
                            finalprice = float.Parse(match.Groups[1].Value, CultureInfo.InvariantCulture);

                            tmp.Prix = finalprice;


                            Regex  reg2 = new Regex(@"(.+),\s(\d+)\s(To|Go)");
                            string spec = prod.CssSelect(".libelle").First().InnerText;

                            Match match2 = reg2.Match(spec);
                            if (match2.Success)
                            {
                                tmp.Nom = match2.Groups[1].Value.Replace("\t", "");

                                if (match2.Groups[3].Value == "To")
                                {
                                    tmp.Capacite = int.Parse(match2.Groups[2].Value) * 1000;
                                }
                                else if (match2.Groups[3].Value == "Go")
                                {
                                    tmp.Capacite = int.Parse(match2.Groups[2].Value);
                                }

                                tmp.PrixAuGO = (float)tmp.Prix / (float)tmp.Capacite;
                            }
                            await Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
                            {
                                LstProd.Add(tmp);
                            }));
                        }
                    }
                }
            }

            LstProd = new ObservableCollection <HDD>(LstProd.OrderBy(p => p.PrixAuGO));
        }
Ejemplo n.º 34
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            foreach (var hardware in thisComputer.Hardware)
            {
                hardware.Update();
                /*---------------------------------CPU---------------------------------*/
                if (hardware.HardwareType == HardwareType.Cpu)
                {
                    cpuName = hardware.Name;
                    foreach (var sensor in hardware.Sensors)
                    {
                        if (sensor.SensorType == SensorType.Load && sensor.Name == "CPU Total")
                        {
                            cpuLoad = sensor.Value.Value;
                        }

                        if (sensor.SensorType == SensorType.Temperature && sensor.Name == "CPU Package")
                        {
                            cpuTemp = sensor.Value.GetValueOrDefault();
                        }
                    }
                }
                /*---------------------------------GPU---------------------------------*/
                if (hardware.HardwareType == HardwareType.GpuAmd || hardware.HardwareType == HardwareType.GpuNvidia)
                {
                    gpuName = hardware.Name;
                    foreach (var sensor in hardware.Sensors)
                    {
                        if (sensor.SensorType == SensorType.Load && sensor.Name == "GPU Core")
                        {
                            gpuLoad = sensor.Value.Value;
                        }

                        if (sensor.SensorType == SensorType.Temperature && sensor.Name == "GPU Core")
                        {
                            gpuTemp = sensor.Value.GetValueOrDefault();
                        }
                        if (sensor.SensorType == SensorType.Fan && sensor.Name == "GPU Fan")
                        {
                            gpuFan = sensor.Value.GetValueOrDefault();
                        }
                        if (sensor.SensorType == SensorType.Control && sensor.Name == "GPU Fan")
                        {
                            gpuFanLoad = sensor.Value.GetValueOrDefault();
                        }
                    }
                }
                /*---------------------------------RAM---------------------------------*/
                if (hardware.HardwareType == HardwareType.Memory)
                {
                    foreach (var sensor in hardware.Sensors)
                    {
                        if (sensor.SensorType == SensorType.Load && sensor.Name == "Memory")
                        {
                            ramLoad = sensor.Value.Value;
                        }
                        if (sensor.SensorType == SensorType.Data && sensor.Name == "Memory Used")
                        {
                            ramUse = sensor.Value.GetValueOrDefault();
                        }
                        if (sensor.SensorType == SensorType.Data && sensor.Name == "Memory Available")
                        {
                            float ramAva = sensor.Value.GetValueOrDefault();
                            totalRam = ramAva + ramUse;
                        }
                    }
                }
                /*---------------------------------Connection---------------------------------*/
                if (hardware.HardwareType == HardwareType.Network)
                {
                    foreach (var sensor in hardware.Sensors)
                    {
                        if (sensor.SensorType == SensorType.Throughput && sensor.Name == "Upload Speed")
                        {
                            upload = (sensor.Value.GetValueOrDefault()) * 8 / 1048576;
                        }
                        if (sensor.SensorType == SensorType.Throughput && sensor.Name == "Download Speed")
                        {
                            download = (sensor.Value.GetValueOrDefault()) * 8 / 1048576;
                        }
                        strNw = Math.Round(download, 2).ToString("F2") + "/" + Math.Round(upload, 2).ToString("F2");
                        if (strNw.Length > 10)
                        {
                            strNw = "Connecting...";
                        }
                    }
                }
                /*---------------------------------Drive---------------------------------*/
                if (hardware.Name == "WDC WD10EZEX-00WN4A0")
                {
                    foreach (var sensor in hardware.Sensors)
                    {
                        hdd = hardware.Name;
                        if (sensor.SensorType == SensorType.Load && sensor.Name == "Total Activity")
                        {
                            hddLoad = sensor.Value.Value;
                        }
                        if (sensor.SensorType == SensorType.Temperature && sensor.Name == "Temperature")
                        {
                            hddTemp = sensor.Value.GetValueOrDefault();
                        }
                        if (sensor.SensorType == SensorType.Load && sensor.Name == "Used Space")
                        {
                            hddUse = sensor.Value.GetValueOrDefault();
                        }
                    }
                }

                if (hardware.Name == "Samsung SSD 960 EVO 250GB")
                {
                    foreach (var sensor in hardware.Sensors)
                    {
                        ssd = hardware.Name.Substring(0, 19);
                        if (sensor.SensorType == SensorType.Load && sensor.Name == "Total Activity")
                        {
                            ssdLoad = sensor.Value.Value;
                        }
                        if (sensor.SensorType == SensorType.Temperature && sensor.Name == "Temperature")
                        {
                            ssdTemp = sensor.Value.GetValueOrDefault();
                        }
                        if (sensor.SensorType == SensorType.Load && sensor.Name == "Used Space")
                        {
                            ssdUse = sensor.Value.GetValueOrDefault();
                        }
                    }
                }

                if (hardware.HardwareType == HardwareType.Heatmaster)
                {
                    foreach (var sensor in hardware.Sensors)
                    {
                        if (sensor.SensorType == SensorType.Load && sensor.Name == "CPU Total")
                        {
                            cpuLoad = sensor.Value.Value;
                        }

                        if (sensor.SensorType == SensorType.Temperature && sensor.Name == "CPU Package")
                        {
                            cpuTemp = sensor.Value.GetValueOrDefault();
                        }
                    }
                }
                /*---------------------------------Display---------------------------------*/
                grCPU.Text      = cpuName;
                txtLoadCPU.Text = Math.Round(cpuLoad).ToString() + " %";
                txtTempCPU.Text = Math.Round(cpuTemp).ToString() + " °C";

                grGPU.Text      = gpuName;
                txtLoadGPU.Text = Math.Round(gpuLoad).ToString() + " %";
                txtTempGPU.Text = Math.Round(gpuTemp).ToString() + " °C";
                txtFanGPU.Text  = Math.Round(gpuFan).ToString() + " RPM";

                txtTotalRam.Text = Math.Round(totalRam).ToString() + " GB";
                txtRamUse.Text   = Math.Round(ramUse).ToString() + " GB";
                txtRamLoad.Text  = Math.Round(ramLoad).ToString() + " %";

                txtDown.Text = Math.Round(download, 2).ToString("F2") + " MB/s";
                txtUp.Text   = Math.Round(upload, 2).ToString("F2") + " MB/s";

                grHDD.Text      = hdd;
                txtHddLoad.Text = Math.Round(hddLoad).ToString() + " %";
                txtHddUse.Text  = Math.Round(hddUse).ToString() + " %";
                txtHddTemp.Text = Math.Round(hddTemp).ToString() + " °C";

                grSSD.Text      = ssd;
                txtSsdLoad.Text = Math.Round(ssdLoad).ToString() + " %";
                txtSsdUse.Text  = Math.Round(ssdUse).ToString() + " %";
                txtSsdTemp.Text = Math.Round(ssdTemp).ToString() + " °C";
                /*---------------------------------Send DATA---------------------------------*/
            }
            Processor dataCPU = new Processor
            {
                Name = cpuName,
                Load = Math.Round(cpuLoad, 1),
                Temp = Math.Round(cpuTemp, 1)
            };
            Graphic dataGPU = new Graphic
            {
                Name = gpuName,
                Load = Math.Round(gpuLoad, 1),
                Temp = Math.Round(gpuTemp, 1),
            };
            Ram dataRam = new Ram
            {
                Use = Math.Round(ramUse).ToString() + "/" + Math.Round(totalRam).ToString()
            };
            Connection dataNet = new Connection
            {
                Speed = strNw
            };
            HDD infoHDD = new HDD
            {
                Name = hdd,
                Use  = Math.Round(hddUse),
                Load = Math.Round(hddLoad),
                Temp = Math.Round(hddTemp)
            };
            SSD infoSSD = new SSD
            {
                Name = ssd,
                Use  = Math.Round(ssdUse),
                Load = Math.Round(ssdLoad),
                Temp = Math.Round(ssdTemp)
            };
            Infomation info = new Infomation
            {
                CPU      = dataCPU,
                GPU      = dataGPU,
                RAM      = dataRam,
                Net      = dataNet,
                hddDrive = infoHDD,
                ssdDrive = infoSSD
            };
            string obj = JsonConvert.SerializeObject(info);

            if (lblWIFIStatus.Text == "Connected")
            {
                try
                {
                    NetworkStream stream = client.GetStream();
                    byte[]        data   = Encoding.ASCII.GetBytes(obj + "\r\n");
                    stream.Write(data, 0, data.Length);
                }
                catch (Exception)
                {
                    AppIcon.ShowBalloonTip(5000, "Mất kêt nối", "Kiểm tra lại server", ToolTipIcon.Warning);
                    txtIP.Enabled           = true;
                    timer1.Enabled          = false;
                    btnConnectWIFI.Text     = "Connect";
                    lblWIFIStatus.Text      = "Disconnected";
                    lblWIFIStatus.ForeColor = Color.Red;
                    client.Close();
                    client = new TcpClient();
                }
            }
            if (lblStatusWired.Text == "Connected")
            {
                a = dataCPU.Name + "," + dataCPU.Load + "," + dataCPU.Temp + "," + dataGPU.Name + "," + dataGPU.Load + "," + dataGPU.Temp + "," + dataRam.Use + "," + dataNet.Speed + "," + infoHDD.Name + "," + infoHDD.Use + "," + infoHDD.Load + "," + infoHDD.Temp + "," + infoSSD.Name + "," + infoSSD.Use + "," + infoSSD.Load + "," + infoSSD.Temp + "*";
                serialPort1.Write(a);
            }
        }
Ejemplo n.º 35
0
        static void Main(string[] args)
        {
            Flash flash1 = new Flash(2000, TypeUSB.USB1);

            flash1.Name  = "Kingston";
            flash1.Model = "KB12";

            ServiceStorage.AddFlash(flash1);
            ServiceStorage.AddFlash(new Flash(4000, TypeUSB.USB2)
            {
                Name = "Transend", Model = "B125"
            });
            ServiceStorage.AddFlash(new Flash(8000, TypeUSB.USB3)
            {
                Name = "Samsung", Model = "S13G"
            });
            ServiceStorage.AddFlash(new Flash(16000, TypeUSB.USB3)
            {
                Name = "Samsung", Model = "S13G4"
            });


            HDD hdd1 = new HDD(TypeUSB.USB1, 2, 256000);

            hdd1.Model = "Barracuda";
            hdd1.Name  = "Seagate";

            HDD hdd2 = (new HDD(TypeUSB.USB2, 3, 84992)
            {
                Name = "Seagate", Model = "Iron Wolf"
            });
            HDD hdd3 = (new HDD(TypeUSB.USB1, 4, 256000)
            {
                Name = "Seagate", Model = "Sky Hawk"
            });

            ServiceStorage.AddHDD(hdd1);
            ServiceStorage.AddHDD(hdd2);
            ServiceStorage.AddHDD(hdd3);


            DVD dvd1 = new DVD(TypeDVD.SimpleSide)
            {
                Name = "Sony", Model = "DYK2"
            };
            DVD dvd2 = new DVD(TypeDVD.DoubleSide)
            {
                Name = "Panasonic", Model = "DG5S"
            };
            DVD dvd3 = new DVD(TypeDVD.DoubleSide)
            {
                Name = "Lightning", Model = "ESR9"
            };

            ServiceStorage.AddDVD(dvd1);
            ServiceStorage.AddDVD(dvd2);
            ServiceStorage.AddDVD(dvd3);

            while (true)
            {
                int x;
                Console.WriteLine("Выберите устройство, куда вы будете копировать.\n1: Флешка\n2: Жесткий диск\n3: DVD диск\n\n4: Выход");
                x = Int32.Parse(Console.ReadLine());
                if (x == 1)
                {
                    Console.Clear();
                    //ServiceStorage.printFlashes();
                    Console.WriteLine("Введите объем информации");
                    double t = double.Parse(Console.ReadLine());
                    ServiceStorage.GetCountDevice(TypeDevice.Flash, t);
                    Console.WriteLine("\nEnter any key");
                    Console.ReadKey();
                    Console.Clear();
                }
                if (x == 2)
                {
                    Console.Clear();
                    //ServiceStorage.printHDDs();
                    Console.WriteLine("Введите объем информации");
                    double s = double.Parse(Console.ReadLine());
                    ServiceStorage.GetCountDevice(TypeDevice.HDD, s);
                    Console.WriteLine("\nEnter any key");
                    Console.ReadKey();
                    Console.Clear();
                }
                if (x == 3)
                {
                    Console.Clear();
                    //ServiceStorage.printDVDs();
                    Console.WriteLine("Введите объем информации");
                    double s = double.Parse(Console.ReadLine());
                    ServiceStorage.GetCountDevice(TypeDevice.DVD, s);
                    Console.WriteLine("\nEnter any key");
                    Console.ReadKey();
                    Console.Clear();
                }
                if (x == 4)
                {
                    Console.Clear();
                    break;
                }
            }
        }
Ejemplo n.º 36
0
        public static async void GrosbillExtractor(string rootUrl, ObservableCollection <HDD> LstProd)
        {
            string        UrlBase = "https://www.grosbill.com/3-disque_dur-3.5-type-informatique?page=";
            string        compl   = "&tri=w&filtre_page=100&mode=listing&filtre_type_produit=disque_dur#";
            List <string> LstPage = new List <string>();

            ScrapySharp.Network.ScrapingBrowser browser = new ScrapySharp.Network.ScrapingBrowser();
            var res = await browser.NavigateToPageAsync(new Uri(rootUrl));

            LstPage.Add(rootUrl + compl + "1");

            //foreach (HtmlNode nod in res.Html.CssSelect(".pagination").First().CssSelect(".page_number"))
            //{
            //    LstPage.Add(UrlBase + nod.InnerText+compl+ nod.InnerText);
            //}



            foreach (string elem in LstPage)
            {
                var rslt = await browser.NavigateToPageAsync(new Uri(elem));

                foreach (HtmlNode nd in rslt.Html.CssSelect(".listing_product").First().SelectNodes("//tr"))
                {
                    HDD tmp   = new HDD();
                    var price = nd.CssSelect(".btn_price_wrapper").FirstOrDefault()?.InnerText;

                    float finalprice = 0.0f;
                    Regex regex      = new Regex(@"(\d+)&euro;(\d\d)");
                    if (price != null)
                    {
                        Match match = regex.Match(price);
                        if (match.Success)
                        {
                            finalprice = float.Parse(match.Groups[1].ToString() + "." + match.Groups[2].ToString(), CultureInfo.InvariantCulture);

                            tmp.Prix = finalprice;
                        }
                    }
                    if (nd.CssSelect(".product_description").Count() == 1)
                    {
                        string spec = nd.CssSelect(".product_description").First().ChildNodes[1].InnerText;
                        Regex  reg2 = new Regex(@"(.+)\s+(\d+)\s*(To|Go)(.*)");


                        Match match2 = reg2.Match(spec);
                        if (match2.Success)
                        {
                            tmp.Nom = match2.Groups[1].Value.Replace("\t", "");

                            if (match2.Groups[3].Value == "To")
                            {
                                tmp.Capacite = int.Parse(match2.Groups[2].Value) * 1000;
                            }
                            else if (match2.Groups[3].Value == "Go")
                            {
                                tmp.Capacite = int.Parse(match2.Groups[2].Value);
                            }

                            tmp.PrixAuGO = (float)tmp.Prix / (float)tmp.Capacite;
                        }
                    }

                    await Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
                    {
                        if (tmp.Capacite != 0)
                        {
                            LstProd.Add(tmp);
                        }
                    }));
                }
            }

            Debug.WriteLine(LstProd.Count);
        }