Ejemplo n.º 1
0
        public List <Response.DeviceTypeUsageResponse> GetDeviceTypeUsage(Request.ChartRequest request)
        {
            List <Response.DeviceTypeUsageResponse> result = new List <Response.DeviceTypeUsageResponse>();

            try
            {
                _logger.InfoLog(Constants.ACTION_ENTRY, "Chart_UtilizationByDeviceType.Get");
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, component.helper.SolutionConfiguration.Version);

                    parameters.Add(sqlDataAccess.CreateParameter("companyGuid", component.helper.SolutionConfiguration.CompanyId, DbType.Guid, ParameterDirection.Input));
                    if (request.EntityGuid != null && request.EntityGuid != Guid.Empty)
                    {
                        parameters.Add(sqlDataAccess.CreateParameter("parentEntityGuid", request.EntityGuid, DbType.Guid, ParameterDirection.Input));
                    }

                    parameters.Add(sqlDataAccess.CreateParameter("frequency", request.Frequency, DbType.String, ParameterDirection.Input));

                    parameters.Add(sqlDataAccess.CreateParameter("syncDate", DateTime.UtcNow, DbType.DateTime, ParameterDirection.Output));
                    parameters.Add(sqlDataAccess.CreateParameter("enableDebugInfo", component.helper.SolutionConfiguration.EnableDebugInfo, DbType.String, ParameterDirection.Input));
                    DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[Chart_UtilizationByDeviceType]", CommandType.StoredProcedure, null), parameters.ToArray());
                    result = DataUtils.DataReaderToList <Response.DeviceTypeUsageResponse>(dbDataReader, null);
                }
                _logger.InfoLog(Constants.ACTION_EXIT, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            }
            catch (Exception ex)
            {
                _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            }
            return(result);
        }
