public async Task <bool> PutBinary(string endPoint, byte[] requestBody) { try { //Task.Delay(1 * 1000); string url = UrlConfig.GetFullURL(Endpoint.upload, Endpoint_Method.POST); InitializeHttpClient(); var requestContent = new StreamContent(new MemoryStream(requestBody)); HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, url); httpRequestMessage.Content = requestContent; System.Diagnostics.Debug.WriteLine("Service call Put url : " + url); System.Diagnostics.Debug.WriteLine("Service call Put requestBody : " + requestBody); var httpResponse = await httpClient.SendAsync(httpRequestMessage); System.Diagnostics.Debug.WriteLine("Service call Put response: " + httpResponse); if (httpResponse.IsSuccessStatusCode) { return(true); } else { return(false); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); return(false); } }
public async Task <string> SetScheduler(string schedule) { try { var res = await GetWsData(UrlConfig.GetFullURL(Endpoint.scheduler, Endpoint_Method.POST), schedule); return(res); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); } return(null); }
public async Task <bool> SetDeviceConfig(Config config) { try { string jsonIgnoreNullValues = JsonConvert.SerializeObject(config, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); var result = await SetWsData(UrlConfig.GetFullURL(Endpoint.config, Endpoint_Method.POST), jsonIgnoreNullValues); return(result); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); } return(true); }
public async Task <string> GetScheduler(DeviceInfoRequest deviceInfoRequest) { try { string jsonIgnoreNullValues = JsonConvert.SerializeObject(deviceInfoRequest, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); var _schedule = await GetWsData(UrlConfig.GetFullURL(Endpoint.scheduler, Endpoint_Method.GET), jsonIgnoreNullValues, ErrorCode.SCHEDULE_GET); return(_schedule); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); } return(string.Empty); }
public async Task <string> GetHealthCheck(HeartBeat _heartBeat) { try { if (_heartBeat != null) { string jsonIgnoreNullValues = JsonConvert.SerializeObject(_heartBeat, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); var info = await GetWsData(UrlConfig.GetFullURL(Endpoint.info, Endpoint_Method.GET, isNewFW: true), jsonIgnoreNullValues); return(info); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); } return(string.Empty); }
public async Task <string> GetDeviceSnapShotInfo(DeviceInfoRequest deviceInfoRequest) { try { if (deviceInfoRequest != null) { string jsonIgnoreNullValues = JsonConvert.SerializeObject(deviceInfoRequest, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); var info = await GetWsData(UrlConfig.GetFullURL(Endpoint.snapshot, Endpoint_Method.GET), jsonIgnoreNullValues); return(info); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); } return(string.Empty); }