Esempio n. 1
0
 public static void Savelog(string fileName, CLog log, CView View, List<XmlNode> trash)
 {
     XmlDocument doc;
     save_xml_from_class(out doc, log, View, trash);
     doc.Save(fileName);
     doc = null;
 }
Esempio n. 2
0
        void NewFilterPage_AddingView(CView View)
        {
            string s = null;
            ViewListGrid.RowDefinitions.Add(new RowDefinition());
            ViewListGrid.RowDefinitions[0].Height = new GridLength(40);
            ViewButton ButtonView = new ViewButton(View);
            string Header = s != null ? s : View.Name + "_Copy";//\nОбновлено в " + ButtonView.UpdateTime.ToShortTimeString();

            if ((ViewListGrid.Children.Cast<ViewButton>()).FirstOrDefault(x => x.View.Name == Header) != null)
            {
                int i = 1;
                for (; ((ViewListGrid.Children.Cast<ViewButton>()).FirstOrDefault(x => x.View.Name == Header + "_" + i) != null); i++) ;
                ButtonView.View.Name = Header + "_" + i;
            }
            else
                ButtonView.View.Name = Header;
            ButtonView.Height = 40;
            ButtonView.Content = ButtonView.View.Name + "\nОбновлено в " + ButtonView.UpdateTime.ToShortTimeString();
            ButtonView.Margin = new Thickness(0);
            ButtonView.Click += ChangeView;
            ViewListGrid.Margin = new Thickness(0);
            ViewListGrid.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            Grid.SetRow(ButtonView, ViewListGrid.RowDefinitions.Count - 1);
            ViewListGrid.Children.Add(ButtonView);
        }
Esempio n. 3
0
 private void DeleteSelectedView(object sender, RoutedEventArgs e)
 {
     int index = ((ViewListGrid.Children.Cast<ViewButton>()).ToList<ViewButton>()).FindIndex(x => x.View == NowView);
     if (index != 0)
     {
         for (int j = index + 1; j < ViewListGrid.RowDefinitions.Count; j++)
             Grid.SetRow(ViewListGrid.Children[j], j - 1);
         ViewListGrid.RowDefinitions.RemoveAt(ViewListGrid.RowDefinitions.Count - 1);
         UIElement[] Collection = new UIElement[ViewListGrid.Children.Count - 1];
         for (int i = 0; i < ViewListGrid.Children.Count - 1; i++)
             if (i < index)
                 Collection[i] = ViewListGrid.Children[i];
             else
                 Collection[i] = ViewListGrid.Children[i + 1];
         ViewListGrid.Children.Clear();
         foreach (var i in Collection)
             if (i != null)
                 ViewListGrid.Children.Add(i);
         NowView = ((ViewButton)(ViewListGrid.Children[0])).View;
         ((ViewButton)(ViewListGrid.Children[0])).Background = Brushes.DarkGray;
         SetTreeView(NowView);
         NewFilterPage.CurrentCView = NowView;
         this.Title = "ELPTWPF - " + NowView.Name;
     }
     else
         MessageBox.Show("Нельзя удалить основное View");
 }
