Exemplo n.º 1
0
        /// <summary>
        /// Searches the specified IP Address.
        /// //string IP, string term)
        /// </summary>
        public async Task Search()
        {
            try
            {
                var foundDevices = await deviceLocator.SearchAsync().ConfigureAwait(false);

                foreach (DiscoveredSsdpDevice device in foundDevices.ToList())
                {
                    SsdpDevice info = await device.GetDeviceInfo().ConfigureAwait(false);

                    var fd = new FoundDevice
                    {
                        IpAddress  = device.DescriptionLocation.DnsSafeHost,
                        DeviceName = info.FriendlyName,
                        DeviceId   = info.Uuid.Replace("-", ""),
                        FoundUsing = "SSdp",
                        FoundAt    = device.AsAt.DateTime
                    };

                    FoundDeviceCollection.Add(fd);
                }
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine($"\t{ex.Message}");
                Console.ResetColor();
            }
        }
Exemplo n.º 2
0
        private void FindDeviceId(object obj)
        {
            try
            {
                var workflow = new PingWorkflow();

                var device   = obj as FoundDevice;
                var DeviceId = workflow.FindDeviceId(device);
                device.DeviceId = DeviceId.Value ?? Utils.Common;
                FoundDeviceCollection.Add(device);

                Thread.Sleep(100);
                QueueLength--;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 3
0
        private void DeviceLocator_DeviceAvailable(object sender, DeviceAvailableEventArgs e)
        {
            try
            {
                var device     = e.DiscoveredDevice;
                var infoDevice = device.GetDeviceInfo().ConfigureAwait(false).GetAwaiter().GetResult();

                var objs = new List <object> {
                    device, infoDevice
                };
                var foundDevice = auow.BuildObject <FoundDevice, List <object> >(objs);

                FoundDeviceCollection.Add(foundDevice);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 4
0
        public void Commit <T>(T item)
        {
            if (item == null)
            {
                return;
            }

            var device      = item as FoundDevice;
            var callingName = NameOfCallingClass();

            Console.WriteLine($"{callingName} \t||\t {device}");

            if (string.IsNullOrEmpty(device.IpAddress))
            {
                return;
            }

            FoundDeviceCollection.Add(device);
        }