예제 #1
0
        private void ReadChannels()
        {
            var pos = 0;

            using var file = new StreamReader(FileName);
            string line;

            while ((line = file.ReadLine()) != null)
            {
                ChannelInfo channel = new Channels(pos, line, DataRoot);
                DataRoot.AddChannel(allChannels, channel);
                pos++;
            }
        }
예제 #2
0
        private void ReadChannel(FileData file, ChannelList curList, XmlNode node, int rowId)
        {
            var setupNode = node["Setup"] ?? throw new FileLoadException("Missing Setup XML element");
            var bcastNode = node["Broadcast"] ?? throw new FileLoadException("Missing Broadcast XML element");
            var data      = new Dictionary <string, string>(StringComparer.InvariantCultureIgnoreCase);

            foreach (var n in new[] { setupNode, bcastNode })
            {
                foreach (XmlAttribute attr in n.Attributes)
                {
                    data.Add(attr.LocalName, attr.Value);
                }
            }

            if (!data.ContainsKey("UniqueID") || !int.TryParse(data["UniqueID"], out var uniqueId)) // UniqueId only exists in ChannelMap_105 and later
            {
                uniqueId = rowId;
            }
            var chan = new Channel(curList.SignalSource & SignalSource.MaskAdInput, rowId, uniqueId, setupNode);

            chan.OldProgramNr = -1;
            chan.IsDeleted    = false;
            if (file.formatVersion == 1)
            {
                this.ParseChannelFormat1(data, chan);
            }
            else if (file.formatVersion == 2)
            {
                this.ParseChannelFormat2(data, chan);
            }

            if ((chan.SignalSource & SignalSource.MaskAdInput) == SignalSource.DvbT)
            {
                chan.ChannelOrTransponder = LookupData.Instance.GetDvbtTransponder(chan.FreqInMhz).ToString();
            }
            else if ((chan.SignalSource & SignalSource.MaskAdInput) == SignalSource.DvbC)
            {
                chan.ChannelOrTransponder = LookupData.Instance.GetDvbcChannelName(chan.FreqInMhz);
            }

            DataRoot.AddChannel(curList, chan);
        }
예제 #3
0
        private void ReadChannels(SQLiteCommand cmd)
        {
            string[] fieldNames =
            {
                "rowid",         "major_channel", "physical_ch",   "sname",         "freq",  "skip", "running_status", "free_CA_mode", "child_lock",
                "profile1index", "profile2index", "profile3index", "profile4index", "stype", "onid", "tsid",           "svcid",        "ntype",     "ya_svcid",
                "delivery",      "delivery_type"
            };

            string sql = string.Join(" ",
                                     "SELECT",
                                     "s.rowid, s.major_channel, s.physical_ch, cast(s.sname as blob), t.freq, s.skip, s.running_status,",
                                     "s.free_CA_mode, s.child_lock, s.profile1index, s.profile2index, s.profile3index, s.profile4index, s.stype,",
                                     "s.onid, s.tsid, s.svcid, s.ntype, s.ya_svcid, t.delivery, ifnull(t.delivery_type, 0)",
                                     "FROM SVL s",
                                     "LEFT OUTER JOIN TSL t ON s.physical_ch = t.physical_ch and s.tsid = t.tsid",
                                     "ORDER BY s.ntype, major_channel");

            var fields = GetFieldMap(fieldNames);

            cmd.CommandText = sql;
            using (var r = cmd.ExecuteReader())
            {
                while (r.Read())
                {
                    ChannelInfo channel = new DbChannel(r, fields, DataRoot, DefaultEncoding);
                    if (!channel.IsDeleted)
                    {
                        ChannelList channelList = DataRoot.GetChannelList(channel.SignalSource);

                        if (channelList != null)
                        {
                            DataRoot.AddChannel(channelList, channel);
                        }
                    }
                }
            }
        }
예제 #4
0
        private void LoadFavorites(SQLiteCommand cmd)
        {
            cmd.CommandText = @"
select fi.FavoriteId, fi.ServiceId, fi.ChannelNum, fi.Selectable, fi.Visible, fi.isDeleted, fi.Protected, l.Lcn 
from FavoriteItem fi 
left outer join Lcn l on l.ServiceId=fi.ServiceId and l.FavoriteId=fi.FavoriteId
";
            using (var r = cmd.ExecuteReader())
            {
                while (r.Read())
                {
                    int favListId = r.GetInt32(0);
                    var ci        = channelsById.TryGet(r.GetInt32(1));
                    if (ci == null)
                    {
                        continue;
                    }

                    int favListIdx = favListIdToFavIndex.TryGet(favListId, -1);
                    if (favListIdx >= 0)
                    {
                        // NOTE: we need to set the NEW fav index here because AddChannel will use the new value to initialize the old value
                        ci.FavIndex[favListIdx] = r.GetInt32(2);
                    }

                    ci.SetOldPosition(favListIdx + 1, r.GetInt32(2)); // 0=main nr, 1-4=fav 1-4
                    if (favListIdx < 0)
                    {
                        // physical channel list (specific satellite, $av, ...)
                        var list = channelLists.TryGet(favListId);

                        if (!r.IsDBNull(7)) // LCN
                        {
                            ci.ProgramNrPreset = r.GetInt32(7);
#if LOCK_LCN_LISTS
                            list.ReadOnly = true;
#endif
                        }

                        ci.Skip      = r.GetInt32(3) == 0;
                        ci.Lock      = r.GetInt32(6) != 0;
                        ci.Hidden    = r.GetInt32(4) == 0;
                        ci.IsDeleted = r.GetInt32(5) != 0;
                        ci.Source    = list.ShortCaption;
                        if (ci.IsDeleted)
                        {
                            ci.OldProgramNr = -1;
                        }
                        if ((ci.SignalSource & (SignalSource.MaskAntennaCableSat | SignalSource.MaskAnalogDigital)) == SignalSource.DvbS)
                        {
                            ci.Satellite = list.ShortCaption;
                        }

                        DataRoot.AddChannel(list, ci);
                    }
                }
            }

            foreach (var ci in channelsById.Values)
            {
                DataRoot.AddChannel(userFavList, ci);
            }
        }