Esempio n. 1
0
        static void Retrieve()
        {
            Console.WriteLine("Enter Your option\n");
            Console.WriteLine("1)MINIMUM\n");
            Console.WriteLine("2)MAXIMUM");
            int option = Convert.ToInt32(Console.ReadLine());

            using (var context = new TempratueControllerEntities())
            {
                if (option == 2)
                {
                    var values = context.TempTimes
                                 .OrderByDescending(a => a.Temprature)
                                 .First();
                    Console.WriteLine("The Max value recorded was: " + values.Temprature + " at time: " + values.Time);
                }
                if (option == 1)
                {
                    var values = context.TempTimes
                                 .OrderBy(a => a.Temprature)
                                 .First();
                    Console.WriteLine("The Min value recorded was: " + values.Temprature + " at time: " + values.Time);
                }
            }
        }
Esempio n. 2
0
        static void checkTemp()
        {
            Random rnd = new Random();

            Console.WriteLine("Enter the Min treshold: ");
            int min = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Enter the Max treshold: ");
            int max = Convert.ToInt32(Console.ReadLine());

            int[] a = new int[100];
            int   temp;

            for (int i = 0; i < 10; i++)
            {
                temp = rnd.Next(min - 5, max + 5);
                a[i] = temp;
            }
            for (int i = 0; i < 10; i++)
            {
                Thread.Sleep(300);
                if (a[i] <= min || a[i] >= max)
                {
                    using (TempratueControllerEntities context = new TempratueControllerEntities())
                    {
                        TempTime tmp = new TempTime
                        {
                            Temprature = a[i],
                            Time       = DateTime.Now
                        };
                        context.TempTimes.Add(tmp);
                        context.SaveChanges();
                    }
                    int      warningValue = a[i];
                    DateTime warningTime  = DateTime.Now.ToLocalTime();
                    Warning.RaiseWarning(warningValue, warningTime);
                }
            }

            Console.ReadKey();
        }