Exemplo n.º 1
0
        private void Button5_Click(object sender, EventArgs e)
        {
            try
            {
                ComboBox();
                if (string.IsNullOrEmpty(textBox5.Text))
                {
                    textBox5.Text = "1";
                }

                if (Selection6 == "C=>F")
                {
                    textBox2.Text = Temperatures.CtoF(textBox1.Text, Selection9, Selection8, Convert.ToInt32(textBox5.Text), Selection7, "Error!");
                }
                else
                {
                    textBox2.Text = Temperatures.FtoC(textBox1.Text, Selection9, Selection8, Convert.ToInt32(textBox5.Text), Selection7, "Error!");
                }

                button6.Cursor = Cursors.Hand;
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message);
            }
        }
Exemplo n.º 2
0
 public void ComputeHeights(int maxTemp, int height)
 {
     MaxHeight = height * (maxTemp - MaxTemperature) / maxTemp;
     AvgHeight = height * (maxTemp - AvgTemperature) / maxTemp;
     MinHeight = height * (maxTemp - MinTemperature) / maxTemp;
     Heights   = Temperatures.Select(temp => height * (maxTemp - temp) / maxTemp).ToArray();
 }
Exemplo n.º 3
0
        public void MakePlotTest()
        {
            CleanTestBase.RunAutomatically(false);
            var cs = new OxyCalculationSetup(Utili.GetCurrentMethodAndClass());

            cs.StartHousehold(1, GlobalConsts.CSVCharacter,
                              LoadTypePriority.Mandatory,
                              configSetter: x => x.Enable(CalcOption.TemperatureFile));
            using (FileFactoryAndTracker fft = new FileFactoryAndTracker(cs.DstDir, "1", cs.Wd.InputDataLogger))
            {
                CalculationProfiler     cp   = new CalculationProfiler();
                ChartCreationParameters ccps = new ChartCreationParameters(300, 4000,
                                                                           2500, false, GlobalConsts.CSVCharacter, new DirectoryInfo(cs.DstDir));
                var aeupp = new Temperatures(ccps, fft, cp);
                Logger.Info("Making picture");
                var di  = new DirectoryInfo(cs.DstDir);
                var rfe = cs.GetRfeByFilename("Temperatures.csv");
                aeupp.MakePlot(rfe);
                Logger.Info("finished picture");
                //OxyCalculationSetup.CopyImage(resultFileEntries[0].FullFileName);
                var imagefiles = FileFinder.GetRecursiveFiles(di, "Temperatures.png");
                imagefiles.Count.Should().BeGreaterOrEqualTo(1);
            }
            cs.CleanUp();
            CleanTestBase.RunAutomatically(true);
        }
Exemplo n.º 4
0
        public async Task <IActionResult> PutTemperatures([FromRoute] int id, [FromBody] Temperatures temperatures)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != temperatures.IdTemperature)
            {
                return(BadRequest());
            }

            _context.Entry(temperatures).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TemperaturesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 5
0
        public void Insert(string temperature)
        {
            Dictionary <string, int> wordToNumbers = new Dictionary <string, int>
            {
                { "one", 1 },
                { "two", 2 },
                { "three", 3 },
                { "four", 4 },
                { "five", 5 },
                { "six", 6 },
                { "seven", 7 },
                { "eight", 8 },
                { "nine", 9 },
                { "ten", 10 }
            };

            if (wordToNumbers.ContainsKey(temperature))
            {
                Temperatures.Add(wordToNumbers[temperature]);
            }
            else
            {
                Console.WriteLine("Cannot insert " + temperature);
            }
        }
Exemplo n.º 6
0
        public async Task <ActionResult <Temperatures> > PostTemperatures(Temperatures temperatures)
        {
            _context.Temperatures.Add(temperatures);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTemperatures", new { id = temperatures.ReadingKey }, temperatures));
        }
