private void FillBoxSetTable(int boxId) { List <Tuple <string, string> > boxList = new List <Tuple <string, string> >(); BoxSet box = ConfigurationDAL.GetBoxSetById(boxId); Cpu cp = ConfigurationDAL.GetCpulById(box.cupId); Hdd hdd = ConfigurationDAL.GetHddlById(box.hddId); VideoCard video = ConfigurationDAL.GetVideoCardlById(box.videoCardId); boxList.Add(new Tuple <string, string>("номер", box.id.ToString())); boxList.Add(new Tuple <string, string>("процесор", cp.name)); boxList.Add(new Tuple <string, string>("процесорен производител", cp.producer)); boxList.Add(new Tuple <string, string>("дъно", box.motherboard)); boxList.Add(new Tuple <string, string>("рам", box.ram)); boxList.Add(new Tuple <string, string>("видео карта", video.name)); boxList.Add(new Tuple <string, string>("производител на видео карта", video.producer)); boxList.Add(new Tuple <string, string>("охлаждане", box.coolingSystem)); boxList.Add(new Tuple <string, string>("захранване", box.powerSupply)); boxList.Add(new Tuple <string, string>("лан карта", box.expansionCards)); boxList.Add(new Tuple <string, string>("хард диск", hdd.name)); boxList.Add(new Tuple <string, string>("производител на хард диск", hdd.producer)); boxList.Add(new Tuple <string, string>("преносими устройства", box.removableDevices)); boxList.Add(new Tuple <string, string>("кутия", box.box)); BoxSetGrid.DataSource = boxList; BoxSetGrid.DataBind(); }
private void ListInfoAStorageList(List <Storage> storegeList) { foreach (Storage store in storegeList) { if (store is Hdd) { Hdd hdd = (Hdd)store; ShConsole.ConsoleInfo(hdd.ToString()); } else if (store is DvD_RW) { DvD_RW dvd_rw = (DvD_RW)store; ShConsole.ConsoleInfo(dvd_rw.ToString()); } else if (store is DVD) { DVD dvd = (DVD)store; ShConsole.ConsoleInfo(dvd.ToString()); } else if (store is Floppy) { Floppy floppy = (Floppy)store; ShConsole.ConsoleInfo(floppy.ToString()); } } }
public void TestGetCommand() { Hdd hdd = new Hdd(); List <String> devices = hdd.getCommand("df", "-l -B M"); Assert.IsNotEmpty(devices); }
public void GetPartsInfo() { Console.WriteLine($"CPU: {Cpu.Name}"); Console.WriteLine($"HDD: {Hdd.Name}"); Console.WriteLine($"RAM: {Ram.Name}"); Console.WriteLine($"VGA: {Vga.Name}"); Console.WriteLine($"Performance factor: {Cpu.PerformanceFactor() + Hdd.PerformanceFactor() + Ram.PerformanceFactor() + Vga.PerformanceFactor()}"); }
public async void AddHddAsyncTest() { ILaptopService laptopService = GetServiceObject(); Hdd hdd = new Hdd(); hdd.Type = "5 TB"; hdd.Price = "500"; bool flag = await laptopService.AddHddAsync(hdd); Assert.True(flag); }
private string ReadKey() { try { return(this._hashService.Sha256(Bios.GetId() + Hdd.GetId() + Processor.GetId())); } catch { return("ZGVmYXVsdF9pZA=="); } }
protected void btn_hdd_Click(object sender, EventArgs e) { Hdd h = new Hdd(); h.AkcioSzazalek = Double.Parse(tb_akcio.Text); h.Ar = Int32.Parse(tb_ar.Text); h.GyartoId = Int64.Parse(lb_gyarto.SelectedValue); h.Leiras = tb_leiras.Text; h.Nev = tb_nev.Text; h.RaktaronDarab = Int32.Parse(tb_darab.Text); h.CsatoloId = Int64.Parse(lb_hdd_csatolo.Text); h.Meret = Int32.Parse(tb_hdd_meret.Text); Adatbazis.AddTermek(h); }
private int InsertHdd() { string hdd = this.boxSet.GetHddAndHddProducer().Item1; string hddProducer = this.boxSet.GetHddAndHddProducer().Item2; CustomComputersAspEntities db = new CustomComputersAspEntities(); Hdd match = db.Hdds.FirstOrDefault(h => h.name == hdd && h.producer == hddProducer); if (match == null) { db.AddToHdds(new Hdd() { name = hdd, producer = hddProducer }); db.SaveChanges(); match = db.Hdds.FirstOrDefault(h => h.name == hdd && h.producer == hddProducer); } return(match.id); }
public async Task <bool> AddHddAsync(Hdd hdd) { bool result = false; try { using (var firstConnection = new SqliteConnection(DbConnection.connectionString)) { firstConnection.Open(); var insertCommand = firstConnection.CreateCommand(); insertCommand.CommandText = @"INSERT INTO Hdd(type, price) VALUES('" + hdd.Type + "', '" + hdd.Price + "')"; int res = insertCommand.ExecuteNonQuery(); if (res > 0) { result = true; } } } catch (Exception) { } return(await Task.FromResult(result)); }
public void AddServerHardDrives() { Config.waitServerReady(server.Id); int prevoiousHDDCounts = 0; prevoiousHDDCounts = server.Hardware.Hdds.Count; var result = client.ServerHdds.Create(new POCO.Requests.Servers.AddHddRequest() { Hdds = new System.Collections.Generic.List <POCO.Requests.Servers.HddRequest>() { { new POCO.Requests.Servers.HddRequest() { Size = 20, IsMain = false } }, } }, server.Id); Config.waitServerReady(server.Id); var resultserver = client.Servers.Show(result.Id); hddToUpdate = resultserver.Hardware.Hdds.Where(hdd => !hdd.IsMain).FirstOrDefault(); Assert.IsNotNull(result); Assert.IsTrue(result.Hardware.Hdds.Count > 0); var updateResult = client.ServerHdds.Update(new POCO.Requests.Servers.UpdateHddRequest() { Size = hddToUpdate.Size + 10 }, server.Id, hddToUpdate.Id); Config.waitServerReady(server.Id); Assert.IsNotNull(updateResult); //delete HDD DeleteHardDrive(); }
static void Main(string[] args) { Flash flash = new Flash { CapturedSize = 4, DiskSpeed = 5, Memory = 32, Model = " 3.0", Name = "USB" }; Dvd dvd = new Dvd { CapturedSize = 4, Type = "birterefli", Model = "dvd", Name = "dvd" }; Hdd hdd = new Hdd { Name = "USB", Model = "2.0", Speed = 0.5, Size = 7, CapturedSize = 4 }; hdd.Copy(); flash.Copy(); Console.WriteLine("about media"); Console.WriteLine("HDD"); hdd.PrintDeviceInfo(); Console.WriteLine("DVD"); dvd.PrintDeviceInfo(); Console.WriteLine("Flash"); flash.PrintDeviceInfo(); }
public async Task <bool> AddHddAsync(Hdd hdd) { return(await _laptopDAL.AddHddAsync(_mapper.Map <Model.Hdd>(hdd))); }
public void StorageMenu() { if (System.IO.File.Exists(storesfilepath) && new FileInfo(storesfilepath).Length > 0) { FileHandling.DeserializerProcess(storages, storesfilepath); } if (System.IO.File.Exists(mountedfilepath) && new FileInfo(mountedfilepath).Length > 0) { FileHandling.DeserializerProcess(computer.GetStorages(), mountedfilepath); } while (true) { try { StorageMenuList(); ShConsole.UserInput("Choose a menu: "); string answer = Console.ReadLine().ToLower(); if (answer == "listmounts" || answer == "list mounts") { if (computer.GetStorages().Count == 0) { throw new NullReferenceException("Mount at least one storage first"); } else { ListInfoAStorageList(computer.GetStorages()); } Console.WriteLine(); } else if (answer == "liststores" || answer == "list stores") { if (storages.Count == 0) { throw new NullReferenceException("Make at least one storage first"); } else { ListInfoAStorageList(storages); } Console.WriteLine(); } else if (answer == "addmount" || answer == "add mount") { if (storages.Count == 0) { throw new NullReferenceException("Make one storage at least!"); } else { ListInfoAStorageList(storages); ShConsole.UserInput("Give me the storage Id,which you want put on the computer: "); string addAnswer = Console.ReadLine(); computer.Mount(addAnswer, storages); } Console.WriteLine(); } else if (answer == "usemount" || answer == "use mount") { ListInfoAStorageList(computer.GetStorages()); MountedStorageHandler msh = new MountedStorageHandler(ShConsole, computer); msh.MountedMenu(); Console.WriteLine(); } else if (answer == "addstore" || answer == "add store") { Console.WriteLine("What storage you want to make(Hdd,Dvd,Dvd_rw,Floppy)"); string newstorage = Console.ReadLine().ToLower(); string id = IdGenerator(); if (newstorage == "hdd") { string[] storageParams = new string[] { "Max capacity", "Name" }; List <string> sp = new List <string>(); foreach (string param in storageParams) { ShConsole.UserInput($"Give me {param}: "); sp.Add(Console.ReadLine()); } Storage storage = new Hdd(id, Convert.ToInt32(sp[0]), sp[1]); storages.Add(storage); } else if (newstorage == "dvd" || newstorage == "floppy" || newstorage == "dvd_rw" || newstorage == "dvd-rw" || newstorage == "dvd rw") { ShConsole.UserInput($"Give me the storage Name : "); string name = Console.ReadLine(); if (newstorage == "dvd") { Storage storage = new DVD(id, name); storages.Add(storage); } else if (newstorage == "floppy") { Storage storage = new Floppy(id, name); storages.Add(storage); } else if (newstorage == "dvd_rw" || newstorage == "dvd-rw" || newstorage == "dvd rw") { Storage storage = new DvD_RW(id, name); storages.Add(storage); } } else { throw new ArgumentException("Invalid argument"); } ShConsole.ConsoleInfo($"The {newstorage} storage has been created"); Console.WriteLine(); } else if (answer == "deletestore" || answer == "delete store") { if (storages.Count == 0) { throw new NullReferenceException("Create a storage first please"); } else { ListInfoAStorageList(storages); ShConsole.UserInput("Give me the storage Id you want to delete: "); string deletingStoreId = Console.ReadLine(); for (int i = 0; i < storages.Count; i++) { if (storages[i].Id == deletingStoreId) { ShConsole.UserInput($"Are you sure you want to delete this storage {storages[i].StoreName}?(yes/no): "); string deleteAnswer = Console.ReadLine().ToLower(); if (deleteAnswer == "yes" || deleteAnswer == "y") { ShConsole.ConsoleInfo($"the {storages[i].StoreName} has been deleted"); storages.Remove(storages[i]); } else if (deleteAnswer == "no" || deleteAnswer == "n") { ShConsole.ConsoleInfo("the deleting process has been declined"); } else { throw new ArgumentException("invalid input"); } } else if (storages[i].Id != deletingStoreId && i == storages.Count() - 1) { throw new NullReferenceException("There is no such store"); } } Console.WriteLine(); } } else if (answer == "remove mount" || answer == "removemount") { if (computer.GetStorages().Count == 0) { throw new NullReferenceException("There is no mounted storage"); } else { ListInfoAStorageList(computer.GetStorages()); ShConsole.UserInput("Give me the storage Id you want to remove: "); string removingStoreId = Console.ReadLine(); for (int i = 0; i < computer.GetStorages().Count; i++) { if (computer.GetStorages()[i].Id == removingStoreId) { ShConsole.UserInput($"Are you sure you want to remove this storage {computer.GetStorages()[i].StoreName}?(yes/no) : "); string removeAnswer = Console.ReadLine().ToLower(); if (removeAnswer == "yes" || removeAnswer == "y") { ShConsole.ConsoleInfo($"the {computer.GetStorages()[i].StoreName} has been removed"); storages.Add(computer.GetStorages()[i]); computer.GetStorages().Remove(computer.GetStorages()[i]); } else if (removeAnswer == "no" || removeAnswer == "n") { ShConsole.ConsoleInfo("the removing process has been declined"); } else { throw new ArgumentException("invalid input"); } break; } else if (computer.GetStorages()[i].Id != removingStoreId && i == computer.GetStorages().Count() - 1) { throw new NullReferenceException("There is no such store"); } } } Console.WriteLine(); } else if (answer == "modify mount" || answer == "modifymount") { if (computer.GetStorages().Count == 0) { throw new NullReferenceException("There is no mounted storage"); } else { ListInfoAStorageList(computer.GetStorages()); ShConsole.UserInput("Give me the mounted storage Id you want to modify"); string modifyingMountedStoreId = Console.ReadLine(); for (int i = 0; i < computer.GetStorages().Count; i++) { if (computer.GetStorages()[i].Id == modifyingMountedStoreId) { ShConsole.UserInput($"Are you sure You want to modify the storage NAME?(yes/no): "); string removeAnswer = Console.ReadLine().ToLower(); if (removeAnswer == "yes" || removeAnswer == "y") { ShConsole.UserInput("Give me the new store name: "); string newName = Console.ReadLine(); computer.GetStorages()[i].StoreName = newName; } else if (removeAnswer == "no" || removeAnswer == "n") { ShConsole.ConsoleInfo("the modifying process has been declined"); } else { throw new ArgumentException("invalid input"); } break; } else if (computer.GetStorages()[i].Id != modifyingMountedStoreId && i == computer.GetStorages().Count() - 1) { throw new Exception("There is no such mounted store"); } } } Console.WriteLine(); } else if (answer == "modify store" || answer == "modifystore") { if (storages.Count == 0) { throw new NullReferenceException("There is no unmounted storage"); } else { ListInfoAStorageList(storages); ShConsole.UserInput("Give me the storage Id you want to modify: "); string modifyingStoreId = Console.ReadLine(); for (int i = 0; i < storages.Count; i++) { if (storages[i].Id == modifyingStoreId) { if (storages[i].FileList.Count == 0) { ShConsole.UserInput($"Are you sure You want to modify the storage NAME?(yes/no): "); string removeAnswer = Console.ReadLine().ToLower(); if (removeAnswer == "yes" || removeAnswer == "y") { ShConsole.UserInput("Give me the new store name: "); string newName = Console.ReadLine(); storages[i].StoreName = newName; } else if (removeAnswer == "no" || removeAnswer == "n") { ShConsole.ConsoleInfo("the modifying process has been declined"); } else { throw new ArgumentException("invalid input"); } } else if (storages[i].FileList.Count > 0) { throw new Exception("The store is not empty,you can't modify the name"); } } else if (storages[i].Id != modifyingStoreId && i == computer.GetStorages().Count() - 1) { throw new NullReferenceException("There is no such store"); } } Console.WriteLine(); } } else if (answer == "save") { FileHandling.SerializeProcess(storages, storesfilepath); ShConsole.ConsoleInfo("the storage data has been saved"); FileHandling.SerializeProcess(computer.GetStorages(), mountedfilepath); ShConsole.ConsoleInfo("the mounted storage data has been saved"); Console.WriteLine(); } else if (answer == "exit") { FileHandling.SerializeProcess(storages, storesfilepath); ShConsole.ConsoleInfo("the storage data has been saved"); FileHandling.SerializeProcess(computer.GetStorages(), mountedfilepath); ShConsole.ConsoleInfo("the mounted storage data has been saved"); Console.WriteLine(); ShConsole.ConsoleInfo("Good bye"); break; } else { throw new ArgumentException("invalid argument"); } } catch (Exception ex) { ShConsole.Error(ex.Message); } } }
// Пример Агрегации. public Computer(Hdd hdd, Monitor monitor, Ram ram) { _hdd = hdd; _monitor = monitor; _ram = ram; }
// Пример композиции. public Computer() { _hdd = new Hdd(); _monitor = new Monitor(); _ram = new Ram(); }
public Task <bool> AddHddAsync(Hdd hdd) { return(_laptopService.AddHddAsync(hdd)); }
//check if configuration changed public bool IsConfigChanged() { return (Ram != RamFixed //for desktops check any hdd string changes || (!IsNotebook && Hdd != HddFixed) //for notebooks exclude add/remove hdd events (portable hdd) || (IsNotebook && Hdd != HddFixed && (!string.IsNullOrEmpty(HddFixed) && !Hdd.Contains(HddFixed)) && (!string.IsNullOrEmpty(Hdd) && !HddFixed.Contains(Hdd))) || MotherBoard != MotherBoardFixed || VideoAdapter != VideoAdapterFixed //for notebooks exclude monitor change events || (!IsNotebook && Monitor != MonitorFixed)); }
static void Main(string[] args) { int dvdSpeed = 50; int dvdMemory = 9000; Dvd dvd = new Dvd(); dvd.SetName("Dvd"); dvd.SetModel("Modeldvd"); dvd.SpeedRead = dvdSpeed; dvd.SpeedWrite = dvdSpeed; dvd.SetMemory(dvdMemory); int flashSpeed = 30; int flashMemory = 8000; Flash flash = new Flash(); flash.SetName("Flash-usb"); flash.SetModel("Modelflash"); flash.SetMemory(flashMemory); flash.SetSpeedUsb(flashSpeed); int hddSpeed = 150; int countSection = 2; int amoutSection = 500000; Hdd hdd = new Hdd(hddSpeed, countSection, amoutSection); hdd.SetName("Hdd"); hdd.SetModel("HddModel"); string[] stringsMenu = { "Информация о всех устройствах", "Общая память всех устройств", "Копирование информации на выбранное устройство и рассчет времени копирования", "Рассчет необходимого количества носителей информации для копирования", "Выход" }; ConsoleMenu menu = new ConsoleMenu(stringsMenu); int menuResult; do { menuResult = menu.PrintMenu(); menuResult++; switch (menuResult) { case 1: string info = dvd.GetInfo(); Console.WriteLine(info); Console.WriteLine("__________________________________________"); info = hdd.GetInfo(); Console.WriteLine(info); Console.WriteLine("__________________________________________"); info = flash.GetInfo(); Console.WriteLine(info); Console.WriteLine("__________________________________________"); Console.ReadLine(); break; case 2: int allMemory = hdd.FreeMemoryInfo() + dvd.FreeMemoryInfo() + flash.FreeMemoryInfo(); Console.WriteLine("Общаая память - {0} Мб", allMemory); Console.ReadLine(); break; case 3: string[] stringsToDoMenu = { "Узнать время записи на конкретном диске", "Записать информацию на конкретный диск", "Назад" }; ConsoleMenu toDoMenu = new ConsoleMenu(stringsToDoMenu); int toDoMenuResult; Console.WriteLine("Введите размер информации(мб)"); int sizeInfo = 0; int.TryParse(Console.ReadLine(), out sizeInfo); bool isCopied; do { toDoMenuResult = toDoMenu.PrintMenu(); toDoMenuResult++; switch (toDoMenuResult) { case 2: string[] stringsChooseMenu = { "Записать на Двд", "Записать на Флэш память", "Записать на Жесткий диск", "Назад" }; ConsoleMenu chooseMenu = new ConsoleMenu(stringsChooseMenu); int chooseMenuResult; do { chooseMenuResult = chooseMenu.PrintMenu(); chooseMenuResult++; switch (chooseMenuResult) { case 1: isCopied = dvd.CopyData(ref sizeInfo); if (isCopied) { Console.WriteLine("Информация успешно записана"); } else { Console.WriteLine("Извините недостаточно памяти на диске"); } Console.ReadLine(); break; case 2: isCopied = flash.CopyData(ref sizeInfo); if (isCopied) { Console.WriteLine("Информация успешно записана"); } else { Console.WriteLine("Извините недостаточно памяти на диске"); } Console.ReadLine(); break; case 3: isCopied = hdd.CopyData(ref sizeInfo); if (isCopied) { Console.WriteLine("Информация успешно записана"); } else { Console.WriteLine("Извините недостаточно памяти на диске"); } Console.ReadLine(); break; } }while (chooseMenuResult != stringsChooseMenu.Length); break; case 1: string[] stringssChooseMenu = { "Записать на Двд", "Записать на Флэш память", "Записать на Жесткий диск", "Назад" }; ConsoleMenu choosseMenu = new ConsoleMenu(stringssChooseMenu); int choosseMenuResult; do { choosseMenuResult = choosseMenu.PrintMenu(); choosseMenuResult++; switch (choosseMenuResult) { case 1: double time = sizeInfo / dvd.SpeedWrite; Console.WriteLine("Это займет {0} секунд", time); Console.ReadLine(); break; case 2: time = sizeInfo / flash.GetUsbSpeed(); Console.WriteLine("Это займет {0} секунд", time); Console.ReadLine(); break; case 3: time = sizeInfo / hdd.GetUsbSpeed(); Console.WriteLine("Это займет {0} секунд", time); Console.ReadLine(); break; } }while (choosseMenuResult != stringssChooseMenu.Length); break; } } while (toDoMenuResult != stringsToDoMenu.Length); break; case 4: Console.WriteLine("Введите размер информации(мб)"); int.TryParse(Console.ReadLine(), out sizeInfo); if (sizeInfo <= hdd.FreeMemoryInfo()) { Console.WriteLine("Вам достаточно жесткого диска"); } else if (sizeInfo <= (hdd.FreeMemoryInfo() + dvd.FreeMemoryInfo())) { Console.WriteLine("Вам достаточно жесткого диска и двд диска"); } else if (sizeInfo <= (hdd.FreeMemoryInfo() + dvd.FreeMemoryInfo() + flash.FreeMemoryInfo())) { Console.WriteLine("Вам достаточно жесткого диска , двд диска,и флэш памяти"); } else { Console.WriteLine("3 дисков недостаточно для копирования информации"); } Console.ReadLine(); break; } }while (menuResult != stringsMenu.Length); }