public GeneralPhone(FormFactor formFactor, string serialNumber)
 {
     SerialNumber       = serialNumber;
     FormFactor         = formFactor;
     this.deviceActions = new Dictionary <string, Action <int> >();
     connectedDevices   = new HashSet <IInterconnection>();
 }
示例#2
0
        private List <Motherboard> GetTestMotherboards()
        {
            var motherboards  = new List <Motherboard>();
            var am4SocketType = new PCItemType()
            {
                Name = "AM4"
            };
            var motherboardFormFactor = new FormFactor()
            {
                Name = "ATX"
            };

            motherboards.Add(new Motherboard()
            {
                Name = "MSI B450 TOMAHAWK", MaxRam = 64, RamSlots = 4, Price = 111.99M, FormFactor = motherboardFormFactor, SocketType = am4SocketType
            });
            motherboardFormFactor = new FormFactor()
            {
                Name = "ATX"
            };
            am4SocketType = new PCItemType()
            {
                Name = "AM4"
            };
            motherboards.Add(new Motherboard()
            {
                Name = "Asus ROG STRIX B450-F GAMING", MaxRam = 64, RamSlots = 4, Price = 129.99M, FormFactor = motherboardFormFactor, SocketType = am4SocketType
            });
            return(motherboards);
        }
示例#3
0
 public string PersonalToString()
 {
     return("Amount: " + Amount.ToString() + " \n" +
            "Type: " + Type.ToString() + " \n" +
            "FormFactor: " + FormFactor.ToString() + " \n" +
            "ShpindelSpeed: " + ShpindelSpeed.ToString() + " \n" +
            "AverageFoundingSpeed: " + FormFactor.ToString() + " \n" +
            "ConnectionInterface: " + ConnectionInterface.ToString());
 }
示例#4
0
 public PowerSupply(string manufacturer, string productsName, string serialNumber, int price, DateTime dateOfPurchase, DateTime dateOfAdd, DateTime warranty, string text, int output, Efficency efficency, int sata, int pcie, int molex, bool modular, FormFactor formFactor) : base(manufacturer, productsName, serialNumber, price, dateOfPurchase, dateOfAdd, warranty, text)
 {
     Output     = output;
     Efficency  = efficency;
     Sata       = sata;
     Pcie       = pcie;
     Molex      = molex;
     Modular    = modular;
     FormFactor = formFactor;
 }
示例#5
0
        public GamePhone(FormFactor formFactor, string serialNumber) : base(formFactor, serialNumber)
        {
            List <IComponent> components = new List <IComponent>();

            components.Add(new MonochromeScreen("Monochrome", 120, 70, "2LTMD20200318"));
            components.Add(new KeyboardWithJoystick(new List <string> {
                "English", "Russian"
            }, "KP20200318"));

            this.PhoneComponents = components;
        }
        private PowerSupply GetPowerSupply()
        {
            var formFactor = new FormFactor()
            {
                Name = "ATX"
            };

            return(new PowerSupply()
            {
                Name = "EVGA BR", Modular = false, Wattage = 500, Price = 40.98M, Efficiency = 80, FormFactor = formFactor
            });
        }
        private void CreatePowerSupplies()
        {
            var formFactor = new FormFactor()
            {
                Name = "ATX"
            };

            this.powerSupplyService.Create(new PowerSupply()
            {
                Name = "Corsair RM(2019)", Modular = true, Wattage = 750, Price = 119.99M, Efficiency = 80, FormFactor = formFactor, ImageSrc = "~/images/PowerSupply/02951377c9eed1e21fc3d8ba6092717e.256p.jpg"
            });
            formFactor = new FormFactor()
            {
                Name = "ATX"
            };
            this.powerSupplyService.Create(new PowerSupply()
            {
                Name = "EVGA BR", Modular = false, Wattage = 500, Price = 40.98M, Efficiency = 80, FormFactor = formFactor, ImageSrc = "~/images/PowerSupply/41TubKs3apL.jpg"
            });
            formFactor = new FormFactor()
            {
                Name = "ATX"
            };
            this.powerSupplyService.Create(new PowerSupply()
            {
                Name = "EVGA SuperNOVA G3", Modular = true, Wattage = 650, Price = 112.98M, Efficiency = 80, FormFactor = formFactor, ImageSrc = "~/images/PowerSupply/41WlwxBojdL.jpg"
            });
            formFactor = new FormFactor()
            {
                Name = "ATX"
            };
            this.powerSupplyService.Create(new PowerSupply()
            {
                Name = "Thermaltake Smart", Modular = false, Wattage = 500, Price = 33.98M, Efficiency = 80, FormFactor = formFactor, ImageSrc = "~/images/PowerSupply/51lUqysCuDL.jpg"
            });
            formFactor = new FormFactor()
            {
                Name = "ATX"
            };
            this.powerSupplyService.Create(new PowerSupply()
            {
                Name = "Seasonic M12II 520 Bronze", Modular = true, Wattage = 520, Price = 74.99M, Efficiency = 80, FormFactor = formFactor, ImageSrc = "~/images/PowerSupply/51Q-akpuooL.jpg"
            });
            formFactor = new FormFactor()
            {
                Name = "ATX"
            };
            this.powerSupplyService.Create(new PowerSupply()
            {
                Name = "Cooler Master Silent Pro Hybrid", Modular = true, Wattage = 1300, Price = 669.20M, Efficiency = 80, FormFactor = formFactor, ImageSrc = "~/images/PowerSupply/b624497b6d3a1589cfc26c69467f05c8.256p.jpg"
            });
        }
示例#8
0
        private Motherboard GetMotherboard()
        {
            var am4SocketType = new PCItemType()
            {
                Name = "AM4"
            };
            var motherboardFormFactor = new FormFactor()
            {
                Name = "ATX"
            };

            return(new Motherboard()
            {
                Name = "Asus ROG STRIX B450-F GAMING", MaxRam = 64, RamSlots = 4, Price = 129.99M, FormFactor = motherboardFormFactor, SocketType = am4SocketType
            });
        }
