Пример #1
0
        // timepoint selection changed
        private void tlc1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count > 0)
            {
                _selectedmte = e.AddedItems[0] as MetricsTransactionsEntity;
                var dict = ConvertView(_selectedmte);

                // disable pie chart
                //ps1.ItemsSource = dict.Where(kp => kp.Key.StartsWith("Percent")); ;
                //chart2.Title = _selectedmte.Time.ToString();

                metrics_tb.Text = string.Format("{0}({4}hour) {1} Metrics ({2};{3})",
                                                _selectedmte.Time, _currentstoragetype, access_cb.SelectedValue, trans_cb.SelectedValue, _selectedmte.TimeSpan.TotalHours);

                string propsstr = "";
                foreach (var kp in dict)
                {
                    propsstr += (kp.Key + ": " + kp.Value + "\n");
                }
                m1tb.Text = propsstr;
            }
            else
            {
                metrics_tb.Text = "";
                m1tb.Text       = "";
            }
        }
Пример #2
0
        Dictionary <string, object> ConvertView(MetricsTransactionsEntity mte)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();
            Type mtet = typeof(MetricsTransactionsEntity);

            foreach (var prop in mtet.GetProperties())
            {
                //if(prop.Name.StartsWith("Percent"))
                dict.Add(prop.Name, prop.GetValue(mte, null));
            }
            return(dict);
        }
Пример #3
0
        void ls_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            _selectedmte = e.AddedItems[0] as MetricsTransactionsEntity;
            var dict = ConvertView(_selectedmte);

            ps1.ItemsSource = dict.Where(kp => kp.Key.StartsWith("Percent"));
            chart2.Title    = _selectedmte.Time.ToString();

            string propsstr = "";

            foreach (var kp in dict)
            {
                propsstr += (kp.Key + ": " + kp.Value + "\n");
            }
            m1tb.Text = propsstr;
        }
Пример #4
0
        List <MetricsTransactionsEntity> CompressDataPoints(List <MetricsTransactionsEntity> orilist)
        {
            int datapointnum = int.Parse(ConfigurationManager.AppSettings["datapointsnumber"]);
            List <MetricsTransactionsEntity> retlist = new List <MetricsTransactionsEntity>();

            if (orilist.Count == 0)
            {
                return(retlist);
            }

            double stepf = orilist.Count / datapointnum;

            if (stepf >= 2)
            {
                int step = (int)stepf;
                MetricsTransactionsEntity tmpmte = null;
                for (int i = 0; i < orilist.Count; i++)
                {
                    if (i % step == 0)
                    {
                        if (tmpmte != null)
                        {
                            retlist.Add(tmpmte);
                        }
                        tmpmte = orilist[i];
                    }
                    else
                    {
                        tmpmte = tmpmte.Merge(orilist[i]);
                    }
                }
                retlist.Add(tmpmte);
                return(retlist);
            }
            else
            {
                return(orilist);
            }
        }
