Example #1
0
        private void UpdateDeviceData(string uniqueId, List<Data.HourInfo> infos)
        {
            var deviceInfo = cachedDevicesInfos.Find(o => o.UniqueId == uniqueId);
            if (deviceInfo == null)
            {
                deviceInfo = new Data.DeviceInfo();
                deviceInfo.UniqueId = uniqueId;
                cachedDevicesInfos.Add(deviceInfo);
            }

            deviceInfo.Hours = infos;
        }
Example #2
0
        public static List<Data.DeviceInfo> Load(string[] devices)
        {
            var config = Configuration.Read();

            if (File.Exists(config.SQliteDatabasePath))
            {
                try
                {
                    var connection = Connection.Create(config);
                    if (connection != null)
                    {
                        DataTable hoursTable = Table.GetHours(connection, devices);
                        if (hoursTable != null)
                        {
                            var hourRowInfos = new List<Row.HourRowInfo>();

                            // Get HourRowInfo objects from DataRows
                            foreach (DataRow row in hoursTable.Rows)
                            {
                                var hourRowInfo = Row.GetHourInfo(connection, row);
                                if (hourRowInfo != null) hourRowInfos.Add(hourRowInfo);
                            }

                            var result = new List<Data.DeviceInfo>();

                            // Create DeviceInfo object for each HourRowInfo
                            foreach (var hourRowInfo in hourRowInfos)
                            {
                                Data.DeviceInfo deviceInfo = null;
                                deviceInfo = result.Find(o => o.UniqueId == hourRowInfo.UniqueId);
                                if (deviceInfo == null)
                                {
                                    deviceInfo = new Data.DeviceInfo();
                                    deviceInfo.UniqueId = hourRowInfo.UniqueId;
                                    result.Add(deviceInfo);
                                }

                                deviceInfo.AddHourInfo(hourRowInfo.HourInfo);
                            }

                            Logger.Log("Local Data Server : Backup Loaded Successfully");

                            return result;
                        }

                        Connection.Close(connection);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log("Local Data Server : Error Loading Backup :: " + ex.Message);
                }
            }
            else Logger.Log("Local Server Backup File Not Found @ " + config.SQliteDatabasePath);

            return null;
        }
Example #3
0
        private void UpdateDeviceData(string uniqueId, Data.TimersInfo info)
        {
            var deviceInfo = cachedDevicesInfos.Find(o => o.UniqueId == uniqueId);
            if (deviceInfo == null)
            {
                deviceInfo = new Data.DeviceInfo();
                deviceInfo.UniqueId = uniqueId;
                cachedDevicesInfos.Add(deviceInfo);
            }

            deviceInfo.Timers = info;
        }
Example #4
0
        public void Initialize(DeviceConfiguration config)
        {
            configuration = config;

            deviceInfo = new Data.DeviceInfo();
            deviceInfo.UniqueId = config.UniqueId;
            deviceInfo.Enabled = config.Enabled;
            deviceInfo.Index = config.Index;
        }