Skip to content

Commit 9401ada

Browse files
committed
Avoid duplicates
1 parent 062c584 commit 9401ada

1 file changed

Lines changed: 29 additions & 9 deletions

File tree

PSMSVirtualDeviceManager/StartPage/TroubleshootIssueTracker/ClassLogService.vb

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ Public Class ClassLogService
366366
Return mIssues.ToArray
367367
End If
368368

369+
Dim mFaieldController As New HashSet(Of Integer)
370+
369371
Dim mTemplate As New STRUC_LOG_ISSUE(
370372
LOG_ISSUE_BLUETOOTH_ADDRESS_FAIL,
371373
"PSMoveServiceEx failed to asign the host address to the controller id {0}.",
@@ -387,10 +389,13 @@ Public Class ClassLogService
387389
If (mMatch.Success AndAlso mMatch.Groups("ID").Success) Then
388390
Dim iControllerID As Integer = CInt(mMatch.Groups("ID").Value)
389391

390-
Dim mNewIssue As New STRUC_LOG_ISSUE(mTemplate)
391-
mNewIssue.sDescription = String.Format(mTemplate.sDescription, iControllerID)
392+
If (Not mFaieldController.Contains(iControllerID)) Then
393+
mFaieldController.Add(iControllerID)
392394

393-
mIssues.Add(mNewIssue)
395+
Dim mNewIssue As New STRUC_LOG_ISSUE(mTemplate)
396+
mNewIssue.sDescription = String.Format(mTemplate.sDescription, iControllerID)
397+
mIssues.Add(mNewIssue)
398+
End If
394399
End If
395400
End If
396401
Next
@@ -406,6 +411,8 @@ Public Class ClassLogService
406411
Return mIssues.ToArray
407412
End If
408413

414+
Dim mFailedDevices As New HashSet(Of String)
415+
409416
Dim mTemplate As New STRUC_LOG_ISSUE(
410417
LOG_ISSUE_DEVICE_FAIL,
411418
"PSMoveServiceEx failed to open device {0} ({1}).",
@@ -428,10 +435,15 @@ Public Class ClassLogService
428435
Dim iDeviceID As Integer = CInt(mMatch.Groups("DeviceID").Value)
429436
Dim sPath As String = CStr(mMatch.Groups("Path").Value)
430437

431-
Dim mNewIssue As New STRUC_LOG_ISSUE(mTemplate)
432-
mNewIssue.sDescription = String.Format(mTemplate.sDescription, iDeviceID, sPath)
438+
Dim sDevicekey = String.Format("{0}/{1}", iDeviceID, sPath)
439+
440+
If (Not mFailedDevices.Contains(sDevicekey)) Then
441+
mFailedDevices.Add(sDevicekey)
433442

434-
mIssues.Add(mNewIssue)
443+
Dim mNewIssue As New STRUC_LOG_ISSUE(mTemplate)
444+
mNewIssue.sDescription = String.Format(mTemplate.sDescription, iDeviceID, sPath)
445+
mIssues.Add(mNewIssue)
446+
End If
435447
End If
436448
End If
437449
Next
@@ -769,6 +781,8 @@ Public Class ClassLogService
769781
Return mIssues.ToArray
770782
End If
771783

784+
Dim mClosedDevices As New HashSet(Of String)
785+
772786
Dim mTemplate As New STRUC_LOG_ISSUE(
773787
LOG_ISSUE_DEVICE_TIMEOUT,
774788
"PSMoveServiceEx closed {0} id {1} due to timeout (no data received), typically caused by connection issues.",
@@ -813,9 +827,15 @@ Public Class ClassLogService
813827

814828
iState = CONST_SEARCH_CLOSED_DEVICE
815829

816-
Dim mNewIssue As New STRUC_LOG_ISSUE(mTemplate)
817-
mNewIssue.sDescription = String.Format(mTemplate.sDescription, sDeviceType, iStateDeviceId)
818-
mIssues.Add(mNewIssue)
830+
Dim sDevicekey = String.Format("{0}/{1}", sDeviceType, iStateDeviceId)
831+
832+
If (Not mClosedDevices.Contains(sDevicekey)) Then
833+
mClosedDevices.Add(sDevicekey)
834+
835+
Dim mNewIssue As New STRUC_LOG_ISSUE(mTemplate)
836+
mNewIssue.sDescription = String.Format(mTemplate.sDescription, sDeviceType, iStateDeviceId)
837+
mIssues.Add(mNewIssue)
838+
End If
819839
End If
820840
End If
821841
End Select

0 commit comments

Comments
 (0)