/// <summary> /// Closes the WMC ObjectStore with the option to dispose the ObjectStore /// </summary> /// <param name="dispose">true = dispose ObjectStore</param> public static void Close(bool dispose = false) { if (objectStore != null) { objectStore.StoreExpired -= WmcObjectStore_StoreExpired; ObjectStore.ReleaseObjectStoreReference(); } wmcMergedLineup = null; try { if (dispose) { objectStore?.Dispose(); } } catch (Exception ex) { Logger.WriteInformation($"Exception thrown while trying to dispose of ObjectStore. {ex.Message}\n{ex.StackTrace}"); } objectStore = null; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); }
private static MergedLineup GetMergedLineupFromScannedLineup(Lineup scanned_lineup) { MergedLineup merged_lineup = scanned_lineup.PrimaryProvider; if (null == merged_lineup) { merged_lineup = scanned_lineup.SecondaryProvider; if (null == merged_lineup) { merged_lineup = new MergedLineups(object_store).First; if (merged_lineup.GetChannels().Length == 0) { foreach (MergedLineup ml in new MergedLineups(object_store)) { if (ml.GetChannels().Length > 0) { merged_lineup = ml; break; } } } } } return(merged_lineup); }
private void SelectAndLoadLineup(MergedLineup lineup) { merged_lineup_ = lineup; Channel[] channels = merged_lineup_.GetChannels(); int channel_count = channels.Length; merged_channels_ = new List <MergedChannel>(); foreach (Channel ch in channels.Distinct()) { merged_channels_.Add((MergedChannel)ch); } SortChannels(); MergedLineupGridView.RowCount = merged_channels_.Count; MergedLineupGridView.Invalidate(); }
public static void Close(bool dispose = false) { mergedLineup_ = null; singletonLineup_ = null; if (objectStore_ != null) { } if (dispose) { if (objectStore_ != null) { objectStore.Dispose(); } if (singletonStore_ != null) { ObjectStore.DisposeSingleton(); } } objectStore_ = null; singletonStore_ = null; }
public static void AddUserChannelInLineup(Lineup lineup, string callsign, int channel_number, int subchannel, ModulationType modulation_type) { List <ChannelTuningInfo> tuning_infos = new List <ChannelTuningInfo>(); foreach (Device device in lineup.ScanDevices) { string old_tuningspace_name = device.DeviceType.TuningSpaceName; if (string.IsNullOrEmpty(old_tuningspace_name)) { // hacky. For now I'm just trying to get it to work with ClearQAM. Ultimately I guess this would be a case // statement picking a value based on modulation_type. Why is it null for all my devices currently? string temp_tuningspace_name = GetTuningSpaceNameForModulation(modulation_type); // What really seems to matter looking at // ChannelTuningInfo(Device device, SerializationFormat format, byte[] serializedTuneRequest, TuneRequest tr) : base(device, format, serializedTuneRequest, tr) // in .NET Reflector is whether the tuning space has subnumbers or not. So if we can't figure out // what TuningSpace makes sense, pick one based on if subchannel is 0. if (string.IsNullOrEmpty(temp_tuningspace_name)) { temp_tuningspace_name = ((subchannel != 0) ? "ClearQAM" : "Cable"); } device.DeviceType.TuningSpaceName = temp_tuningspace_name; } try { ChannelTuningInfo channel_tuning_info = new ChannelTuningInfo(device, channel_number, subchannel, modulation_type); tuning_infos.Add(channel_tuning_info); } finally { device.DeviceType.TuningSpaceName = old_tuningspace_name; } } Channel ch = new Channel(); ch.CallSign = callsign; ch.ChannelType = ChannelType.UserAdded; ch.Number = channel_number; ch.SubNumber = subchannel; lineup.AddChannel(ch); foreach (ChannelTuningInfo channel_tuning_info in tuning_infos) { ch.TuningInfos.Add(channel_tuning_info); } ch.Update(); MergedChannel merged_channel = new MergedChannel(); merged_channel.Number = channel_number; merged_channel.SubNumber = subchannel; merged_channel.CallSign = callsign; merged_channel.ChannelType = ChannelType.UserAdded; merged_channel.FullMerge(ch); MergedLineup merged_lineup = (lineup.PrimaryProvider != null) ? lineup.PrimaryProvider : lineup.SecondaryProvider; if (merged_lineup == null) { merged_lineup = new MergedLineups(lineup.ObjectStore).First; } List <Channel> new_channels_list = new List <Channel>(); new_channels_list.Add(ch); bool old_keepAllPrimary = merged_lineup.LineupMergeRule.KeepAllPrimary; bool old_keepAllSecondary = merged_lineup.LineupMergeRule.KeepAllSecondary; merged_lineup.LineupMergeRule.KeepAllPrimary = true; merged_lineup.LineupMergeRule.KeepAllSecondary = true; try { lineup.NotifyChannelAdded(ch); // merged_lineup.OnChannelsAdded(lineup, new_channels_list); } finally { merged_lineup.LineupMergeRule.KeepAllPrimary = old_keepAllPrimary; merged_lineup.LineupMergeRule.KeepAllSecondary = old_keepAllSecondary; } }
private void SelectAndLoadLineup(MergedLineup lineup) { merged_lineup_ = lineup; Channel[] channels = merged_lineup_.GetChannels(); int channel_count = channels.Length; merged_channels_ = new List<MergedChannel>(); foreach (Channel ch in channels.Distinct()) merged_channels_.Add((MergedChannel)ch); SortChannels(); MergedLineupGridView.RowCount = merged_channels_.Count; MergedLineupGridView.Invalidate(); }
public static MergedChannel CreateMergedChannelFromChannels( List <Channel> channels, int guide_channel_number, int guide_subchannel, ChannelType channel_type = ChannelType.UserAdded) { try { Channel primary_channel = channels[0]; List <Channel> secondary_channels = channels.GetRange(1, channels.Count - 1); MergedLineup merged_lineup = GetMergedLineupFromScannedLineup(primary_channel.Lineup); MergedChannel merged_channel = new MergedChannel(); merged_channel.CallSign = primary_channel.CallSign; merged_channel.Number = guide_channel_number; merged_channel.OriginalNumber = guide_channel_number; merged_channel.SubNumber = guide_subchannel; merged_channel.OriginalSubNumber = guide_subchannel; merged_channel.ChannelType = channel_type; merged_channel.PrimaryChannel = primary_channel; merged_channel.Service = primary_channel.Service; merged_channel.Lineup = merged_lineup; new MergedChannels(object_store).Add(merged_channel); foreach (TuningInfo tuning_info in primary_channel.TuningInfos) { merged_channel.TuningInfos.Add(tuning_info); } foreach (Channel secondary_channel in secondary_channels) { merged_channel.SecondaryChannels.Add(secondary_channel); foreach (TuningInfo tuning_info in secondary_channel.TuningInfos) { merged_channel.TuningInfos.Add(tuning_info); } } merged_channel.GetUIdValue(true); merged_channel.Update(); try { merged_lineup.AddChannel(merged_channel); } catch (Exception exc) { Console.WriteLine("Caught exception thrown by MergedLineup.AddChannel {0} Message: {1}", exc.ToString(), exc.Message); } return(merged_channel); } catch (Exception exc) { if (channels != null) { exc.Data.Add("CreateMergedChannelFromChannels_channels.Count", channels.Count); for (int index = 0; index < channels.Count; ++index) { string key_start = string.Format("CreateMergedChannelFromChannels_channels[{0}]", index); Channel channel = channels[index]; if (channel != null) { exc.Data.Add(key_start + ".Number", channel.Number); exc.Data.Add(key_start + ".SubNumber", channel.SubNumber); } else { exc.Data.Add(key_start, "NULL"); } } if (channels.Count > 0 && channels[0] != null) { if (channels[0].Lineup != null) { exc.Data.Add("CreateMergedChannelFromChannels_channels[0].Lineup", channels[0].Lineup); if (channels[0].Lineup.PrimaryProvider != null) { exc.Data.Add("CreateMergedChannelFromChannels_channels[0].Lineup.PrimaryProvider", channels[0].Lineup.PrimaryProvider); } else { exc.Data.Add("CreateMergedChannelFromChannels_channels[0].Lineup.PrimaryProvider", "NULL"); } } else { exc.Data.Add("CreateMergedChannelFromChannels_channels[0].Lineup", "NULL"); } } } else { exc.Data.Add("CreateMergedChannelFromChannels_channels", "NULL"); } throw; } }
static void Main(string[] args) { MergedLineups merged_lineups = new MergedLineups(ChannelEditing.object_store); MergedLineup main_lineup = merged_lineups.ToArray()[1]; Lineup[] lineups = ChannelEditing.GetLineups(); foreach (Lineup lineup in lineups) { if ((lineup.Name == "Scanned (Digital Cable (ClearQAM))") && lineup.ScanDevices.Empty) { foreach (Channel ch in lineup.GetChannels()) { lineup.RemoveChannel(ch); } lineup.Unlock(); } if (!lineup.ScanDevices.Empty) { lineup.PrimaryProvider = main_lineup; } } foreach (MergedLineup mergedlineup in merged_lineups) { if (mergedlineup.GetChannels().Count() == 0) { mergedlineup.Unlock(); //merged_lineups.RemoveAllMatching(mergedlineup); } } Service[] services = new Services(ChannelEditing.object_store).ToArray(); DeviceGroup[] device_groups = new DeviceGroups(ChannelEditing.object_store).ToArray(); foreach (DeviceGroup device_group in device_groups) { Console.WriteLine("DeviceGroup: {0}", device_group.Name); } Device[] devices = new Devices(ChannelEditing.object_store).ToArray(); foreach (Device d in devices) { Console.WriteLine("Device: {0}", d.Name); } DeviceType[] device_types = new DeviceTypes(ChannelEditing.object_store).ToArray(); foreach (DeviceType dt in device_types) { Console.WriteLine("DeviceType: {0} DisplayName: {1} HeadendType: {2} Id: {3} IsSetTopBox: {4} NetworkType: {5} TuningSpaceName: {6} VideoSource: {7} ViewPriority: {8}", dt.Name, dt.DisplayName, dt.HeadendType, dt.Id, dt.IsSetTopBox, dt.NetworkType, dt.TuningSpaceName, dt.VideoSource, dt.ViewPriority); Microsoft.MediaCenter.TV.Tuning.TuningSpace tuning_space = dt.TuningSpace; if (tuning_space != null) { Console.WriteLine("Tuning space CLSID: {0} FriendlyName: {1} UniqueName: {2}", tuning_space.CLSID, tuning_space.FriendlyName, tuning_space.UniqueName); } } foreach (Service service in services) { Console.WriteLine("Service: {0} IsCached: {1} IsMerged: {2}", service.Name, service.IsCached, service.IsMergedService); } if (false) { foreach (Lineup lineup in lineups) { Console.WriteLine("Lineup: {0} ", lineup.Name); if (lineup.DeviceGroup != null) { Console.WriteLine("DeviceGroup: {0}", lineup.DeviceGroup.Name); if (lineup.DeviceGroup.Devices != null) { foreach (Device d in lineup.DeviceGroup.Devices) { Console.WriteLine(d.Name); } } } if (lineup.ScanDevices != null) { foreach (Device d in lineup.ScanDevices) { Console.WriteLine("ScanDevice: {0}", d); } } if (lineup.WmisDevices != null) { foreach (Device d in lineup.WmisDevices) { Console.WriteLine("WmiDevice: {0}", d); } //if (lineup.WmisDevices.Empty && lineup.ScanDevices.Empty) foreach (Channel ch in lineup.GetChannels()) { if (ch.Service != null) { Console.WriteLine("Callsign: {0}, CHannelNumber {1}, Service Callsign {2}, Service Name {3}", ch.CallSign, ch.ChannelNumber, ch.Service.CallSign, ch.Service.Name); if (!ch.Service.ScheduleEntries.Empty) { foreach (ScheduleEntry entry in ch.Service.ScheduleEntries) { if (entry.Program != null) { Console.WriteLine(entry.Program.Title); } } } } } } /* foreach (Channel ch in lineup.GetChannels()) * { * Console.WriteLine("Channel: {0} Service: {1}", ch.Number, ch.Service); * } */ } } MergedLineup merged_lineup = lineups[0].PrimaryProvider; Console.WriteLine("MergedLineup: {0}", merged_lineup); if (merged_lineup.SecondaryLineups != null) { foreach (Lineup lineup in merged_lineup.SecondaryLineups) { Console.WriteLine("Secondary Lineup: {0}", lineup.Name); } } Console.ReadLine(); FavoriteLineups favorite_lineups = new FavoriteLineups(ChannelEditing.object_store); foreach (FavoriteLineup favorite in favorite_lineups) { Console.WriteLine(favorite.Name); } PackageSubscriptions subscriptions = new PackageSubscriptions(ChannelEditing.object_store); foreach (PackageSubscription sub in subscriptions) { Console.WriteLine(sub.Package.Description); } }