示例#9
0
        public GamePhone(FormFactor formFactor, string serialNumber) : base(formFactor, serialNumber)
        {
            List <IComponent> components = new List <IComponent>();

            components.Add(new MonochromeScreen("Monochrome", 120, 70, "2LTMD20200318"));

            var joystickButtons = new List <JoystickButtons> {
                JoystickButtons.Up, JoystickButtons.Down, JoystickButtons.Left, JoystickButtons.Right
            };
            var languages = new List <string> {
                "English", "Russian"
            };

            components.Add(new KeyboardWithJoystick(languages, "KP20200318", joystickButtons));

            this.PhoneComponents = components;
        }
        public SmsCallPhone(FormFactor formFactor, string serialNumber) : base(formFactor, serialNumber)
        {
            List <IComponent> components = new List <IComponent>();

            components.Add(new MonochromeScreen("Monochrome", 120, 70, "2LTMD20200225"));
            components.Add(new Keyboard(new List <string> {
                "English", "Russian"
            }, "KP20200225"));
            components.Add(new Communicator("SC20200406", this));
            Battery battery = new Battery("SC20200430", 60);

            components.Add(battery);

            var memory = new Memory("MC20200424");

            memory.Add <SmsMessage>(new List <SmsMessage>());
            memory.Add <Contact>(new List <Contact>());
            memory.Add <PhoneCall>(new List <PhoneCall>());

            components.Add(memory);

            this.PhoneComponents = components;

            this.deviceActions.Add(typeof(PowerBank).Name, (powerUp) =>
            {
                lock (syncRoot)
                {
                    battery.Capacity = (battery.Capacity + powerUp) > 100 ? 100 : battery.Capacity + powerUp;
                }

                progress?.Report(battery.Capacity);
            });

            this.deviceActions.Add(typeof(SmsCallPhone).Name, (powerDown) =>
            {
                lock (syncRoot)
                {
                    battery.Capacity = (battery.Capacity - powerDown) < 0 ? 0 : battery.Capacity - powerDown;
                }

                progress?.Report(battery.Capacity);
            });

            base.SupportedPlugins.Add(Plugins.Usb);
        }
示例#11
0
 public Motherboard(string manufacturer, string productsName, string serialNumber, int price, DateTime dateOfPurchase, DateTime dateOfAdd, DateTime warranty, string text, FormFactor formFactor, Socket socket, MemoryGeneration memoryGeneration, bool crossfire, bool sli, bool bluetooth, bool wifi, int m2X4Number, int memorySlots, int maxMemorySize, int pciEX16Slots, int pciEX4Slots, int pciEX1Slots, int sata3Connectors, int usb30, int usb31, int lan) : base(manufacturer, productsName, serialNumber, price, dateOfPurchase, dateOfAdd, warranty, text)
 {
     FormFactor       = formFactor;
     Socket           = socket;
     MemoryGeneration = memoryGeneration;
     Crossfire        = crossfire;
     Sli             = sli;
     Bluetooth       = bluetooth;
     Wifi            = wifi;
     M2x4Number      = m2X4Number;
     MemorySlots     = memorySlots;
     MaxMemorySize   = maxMemorySize;
     PciE_x16_Slots  = pciEX16Slots;
     PciE_x4_Slots   = pciEX4Slots;
     PciE_x1_Slots   = pciEX1Slots;
     Sata3Connectors = sata3Connectors;
     Usb30           = usb30;
     Usb31           = usb31;
     Lan             = lan;
 }
        private Storage GetStorage()
        {
            var formFactor25 = new FormFactor()
            {
                Name = "M2"
            };
            var ssd = new PCItemType()
            {
                Name = "SSD"
            };
            var conInterface = new ConnectionInterface()
            {
                Name = "SATA 6 GB/s"
            };

            return(new Storage()
            {
                Name = "Samsung 860 Evo", Capacity = "1TB", Cache = 1024, FormFactor = formFactor25, Interface = conInterface, Type = ssd, Price = 149.99M
            });
        }
        private List <Storage> GetTestStorages()
        {
            var storages     = new List <Storage>();
            var formFactor35 = new FormFactor()
            {
                Name = "3.5"
            };
            var conInterface = new ConnectionInterface()
            {
                Name = "SATA 6 GB/s"
            };
            var hdd = new PCItemType()
            {
                Name = "7200RPM"
            };

            storages.Add(new Storage()
            {
                Name = "Western Digital Caviar Blue", Capacity = "1TB", Cache = 64, FormFactor = formFactor35, Interface = conInterface, Type = hdd, Price = 44.08M
            });
            var formFactor25 = new FormFactor()
            {
                Name = "M2"
            };
            var ssd = new PCItemType()
            {
                Name = "SSD"
            };

            conInterface = new ConnectionInterface()
            {
                Name = "SATA 6 GB/s"
            };
            storages.Add(new Storage()
            {
                Name = "Samsung 860 Evo", Capacity = "1TB", Cache = 1024, FormFactor = formFactor25, Interface = conInterface, Type = ssd, Price = 149.99M
            });
            return(storages);
        }
        private List <PowerSupply> GetTestPowerSupplys()
        {
            var powerSupplies = new List <PowerSupply>();
            var formFactor    = new FormFactor()
            {
                Name = "ATX"
            };

            powerSupplies.Add(new PowerSupply()
            {
                Name = "Corsair RM(2019)", Modular = true, Wattage = 750, Price = 119.99M, Efficiency = 80, FormFactor = formFactor
            });
            formFactor = new FormFactor()
            {
                Name = "ATX"
            };
            powerSupplies.Add(new PowerSupply()
            {
                Name = "EVGA BR", Modular = false, Wattage = 500, Price = 40.98M, Efficiency = 80, FormFactor = formFactor
            });
            return(powerSupplies);
        }
示例#15
0
        public List <FormSettings> GetFormSettings(FormFactor formFactor, CultureInfo culture, string etoken)
        {
            List <FormSettings> list = new List <FormSettings>();
            string settingsNodeName;

            if (formFactor == FormFactor.Mobile)
            {
                settingsNodeName = "PhoneSettings";
            }
            else if (formFactor == FormFactor.Tablet)
            {
                settingsNodeName = "TabletSettings";
            }
            else
            {
                if (formFactor != FormFactor.Desktop)
                {
                    SchemaParser.Tracer.TraceError <FormFactor>(0L, "FormFactor {0} is not supported", formFactor);
                    return(list);
                }
                settingsNodeName = "DesktopSettings";
            }
            foreach (FormSettings.FormSettingsType formSettingsType in SchemaParser.allFormSettingsTypes)
            {
                XmlNode formSettingsParentNode = this.GetFormSettingsParentNode(formSettingsType);
                if (formSettingsParentNode != null)
                {
                    FormSettings formSettingsForFormType = this.GetFormSettingsForFormType(formSettingsParentNode, settingsNodeName, culture.ToString(), etoken);
                    if (formSettingsForFormType != null)
                    {
                        formSettingsForFormType.SettingsType = formSettingsType;
                        list.Add(formSettingsForFormType);
                    }
                }
            }
            return(list);
        }
