Exemplo n.º 1
0
        public static void ClearTimetable(FileInfo sqlDB)
        {
            List<string> network_tables = new List<string>();
            network_tables.Add(SQLFieldNames.TIMETABLES);
            network_tables.Add(SQLFieldNames.SERVICES);
            network_tables.Add(SQLFieldNames.ROUTES);
            network_tables.Add(SQLFieldNames.STOPS);

            SQLiteDatabase db = new SQLiteDatabase(sqlDB);
            db.ClearTable(network_tables);
        }
Exemplo n.º 2
0
        public static void ClearNetwork(FileInfo sqlDB)
        {
            List<string> network_tables = new List<string>();
            network_tables.Add(SQLFieldNames.LOCATION_ALIASES);
            network_tables.Add(SQLFieldNames.LOCATIONS);
            network_tables.Add(SQLFieldNames.NETWORKS);
            network_tables.Add(SQLFieldNames.TOUCHING_LOCATIONS);
            network_tables.Add(SQLFieldNames.SWAP_LOCATIONS);

            SQLiteDatabase db = new SQLiteDatabase(sqlDB);
            db.ClearTable(network_tables);
        }
Exemplo n.º 3
0
 public void ClearTable(string tablename, System.Data.SQLite.SQLiteDatabase db = null)
 {
     if (db == null)
     {
         db = this.db;
     }
     if (db == null)
     {
         db = this.db;
     }
     if (db == null)
     {
         return;
     }
     db.ClearTable(tablename);
 }
Exemplo n.º 4
0
 public void ClearTable(string tableName)
 {
     db.ClearTable(tableName);
 }
Exemplo n.º 5
0
        public void ConfigureTVGuide(bool useUPnPStreamUrl = false)
        {
            Log("Checking for the source.db and settings.xml files");

            if (!System.IO.File.Exists(settings.TVGuidePath))
            {
                Log("   source.db file not found at: " + settings.TVGuidePath);
                Log("Failed TVGuide configuration");
                return;
            }
            else
            {
                Log("   source.db found at: " + settings.TVGuidePath);
            }

            if (!System.IO.File.Exists(settings.TVGuidePath))
            {
                Log("   settings.xml file not found at: " + new FileInfo(settings.TVGuidePath).Directory + @"\settings.xml");
                Log("Failed TVGuide configuration");
                return;
            }
            else
            {
                Log("   settings.xml file found at: " + new FileInfo(settings.TVGuidePath).Directory + @"\settings.xml");
            }

            Log("Rewriting TVGuide channels from favorites (including strm file references)");

            Log("   Clearing any existing channel configurations");
            SQLiteDatabase db = new SQLiteDatabase(settings.TVGuidePath);
            try
            {
                db.ClearTable("CUSTOM_STREAM_URL");
                db.ClearTable("CHANNELS");
            }
            catch (Exception crap)
            {
                Log(crap.Message);
                return;
            }

            int i = 0;
            foreach (Channel channel in channels)
            {
                if (channel.Checked)
                {
                    db = new SQLiteDatabase(settings.TVGuidePath);

                    //Channel insert data
                    Dictionary<String, String> channelData = new Dictionary<String, String>();
                    channelData.Add("ID", channel.Id);
                    channelData.Add("TITLE", channel.VirtualNumber + " " + channel.Callsign);
                    channelData.Add("SOURCE", "xmltv");
                    channelData.Add("VISIBLE", "1");
                    channelData.Add("WEIGHT", i.ToString());

                    //Custom streams insert data
                    Dictionary<String, String> streamData = new Dictionary<String, String>();
                    streamData.Add("CHANNEL", channel.Id);
                    if (!useUPnPStreamUrl)
                    {
                        streamData.Add("STREAM_URL", StrmDirectory + channel.Filename);
                    }
                    else
                    {
                        string uuid = "missing-uuid-configuration";
                        try
                        {
                            uuid = settings.HDHRDMS.Split('|')[1];
                        }
                        catch (Exception){}
                        streamData.Add("STREAM_URL", "upnp://" + uuid + "/CableTV%2fv" + channel.VirtualNumber);
                    }

                    //Sources update
                    Dictionary<String, String> xmltvSourceUpdate = new Dictionary<String, String> { { "CHANNELS_UPDATED", "current_timestamp" } };
                    db.Update("SOURCES", xmltvSourceUpdate, "ID=\"xmltv\"");

                    try
                    {
                        db.Insert("CHANNELS", channelData);
                        db.Insert("CUSTOM_STREAM_URL", streamData);
                        Log("   Wrote channel: " + channel.VirtualNumber + " - " + channel.Callsign + " With stream path: " + streamData["STREAM_URL"]);
                    }
                    catch (Exception crap)
                    {
                        Log(crap.Message);
                    }

                    i++;
                }
            }

            Log("Updating settings and last updated timestamps");

            UpdateTVGuideSettingXML();

            //Custom streams insert data
            DataTable updateMax;
            String query = "select max(id) + 1 as next_id from UPDATES;";
            updateMax = db.GetDataTable(query);
            string nextId = "";
            foreach (DataRow dRow in updateMax.Rows)
            {
                nextId = dRow["next_id"].ToString();
            }
            Dictionary<String, String> updatesData = new Dictionary<String, String>();
            updatesData.Add("ID", nextId);
            updatesData.Add("SOURCE", "xmltv");
            updatesData.Add("DATE", DateTime.UtcNow.ToString("yyyy-MM-dd"));
            updatesData.Add("PROGRAMS_UPDATED", "current_timestamp");
            db.Insert("UPDATES", updatesData);

            //Settings update data
            Dictionary<String, String> sourceSetting = new Dictionary<String, String> { { "VALUE", "XMLTV" } };
            db.Update("SETTINGS", sourceSetting, String.Format("KEY = {0}", "\"source\""));
            Dictionary<String, String> xmltvFileSetting = new Dictionary<String, String> { { "VALUE", new FileInfo(settings.MC2XMLPath).Directory + @"\xmltv.xml" } };
            db.Update("SETTINGS", xmltvFileSetting, String.Format("KEY = {0}", "\"xmltv.file\""));

            Log("Done updating TVGuide!");
        }