Skip to main content

Hi All


I would like to know if someone has success in implementing 'repair error' service manager feature programmatically. In many cases there are errors which will get solved in next try. for example 'System.Net.Sockets.SocketException: An existing connection' error might have been caused due to network issues and it gets solved with 'repair error'. 


 It will be really helpfull if we can implement this 'retry' kind of code using code.


 


regards


S.Saba

I had to repair 250 items with a delay between repairs.   The person/ID running this would need K2 Admin rights.

 

Imports SourceCode
Imports System.Threading

Public Class K2RepairError

    Private Sub btnRepair_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRepair.Click
        Dim oK2Manager As New K2Mng.K2Manager
        Dim oK2ErrorProfiles As K2Mng.ErrorProfiles
        Dim oK2ErrorProfile As K2Mng.ErrorProfile

        Dim blnResult As Boolean = False
        Try

            oK2Manager.Login(yourK2ServerNameHere, 5252)
            oK2ErrorProfiles = oK2Manager.GetErrorProfiles

'I only have 1 error profile created which displays all errors thus I use (0) first profile
            Dim oErrorlog As K2Mng.ErrorLog = oK2Manager.GetErrorLogs(oK2ErrorProfiles(0).ID)
            For Each oErrorLogItem As K2Mng.ErrorLogItem In oErrorlog

                oErrorLogItem.LoadCodeItem(oK2Manager)

                blnResult = oK2Manager.RepairError(oErrorLogItem.ID, oErrorLogItem.ProcInstID, oErrorLogItem.Code.CodeText)

                'Display message based on outcome of ErrorRepair
                If blnResult Then
                    Thread.Sleep(5000)   '5 seconds
                Else
                    MsgBox("The error was ''NOT'' successfully repaired.", MsgBoxStyle.Information)
                End If
            Next
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
End Class
 


Hi Peter


 It helped a lot. Thanks!!!


 regards


S.Saba


Reply