示例#16
0
        public async Task<string> ScrapeFromProductPageAsync(string productUrl)
        {
            if (productUrl.Contains("Combo"))
            {
                var message = "Invalid Product.";
                this.logger.LogWarning(message);
                return message;
            }

            var document = await this.Context.OpenAsync(productUrl);
            var ssdDataTableRows = this.GetAllTablesRows(document);
            var ssdDataTables = this.GetAllTables(document);
            var ssd = new SSD
            {
                Price = this.GetPrice(document),
                ImageUrl = this.GetImageUrl(document),
                Category = this.GetCategoryFromUrl(productUrl),
            };

            this.logger.LogInformation(productUrl);

            foreach (var tableRow in ssdDataTableRows)
            {
                var rowName = tableRow.FirstChild.TextContent.Trim();
                var rowValue = tableRow.LastElementChild.InnerHtml.Replace("<br><br>", "{n}").Replace("<br>", "{n}").Trim();

                switch (rowName)
                {
                    case "Model":
                        if (this.ssdRepo.AllAsNoTracking().Any(x => x.Model == rowValue))
                        {
                            var message = "Already exists.";
                            this.logger.LogWarning(message);
                            return message;
                        }

                        ssd.Model = rowValue;
                        break;
                    case "Brand":
                        ssd.Brand = this.GetOrCreateBrand(this.brandRepo, rowValue);
                        break;
                    case "Series":
                        ssd.Series = this.GetOrCreateSeries(this.seriesRepo, rowValue);
                        break;
                    case "Used For":
                        var usage = this.usageRepo.All().FirstOrDefault(x => x.Name == rowValue);
                        if (usage == null)
                        {
                            usage = new DiskForUsage
                            {
                                Name = rowValue,
                            };
                        }

                        ssd.Usage = usage;
                        break;
                    case "Form Factor":
                        var formFactor = this.formFactorRepo.All().FirstOrDefault(x => x.Name == rowValue);
                        if (formFactor == null)
                        {
                            formFactor = new FormFactor
                            {
                                Name = rowValue,
                            };
                        }

                        ssd.FormFactor = formFactor;
                        break;
                    case "Capacity":
                        var capacityMatch = this.MatchOneOrMoreDigits.Match(rowValue);
                        if (!capacityMatch.Success)
                        {
                            continue;
                        }

                        var capacity = short.Parse(capacityMatch.Value);
                        if (rowValue.ToLower().Contains("tb"))
                        {
                            capacity *= 1024;
                        }

                        ssd.CapacityGb = capacity;
                        break;
                    case "Memory Components":
                        var memoryComponent = this.memoryComponentRepo.All().FirstOrDefault(x => x.Name == rowValue);
                        if (memoryComponent == null)
                        {
                            memoryComponent = new MemoryComponent
                            {
                                Name = rowValue,
                            };
                        }

                        ssd.MemoryComponent = memoryComponent;
                        break;
                    case "Interface":
                        var ssdInterface = this.interfaceRepo.All().FirstOrDefault(x => x.Name == rowValue);
                        if (ssdInterface == null)
                        {
                            ssdInterface = new Interface
                            {
                                Name = rowValue,
                            };
                        }

                        ssd.Interface = ssdInterface;
                        break;
                    case "Cache":
                        var cacheMatch = this.MatchOneOrMoreDigits.Match(rowValue);
                        if (!cacheMatch.Success)
                        {
                            continue;
                        }

                        var cache = int.Parse(cacheMatch.Value);
                        if (rowValue.ToLower().Contains("mb"))
                        {
                            cache *= 1024;
                        }
                        else if (rowValue.ToLower().Contains("gb"))
                        {
                            cache *= 1024 * 1024;
                        }

                        ssd.CacheKb = cache;
                        break;
                    case "Max Sequential Read":
                        var seqReadMatch = this.MatchOneOrMoreDigits.Match(rowValue);
                        if (!seqReadMatch.Success)
                        {
                            continue;
                        }

                        ssd.MaxSequentialReadMBps = short.Parse(seqReadMatch.Value);
                        break;
                    case "Max Sequential Write":
                        var seqWriteMatch = this.MatchOneOrMoreDigits.Match(rowValue);
                        if (!seqWriteMatch.Success)
                        {
                            continue;
                        }

                        ssd.MaxSequentialWriteMBps = short.Parse(seqWriteMatch.Value);
                        break;
                    case "4KB Random Read":
                        ssd.FourKBRandomRead = rowValue;
                        break;
                    case "4KB Random Write":
                        ssd.FourKBRandomWrite = rowValue;
                        break;
                    case "MTBF":
                        var mtbfMatch = this.MatchOneOrMoreDigits.Match(rowValue.Replace(",", string.Empty));
                        if (!mtbfMatch.Success)
                        {
                            continue;
                        }

                        ssd.MeanTimeBetweenFailures = int.Parse(mtbfMatch.Value);
                        break;
                    case "Features":
                        ssd.Features = rowValue;
                        break;
                    case "Height":
                        ssd.Height = this.MatchAndParseFloat(rowValue);
                        break;
                    case "Width":
                        ssd.Width = this.MatchAndParseFloat(rowValue);
                        break;
                    case "Depth":
                        ssd.Length = this.MatchAndParseFloat(rowValue);
                        break;
                    case "Date First Available":
                        ssd.FirstAvailable = DateTime.Parse(rowValue);
                        break;
                }
            }

            if (ssd.Model == null)
            {
                var message = "Invalid Model.";
                this.logger.LogWarning(message);
                return message;
            }

            await this.ssdRepo.AddAsync(ssd);
            await this.ssdRepo.SaveChangesAsync();
            var successMessage = $"Successfully added {ssd.Model}.";
            this.logger.LogInformation(successMessage);
            return successMessage;
        }
