Esempio n. 1
0
 /// <summary>
 /// Constructor, initialize all attributes
 /// </summary>
 /// <param name="clientName">ClientName to initialize</param>
 /// <param name="cooler">Coolr to initialize</param>
 /// <param name="dvdBurner">DvdBurner to initialize</param>
 /// <param name="extraAccesory">Extracessory to initialize</param>
 /// <param name="os">Operative system to initialize</param>
 /// <param name="type">Computer type to initialize</param>
 /// <param name="processor">Processor to initialize</param>
 /// <param name="hardDisk">Hard disk to initialize</param>
 /// <param name="ram">RAM to initialize</param>
 /// <param name="desc">Description to initialize</param>
 /// <param name="graphicCard">Graphic card to initialize</param>
 public Desktop(string clientName, Cooler cooler, bool dvdBurner, bool extraAccesory, OS os, ComType type, Processor processor, HardDisk hardDisk, RAM ram, string desc, GraphicCard graphicCard)
     : base(clientName, os, type, processor, hardDisk, ram, desc, graphicCard)
 {
     this.cooler        = cooler;
     this.dvdBurner     = dvdBurner;
     this.extraAccesory = extraAccesory;
 }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Weight,Tdp,Price")] Cooler cooler)
        {
            if (id != cooler.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cooler);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CoolerExists(cooler.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cooler));
        }
Esempio n. 3
0
 /// <summary>
 /// Constructor, initialize all attributes
 /// </summary>
 /// <param name="id">Id to initialize</param>
 /// <param name="clientName">ClientName to initialize</param>
 /// <param name="cooler">Coolr to initialize</param>
 /// <param name="dvdBurner">DvdBurner to initialize</param>
 /// <param name="extraAccesory">Extracessory to initialize</param>
 /// <param name="os">Operative system to initialize</param>
 /// <param name="type">Computer type to initialize</param>
 /// <param name="processor">Processor to initialize</param>
 /// <param name="hardDisk">Hard disk to initialize</param>
 /// <param name="ram">RAM to initialize</param>
 /// <param name="desc">Description to initialize</param>
 /// <param name="graphicCard">Graphic card to initialize</param>
 /// <param name="state">State to initialize</param>
 /// <param name="date">Date to initialize</param>
 public Desktop(int id, string clientName, Cooler cooler, bool dvdBurner, bool extraAccesory, OS os, ComType type, Processor processor, HardDisk hardDisk, RAM ram, string desc, GraphicCard graphicCard, State state, DateTime date)
     : base(id, clientName, os, type, processor, hardDisk, ram, desc, graphicCard, state, date)
 {
     this.cooler        = cooler;
     this.dvdBurner     = dvdBurner;
     this.extraAccesory = extraAccesory;
 }
Esempio n. 4
0
 private Cooler[] findCoolers()
 {
     Cooler[] answer;
     if (direct)
     {
         string           coolerFile   = Path.Combine(dataDir, "Coolers.xml");
         string           coolerSchema = Path.Combine(schemaDir, "Coolers.xsd");
         CoolerCollection coolers      = new CoolerCollection(coolerFile, coolerSchema);
         answer = new Cooler[coolers.Count];
         for (int i = 0; i < coolers.Count; i++)
         {
             answer[i] = (Cooler)coolers[i];
         }
     }
     else
     {
         DesktopClient.CoolIt_Service.Cooler[] rawCoolers = webService.GetCoolers();
         answer = new Cooler[rawCoolers.Length];
         InputPowerCalculator calc = getInputPowerCalc();
         for (int i = 0; i < rawCoolers.Length; i++)
         {
             DesktopClient.CoolIt_Service.Cooler raw = rawCoolers[i];
             List <DataPoint> data = new List <DataPoint>();
             for (int j = 0; j < raw.CPM.Length; j++)
             {
                 DesktopClient.CoolIt_Service.DataPoint rawPoint = raw.CPM[j];
                 DataPoint point = new DataPoint(rawPoint.temp, rawPoint.data);
                 data.Add(point);
             }
             answer[i] = new Cooler(raw.Name, raw.id, data, raw.price, raw.priceUnit, raw.currencyUnit);
             answer[i].InputPowerCalculator = calc;
         }
     }
     return(answer);
 }