Esempio n. 4
0
        private void ClearMemory_MouseDoubleClick_1(object sender, RoutedEventArgs e)
        {
            // Очистка всего и вся
            ClearLists();
            log = new CLog();
            NowView = new CView(log);
            trash = new List<XmlNode>();

            //Начальная доступность
            FilterTabName.IsEnabled = false;
            ParamsTab.IsEnabled = false;
            _Filters.IsEnabled = false;
            CopyButton.IsEnabled = false;
            DeleteButton.IsEnabled = false;
            VisualizeFromXButton.IsEnabled = false;
            _Save.IsEnabled = false;

            //Установка строки состояния

            Label LoadStatus = new Label();
            LoadStatus.Height = 28;
            LoadStatus.Content = "Лог не загружен";
            StatusBar1.Items.Add(LoadStatus);
            Label LoadNumbers = new Label();
            LoadNumbers.Height = 28;
            LoadNumbers.Visibility = System.Windows.Visibility.Collapsed;
            StatusBar1.Items.Add(LoadNumbers);

            // Очистка памяти
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Esempio n. 5
0
 private void ChangeView(object sender, RoutedEventArgs e)
 {
     ((ViewListGrid.Children.Cast<ViewButton>()).First(x => x.View == NowView)).Background = Color1.Clone();
     NowView = ((ViewButton)sender).View;
     ((ViewButton)sender).Background = Brushes.DarkGray;
     SetTreeView(NowView);
     if (NewFilterPage!=null)
     NewFilterPage.CurrentCView = NowView;
     this.Title = "ELPTWPF - " + NowView.Name;
 }
Esempio n. 6
0
 public static CView operator &(CView view1, CView view2)
 {
     if (!view1.Log.Equals(view2.Log))
         throw new ArgumentException("Данные View представляют различные журналы событий");
     CView result = new CView(view1.Log);
     result.Traces = view1.Traces.Intersect(view2.Traces).ToList<CTrace>();
     return result;
 }
Esempio n. 7
0
 private void VisualizeLog(CView View, int i, int j)
 {
     for (i--; i < j; i++)
     {
         TreeViewItem Case = new TreeViewItem();
         Case.Header = View.Traces[i].Name;
         Case.ToolTip = (i+1).ToString();
         TreeViewItem events = new TreeViewItem();
         Case.Items.Add(events);
         Case.Expanded += Case_Expanded;
         Case.Collapsed += Case_Collapsed;
         Case.Selected += Case_Selected;
         Case.Tag = i;
         treeView1.Items.Add(Case);
     }
     ((Label)StatusBar1.Items[1]).Visibility = System.Windows.Visibility.Visible;
     ((Label)StatusBar1.Items[1]).Content = "Отображены элементы с " + FirstElement + " по " + j;
 }
Esempio n. 8
0
        private static void save_xml_from_class(out XmlDocument doc, CLog log, CView View, List<XmlNode> trash)
        {
            CultureInfo a = new CultureInfo(CultureInfo.CurrentCulture.Name);
            a.NumberFormat.NumberDecimalSeparator = ".";
            doc = new XmlDocument();
            doc.LoadXml("<?xml version=\"1.0\" encoding=\"UTF-8\"?> <log> </log>");
            foreach (XmlNode n in trash)
            {
                XmlNode temp = doc.ImportNode(n, true);
                doc.DocumentElement.AppendChild(temp);
            }
            foreach (CTrace trace in View.Traces)
            {
                XmlNode TraceNode = doc.CreateElement("trace");
                XmlNode NameParam = doc.CreateElement("string");
                XmlAttribute Key = doc.CreateAttribute("key"), Value = doc.CreateAttribute("value");
                Key.Value = "concept:name";
                Value.Value = trace.Name;
                NameParam.Attributes.Append(Key);
                NameParam.Attributes.Append(Value);
                TraceNode.AppendChild(NameParam);
                // Выведение параметров Trace
                #region
                foreach (var i in trace.Text_Parameters)
                {
                    XmlNode TextParam = doc.CreateElement("string");
                    Key = doc.CreateAttribute("key"); Value = doc.CreateAttribute("value");
                    Key.Value = i.Key;
                    Value.Value = i.Value.ToString();
                    TextParam.Attributes.Append(Key);
                    TextParam.Attributes.Append(Value);
                    TraceNode.AppendChild(TextParam);
                }
                foreach (var i in trace.Bool_Parameters)
                {
                    XmlNode BoolParam = doc.CreateElement("boolean");
                    Key = doc.CreateAttribute("key"); Value = doc.CreateAttribute("value");
                    Key.Value = i.Key;
                    Value.Value = i.Value.ToString();
                    BoolParam.Attributes.Append(Key);
                    BoolParam.Attributes.Append(Value);
                    TraceNode.AppendChild(BoolParam);
                }
                foreach (var i in trace.Int_Parameters)
                {
                    XmlNode IntParam = doc.CreateElement("int");
                    Key = doc.CreateAttribute("key"); Value = doc.CreateAttribute("value");
                    Key.Value = i.Key;
                    Value.Value = i.Value.ToString();
                    IntParam.Attributes.Append(Key);
                    IntParam.Attributes.Append(Value);
                    TraceNode.AppendChild(IntParam);
                }
                foreach (var i in trace.Double_Parameters)
                {
                    XmlNode FloatParam = doc.CreateElement("float");
                    Key = doc.CreateAttribute("key"); Value = doc.CreateAttribute("value");
                    Key.Value = i.Key;
                    Value.Value = i.Value.ToString(a);
                    FloatParam.Attributes.Append(Key);
                    FloatParam.Attributes.Append(Value);
                    TraceNode.AppendChild(FloatParam);
                }
                #endregion

                foreach (CEvent Event in trace.Events)
                {
                    XmlNode EventNode = doc.CreateElement("event");
                    XmlNode EventNameParam = doc.CreateElement("string");
                    Key = doc.CreateAttribute("key"); Value = doc.CreateAttribute("value");
                    Key.Value = "concept:name";
                    Value.Value = Event.Name;
                    EventNameParam.Attributes.Append(Key);
                    EventNameParam.Attributes.Append(Value);
                    EventNode.AppendChild(EventNameParam);
                    if (Event.Date.HasValue)
                    {
                        DateTimeOffset Date = Event.Date.Value;

                        string date = Date.Year.ToString("D4") + "-" + Date.Month.ToString("D2") + "-" + Date.Day.ToString("D2") + "T" +
                            Date.Hour.ToString("D2") + ":" + Date.Minute.ToString("D2") + ":" + Date.Second.ToString("D2") + "."
                            + Date.Millisecond.ToString("D3") + (Date.Offset.Hours > 0 ? "+" : "-") + Date.Offset.Hours.ToString("D2") +
                            ":" + Date.Offset.Minutes.ToString("D2");
                        XmlNode EventDateParam = doc.CreateElement("date");
                        Key = doc.CreateAttribute("key"); Value = doc.CreateAttribute("value");
                        Key.Value = "time:timestamp";
                        Value.Value = date;
                        EventDateParam.Attributes.Append(Key);
                        EventDateParam.Attributes.Append(Value);
                        EventNode.AppendChild(EventDateParam);
                    }
                    foreach (var i in Event.Text_Parameters)
                    {
                        XmlNode TextParam = doc.CreateElement("string");
                        Key = doc.CreateAttribute("key"); Value = doc.CreateAttribute("value");
                        Key.Value = i.Key;
                        Value.Value = i.Value.ToString();
                        TextParam.Attributes.Append(Key);
                        TextParam.Attributes.Append(Value);
                        EventNode.AppendChild(TextParam);
                    }
                    foreach (var i in Event.Bool_Parameters)
                    {
                        XmlNode BoolParam = doc.CreateElement("boolean");
                        Key = doc.CreateAttribute("key"); Value = doc.CreateAttribute("value");
                        Key.Value = i.Key;
                        Value.Value = i.Value.ToString();
                        BoolParam.Attributes.Append(Key);
                        BoolParam.Attributes.Append(Value);
                        EventNode.AppendChild(BoolParam);
                    }
                    foreach (var i in Event.Int_Parameters)
                    {
                        XmlNode IntParam = doc.CreateElement("int");
                        Key = doc.CreateAttribute("key"); Value = doc.CreateAttribute("value");
                        Key.Value = i.Key;
                        Value.Value = i.Value.ToString();
                        IntParam.Attributes.Append(Key);
                        IntParam.Attributes.Append(Value);
                        EventNode.AppendChild(IntParam);
                    }
                    foreach (var i in Event.Double_Parameters)
                    {
                        XmlNode FloatParam = doc.CreateElement("float");
                        Key = doc.CreateAttribute("key"); Value = doc.CreateAttribute("value");
                        Key.Value = i.Key;
                        Value.Value = i.Value.ToString(a);
                        FloatParam.Attributes.Append(Key);
                        FloatParam.Attributes.Append(Value);
                        EventNode.AppendChild(FloatParam);
                    }
                    TraceNode.AppendChild(EventNode);
                }
                doc.DocumentElement.AppendChild(TraceNode);
            }
        }
Esempio n. 9
0
 private void SetTreeView(CView View)
 {
     treeView1.Items.Clear();
     VisualizeLog(View, 1, Math.Min(40, View.Traces.Count));
     VisualizeStatsAboutView(View);
     GC.Collect();
     GC.WaitForPendingFinalizers();
 }
Esempio n. 10
0
        void VisualizeStatsAboutView(CView View)
        {
            //Длинна лога
            int Count = 0;
            foreach (var i in View.Traces)
                Count += i.Count;
            EventCount.Text = Count.ToString();

            //Количество событий
            SortedSet<string> EventNames = new SortedSet<string>();
            foreach (var i in View.Traces)
                foreach (var j in i.Events)
                    EventNames.Add(j.Name);
            EventNameCount.Text = EventNames.Count.ToString();

            // Количество трасс
            TraceCount.Text = View.Traces.Count.ToString();

            // Количество вариантов
            HashSet<string> Variants = new HashSet<string>();
            foreach (var Trace in View.Traces)
            {
                string Variant = "";
                foreach (var Event in Trace.Events)
                {
                    Variant += Event.Name + "=))";
                }
                Variants.Add(Variant);
            }
            VarietyCount.Text = Variants.Count.ToString();

            // Детализация лога
            double Detalization;
            int VarietySum = 0, VarCount = 0;
            foreach (var Trace in NowView.Traces)
            {
                HashSet<string> EventInTraceNames = new HashSet<string>();
                foreach (var Event in Trace.Events)
                    EventInTraceNames.Add(Event.Name);
                VarietySum += EventInTraceNames.Count;
                VarCount++;
            }
            Detalization = (double)VarietySum / (double)VarCount;
            AvarageVariety.Text = Detalization.ToString("F3");

            // Минимальное, среднее и максимальное значение классов событий в trace

            int MinCount = int.MaxValue, MaxCount = 0;
            double AverageCount;
            int Sum = 0, ECount = 0;
            foreach (var Trace in NowView.Traces)
            {
                MinCount = Trace.Events.Count < MinCount ? Trace.Events.Count : MinCount;
                MaxCount = Trace.Events.Count > MaxCount ? Trace.Events.Count : MaxCount;
                Sum += Trace.Events.Count;
                ECount++;
            }
            AverageCount = (double)Sum / (double)ECount;

            MinEventInTraceCount.Text = MinCount.ToString();
            AverageEventInTraceCount.Text = AverageCount.ToString("F2");
            MaxEventInTraceCount.Text = MaxCount.ToString();

            // Минимальное, среднее и максимальное значение количества параметров у события

            int MinParamCount = int.MaxValue, MaxParamCount = 0;
            double AverageParamCount;
            Sum = 0; ECount = 0;
            foreach (var Trace in NowView.Traces)
            {
                for (int i = 0; i < Trace.Events.Count; i++)
                {
                    int ParamCount = Trace[i].Bool_Parameters.Count + Trace[i].Double_Parameters.Count + Trace[i].Int_Parameters.Count +
                        Trace[i].Text_Parameters.Count;
                    MinParamCount = ParamCount < MinParamCount ? ParamCount : MinParamCount;
                    MaxParamCount = ParamCount > MaxParamCount ? ParamCount : MaxParamCount;
                    Sum += ParamCount;
                    ECount++;
                }
            }
            AverageParamCount = (double)Sum / (double)ECount;

            MinParamInEventCount.Text = MinParamCount.ToString();
            AverageParamInEventCount.Text = AverageParamCount.ToString("F2");
            MaxParamInEventCount.Text = MaxParamCount.ToString();

            VisualizeStatsAboutViewGraph(View, EventNames);
        }
Esempio n. 11
0
        void VisualizeStatsAboutViewGraph(CView View, SortedSet<string> ClassNames)
        {
            // График: по оси ОХ - кейсы, по timestamp первого события, OY - количество классов событий в кейсе -
            Chart1.Series.Clear();
            ObservableCollection<ChartIntTimePoint> ChartData = new ObservableCollection<ChartIntTimePoint>();
            LineSeries NewChart = new LineSeries();
            int Count;
            DateTime ThisTime = new DateTime();
            bool HasDate = false;
            ChartIntTimePoint NewPoint;
            foreach (var i in View.Traces)
            {
                SortedSet<string> EventNames = new SortedSet<string>();
                Count = 0;
                HasDate = false;
                for (int k = 0; k < i.Events.Count; k++)
                {
                    if (HasDate = i[k].Date.HasValue)
                    {
                        ThisTime = i[k].Date.Value.LocalDateTime;
                        break;
                    }
                }
                foreach (var j in i.Events)
                    EventNames.Add(j.Name);
                Count = EventNames.Count;
                if (HasDate)
                {
                    NewPoint = new ChartIntTimePoint();
                    NewPoint.Time = ThisTime;
                    NewPoint.Value = Count;
                    ChartData.Add(NewPoint);
                }
            }
            NewChart.ItemsSource = ChartData;
            NewChart.DependentValuePath = "Value";
            NewChart.IndependentValuePath = "Time";
            NewChart.Title = "Количество классов\nсобытий в трассе";
            Chart1.Series.Add(NewChart);
            // График: по оси ОХ - кейсы, по timestamp первого события, OY - количеств событий в кейсе -
            NewChart = new LineSeries();
            foreach (var i in View.Traces)
            {
                Count = i.Events.Count;
                HasDate = false;
                for (int k = 0; k < i.Events.Count; k++)
                {
                    if (HasDate = i[k].Date.HasValue)
                    {
                        ThisTime = i[k].Date.Value.LocalDateTime;
                        break;
                    }
                }
                if (HasDate)
                {
                    NewPoint = new ChartIntTimePoint();
                    NewPoint.Time = ThisTime;
                    NewPoint.Value = Count;
                    ChartData.Add(NewPoint);
                }
            }
            NewChart.ItemsSource = ChartData;
            NewChart.DependentValuePath = "Value";
            NewChart.IndependentValuePath = "Time";
            NewChart.Title = "Количество\nсобытий в трассе";
            Chart1.Series.Add(NewChart);

            // График: по оси ОХ - классы событий (activity), OY - количество кейсов, в которым встречается это событие -
            NewChart = new LineSeries();
            ObservableCollection<ChartIntStringPoint> ChartDataString = new ObservableCollection<ChartIntStringPoint>();
            ChartIntStringPoint Point = new ChartIntStringPoint();
            foreach (var Name in ClassNames)
            {
                Count = View.Traces.Count<CTrace>(x => x.Events.FindIndex(y => y.Name == Name) != -1);
                Point = new ChartIntStringPoint();
                Point.ClassName = Name;
                Point.Value = Count;
                ChartDataString.Add(Point);
            }
            NewChart.ItemsSource = ChartDataString;
            NewChart.DependentValuePath = "Value";
            NewChart.IndependentValuePath = "ClassName";
            NewChart.Title = "Встречаемость";
            Chart2.Series.Clear();
            Chart2.Series.Add(NewChart);

            // График: по оси ОХ - классы событий (activity), OY - количество кейсов, в которым встречается это событие -
            NewChart = new LineSeries();
            ObservableCollection<ChartDoubleStringPoint> ChartDoubleString = new ObservableCollection<ChartDoubleStringPoint>();
            Point = new ChartIntStringPoint();
            double[] CountOfEv = new double[ClassNames.Count];
            double[] ParamCount = new double[ClassNames.Count];
            foreach (var Trace in View.Traces)
            {
                foreach (var Event in Trace.Events)
                {
                    int Index = ClassNames.ToList<string>().FindIndex(x => x == Event.Name);
                    CountOfEv[Index]++;
                    ParamCount[Index] += Event.Parameters.Count;
                }
            }
            foreach (var Name in ClassNames)
            {
                int Index = ClassNames.ToList<string>().FindIndex(x => x == Name);
                ChartDoubleStringPoint PointD = new ChartDoubleStringPoint();
                PointD.ClassName = Name;
                PointD.Value = ParamCount[Index]/CountOfEv[Index];
                ChartDoubleString.Add(PointD);
            }
            NewChart.ItemsSource = ChartDoubleString;
            NewChart.DependentValuePath = "Value";
            NewChart.IndependentValuePath = "ClassName";
            NewChart.Title = "Количество\nпараметров";
            Chart3.Series.Clear();
            Chart3.Series.Add(NewChart);
        }
Esempio n. 12
0
 private void OnAddingView(CView View)
 {
     if (AddingView != null)
         AddingView(View);
 }
Esempio n. 13
0
 private void ButtonFilter_Click(object sender, RoutedEventArgs e)
 {
     CView NewView;
     Dictionary<string,object> par = new Dictionary<string,object>();
     try
     {
         if (currentcview != null)
             par.Add(viewname, currentcview);
         else
             throw new ArgumentNullException("Отсутствует CView для фильтрации. Пожалуйста, выберите CView.");
         for(int i=0;i<paramboxes.Count;i++)
         {
             par.Add(paramboxes[i].ParamName,paramboxes[i].TrueType);
         }
         NewView = FS.Run(number, par);
     }
     catch(Exception ex)
     {
         ErrorCatcher(ex);
         return;
     }
     currentcview = NewView;
     OnAddingView(NewView);
     ComboBoxItem cbi = new ComboBoxItem();
 }