示例#17
0
        public async Task <string> ScrapeFromProductPageAsync(string productUrl)
        {
            if (productUrl.Contains("Combo"))
            {
                var message = "Invalid Product.";
                this.logger.LogWarning(message);
                return(message);
            }

            var document = await this.Context.OpenAsync(productUrl);

            var caseDataTableRows = this.GetAllTablesRows(document);
            var caseDataTables    = this.GetAllTables(document);
            var casePc            = new Case
            {
                Price            = this.GetPrice(document),
                ImageUrl         = this.GetImageUrl(document),
                Category         = this.GetCategoryFromUrl(productUrl),
                DownloadedRating = this.GetRatings(document),
            };

            casePc.DownloadedRating.ProductId = casePc.Id;

            this.logger.LogInformation(productUrl);

            foreach (var tableRow in caseDataTableRows)
            {
                var rowName  = tableRow.FirstChild.TextContent.Trim();
                var rowValue = tableRow.LastElementChild.InnerHtml.Replace("<br><br>", "{n}").Replace("<br>", "{n}").Trim();

                switch (rowName)
                {
                case "Model":
                    if (this.caseRepo.AllAsNoTracking().Any(x => x.Model == rowValue))
                    {
                        var message = "Already exists.";
                        this.logger.LogWarning(message);
                        return(message);
                    }

                    casePc.Model = rowValue;
                    break;

                case "Brand":
                    casePc.Brand = this.GetOrCreateBrand(this.brandRepo, rowValue);
                    break;

                case "Series":
                    casePc.Series = this.GetOrCreateSeries(this.seriesRepo, rowValue);
                    break;

                case "Type":
                    var type = this.caseTypeRepo.All().FirstOrDefault(x => x.Name == rowValue);
                    if (type == null)
                    {
                        type = new CaseType
                        {
                            Name = rowValue,
                        };
                    }

                    casePc.CaseType = type;
                    break;

                case "Color":
                    var color = this.colorRepo.All().FirstOrDefault(x => x.Name == rowValue);
                    if (color == null)
                    {
                        color = new Color
                        {
                            Name = rowValue,
                        };
                    }

                    casePc.Color = color;
                    break;

                case "Case Material":
                    var materialParts = rowValue.Split("/");
                    foreach (var materialPart in materialParts)
                    {
                        var materialName = materialPart.Trim();
                        if (this.caseMaterialRepo.AllAsNoTracking()
                            .Any(x => x.Material.Name == materialName && x.CaseId == casePc.Id))
                        {
                            continue;
                        }

                        var material = this.materialRepo.All().FirstOrDefault(x => x.Name == rowValue);
                        if (material == null)
                        {
                            material = new Material
                            {
                                Name = rowValue,
                            };
                        }

                        var caseMaterial = new CaseMaterial
                        {
                            Material = material,
                            CaseId   = casePc.Id,
                        };

                        casePc.CaseMaterials.Add(caseMaterial);
                    }

                    break;

                case "With Power Supply":
                    bool?hasPowerSupply = null;
                    if (rowValue.ToLower().Contains("no"))
                    {
                        hasPowerSupply = false;
                    }
                    else if (rowValue.ToLower().Contains("yes"))
                    {
                        hasPowerSupply = true;
                    }

                    casePc.HasPowerSupply = hasPowerSupply;
                    break;

                case "Power Supply Mounted":
                    casePc.CasePowerSupplyPosition = Enum.Parse <CasePowerSupplyPosition>(rowValue);
                    break;

                case "Motherboard Compatibility":
                    var formFactorParts = rowValue.Split("/");
                    foreach (var formFactorPart in formFactorParts)
                    {
                        var formFactorName = formFactorPart.Trim();
                        if (this.caseFormFactorRepo.AllAsNoTracking()
                            .Any(x => x.FormFactor.Name == formFactorName && x.CaseId == casePc.Id))
                        {
                            continue;
                        }

                        var formFactor = this.formFactorRepo.All().FirstOrDefault(x => x.Name == formFactorName);
                        if (formFactor == null)
                        {
                            formFactor = new FormFactor
                            {
                                Name = formFactorName,
                            };
                        }

                        var caseFormFactor = new CaseFormFactor
                        {
                            CaseId     = casePc.Id,
                            FormFactor = formFactor,
                        };

                        casePc.CaseFormFactors.Add(caseFormFactor);
                    }

                    break;

                case "Side Panel Window":
                    bool?hasPanelWindow = null;
                    if (rowValue.ToLower().Contains("no"))
                    {
                        hasPanelWindow = false;
                    }
                    else if (rowValue.ToLower().Contains("yes"))
                    {
                        hasPanelWindow = true;
                    }

                    casePc.SidePanelWindow = hasPanelWindow;
                    break;

                case "Dust Filters":
                    casePc.DustFilters = rowValue;
                    break;

                case "Internal 3.5\" Drive Bays":
                    var driveBay3point5Match = this.MatchOneOrMoreDigits.Match(rowValue);
                    if (!driveBay3point5Match.Success)
                    {
                        continue;
                    }

                    casePc.DriveBay3point5 = byte.Parse(driveBay3point5Match.Value);
                    break;

                case "Internal 2.5\" Drive Bays":
                    var driveBay2point5Match = this.MatchOneOrMoreDigits.Match(rowValue);
                    if (!driveBay2point5Match.Success)
                    {
                        continue;
                    }

                    casePc.DriveBay2point5 = byte.Parse(driveBay2point5Match.Value);
                    break;

                case "Expansion Slots":
                    var expansionSlotsMatch = this.MatchOneOrMoreDigits.Match(rowValue);
                    if (!expansionSlotsMatch.Success)
                    {
                        continue;
                    }

                    casePc.ExpansionSlots = byte.Parse(expansionSlotsMatch.Value);
                    break;

                case "Front Ports":
                    casePc.FrontPorts = rowValue;
                    break;

                case "Fan Options":
                    casePc.FanOptions = rowValue;
                    break;

                case "Radiator Options":
                    casePc.RadioatorOptions = rowValue;
                    break;

                case "Max GPU Length":
                    var gpuLenghtMatch = this.MatchOneOrMoreDigits.Match(rowValue);
                    if (!gpuLenghtMatch.Success)
                    {
                        continue;
                    }

                    casePc.MaxGPULength = short.Parse(gpuLenghtMatch.Value);
                    break;

                case "Max CPU Cooler Height":
                    var cpuCoolerHeightMatch = this.MatchOneOrMoreDigits.Match(rowValue);
                    if (!cpuCoolerHeightMatch.Success)
                    {
                        continue;
                    }

                    casePc.MaxCPUCoolerHeight = short.Parse(cpuCoolerHeightMatch.Value);
                    break;

                case "Max PSU Length":
                    var psuLenghtMatch = this.MatchOneOrMoreDigits.Match(rowValue);
                    if (!psuLenghtMatch.Success)
                    {
                        continue;
                    }

                    casePc.MaxPSULenght = short.Parse(psuLenghtMatch.Value);
                    break;

                case "Dimensions (H x W x D)":
                    var dimensions        = rowValue.Split("{n}")[0];
                    var dimensionsMatches = this.MatchOneOrMoreDigitsFloat.Matches(dimensions);
                    if (dimensionsMatches.Count >= 3)
                    {
                        casePc.Height = this.MatchAndParseFloat(dimensionsMatches[0].Value) * 2.54F;
                        casePc.Width  = this.MatchAndParseFloat(dimensionsMatches[1].Value) * 2.54F;
                        casePc.Depth  = this.MatchAndParseFloat(dimensionsMatches[2].Value) * 2.54F;
                    }

                    break;

                case "Weight":
                    casePc.Weight = this.MatchAndParseFloat(rowValue) * 0.45F;
                    break;

                case "Features":
                    casePc.Features = rowValue;
                    break;

                case "Date First Available":
                    casePc.FirstAvailable = DateTime.Parse(rowValue);
                    break;
                }
            }

            if (casePc.Model == null)
            {
                var message = "Invalid Model.";
                this.logger.LogWarning(message);
                return(message);
            }

            await this.caseRepo.AddAsync(casePc);

            await this.caseRepo.SaveChangesAsync();

            var successMessage = $"Successfully added {casePc.Model}.";

            this.logger.LogInformation(successMessage);
            return(successMessage);
        }
        private void CreateStorages()
        {
            var formFactor35 = new FormFactor()
            {
                Name = "3.5"
            };
            var conInterface = new ConnectionInterface()
            {
                Name = "SATA 6 GB/s"
            };
            var hdd = new PCItemType()
            {
                Name = "7200RPM"
            };

            this.storageService.Create(new Storage()
            {
                Name = "Western Digital Caviar Blue", Capacity = "1TB", Cache = 64, FormFactor = formFactor35, Interface = conInterface, Type = hdd, Price = 44.08M, ImageSrc = "~/images/Storage/09a31f32abb3daaf5ed9b849bd60e675.256p (1).jpg"
            });
            var formFactor25 = new FormFactor()
            {
                Name = "M2"
            };
            var ssd = new PCItemType()
            {
                Name = "SSD"
            };

            conInterface = new ConnectionInterface()
            {
                Name = "SATA 6 GB/s"
            };
            this.storageService.Create(new Storage()
            {
                Name = "Samsung 860 Evo", Capacity = "1TB", Cache = 1024, FormFactor = formFactor25, Interface = conInterface, Type = ssd, Price = 149.99M, ImageSrc = "~/images/Storage/09a31f32abb3daaf5ed9b849bd60e675.256p.jpg"
            });
            formFactor25 = new FormFactor()
            {
                Name = "M2"
            };
            ssd = new PCItemType()
            {
                Name = "SSD"
            };
            conInterface = new ConnectionInterface()
            {
                Name = "SATA 6 GB/s"
            };
            this.storageService.Create(new Storage()
            {
                Name = "Smasung 970 Evo", Capacity = "250GB", Cache = 64, FormFactor = formFactor25, Interface = conInterface, Type = ssd, Price = 87.99M, ImageSrc = "~/images/Storage/41qR7C253KL.jpg"
            });
            formFactor25 = new FormFactor()
            {
                Name = "M2"
            };
            ssd = new PCItemType()
            {
                Name = "SSD"
            };
            conInterface = new ConnectionInterface()
            {
                Name = "SATA 6 GB/s"
            };
            this.storageService.Create(new Storage()
            {
                Name = "Samsung 860 QVO", Capacity = "500GB", Cache = 64, FormFactor = formFactor25, Interface = conInterface, Type = ssd, Price = 49.99M, ImageSrc = "~/images/Storage/41UKoJx2tZL.jpg"
            });
            formFactor25 = new FormFactor()
            {
                Name = "M2"
            };
            ssd = new PCItemType()
            {
                Name = "SSD"
            };
            conInterface = new ConnectionInterface()
            {
                Name = "SATA 6 GB/s"
            };
            this.storageService.Create(new Storage()
            {
                Name = "Kingston A400", Capacity = "480GB", Cache = 64, FormFactor = formFactor25, Interface = conInterface, Type = ssd, Price = 168.99M, ImageSrc = "~/images/Storage/72ac6b04347d22c2592029d4a49bc5ed.256p.jpg"
            });
            formFactor25 = new FormFactor()
            {
                Name = "M2"
            };
            ssd = new PCItemType()
            {
                Name = "SSD"
            };
            conInterface = new ConnectionInterface()
            {
                Name = "SATA 6 GB/s"
            };
            this.storageService.Create(new Storage()
            {
                Name = "Intel 660p Series", Capacity = "2TB", Cache = 64, FormFactor = formFactor25, Interface = conInterface, Type = ssd, Price = 79.98M, ImageSrc = "~/images/Storage/c7b5b7dacbecdcdd0e073b761193eef6.256p.jpg"
            });
        }
