예제 #1
0
        internal void ToggleChannel(KeyblockChannelUpdate update)
        {
            if (update == null)
            {
                return;
            }
            Logger.Debug("Update channel list to monitor");
            var list = GetChannelsToMonitor();

            if (update.Enabled)
            {
                if (list.ContainsKey(update.Id))
                {
                    Logger.Info($"Updated key {update.NewKey} for {update.Id}");
                    list[update.Id] = update.NewKey;
                }
                else
                {
                    Logger.Info($"Add key {update.NewKey} for {update.Id}");
                    list.Add(update.Id, update.NewKey);
                }
            }
            else if (list.ContainsKey(update.Id))
            {
                Logger.Info($"Removed key for {update.Id}");
                list.Remove(update.Id);
            }
            KeyblockChannelsToMonitor = string.Join(";", list.Select(kv => $"{kv.Key}:{kv.Value}"));
            Save();
        }
예제 #2
0
        private void UpdateKeyblock(Channel newChannel, Channel oldChannel)
        {
            if (newChannel.Keyblock == oldChannel.Keyblock && newChannel.KeyblockId == oldChannel.KeyblockId)
            {
                return;
            }
            _logger.Info($"{(newChannel.Keyblock ? "Add to" : "Remove from")} Keyblock - {newChannel.Name}: {newChannel.KeyblockId}");
            var kcu = new KeyblockChannelUpdate {
                Id = newChannel.Number.ToString(), Name = newChannel.Name, Enabled = newChannel.Keyblock, OldKey = oldChannel.KeyblockId, NewKey = newChannel.KeyblockId
            };

            SendData(nameof(Keyblock), DataType.KeyblockChannelUpdate, kcu);
        }