Esempio n. 5
0
        public static void Main()
        {
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
            Thermostat thermostat = new Thermostat();
            Heater     heater     = new Heater(60);
            Cooler     cooler     = new Cooler(80);
            string     temperature;

            // Using C# 2.0 or later syntax.
            thermostat.OnTemperatureChange +=
                heater.OnTemperatureChanged;
            // Using C# 3.0.  Change to anonymous method
            // if using C# 2.0
            thermostat.OnTemperatureChange +=
                (newTemperature) =>
            {
                throw new InvalidOperationException();
            };
            thermostat.OnTemperatureChange +=
                cooler.OnTemperatureChanged;

            Console.Write("Enter temperature: ");
            temperature = Console.ReadLine();
            thermostat.CurrentTemperature = int.Parse(temperature);
        }
Esempio n. 6
0
        /// <summary>
        /// User has changed a cooler or one of its settings.
        /// </summary>
        /// <param name="sender">The CoolerPicker which generated this event</param>
        /// <param name="e">(unused)</param>
        void handle_CoolerChangedEvent(object sender, EventArgs e)
        {
            Cooler cooler = ((CoolerPicker)sender).Cooler;

            webServiceAdapter.SetCooler(cooler.Name, ((CoolerPicker)sender).PowerFactor);
            simulate();
        }
Esempio n. 7
0
        public ICollection <Cooler> getCoolersFromExcel(XLWorkbook workBook)
        {
            ICollection <Cooler> result = new List <Cooler>();
            var worksheet = workBook.Worksheet("Кулери");

            foreach (IXLRow row in worksheet.RowsUsed().Skip(1))
            {
                var cooler = new Cooler();
                //cooler.Id = int.Parse(row.Cell(1).Value.ToString());
                cooler.Name   = row.Cell(2).Value.ToString();
                cooler.Weight = int.Parse(row.Cell(3).Value.ToString());
                cooler.Tdp    = int.Parse(row.Cell(4).Value.ToString());
                cooler.Price  = int.Parse(row.Cell(5).Value.ToString());
                var selectedSockets = stringToIntList(row.Cell(6).Value.ToString());
                List <SocketsToCooler> socketsToCoolers = new List <SocketsToCooler>();
                foreach (var i in selectedSockets)
                {
                    socketsToCoolers.Add(new SocketsToCooler
                    {
                        SocketId = i,
                        CoolerId = cooler.Id
                    });
                }
                result.Add(cooler);
            }
            return(result);
        }
        public static void Main()
        {
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
            Thermostat thermostat = new Thermostat();
            Heater heater = new Heater(60);
            Cooler cooler = new Cooler(80);
            string temperature;

            // Using C# 2.0 or later syntax.
            thermostat.OnTemperatureChange +=
                heater.OnTemperatureChanged;
            // Using C# 3.0.  Change to anonymous method
            // if using C# 2.0
            thermostat.OnTemperatureChange +=
                (newTemperature) =>
                {
                    throw new InvalidOperationException();
                };
            thermostat.OnTemperatureChange +=
                cooler.OnTemperatureChanged;

            Console.Write("Enter temperature: ");
            temperature = Console.ReadLine();
            thermostat.CurrentTemperature = int.Parse(temperature);
        }
Esempio n. 9
0
        public ActionResult DeleteConfirmed(int id)
        {
            Cooler cooler = db.Coolers.Find(id);

            db.Coolers.Remove(cooler);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 10
0
 public NotGettingBetter(Cooler cooler, OptimizationType optimizationType, uint maxSteps,
                         uint notGettingBetterDuration = 1000)
 {
     _bestSolValue             = optimizationType == OptimizationType.Maximization ? double.MinValue : double.MaxValue;
     _cooler                   = cooler;
     _notGettingBetterDuration = notGettingBetterDuration;
     _optimizationType         = optimizationType;
     _maxSteps                 = maxSteps;
 }
Esempio n. 11
0
        private Cooler GetImageForCooler(Cooler cooler)
        {
            var images = db.Images.Where(i => i.CoolerId == cooler.Id).ToList();

            cooler.Image = images.Count > 0 ? images[0] : new WcwImage {
                Name = "defaultCooler.png"
            };
            return(cooler);
        }
Esempio n. 12
0
        public CoolerControl(Flowsheet flowsheet, Point location, Cooler cooler) :
            base(flowsheet, location, cooler)
        {
            InitializeComponent();

            this.Size = new System.Drawing.Size(UI.UNIT_OP_CTRL_W, UI.UNIT_OP_CTRL_H);
            UI.SetStatusColor(this, this.Cooler.SolveState);
            this.UpdateBackImage();
        }
Esempio n. 13
0
 public Cooler[] GetCoolers()
 {
     Cooler[] answer = new Cooler[coolers.Count];
     for (int i = 0; i < coolers.Count; i++)
     {
         answer[i] = (Cooler)coolers[i];
     }
     return(answer);
 }
Esempio n. 14
0
 public ActionResult Edit([Bind(Include = "IDCooler,Name,hasFan,Description,Price")] Cooler cooler)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cooler).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cooler));
 }