示例#19
0
        private static void DetectPlatfrom(this string userAgent, out FormFactor formFactor, out PlarformType plarformType, out string osVersion)
        {
            var theData = userAgent.ToLower().SubstringBetween('(', ')').Split(';');


            foreach (var s in theData)
            {
                if (s.StartsWith("series 60"))
                {
                    plarformType = PlarformType.Symbian;
                    formFactor   = FormFactor.Mobile;
                    osVersion    = null;
                    return;
                }


                if (s.StartsWith("android"))
                {
                    plarformType = PlarformType.Android;
                    formFactor   = FormFactor.Mobile;
                    osVersion    = null;
                    return;
                }

                if (s.StartsWith("blackberry"))
                {
                    plarformType = PlarformType.BlackBerry;
                    formFactor   = FormFactor.Mobile;
                    osVersion    = null;
                    return;
                }

                if (s.StartsWith("iphone"))
                {
                    plarformType = PlarformType.Apple;
                    formFactor   = FormFactor.Mobile;
                    osVersion    = null;
                    return;
                }

                if (s.StartsWith("ipad"))
                {
                    plarformType = PlarformType.Apple;
                    formFactor   = FormFactor.Tablet;
                    osVersion    = null;
                    return;
                }

                if (s.StartsWith("windows nt"))
                {
                    plarformType = PlarformType.Windows;
                    formFactor   = FormFactor.Desktop;
                    osVersion    = WindowsVersions.GetExtendedInfo(s.SubstringFromString("windows nt").Trim());
                    return;
                }


                if (s.StartsWith("windows mobile"))
                {
                    plarformType = PlarformType.Windows;
                    formFactor   = FormFactor.Mobile;
                    osVersion    = null;
                    return;
                }
            }

            plarformType = PlarformType.Unknown;
            formFactor   = FormFactor.Unknown;
            osVersion    = null;
        }
        private void CreateMotherboards()
        {
            var am4SocketType = new PCItemType()
            {
                Name = "AM4"
            };
            var motherboardFormFactor = new FormFactor()
            {
                Name = "ATX"
            };

            this.motherboardService.Create(new Motherboard()
            {
                Name = "MSI B450 TOMAHAWK", MaxRam = 64, RamSlots = 4, Price = 111.99M, FormFactor = motherboardFormFactor, SocketType = am4SocketType, ImageSrc = "~/images/Motherboard/51DZf-KOjZL.jpg"
            });
            motherboardFormFactor = new FormFactor()
            {
                Name = "ATX"
            };
            am4SocketType = new PCItemType()
            {
                Name = "AM4"
            };
            this.motherboardService.Create(new Motherboard()
            {
                Name = "Asus ROG STRIX B450-F GAMING", MaxRam = 64, RamSlots = 4, Price = 129.99M, FormFactor = motherboardFormFactor, SocketType = am4SocketType, ImageSrc = "~/images/Motherboard/65d2e2e1dd6c41fe051500c6d88ffe0c.256p.jpg"
            });
            am4SocketType = new PCItemType()
            {
                Name = "AM4"
            };
            motherboardFormFactor = new FormFactor()
            {
                Name = "ATX"
            };
            this.motherboardService.Create(new Motherboard()
            {
                Name = "Gigabyte GA-A320M-S2H", MaxRam = 32, RamSlots = 4, Price = 54.99M, FormFactor = motherboardFormFactor, SocketType = am4SocketType, ImageSrc = "~/images/Motherboard/66e5b5e4d0a52b6a2f99bb53bf52eee7.256p.jpg"
            });
            var lga1151SockeType = new PCItemType()
            {
                Name = "LGA1151"
            };

            motherboardFormFactor = new FormFactor()
            {
                Name = "ATX"
            };
            this.motherboardService.Create(new Motherboard()
            {
                Name = "Gigabyte Z390 AORUS PRO WIFI", MaxRam = 128, RamSlots = 4, Price = 183.98M, FormFactor = motherboardFormFactor, SocketType = lga1151SockeType, ImageSrc = "~/images/Motherboard/7fe5cb1d35e7385f6cd195e787ab9274.256p.jpg"
            });
            lga1151SockeType = new PCItemType()
            {
                Name = "LGA1151"
            };
            motherboardFormFactor = new FormFactor()
            {
                Name = "ATX"
            };
            this.motherboardService.Create(new Motherboard()
            {
                Name = "MSI MPG Z390 GAMING EDGE AC", MaxRam = 128, RamSlots = 4, Price = 189.99M, FormFactor = motherboardFormFactor, SocketType = lga1151SockeType, ImageSrc = "~/images/Motherboard/a735153cb96091c6e69f267386e177df.256p.jpg"
            });
            lga1151SockeType = new PCItemType()
            {
                Name = "LGA1151"
            };
            motherboardFormFactor = new FormFactor()
            {
                Name = "ATX"
            };
            this.motherboardService.Create(new Motherboard()
            {
                Name = "Gigabyte Z390 UD", MaxRam = 128, RamSlots = 4, Price = 114.99M, FormFactor = motherboardFormFactor, SocketType = lga1151SockeType, ImageSrc = "~/images/Motherboard/de8a63a66404b62463a5c4f898131b38.256p.jpg"
            });
        }
