public Form1() { InitializeComponent(); lbase = LocalBase.getInstance(); lbase.Init("subscribers"); }
public void Send(string code, long timestamp, Dictionary <Enums.MeasureType, double> measurements, string codeAgr) { if (code.Length != 4 || codeAgr.Length != 4) { throw new ArgumentException("Invalid code"); } try{ int.Parse(code); int.Parse(codeAgr); } catch { throw new ArgumentOutOfRangeException("It must be number."); } if (measurements.Count <= 0) { try { } catch (Exception e) { throw new ArgumentException("Dictionary is empty."); } } if (timestamp < 1528236934 || timestamp > 1546300800) { throw new ArgumentOutOfRangeException("Timestamp is out of range."); } using (var data = new LocalBaseDBContex()) { LocalBase lb = new LocalBase() { AgregatorCode = codeAgr, DeviceCode = code, TimeStamp = (Datas.UnixTimeToDateTime(timestamp)).ToString(), Voltage = measurements[MeasureType.voltage], Eletricity = measurements[MeasureType.electricity], ActivePower = measurements[MeasureType.activePower], ReactivePower = measurements[MeasureType.reactivePower] }; data.LocalBaseData.Add(lb); data.SaveChanges(); } Console.WriteLine("Message from [{0}] added in LocalDataBase at {1}.", code, Datas.UnixTimeToDateTime(timestamp)); }
public Rostelecom() { lBase = LocalBase.getInstance(); }
public void RemoveListener(LocalBase local) { baseSet.Remove(local); }
public void AddListener(LocalBase local) { baseSet.Add(local); }