Inheritance: TersoConnectEntity, IDisposable
 /// <summary>
 /// Get device by id for deletion
 /// </summary>
 /// <param name="deviceId"></param>
 /// <returns></returns>
 public DeviceModel GetDeviceById(int deviceId)
 {
     ServiceData serviceData = new ServiceData();
     try
     {
         DeviceModel device;
         using (DBDevice objDbDevice = new DBDevice())
         {
             device = objDbDevice.GetDeviceById(deviceId);
         }
         return device;
     }
     catch (Exception ex)
     {
         serviceData.Result = false;
         serviceData.ErrorMessage = ex.Message;
         serviceData.ErrorDetails = ex.ToString();
         throw new FaultException<ServiceData>(serviceData);
     }
 }
 /// <summary>
 /// Method to get device list after applying filter of search text
 /// </summary>
 /// <param name="searchText"></param>
 /// <returns></returns>
 public List<DeviceModel> GetFilterDeviceList(string searchText)
 {
     ServiceData serviceData = new ServiceData();
     try
     {
         List<DeviceModel> lstDevice;
         using (DBDevice objDbDevice = new DBDevice())
         {
             lstDevice = objDbDevice.GetFilterDeviceList(searchText, Convert.ToInt32(ConfigurationManager.AppSettings["SensorTimeWindow"]));
         }
         return lstDevice;
     }
     catch (Exception ex)
     {
         serviceData.Result = false;
         serviceData.ErrorMessage = ex.Message;
         serviceData.ErrorDetails = ex.ToString();
         throw new FaultException<ServiceData>(serviceData);
     }
 }
 /// <summary>
 /// Method to check duplicate device with serial number
 /// </summary>
 /// <param name="deviceId"></param>
 /// <param name="serial"></param>
 /// <returns></returns>
 public int CheckForDuplicateSerial(int deviceId, string serial)
 {
     ServiceData serviceData = new ServiceData();
     try
     {
         int result;
         using (DBDevice objDbDevice = new DBDevice())
         {
             result = objDbDevice.CheckForDuplicateSerial(deviceId, serial);
         }
         return result;
     }
     catch (Exception ex)
     {
         serviceData.Result = false;
         serviceData.ErrorMessage = ex.Message;
         serviceData.ErrorDetails = ex.ToString();
         throw new FaultException<ServiceData>(serviceData);
     }
 }
 /// <summary>
 /// Method to get device by deviceid with page number and page size for server side paging
 /// </summary>
 /// <param name="logicalDeviceId"></param>
 /// <returns></returns>
 public DeviceModel GetDeviceInventoriesList(string logicalDeviceId)
 {
     ServiceData serviceData = new ServiceData();
     try
     {
         DeviceModel lstDevice;
         using (DBDevice objDbDevice = new DBDevice())
         {
             lstDevice = objDbDevice.GetDeviceInventoriesList(logicalDeviceId);
         }
         return lstDevice;
     }
     catch (Exception ex)
     {
         serviceData.Result = false;
         serviceData.ErrorMessage = ex.Message;
         serviceData.ErrorDetails = ex.ToString();
         throw new FaultException<ServiceData>(serviceData);
     }
 }
 /// <summary>
 /// Get device by logical device Id
 /// </summary>
 /// <param name="deviceMl"></param>
 /// <returns></returns>
 public int GetDeviceModelByLogicalDeviceId(DeviceModel deviceMl)
 {
     ServiceData serviceData = new ServiceData();
     try
     {
         int result;
         using (DBDevice objDbDevice = new DBDevice())
         {
             result = objDbDevice.GetDeviceModelByLogicalDeviceId(deviceMl);
         }
         return result;
     }
     catch (Exception ex)
     {
         serviceData.Result = false;
         serviceData.ErrorMessage = ex.Message;
         serviceData.ErrorDetails = ex.ToString();
         throw new FaultException<ServiceData>(serviceData);
     }
 }
 /// <summary>
 ///  Method to get the device detail by logical device id
 /// </summary>
 /// <param name="logicalDeviceId"></param>
 /// <returns></returns>
 public DeviceModel GetDeviceByLogicalDeviceId(string logicalDeviceId)
 {
     ServiceData serviceData = new ServiceData();
     try
     {
         DeviceModel lstDevice;
         using (DBDevice objDbDevice = new DBDevice())
         {
             lstDevice = objDbDevice.GetDeviceByLogicalDeviceId(logicalDeviceId, Convert.ToInt32(ConfigurationManager.AppSettings["SensorTimeWindow"]));
         }
         return lstDevice;
     }
     catch (Exception ex)
     {
         serviceData.Result = false;
         serviceData.ErrorMessage = ex.Message;
         serviceData.ErrorDetails = ex.ToString();
         throw new FaultException<ServiceData>(serviceData);
     }
 }
 /// <summary>
 /// Method tot delete the device
 /// </summary>
 /// <param name="deviceId"></param>
 /// <returns></returns>
 public void DeleteDevice(int deviceId)
 {
     ServiceData serviceData = new ServiceData();
     try
     {
         using (DBDevice objDbDevice = new DBDevice())
         {
             objDbDevice.DeleteDevice(deviceId);
         }
     }
     catch (Exception ex)
     {
         serviceData.Result = false;
         serviceData.ErrorMessage = ex.Message;
         serviceData.ErrorDetails = ex.ToString();
         throw new FaultException<ServiceData>(serviceData);
     }
 }