示例#21
0
        public async Task <string> ScrapeFromProductPageAsync(string productUrl)
        {
            if (productUrl.Contains("Combo"))
            {
                var message = "Invalid Product.";
                this.logger.LogWarning(message);
                return(message);
            }

            var document = await this.Context.OpenAsync(productUrl);

            var motherboardDataTableRows = this.GetAllTablesRows(document);
            var motherboardDataTables    = this.GetAllTables(document);
            var motherboard = new Motherboard
            {
                Price    = this.GetPrice(document),
                ImageUrl = this.GetImageUrl(document),
                Category = this.GetCategoryFromUrl(productUrl),
            };

            foreach (var table in motherboardDataTables)
            {
                var caption   = table.FirstElementChild.TextContent;
                var tableRows = table.QuerySelectorAll("tr");

                switch (caption)
                {
                case "Onboard Audio":
                    var audioChipsetName = tableRows[0].LastChild.TextContent.Trim();
                    var firstLine        = tableRows[1].LastElementChild
                                           .InnerHtml.Replace("<br><br>", "{n}").Replace("<br>", "{n}").Trim().Split("{n}");
                    var   matches  = this.MatchOneOrMoreDigitsFloat.Matches(firstLine[0]);
                    float channels = 0;
                    foreach (Match match in matches)
                    {
                        channels = Math.Max(channels, float.Parse(match.Value, CultureInfo.InvariantCulture));
                    }

                    var audioChipset = this.audioChipsetRepo.All().FirstOrDefault(x => x.Name == audioChipsetName);
                    if (audioChipset == null)
                    {
                        audioChipset = new AudioChipset
                        {
                            Name     = audioChipsetName,
                            Channels = channels,
                        };
                    }

                    motherboard.AudioChipset = audioChipset;
                    break;

                case "Onboard LAN":
                    var lanChipsetName = tableRows[0].LastChild.TextContent.Trim();
                    var lanChipset     = this.lanChipsetRepo.All().FirstOrDefault(x => x.Name == lanChipsetName);
                    if (lanChipset == null)
                    {
                        lanChipset = new LanChipset
                        {
                            Name = lanChipsetName,
                        };
                    }

                    motherboard.LanChipset = lanChipset;
                    break;

                case "Rear Panel Ports":
                    var ports = string.Empty;
                    foreach (var tableRow in tableRows)
                    {
                        if (tableRow.FirstChild.TextContent != "Back I/O Ports")
                        {
                            ports += tableRow.LastChild.TextContent.Trim() + Environment.NewLine;
                        }
                    }

                    if (!string.IsNullOrEmpty(ports))
                    {
                        motherboard.RearPanelPorts = ports;
                    }

                    break;
                }
            }

            this.logger.LogInformation(productUrl);

            foreach (var tableRow in motherboardDataTableRows)
            {
                var rowName  = tableRow.FirstChild.TextContent.Trim();
                var rowValue = tableRow.LastElementChild.InnerHtml.Replace("<br><br>", "{n}").Replace("<br>", "{n}").Trim();

                switch (rowName)
                {
                case "Model":
                    if (this.motherboardRepo.AllAsNoTracking().Any(x => x.Model == rowValue))
                    {
                        var message = "Already exists.";
                        this.logger.LogWarning(message);
                        return(message);
                    }

                    motherboard.Model = rowValue;
                    break;

                case "Brand":
                    var brand = this.brandRepo.All().FirstOrDefault(x => x.Name == rowValue);
                    if (brand == null)
                    {
                        brand = new Brand
                        {
                            Name = rowValue,
                        };
                    }

                    motherboard.Brand = brand;
                    break;

                case "Series":
                    var seriesName = rowValue.Replace("Series", string.Empty).Trim();
                    var series     = this.seriesRepo.All().FirstOrDefault(x => x.Name == seriesName);
                    if (series == null)
                    {
                        series = new Series
                        {
                            Name = seriesName,
                        };
                    }

                    motherboard.Series = series;
                    break;

                case "CPU Socket Type":
                    var socket = this.socketRepo.All().FirstOrDefault(x => x.Name == rowValue);
                    if (socket == null)
                    {
                        socket = new Socket
                        {
                            Name = rowValue,
                        };
                    }

                    motherboard.Socket = socket;
                    break;

                case "Chipset":
                    var chipset = this.chipsetreopo.All().FirstOrDefault(x => x.Name == rowValue);
                    if (chipset == null)
                    {
                        chipset = new MothrboardChipset
                        {
                            Name = rowValue,
                        };
                    }

                    motherboard.Chipset = chipset;
                    break;

                case "Number of Memory Slots":
                    motherboard.MemorySlots = int.Parse(this.MatchOneOrMoreDigits.Match(rowValue).Value);
                    break;

                case "Memory Standard":
                    var lines = rowValue.Split("{n}");
                    foreach (var line in lines)
                    {
                        var typeMatch = new Regex(@"DDR\d\w?").Match(line);
                        if (!typeMatch.Success)
                        {
                            continue;
                        }

                        var memoryTypeAsString = typeMatch.Value;
                        var matches            = new Regex(@"\d{3,4}").Matches(line);
                        foreach (Match match in matches)
                        {
                            var memorySpeedAsShort = short.Parse(match.Value);

                            var motherboardMemoryType = this.motherboardMemoryTypeRepo.All()
                                                        .FirstOrDefault(x => x.MotherboardId == motherboard.Id && x.MemoryType.Type == memoryTypeAsString &&
                                                                        x.MemorySpeed.Speed == memorySpeedAsShort);
                            if (motherboardMemoryType != null)
                            {
                                continue;
                            }

                            var memoryType = this.memoryTypeRepo.All().FirstOrDefault(x => x.Type == memoryTypeAsString);
                            if (memoryType == null)
                            {
                                memoryType = new MemoryType
                                {
                                    Type = memoryTypeAsString,
                                };
                                await this.memoryTypeRepo.AddAsync(memoryType);

                                await this.memoryTypeRepo.SaveChangesAsync();
                            }

                            var memorySpeed = this.memorySpeedRepo.All().FirstOrDefault(x => x.Speed == memorySpeedAsShort);
                            if (memorySpeed == null)
                            {
                                memorySpeed = new MemorySpeed
                                {
                                    Speed = memorySpeedAsShort,
                                };
                                await this.memorySpeedRepo.AddAsync(memorySpeed);

                                await this.memorySpeedRepo.SaveChangesAsync();
                            }

                            motherboardMemoryType = new MotherboardMemoryType
                            {
                                Motherboard = motherboard,
                                MemoryType  = memoryType,
                                MemorySpeed = memorySpeed,
                            };
                            motherboard.MotherboardMemoryType.Add(motherboardMemoryType);
                        }
                    }

                    break;

                case "Maximum Memory Supported":
                    var maximumMemory = int.Parse(this.MatchOneOrMoreDigits.Match(rowValue).Value);
                    if (rowValue.ToLower().Contains("gb"))
                    {
                        maximumMemory *= 1024;
                    }

                    motherboard.MaxMemorySupport = maximumMemory;
                    break;

                case "Channel Supported":
                    byte?channel = rowValue.ToLower() switch
                    {
                        "dual channel" => 2,
                        "triple channel" => 3,
                        "quad channel" => 4,
                        _ => null,
                    };
                    motherboard.MemoryChannel = channel;
                    break;

                case "PCI Express 3.0 x16":
                    motherboard.PCIe3x16 = this.GetNumberOfSlots(@"(?'slots'\d) x PCI", rowValue);
                    break;

                case "PCI Express 4.0 x16":
                    motherboard.PCIe4x16 = this.GetNumberOfSlots(@"(?'slots'\d) x PCI", rowValue);
                    break;

                case "PCI Express x1":
                    motherboard.PCIex1 = this.GetNumberOfSlots(@"(?'slots'\d) x PCI", rowValue);
                    break;

                case "SATA 6Gb/s":
                    motherboard.Sata6Gbs = this.GetNumberOfSlots(@"(?'slots'\d) x SATA", rowValue);
                    break;

                case "SATA 3Gb/s":
                    motherboard.Sata3Gbs = this.GetNumberOfSlots(@"(?'slots'\d) x SATA", rowValue);
                    break;

                case "M.2":
                    motherboard.Mdot2 = this.GetNumberOfSlots(@"(?'slots'\d) x M\.", rowValue);
                    break;

                case "Back I/O Ports":
                    motherboard.RearPanelPorts = rowValue.Replace("\n", "NewLine");
                    break;

                case "Form Factor":
                    var formFactor = this.formFactorRepo.All().FirstOrDefault(x => x.Name == rowValue);
                    if (formFactor == null)
                    {
                        formFactor = new FormFactor
                        {
                            Name = rowValue,
                        };
                    }

                    motherboard.FormFactor = formFactor;
                    break;

                case "Dimensions (W x L)":
                    var dimensionsSplit = rowValue.Split('x');
                    var widthInInch     = this.MatchAndParseFloat(dimensionsSplit[0]);
                    var lengthInInch    = this.MatchAndParseFloat(dimensionsSplit[1]);
                    motherboard.Width  = widthInInch * 2.54F;
                    motherboard.Length = lengthInInch * 2.54F;
                    break;

                case "Features":
                    motherboard.Features = rowValue;
                    break;

                case "Date First Available":
                    motherboard.FirstAvailable = DateTime.Parse(rowValue);
                    break;
                }
            }

            if (motherboard.Model == null)
            {
                var message = "Invalid Model.";
                this.logger.LogWarning(message);
                return(message);
            }

            await this.motherboardRepo.AddAsync(motherboard);

            await this.motherboardRepo.SaveChangesAsync();

            var successMessage = $"Successfully added {motherboard.Model}.";

            this.logger.LogInformation(successMessage);
            return(successMessage);
        }
