コード例 #1
0
        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);
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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());
        }
コード例 #4
0
ファイル: IOT_ALERT.cs プロジェクト: IEW-CCS/IEW_CCS_Gateway
        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());
        }
コード例 #5
0
ファイル: IOT_DEVICE.cs プロジェクト: IEW-CCS/IEW_CCS_Gateway
        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);
        }