Пример #1
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);
        }
Пример #2
0
 public List <Entity.DeviceMaintenanceResponse> GetUpComingList(Entity.DeviceMaintenanceRequest request)
 {
     try
     {
         if (request.currentDate.HasValue)
         {
             DateTime dateValue;
             if (DateTime.TryParse(request.currentDate.Value.ToString(), out dateValue))
             {
                 dateValue = dateValue.AddMinutes(-double.Parse(request.timeZone));
             }
             request.currentDate = dateValue;
         }
         return(_deviceMaintenanceRepository.GetUpComingList(request));
     }
     catch (Exception ex)
     {
         _logger.Error(Constants.ACTION_EXCEPTION, $"DeviceMaintenanceService.List, Error: {ex.Message}");
         return(new List <Entity.DeviceMaintenanceResponse>());
     }
 }
Пример #3
0
        public Entity.BaseResponse <Entity.DeviceSceduledMaintenanceResponse> GetDeviceScheduledMaintenance(Entity.DeviceMaintenanceRequest request)
        {
            Entity.BaseResponse <List <Entity.DeviceSceduledMaintenanceResponse> > result = new Entity.BaseResponse <List <Entity.DeviceSceduledMaintenanceResponse> >();
            var deviceDetail = new Entity.BaseResponse <Entity.DeviceSceduledMaintenanceResponse>();

            try
            {
                logger.InfoLog(Constants.ACTION_ENTRY, "DeviceMaintenanceRepository.GetDeviceScheduledMaintenence");
                using (var sqlDataAccess = new SqlDataAccess(ConnectionString))
                {
                    DateTime dateValue;
                    if (DateTime.TryParse(request.currentDate.ToString(), out dateValue))
                    {
                        dateValue = dateValue.AddMinutes(-double.Parse(request.timeZone));
                    }
                    List <DbParameter> parameters = sqlDataAccess.CreateParams(component.helper.SolutionConfiguration.CurrentUserId, "v1");
                    if (request.DeviceGuid.HasValue && !request.DeviceGuid.Value.Equals(Guid.Empty))
                    {
                        parameters.Add(sqlDataAccess.CreateParameter("guid", request.DeviceGuid.Value, DbType.Guid, ParameterDirection.Input));
                    }
                    if (request.EntityGuid.HasValue && !request.EntityGuid.Value.Equals(Guid.Empty))
                    {
                        parameters.Add(sqlDataAccess.CreateParameter("entityGuid", request.EntityGuid.Value, DbType.Guid, ParameterDirection.Input));
                    }
                    parameters.Add(sqlDataAccess.CreateParameter("currentDate", dateValue, 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));
                    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 <Entity.DeviceSceduledMaintenanceResponse>(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);
                    }
                    Entity.DeviceSceduledMaintenanceResponse obj = new Entity.DeviceSceduledMaintenanceResponse();
                    obj.UniqueId = "";
                    obj.Day      = "0";
                    obj.Hour     = "0";
                    obj.Minute   = "0";
                    if (result.Data != null && result.Data.Count > 0)
                    {
                        var data = result.Data[0];
                        if (data.startDateTime != DateTime.MinValue)
                        {
                            dateValue = data.startDateTime;                //.AddMinutes(-double.Parse(request.timeZone));// TimeZoneInfo.ConvertTimeBySystemTimeZoneId(data.startDateTime, "UTC", request.timeZone);
                            TimeSpan span = (dateValue - DateTime.UtcNow); // request.currentDate.Value);
                            obj.Day      = Convert.ToString(span.Days);
                            obj.Hour     = Convert.ToString(span.Hours);
                            obj.Minute   = Convert.ToString(span.Minutes);
                            obj.UniqueId = data.UniqueId;
                        }
                    }
                    obj.startDateTime         = dateValue;
                    deviceDetail.Data         = obj;
                    deviceDetail.LastSyncDate = result.LastSyncDate;
                    deviceDetail.IsSuccess    = true;
                }
                logger.InfoLog(Constants.ACTION_EXIT, "DeviceMaintenanceRepository.GetDeviceScheduledMaintenence");
            }
            catch (Exception ex)
            {
                logger.ErrorLog(Constants.ACTION_EXCEPTION, ex);
            }
            return(deviceDetail);
        }
Пример #4
0
 public Entity.BaseResponse <Entity.DeviceSceduledMaintenanceResponse> GetDeviceScheduledMaintenance(Entity.DeviceMaintenanceRequest request)
 {
     try
     {
         return(_deviceMaintenanceRepository.GetDeviceScheduledMaintenance(request));
     }
     catch (Exception ex)
     {
         _logger.Error(Constants.ACTION_EXCEPTION, $"DeviceMaintenanceService.Get, Error: {ex.Message}");
         return(new Entity.BaseResponse <Entity.DeviceSceduledMaintenanceResponse>());
     }
 }