示例#22
0
        private static DeviceInfo ParseIphoneIPad(string userAgent, string[] platformInfo, FormFactor formFactor)
        {
            var result = new DeviceInfo
            {
                PlarformType = PlarformType.Apple,
                FormFactor = formFactor,
                OsVersion = null
            };

            var browserData = userAgent.SubstringFromChar(')', 1)
   .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            var browserInfo = browserData.FirstOrDefault(itm => itm.StartsWith("CriOS"));
            if (browserInfo != null)
            {
                result.AppHost = ApplicationHost.Chrome;
                result.AppVersion = browserInfo.SubstringFromChar('/');
                return result;
            }

            browserInfo = browserData.FirstOrDefault(itm => itm.StartsWith("OPiOS"));
            if (browserInfo != null)
            {
                result.AppHost = ApplicationHost.Opera;
                result.AppVersion = browserInfo.SubstringFromChar('/');
                return result;
            }



            browserInfo = browserData.FirstOrDefault(itm => itm.StartsWith("UCBrowser"));
            if (browserInfo != null)
            {
                result.AppHost = ApplicationHost.UcBrowser;
                result.AppVersion = browserInfo.SubstringFromChar('/');
                return result;
            }

            browserInfo = browserData.FirstOrDefault(itm => itm.StartsWith("MicroMessenger"));
            if (browserInfo != null)
            {
                result.AppHost = ApplicationHost.WeChat;
                result.AppVersion = browserInfo.SubstringFromChar('/');
                return result;
            }
            
            browserInfo = browserData.FirstOrDefault(itm => itm.StartsWith("Version"));
            if (browserInfo != null)
            {
                result.AppHost = ApplicationHost.Safari;
                result.AppVersion = browserInfo.SubstringFromChar('/');
                return result;
            }


            return result;

        }
示例#23
0
 public SimCard(FormFactor formFactor, string phoneNumber) : this()
 {
     Form        = formFactor;
     PhoneNumber = phoneNumber;
 }
