Пример #1
0
        private void ImportChannel(GuideServiceAgent tvGuideAgent, SchedulerServiceAgent tvSchedulerAgent, ImportChannelsContext.ImportChannel importChannel)
        {
            Guid channelId;

            Channels.ChannelLink channelLink = Channels.ChannelLinks.GetChannelLinkForMediaPortalChannel(importChannel.Channel);
            if (channelLink == null)
            {
                Channel channel = new Channel();
                channel.ChannelType = this.Context.ChannelType;
                channel.VisibleInGuide = true;
                channel.DisplayName = importChannel.Channel.DisplayName;
                channel.LogicalChannelNumber = importChannel.LogicalChannelNumber;
                channel.Sequence = importChannel.Channel.SortOrder;
                channel = tvSchedulerAgent.SaveChannel(channel);
                Channels.ChannelLinks.SetLinkedMediaPortalChannel(channel, importChannel.Channel);

                channelId = channel.ChannelId;
            }
            else
            {
                channelId = channelLink.ChannelId;
            }

            if (!_importChannelsOnlyRadioButton.Checked)
            {
                string groupName;
                int groupSequence;
                if (_importChannelsAndGroupsRadioButton.Checked)
                {
                    groupName = importChannel.GroupName;
                    groupSequence = importChannel.GroupSequence;
                }
                else
                {
                    groupName = _groupNameTextBox.Text.Trim();
                    groupSequence = 0;
                }
                if (!String.IsNullOrEmpty(importChannel.GroupName))
                {
                    if (!_channelGroupsByName.ContainsKey(groupName))
                    {
                        ChannelGroup channelGroup = new ChannelGroup();
                        channelGroup.GroupName = groupName;
                        channelGroup.VisibleInGuide = true;
                        channelGroup.ChannelType = this.Context.ChannelType;
                        channelGroup.Sequence = groupSequence;
                        channelGroup = tvSchedulerAgent.SaveChannelGroup(channelGroup);
                        _channelGroupsByName[groupName] = channelGroup;
                        _channelMembersByName[groupName] = new List<Guid>();
                    }

                    if (!_channelMembersByName.ContainsKey(groupName))
                    {
                        _channelMembersByName[groupName] = new List<Guid>(
                            tvSchedulerAgent.GetChannelGroupMembers(_channelGroupsByName[groupName].ChannelGroupId));
                    }

                    _channelMembersByName[groupName].Add(channelId);
                }
            }
        }
Пример #2
0
        private void ImportChannel(GuideServiceAgent tvGuideAgent, SchedulerServiceAgent tvSchedulerAgent, ImportChannelsContext.ImportChannel importChannel)
        {
            Guid channelId;

            Channels.ChannelLink channelLink = Channels.ChannelLinks.GetChannelLinkForMediaPortalChannel(importChannel.Channel);
            if (channelLink == null)
            {
                Channel channel = new Channel();
                channel.ChannelType          = this.Context.ChannelType;
                channel.VisibleInGuide       = true;
                channel.DisplayName          = importChannel.Channel.DisplayName;
                channel.LogicalChannelNumber = importChannel.LogicalChannelNumber;
                channel.Sequence             = importChannel.Channel.SortOrder;
                channel = tvSchedulerAgent.SaveChannel(channel);
                Channels.ChannelLinks.SetLinkedMediaPortalChannel(channel, importChannel.Channel);

                channelId = channel.ChannelId;
            }
            else
            {
                channelId = channelLink.ChannelId;
            }

            if (!_importChannelsOnlyRadioButton.Checked)
            {
                string groupName;
                int    groupSequence;
                if (_importChannelsAndGroupsRadioButton.Checked)
                {
                    groupName     = importChannel.GroupName;
                    groupSequence = importChannel.GroupSequence;
                }
                else
                {
                    groupName     = _groupNameTextBox.Text.Trim();
                    groupSequence = 0;
                }
                if (!String.IsNullOrEmpty(importChannel.GroupName))
                {
                    if (!_channelGroupsByName.ContainsKey(groupName))
                    {
                        ChannelGroup channelGroup = new ChannelGroup();
                        channelGroup.GroupName      = groupName;
                        channelGroup.VisibleInGuide = true;
                        channelGroup.ChannelType    = this.Context.ChannelType;
                        channelGroup.Sequence       = groupSequence;
                        channelGroup = tvSchedulerAgent.SaveChannelGroup(channelGroup);
                        _channelGroupsByName[groupName]  = channelGroup;
                        _channelMembersByName[groupName] = new List <Guid>();
                    }

                    if (!_channelMembersByName.ContainsKey(groupName))
                    {
                        _channelMembersByName[groupName] = new List <Guid>(
                            tvSchedulerAgent.GetChannelGroupMembers(_channelGroupsByName[groupName].ChannelGroupId));
                    }

                    _channelMembersByName[groupName].Add(channelId);
                }
            }
        }