示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="lineupId"></param>
        public static void UnsubscribeChannelsInLineup(long lineupId)
        {
            try
            {
                // unsubscribe all channels with this lineup as a primary
                if (!(WmcObjectStore.Fetch(lineupId) is Lineup lineup))
                {
                    return;
                }
                foreach (var channel in lineup.GetChannels())
                {
                    foreach (MergedChannel mergedChannel in channel.ReferencingPrimaryChannels)
                    {
                        SubscribeLineupChannel(0, mergedChannel.Id);
                    }

                    foreach (MergedChannel mergedChannel in channel.ReferencingSecondaryChannels)
                    {
                        mergedChannel.SecondaryChannels.RemoveAllMatching(channel);
                        mergedChannel.Update();
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteError($"Exception thrown during UnsubscribeChannelsInLineup(). {ex.Message}\n{ex.StackTrace}");
            }
        }
示例#2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mergedChannelId"></param>
 /// <param name="enable"></param>
 public static void SetChannelEnableState(long mergedChannelId, bool enable)
 {
     try
     {
         if (!(WmcObjectStore.Fetch(mergedChannelId) is MergedChannel mergedChannel))
         {
             return;
         }
         foreach (TuningInfo tuningInfo in mergedChannel.TuningInfos)
         {
             var infoOverride = tuningInfo.GetOverride(mergedChannel);
             if (!infoOverride?.IsUserOverride ?? true)
             {
                 continue;
             }
             infoOverride.UserBlockedState = tuningInfo.IsSuggestedBlocked ? UserBlockedState.Blocked : UserBlockedState.Enabled;
             infoOverride.Update();
             tuningInfo.Update();
         }
         mergedChannel.UserBlockedState = enable ? UserBlockedState.Enabled : UserBlockedState.Blocked;
         mergedChannel.Update();
         mergedChannel.Lineup.NotifyChannelUpdated(mergedChannel);
     }
     catch (Exception ex)
     {
         Logger.WriteInformation($"Exception thrown during SetChannelEnableState(). {ex.Message}\n{ex.StackTrace}");
     }
 }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="lineupId"></param>
        public static void DeleteLineup(long lineupId)
        {
            try
            {
                // remove all channels from lineup
                if (!(WmcObjectStore.Fetch(lineupId) is Lineup lineup))
                {
                    return;
                }
                foreach (var channel in lineup.GetChannels())
                {
                    lineup.RemoveChannel(channel);
                }

                // remove lineup from device(s)
                foreach (Device device in new Devices(WmcObjectStore))
                {
                    if (!device.WmisLineups.Contains(lineup))
                    {
                        continue;
                    }
                    device.WmisLineups.RemoveAllMatching(lineup);
                    device.Update();
                }

                // null the lineup name (necessary?)
                lineup.Name = null;
                lineup.Update();
            }
            catch (Exception ex)
            {
                Logger.WriteError($"Exception thrown during DeleteLineup(). {ex.Message}\n{ex.StackTrace}");
            }
        }
示例#4
0
        /// <summary>
        /// Clears all schedule entries in a service
        /// </summary>
        /// <param name="mergedChannelId"></param>
        public static void ClearServiceScheduleEntries(long mergedChannelId)
        {
            try
            {
                if (!(WmcObjectStore.Fetch(mergedChannelId) is MergedChannel channel))
                {
                    return;
                }
                foreach (ScheduleEntry scheduleEntry in channel.Service.ScheduleEntries)
                {
                    scheduleEntry.Service = null;
                    scheduleEntry.Program = null;
                    scheduleEntry.Unlock();
                    scheduleEntry.Update();
                }
                channel.Service.ScheduleEndTime = DateTime.MinValue;
                channel.Service.Update();

                // notify channel it was updated
                channel.Update();
            }
            catch (Exception ex)
            {
                Logger.WriteError($"Exception thrown during ClearServiceScheduleEntries(). {ex.Message}\n{ex.StackTrace}");
            }
        }
示例#5
0
 /// <summary>
 /// Set a custom channel number for a merged channel
 /// </summary>
 /// <param name="id">database object key</param>
 /// <param name="number">desired custom number, a null or empty string will revert to original channel numbers</param>
 /// <returns>resulting channel number for the merged channel</returns>
 public static void SetChannelCustomNumber(long id, string number)
 {
     try
     {
         if (!(WmcObjectStore.Fetch(id) is MergedChannel channel))
         {
             return;
         }
         if (!string.IsNullOrEmpty(number))
         {
             var digits = number.Split('.');
             if (digits.Length > 0)
             {
                 channel.Number = int.Parse(digits[0]);
             }
             channel.SubNumber = digits.Length > 1 ? int.Parse(digits[1]) : 0;
         }
         else
         {
             channel.Number    = channel.OriginalNumber;
             channel.SubNumber = channel.OriginalSubNumber;
         }
         channel.Update();
     }
     catch (Exception ex)
     {
         Logger.WriteError($"Exception thrown during SetChannelCustomNumber(). {ex.Message}\n{ex.StackTrace}");
     }
 }
示例#6
0
 /// <summary>
 /// Set a custom callsign for a merged channel
 /// </summary>
 /// <param name="id">database object key</param>
 /// <param name="callsign">desired custom callsign, a null or empty string will assign primary channel's callsign</param>
 /// <returns>resulting callsign for the merged channel</returns>
 public static void SetChannelCustomCallsign(long id, string callsign)
 {
     try
     {
         if (!(WmcObjectStore.Fetch(id) is MergedChannel channel))
         {
             return;
         }
         channel.CallSign = callsign;
         channel.Update();
     }
     catch (Exception ex)
     {
         Logger.WriteError($"Exception thrown during SetChannelCustomCallsign(). {ex.Message}\n{ex.StackTrace}");
     }
 }
示例#7
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static List <Channel> GetEpg123LineupChannels()
        {
            var ret = new List <Channel>();

            try
            {
                foreach (var lineup in from myLineup in GetWmisLineups()
                         where myLineup.Name.StartsWith("EPG123") || myLineup.Name.StartsWith("HDHR2MXF")
                         select WmcObjectStore.Fetch(myLineup.LineupId) as Lineup)
                {
                    ret.AddRange(lineup.UncachedChannels.ToList());
                }
            }
            catch (Exception ex)
            {
                Logger.WriteInformation($"Exception thrown during GetEpg123LineupChannels(). {ex.Message}\n{ex.StackTrace}");
            }
            return(ret);
        }
示例#8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="scannedLineup"></param>
        /// <param name="service"></param>
        /// <param name="channel"></param>
        /// <param name="tuningInfos"></param>
        public static void AddUserChannel(Lineup scannedLineup, Service service, Channel channel, List <TuningInfo> tuningInfos)
        {
            try
            {
                WmcObjectStore.Add(service);
                scannedLineup.AddChannel(channel);

                foreach (var tuningInfo in tuningInfos)
                {
                    WmcObjectStore.Add(tuningInfo);
                    channel.TuningInfos.Add(tuningInfo);
                }

                scannedLineup.NotifyChannelAdded(channel);
            }
            catch (Exception ex)
            {
                Logger.WriteError($"Exception thrown during AddUserChannel(). {ex.Message}\n{ex.StackTrace}");
            }
        }
示例#9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="lineupId"></param>
        /// <returns></returns>
        public static List <myLineupLvi> GetLineupChannels(long lineupId)
        {
            var ret = new List <myLineupLvi>();

            try
            {
                if (!(WmcObjectStore.Fetch(lineupId) is Lineup lineup))
                {
                    return(ret);
                }
                foreach (Channel channel in lineup.UncachedChannels)
                {
                    ret.Add(new myLineupLvi(channel));
                }
            }
            catch (Exception ex)
            {
                Logger.WriteInformation($"Exception thrown during GetLineupChannels(). {ex.Message}\n{ex.StackTrace}");
            }
            return(ret);
        }
示例#10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="channelId"></param>
 public static void DeleteChannel(long channelId)
 {
     try
     {
         if (!(WmcObjectStore.Fetch(channelId) is Channel channel))
         {
             return;
         }
         if (channel.ChannelType == ChannelType.UserAdded)
         {
             WmcMergedLineup.DeleteUserAddedChannel(channel);
         }
         else
         {
             WmcMergedLineup.RemoveChannel(channel);
         }
         WmcMergedLineup.Update();
         channel.Uncache();
     }
     catch (Exception ex)
     {
         Logger.WriteError($"Exception thrown during DeleteChannel(). {ex.Message}\n{ex.StackTrace}");
     }
 }
示例#11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="lineupChannelId"></param>
        /// <param name="mergedChannelId"></param>
        public static void SubscribeLineupChannel(long lineupChannelId, long mergedChannelId)
        {
            try
            {
                Channel listings = null;
                if (!(WmcObjectStore.Fetch(mergedChannelId) is MergedChannel mergedChannel))
                {
                    return;
                }
                if (lineupChannelId > 0)
                {
                    // grab the listings
                    listings = WmcObjectStore.Fetch(lineupChannelId) as Channel;
                    if (listings == null)
                    {
                        return;
                    }

                    // add this channel lineup to the device group if necessary
                    foreach (Device device in mergedChannel.Lineup.DeviceGroup.Devices)
                    {
                        try
                        {
                            if (device.Name.ToLower().Contains("delete") || device.ScannedLineup == null ||
                                !device.ScannedLineup.IsSameAs(mergedChannel.PrimaryChannel.Lineup) ||
                                device.WmisLineups != null && device.WmisLineups.Contains(listings.Lineup))
                            {
                                continue;
                            }
                            device.SubscribeToWmisLineup(listings.Lineup);
                            device.Update();
                        }
                        catch (Exception ex)
                        {
                            Logger.WriteVerbose($"Failed to associate lineup {listings.Lineup} with device {device.Name ?? "<<NULL>>"} ({(device.ScannedLineup == null ? "<<NULL>>" : device.ScannedLineup.Name)}). {ex.Message}");
                        }
                    }
                }

                if (lineupChannelId == 0 && (mergedChannel.PrimaryChannel?.Lineup?.Name?.StartsWith("Scanned") ?? false))
                {
                    // do nothing
                }
                else
                {
                    foreach (Channel secondary in mergedChannel.SecondaryChannels)
                    {
                        if (secondary.Lineup == null)
                        {
                            mergedChannel.SecondaryChannels.RemoveAllMatching(secondary);
                        }
                    }
                    mergedChannel.AddChannelListings(listings);
                }
                SetChannelEnableState(mergedChannelId, listings != null);
                mergedChannel.Update();
            }
            catch (Exception ex)
            {
                Logger.WriteInformation($"Exception thrown during SubscribeLineupChannel(). {ex.Message}\n{ex.StackTrace}");
            }
        }