public Entity.BaseResponse <List <Entity.KitDevice> > ProvisionKit(Entity.ProvisionKitRequest request)
        {
            Entity.BaseResponse <List <Entity.KitDevice> > result = new Entity.BaseResponse <List <Entity.KitDevice> >();
            try
            {
                _logger.InfoLog(LogHandler.Constants.ACTION_ENTRY, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    var kitDevices = string.Join(",", request.KitDevices);

                    List <System.Data.Common.DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CompanyId, component.helper.SolutionConfiguration.Version);
                    parameters.Add(sqlDataAccess.CreateParameter("kitCode", request.KitCode, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("uniqueId", kitDevices, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("greenhouseguid", request.GreenHouseGuid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("culture", component.helper.SolutionConfiguration.Culture, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("enableDebugInfo", component.helper.SolutionConfiguration.EnableDebugInfo, DbType.String, ParameterDirection.Input));
                    System.Data.Common.DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[Provision_HardwareKit]", CommandType.StoredProcedure, null), parameters.ToArray());
                    result.Data = DataUtils.DataReaderToList <Entity.KitDevice>(dbDataReader, null);
                    if (parameters.Where(p => p.ParameterName.Equals("output")).FirstOrDefault().Value.ToString() == "1")
                    {
                        result.Message = parameters.Where(p => p.ParameterName.Equals("fieldname")).FirstOrDefault().Value.ToString();
                    }
                }
                _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);
        }
Example #2
0
 public Entity.BaseResponse <List <Response.EnergyConsumptionByMeter> > GetEnergyConsumptionByMeter(Request.ChartRequest request)
 {
     Entity.BaseResponse <List <Response.EnergyConsumptionByMeter> > result = new Entity.BaseResponse <List <Response.EnergyConsumptionByMeter> >();
     try
     {
         _logger.InfoLog(Constants.ACTION_ENTRY, "Chart_StatisticsByEntity.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("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_EnergyConsumptionByMeter]", CommandType.StoredProcedure, null), parameters.ToArray());
             result.Data = DataUtils.DataReaderToList <Response.EnergyConsumptionByMeter>(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);
 }
Example #3
0
        public ActionStatus DeleteMediaFiles(Guid deviceId, Guid?fileId)
        {
            ActionStatus result = new ActionStatus(true);

            try
            {
                logger.InfoLog(Constants.ACTION_ENTRY, "DeviceRepository.DeleteMediaFiles");
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, component.helper.SolutionConfiguration.Version);
                    parameters.Add(sqlDataAccess.CreateParameter("guid", fileId, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("deviceGuid", deviceId, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("status", true, DbType.Boolean, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("culture", component.helper.SolutionConfiguration.Culture, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("enableDebugInfo", component.helper.SolutionConfiguration.EnableDebugInfo, DbType.String, ParameterDirection.Input));
                    sqlDataAccess.ExecuteNonQuery(sqlDataAccess.CreateCommand("[DeviceFiles_UpdateStatus]", CommandType.StoredProcedure, null), parameters.ToArray());
                    int outPut = int.Parse(parameters.Where(p => p.ParameterName.Equals("output")).FirstOrDefault().Value.ToString());
                    if (outPut > 0)
                    {
                        result.Success = true;
                    }
                    else
                    {
                        result.Success = false;
                    }
                    result.Message = parameters.Where(p => p.ParameterName.Equals("fieldname")).FirstOrDefault().Value.ToString();
                }
                logger.InfoLog(Constants.ACTION_EXIT, "DeviceRepository.DeleteMediaFiles");
            }
            catch (Exception ex)
            {
                logger.ErrorLog(Constants.ACTION_EXCEPTION, ex);
            }
            return(result);
        }
Example #4
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);
        }
        public ActionStatus UpdateDetails(Model.User request)
        {
            ActionStatus result = new ActionStatus(true);

            try
            {
                logger.Information(Constants.ACTION_ENTRY, "UserRepository.UpdateDetails");
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, component.helper.SolutionConfiguration.Version);
                    parameters.Add(sqlDataAccess.CreateParameter("companyGuid", request.CompanyGuid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("email", request.Email, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("contactNo", request.ContactNo, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("firstName", request.FirstName, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("lastName", request.LastName, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("timezoneGuid", request.TimeZoneGuid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("culture", component.helper.SolutionConfiguration.Culture, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("enableDebugInfo", component.helper.SolutionConfiguration.EnableDebugInfo, DbType.String, ParameterDirection.Input));
                    int intResult = sqlDataAccess.ExecuteNonQuery(sqlDataAccess.CreateCommand("[User_UpdateDetail]", CommandType.StoredProcedure, null), parameters.ToArray());
                    result.Data = int.Parse(parameters.Where(p => p.ParameterName.Equals("newid")).FirstOrDefault().Value.ToString());
                }
                logger.Information(Constants.ACTION_EXIT, "UserRepository.UpdateDetails");
            }
            catch (Exception ex)
            {
                logger.Error(Constants.ACTION_EXCEPTION, ex);
            }
            return(result);
        }
 public Entity.BaseResponse <int> ValidateKit(string kitCode)
 {
     Entity.BaseResponse <int> result = new Entity.BaseResponse <int>();
     try
     {
         _logger.InfoLog(LogHandler.Constants.ACTION_ENTRY, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
         using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
         {
             List <System.Data.Common.DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CompanyId, component.helper.SolutionConfiguration.Version);
             parameters.Add(sqlDataAccess.CreateParameter("kitCode", kitCode, DbType.String, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("culture", component.helper.SolutionConfiguration.Culture, DbType.String, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("enableDebugInfo", component.helper.SolutionConfiguration.EnableDebugInfo, DbType.String, ParameterDirection.Input));
             result.Data = (Int32)(sqlDataAccess.ExecuteScalar(sqlDataAccess.CreateCommand("[Validate_KitCode]", CommandType.StoredProcedure, null), parameters.ToArray()));
             if (result.Data > 0 && result != null)
             {
                 result.IsSuccess = true;
             }
         }
         _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);
 }
Example #7
0
        public Entity.BaseResponse <List <Entity.AttributeItem> > DeviceAttributeLookup(Guid deviceId)
        {
            Entity.BaseResponse <List <Entity.AttributeItem> > result = new Entity.BaseResponse <List <Entity.AttributeItem> >();
            try
            {
                _logger.InfoLog(Constants.ACTION_ENTRY, "Device_LatestAttributeValue_Get.Get");
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, component.helper.SolutionConfiguration.Version);
                    parameters.Add(sqlDataAccess.CreateParameter("guid", deviceId, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("syncDate", DateTime.UtcNow, DbType.DateTime, ParameterDirection.Output));

                    DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[Device_LatestAttributeValue_Get]", CommandType.StoredProcedure, null), parameters.ToArray());
                    result.Data = DataUtils.DataReaderToList <Entity.AttributeItem>(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);
        }
 public Entity.SearchResult <List <Entity.GreenHouseDetail> > List(Entity.SearchRequest request)
 {
     Entity.SearchResult <List <Entity.GreenHouseDetail> > result = new Entity.SearchResult <List <Entity.GreenHouseDetail> >();
     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, request.Version);
             parameters.Add(sqlDataAccess.CreateParameter("companyguid", component.helper.SolutionConfiguration.CompanyId, DbType.Guid, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("search", request.SearchText, DbType.String, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("pagesize", request.PageSize, DbType.Int32, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("pagenumber", request.PageNumber, DbType.Int32, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("orderby", request.OrderBy, DbType.String, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("count", DbType.Int32, ParameterDirection.Output, 16));
             DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[GreenHouse_List]", CommandType.StoredProcedure, null), parameters.ToArray());
             result.Items = DataUtils.DataReaderToList <Entity.GreenHouseDetail>(dbDataReader, null);
             result.Count = int.Parse(parameters.Where(p => p.ParameterName.Equals("count")).FirstOrDefault().Value.ToString());
         }
         _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);
 }
Example #9
0
 public Entity.SearchResult <List <Entity.AlertResponse> > GetAlertList(Entity.AlertRequest request)
 {
     Entity.SearchResult <List <Entity.AlertResponse> > result = new Entity.SearchResult <List <Entity.AlertResponse> >();
     try
     {
         logger.InfoLog(Constants.ACTION_ENTRY, MethodBase.GetCurrentMethod().Name);
         using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
         {
             List <System.Data.Common.DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, "v1");
             parameters.Add(sqlDataAccess.CreateParameter("companyGuid", component.helper.SolutionConfiguration.CompanyId, DbType.Guid, ParameterDirection.Input));
             if (!string.IsNullOrEmpty(request.EntityGuid))
             {
                 parameters.Add(sqlDataAccess.CreateParameter("entityGuid", Guid.Parse(request.EntityGuid), DbType.Guid, ParameterDirection.Input));
             }
             if (!string.IsNullOrEmpty(request.DeviceGuid))
             {
                 parameters.Add(sqlDataAccess.CreateParameter("deviceGuid", Guid.Parse(request.DeviceGuid), DbType.Guid, ParameterDirection.Input));
             }
             parameters.Add(sqlDataAccess.CreateParameter("pagesize", request.PageSize, DbType.Int32, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("pagenumber", request.PageNumber, DbType.Int32, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("orderby", request.OrderBy, DbType.String, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("count", DbType.Int32, ParameterDirection.Output, 16));
             System.Data.Common.DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[Alert_List]", CommandType.StoredProcedure, null), parameters.ToArray());
             result.Items = DataUtils.DataReaderToList <Entity.AlertResponse>(dbDataReader, null);
             result.Count = int.Parse(parameters.Where(p => p.ParameterName.Equals("count")).FirstOrDefault().Value.ToString());
         }
         logger.InfoLog(Constants.ACTION_EXIT, MethodBase.GetCurrentMethod().Name);
     }
     catch (Exception ex)
     {
         logger.ErrorLog(Constants.ACTION_EXCEPTION, ex);
     }
     return(result);
 }
Example #10
0
        public Entity.DeviceMaintenance Get(Guid id, DateTime currentDate, string timeZone)
        {
            List <Entity.DeviceMaintenance> result = new List <Entity.DeviceMaintenance>();

            Entity.DeviceMaintenance maintenanceDetail = new Entity.DeviceMaintenance();
            try
            {
                DateTime dateValue;
                if (DateTime.TryParse(currentDate.ToString(), out dateValue))
                {
                    dateValue = dateValue.AddMinutes(-double.Parse(timeZone));
                }
                logger.InfoLog(Constants.ACTION_ENTRY, "DeviceMaintenanceRepository.GetUpComingList");
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, "v1");
                    parameters.Add(sqlDataAccess.CreateParameter("guid", id, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("currentDate", dateValue, DbType.DateTime, ParameterDirection.Input));
                    DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[DeviceMaintenance_Get]", CommandType.StoredProcedure, null), parameters.ToArray());
                    result = DataUtils.DataReaderToList <Entity.DeviceMaintenance>(dbDataReader, null);
                    if (result.Count > 0)
                    {
                        maintenanceDetail = result[0];
                    }
                }
                logger.InfoLog(Constants.ACTION_EXIT, "DeviceMaintenanceRepository.GetUpComingList");
            }
            catch (Exception ex)
            {
                logger.ErrorLog(Constants.ACTION_EXCEPTION, ex);
            }
            return(maintenanceDetail);
        }
Example #11
0
 public Entity.BaseResponse <List <Entity.DeviceAttributeChartResponse> > GetDeviceAttributeChartData(Guid deviceGuid, string attributeName, string frequency)
 {
     Entity.BaseResponse <List <Entity.DeviceAttributeChartResponse> > result = new Entity.BaseResponse <List <Entity.DeviceAttributeChartResponse> >(true);
     try
     {
         logger.Information(Constants.ACTION_ENTRY, "DeviceRepository.GetDeviceAttributeChartData");
         using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
         {
             List <System.Data.Common.DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CompanyId, component.helper.SolutionConfiguration.Version);
             parameters.Add(sqlDataAccess.CreateParameter("guid", deviceGuid, DbType.Guid, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("attribute", attributeName, DbType.String, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("frequency", frequency, DbType.String, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("culture", component.helper.SolutionConfiguration.Culture, DbType.String, 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));
             System.Data.Common.DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[Chart_QualityParameter]", CommandType.StoredProcedure, null), parameters.ToArray());
             result.Data = DataUtils.DataReaderToList <Entity.DeviceAttributeChartResponse>(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.Information(Constants.ACTION_EXIT, "DeviceRepository.GetDeviceAttributeChartData");
     }
     catch (Exception ex)
     {
         logger.Error(Constants.ACTION_EXCEPTION, ex);
     }
     return(result);
 }
Example #12
0
        public Entity.BaseResponse <List <Entity.EntityDashboardOverviewResponse> > GetStatistics(Guid entityId, DateTime currentDate, string timeZone)
        {
            Entity.BaseResponse <List <Entity.EntityDashboardOverviewResponse> > result = new Entity.BaseResponse <List <Entity.EntityDashboardOverviewResponse> >();
            try
            {
                logger.InfoLog(Constants.ACTION_ENTRY, "EntityRepository.Get");
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    DateTime dateValue;
                    if (DateTime.TryParse(currentDate.ToString(), out dateValue))
                    {
                        dateValue = dateValue.AddMinutes(-double.Parse(timeZone));
                    }
                    List <DbParameter> parameters = sqlDataAccess.CreateParams(SolutionConfiguration.CurrentUserId, SolutionConfiguration.Version);
                    parameters.Add(sqlDataAccess.CreateParameter("guid", entityId, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("currentDate", dateValue, DbType.DateTime, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("syncDate", DateTime.UtcNow, DbType.DateTime, ParameterDirection.Output));
                    DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[EntityStatistics_Get]", CommandType.StoredProcedure, null), parameters.ToArray());

                    result.Data = DataUtils.DataReaderToList <Entity.EntityDashboardOverviewResponse>(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, "EntityRepository.Get");
            }
            catch (Exception ex)
            {
                logger.ErrorLog(Constants.ACTION_EXCEPTION, ex);
            }
            return(result);
        }
Example #13
0
 public Entity.BaseResponse <int> ValidateKit(string kitCode)
 {
     Entity.BaseResponse <int> result = new Entity.BaseResponse <int>();
     try
     {
         logger.Information(Constants.ACTION_ENTRY, "ValidateKit.Get");
         using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
         {
             List <System.Data.Common.DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CompanyId, component.helper.SolutionConfiguration.Version);
             parameters.Add(sqlDataAccess.CreateParameter("kitCode", kitCode, DbType.String, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("culture", component.helper.SolutionConfiguration.Culture, DbType.String, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("enableDebugInfo", component.helper.SolutionConfiguration.EnableDebugInfo, DbType.String, ParameterDirection.Input));
             sqlDataAccess.ExecuteScalar(sqlDataAccess.CreateCommand("[Validate_KitCode]", CommandType.StoredProcedure, null), parameters.ToArray());
             int outPut = int.Parse(parameters.Where(p => p.ParameterName.Equals("output")).FirstOrDefault().Value.ToString());
             if (outPut > 0)
             {
                 result.IsSuccess = true;
             }
             else
             {
                 result.IsSuccess = false;
             }
             result.Message = parameters.Where(p => p.ParameterName.Equals("fieldname")).FirstOrDefault().Value.ToString();
         }
         logger.Information(Constants.ACTION_EXIT, "ValidateKit.Get");
     }
     catch (Exception ex)
     {
         logger.Error(Constants.ACTION_EXCEPTION, ex);
     }
     return(result);
 }
        public Entity.DeviceDetail Get(Guid deviceId)
        {
            List <Entity.DeviceDetail> listResult = new List <Entity.DeviceDetail>();
            var result = new Entity.DeviceDetail();

            try
            {
                logger.InfoLog(Constants.ACTION_ENTRY, "DeviceRepository.Get");

                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <System.Data.Common.DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CompanyId, component.helper.SolutionConfiguration.Version);
                    parameters.Add(sqlDataAccess.CreateParameter("companyGuid", component.helper.SolutionConfiguration.CompanyId, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("guid", deviceId, DbType.Guid, ParameterDirection.Input));
                    DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[Device_Get]", CommandType.StoredProcedure, null), parameters.ToArray());
                    listResult = DataUtils.DataReaderToList <Entity.DeviceDetail>(dbDataReader, null);
                    if (listResult.Count > 0)
                    {
                        result = listResult[0];
                    }
                }
                logger.InfoLog(Constants.ACTION_EXIT, "DeviceRepository.Get");
            }
            catch (Exception ex)
            {
                logger.ErrorLog(Constants.ACTION_EXCEPTION, ex);
            }
            return(result);
        }
        public Entity.SearchResult <List <Entity.HardwareKitResponse> > List(Entity.SearchRequest request, bool isAssigned, string companyId)
        {
            Entity.SearchResult <List <Entity.HardwareKitResponse> > result = new Entity.SearchResult <List <Entity.HardwareKitResponse> >();
            try
            {
                logger.Information(Constants.ACTION_ENTRY, "HardwareKitRepository.Get");
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <System.Data.Common.DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, request.Version);
                    if (!string.IsNullOrEmpty(companyId))
                    {
                        parameters.Add(sqlDataAccess.CreateParameter("companyguid", Guid.Parse(companyId), DbType.Guid, ParameterDirection.Input));
                    }

                    parameters.Add(sqlDataAccess.CreateParameter("search", request.SearchText, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("isAssigned", isAssigned ? 1 : 0, DbType.Int32, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("pagesize", request.PageSize, DbType.Int32, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("pagenumber", request.PageNumber, DbType.Int32, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("orderby", request.OrderBy, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("count", DbType.Int32, ParameterDirection.Output, 16));
                    System.Data.Common.DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[HardwareKit_List]", CommandType.StoredProcedure, null), parameters.ToArray());
                    result.Items = DataUtils.DataReaderToList <Entity.HardwareKitResponse>(dbDataReader, null);
                    result.Count = int.Parse(parameters.Where(p => p.ParameterName.Equals("count")).FirstOrDefault().Value.ToString());
                }
                logger.Information(Constants.ACTION_EXIT, "HardwareKitRepository.Get");
            }
            catch (Exception ex)
            {
                logger.Error(Constants.ACTION_EXCEPTION, ex);
            }
            return(result);
        }
 public Entity.BaseResponse <List <Entity.BuildingOverviewResponse> > GetBuildingOverview(Guid buildingId, string frequency)
 {
     Entity.BaseResponse <List <Entity.BuildingOverviewResponse> > result = new Entity.BaseResponse <List <Entity.BuildingOverviewResponse> >();
     try
     {
         logger.InfoLog(Constants.ACTION_ENTRY, "EntityRepository.GetBuildingOverview");
         using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
         {
             List <DbParameter> parameters = sqlDataAccess.CreateParams(SolutionConfiguration.CurrentUserId, SolutionConfiguration.Version);
             parameters.Add(sqlDataAccess.CreateParameter("guid", buildingId, DbType.Guid, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("frequency", frequency, DbType.String, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("syncDate", DateTime.UtcNow, DbType.DateTime, ParameterDirection.Output));
             DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[BuildingStatistics_Get]", CommandType.StoredProcedure, null), parameters.ToArray());
             result.Data = DataUtils.DataReaderToList <Entity.BuildingOverviewResponse>(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, "EntityRepository.GetBuildingOverview");
     }
     catch (Exception ex)
     {
         logger.ErrorLog(Constants.ACTION_EXCEPTION, ex);
     }
     return(result);
 }
Example #17
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);
        }
Example #18
0
        public List <Entity.DeviceMaintenanceResponse> GetUpComingList(Entity.DeviceMaintenanceRequest request)
        {
            List <Entity.DeviceMaintenanceResponse> result = new List <Entity.DeviceMaintenanceResponse>();

            try
            {
                logger.InfoLog(Constants.ACTION_ENTRY, "DeviceMaintenanceRepository.GetUpComingList");
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, "v1");
                    parameters.Add(sqlDataAccess.CreateParameter("companyguid", component.helper.SolutionConfiguration.CompanyId, DbType.Guid, ParameterDirection.Input));
                    if (request.EntityGuid.HasValue)
                    {
                        parameters.Add(sqlDataAccess.CreateParameter("entityGuid", request.EntityGuid.Value, DbType.Guid, ParameterDirection.Input));
                    }
                    if (request.DeviceGuid.HasValue)
                    {
                        parameters.Add(sqlDataAccess.CreateParameter("guid", request.DeviceGuid, DbType.Guid, ParameterDirection.Input));
                    }
                    parameters.Add(sqlDataAccess.CreateParameter("currentDate", request.currentDate, DbType.DateTime, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("count", DbType.Int32, ParameterDirection.Output, 16));
                    DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[DeviceMaintenance_UpComingList]", CommandType.StoredProcedure, null), parameters.ToArray());
                    result = DataUtils.DataReaderToList <Entity.DeviceMaintenanceResponse>(dbDataReader, null);
                }
                logger.InfoLog(Constants.ACTION_EXIT, "DeviceMaintenanceRepository.GetUpComingList");
            }
            catch (Exception ex)
            {
                logger.ErrorLog(Constants.ACTION_EXCEPTION, ex);
            }
            return(result);
        }
 public Entity.SearchResult <List <Entity.EntityDetail> > List(Entity.SearchRequest request)
 {
     Entity.SearchResult <List <Entity.EntityDetail> > result = new Entity.SearchResult <List <Entity.EntityDetail> >();
     try
     {
         logger.InfoLog(Constants.ACTION_ENTRY, "EntityRepository.Get");
         using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
         {
             List <DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, request.Version);
             if (!request.EntityId.Equals(Guid.Empty) && !request.EntityId.Equals(SolutionConfiguration.EntityGuid))
             {
                 parameters.Add(sqlDataAccess.CreateParameter("parentEntityGuid", request.EntityId, DbType.Guid, ParameterDirection.Input));
             }
             parameters.Add(sqlDataAccess.CreateParameter("companyguid", component.helper.SolutionConfiguration.CompanyId, DbType.Guid, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("search", request.SearchText, DbType.String, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("pagesize", request.PageSize, DbType.Int32, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("pagenumber", request.PageNumber, DbType.Int32, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("orderby", request.OrderBy, DbType.String, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("count", DbType.Int32, ParameterDirection.Output, 16));
             DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[Entity_List]", CommandType.StoredProcedure, null), parameters.ToArray());
             result.Items = DataUtils.DataReaderToList <Entity.EntityDetail>(dbDataReader, null);
             result.Count = int.Parse(parameters.Where(p => p.ParameterName.Equals("count")).FirstOrDefault().Value.ToString());
         }
         logger.InfoLog(Constants.ACTION_EXIT, "EntityRepository.Get");
     }
     catch (Exception ex)
     {
         logger.ErrorLog(Constants.ACTION_EXCEPTION, ex);
     }
     return(result);
 }
Example #20
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);
        }
        public ActionStatus Manage(Model.Role request)
        {
            ActionStatus result = new ActionStatus(true);

            try
            {
                logger.InfoLog(Constants.ACTION_ENTRY, "RoleRepository.Manage");
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, component.helper.SolutionConfiguration.Version);
                    parameters.Add(sqlDataAccess.CreateParameter("companyGuid", request.CompanyGuid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("name", request.Name, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("description", request.Description, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("isAdminRole", request.IsAdminRole, DbType.Boolean, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("newid", request.Guid, DbType.Guid, ParameterDirection.Output));
                    parameters.Add(sqlDataAccess.CreateParameter("culture", component.helper.SolutionConfiguration.Culture, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("enableDebugInfo", component.helper.SolutionConfiguration.EnableDebugInfo, DbType.String, ParameterDirection.Input));
                    int intResult = sqlDataAccess.ExecuteNonQuery(sqlDataAccess.CreateCommand("[Role_AddUpdate]", CommandType.StoredProcedure, null), parameters.ToArray());
                    result.Data = parameters.Where(p => p.ParameterName.Equals("newid")).FirstOrDefault().Value.ToString();
                }
                logger.InfoLog(Constants.ACTION_EXIT, "RoleRepository.Manage");
            }
            catch (Exception ex)
            {
                logger.ErrorLog(Constants.ACTION_EXCEPTION, ex);
            }
            return(result);
        }
Example #22
0
        public ActionStatus UpdateDetails(Model.Company request)
        {
            ActionStatus result = new ActionStatus(true);

            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", request.Guid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("name", request.Name, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("contactNo", request.ContactNo, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("address", request.Address, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("countryGuid", request.CountryGuid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("stateGuid", request.StateGuid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("city", request.City, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("postalCode", request.PostalCode, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("timezoneGuid", request.TimezoneGuid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("culture", component.helper.SolutionConfiguration.Culture, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("enableDebugInfo", component.helper.SolutionConfiguration.EnableDebugInfo, DbType.String, ParameterDirection.Input));
                    int intResult = sqlDataAccess.ExecuteNonQuery(sqlDataAccess.CreateCommand("[Company_UpdateDetail]", CommandType.StoredProcedure, null), parameters.ToArray());
                    result.Data = int.Parse(parameters.Where(p => p.ParameterName.Equals("output")).FirstOrDefault().Value.ToString());
                }
                _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);
        }
 public Entity.BaseResponse <List <Response.GeneratorDetailResponse> > GetGeneratorStatics(Guid generatorId)
 {
     Entity.BaseResponse <List <Response.GeneratorDetailResponse> > result = new Entity.BaseResponse <List <Response.GeneratorDetailResponse> >();
     try
     {
         logger.Information(Constants.ACTION_ENTRY, "GeneratorRepository.GetGeneratorStatics");
         using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
         {
             List <System.Data.Common.DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CompanyId, component.helper.SolutionConfiguration.Version);
             parameters.Add(sqlDataAccess.CreateParameter("guid", generatorId, DbType.Guid, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("syncDate", DateTime.UtcNow, DbType.DateTime, ParameterDirection.Output));
             DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[DeviceStatistics_Get]", CommandType.StoredProcedure, null), parameters.ToArray());
             result.Data = DataUtils.DataReaderToList <Response.GeneratorDetailResponse>(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.Information(Constants.ACTION_EXIT, "GeneratorRepository.GetGeneratorStatics");
     }
     catch (Exception ex)
     {
         logger.Error(Constants.ACTION_EXCEPTION, ex);
     }
     return(result);
 }
        public Entity.HardwareKitDTO GetHardwareKitDetails(Entity.SearchRequest request)
        {
            Entity.SearchResult <List <Entity.HardwareKit> > result = new Entity.SearchResult <List <Entity.HardwareKit> >();
            var hardwareKitDto = new Entity.HardwareKitDTO();

            try
            {
                _logger.InfoLog(LogHandler.Constants.ACTION_ENTRY, null, "", "", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <System.Data.Common.DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, request.Version);
                    parameters.Add(sqlDataAccess.CreateParameter("guid", request.Guid, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("pagesize", request.PageSize, DbType.Int32, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("pagenumber", request.PageNumber, DbType.Int32, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("orderby", request.OrderBy, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("count", DbType.Int32, ParameterDirection.Output, 16));
                    System.Data.Common.DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[KitDevice_List]", CommandType.StoredProcedure, null), parameters.ToArray());
                    result.Items = DataUtils.DataReaderToList <Entity.HardwareKit>(dbDataReader, null);
                    result.Count = int.Parse(parameters.Where(p => p.ParameterName.Equals("count")).FirstOrDefault().Value.ToString());
                    HardwareKitDTO hardwareKitDTO = new HardwareKitDTO();

                    if (result.Count >= 0)
                    {
                        var hardwareKit = result.Items.FirstOrDefault();
                        hardwareKitDto = (from c in result.Items
                                          group c by new
                        {
                            c.KitGuid,
                            c.KitCode,
                            c.KitType,
                        } into gcs
                                          select new HardwareKitDTO()
                        {
                            Guid = hardwareKit.Guid,
                            CompanyGuid = hardwareKit.CompanyGuid,
                            KitTypeGuid = result.Items.Count > 0 ? result.Items[0].TemplateGuid : hardwareKit.KitTypeGuid,
                            KitCode = gcs.Key.KitCode,
                            KitDevices = gcs.Select(x => new KitDeviceDTO()
                            {
                                Name = x.Name,
                                IsProvisioned = x.IsProvisioned,
                                Note = x.Note,
                                Tag = x.TagGuid,
                                KitGuid = x.KitGuid,
                                UniqueId = x.UniqueId,
                                ParentUniqueId = x.ParentUniqueId,
                            }).ToList()
                        }).FirstOrDefault();
                    }
                }
                _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(hardwareKitDto);
        }
        public Entity.ActionStatus Manage(Model.ElevatorMaintenance request)
        {
            Entity.ActionStatus result = new Entity.ActionStatus(true);
            try
            {
                logger.InfoLog(Constants.ACTION_ENTRY, "ElevatorMaintenanceRepository.Manage");
                int    outPut     = 0;
                int    intResult  = 0;
                string guidResult = string.Empty;
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, component.helper.SolutionConfiguration.Version);
                    parameters.Add(sqlDataAccess.CreateParameter("companyGuid", request.CompanyGuid, DbType.Guid, ParameterDirection.Input));

                    parameters.Add(sqlDataAccess.CreateParameter("status", request.Status, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("description", request.Description, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("scheduleddate", request.ScheduledDate, DbType.DateTime, ParameterDirection.Input));

                    parameters.Add(sqlDataAccess.CreateParameter("culture", component.helper.SolutionConfiguration.Culture, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("enableDebugInfo", component.helper.SolutionConfiguration.EnableDebugInfo, DbType.String, ParameterDirection.Input));
                    if (request.Guid == null || request.Guid == Guid.Empty)
                    {
                        parameters.Add(sqlDataAccess.CreateParameter("newid", request.Guid, DbType.Guid, ParameterDirection.Output));
                        parameters.Add(sqlDataAccess.CreateParameter("entityGuid", request.EntityGuid, DbType.Guid, ParameterDirection.Input));
                        parameters.Add(sqlDataAccess.CreateParameter("elevatorGuid", request.ElevatorGuid, DbType.Guid, ParameterDirection.Input));
                        intResult  = sqlDataAccess.ExecuteNonQuery(sqlDataAccess.CreateCommand("[ElevatorMaintenance_Add]", CommandType.StoredProcedure, null), parameters.ToArray());
                        guidResult = parameters.Where(p => p.ParameterName.Equals("newid")).FirstOrDefault().Value.ToString();
                    }
                    else
                    {
                        parameters.Add(sqlDataAccess.CreateParameter("guid", request.Guid, DbType.Guid, ParameterDirection.Input));
                        intResult  = sqlDataAccess.ExecuteNonQuery(sqlDataAccess.CreateCommand("[ElevatorMaintenance_UpdateStatus]", CommandType.StoredProcedure, null), parameters.ToArray());
                        guidResult = request.Guid.ToString();
                    }
                    outPut = int.Parse(parameters.Where(p => p.ParameterName.Equals("output")).FirstOrDefault().Value.ToString());
                    if (outPut > 0)
                    {
                        if (!string.IsNullOrEmpty(guidResult))
                        {
                            result.Data = Guid.Parse(guidResult);
                        }
                    }
                    else
                    {
                        result.Success = false;
                        result.Message = parameters.Where(p => p.ParameterName.Equals("fieldname")).FirstOrDefault().Value.ToString();
                    }
                }
                logger.InfoLog(Constants.ACTION_EXIT, "ElevatorMaintenanceRepository.Manage");
            }
            catch (Exception ex)
            {
                logger.ErrorLog(Constants.ACTION_EXCEPTION, ex);
            }
            return(result);
        }
        public ActionStatus VerifyHardwareKit(KitVerifyRequest request, bool isEdit = false)
        {
            var response = new ActionStatus(true);
            var result   = new List <BulkUploadResponse>();

            try
            {
                logger.InfoLog(Constants.ACTION_ENTRY, "HardwareKitRepository.VerifyHardwareKit");
                var createdHardwareKits = new List <BulkUploadResponse>();
                var xmlData             = string.Empty;
                using (var stringwriter = new System.IO.StringWriter())
                {
                    var serializer = new XmlSerializer(request.GetType());
                    serializer.Serialize(stringwriter, request);
                    xmlData = stringwriter.ToString();
                }

                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <System.Data.Common.DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, component.helper.SolutionConfiguration.Version);
                    parameters.Add(sqlDataAccess.CreateParameter("data", xmlData.ToString(), DbType.Xml, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("isEdit", (isEdit == false ? 0 : 1), DbType.Boolean, ParameterDirection.Input));

                    System.Data.Common.DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[HardwareKit_Validate]", CommandType.StoredProcedure, null), parameters.ToArray());
                    result = DataUtils.DataReaderToList <Entity.BulkUploadResponse>(dbDataReader, null);

                    response.Data = result;
                    var errorResult = result.Where(x => !string.IsNullOrEmpty(x.hardwareKitError));
                    var isValid     = errorResult.Count();
                    if (isValid > 0)
                    {
                        response.Success = false;
                        response.Message = errorResult.FirstOrDefault().hardwareKitError;

                        //foreach (var error in errorResult)
                        //{
                        //    response.Message += error.hardwareKitError + ". ";
                        //}
                    }
                    else
                    {
                        response.Success = true;
                    }
                }
                logger.InfoLog(Constants.ACTION_EXIT, "HardwareKitRepository.VerifyHardwareKit");
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message.ToString();
                logger.ErrorLog(Constants.ACTION_EXCEPTION, ex);
            }

            return(response);
        }
Example #27
0
        public Entity.BaseResponse <List <Response.DevicePeakHoursResponse> > GetPeakHoursByElevator(Request.ElevatorsPeakRequest request)
        {
            Entity.BaseResponse <List <Response.DevicePeakHoursResponse> > responseResult = new Entity.BaseResponse <List <Response.DevicePeakHoursResponse> >();
            List <Response.DevicePeakHoursResponse> tripList = new List <Response.DevicePeakHoursResponse>();

            try
            {
                string ids = String.Join(",", request.ElevatorList);
                _logger.InfoLog(Constants.ACTION_ENTRY, "Chart_PeakHoursByElevator.Get");
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <Response.OperationHours> result     = new List <Response.OperationHours>();
                    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("elevators", ids, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("frequency", request.Frequency, DbType.String, 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_PeakHoursByElevator]", CommandType.StoredProcedure, null), parameters.ToArray());
                    result = DataUtils.DataReaderToList <Response.OperationHours>(dbDataReader, null);
                    if (parameters.Where(p => p.ParameterName.Equals("syncDate")).FirstOrDefault() != null)
                    {
                        responseResult.LastSyncDate = Convert.ToString(parameters.Where(p => p.ParameterName.Equals("syncDate")).FirstOrDefault().Value);
                    }

                    var resultGrp = from data in result
                                    group data by data.Name
                                    into egroup
                                    select egroup;

                    foreach (var group in resultGrp)
                    {
                        List <Response.PeakLookup> lookupItems = new List <Response.PeakLookup>();
                        foreach (var items in group)
                        {
                            lookupItems.Add(new Response.PeakLookup {
                                Name = items.ElevatorName, Value = items.Value
                            });
                        }
                        tripList.Add(new Response.DevicePeakHoursResponse {
                            Time = group.Key, Value = lookupItems
                        });
                    }
                    responseResult.Data = tripList;
                }
                _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(responseResult);
        }
        public ActionStatus Manage(Model.Entity request)
        {
            ActionStatus result = new ActionStatus(true);

            try
            {
                logger.Information(Constants.ACTION_ENTRY, "EntityRepository.Manage");
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    List <DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, component.helper.SolutionConfiguration.Version);

                    parameters.Add(sqlDataAccess.CreateParameter("companyGuid", request.CompanyGuid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("guid", request.Guid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("parentEntityGuid", request.ParentEntityGuid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("name", request.Name, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("type", request.Type, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("description", request.Description, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("latitude", request.Latitude, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("longitude ", request.Longitude, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("address", request.Address, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("address2", request.Address2, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("city", request.City, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("stateGuid", request.StateGuid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("countryGuid", request.CountryGuid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("zipCode", request.Zipcode, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("image", request.Image, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("newid", request.Guid, DbType.Guid, ParameterDirection.Output));
                    parameters.Add(sqlDataAccess.CreateParameter("culture", component.helper.SolutionConfiguration.Culture, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("enableDebugInfo", component.helper.SolutionConfiguration.EnableDebugInfo, DbType.String, ParameterDirection.Input));
                    int intResult = sqlDataAccess.ExecuteNonQuery(sqlDataAccess.CreateCommand("[Entity_AddUpdate]", CommandType.StoredProcedure, null), parameters.ToArray());

                    int outPut = int.Parse(parameters.Where(p => p.ParameterName.Equals("output")).FirstOrDefault().Value.ToString());
                    if (outPut > 0)
                    {
                        string guidResult = parameters.Where(p => p.ParameterName.Equals("newid")).FirstOrDefault().Value.ToString();
                        if (!string.IsNullOrEmpty(guidResult))
                        {
                            result.Data = _uow.DbContext.Entity.Where(u => u.Guid.Equals(Guid.Parse(guidResult))).FirstOrDefault();
                        }
                    }
                    else
                    {
                        result.Message = parameters.Where(p => p.ParameterName.Equals("fieldname")).FirstOrDefault().Value.ToString();
                    }
                }
                logger.Information(Constants.ACTION_EXIT, "EntityRepository.Manage");
            }
            catch (Exception ex)
            {
                logger.Error(Constants.ACTION_EXCEPTION, ex);
            }
            return(result);
        }
 public Entity.SearchResult <List <Entity.UserResponse> > List(Entity.SearchRequest request)
 {
     Entity.SearchResult <List <Entity.UserResponse> > result = new Entity.SearchResult <List <Entity.UserResponse> >();
     try
     {
         logger.InfoLog(Constants.ACTION_ENTRY, "UserRepository.Get");
         using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
         {
             List <System.Data.Common.DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, request.Version);
             parameters.Add(sqlDataAccess.CreateParameter("companyguid", component.helper.SolutionConfiguration.CompanyId, DbType.Guid, ParameterDirection.Input));
             if (request.EntityId != Guid.Empty)
             {
                 parameters.Add(sqlDataAccess.CreateParameter("entityGuid", request.EntityId, DbType.Guid, ParameterDirection.Input));
             }
             if (request.ParentEntityGuid != Guid.Empty)
             {
                 parameters.Add(sqlDataAccess.CreateParameter("parentEntityGuid", request.ParentEntityGuid, DbType.Guid, ParameterDirection.Input));
             }
             parameters.Add(sqlDataAccess.CreateParameter("search", request.SearchText, DbType.String, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("pagesize", request.PageSize, DbType.Int32, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("pagenumber", request.PageNumber, DbType.Int32, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("orderby", request.OrderBy, DbType.String, ParameterDirection.Input));
             parameters.Add(sqlDataAccess.CreateParameter("count", DbType.Int32, ParameterDirection.Output, 16));
             System.Data.Common.DbDataReader dbDataReader = sqlDataAccess.ExecuteReader(sqlDataAccess.CreateCommand("[User_List]", CommandType.StoredProcedure, null), parameters.ToArray());
             result.Items = DataUtils.DataReaderToList <Entity.UserResponse>(dbDataReader, null);
             // result.Count = int.Parse(parameters.Where(p => p.ParameterName.Equals("count")).FirstOrDefault().Value.ToString());
             var count = parameters.Where(p => p.ParameterName.Equals("count")).FirstOrDefault();
             if (count != null && !string.IsNullOrWhiteSpace(count.Value.ToString()))
             {
                 result.Count = int.Parse(count.Value.ToString());
             }
             var outPut = parameters.Where(p => p.ParameterName.Equals("output")).FirstOrDefault();
             if (outPut != null)
             {
                 int outputvalue = int.Parse(outPut.Value.ToString());
                 result.Count = outputvalue < 0 ? outputvalue : result.Count;
             }
         }
         logger.InfoLog(Constants.ACTION_EXIT, "UserRepository.Get");
     }
     catch (Exception ex)
     {
         logger.ErrorLog(Constants.ACTION_EXCEPTION, ex);
     }
     return(result);
 }
        public ActionStatus Manage(Model.GreenHouse request)
        {
            ActionStatus result = new ActionStatus(true);

            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", request.CompanyGuid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("guid", request.Guid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("name", request.Name, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("description", request.Description, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("address", request.Address, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("address2", request.Address2, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("city", request.City, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("stateGuid", request.StateGuid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("countryGuid", request.CountryGuid, DbType.Guid, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("zipCode", request.Zipcode, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("latitude", request.Latitude, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("longitude", request.Longitude, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("image", request.Image, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("newid", request.Guid, DbType.Guid, ParameterDirection.Output));
                    parameters.Add(sqlDataAccess.CreateParameter("culture", component.helper.SolutionConfiguration.Culture, DbType.String, ParameterDirection.Input));
                    parameters.Add(sqlDataAccess.CreateParameter("enableDebugInfo", component.helper.SolutionConfiguration.EnableDebugInfo, DbType.String, ParameterDirection.Input));
                    int    intResult  = sqlDataAccess.ExecuteNonQuery(sqlDataAccess.CreateCommand("[GreenHouse_AddUpdate]", CommandType.StoredProcedure, null), parameters.ToArray());
                    string guidResult = parameters.Where(p => p.ParameterName.Equals("newid")).FirstOrDefault().Value.ToString();
                    if (!string.IsNullOrEmpty(guidResult))
                    {
                        result.Data = _uow.DbContext.GreenHouse.Where(u => u.Guid.Equals(Guid.Parse(guidResult))).FirstOrDefault();
                    }
                }
                _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);
        }