Created
May 11, 2020 15:27
-
-
Save mattiamanzati/85755cd5f69e2e3e16fbf62c6e107c86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Region "Scarica dati capo" | |
| Public Overridable Function ScaricaInformazioniCapo(ByVal strCodCapo As String, ByRef datNas As Date, ByRef strSesso As String, ByRef strRazza As String, ByRef strLog As String) As Boolean | |
| Dim client As RestClient | |
| Dim request As RestRequest | |
| Dim response As RestResponse | |
| Dim strCodAic As String = "" | |
| Dim strContent As String = "" | |
| Dim strTmp As String() | |
| Dim strNextTag As String = "" | |
| Try | |
| ' inizializzo il client | |
| client = New RestClient("https://www.vetinfo.it/") | |
| ' preparo la richiesta | |
| request = New RestRequest("/sso_portale/informazioni/int_capi_no_log.pl", Method.POST) | |
| request.AddParameter("P_CODICE_CAPO", strCodCapo) | |
| request.AddParameter("P_CODICE_SPECIE", "0121") | |
| request.AddParameter("P_CAPI", "") | |
| ' eseguo la richiesta | |
| response = client.Execute(request) | |
| ' check status code | |
| If Not response.StatusCode = Net.HttpStatusCode.OK Then | |
| ThrowRemoteEvent(New NTSEventArgs(CLN__STD.ThMsg.MSG_INFO, "Errore in fase di recupero dati per " & NTSCStr(strCodCapo) & "! Richiesta fallita.")) | |
| Return False | |
| End If | |
| strContent = response.Content | |
| ' guardo che il capo non sia cancellato | |
| If strContent.ToLower.Contains("capo non presente in anagrafe") Then | |
| strLog &= strCodCapo & " capo non presente in anagrafe." & vbCrLf | |
| Return False | |
| End If | |
| strTmp = strContent.Split(New String() {"<td", "</td>"}, StringSplitOptions.RemoveEmptyEntries) | |
| For Each str As String In strTmp | |
| str = str.Replace(" ", " ").Trim | |
| If str.LastIndexOf(">") > -1 Then str = str.Substring(str.LastIndexOf(">") + 1) | |
| str = str.Trim | |
| If str.Length = 0 Then Continue For | |
| ' parso il token | |
| If str = "Data nascita:" Then | |
| strNextTag = "ac_datnas" | |
| Continue For | |
| ElseIf str = "Sesso:" Then | |
| strNextTag = "ac_sesso" | |
| Continue For | |
| ElseIf str = "Razza:" Then | |
| strNextTag = "xxac_codrazz" | |
| Continue For | |
| End If | |
| ' parso il valore | |
| If strNextTag = "ac_datnas" Then | |
| ' data di nascita | |
| datNas = NTSCDate(str) | |
| ElseIf strNextTag = "ac_sesso" Then | |
| ' sesso | |
| If str = "FEMMINA" Then | |
| strSesso = "F" | |
| ElseIf str = "MASCHIO" Then | |
| strSesso = "M" | |
| Else | |
| strSesso = "" | |
| End If | |
| ElseIf strNextTag = "xxac_codrazz" Then | |
| ' descrizione razza | |
| strRazza = str | |
| End If | |
| ' annullo il token | |
| strNextTag = "" | |
| Next | |
| Return True | |
| Catch ex As Exception | |
| '-------------------------------------------------------------- | |
| If GestErrorCallThrow() Then | |
| Throw New NTSException(GestError(ex, Me, "", oApp.InfoError, "", False)) | |
| Else | |
| ThrowRemoteEvent(New NTSEventArgs("", GestError(ex, Me, "", oApp.InfoError, "", False))) | |
| End If | |
| '-------------------------------------------------------------- | |
| End Try | |
| Return True | |
| End Function | |
| #End Region |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment