Example #1
0
        public IHttpActionResult Post([FromBody] string request)
        {
            try
            {
                logger.Info("request: " + request);

                var     jss  = new JavaScriptSerializer();
                dynamic data = jss.Deserialize <dynamic>(request);

                temp_fan temp = JsonConvert.DeserializeObject <temp_fan>(request);
                // data["GMT"] = "yyyy-MM-dd hh:mm:ss.ffffff offset"
                var dtCreated = (string)data["GMT"];
                logger.Debug("PiPlateController.Post dtCreated = " + dtCreated);
                int idx = dtCreated.IndexOf('.');
                dtCreated = dtCreated.Substring(0, idx);
                logger.Debug("PiPlateController.Post dtCreated SHORT = " + dtCreated);
                //temp.dt_created = DateTime.ParseExact(dtCreated, "yyyy-MM-dd hh:mm:ss", CultureInfo.InvariantCulture);
                temp.dt_created = DateTime.Parse(dtCreated);
                using (var context = new db_Entities())
                {
                    context.Entry(temp).State = EntityState.Added;
                    context.SaveChanges();
                }

                logger.Info(request);
            }
            catch (Exception ex)
            {
                logger.Info("exception: " + ex.ToString());
            }

            return(Ok(request));
        }
Example #2
0
 public temp_fan(temp_fan tempFan)
 {
     id         = tempFan.id;
     temp_1     = tempFan.temp_1;
     temp_2     = tempFan.temp_2;
     temp_3     = tempFan.temp_3;
     fan_on     = tempFan.fan_on;
     charger_on = tempFan.charger_on;
     voltage    = tempFan.voltage;
     dt_created = tempFan.dt_created;
 }