Esempio n. 1
0
            public static string List(string url)
            {
                string response = null;

                try
                {
                    var uri = new Uri(url);

                    // Get Devices Parameter
                    string json = HttpUtility.ParseQueryString(uri.Query).Get("devices");
                    if (!string.IsNullOrEmpty(json))
                    {
                        var devices = JSON.ToType <List <API.Data.DeviceListItem> >(json);
                        if (devices != null)
                        {
                            var deviceInfos = new List <API.Data.DeviceInfo>();

                            foreach (var device in devices)
                            {
                                var deviceInfo = DeviceInfos.Find(o => o.UniqueId == device.UniqueId);
                                if (deviceInfo != null)
                                {
                                    var info = new API.Data.DeviceInfo();
                                    info.UniqueId    = deviceInfo.UniqueId;
                                    info.Enabled     = deviceInfo.Enabled;
                                    info.Index       = deviceInfo.Index;
                                    info.Description = deviceInfo.Description;

                                    deviceInfos.Add(info);
                                }
                            }

                            if (deviceInfos.Count > 0)
                            {
                                response = API.Data.DeviceInfo.ListToJson(deviceInfos);
                            }
                        }
                    }
                    else
                    {
                        var deviceInfos = new List <API.Data.DeviceInfo>();

                        foreach (var deviceInfo in DeviceInfos)
                        {
                            var info = new API.Data.DeviceInfo();
                            info.UniqueId    = deviceInfo.UniqueId;
                            info.Enabled     = deviceInfo.Enabled;
                            info.Index       = deviceInfo.Index;
                            info.Description = deviceInfo.Description;

                            deviceInfos.Add(info);
                        }

                        if (deviceInfos.Count > 0)
                        {
                            response = API.Data.DeviceInfo.ListToJson(deviceInfos);
                        }
                    }
                }
                catch (Exception ex) { logger.Error(ex); }

                return(response);
            }
            public static string List(string url)
            {
                string response = null;

                try
                {
                    var uri = new Uri(url);

                    // Get Devices Parameter
                    string json = HttpUtility.ParseQueryString(uri.Query).Get("devices");
                    if (!string.IsNullOrEmpty(json))
                    {
                        var devices = JSON.ToType<List<API.Data.DeviceListItem>>(json);
                        if (devices != null)
                        {
                            var deviceInfos = new List<API.Data.DeviceInfo>();

                            foreach (var device in devices)
                            {
                                var deviceInfo = DeviceInfos.Find(o => o.UniqueId == device.UniqueId);
                                if (deviceInfo != null)
                                {
                                    var info = new API.Data.DeviceInfo();
                                    info.UniqueId = deviceInfo.UniqueId;
                                    info.Enabled = deviceInfo.Enabled;
                                    info.Index = deviceInfo.Index;
                                    info.Description = deviceInfo.Description;

                                    deviceInfos.Add(info);
                                }
                            }

                            if (deviceInfos.Count > 0) response = API.Data.DeviceInfo.ListToJson(deviceInfos);
                        }
                    }
                    else
                    {
                        var deviceInfos = new List<API.Data.DeviceInfo>();

                        foreach (var deviceInfo in DeviceInfos)
                        {
                            var info = new API.Data.DeviceInfo();
                            info.UniqueId = deviceInfo.UniqueId;
                            info.Enabled = deviceInfo.Enabled;
                            info.Index = deviceInfo.Index;
                            info.Description = deviceInfo.Description;

                            deviceInfos.Add(info);
                        }

                        if (deviceInfos.Count > 0) response = API.Data.DeviceInfo.ListToJson(deviceInfos);
                    }
                }
                catch (Exception ex) { Logger.Log("Error Getting Local Server Devices :: " + ex.Message, LogLineType.Error); }

                return response;
            }