public ArrayList getPastCoolingData(int fanNumber, Int64 startTicks, Int64 endTicks)
        {
            ArrayList result = new ArrayList();


            DateTime startDate = new DateTime(startTicks);

            var start = startDate.Date;

            DateTime endDate = new DateTime(endTicks);

            var end = endDate.Date;

            SqlConnection conn = new System.Data.SqlClient.SqlConnection();
            try
            {

                string connectionString = ConfigurationManager.ConnectionStrings["KnightWatchDBConnection"].ConnectionString;

                conn.ConnectionString = connectionString;

                conn.Open();


                String sqlQuery = "select cool_demand, cool_output, entry_date, entry_time from Fan f where fan_number = @fan_number and entry_date between @startDate and @endDate";

                SqlCommand command = new SqlCommand(sqlQuery, conn);

                SqlParameter fanNumb = command.Parameters.AddWithValue("@fan_number", fanNumber);

                SqlParameter start_d = command.Parameters.AddWithValue("@startDate", start);

                SqlParameter end_d = command.Parameters.AddWithValue("@endDate", end);

                using (SqlDataReader commandReader = command.ExecuteReader())
                {

                    while (commandReader.Read())
                    {
                        String dateOnly = commandReader["entry_date"].ToString();

                        String timeOnly = commandReader["entry_time"].ToString();

                        DateTime d = DateTime.Parse(dateOnly.Substring(0, dateOnly.IndexOf(" ")) + "  " + timeOnly);
                        //result.Add(d);
                        if (DateTime.Compare(d, startDate) >= 0 && DateTime.Compare(d, endDate) <= 0)
                        {

                            CoolingData cooling = new CoolingData();

                            cooling.coolDemand = Double.Parse(commandReader["cool_demand"].ToString());

                            cooling.coolOutput = Double.Parse(commandReader["cool_output"].ToString());

                            cooling.ratio = cooling.coolDemand / cooling.coolOutput;

                            result.Add(cooling);
                        }
                        

                    }

                }

            }
            catch (Exception ex)
            {

                Console.WriteLine(ex.Message);
            }

            conn.Close();

            

            return result;
        }
        public CoolingData getCurrentCoolingData(int fanNumber)
        {
            CoolingData cooling = new CoolingData();

            SqlConnection conn = new System.Data.SqlClient.SqlConnection();
            try
            {

                string connectionString = ConfigurationManager.ConnectionStrings["KnightWatchDBConnection"].ConnectionString;

                conn.ConnectionString = connectionString;

                conn.Open();


                String sqlQuery = "select cool_demand, cool_output from Fan f where fan_number = @fan_number and entry_date = (select max(entry_date) from Fan where fan_number =@fan_number) and entry_time = (select max(entry_time) from fan f1 where f1.entry_date = f.entry_date and fan_number = @fan_number)";

                SqlCommand command = new SqlCommand(sqlQuery, conn);

                SqlParameter fanNumb = command.Parameters.AddWithValue("@fan_number", fanNumber);

                SqlDataReader commandReader = command.ExecuteReader();

                while (commandReader.Read())
                {
                    cooling.coolDemand = Double.Parse(commandReader["cool_demand"].ToString());

                    cooling.coolOutput = Double.Parse(commandReader["cool_output"].ToString());

                }

            }
            catch (Exception ex)
            {

                Console.WriteLine(ex.Message);
            }

            conn.Close();

            cooling.ratio = cooling.coolDemand / cooling.coolOutput;

            return cooling;
        }