Ejemplo n.º 2
0
        public List <Response.WaterUsageResponse> GetWaterUsage(Request.ChartRequest request)
        {
            List <Response.WaterUsageResponse> result = new List <Response.WaterUsageResponse>();

            try
            {
                _logger.InfoLog(LogHandler.Constants.ACTION_ENTRY, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, component.helper.SolutionConfiguration.Version);
                    parameters.Add(sqlDataAccess.CreateParameter("companyguid", component.helper.SolutionConfiguration.CompanyId, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("entityguid", request.GreenHouseGuid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("guid", request.HardwareKitGuid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("enableDebugInfo", component.helper.SolutionConfiguration.EnableDebugInfo, DbType.String, ParameterDirection.Input));
                    DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[Chart_WaterConsumption]", CommandType.StoredProcedure, null), parameters.ToArray());
                    result = DataUtils.DataReaderToList <Response.WaterUsageResponse>(dbDataReader, null);
                }
                _logger.InfoLog(LogHandler.Constants.ACTION_EXIT, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            }
            catch (Exception ex)
            {
                _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            }

            return(result);
        }
Ejemplo n.º 3
0
        public Entity.BaseResponse <List <Response.FuelUsageResponse> > GetFuelUsage(Request.ChartRequest request)
        {
            Entity.BaseResponse <List <Response.FuelUsageResponse> > result = new Entity.BaseResponse <List <Response.FuelUsageResponse> >();
            try
            {
                _logger.InfoLog(Constants.ACTION_ENTRY, "Chart_FuelUsed.Get");
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, component.helper.SolutionConfiguration.Version);
                    parameters.Add(sqlDataAccess.CreateParameter("entityguid", request.EntityGuid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("guid", request.DeviceGuid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("enableDebugInfo", component.helper.SolutionConfiguration.EnableDebugInfo, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("syncDate", DateTime.UtcNow, DbType.DateTime, ParameterDirection.Output));
                    DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[Chart_FuelUsed]", CommandType.StoredProcedure, null), parameters.ToArray());
                    result.Data = DataUtils.DataReaderToList <Response.FuelUsageResponse>(dbDataReader, null);
                    if (parameters.Where(p => p.ParameterName.Equals("syncDate")).FirstOrDefault() != null)
                    {
                        result.LastSyncDate = Convert.ToString(parameters.Where(p => p.ParameterName.Equals("syncDate")).FirstOrDefault().Value);
                    }
                }
                _logger.InfoLog(Constants.ACTION_EXIT, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            }
            catch (Exception ex)
            {
                _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            }

            return(result);
        }
Ejemplo n.º 4
0
        public List <Response.FuelUsageResponse> GetFuelUsage(Request.ChartRequest request)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("companyguid", request.CompanyGuid.ToString());
            parameters.Add("entityguid", request.EntityGuid.ToString());
            parameters.Add("hardwarekitguid", request.HardwareKitGuid.ToString());
            return(_entityRepository.ExecuteStoredProcedure <Response.FuelUsageResponse>("[ChartDate]", parameters));
        }
Ejemplo n.º 5
0
        public List <Response.DeviceBatteryStatusResponse> GetDeviceBatteryStatus(Request.ChartRequest request)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("companyguid", request.CompanyGuid.ToString());
            parameters.Add("entityguid", request.EntityGuid.ToString());
            parameters.Add("hardwarekitguid", request.HardwareKitGuid.ToString());
            return(_entityRepository.ExecuteStoredProcedure <Response.DeviceBatteryStatusResponse>("[GensetUsage_Get]", parameters));
        }
Ejemplo n.º 6
0
        public List <Response.EnergyUsageResponse> GetEnergyUsage(Request.ChartRequest request)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("companyguid", request.CompanyGuid.ToString());
            parameters.Add("greenhouseguid", request.EntityGuid.ToString());
            parameters.Add("hardwarekitguid", request.DeviceGuid.ToString());
            return(_locationRepository.ExecuteStoredProcedure <Response.EnergyUsageResponse>("[ChartDate]", parameters));
        }
 public Entity.BaseResponse <List <Response.FuelUsageResponse> > FuelUsage(Request.ChartRequest request)
 {
     Entity.BaseResponse <List <Response.FuelUsageResponse> > response = new Entity.BaseResponse <List <Response.FuelUsageResponse> >(true);
     try
     {
         response.Data = _chartService.GetFuelUsage(request);
     }
     catch (Exception ex) {
         base.LogException(ex);
     }
     return(response);
 }
Ejemplo n.º 8
0
 public Entity.BaseResponse <List <Response.WaterUsageResponse> > WaterUsage(Request.ChartRequest request)
 {
     Entity.BaseResponse <List <Response.WaterUsageResponse> > response = new Entity.BaseResponse <List <Response.WaterUsageResponse> >(true);
     try
     {
         response.Data = _chartService.GetWaterUsage(request);
     }
     catch (Exception ex)
     {
         base.LogException(ex);
         return(new Entity.BaseResponse <List <Response.WaterUsageResponse> >(false, ex.Message));
     }
     return(response);
 }
Ejemplo n.º 9
0
 public Entity.BaseResponse <List <Response.FuelUsageResponse> > GetFuelUsage(Request.ChartRequest request)
 {
     Entity.BaseResponse <List <Response.FuelUsageResponse> > response = new Entity.BaseResponse <List <Response.FuelUsageResponse> >(true);
     try
     {
         response           = _chartService.GetFuelUsage(request);
         response.IsSuccess = true;
     }
     catch (Exception ex)
     {
         base.LogException(ex);
         return(new Entity.BaseResponse <List <Response.FuelUsageResponse> >(false, ex.Message));
     }
     return(response);
 }
Ejemplo n.º 10
0
        public Entity.BaseResponse <List <Response.EnergyConsumption> > GetEnergyUsage(Request.ChartRequest request)
        {
            Entity.BaseResponse <List <Response.EnergyConsumption> > result = new Entity.BaseResponse <List <Response.EnergyConsumption> >();
            List <Response.EnergyConsumption> energylst = new List <Response.EnergyConsumption>();

            try
            {
                _logger.InfoLog(Constants.ACTION_ENTRY, "Chart_EnergyConsumption.Get");
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <Response.EnergyConsumptionResponse> data = new List <Response.EnergyConsumptionResponse>();
                    List <DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, component.helper.SolutionConfiguration.Version);
                    if (!request.CompanyGuid.Equals(Guid.Empty))
                    {
                        parameters.Add(sqlDataAccess.CreateParameter("companyguid", request.CompanyGuid, DbType.Guid, ParameterDirection.Input));
                    }
                    if (!request.EntityGuid.Equals(Guid.Empty))
                    {
                        parameters.Add(sqlDataAccess.CreateParameter("entityguid", request.EntityGuid, DbType.Guid, ParameterDirection.Input));
                    }
                    if (!request.DeviceGuid.Equals(Guid.Empty))
                    {
                        parameters.Add(sqlDataAccess.CreateParameter("guid", request.DeviceGuid, DbType.Guid, ParameterDirection.Input));
                    }
                    parameters.Add(sqlDataAccess.CreateParameter("syncDate", DateTime.UtcNow, DbType.DateTime, ParameterDirection.Output));
                    parameters.Add(sqlDataAccess.CreateParameter("enableDebugInfo", component.helper.SolutionConfiguration.EnableDebugInfo, DbType.String, ParameterDirection.Input));
                    DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[Chart_CurrentConsumption]", CommandType.StoredProcedure, null), parameters.ToArray());
                    data = DataUtils.DataReaderToList <Response.EnergyConsumptionResponse>(dbDataReader, null);
                    if (parameters.Where(p => p.ParameterName.Equals("syncDate")).FirstOrDefault() != null)
                    {
                        result.LastSyncDate = Convert.ToString(parameters.Where(p => p.ParameterName.Equals("syncDate")).FirstOrDefault().Value);
                    }
                    var resultGrp = from item in data
                                    group item by item.Month
                                    into egroup
                                    select egroup;
                    foreach (var group in resultGrp)
                    {
                        List <Response.EnergyConsumptionByMonth> lookupItems = new List <Response.EnergyConsumptionByMonth>();
                        foreach (var items in group)
                        {
                            lookupItems.Add(new Response.EnergyConsumptionByMonth {
                                Year = items.Year, Value = items.Value
                            });
                        }
                        energylst.Add(new Response.EnergyConsumption {
                            Month = group.Key, EnergyValue = lookupItems
                        });
                    }
                    result.Data      = energylst;
                    result.IsSuccess = true;
                }
                _logger.InfoLog(Constants.ACTION_EXIT, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            }
            catch (Exception ex)
            {
                _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            }
            return(result);
        }
 public Entity.BaseResponse <List <Response.DeviceBatteryStatusResponse> > DeviceBatteryStatus(Request.ChartRequest request)
 {
     Entity.BaseResponse <List <Response.DeviceBatteryStatusResponse> > response = new Entity.BaseResponse <List <Response.DeviceBatteryStatusResponse> >(true);
     try
     {
         response.Data = _chartService.GetDeviceBatteryStatus(request);
     }
     catch (Exception ex)
     {
         base.LogException(ex);
     }
     return(response);
 }
Ejemplo n.º 12
0
 public Entity.BaseResponse <List <Response.EnergyConsumption> > EnergyConsumption(Request.ChartRequest request)
 {
     Entity.BaseResponse <List <Response.EnergyConsumption> > response = new Entity.BaseResponse <List <Response.EnergyConsumption> >(true);
     try
     {
         response           = _chartService.GetEnergyUsage(request);
         response.Message   = "Data Loaded Successfully !!";
         response.IsSuccess = true;
     }
     catch (Exception ex) {
         base.LogException(ex);
     }
     return(response);
 }
Ejemplo n.º 13
0
 public Entity.BaseResponse <List <Response.CompanyUsageResponse> > CompanyUsage(Request.ChartRequest request)
 {
     Entity.BaseResponse <List <Response.CompanyUsageResponse> > response = new Entity.BaseResponse <List <Response.CompanyUsageResponse> >(true);
     try
     {
         response.Data = _chartService.GetCompanyUsage(request);
         if (response.Data.Count == 0)
         {
             response.IsSuccess = false;
             response.Message   = "No usage found";
         }
         else if (response.Data.Count > 0 && int.Parse(response.Data[0].UtilizationPer) <= 0)
         {
             response.IsSuccess = false;
             response.Message   = "No usage found";
         }
     }
     catch (Exception ex)
     {
         base.LogException(ex);
     }
     return(response);
 }
Ejemplo n.º 14
0
 public Entity.BaseResponse <List <Response.DeviceTypeUsageResponse> > DeviceTypeUsage(Request.ChartRequest request)
 {
     Entity.BaseResponse <List <Response.DeviceTypeUsageResponse> > response = new Entity.BaseResponse <List <Response.DeviceTypeUsageResponse> >(true);
     try
     {
         response.Data = _chartService.GetDeviceTypeUsage(request);
         if (response.Data.Count == 0)
         {
             response.IsSuccess = false;
             response.Message   = "No usage found";
         }
     }
     catch (Exception ex) {
         base.LogException(ex);
     }
     return(response);
 }