示例#1
0
        public static int GetQueryNumbersFromBlob(string Date, string scenarioName, out int avgTime, CloudStorageAccount storageAccount, string containerName)
        {
            Dictionary <string, string> dict           = ReportHelpers.GetDictFromBlob(storageAccount, "IISRequestDetails" + Date + ".json", containerName);
            List <IISRequestDetails>    requestDetails = new List <IISRequestDetails>();
            int totalRequestNumber = 0;

            avgTime = 0;
            int count = 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 == scenarioName)
                        {
                            totalRequestNumber += detail.RequestsPerHour;
                            avgTime            += detail.AvgTimeTakenInMilliSeconds;
                            count++;
                        }
                    }
                }
            }
            if (count > 1)
            {
                avgTime = Convert.ToInt32(avgTime / count);
            }
            return(totalRequestNumber);
        }
示例#2
0
        public static string CreateTableForIISRequestsDistribution(CloudStorageAccount storageAccount, string containerName, List <string> datesInWeek)
        {
            StringBuilder sb           = new StringBuilder();
            string        fontOpenTag  = @"<b><span style='font-size:11.0pt;font-family:'Calibri','sans-serif';color:windowtext'>";
            string        fontCloseTag = @"</span></b>";
            string        cellOpenTag1 = @"<td width=200 valign=top style='width:200pt;border:solid #8EAADB 1.0pt;border-bottom:solid #8EAADB 1.5pt;padding:0in 5.4pt 0in 5.4pt'>";
            string        cellOpenTag2 = @"<td width=175 valign=top style='width:175pt;border:solid #8EAADB 1.0pt;border-bottom:solid #8EAADB 1.5pt;padding:0in 5.4pt 0in 5.4pt'>";

            sb.Append(@"<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 style='border-collapse:collapse'>");
            sb.Append(@"<tr>" + cellOpenTag1 + fontOpenTag + "Scenario Name" + fontCloseTag + "</td>");
            sb.Append(cellOpenTag2 + fontOpenTag + "# of Requests" + fontCloseTag + "</td>");
            sb.Append(cellOpenTag2 + fontOpenTag + "Avg Time Taken in ms" + fontCloseTag + "</td></tr>");

            var content = ReportHelpers.Load(storageAccount, "Configration.IISRequestStems.json", containerName);
            List <IISRequestDetails> UriStems = new List <IISRequestDetails>();

            UriStems = new JavaScriptSerializer().Deserialize <List <IISRequestDetails> >(content);
            foreach (IISRequestDetails stem in UriStems)
            {
                int avgTime      = 0;
                int requestCount = ReportHelpers.GetQueryNumbers(stem.ScenarioName, out avgTime, datesInWeek, storageAccount, containerName);

                sb.Append(@"<tr>" + cellOpenTag1);
                sb.Append(stem.ScenarioName);
                sb.Append(@"</td>" + cellOpenTag2);
                sb.Append(Convert.ToInt64(requestCount).ToString("#,##0"));
                sb.Append(@"</td>" + cellOpenTag2);
                sb.Append(Convert.ToInt64(avgTime).ToString("#,##0"));
                sb.Append("</td></tr>");
            }
            sb.Append("</table>");
            return(sb.ToString());
        }
示例#3
0
        /// <summary>
        /// Gets the JSON data from the blob. The blobs are pre-created as key value pairs using Ops tasks.
        /// </summary>
        /// <param name="blobName"></param>
        /// <param name="xValues"></param>
        /// <param name="yValues"></param>
        public static void AppendDatatoBlob(CloudStorageAccount account, string blobName, Tuple <string, string> tuple, int bufferCount, string containerName = "dashboard")
        {
            List <Tuple <string, string> > dict = new List <Tuple <string, string> >();

            try
            {
                if (ReportHelpers.IffBlobExists(account, blobName, containerName))
                {
                    string json = Load(account, blobName, containerName);
                    if (!string.IsNullOrEmpty(json))
                    {
                        JArray array = JArray.Parse(json);
                        foreach (JObject item in array)
                        {
                            dict.Add(new Tuple <string, string>(item["key"].ToString(), item["value"].ToString()));
                        }
                    }
                }
            }catch (StorageException e)
            {
                Console.WriteLine(string.Format("Exception thrown while trying to load blob {0}. Exception : {1}", blobName, e.Message));
            }


            dict.Add(tuple);
            if (dict.Count > bufferCount)
            {
                dict.RemoveRange(0, dict.Count - bufferCount);
            }

            JArray reportObject = ReportHelpers.GetJson(dict);

            ReportHelpers.CreateBlob(account, blobName, containerName, "application/json", ReportHelpers.ToStream(reportObject));
        }
