对 COM 应用程序的 Web 服务的并发调用 (Primavera ERP)

Concurrent calls to web service to COM application (Primavera ERP)

我有一个调用函数并在 ERP PRIMAVERA 中创建销售的 Web 服务,如果我按顺序调用它确实有效,但如果我并发调用它,因为 ERP 不支持线程并且只能创建一个线程有一次,Web 服务同时挂起了系统、客户端和 ERP。我不知道如何解决这个问题。 我能做什么?

我试图在日志 table 中创建一个记录呼叫状态的列,但由于时间差异以毫秒为单位,因此数据库中的写入为我提供了 2 个具有相同状态的呼叫,因此挂起系统。

    <WebMethod()>
    Public Function InsereVenda(ByVal id As String, ByVal xml As String) As String

        Dim ObjResp As New ObjResposta

        Try

            ObjResp = RetornaObjRespostaDocs("InsereVenda", id, xml)

            Return ObjResp.XMLResposta

        Catch ex As Exception
            If ex.Message = "" Then
                Return "Erro"
            Else

                Return ObjResp.XMLResposta
            End If


        End Try

    End Function
End Class


 Public Class Pedido
    Inherits System.Web.Services.WebService

    Private Function RetornaObjRespostaDocs(ByVal metodo As String, ByVal id As String, ByVal xml As String) As ObjResposta

        Dim msg As String = ""
        Dim servWeb As ServicosWeb
        Dim lista As DataTable

        RetornaObjRespostaDocs = New ObjResposta

        servWeb = New ServicosWeb(My.Settings.Username, My.Settings.Password, My.Settings.Empresa, My.Settings.TipoEmpresa)

        Try

            RetornaObjRespostaDocs.ID = id
            RetornaObjRespostaDocs.XML = xml
            RetornaObjRespostaDocs.DataProc = Now
            RetornaObjRespostaDocs.TipoMsg = metodo




            'While 1 < 2
            '    
            Thread.Sleep(1000)
            servWeb.GuardarRegistoTabelaLOGWebService(id, "", RetornaObjRespostaDocs.TipoMsg,
                                                          RetornaObjRespostaDocs.DataProc, RetornaObjRespostaDocs.XML, "", "0", "R")
            Thread.Sleep(1000)
            lista = servWeb.ConsultaSQLDatatable("select CDU_Estado from TDU_LogWebService  WITH (NOLOCK) where CDU_Estado = 'R'")

            If lista.Rows.Count <=0 Then
                servWeb.InsereVenda(xml, RetornaObjRespostaDocs)
                servWeb.GuardarRegistoTabelaLOGWebService(RetornaObjRespostaDocs.ID, RetornaObjRespostaDocs.Mensagem, RetornaObjRespostaDocs.TipoMsg,
            RetornaObjRespostaDocs.DataProc, RetornaObjRespostaDocs.XML, RetornaObjRespostaDocs.XMLResposta, RetornaObjRespostaDocs.Sucesso, "G")


            Else

                Thread.Sleep(1000)


            End If

            'End While




            Return RetornaObjRespostaDocs

        Catch ex As Exception

            servWeb.GuardarRegistoTabelaLOGWebService(RetornaObjRespostaDocs.ID, RetornaObjRespostaDocs.Mensagem, RetornaObjRespostaDocs.TipoMsg,
                        RetornaObjRespostaDocs.DataProc, RetornaObjRespostaDocs.XML, RetornaObjRespostaDocs.XMLResposta, RetornaObjRespostaDocs.Sucesso, "G")

            Return RetornaObjRespostaDocs

        End Try

    End Function

``

看来我的代码没问题,只是客户端应用程序以错误的方式调用它。