示例#24
0
        private static DeviceInfo ParseIphoneIPad(string userAgent, string[] platformInfo, FormFactor formFactor)
        {
            var result = new DeviceInfo
            {
                PlarformType = PlarformType.Apple,
                FormFactor   = formFactor,
                OsVersion    = null
            };

            var browserData = userAgent.SubstringFromChar(')', 1)
                              .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            var browserInfo = browserData.FirstOrDefault(itm => itm.StartsWith("CriOS"));

            if (browserInfo != null)
            {
                result.AppHost    = ApplicationHost.Chrome;
                result.AppVersion = browserInfo.SubstringFromChar('/');
                return(result);
            }

            browserInfo = browserData.FirstOrDefault(itm => itm.StartsWith("OPiOS"));
            if (browserInfo != null)
            {
                result.AppHost    = ApplicationHost.Opera;
                result.AppVersion = browserInfo.SubstringFromChar('/');
                return(result);
            }



            browserInfo = browserData.FirstOrDefault(itm => itm.StartsWith("UCBrowser"));
            if (browserInfo != null)
            {
                result.AppHost    = ApplicationHost.UcBrowser;
                result.AppVersion = browserInfo.SubstringFromChar('/');
                return(result);
            }

            browserInfo = browserData.FirstOrDefault(itm => itm.StartsWith("MicroMessenger"));
            if (browserInfo != null)
            {
                result.AppHost    = ApplicationHost.WeChat;
                result.AppVersion = browserInfo.SubstringFromChar('/');
                return(result);
            }

            browserInfo = browserData.FirstOrDefault(itm => itm.StartsWith("Version"));
            if (browserInfo != null)
            {
                result.AppHost    = ApplicationHost.Safari;
                result.AppVersion = browserInfo.SubstringFromChar('/');
                return(result);
            }


            return(result);
        }
示例#25
0
        public async Task <string> ScrapeFromProductPageAsync(string productUrl)
        {
            if (productUrl.Contains("Combo"))
            {
                var message = "Invalid Product.";
                this.logger.LogWarning(message);
                return(message);
            }

            var document = await this.Context.OpenAsync(productUrl);

            var hddDataTableRows = this.GetAllTablesRows(document);
            var hddDataTables    = this.GetAllTables(document);
            var hdd = new HDD
            {
                Price    = this.GetPrice(document),
                ImageUrl = this.GetImageUrl(document),
                Category = this.GetCategoryFromUrl(productUrl),
            };

            this.logger.LogInformation(productUrl);

            foreach (var tableRow in hddDataTableRows)
            {
                var rowName  = tableRow.FirstChild.TextContent.Trim();
                var rowValue = tableRow.LastElementChild.InnerHtml.Replace("<br><br>", "{n}").Replace("<br>", "{n}").Trim();

                switch (rowName)
                {
                case "Model":
                    if (this.hddRepo.AllAsNoTracking().Any(x => x.Model == rowValue))
                    {
                        var message = "Already exists.";
                        this.logger.LogWarning(message);
                        return(message);
                    }

                    hdd.Model = rowValue;
                    break;

                case "Brand":
                    hdd.Brand = this.GetOrCreateBrand(this.brandRepo, rowValue);
                    break;

                case "Series":
                    hdd.Series = this.GetOrCreateSeries(this.seriesRepo, rowValue);
                    break;

                case "Interface":
                    var hddInterface = this.interfaceRepo.All().FirstOrDefault(x => x.Name == rowValue);
                    if (hddInterface == null)
                    {
                        hddInterface = new Interface
                        {
                            Name = rowValue,
                        };
                    }

                    hdd.Interface = hddInterface;
                    break;

                case "Capacity":
                    var capacityMatch = this.MatchOneOrMoreDigits.Match(rowValue);
                    if (!capacityMatch.Success)
                    {
                        continue;
                    }

                    var capacity = short.Parse(capacityMatch.Value);
                    if (rowValue.ToLower().Contains("tb"))
                    {
                        capacity *= 1024;
                    }

                    hdd.CapacityGb = capacity;
                    break;

                case "RPM":
                    var rpmMatch = this.MatchOneOrMoreDigits.Match(rowValue);
                    if (!rpmMatch.Success)
                    {
                        continue;
                    }

                    hdd.RevolutionsPerMinute = short.Parse(rpmMatch.Value);
                    break;

                case "Cache":
                    var cacheMatch = this.MatchOneOrMoreDigits.Match(rowValue);
                    if (!cacheMatch.Success)
                    {
                        continue;
                    }

                    var cache = int.Parse(cacheMatch.Value);
                    if (rowValue.ToLower().Contains("mb"))
                    {
                        cache *= 1024;
                    }

                    hdd.CacheKb = cache;
                    break;

                case "Features":
                    hdd.Features = rowValue;
                    break;

                case "Usage":
                    var usage = this.usageRepo.All().FirstOrDefault(x => x.Name == rowValue);
                    if (usage == null)
                    {
                        usage = new DiskForUsage
                        {
                            Name = rowValue,
                        };
                    }

                    hdd.Usage = usage;
                    break;

                case "Form Factor":
                    var formFactor = this.formFactorRepo.All().FirstOrDefault(x => x.Name == rowValue);
                    if (formFactor == null)
                    {
                        formFactor = new FormFactor
                        {
                            Name = rowValue,
                        };
                    }

                    hdd.FormFactor = formFactor;
                    break;

                case "Height (maximum)":
                    hdd.Height = this.MatchAndParseFloat(rowValue);
                    break;

                case "Width (maximum)":
                    hdd.Width = this.MatchAndParseFloat(rowValue);
                    break;

                case "Length (maximum)":
                    hdd.Length = this.MatchAndParseFloat(rowValue);
                    break;

                case "Date First Available":
                    hdd.FirstAvailable = DateTime.Parse(rowValue);
                    break;
                }
            }

            if (hdd.Model == null)
            {
                var message = "Invalid Model.";
                this.logger.LogWarning(message);
                return(message);
            }

            await this.hddRepo.AddAsync(hdd);

            await this.hddRepo.SaveChangesAsync();

            var successMessage = $"Successfully added {hdd.Model}.";

            this.logger.LogInformation(successMessage);
            return(successMessage);
        }
示例#26
0
 public Simcard(string op, FormFactor formfactor, NetworkType network)
 {
     Operator         = op;
     FormFactor       = formfactor;
     SupportedNetwork = network;
 }
 public GeneralPhone(FormFactor formFactor, string serialNumber)
 {
     SerialNumber = serialNumber;
     FormFactor   = formFactor;
 }
示例#28
0
 public override string ToString()
 {
     return(SupportedNetwork.ToString() + " " + FormFactor.ToString() + " by " + Operator);
 }
示例#29
0
 public MotherboardModel(string name, float mass, List <ConnectionInterface> connectionInterfacePool, Socket socket, FormFactor formFactor) : base(name, connectionInterfacePool, mass)
 {
     this.socket     = socket;
     this.formFactor = formFactor;
 }