示例#4
0
        public static string CreateTableForResponseTime(CloudStorageAccount storageAccount, string containerName, DateTime date)
        {
            StringBuilder sb           = new StringBuilder();
            string        fontOpenTag  = @"<b><span style='font-size:11.0pt;font-family:'Calibri','sans-serif';color:windowtext'>";
            string        fontCloseTag = @"</span></b>";
            string        cellOpenTag1 = @"<td width=200 valign=top style='width:200pt;border:solid #8EAADB 1.0pt;border-bottom:solid #8EAADB 1.5pt;padding:0in 5.4pt 0in 5.4pt'>";
            string        cellOpenTag2 = @"<td width=175 valign=top style='width:175pt;border:solid #8EAADB 1.0pt;border-bottom:solid #8EAADB 1.5pt;padding:0in 5.4pt 0in 5.4pt'>";

            sb.Append(@"<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 style='border-collapse:collapse'>");
            sb.Append(@"<tr>" + cellOpenTag1 + fontOpenTag + "Uri Stem" + fontCloseTag + "</td>");
            sb.Append(cellOpenTag2 + fontOpenTag + "Avg Time Taken in ms" + fontCloseTag + "</td></tr>");

            string blobName = "IISResponseTimeDetails" + string.Format("{0:yyMMdd}", date.AddDays(-1)) + ".json";

            Dictionary <string, string> dict           = ReportHelpers.GetDictFromBlob(storageAccount, blobName, containerName);
            IISResponseTimeDetails      requestDetails = new IISResponseTimeDetails();

            if (dict != null)
            {
                foreach (KeyValuePair <string, string> keyValuePair in dict)
                {
                    requestDetails = new JavaScriptSerializer().Deserialize <IISResponseTimeDetails>(keyValuePair.Value);

                    sb.Append(@"<tr>" + cellOpenTag1);
                    sb.Append(requestDetails.UriStem);
                    sb.Append(@"</td>" + cellOpenTag2);
                    sb.Append(Convert.ToInt64(requestDetails.AvgTimeTakenInMilliSeconds).ToString("#,##0"));
                    sb.Append("</td></tr>");
                }
            }
            sb.Append("</table>");
            return(sb.ToString());
        }
示例#5
0
        /// <summary>
        /// Given a list of blob names, this function returns a list of key values and another list of aggregated values for those keys
        /// For example, combined install, install-dependency counts for 2.4
        /// </summary>
        /// <param name="blobNames">List of blob names</param>
        /// <param name="storageAccount">Storage Account to be used</param>
        /// <param name="containerName">Container that has the blobs</param>
        /// <param name="xValues">List of keys</param>
        /// <param name="yValues">List of values</param>
        public static void GetValuesFromBlobs(string[] blobNames, CloudStorageAccount storageAccount, string containerName, out List <string> xValues, out List <Object> yValues)
        {
            xValues = new List <string>();
            yValues = new List <Object>();
            Dictionary <string, object> combinedValues = new Dictionary <string, object>();

            foreach (string blobName in blobNames)
            {
                string json = ReportHelpers.Load(storageAccount, blobName, containerName);
                if (json == null)
                {
                    return;
                }

                JArray array = JArray.Parse(json);
                foreach (JObject item in array)
                {
                    string currentKey   = item["key"].ToString();
                    object currentValue = item["value"];

                    if (!combinedValues.ContainsKey(currentKey))
                    {
                        combinedValues.Add(currentKey, currentValue);
                    }
                    else
                    {
                        combinedValues[currentKey] = Convert.ToInt64(currentValue) + Convert.ToInt64(combinedValues[currentKey]);
                    }
                }
            }

            foreach (var item in combinedValues)
            {
                xValues.Add(item.Key);
                yValues.Add(item.Value);
            }
        }