Пример #1
0
        public UiBroadcastDiscovery Download(Form ownerForm, UiServiceProvider serviceProvider, UiBroadcastDiscovery currentUiDiscovery, bool fromCache, bool?highDefinitionPriority = null)
        {
            UiBroadcastDiscovery uiDiscovery;

            try
            {
                uiDiscovery = null;
                if (fromCache)
                {
                    OnBeforeCacheLoad(this, EventArgs.Empty);
                    var cachedDiscovery = AppUiConfiguration.Current.Cache.LoadXmlDocument <UiBroadcastDiscovery>("UiBroadcastDiscovery", serviceProvider.Key);
                    OnAfterCacheLoad(this, new CacheEventArgs(cachedDiscovery));

                    if (cachedDiscovery != null)
                    {
                        uiDiscovery = cachedDiscovery.Document;
                    }
                } // if

                if (uiDiscovery == null)
                {
                    OnBeforeDownload(this, EventArgs.Empty);
                    var downloader = new UiDvbStpEnhancedDownloader()
                    {
                        Request = new UiDvbStpEnhancedDownloadRequest(2)
                        {
                            MulticastAddress        = IPAddress.Parse(serviceProvider.Offering.Push[0].Address),
                            MulticastPort           = serviceProvider.Offering.Push[0].Port,
                            Description             = Properties.Texts.BroadcastObtainingList,
                            DescriptionParsing      = Properties.Texts.BroadcastParsingList,
                            AllowXmlExtraWhitespace = false,
                            XmlNamespaceReplacer    = NamespaceUnification.Replacer,
#if DEBUG
                            DumpToFolder = AppUiConfiguration.Current.Folders.Cache
#endif
                        },
                        TextUserCancelled     = Properties.Texts.UserCancelListRefresh,
                        TextDownloadException = Properties.Texts.BroadcastListUnableRefresh,
                    };
                    downloader.Request.AddPayload(0x02, null, Properties.Texts.Payload02DisplayName, typeof(BroadcastDiscoveryRoot));
                    downloader.Request.AddPayload(0x05, null, Properties.Texts.Payload05DisplayName, typeof(PackageDiscoveryRoot));
                    downloader.Download(ownerForm);
                    OnAfterDownload(this, new DownloadEventArgs(downloader));
                    if (!downloader.IsOk)
                    {
                        return(null);
                    }

                    var xmlDiscovery = downloader.Request.Payloads[0].XmlDeserializedData as BroadcastDiscoveryRoot;
                    uiDiscovery = new UiBroadcastDiscovery(xmlDiscovery, serviceProvider.DomainName, downloader.Request.Payloads[0].SegmentVersion);

                    OnBeforeMerge(this, new MergeEventArgs(uiDiscovery, currentUiDiscovery));
                    UiBroadcastDiscoveryMergeResultDialog.Merge(ownerForm, currentUiDiscovery, uiDiscovery);
                    OnAfterMerge(this, new MergeEventArgs(uiDiscovery, currentUiDiscovery));

                    var packageDiscovery = downloader.Request.Payloads[1].XmlDeserializedData as PackageDiscoveryRoot;
                    highDefinitionPriority = highDefinitionPriority.HasValue ? highDefinitionPriority.Value : !AppUiConfiguration.Current.User.ChannelNumberStandardDefinitionPriority;

                    OnBeforeAssignNumbers(this, new AssignNumbersArgs(uiDiscovery, packageDiscovery, serviceProvider, highDefinitionPriority.Value));
                    UiServicesLogicalNumbers.AssignLogicalNumbers(uiDiscovery, packageDiscovery, serviceProvider.DomainName, highDefinitionPriority.Value);
                    OnAfterAssignNumbers(this, new AssignNumbersArgs(uiDiscovery, packageDiscovery, serviceProvider, highDefinitionPriority.Value));

                    AppUiConfiguration.Current.Cache.SaveXml("PackageDiscovery", serviceProvider.Key, 0, packageDiscovery);
                    AppUiConfiguration.Current.Cache.SaveXml("UiBroadcastDiscovery", serviceProvider.Key, uiDiscovery.Version, uiDiscovery);
                } // if

                return(uiDiscovery);
            }
            catch (Exception ex)
            {
                OnHandleException(this, new HandleExceptionEventArgs(ownerForm, null, Properties.Texts.BroadcastListUnableRefresh, ex));
                return(null);
            } // try-catch
        }     // Download
Пример #2
0
        }     // ClearLogicalNumbers

        public static void AssignLogicalNumbers(UiBroadcastDiscovery uiDiscovery, PackageDiscoveryRoot packageDiscovery, string defaultDomain, bool highDefinitionPriority = true)
        {
            var aux = new UiServicesLogicalNumbers(uiDiscovery, packageDiscovery, defaultDomain, highDefinitionPriority);

            aux.Assign();
        } // AssignLogicalNumbers