Esempio n. 15
0
 public ActionResult Edit([Bind(Include = "Id,Name,Categrory,ShortDescription,FullDescription,Price,Active")] Cooler cooler)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cooler).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cooler));
 }
Esempio n. 16
0
        public ActionResult Create([Bind(Include = "IDCooler,Name,hasFan,Description,Price")] Cooler cooler)
        {
            if (ModelState.IsValid)
            {
                db.Coolers.Add(cooler);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cooler));
        }
 public async Task <IEnumerable <Cooler> > PostCooler([FromBody] Cooler value)
 {
     if (User.Identity.IsAuthenticated)
     {
         return(await _componentService.AddCooler(new AddCoolerRequest(value)));
     }
     else
     {
         throw new UnauthorizedAccessException("Only admin can make changes. Have a nice day and f**k off ;)");
     }
 }
Esempio n. 18
0
        public ActionResult Create([Bind(Include = "Id,Name,Categrory,ShortDescription,FullDescription,Price,Active")] Cooler cooler)
        {
            if (ModelState.IsValid)
            {
                db.Coolers.Add(cooler);
                db.SaveChanges();
                return(RedirectToAction("AddImage", new { id = cooler.Id }));
            }

            return(View(cooler));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,Weight,Tdp,Price")] Cooler cooler)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cooler);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cooler));
        }
Esempio n. 20
0
        public ConditionalHeat(Cooler cooler, OptimizationType optimizationType, uint maxSteps, float heatBackByPercent, ushort clock = 100)
        {
            _clock             = clock;
            _counter           = clock;
            _cooler            = cooler;
            _maxSteps          = maxSteps;
            _optimizationType  = optimizationType;
            _heatBackByPercent = heatBackByPercent;

            _bestSolValue = _optimizationType == OptimizationType.Maximization ? double.MinValue : double.MaxValue;
            TotalSteps    = 0;
        }
