1
1
#region Copyright
2
2
//=======================================================================================
3
- // Microsoft Azure Customer Advisory Team
3
+ // Microsoft Azure Customer Advisory Team
4
4
//
5
5
// This sample is supplemental to the technical guidance published on my personal
6
- // blog at http://blogs.msdn.com/b/paolos/.
7
- //
6
+ // blog at http://blogs.msdn.com/b/paolos/.
7
+ //
8
8
// Author: Paolo Salvatori
9
9
//=======================================================================================
10
10
// Copyright (c) Microsoft Corporation. All rights reserved.
11
- //
12
- // LICENSED UNDER THE APACHE LICENSE, VERSION 2.0 (THE "LICENSE"); YOU MAY NOT USE THESE
13
- // FILES EXCEPT IN COMPLIANCE WITH THE LICENSE. YOU MAY OBTAIN A COPY OF THE LICENSE AT
11
+ //
12
+ // LICENSED UNDER THE APACHE LICENSE, VERSION 2.0 (THE "LICENSE"); YOU MAY NOT USE THESE
13
+ // FILES EXCEPT IN COMPLIANCE WITH THE LICENSE. YOU MAY OBTAIN A COPY OF THE LICENSE AT
14
14
// http://www.apache.org/licenses/LICENSE-2.0
15
- // UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, SOFTWARE DISTRIBUTED UNDER THE
16
- // LICENSE IS DISTRIBUTED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17
- // KIND, EITHER EXPRESS OR IMPLIED. SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING
15
+ // UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, SOFTWARE DISTRIBUTED UNDER THE
16
+ // LICENSE IS DISTRIBUTED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17
+ // KIND, EITHER EXPRESS OR IMPLIED. SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING
18
18
// PERMISSIONS AND LIMITATIONS UNDER THE LICENSE.
19
19
//=======================================================================================
20
20
#endregion
45
45
46
46
namespace ServiceBusExplorer . Controls
47
47
{
48
+ using Abstractions ;
49
+
48
50
public partial class PartitionListenerControl : UserControl
49
51
{
50
52
#region Private Constants
@@ -115,14 +117,13 @@ public partial class PartitionListenerControl : UserControl
115
117
private readonly WriteToLogDelegate writeToLog ;
116
118
private readonly Func < Task > stopLog ;
117
119
private readonly Action startLog ;
118
- private EventData currentEventData ;
119
- private int grouperEventDataCustomPropertiesWidth ;
120
+ private EventDataMessage currentEventData ;
120
121
private int currentMessageRowIndex ;
121
122
private readonly int partitionCount ;
122
123
private bool sorting ;
123
- private readonly SortableBindingList < EventData > eventDataBindingList = new SortableBindingList < EventData > { AllowNew = false , AllowEdit = false , AllowRemove = false } ;
124
+ private readonly SortableBindingList < EventDataMessage > eventDataBindingList = new SortableBindingList < EventDataMessage > { AllowNew = false , AllowEdit = false , AllowRemove = false } ;
124
125
private readonly IList < PartitionRuntimeInformation > partitionRuntumeInformationList = new List < PartitionRuntimeInformation > ( ) ;
125
- private BlockingCollection < EventData > eventDataCollection = new BlockingCollection < EventData > ( ) ;
126
+ private BlockingCollection < EventDataMessage > eventDataCollection = new BlockingCollection < EventDataMessage > ( ) ;
126
127
private System . Timers . Timer timer ;
127
128
private long receiverMessageNumber ;
128
129
private long receiverMessageSizeTotal ;
@@ -151,6 +152,7 @@ public partial class PartitionListenerControl : UserControl
151
152
private bool clearing ;
152
153
private bool cleared ;
153
154
private readonly string iotHubConnectionString ;
155
+ int grouperEventDataCustomPropertiesWidth ;
154
156
public Task AsyncTrackEventDataTask { get ; private set ; }
155
157
156
158
#endregion
@@ -315,12 +317,12 @@ private void InitializeControls()
315
317
eventDataDataGridView . DefaultCellStyle . SelectionBackColor = Color . FromArgb ( 92 , 125 , 150 ) ;
316
318
eventDataDataGridView . DefaultCellStyle . SelectionForeColor = SystemColors . Window ;
317
319
318
- // Set RowHeadersDefaultCellStyle.SelectionBackColor so that its default
320
+ // Set RowHeadersDefaultCellStyle.SelectionBackColor so that its default
319
321
// value won't override DataGridView.DefaultCellStyle.SelectionBackColor.
320
322
eventDataDataGridView . RowHeadersDefaultCellStyle . SelectionBackColor = Color . FromArgb ( 153 , 180 , 209 ) ;
321
323
322
- // Set the background color for all rows and for alternating rows.
323
- // The value for alternating rows overrides the value for all rows.
324
+ // Set the background color for all rows and for alternating rows.
325
+ // The value for alternating rows overrides the value for all rows.
324
326
eventDataDataGridView . RowsDefaultCellStyle . BackColor = SystemColors . Window ;
325
327
eventDataDataGridView . RowsDefaultCellStyle . ForeColor = SystemColors . ControlText ;
326
328
//eventDataDataGridView.AlternatingRowsDefaultCellStyle.BackColor = Color.White;
@@ -631,7 +633,7 @@ private void CalculateLastColumnWidth(object sender)
631
633
632
634
private void eventDataDataGridView_RowEnter ( object sender , DataGridViewCellEventArgs e )
633
635
{
634
- var bindingList = eventDataBindingSource . DataSource as BindingList < EventData > ;
636
+ var bindingList = eventDataBindingSource . DataSource as BindingList < EventDataMessage > ;
635
637
currentMessageRowIndex = e . RowIndex ;
636
638
if ( bindingList == null )
637
639
{
@@ -644,11 +646,26 @@ private void eventDataDataGridView_RowEnter(object sender, DataGridViewCellEvent
644
646
currentEventData = bindingList [ e . RowIndex ] ;
645
647
eventDataPropertyGrid . SelectedObject = currentEventData ;
646
648
647
- LanguageDetector . SetFormattedMessage ( serviceBusHelper , currentEventData . Clone ( ) , txtMessageText ) ;
649
+ try
650
+ {
651
+ //var eventData = currentEventData.Clone();
652
+ LanguageDetector . SetFormattedMessage ( serviceBusHelper , currentEventData , txtMessageText ) ;
653
+ }
654
+ catch ( Exception exception )
655
+ {
656
+ HandleException ( exception ) ;
657
+ }
648
658
649
- var listViewItems = currentEventData . Properties . Select ( p => new ListViewItem ( new [ ] { p . Key , ( p . Value ?? string . Empty ) . ToString ( ) } ) ) . ToArray ( ) ;
650
- eventDataPropertyListView . Items . Clear ( ) ;
651
- eventDataPropertyListView . Items . AddRange ( listViewItems ) ;
659
+ try
660
+ {
661
+ var listViewItems = currentEventData . Properties . Select ( p => new ListViewItem ( new [ ] { p . Key , ( p . Value ?? string . Empty ) . ToString ( ) } ) ) . ToArray ( ) ;
662
+ eventDataPropertyListView . Items . Clear ( ) ;
663
+ eventDataPropertyListView . Items . AddRange ( listViewItems ) ;
664
+ }
665
+ catch ( Exception exception )
666
+ {
667
+ HandleException ( exception ) ;
668
+ }
652
669
}
653
670
654
671
private void tabPageMessages_Resize ( object sender , EventArgs e )
@@ -691,7 +708,7 @@ private void eventDataDataGridView_CellDoubleClick(object sender, DataGridViewCe
691
708
{
692
709
return ;
693
710
}
694
- var bindingList = eventDataBindingSource . DataSource as BindingList < EventData > ;
711
+ var bindingList = eventDataBindingSource . DataSource as BindingList < EventDataMessage > ;
695
712
if ( bindingList == null )
696
713
{
697
714
return ;
@@ -831,7 +848,7 @@ private async void btnStart_Click(object sender, EventArgs e)
831
848
checkBoxCheckpoint ,
832
849
cancellationTokenSource . Token )
833
850
{
834
- TrackEvent = ev => Invoke ( new Action < EventData > ( m => eventDataCollection . Add ( m ) ) , ev ) ,
851
+ TrackEvent = ev => Invoke ( new Action < EventData > ( m => eventDataCollection . Add ( new EventDataMessage ( m ) ) ) , ev ) ,
835
852
GetElapsedTime = GetElapsedTime ,
836
853
UpdateStatistics = UpdateStatistics ,
837
854
WriteToLog = writeToLog ,
@@ -953,7 +970,7 @@ private void btnClear_Click(object sender, EventArgs e)
953
970
clearing = true ;
954
971
cleared = true ;
955
972
eventDataCollection . Dispose ( ) ;
956
- eventDataCollection = new BlockingCollection < EventData > ( ) ;
973
+ eventDataCollection = new BlockingCollection < EventDataMessage > ( ) ;
957
974
ClearTrackedMessages ( ) ;
958
975
ClearStatistics ( ) ;
959
976
ClearCharts ( ) ;
@@ -1166,8 +1183,8 @@ private void RefreshGraph()
1166
1183
if ( InvokeRequired )
1167
1184
{
1168
1185
Invoke ( new Action < long , long , long , bool > ( InternalUpdateStatistics ) ,
1169
- new object [ ] { receiveTuple . Item1 ,
1170
- receiveTuple . Item2 ,
1186
+ new object [ ] { receiveTuple . Item1 ,
1187
+ receiveTuple . Item2 ,
1171
1188
receiveTuple . Item3 ,
1172
1189
graph } ) ;
1173
1190
}
@@ -1338,7 +1355,7 @@ private void PartitionListenerControl_Paint(object sender, PaintEventArgs e)
1338
1355
cboReceiverInspector . Size . Height + 1 ) ;
1339
1356
}
1340
1357
1341
- /// <summary>
1358
+ /// <summary>
1342
1359
/// Clean up any resources being used.
1343
1360
/// </summary>
1344
1361
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
@@ -1501,7 +1518,7 @@ private void saveSelectedEventToolStripMenuItem_Click(object sender, EventArgs e
1501
1518
{
1502
1519
return ;
1503
1520
}
1504
- var bindingList = eventDataBindingSource . DataSource as BindingList < EventData > ;
1521
+ var bindingList = eventDataBindingSource . DataSource as BindingList < EventDataMessage > ;
1505
1522
if ( bindingList == null )
1506
1523
{
1507
1524
return ;
@@ -1543,8 +1560,8 @@ private void saveSelectedEventsToolStripMenuItem_Click(object sender, EventArgs
1543
1560
{
1544
1561
return ;
1545
1562
}
1546
- var messages = eventDataDataGridView . SelectedRows . Cast < DataGridViewRow > ( ) . Select ( r => r . DataBoundItem as EventData ) ;
1547
- IEnumerable < EventData > events = messages as EventData [ ] ?? messages . ToArray ( ) ;
1563
+ var messages = eventDataDataGridView . SelectedRows . Cast < DataGridViewRow > ( ) . Select ( r => r . DataBoundItem as EventDataMessage ) ;
1564
+ IEnumerable < EventDataMessage > events = messages as EventDataMessage [ ] ?? messages . ToArray ( ) ;
1548
1565
if ( ! events . Any ( ) )
1549
1566
{
1550
1567
return ;
0 commit comments