public Boolean isOverTrialPeriod(IOT_DbContext _db) { var vIoT_DeviceTypes = _db.IOT_DEVICE_TYPE.AsQueryable(); vIoT_DeviceTypes = vIoT_DeviceTypes.OrderBy(c => c.clm_date_time); var oIot_DeviceType = vIoT_DeviceTypes.FirstOrDefault(); if (oIot_DeviceType != null) { if (oIot_DeviceType.clm_date_time == null) { return(true); } else { DateTime oldDate = oIot_DeviceType.clm_date_time; DateTime newDate = DateTime.Now; // Difference in days, hours, and minutes. TimeSpan ts = newDate - oldDate; // Difference in days. int differenceInDays = ts.Days; if (differenceInDays > 30) { return(true); } } } return(false); }
private bool ConnectDatabase() { try { //System.Diagnostics.Debug.Print("DB COnnect Start" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); cls_LogMessage log_msg = new cls_LogMessage("INFO", "MonitorService", "ConnectDatabase", "DB Connect Start..."); _logger.LogInformation(log_msg.get_log_message()); this.db = new IOT_DbContext(this.service_initial.db_info.db_type, this.service_initial.db_info.connection_string); //System.Diagnostics.Debug.Print("DB COnnect End & init Start" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); log_msg.message = "DB Connect End & init Start"; _logger.LogInformation(log_msg.get_log_message()); this.db.ChangeTracker.AutoDetectChangesEnabled = false; this.db.ChangeTracker.LazyLoadingEnabled = false; this.db.IOT_STATUS_MONITOR.FirstOrDefault(); //System.Diagnostics.Debug.Print("DB COnnect init End" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")); log_msg.message = "DB Init End"; _logger.LogInformation(log_msg.get_log_message()); return(true); } catch (Exception ex) { //Console.WriteLine("Connect Database error -> " + ex.Message); cls_LogMessage log_msg = new cls_LogMessage("ERROR", "MonitorService", "ConnectDatabase", "Exception: " + ex.Message); _logger.LogInformation(log_msg.get_log_message()); return(false); } }
public List <IOT_DEVICE_TYPE> getDeviceTypeOrderBySeqNO(IOT_DbContext _db) { var vIoT_DeviceTypes = _db.IOT_DEVICE_TYPE.AsQueryable(); vIoT_DeviceTypes = vIoT_DeviceTypes.OrderBy(c => c.order_seqno); return(vIoT_DeviceTypes.ToList()); }
public List <IOT_ALERT> getNotYetConfirmAlerts(IOT_DbContext _db) { var vIotAlerts = _db.IOT_ALERT.AsQueryable(); vIotAlerts = vIotAlerts.Where(c => c.review_user == null); vIotAlerts = vIotAlerts.OrderByDescending(c => c.rpt_date_time); return(vIotAlerts.ToList()); }
public int getNewTableNO(IOT_DbContext _db) { int iTableNo = 1; var vIoT_Devices = _db.IOT_DEVICE.AsQueryable(); vIoT_Devices = vIoT_Devices.OrderByDescending(c => c.device_no); IOT_DEVICE oIoT_Device = vIoT_Devices.FirstOrDefault(); if (oIoT_Device != null) { iTableNo = oIoT_Device.device_no + 1; if (iTableNo > 128) { iTableNo = 999; } } return(iTableNo); }