Пример #1
0
 public Station GetStationInfoWithMatrix(StationOptions stationOptions)
 {
     try
     {
         Station station = new Station(stationOptions);
         return(station);
     }
     catch (Exception ex)
     {
         WebCommon.LogExceptionInfo(new Exception(string.Format("An error occurred while trying to load info for StationId: {0}", stationOptions.stationId), ex));
         throw new Exception("An error occurred while trying to load the Station info.");
     }
 }
Пример #2
0
        public async Task <bool> UpdateDeviceOptions(StationOptions opt)
        {
            try
            {
                var json           = new JavaScriptSerializer().Serialize(opt);
                var commandMessage = new Message(Encoding.ASCII.GetBytes(json));
                await client.SendAsync("sensor_hub", commandMessage);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(await Task.FromResult(false));
            }

            return(await Task.FromResult(true));
        }
Пример #3
0
        public async Task <ActionResult> UpdateConfigSetting(StationOptions opt)
        {
            if (opt == null)
            {
                return(Json(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Not a valid option")));
            }
            else
            {
                bool succ = await restController.UpdateDeviceConfigSettings(opt);

                bool succIot = await messageController.UpdateDeviceOptions(opt);

                if (succ)
                {
                    return(Json(new HttpStatusCodeResult(HttpStatusCode.Accepted, "Success Updating")));
                }
                else
                {
                    return(Json(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "Failure to contact server")));
                }
            }
        }
Пример #4
0
        public async Task <ActionResult> GetConfigSetForStation(String statName)
        {
            StationOptions opt = await restController.GetConfigSetting(statName);

            return(Json(opt, JsonRequestBehavior.AllowGet));
        }