示例#1
0
        private async Task RegisterSOSAlert(bool force, SOSAlert alert)
        {
            try
            {
                await _reachClient.CheckAuthorization(force);

                var stringContent = new StringContent(JsonConvert.SerializeObject(alert), Encoding.UTF8, "application/json");
                var response      = await _reachClient.HttpClient.PostAsync(string.Format("{0}/v2.0/sos/global/alerts", _reachClient._serviceUrl), stringContent);

                if (!response.IsSuccessStatusCode)
                {
                    throw await _reachClient.ProcessUnsuccessResponseMessage(response);
                }
            }
            catch (ReachClientException ex)
            {
                if (ex.ErrorCode == ReachExceptionCodes.AuthTokenExpired)
                {
                    await RegisterSOSAlert(true, alert);
                }
                throw;
            }
            catch (Exception)
            {
                throw new ReachClientException {
                          ErrorCode = ReachExceptionCodes.ClientUnknown
                };
            }
        }
示例#2
0
 public async Task RegisterSOSAlert(SOSAlert alert)
 {
     await RegisterSOSAlert(false, alert);
 }