예제 #1
0
        public static KLogger GetFromDatabase(int id)
        {
            Database db     = DatabaseFactory.CreateDatabase();
            String   strSql =
                "SELECT * " +
                "FROM tblSignals " +
                "WHERE clv_signal = " + id;
            IDataReader dr = db.ExecuteReader(db.GetSqlStringCommand(strSql));

            KLogger k = new KLogger();

            if (dr != null && !dr.IsClosed)
            {
                if (!dr.Read())
                {
                    throw new Exception("This signal does not exist in the database");
                }
                k.stationID = dr.GetInt64(0);
                if (!dr.IsDBNull(1))
                {
                    k.station = dr.GetString(1);
                }
                if (!dr.IsDBNull(2))
                {
                    k.deviceName = dr.GetString(2);
                }
                if (!dr.IsDBNull(3))
                {
                    k.lineName = dr.GetString(3);
                }
                if (!dr.IsDBNull(4))
                {
                    k.bitRate = EnumFromValue.FromBitRate(dr.GetInt32(4));
                }
                if (!dr.IsDBNull(5))
                {
                    k.sampleRate = EnumFromValue.FromSampleRate(dr.GetInt32(5));
                }
                if (!dr.IsDBNull(6))
                {
                    k.volume = (uint)dr.GetInt32(6);
                }
                if (!dr.IsDBNull(7))
                {
                    k.recycleInterval = dr.GetInt32(7);
                }
                if (!dr.IsDBNull(8))
                {
                    k.workingDirectory = dr.GetString(8);
                }
                if (!dr.IsDBNull(9))
                {
                    k.enabled = dr.GetBoolean(9);
                }
            }
            dr.Close();
            return(k);
        }
예제 #2
0
        public static List <KLogger> GetAllFromDatabase()
        {
            Database db     = DatabaseFactory.CreateDatabase();
            String   strSql =
                "SELECT * " +
                "FROM tblSignals ";
            IDataReader dr = db.ExecuteReader(db.GetSqlStringCommand(strSql));

            List <KLogger> loggers = new List <KLogger>();

            if (dr != null && !dr.IsClosed)
            {
                while (dr.Read())
                {
                    KLogger k = new KLogger();
                    k.stationID = dr.GetInt64(0);
                    if (!dr.IsDBNull(1))
                    {
                        k.station = dr.GetString(1);
                    }
                    if (!dr.IsDBNull(2))
                    {
                        k.deviceName = dr.GetString(2);
                    }
                    if (!dr.IsDBNull(3))
                    {
                        k.lineName = dr.GetString(3);
                    }
                    if (!dr.IsDBNull(4))
                    {
                        k.bitRate = EnumFromValue.FromBitRate(dr.GetInt32(4));
                    }
                    if (!dr.IsDBNull(5))
                    {
                        k.sampleRate = EnumFromValue.FromSampleRate(dr.GetInt32(5));
                    }
                    if (!dr.IsDBNull(6))
                    {
                        k.volume = (uint)dr.GetInt32(6);
                    }
                    if (!dr.IsDBNull(7))
                    {
                        k.recycleInterval = dr.GetInt32(7);
                    }
                    if (!dr.IsDBNull(8))
                    {
                        k.workingDirectory = dr.GetString(8);
                    }
                    if (!dr.IsDBNull(9))
                    {
                        k.enabled = dr.GetBoolean(9);
                    }
                    loggers.Add(k);
                }
            }
            dr.Close();
            return(loggers);
        }