Example #1
0
        /// <summary>
        /// Start ad-hoc scan
        /// </summary>
        /// <param name="discoverer"></param>
        private async Task SetAdHocScanAsync(DiscovererInfo discoverer)
        {
            if (!IsDiscoveryEventSubscribed)
            {
                discoverer.DiscoveryRequestId = Guid.NewGuid().ToString();
                Discovery = await RegistryServiceEvents.SubscribeDiscoveryProgressByRequestIdAsync(
                    discoverer.DiscoveryRequestId, async data => {
                    await InvokeAsync(() => ScanProgress(data));
                });

                IsDiscoveryEventSubscribed = true;
            }

            try {
                EventResult = string.Empty;

                discoverer.IsSearching = true;
                ScanResult             = "displayBlock";
                DiscovererData         = discoverer;
                Status = await RegistryHelper.DiscoverServersAsync(discoverer);
            }
            catch {
                if (Discovery != null)
                {
                    await Discovery.DisposeAsync();
                }
                IsDiscoveryEventSubscribed = false;
            }
        }
Example #2
0
        public async void Dispose()
        {
            if (_discovererEvent != null)
            {
                await _discovererEvent.DisposeAsync();
            }

            if (Discovery != null)
            {
                await Discovery.DisposeAsync();
            }
        }
Example #3
0
        public async override void Dispose()
        {
            if (_events != null)
            {
                await _events.DisposeAsync();
            }

            if (Discovery != null)
            {
                await Discovery.DisposeAsync();
            }
        }
Example #4
0
        /// <summary>
        /// Enable discoverer scan
        /// </summary>
        /// <param name="discoverer"></param>
        private async Task SetScanAsync(DiscovererInfo discoverer, bool checkStatus)
        {
            try {
                discoverer.ScanStatus = checkStatus;
                EventResult           = string.Empty;

                if (discoverer.ScanStatus == true)
                {
                    if (!IsDiscoveryEventSubscribed)
                    {
                        Discovery = await RegistryServiceEvents.SubscribeDiscoveryProgressByDiscovererIdAsync(
                            discoverer.DiscovererModel.Id, async data => {
                            await InvokeAsync(() => ScanProgress(data));
                        });
                    }

                    IsDiscoveryEventSubscribed = true;
                    discoverer.IsSearching     = true;
                    ScanResult     = "displayBlock";
                    DiscovererData = discoverer;
                }
                else
                {
                    discoverer.IsSearching = false;
                    ScanResult             = "displayNone";
                    if (Discovery != null)
                    {
                        await Discovery.DisposeAsync();
                    }
                    IsDiscoveryEventSubscribed = false;
                }
                Status = await RegistryHelper.SetDiscoveryAsync(discoverer);
            }
            catch {
                if (Discovery != null)
                {
                    await Discovery.DisposeAsync();
                }
                IsDiscoveryEventSubscribed = false;
            }
        }