Exemplo n.º 7
0
        public OrdersDataGenerator()
        {
            Regions      = GetRegionFaker(GetRegions()).Generate(5);
            Temperatures = GetTemperatureFaker(GetTemperatures()).Generate(4);
            Addresses    = GetAddressFaker(GetCities(), GetStreets(), GetZipCodes(), Regions.Select(x => x.RegionId)).Generate(20);
            Restaurants  = GetRestaurantFaker(GetRestaurants(), Addresses.Select(x => x.AddressId)).Generate(10);
            Menus        = GetMenuFaker(GetMenus(), Restaurants.Select(x => x.RestaurantId)).Generate(3);
            MenuItems    = GetMenuItemFaker(GetMenuItems(), Temperatures.Select(x => x.TemperatureId),
                                            Menus.Select(x => x.MenuId)).Generate(20);
            Customers      = GetCustomerFaker(GetFirstNames(), GetLastNames(), Addresses.Select(x => x.AddressId)).Generate(5);
            Ingredients    = GetIngredientFaker(GetIngredients(), Temperatures.Select(x => x.TemperatureId)).Generate(15);
            InventoryItems = GetInventoryItemFaker(Ingredients.Select(x => x.IngredientId),
                                                   Restaurants.Select(x => x.RestaurantId)).Generate(20);
            MenuItemIngredients = GetMenuItemIngredientFaker(MenuItems.Select(x => x.MenuItemId),
                                                             Ingredients.Select(x => x.IngredientId)).Generate(50);

            var shelves = new List <ShelfEntity>();

            for (int i = 0; i < 3; i++)
            {
                shelves.AddRange(GetShelfFaker(Temperatures.Select(x => x.TemperatureId),
                                               Restaurants.Select(x => x.RestaurantId)).Generate(1));
            }
            shelves.AddRange(GetShelfFaker(Temperatures.Select(x => x.TemperatureId),
                                           Restaurants.Select(x => x.RestaurantId), true).Generate(1));

            Shelves = shelves;

            Couriers = GetCourierFaker(GetFirstNames(), GetLastNames(), Addresses.Select(x => x.AddressId)).Generate(20);
            Orders   = GetOrderFaker(Customers.Select(x => x.CustomerId),
                                     Restaurants.Select(x => x.RestaurantId), Addresses.Select(x => x.AddressId),
                                     Couriers.Select(x => x.CourierId)).Generate(10);
            OrderItems = GetOrderItemFaker(MenuItems.Select(x => x.MenuItemId),
                                           Orders.Select(x => x.OrderId), Shelves.Select(x => x.ShelfId)).Generate(20);
        }
Exemplo n.º 8
0
        public async Task <IActionResult> PutTemperatures(int id, Temperatures temperatures)
        {
            if (id != temperatures.ReadingKey)
            {
                return(BadRequest());
            }

            _context.Entry(temperatures).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TemperaturesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IHttpActionResult> PostTemperatures(Temperatures temperatures)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Temperatures.Add(temperatures);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (TemperaturesExists(temperatures.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = temperatures.Id }, temperatures));
        }
        public async Task <IHttpActionResult> PutTemperatures(int id, Temperatures temperatures)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != temperatures.Id)
            {
                return(BadRequest());
            }

            db.Entry(temperatures).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();

                Hub.Clients.All.receiveTemperature(temperatures);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TemperaturesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Temperatures temperatures = await db.Temperatures.FindAsync(id);

            db.Temperatures.Remove(temperatures);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 12
0
        /// <summary>
        /// Sauvegarde du modèle
        /// </summary>
        public void SerializeTemperatures()
        {
            var serialiseur = new XmlSerializer(typeof(List <Temperature>));

            using (var writer = XmlWriter.Create("Temperatures.xml"))
            {
                serialiseur.Serialize(writer, Temperatures.ToList());
            }
        }
Exemplo n.º 13
0
 private void AddTemperatureExecutionMethod()
 {
     Temperatures.Add(new Temperature()
     {
         Valeur      = new Random(DateTime.Now.Millisecond).NextDouble() * 10d + 20d,
         DateDePrise = DateTime.Now.Date
     });
     SerializeTemperatures();
 }
Exemplo n.º 14
0
        public void AddChartData(string label, int value)
        {
            Json labelItem = Labels.Add();

            labelItem.StringValue = label;

            Json temperatureItem = Temperatures.Add();

            temperatureItem.IntegerValue = value;
        }
Exemplo n.º 15
0
        public void AddChartData(string label, int value)
        {
            Json labelItem = Labels.Add();

            labelItem.SetStringValue(label);

            Json temperatureItem = Temperatures.Add();

            temperatureItem.SetIntegerValue(value);
        }
Exemplo n.º 16
0
        public Temperatures GetTemperatureDevice()
        {
            Temperatures temperatureDevices = new Temperatures();

            using (WebClient wc = new WebClient())
            {
                var json = wc.DownloadString(Configuracion.UrlBase + string.Format(Configuracion.UrlGetDeviceType, "temp"));
                temperatureDevices = JsonConvert.DeserializeObject <Temperatures>(json);
            }
            return(temperatureDevices);
        }
Exemplo n.º 17
0
 public void Insert(int temperature)
 {
     if (temperature > 0 && temperature < 101)
     {
         Temperatures.Add(temperature);
     }
     else
     {
         Console.WriteLine("Cannot insert " + temperature);
     }
 }
Exemplo n.º 18
0
        public async Task <IHttpActionResult> GetTemperatures(int id)
        {
            Temperatures temperatures = await db.Temperatures.FindAsync(id);

            if (temperatures == null)
            {
                return(NotFound());
            }

            return(Ok(temperatures));
        }
Exemplo n.º 19
0
        public double GetTemperatureDataDevice(string idx)
        {
            Temperatures temperatureDevices = new Temperatures();

            using (WebClient wc = new WebClient())
            {
                var json = wc.DownloadString(Configuracion.UrlBase + string.Format(Configuracion.UrlGetDevice, idx));
                temperatureDevices = JsonConvert.DeserializeObject <Temperatures>(json);
            }
            return(Convert.ToDouble(temperatureDevices.result[0].Data.Replace(" C", "")));
        }
