Beispiel #1
0
        private void btnOpenLeft_Click(object sender, EventArgs e)
        {
            openFileDialog1.Filter   = "Trace Files|*.tracesql;*.twiz;*.trc;*.aet";
            openFileDialog1.FileName = "";
            var result = openFileDialog1.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return;
            }
            btnLeftSelectAll.Enabled = false;
            execTreeLeft.Nodes.Clear();
            leftSelected.Clear();

            if (result == DialogResult.OK)
            {
                string filename = openFileDialog1.FileName;
                // Process the file

                if (TraceDeserializer.IsSerializedData(filename))
                {
                    if (TraceDeserializer.IsSerializedVersionSupported(filename))
                    {
                        leftData = new TraceDeserializer().DeserializeTraceData(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.None));
                        UIBuilder.BuildExecutionTree(leftData, execTreeLeft, SQLMap, ExecMap, false);
                        btnLeftSelectAll.Enabled = true;
                        btnCopyToRight.Enabled   = true;
                        if (leftData != null && rightData != null)
                        {
                            btnCompare.Enabled = true;
                        }
                        System.GC.Collect();
                    }
                    else
                    {
                        MessageBox.Show("This version of Trace Wizard cannot import the serialized data, maybe it was serialized with an older version.");
                    }
                }
                else
                {
                    var fileExtension = new FileInfo(filename).Extension.ToLower();

                    if (fileExtension.Equals(".tracesql") || fileExtension.Equals(".trc"))
                    {
                        leftProcessor = new TraceSQLProcessor(filename);
                    }
                    else if (fileExtension.Equals(".aet"))
                    {
                        leftProcessor = new AETTraceProcessor(filename);
                    }

                    leftProcessor.WorkerReportsProgress      = true;
                    leftProcessor.WorkerSupportsCancellation = true;

                    leftProcessor.ProgressChanged    += ProcessorLeft_ProgressChanged;
                    leftProcessor.RunWorkerCompleted += ProcessorLeft_RunWorkerCompleted;
                    leftProcessor.RunWorkerAsync();
                }
            }
        }
Beispiel #2
0
 private void rightBuildExpandingNode(TreeNode node, ExecutionCall call)
 {
     node.Nodes.Clear();
     foreach (var child in call.Children)
     {
         UIBuilder.BuildExecutionTree(node, child, rSQLMap, rExecMap, true, true);
     }
 }
Beispiel #3
0
        public static void BuildExecutionTree(TraceData traceData, TreeView executionTree, Dictionary <SQLStatement, TreeNode> SQLMapToTree, Dictionary <ExecutionCall, TreeNode> ExecCallToTree, bool showLoading = true, bool diffMode = false)
        {
            if (traceData == null)
            {
                return;
            }
            var execList = traceData.ExecutionPath;
            var sqlList  = traceData.SQLStatements;

            executionTree.Nodes.Clear();
            SQLMapToTree.Clear();
            ExecCallToTree.Clear();

            var    contextList     = execList.OrderBy(p => p.StartLine).Select(p => p.Context).Distinct().ToList();
            var    contextNodeList = new List <TreeNode>();
            double totalTraceTime  = 0;

            foreach (var ctx in contextList)
            {
                var ctxNode = new TreeNode(ctx);
                contextNodeList.Add(ctxNode);
                var    rootExecCalls    = execList.Where(p => p.Context.Equals(ctx)).OrderBy(p => p.StartLine);
                double contextTotalTime = 0;
                foreach (var exec in rootExecCalls)
                {
                    contextTotalTime += exec.Duration;
                    if (!diffMode)
                    {
                        if (exec.HasError || exec.IsError)
                        {
                            ctxNode.BackColor = Color.Yellow;
                        }
                        else if (exec.Duration >= Properties.Settings.Default.LongCall)
                        {
                            ctxNode.BackColor = Color.LightGreen;
                        }
                    }
                    else
                    {
                        /* only color yellow in Diff mode if there was a MODIFIED */
                        if (exec.DiffStatus == DiffStatus.MODIFIED)
                        {
                            ctxNode.BackColor = Color.Yellow;
                        }
                    }
                    UIBuilder.BuildExecutionTree(ctxNode, exec, SQLMapToTree, ExecCallToTree, showLoading, diffMode);
                }
                if (rootExecCalls.First().Type.HasFlag(ExecutionCallType.AE) == false)
                {
                    ctxNode.Text += " Dur: " + contextTotalTime;
                }
                totalTraceTime += contextTotalTime;
            }
            foreach (var node in contextNodeList)
            {
                executionTree.Nodes.Add(node);
            }
        }
Beispiel #4
0
 private void btnCopyToRight_Click(object sender, EventArgs e)
 {
     rightData = leftData;
     UIBuilder.BuildExecutionTree(rightData, execTreeRight, SQLMap, ExecMap, false);
     btnRightSelectAll.Enabled = true;
     if (leftData != null && rightData != null)
     {
         btnCompare.Enabled = true;
     }
 }
Beispiel #5
0
        private void DrawTrees()
        {
            TraceData ltd = new TraceData();

            ltd.ExecutionPath = left;
            UIBuilder.BuildExecutionTree(ltd, diffLeft, lSQLMap, lExecMap, true, true);

            TraceData rtd = new TraceData();

            rtd.ExecutionPath = right;
            UIBuilder.BuildExecutionTree(rtd, diffRight, rSQLMap, rExecMap, true, true);
        }
Beispiel #6
0
        public CompareDialog(TraceData initData)
        {
            InitializeComponent();

            if (initData != null)
            {
                leftData = initData;
                btnCopyToRight.Enabled   = true;
                btnLeftSelectAll.Enabled = true;

                UIBuilder.BuildExecutionTree(leftData, execTreeLeft, SQLMap, ExecMap, false);
            }
        }
Beispiel #7
0
        private void ProcessorRight_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            rightProgress.Value = 0;
            if (e.Cancelled)
            {
                MessageBox.Show("Trace file processing cancelled.");
                System.GC.Collect();
                return;
            }

            rightData = (TraceData)e.Result;

            UIBuilder.BuildExecutionTree(rightData, execTreeRight, SQLMap, ExecMap, false);
            btnRightSelectAll.Enabled = true;
            if (leftData != null && rightData != null)
            {
                btnCompare.Enabled = true;
            }

            System.GC.Collect();
        }
Beispiel #8
0
 void InitUI()
 {
     UIBuilder.BuildAllSQLList(sqlListView, sqlList);
 }