private List <Tuple <string, string, double> > GetScenarioValuesFromBlob(string blobName, string containerName, int startTime, int endTime)
        {
            Dictionary <string, string> dict           = ReportHelpers.GetDictFromBlob(StorageAccount, blobName, containerName);
            List <IISRequestDetails>    requestDetails = new List <IISRequestDetails>();

            foreach (KeyValuePair <string, string> keyValuePair in dict)
            {
                int key = Convert.ToInt32(keyValuePair.Key.Replace(":", "").Replace("-", ""));

                if ((key >= startTime) && (key <= endTime))
                {
                    requestDetails.AddRange(new JavaScriptSerializer().Deserialize <List <IISRequestDetails> >(keyValuePair.Value));
                }
            }

            var requestGroups = requestDetails.GroupBy(item => item.ScenarioName);
            List <Tuple <string, string, double> > scenarios = new List <Tuple <string, string, double> >();

            foreach (IGrouping <string, IISRequestDetails> group in requestGroups)
            {
                if (group.Key.Contains("Over all requests"))
                {
                    LoadTestRequestPerHour = Convert.ToInt32((group.Average(item => item.RequestsPerHour)));
                    continue;
                }
                scenarios.Add(new Tuple <string, string, double>(group.Key, Convert.ToInt32((group.Average(item => item.RequestsPerHour) / LoadTestRequestPerHour) * 100) + "%", group.Average(item => item.AvgTimeTakenInMilliSeconds)));
            }
            return(scenarios);
        }
        private List <int> GetMetricValuesFromBlob(string blobName, string containerName, int startTime, int endTime)
        {
            Dictionary <string, string> dict = new Dictionary <string, string>();

            try
            {
                dict = ReportHelpers.GetDictFromBlob(StorageAccount, blobName, containerName);
            }
            catch (Exception) { }
            List <int> values = new List <int>();

            if (dict != null)
            {
                foreach (KeyValuePair <string, string> keyValuePair in dict)
                {
                    int key = Convert.ToInt32(keyValuePair.Key.Replace(":", "").Replace("-", ""));

                    if ((key >= startTime) && (key <= endTime))
                    {
                        values.Add(Convert.ToInt32(keyValuePair.Value));
                    }
                }
            }
            return(values);
        }
        private int GetDownloadNumbersFromBlob(string blobName)
        {
            Dictionary <string, string> dict = ReportHelpers.GetDictFromBlob(StorageAccount, blobName, ContainerName);
            List <int> values = new List <int>();

            foreach (KeyValuePair <string, string> keyValuePair in dict)
            {
                values.Add(Convert.ToInt32(keyValuePair.Value));
            }
            return(values.Sum());
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Returns the instance count in Gallery cloud service for the last hour.
 /// </summary>
 /// <returns></returns>
 private int GetCurrentInstanceCountInGallery()
 {
     try
     {
         Dictionary <string, string> instanceCountDict = ReportHelpers.GetDictFromBlob(StorageAccount, ServiceName + "InstanceCount" + string.Format("{0:MMdd}", DateTime.Now) + "HourlyReport.json", ContainerName);
         if (instanceCountDict != null && instanceCountDict.Count > 0)
         {
             return(Convert.ToInt32(instanceCountDict.Values.ElementAt(instanceCountDict.Count - 1)));
         }
         else
         {
             return(3); //default instance count in Gallery
         }
     }catch
     {
         return(3); //return 3 by default as we don't want to fail if the expected blob is not present.
     }
 }
        private int GetSearchQueryNumbersFromBlob()
        {
            Dictionary <string, string> dict           = ReportHelpers.GetDictFromBlob(StorageAccount, "IISRequestDetails" + Date + ".json", ContainerName);
            List <IISRequestDetails>    requestDetails = new List <IISRequestDetails>();
            int totalSearchRequestNumber = 0;

            if (dict != null)
            {
                foreach (KeyValuePair <string, string> keyValuePair in dict)
                {
                    requestDetails = new JavaScriptSerializer().Deserialize <List <IISRequestDetails> >(keyValuePair.Value);
                    foreach (IISRequestDetails detail in requestDetails)
                    {
                        if (detail.ScenarioName == "Search")
                        {
                            totalSearchRequestNumber += detail.RequestsPerHour;
                        }
                    }
                }
            }
            return(totalSearchRequestNumber);
        }