public static void Initialize(SimpleApiDBContext context) { context.Database.EnsureCreated(); if (context.DataItems.Any()) { return; // Database has been populated. } // populate the database Models.DataItem[] dataItems = new Models.DataItem[] { new Models.DataItem() { Id = "FirstItem", Value = "This is an item added by the Database initialization." } }; foreach (Models.DataItem dataItem in dataItems) { context.DataItems.Add(dataItem); } context.SaveChanges(); }
public string Get(string longitude, string latitude) { var modelRequest = new Models.DataItem() { longitude = longitude, latitude = latitude }; //List<Models.DataStream> lDataStream = new List<Models.DataStream>(); //lDataStream.Add(new Models.DataStream { id = "longitude", current_value = longitude }); //lDataStream.Add(new Models.DataStream { id = "latitude", current_value = latitude }); //Models.SensorRequest sRequest = new Models.SensorRequest() { // datastreams = lDataStream //}; Models.Location loc = new Models.Location() { disposition = "mobile", name = "device #1", exposure = "outdoor", domain = "physical", ele = "100", lat = float.Parse(latitude), lon = float.Parse(longitude) }; Models.SensorRequest sRequest = new Models.SensorRequest() { location = loc }; var strJsonContent = JsonConvert.SerializeObject(sRequest, Formatting.Indented, new JsonSerializerSettings { }); var request = new RestRequest(requestRoute, Method.PUT); request.AddHeader("X-ApiKey", apiKey); request.AddParameter("application/json", strJsonContent, ParameterType.RequestBody); var result = restClient.Execute <object>(request); return(result.StatusCode.ToString()); }
public MainPageViewModel() { string up = ""; string down = ""; var random = new Random((int)DateTime.Now.Ticks); foreach (var item in Enumerable.Range(1, 20)) { var val = random.Next(-10, 10); var data = new Models.DataItem { Value1 = $"Product name {1}", Value2 = random.Next(10, 55).ToString("C2"), Value3 = (val * .01).ToString("C2"), Arrow = val > 0 ? up : down, Value4 = (random.Next(-10, 10) * .01).ToString("P"), Value5 = DateTime.Now.AddDays(random.Next(10, 1000)).ToString("dd MMM yyyy"), Value6 = "Template 10", }; Items.Add(data); } }
private void DataProvider_OnReceiveData(double data, DateTime time) { var item = new Models.DataItem(time.Ticks / TimeSpan.TicksPerMillisecond, data); AddItem(item); }