Пример #5
0
        List <MetricsTransactionsEntity> LoadMetricsFromFile2(string filepath, out string error)
        {
            try
            {
                error = null;
                var MTEstr   = File.ReadAllText(filepath);
                var MTElines = MTEstr.Split('\n');

                var list       = new List <MetricsTransactionsEntity>();
                int errorcount = 0;
                for (int i = 1; i < MTElines.Length; i++)
                {
                    try
                    {
                        var line2 = MTElines[i].Trim('\r');
                        var cols  = line2.Split(',');
                        var item  = new MetricsTransactionsEntity
                        {
                            PartitionKey = cols[0],
                            RowKey       = cols[1],
                            AnonymousAuthorizationError = long.Parse(cols[2]),
                            AnonymousClientOtherError   = long.Parse(cols[3]),
                            AnonymousClientTimeoutError = long.Parse(cols[4]),
                            AnonymousNetworkError       = long.Parse(cols[5]),
                            AnonymousServerOtherError   = long.Parse(cols[6]),
                            AnonymousServerTimeoutError = long.Parse(cols[7]),
                            AnonymousSuccess            = long.Parse(cols[8]),
                            AnonymousThrottlingError    = long.Parse(cols[9]),
                            AuthorizationError          = long.Parse(cols[10]),
                            Availability              = double.Parse(cols[11]),
                            AverageE2ELatency         = double.Parse(cols[12]),
                            AverageServerLatency      = double.Parse(cols[13]),
                            ClientOtherError          = long.Parse(cols[14]),
                            ClientTimeoutError        = long.Parse(cols[15]),
                            NetworkError              = long.Parse(cols[16]),
                            PercentAuthorizationError = double.Parse(cols[17]),
                            PercentClientOtherError   = double.Parse(cols[18]),
                            PercentNetworkError       = double.Parse(cols[19]),
                            PercentServerOtherError   = double.Parse(cols[20]),
                            PercentSuccess            = double.Parse(cols[21]),
                            PercentThrottlingError    = double.Parse(cols[22]),
                            PercentTimeoutError       = double.Parse(cols[23]),
                            SASAuthorizationError     = long.Parse(cols[24]),
                            SASClientOtherError       = long.Parse(cols[25]),
                            SASClientTimeoutError     = long.Parse(cols[26]),
                            SASNetworkError           = long.Parse(cols[27]),
                            SASServerOtherError       = long.Parse(cols[28]),
                            SASServerTimeoutError     = long.Parse(cols[29]),
                            SASSuccess         = long.Parse(cols[30]),
                            SASThrottlingError = long.Parse(cols[31]),
                            ServerOtherError   = long.Parse(cols[32]),
                            ServerTimeoutError = long.Parse(cols[33]),
                            Success            = long.Parse(cols[34]),
                            ThrottlingError    = long.Parse(cols[35]),
                            //Time =DateTime.Parse(cols[36]),
                            Timestamp             = DateTime.Parse(cols[37]),
                            TotalBillableRequests = long.Parse(cols[38]),
                            TotalEgress           = long.Parse(cols[39]),
                            TotalIngress          = long.Parse(cols[40]),
                            TotalRequests         = long.Parse(cols[41])
                        };
                        list.Add(item);
                    }
                    catch (Exception ex)
                    {
                        errorcount++;
                        error = "Error occured when parsing some metric row. Affected rows:" + errorcount;
                    }
                }

                return(list);
            }
            catch (Exception ex)
            {
                error = "Error occured when loading metrics file.";
                return(null);
            }
        }
Пример #6
0
        List <MetricsTransactionsEntity> LoadMetricsFromFile(string filepath, out string error)
        {
            var list = new List <MetricsTransactionsEntity>();

            try
            {
                int errorcount = 0;
                error = null;

                var MTEstr   = File.ReadAllText(filepath);
                var MTElines = MTEstr.Split('\n');

                var titleline = MTElines[0].Trim('\r');
                var titles    = titleline.Split(',');

                int rowKeyIndex = -1;
                // remove " and find RowKey index
                for (int i = 0; i < titles.Length; i++)
                {
                    titles[i] = titles[i].Trim('\"');
                    if (titles[i] == "RowKey")
                    {
                        rowKeyIndex = i;
                    }
                }

                for (int i = 1; i < MTElines.Length; i++)
                {
                    try
                    {
                        var line = MTElines[i].Trim('\r');
                        if (string.IsNullOrEmpty(line))
                        {
                            continue;
                        }

                        // remove "
                        var fields = line.Split(',');
                        for (int j = 0; j < fields.Length; j++)
                        {
                            fields[j] = fields[j].Trim('\"');
                        }

                        if (titles[rowKeyIndex].Equals("RowKey") &&
                            !fields[rowKeyIndex].Equals("user;All"))
                        {
                            continue;
                        }

                        var newitem = new MetricsTransactionsEntity();
                        var type    = newitem.GetType();
                        for (int j = 0; j < titles.Length; j++)
                        {
                            PropertyInfo prop = null;

                            prop = type.GetProperty(titles[j], BindingFlags.Public | BindingFlags.Instance);
                            if (prop == null || prop.Name == "Time")
                            {
                                continue;
                            }

                            var    proptype = prop.PropertyType;
                            object value    = fields[j];
                            if (proptype != typeof(string))
                            {
                                var methods = proptype.GetMethods(BindingFlags.Static | BindingFlags.Public);
                                var method  = proptype.GetMethod("Parse",
                                                                 new Type[] { typeof(string) });
                                value = method.Invoke(null, new object[] { value });
                            }
                            prop.SetValue(newitem, value, null);
                        }
                        list.Add(newitem);
                    }
                    catch
                    {
                        errorcount++;
                        error = "Error occured when parsing some metric row. Affected rows:" + errorcount;
                    }
                }

                return(list);
            }
            catch (Exception ex)
            {
                error = "Error occured: " + ex.Message;
                return(list);
            }
        }