Esempio n. 21
0
 public Desktop(Cooler cooler, DesktopCPU cpu, Disk drive, DesktopGPU gpu, DesktopMotherboard motherboard, PSU psu, RAM ram)
 {
     try
     {
         if (cooler == null)
         {
             throw new ArgumentNullException("cooler");
         }
         if (cpu == null)
         {
             throw new ArgumentNullException("cpu");
         }
         if (drive == null)
         {
             throw new ArgumentNullException("drive");
         }
         if (gpu == null)
         {
             throw new ArgumentNullException("gpu");
         }
         if (motherboard == null)
         {
             throw new ArgumentNullException("motherboard");
         }
         if (psu == null)
         {
             throw new ArgumentNullException("psu");
         }
         if (ram == null)
         {
             throw new ArgumentNullException("ram");
         }
         Cooler       = cooler;
         _cpu         = cpu;
         _disk        = drive;
         _gpu         = gpu;
         _motherboard = motherboard;
         _psu         = psu;
         _ram         = ram;
     }
     catch (ArgumentNullException exception)
     {
         throw exception;
     }
     catch (ArgumentException exception)
     {
         throw exception;
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Esempio n. 22
0
        public AddCoolerRequest(Cooler element)
        {
            _element = element;

            _parameters = new List <SqlParameter>
            {
                new SqlParameter("@diameter", _element.VentDiam),

                new SqlParameter("@adjst", _element.TurnAdj ?? false ? 1 : 0),

                new SqlParameter("@color", _element.Color)
            };

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

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

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

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

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

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

            if (_element.Socket != null && _element.Socket.Count > 0)
            {
                for (int i = 0; i < _element.Socket.Count; i++)
                {
                    Expression += $"INSERT INTO COOLER_SOCKET VALUES (SELECT ID FROM COOLER WHERE TITLE = @title, @socket{i});";
                    _parameters.Add(new SqlParameter($"@socket{i}", _element.Socket[i]));
                }
            }
        }
Esempio n. 23
0
 public double SimulatePF(double length, double crossSection, string materialName, string coolerName, double powerFactor)
 {
     try {
         CoolerCollection     coolers   = findCoolers();
         Cooler               cooler    = (Cooler)coolers[coolerName];
         MaterialsCollection  materials = findMaterials();
         Material             material  = (Material)materials[materialName];
         SteadyStateSimulator ssSim     = new SteadyStateSimulator();
         return(ssSim.simulate(length, crossSection, material, cooler, powerFactor));
     } catch (Exception ex) {
         throw new SoapException(ex.ToString(), new System.Xml.XmlQualifiedName(""));
     }
 }
Esempio n. 24
0
        public Heater(Cooler cooler, OptimizationType optimizationType, uint maxSteps, float heatBackToPercent, double minTemp = 1e-6)
        {
            _cooler            = cooler;
            _prevMaxTemp       = cooler.InitialTemperature;
            _maxSteps          = maxSteps;
            _optimizationType  = optimizationType;
            _heatBackToPercent = heatBackToPercent;
            _minTemp           = minTemp;

            _bestSolValue    = _optimizationType == OptimizationType.Maximization ? double.MinValue : double.MaxValue;
            TotalSteps       = 0;
            StepsSinceReheat = 0;
        }
Esempio n. 25
0
 public CoolerViewModel()
 {
     ExtraHeater = new HeaterViewModel();
     PageViewExtraHeaterModels.Add(new EmptyVM());
     PageViewExtraHeaterModels.Add(ExtraHeater);
     CoolerTypes         = Cooler.GetTypes();
     PumpPower           = Cooler.GetPumpPower();
     NumOfStages         = Cooler.GetNumOfStages();
     SelectedType        = CoolerTypes[0];
     SelectedNumOfStages = NumOfStages[0];
     SelectedPumpPower   = PumpPower[0];
     ExtraHeaterChecked  = false;
 }
        protected override void Initialize()
        {
            room             = new Room(this);
            room.temperature = 25;
            room.humidity    = 40;

            _controlCenter = new ControlCenter(this, 25.0, 40.0);
            _cooler        = new Cooler(this);
            _heater        = new Heater(this);
            _humidifier    = new Humidifier(this);
            _hygrometer    = new Hygrometer(this);
            _thermometer   = new Thermometer(this);
        }
Esempio n. 27
0
        //Data loaders:
        public async Task <IActionResult> LoadCPUs()
        {
            ViewData["HwType"] = "CPU";

            string moboID = HttpContext.Session.GetString(SessionKeyMOBO);
            MOBO   mobo   = null;

            if (!String.IsNullOrEmpty(moboID))
            {
                mobo = await _context.MOBOes.SingleOrDefaultAsync(m => m.Id == Int32.Parse(moboID));
            }

            string coolerID = HttpContext.Session.GetString(SessionKeyCooler);
            Cooler cooler   = null;

            if (!String.IsNullOrEmpty(coolerID))
            {
                cooler = await _context.Coolers.SingleOrDefaultAsync(m => m.Id == Int32.Parse(coolerID));
            }

            List <CPU> cpuList = await _context.CPUs.AsNoTracking().ToListAsync();

            List <CPUViewModel> cpuListValidated = new List <CPUViewModel>();

            foreach (var item in cpuList)
            {
                CPUViewModel cpuValidated = new CPUViewModel
                {
                    CPU       = item,
                    Socket_ok = true
                };

                if (mobo != null)
                {
                    if (!item.Socket.Equals(mobo.Socket))
                    {
                        cpuValidated.Socket_ok = false;
                    }
                }
                if (cooler != null)
                {
                    if (!item.Socket.Equals(cooler.Socket))
                    {
                        cpuValidated.Socket_ok = false;
                    }
                }

                cpuListValidated.Add(cpuValidated);
            }
            return(View("CPUs", cpuListValidated));
        }
Esempio n. 28
0
        // GET: Coolers/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Cooler cooler = db.Coolers.Find(id);

            if (cooler == null)
            {
                return(HttpNotFound());
            }
            return(View(cooler));
        }
Esempio n. 29
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;
 }
