Exemple #1
0
        public DateTime GetMinEnergyTime()
        {
            object result = ADOUtils.ExecuteScalar(_connectionString, "Select_Min_Energy_Time", null);

            if (result == null)
            {
                throw new SqlStorageException("Can not select time of min energy.");
            }

            return((DateTime)result);
        }
Exemple #2
0
        public double GetMinEnergy()
        {
            object result = ADOUtils.ExecuteScalar(_connectionString, "Select_Min_Energy", null);

            if (result == null)
            {
                throw new SqlStorageException("Can not select min Energy.");
            }

            return((double)result);
        }
Exemple #3
0
        public Coordinates GetMinEnergyPosition()
        {
            int fieldsCountInCoordinateInstanse = 3;
            var result = ADOUtils.ExecuteReaderSingleRow(_connectionString, "Select_Min_Energy_Position", null, fieldsCountInCoordinateInstanse);

            if (result == null)
            {
                throw new ArgumentNullException("Can not select position of min energy.");
            }

            return(new Coordinates((int)result["Id"], (double)result["X"], (double)result["Y"]));
        }
Exemple #4
0
        public double GetMinEnergy(DateTime dateTime)
        {
            var parameters = new Dictionary <string, object>();

            parameters.Add("@Date", dateTime);

            object result = ADOUtils.ExecuteScalar(_connectionString, "Select_Min_Energy_By_Date", null);

            if (result == null)
            {
                throw new SqlStorageException("Can not select min Energy.");
            }

            return((double)result);
        }
        public void OnNext(T value)
        {
            if (EqualityComparer <T> .Default.Equals(value, default))
            {
                throw new ArgumentException($"The {nameof(value)} must be initialized.");
            }

            var parameters = new Dictionary <string, object>();

            parameters.Add("@X", value.ObservationPoint.X);
            parameters.Add("@Y", value.ObservationPoint.Y);
            parameters.Add("@EstimatedValue", value.EstimatedValue);
            parameters.Add("@ObservationTime", value.ObservationTime);

            ADOUtils.ExecuteNonQuery(_connectionString, "Insert_EnergyObservation", parameters);
        }
Exemple #6
0
        public double GetAverageEnergy(DateTime startFrom, DateTime endBy)
        {
            var parameters = new Dictionary <string, object>();

            parameters.Add("@StartFrom", startFrom);
            parameters.Add("@EndBy", endBy);

            object result = ADOUtils.ExecuteScalar(_connectionString, "Select_Average_Energy_Between_Dates", parameters);

            if (result == null)
            {
                throw new SqlStorageException("Can not select average Energy.");
            }

            return((double)result);
        }
Exemple #7
0
        public double GetMaxEnergy(Coordinates coordinates)
        {
            var parameters = new Dictionary <string, object>();

            parameters.Add("@X", coordinates);
            parameters.Add("@Y", coordinates);

            object result = ADOUtils.ExecuteScalar(_connectionString, "Select_Max_Energy_By_Coordinate", null);

            if (result == null)
            {
                throw new SqlStorageException("Can not select max Energy.");
            }

            return((double)result);
        }
Exemple #8
0
        public double GetAverageEnergy(Coordinates rectTopLeft, Coordinates rectBottomRight)
        {
            var parameters = new Dictionary <string, object>();

            parameters.Add("@TopLeftX", rectTopLeft.X);
            parameters.Add("@TopLeftY", rectTopLeft.Y);
            parameters.Add("@BottomRightX", rectBottomRight.X);
            parameters.Add("@BottomRightY", rectBottomRight.Y);

            object result = ADOUtils.ExecuteScalar(_connectionString, "Select_Average_Energy_Between_Coordinates", parameters);

            if (result == null)
            {
                throw new SqlStorageException("Can not select average Energy.");
            }

            return((double)result);
        }
Exemple #9
0
        public IDictionary <double, int> GetDistributionByEnergyValue()
        {
            var resultDistribution       = new Dictionary <double, int>();
            int fieldCountInSelectedItem = 2;

            var selectedItems = ADOUtils.ExecuteReaderRows(_connectionString, "Select_Distribution_By_EnergyValue", null, fieldCountInSelectedItem);

            if (selectedItems == null)
            {
                throw new SqlStorageException("Can not select distribution by estimated value.");
            }

            foreach (var item in selectedItems)
            {
                resultDistribution.Add((double)item["EstimatedValue"], (int)item["Count"]);
            }

            return(resultDistribution);
        }
Exemple #10
0
        public IDictionary <DateTime, int> GetDistributionByObservationTime()
        {
            var resultDistribution       = new Dictionary <DateTime, int>();
            int fieldCountInSelectedItem = 2;

            var selectedItems = ADOUtils.ExecuteReaderRows(_connectionString, "Select_Distribution_By_ObservationTime", null, fieldCountInSelectedItem);

            if (selectedItems == null)
            {
                throw new SqlStorageException("Can not select distribution by observation time.");
            }

            foreach (var item in selectedItems)
            {
                resultDistribution.Add((DateTime)item["ObservationTime"], (int)item["Count"]);
            }

            return(resultDistribution);
        }
Exemple #11
0
        public IDictionary <Coordinates, int> GetDistributionByCoordinates()
        {
            var resultDistribution       = new Dictionary <Coordinates, int>();
            int fieldCountInSelectedItem = 4;

            var selectedItems = ADOUtils.ExecuteReaderRows(_connectionString, "Select_Distribution_By_Coordinates", null, fieldCountInSelectedItem);

            if (selectedItems == null)
            {
                throw new SqlStorageException("Can not select distribution by coordinates");
            }

            foreach (var item in selectedItems)
            {
                var coordinate = new Coordinates((int)item["Id"], (double)item["X"], (double)item["Y"]);

                resultDistribution.Add(coordinate, (int)item["Count"]);
            }

            return(resultDistribution);
        }