private bool PullDataParkingOut() { string APIPullData = Properties.Resources.RequestVehicleTypeAPIURL; DataResponseArray receivedData = (DataResponseArray)restApi.get(this.ip_address_server, APIPullData); if (receivedData != null) { switch (receivedData.Status) { case 206: JArray receivedVehicleTypes = receivedData.Data; JObject vehicleTypes = new JObject(); vehicleTypes.Add(new JProperty("VehicleTypes", receivedVehicleTypes)); if (TKHelper.WriteDataIntoJSONFile(vehicleTypes, Constant.DIR_PATH_SOURCE, Constant.PATH_FILE_MASTER_DATA_PARKING_OUT)) { return(true); } else { notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", Constant.ERROR_MESSAGE_FAIL_TO_WRITE_MASTER_DATA_FILE, ToolTipIcon.Error); return(false); } default: notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", receivedData.Message, ToolTipIcon.Error); return(false); } } else { notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", Constant.ERROR_MESSAGE_FAIL_TO_CONNECT_SERVER, ToolTipIcon.Error); return(false); } }
private bool PullDataParkingIn() { string APIPullData = Properties.Resources.RequestDataParkingPedestrianAPIURL; DataResponseObject response = (DataResponseObject)restApi.get(ip_address_server, APIPullData, true); if (response != null) { if (response.Status == 206) { ParkingInPedestrian parkingInPedestrian = JsonConvert.DeserializeObject <ParkingInPedestrian>(response.Data.ToString()); if (TKHelper.WriteDataIntoJSONFile(parkingInPedestrian, Constant.DIR_PATH_SOURCE, Constant.PATH_FILE_MASTER_DATA_PARKING_IN)) { return(true); } else { notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", Constant.ERROR_MESSAGE_FAIL_TO_WRITE_MASTER_DATA_FILE, ToolTipIcon.Error); return(false); } } else { notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", response.Message, ToolTipIcon.Error); return(false); } } else { notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", Constant.ERROR_MESSAGE_FAIL_TO_CONNECT_SERVER, ToolTipIcon.Error); return(false); } }