Exemplo n.º 20
0
        //Update Temperature
        static async Task <Temperatures> UpdateTemperatureAsync(Temperatures temp)
        {
            HttpResponseMessage response = await client.PutAsJsonAsync($"api/TemperaturesApi/{temp.Id}", temp);

            response.EnsureSuccessStatusCode();

            //Deserialize the update temperature form the response body.
            temp = await response.Content.ReadAsAsync <Temperatures>();

            return(temp);
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,CityName,Temperature")] Temperatures temperatures)
        {
            if (ModelState.IsValid)
            {
                db.Entry(temperatures).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(temperatures));
        }
Exemplo n.º 22
0
        public async Task <IActionResult> PostTemperatures([FromBody] Temperatures temperatures)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Temperatures.Add(temperatures);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTemperatures", new { id = temperatures.IdTemperature }, temperatures));
        }
Exemplo n.º 23
0
        public async Task <IHttpActionResult> PostTemperatures(Temperatures temperatures)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Temperatures.Add(temperatures);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = temperatures.Id }, temperatures));
        }
        public async Task <ActionResult> Create([Bind(Include = "Id,CityName,Temperature")] Temperatures temperatures)
        {
            if (ModelState.IsValid)
            {
                db.Temperatures.Add(temperatures);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(temperatures));
        }
Exemplo n.º 25
0
        private void Button7_Click(object sender, EventArgs e)
        {
            if (Temperaturer)
            {
                textBox13.Text = Temperatures.CtoF(textBox12.Text, false, false, 0, false, "Error!");
            }
            else
            {
                textBox12.Text = Temperatures.FtoC(textBox13.Text, false, false, 0, false, "Error!");
            }

            Temperaturer = !Temperaturer;
        }
Exemplo n.º 26
0
        private void temptToBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (temptToBox.SelectedIndex == -1)
            {
                IsTempToProperInput = false;
                DisableConvertButton();
                return;
            }

            IsTempToProperInput = true;
            TempTo = (Temperatures)temptToBox.SelectedIndex;
            Console.WriteLine(TempTo);
        }
Exemplo n.º 27
0
        public async Task <IHttpActionResult> DeleteTemperatures(int id)
        {
            Temperatures temperatures = await db.Temperatures.FindAsync(id);

            if (temperatures == null)
            {
                return(NotFound());
            }

            db.Temperatures.Remove(temperatures);
            await db.SaveChangesAsync();

            return(Ok(temperatures));
        }
        // GET: Temperatures/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Temperatures temperatures = await db.Temperatures.FindAsync(id);

            if (temperatures == null)
            {
                return(HttpNotFound());
            }
            return(View(temperatures));
        }
Exemplo n.º 29
0
        /// <summary>
        /// Retrieves the weight per unit volume and mass per unit volume of the material.
        /// </summary>
        /// <param name="temperature">This item applies only if the specified material has properties that are temperature dependent.
        /// That is, it applies only if properties are specified for the material at more than one temperature.
        /// This item is the temperature at which the specified data is to be retrieved.
        /// The temperature must have been previously defined for the material.</param>
        /// <exception cref="T:MPT.CSI.API.Core.Support.CSiException">API_DEFAULT_ERROR_CODE</exception>
        /// <exception cref="T:MPT.CSI.API.Core.Support.CSiException"></exception>
        public void FillWeightAndMass(double temperature = 0)
        {
            if (Temperatures.Length == 0 || !Temperatures.Contains(temperature))
            {
                temperature = 0;
            }

            _materialProperties.GetWeightAndMass(_name,
                                                 out var weightPerVolume,
                                                 out var massPerVolume,
                                                 temperature);

            WeightPerVolume = weightPerVolume;
            MassPerVolume   = massPerVolume;
        }
Exemplo n.º 30
0
        protected Faker <ShelfEntity> GetShelfFaker(Guid shelfId, bool isOverflow = false)
        {
            var faker = new Faker <ShelfEntity>()
                        .StrictMode(true)
                        .Ignore(x => x.Temperature)
                        .RuleFor(x => x.ShelfId, s => shelfId)
                        .RuleFor(x => x.IsOverflow, s => isOverflow)
                        .RuleFor(x => x.Capacity, s => s.PickRandom(5, 10, 15, 20))
                        .RuleFor(x => x.Name, s => s.Random.Replace("##-????"))
                        .RuleFor(x => x.DecayRate, s => s.Random.Decimal(10M, 20M))
                        .RuleFor(x => x.TemperatureId, s => s.PickRandom(Temperatures.Select(t => t.TemperatureId)))
                        .RuleFor(x => x.CreationTimestamp, s => DateTime.Now);

            return(faker);
        }