Ejemplo n.º 1
0
        ///CREATE METHODS
        /// <summary>
        /// Creates an electricity meter with the specified attributes
        /// </summary>
        /// <param name="serialNo">string - serial number of the meter</param>
        /// <param name="scalingFactor">int - multiplier for the reading on the meter (eg some meters show x10kWh)</param>
        /// <param name="numbDigits">number of digits on the meter, eg 000123 = 6</param>
        /// <param name="startDate">start date of meter</param>
        /// <param name="propertyId">id of property to which the meter belongs</param>
        /// <returns>JSON representation of id of created meter - int , wrapped in EMResponse obejct</returns>
        public string createElectricityMeter(string serialNo, double scalingFactor, int numbDigits, string startDate, int propertyId)
        {
            EMResponse response = new EMResponse();
            try
            {
                meterMgr = new MeterManager();
                response.data = EMConverter.fromObjectToJSON(meterMgr.createElectricityMeter(serialNo, scalingFactor, numbDigits, startDate, propertyId));
                response.status = ok;
            }
            catch (Exception e)
            {
                response.status = error;
                response.data = e.Message;
            }

            return EMConverter.fromObjectToJSON(response);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Retrieves the date of the most recent invoice on the specifed meter
        /// </summary>
        /// <param name="meterId"></param>
        /// <returns>JSON representation of date string, wrapped in EMResponse obejct</returns>
        public string getLastInvoiceDate(int meterId)
        {
            EMResponse response = new EMResponse();
            try
            {
                meterMgr = new MeterManager();
                response.data = EMConverter.fromObjectToJSON(meterMgr.getLastInvoiceDate(meterId));
                response.status = ok;
            }
            catch (Exception e)
            {
                response.status = error;
                response.data = e.Message;
            }

            return EMConverter.fromObjectToJSON(response);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns list of Chunk objects that represent the total of the specifed datatype between the provided dates, broken down
        /// into the specified interval, eg monthly, annually etc.
        /// </summary>
        /// <param name="meterId"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <param name="intervalId"></param>
        /// <param name="dataTypeId"></param>
        /// <returns>JSON representation of List[Chunk] obejcts, wrapped in EMResponse obejct</returns>
        public string getDataFromMeterByInterval(int meterId, string startDate, string endDate, int intervalId, int dataTypeId)
        {
            EMResponse response = new EMResponse();
            try
            {
                meterMgr = new MeterManager();
                response.data = EMConverter.fromObjectToJSON(meterMgr.getDataFromMeterByInterval(meterId, startDate, endDate, intervalId, dataTypeId));
                response.status = ok;
            }
            catch (Exception e)
            {
                response.status = error;
                response.data = e.Message;
            }

            return EMConverter.fromObjectToJSON(response);
        }
Ejemplo n.º 4
0
        ///DELETE METHODS
        /// <summary>
        /// Removes the meter with specified id and ALL child objects from the database.
        /// </summary>
        /// <param name="meterId"></param>
        /// <returns>void, wrapped in EMResponse obejct</returns>
        public string deleteMeter(int meterId, int propertyId)
        {
            EMResponse response = new EMResponse();
            try
            {
                meterMgr = new MeterManager();
                meterMgr.deleteMeter(meterId, propertyId);
                response.status = ok;
            }
            catch (Exception e)
            {
                response.status = error;
                response.data = e.Message;
            }

            return EMConverter.fromObjectToJSON(response);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Updates the meter reading with the specifed id with the details in the newMeterReading object & updates the annual totals of the
        /// relevant Property object.
        /// </summary>
        /// <param name="readingId">id of reading to be updated</param>
        /// <param name="meterId">id of meter to which the reading belongs</param>
        /// <param name="newMeterReading">JSON representation of MeterReading object with updated details</param>
        /// <param name="propertyId">id of property to which the meter belongs.  Required to update the annual totals.</param>
        /// <returns>JSON representation of updated MeterReading object, wrapped in EMResponse obejct</returns>
        public string editMeterReading(int readingId, int meterId, string newMeterReading, int propertyId)
        {
            EMResponse response = new EMResponse();
            try
            {
                meterMgr = new MeterManager();
                meterMgr.editMeterReading(readingId, meterId, newMeterReading, propertyId);
                response.status = ok;
            }
            catch (Exception e)
            {
                response.status = error;
                response.data = e.Message;
            }

            return EMConverter.fromObjectToJSON(response);
        }
Ejemplo n.º 6
0
 public List <Chunk> getDataFromMeterByInterval(int meterId, string startDate, string endDate, int intervalId, int dataTypeId)
 {
     meterMgr = new MeterManager();
     return(meterMgr.getDataFromMeterByInterval(meterId, startDate, endDate, intervalId, dataTypeId));
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Creates a meter reading & updates annual CO2 and kWh at the property.
        /// </summary>
        /// <param name="date">Date of reading</param>
        /// <param name="reading">the reading, leadings zeros can be omitted</param>
        /// <param name="meterId">id of the meter to which the reading belongs</param>
        /// <param name="propertyId">id of the property to which the meter belongs.  Required to update the annual totals.</param>
        /// <returns>JSON representation of id of created reading obejct, int , wrapped in EMResponse obejct</returns>
        public string createMeterReading(string date, int reading, int meterId, int propertyId)
        {
            EMResponse response = new EMResponse();
            try
            {
                meterMgr = new MeterManager();
                response.data = EMConverter.fromObjectToJSON(meterMgr.createMeterReading(date, reading, meterId, propertyId));
                response.status = ok;
            }
            catch (Exception e)
            {
                response.status = error;
                response.data = e.Message;
            }

            return EMConverter.fromObjectToJSON(response);
        }
Ejemplo n.º 8
0
        //--> METER MANAGER

        public Meter getMeter(int meterId)
        {
            meterMgr = new MeterManager();
            return(meterMgr.getMeter(meterId));
        }
Ejemplo n.º 9
0
 public double getDataFromMeter(int meterId, string startDate, string endDate, int dataTypeId)
 {
     meterMgr = new MeterManager();
     return(meterMgr.getDataFromMeter(meterId, startDate, endDate, dataTypeId));
 }
Ejemplo n.º 10
0
        //public double getCostFromMeter(int meterId, string startDate, string endDate)
        //{
        //    meterMgr = new MeterManager();
        //    return meterMgr.getCostFromMeter(meterId, startDate, endDate);
        //}

        //public List<Chunk> getCostFromMeterByInterval(int meterId, string startDate, string endDate, int intervalId)
        //{
        //    meterMgr = new MeterManager();
        //    return meterMgr.getCostFromMeterByInterval(meterId, startDate, endDate, intervalId);
        //}

        public double getCO2FromMeter(int meterId, string startDate, string endDate)
        {
            meterMgr = new MeterManager();
            return(meterMgr.getCO2FromMeter(meterId, startDate, endDate));
        }
Ejemplo n.º 11
0
 //--> METER MANAGER
 public Meter getMeter(int meterId)
 {
     meterMgr = new MeterManager();
     return meterMgr.getMeter(meterId);
 }
Ejemplo n.º 12
0
 public List<Chunk> getDataFromMeterByInterval(int meterId, string startDate, string endDate, int intervalId, int dataTypeId)
 {
     meterMgr = new MeterManager();
     return meterMgr.getDataFromMeterByInterval(meterId, startDate, endDate, intervalId, dataTypeId);
 }
Ejemplo n.º 13
0
 public double getDataFromMeter(int meterId, string startDate, string endDate, int dataTypeId)
 {
     meterMgr = new MeterManager();
     return meterMgr.getDataFromMeter(meterId, startDate, endDate, dataTypeId);
 }
Ejemplo n.º 14
0
 //public double getCostFromMeter(int meterId, string startDate, string endDate)
 //{
 //    meterMgr = new MeterManager();
 //    return meterMgr.getCostFromMeter(meterId, startDate, endDate);
 //}
 //public List<Chunk> getCostFromMeterByInterval(int meterId, string startDate, string endDate, int intervalId)
 //{
 //    meterMgr = new MeterManager();
 //    return meterMgr.getCostFromMeterByInterval(meterId, startDate, endDate, intervalId);
 //}
 public double getCO2FromMeter(int meterId, string startDate, string endDate)
 {
     meterMgr = new MeterManager();
     return meterMgr.getCO2FromMeter(meterId, startDate, endDate);
 }