Imports DD_LIB_Standards
Public Class ClassProxy
    Public Shared MyPROXYConnectionString As String = ""
    Public Shared MyLinkedServer As String
    Public Shared Function Refresh_Object_Data()
        If LICENSE_PROXY = False Or clsDatabase.DB_PROXY_INITIALIZED = False Then
            Return False
        End If
        Dim sel = "DECLARE	@return_value int" & vbNewLine &
        "EXEC @return_value = [dbo].[PRPROXY_SYNC_OBJECTS]" & vbNewLine &
        "SELECT	'Return Value' = @return_value"
        Dim Result As DataTable = MYDB_ECM.GetDatatable(sel)
        If Not IsNothing(Result) Then
            If Result.Rows(0).Item(0) = 0 Then
                Return True
            Else
                Return False
            End If
        Else
            Return False
        End If
    End Function
    Public Shared Function PRPROXY_SYNC_DOC_OBJECTS()
        If LICENSE_PROXY = False Or clsDatabase.DB_PROXY_INITIALIZED = False Then
            Return False
        End If
        Dim sel = "DECLARE	@return_value int" & vbNewLine &
        "EXEC @return_value = [dbo].[PRPROXY_SYNC_DOC_OBJECTS]" & vbNewLine &
        "SELECT	'Return Value' = @return_value"
        Dim Result As DataTable = MYDB_ECM.GetDatatable(sel)
        If Not IsNothing(Result) Then
            If Result.Rows(0).Item(0) = 0 Then
                Return True
            Else
                Return False
            End If
        Else
            Return False
        End If
    End Function
    Public Shared Function PRPROXY_RECORD_DEL(RECID As Integer, ENTITY_ID As Integer)
        If LICENSE_PROXY = False Or clsDatabase.DB_PROXY_INITIALIZED = False Then
            Return False
        End If
        Dim sel = String.Format("DECLARE @return_value int" & vbNewLine &
        "EXEC @return_value = [dbo].[PRPROXY_RECORD_DEL] {0},{1} " & vbNewLine &
        "SELECT	'Return Value' = @return_value", RECID, ENTITY_ID)
        Dim Result As DataTable = MYDB_ECM.GetDatatable(sel)
        If Not IsNothing(Result) Then
            If Result.Rows(0).Item(0) = 0 Then
                Return True
            Else
                Return False
            End If
        Else
            Return False
        End If
    End Function
    Public Shared Function PRPROXY_RECORD_UPD_INS(ENT_ID As Integer, RECID As Integer)
        If LICENSE_PROXY = False Or clsDatabase.DB_PROXY_INITIALIZED = False Then
            Return False
        End If
        Dim sel = String.Format("DECLARE @return_value int" & vbNewLine &
        "EXEC @return_value = [dbo].[PRPROXY_RECORD_UPD_INS] {0},{1} " & vbNewLine &
        "SELECT	'Return Value' = @return_value", ENT_ID, RECID)
        Dim Result As DataTable = MYDB_ECM.GetDatatable(sel)
        If Not IsNothing(Result) Then
            If Result.Rows(0).Item(0) = 0 Then
                Return True
            Else
                Return False
            End If
        Else
            Return False
        End If
    End Function
    Public Shared Function PRPROXY_RECORD_CONNECT(PARENT_RECID As Integer, RECID As Integer)
        If LICENSE_PROXY = False Or clsDatabase.DB_PROXY_INITIALIZED = False Then
            Return False
        End If
        Dim sel = String.Format("DECLARE @return_value int" & vbNewLine &
        "EXEC @return_value = [dbo].[PRPROXY_RECORD_CONNECT] {0},{1} " & vbNewLine &
        "SELECT	'Return Value' = @return_value", PARENT_RECID, RECID)
        Dim Result As DataTable = MYDB_ECM.GetDatatable(sel)
        If Not IsNothing(Result) Then
            If Result.Rows(0).Item(0) = 0 Then
                Return True
            Else
                Return False
            End If
        Else
            Return False
        End If
    End Function
    Public Shared Function PRPROXY_CONTROL_DEL(REC_ID As Integer, ENT_ID As Integer, CONTROL_ID As Integer)
        If LICENSE_PROXY = False Or clsDatabase.DB_PROXY_INITIALIZED = False Then
            Return False
        End If
        Dim sel = String.Format("DECLARE @return_value int" & vbNewLine &
        "EXEC @return_value = [dbo].[PRPROXY_CONTROL_DEL] {0},{1},{2}" & vbNewLine &
        "SELECT	'Return Value' = @return_value", REC_ID, ENT_ID, CONTROL_ID)
        Dim Result As DataTable = MYDB_ECM.GetDatatable(sel)
        If Not IsNothing(Result) Then
            If Result.Rows(0).Item(0) = 0 Then
                Return True
            Else
                Return False
            End If
        Else
            Return False
        End If
    End Function
    Public Shared Function Refresh_Workflow_Data()
        If LICENSE_PROXY = False Or clsDatabase.DB_PROXY_INITIALIZED = False Then
            Return False
        End If
        Dim sel = "DECLARE	@return_value int" & vbNewLine &
        "EXEC @return_value = [dbo].[PRPROXY_SYNC_WORKFLOWS]" & vbNewLine &
        "SELECT	'Return Value' = @return_value"
        Dim Result As DataTable = MYDB_ECM.GetDatatable(sel)
        If Not IsNothing(Result) Then
            If Result.Rows(0).Item(0) = 0 Then
                Return True
            Else
                Return False
            End If
        Else
            Return False
        End If
    End Function
    Public Shared Function PRPROXY_SYNC_DETAIL_OBJECT(Objectname As String)
        If LICENSE_PROXY = False Or clsDatabase.DB_PROXY_INITIALIZED = False Then
            Return False
        End If
        Dim sel = "DECLARE	@return_value int" & vbNewLine &
        "EXEC @return_value = [dbo].[PRPROXY_SYNC_DETAIL_OBJECT] '" & Objectname & "'" & vbNewLine &
        "SELECT	'Return Value' = @return_value"
        Dim Result As DataTable = MYDB_ECM.GetDatatable(sel)
        If Not IsNothing(Result) Then
            If Result.Rows(0).Item(0) = 0 Then
                Return True
            Else
                Return False
            End If
        Else
            Return False
        End If
    End Function
    Public Shared Function PRPROXY_CONTROL_VALUE_UPD_INS(EntityID As Integer, ControlID As Integer, RecordID As Integer, Value As String)
        If LICENSE_PROXY = False Or clsDatabase.DB_PROXY_INITIALIZED = False Then
            Return False
        End If
        Dim sel = String.Format("DECLARE	@return_value int" & vbNewLine &
        "EXEC @return_value = [dbo].[PRPROXY_CONTROL_VALUE_UPD_INS] {0},{1},{2},'{3}','{4}'" & vbNewLine &
        "SELECT	'Return Value' = @return_value", EntityID, ControlID, RecordID, Value, USER_USERNAME)
        Dim Result As DataTable = MYDB_ECM.GetDatatable(sel)
        If Not IsNothing(Result) Then
            If Result.Rows(0).Item(0) = 0 Then
                Return True
            Else
                Return False
            End If
        Else
            Return False
        End If
    End Function
    Public Shared Function PRPROXY_CONTROL_VALUE_RENEW(RecordID As Integer)
        If LICENSE_PROXY = False Or clsDatabase.DB_PROXY_INITIALIZED = False Then
            Return False
        End If
        Dim sel = String.Format("DECLARE	@return_value int" & vbNewLine &
        "EXEC @return_value = [dbo].[PRPROXY_CONTROL_VALUE_RENEW] {0}" & vbNewLine &
        "SELECT	'Return Value' = @return_value", RecordID)
        Dim Result As DataTable = MYDB_ECM.GetDatatable(sel)
        If Not IsNothing(Result) Then
            If Result.Rows(0).Item(0) = 0 Then
                Return True
            Else
                Return False
            End If
        Else
            Return False
        End If
    End Function
    Public Shared Function IS_PROXY_BUSY()
        If LICENSE_PROXY = False Or clsDatabase.DB_PROXY_INITIALIZED = False Then
            Return False
        End If
        Dim sql = "SELECT SYNC_RUNNING FROM TBPROXY_CONFIG WHERE GUID = 1"
        Dim BUSY
        BUSY = MYDB_ECM.GetScalarValue(sql)
        If IsNothing(BUSY) Then
            Return True
        Else
            Return BUSY
        End If
    End Function
    Public Shared Function PRPROXY_DOC_VALUES_UPD(DocID As Integer, RecId As Integer)
        If LICENSE_PROXY = False Or clsDatabase.DB_PROXY_INITIALIZED = False Then
            Return False
        End If
        Dim sel = String.Format("DECLARE @return_value int" & vbNewLine &
      "EXEC @return_value = [dbo].[PRPROXY_DOC_VALUES_UPD] {0}, {1} " & vbNewLine &
      "SELECT	'Return Value' = @return_value", DocID, RecId)
        Dim Result As DataTable = MYDB_ECM.GetDatatable(sel)
        If Not IsNothing(Result) Then
            If Result.Rows(0).Item(0) = 0 Then
                Return True
            Else
                Return False
            End If
        Else
            Return False
        End If
    End Function
End Class
