Exemplo n.º 1
0
        public static uWiMP.TVServer.MPClient.Client GetClientByHostname(string hostname)
        {
            uWiMP.TVServer.MPClient.Client MPClient = new uWiMP.TVServer.MPClient.Client();

            string connStr = ConfigurationManager.ConnectionStrings["uWiMPConnString"].ConnectionString;
            SQLiteConnection conn = new SQLiteConnection(connStr);
            SQLiteDataReader reader;

            SQLiteCommand cmd = new SQLiteCommand("SELECT Friendly, MACAddress, Port, UsesMovingPictures, UsesTVSeries FROM `MPClients` WHERE Hostname = $Hostname", conn);
            cmd.Parameters.Add("$Hostname", DbType.String, 255).Value = hostname.ToLower();

            try
            {
                conn.Open();
                reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        MPClient.Friendly = reader.GetString(0);
                        MPClient.Hostname = hostname;
                        MPClient.MACAddress = reader.GetString(1);
                        MPClient.Port = reader.GetString(2);
                    }
                }
                reader.Close();
            }
            catch (SQLiteException ex)
            {
                return MPClient;
            }
            finally
            {
                conn.Close();
            }

            return MPClient;
        }
Exemplo n.º 2
0
        public static List<uWiMP.TVServer.MPClient.Client> GetClients()
        {
            List<uWiMP.TVServer.MPClient.Client> mpclients = new List<uWiMP.TVServer.MPClient.Client>();

            string connStr = ConfigurationManager.ConnectionStrings["uWiMPConnString"].ConnectionString;
            SQLiteConnection conn = new SQLiteConnection(connStr);
            SQLiteDataReader reader;

            SQLiteCommand cmd = new SQLiteCommand("SELECT Friendly FROM `MPClients`", conn);

            try
            {
                conn.Open();
                reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        uWiMP.TVServer.MPClient.Client mpclient = new uWiMP.TVServer.MPClient.Client();
                        mpclient.Friendly = reader.GetString(0);
                        mpclients.Add(mpclient);
                    }
                }
                reader.Close();
            }
            catch (SQLiteException ex)
            {
                return null;
            }
            finally
            {
                conn.Close();
            }

            return mpclients;
        }
Exemplo n.º 3
0
        public static uWiMP.TVServer.MPClient.Client GetClient(string friendly)
        {
            uWiMP.TVServer.MPClient.Client MPClient = new uWiMP.TVServer.MPClient.Client();

            string connStr = "Data Source=|DataDirectory|uWiMP.db;";
            SQLiteConnection conn = new SQLiteConnection(connStr);
            SQLiteDataReader reader;

            SQLiteCommand cmd = new SQLiteCommand("SELECT Hostname, MACAddress, Port, UsesMovingPictures, UsesTVSeries FROM `MPClients` WHERE Friendly = $Friendly", conn);
            cmd.Parameters.Add("$Friendly", DbType.String, 255).Value = friendly.ToLower();

            try
            {
                conn.Open();
                reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        MPClient.Friendly = friendly;
                        MPClient.Hostname = reader.GetString(0);
                        MPClient.MACAddress = reader.GetString(1);
                        MPClient.Port = reader.GetString(2);
                        int usesMovingPictures = reader.GetInt32(3);
                        int usesTVSeries = reader.GetInt32(4);
                        if (reader.GetInt32(3) == 1)
                        {
                            MPClient.usesMovingPictures = true;
                        }
                        else
                        {
                            MPClient.usesMovingPictures = false;
                        }
                        if (reader.GetInt32(4) == 1)
                        {
                            MPClient.usesTVSeries = true;
                        }
                        else
                        {
                            MPClient.usesTVSeries = false;
                        }
                    }
                }
                reader.Close();
            }
            catch (SQLiteException ex)
            {
                return MPClient;
            }
            finally
            {
                conn.Close();
            }

            return MPClient;
        }