Exemple #1
0
        public static List <RemoteCommand> load(string query)
        {
            List <RemoteCommand> list = new List <RemoteCommand>();
            MySqlDataReader      rd   = null;

            try
            {
                MySqlConnection conn = Main.getConnection();
                if (conn == null)
                {
                    return(list);
                }
                if (query == null || query.Length == 0)
                {
                    query = "select * from remote_command";
                }
                Log.Info("Query: " + query);
                MySqlCommand cmd = new MySqlCommand(query, conn);

                rd = cmd.ExecuteReader();

                while (rd.Read())
                {
                    RemoteCommand obj = new RemoteCommand();
                    obj.cmd_id   = Convert.ToInt32(rd["cmd_id"].ToString()); // Primary
                    obj.eqp_id   = Convert.ToInt32(rd["eqp_id"].ToString());
                    obj.cmd_text = rd["cmd_text"].ToString();
                    obj.cmd_time = Convert.ToInt32(rd["cmd_time"].ToString());
                    list.Add(obj);
                }
                rd.Close();
            }
            catch (MySqlException e)
            {
                Log.Error("Error: " + e.Message);
            }
            finally
            {
                if (rd != null)
                {
                    rd.Close();
                }
            }
            return(list);
        }
Exemple #2
0
        public static RemoteCommand load(int cmd_id)
        {
            MySqlDataReader rd = null;

            try
            {
                MySqlConnection conn = Main.getConnection();
                if (conn == null)
                {
                    return(null);
                }
                string query = "select * from remote_command where cmd_id='" + cmd_id + "'";
                Log.Info("Query: " + query);
                MySqlCommand cmd = new MySqlCommand(query, conn);

                rd = cmd.ExecuteReader();
                RemoteCommand obj = new RemoteCommand();

                while (rd.Read())
                {
                    obj.cmd_id   = Convert.ToInt32(rd["cmd_id"].ToString()); // Primary
                    obj.eqp_id   = Convert.ToInt32(rd["eqp_id"].ToString());
                    obj.cmd_text = rd["cmd_text"].ToString();
                    obj.cmd_time = Convert.ToInt32(rd["cmd_time"].ToString());
                    break;
                }
                rd.Close();

                return(obj);
            }
            catch (MySqlException e)
            {
                Log.Error("Query: " + e.Message);
            }
            finally
            {
                if (rd != null)
                {
                    rd.Close();
                }
            }
            return(null);
        }