예제 #1
0
 /// <summary>
 /// Retrieves the data.json file contents from the service health dashboard
 /// </summary>
 /// <returns></returns>
 private async Task <IEnumerable <DashboardEventRaw> > GetDashboardEventDataFromS3(string bucket, string key)
 {
     try
     {
         using (GetObjectResponse data = await s3Client.GetObjectAsync(new GetObjectRequest()
         {
             BucketName = bucket,
             Key = key
         }))
         {
             using (Stream stream = data.ResponseStream)
             {
                 using (StreamReader reader = new StreamReader(stream))
                 {
                     try
                     {
                         string             content    = reader.ReadToEnd();
                         DashboardEventData parsedData = JsonConvert.DeserializeObject <DashboardEventData>(content);
                         return(parsedData.Archive); // .Concat(parsedData.Current) -> don't want to do this since current events may not have a finish time
                     }
                     catch (Exception e)
                     {
                         this._context.LogError($"Failed to deserialize retrieved Service Health Dashboard data.", e);
                         return(null);
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         this._context.LogError($"Failed to retrieve data file from s3://{bucket}/{key}", e);
         return(null);
     }
 }
예제 #2
0
        /// <summary>
        /// Retrieves the data.json file contents from the service health dashboard
        /// </summary>
        /// <returns></returns>
        private async Task <IEnumerable <DashboardEventRaw> > GetDashboardEventDataFromSource(string source)
        {
            try
            {
                string data = await httpClient.GetStringAsync(source);

                try
                {
                    DashboardEventData parsedData = JsonConvert.DeserializeObject <DashboardEventData>(data);
                    return(parsedData.Archive); // .Concat(parsedData.Current) -> don't want to do this since current events may not have a finish time
                }
                catch (Exception e)
                {
                    this._context.LogError($"Failed to deserialize retrieved Service Health Dashboard data.", e);
                    return(null);
                }
            }
            catch (Exception e)
            {
                this._context.LogError($"Failed to retrieve data file from {source}", e);
                return(null);
            }
        }