Esempio n. 30
0
    public static void Main()
    {
        Thermostat thermostat = new Thermostat();
        Heater     heater     = new Heater(60);
        Cooler     cooler     = new Cooler(80);

        thermostat.OnTemperatureChange += heater.OnTemperatureChange;
        thermostat.OnTemperatureChange += cooler.OnTemperatureChange;

        string temperature;

        Console.WriteLine("enter temperature:");
        temperature = Console.ReadLine();
        thermostat.CurrentTemperature = int.Parse(temperature);
    }
        public ActionResult AddToShoppingCart(int ID)
        {
            Cooler       cooler = db.Coolers.Find(ID);
            ShoppingCart basket = new ShoppingCart();

            basket.AddItem(new Parts
            {
                Name  = ((cooler.Brand) + " " + (cooler.Model) + " " + (cooler.Rad)),
                Price = (cooler.Price),
                ID    = IdSetter.setId()
            });
            basket.DisplayFor(IdSetter.setId());
            IdSetter.incrementId();
            //seed++;
            return(RedirectToAction("IndexCooler"));
        }
        public static void Main()
        {
            Thermostat thermostat = new Thermostat();
            Heater heater = new Heater(60);
            Cooler cooler = new Cooler(80);

            // Note: Use new Action(cooler.OnTemperatureChanged)
            // for C# 1.0 syntax.
            thermostat.OnTemperatureChange +=
                heater.OnTemperatureChanged;

            thermostat.OnTemperatureChange +=
                cooler.OnTemperatureChanged;

            // Bug: Should not be allowed
            thermostat.OnTemperatureChange(42);
        }
        public static void Main()
        {
            Thermostat thermostat = new Thermostat();
            Heater heater = new Heater(60);
            Cooler cooler = new Cooler(80);
            string temperature;

            // Note: Use new Action(cooler.OnTemperatureChanged)
            // for C# 1.0 syntax.
            thermostat.OnTemperatureChange =
                heater.OnTemperatureChanged;

            // Bug: Assignment operator overrides 
            // previous assignment.
            thermostat.OnTemperatureChange = 
                cooler.OnTemperatureChanged;

            Console.Write("Enter temperature: ");
            temperature = Console.ReadLine();
            thermostat.CurrentTemperature = int.Parse(temperature);
        }
        public static void Main()
        {
            Thermostat thermostat = new Thermostat();
            Heater heater = new Heater(60);
            Cooler cooler = new Cooler(80);

            Action<float> delegate1;
            Action<float> delegate2;
            Action<float> delegate3;

            // use Constructor syntax for C# 1.0.
            delegate1 = heater.OnTemperatureChanged;
            delegate2 = cooler.OnTemperatureChanged;

            Console.WriteLine("Invoke both delegates:");
            delegate3 = delegate1;
            delegate3 += delegate2;
            delegate3(90);

            Console.WriteLine("Invoke only delegate2");
            delegate3 -= delegate1;
            delegate3(30);
        }
        public static void Main()
        {
            try
            {
                Thermostat thermostat = new Thermostat();
                Heater heater = new Heater(60);
                Cooler cooler = new Cooler(80);
                string temperature;

                // Using C# 2.0 or later syntax.
                thermostat.OnTemperatureChange +=
                    heater.OnTemperatureChanged;
                // Using C# 3.0.  Change to anonymous method
                // if using C# 2.0
                thermostat.OnTemperatureChange +=
                    (newTemperature) =>
                    {
                        throw new InvalidOperationException();
                    };
                thermostat.OnTemperatureChange +=
                    cooler.OnTemperatureChanged;

                Console.Write("Enter temperature: ");
                temperature = Console.ReadLine();
                thermostat.CurrentTemperature = int.Parse(temperature);
            }
            catch(AggregateException exception)
            {
                Console.WriteLine(exception.Message);
                foreach(Exception item in exception.InnerExceptions)
                {
                    Console.WriteLine("\t{0}: {1}",
                        item.GetType(), item.Message);
                }
            }
        }
        public static void Main()
        {
            Thermostat thermostat = new Thermostat();
            Heater heater = new Heater(60);
            Cooler cooler = new Cooler(80);
            string temperature;

            // Using C# 2.0 or later syntax.
            thermostat.OnTemperatureChange +=
                heater.OnTemperatureChanged;
            thermostat.OnTemperatureChange +=
                cooler.OnTemperatureChanged;

            Console.Write("Enter temperature: ");
            temperature = Console.ReadLine();
            thermostat.CurrentTemperature = int.Parse(temperature);
        }
        public static void Main()
        {
            Thermostat thermostat = new Thermostat();
            Heater heater = new Heater(60);
            Cooler cooler = new Cooler(80);

            Action<float> delegate1;
            Action<float> delegate2;
            Action<float> delegate3;

            // Note: Use new Action(cooler.OnTemperatureChanged)
            // for C# 1.0 syntax.
            delegate1 = heater.OnTemperatureChanged;
            delegate2 = cooler.OnTemperatureChanged;

            Console.WriteLine("Combine delegates using + operator:");
            delegate3 = delegate1 + delegate2;
            delegate3(60);

            Console.WriteLine("Uncombine delegates using - operator:");
            delegate3 = delegate3 - delegate2;
            delegate3(60);
        }