'Imports bdGestionAsegasa 'Imports GestionAsegasa.Enumeraciones 'Public Class ProcesosZurich ' Public Shared Async Function ObtieneDocumentosPolizasPendientes() As Task ' Try ' Dim bd = bdGestionAsegasa.gestionasegasaEntities.NuevoContextoCN() ' Dim idZurich = bd.companias.First(Function(x) x.Codigo = "0013").idCompania ' Dim tipoFichero As Integer = bd.enumeraciones.Where(Function(x) x.Codigo = "TIPFIC.DOCPOL").First.idEnumeracion ' Dim fi As New Date(2024, 10, 5) ' Dim pols = bd.polizassg.Where(Function(x) x.idCompania = idZurich AndAlso x.NumeroPoliza IsNot Nothing AndAlso x.FechaAlta > fi AndAlso x.documentospolizassg.All(Function(y) y.Tipo = 0)).ToList() ' Dim cz = bd.enumeraciones.First(Function(x) x.Codigo = "CONF.0013") ' Dim sv = New ServicioDocumentos(cz.ValorAlfabetico1, cz.ValorAlfabetico2) ' For Each p In pols ' Dim numpol = p.NumeroPoliza.PadLeft(14, "0") ' Dim ld = Await sv.ObtenerDocumentosAsync(numpol, -1) ' ' Obtener la lista de documentos que no son recibos ' Dim ldocs = ld.Document.Where(Function(x) Not String.IsNullOrEmpty(x.documentTypeDesc) AndAlso Not x.documentTypeDesc.ToLower().Contains("recibo")) ' For Each d In ldocs ' Try ' Dim dr = Await sv.DescargarDocumentoAsync("", d.documentCode, False, numpol, ld.policyVersion) ' Dim sha1 = tsl5.crypt.SHA1(dr.documentFileContent.data) ' Dim docpol = p.documentospolizassg.FirstOrDefault(Function(x) x.Hash = sha1) ' If docpol Is Nothing Then ' docpol = New documentospolizassg() ' Dim fichero = New ficheros() ' fichero.Descripcion = d.documentTypeDesc ' fichero.Fecha = Date.Now ' fichero.idTipo = tipoFichero ' fichero.Fichero = dr.documentFileContent.data ' fichero.NombreFichero = dr.documentFileContent.fileName ' fichero.idAplicacion = p.idPoliza ' ' Crear y almacenar el documento de la póliza ' docpol.Descripcion = d.documentTypeDesc.ToUpper ' docpol.ficheros = fichero ' docpol.FechaComprobacion = Date.Now ' docpol.Fecha = Date.Now ' docpol.Codigo = d.documentCode ' docpol.Hash = sha1 ' docpol.Tipo = ObtieneTipoDocumento(d.typeCode) ' p.documentospolizassg.Add(docpol) ' Else ' docpol.Codigo = d.documentCode ' docpol.Tipo = ObtieneTipoDocumento(d.typeCode) ' End If ' bd.SaveChanges() ' Catch ex As Exception ' Call bdGestionAsegasa.Utilidades.AñadeLog(tsl5.Enumeraciones.TipoLog.Fallo, "En ObtieneDocumentosPolizasPendientes.", "Rutina: ObtieneDocumentosPolizasPendientes. Poliza:" & p.NumeroPoliza & " dc:" & d.documentCode & " " & bdGestionAsegasa.gestionasegasaEntities.bdga.Servidor & " " & ex.Message, ex) ' End Try ' Next ' Next ' Catch ex As Exception ' Call bdGestionAsegasa.Utilidades.AñadeLog(tsl5.Enumeraciones.TipoLog.Fallo, "En ObtieneDocumentosPolizasPendientes.", "Rutina: ObtieneDocumentosPolizasPendientes. " & bdGestionAsegasa.gestionasegasaEntities.bdga.Servidor & " " & ex.Message, ex) ' End Try ' End Function ' Public Shared Async Function ObtieneDocumentosRecibosPendientes() As Task ' Try ' Dim bd = bdGestionAsegasa.gestionasegasaEntities.NuevoContextoCN() ' Dim idZurich = bd.companias.First(Function(x) x.Codigo = "0013").idCompania ' Dim tipoFichero As Integer = bd.enumeraciones.Where(Function(x) x.Codigo = "TIPFIC.DOCPOL").First.idEnumeracion ' Dim fi As New Date(2024, 9, 23) ' Dim cz = bd.enumeraciones.First(Function(x) x.Codigo = "CONF.0013") ' Dim svRecibos = New ServicioRecibos(cz.ValorAlfabetico1, cz.ValorAlfabetico2) ' Dim svDocumentos = New ServicioDocumentos(cz.ValorAlfabetico1, cz.ValorAlfabetico2) ' Dim recs = bd.recibos.Where(Function(x) x.polizassg.idCompania = idZurich AndAlso x.FechaEfecto > fi AndAlso x.documentospolizassg.Count = 0).ToList() ' Dim dr As ObtenerRecibos.getDuplicatedReceiptResponse = Nothing ' For Each r In recs ' Try ' Dim p = r.polizassg ' dr = Await svRecibos.ObtenerReciboDuplicadoAsync(r.NumeroRecibo, cz.ValorAlfabetico1) ' Dim numpol = p.NumeroPoliza.PadLeft(14, "0") ' Dim bpdf = Await svDocumentos.DescargarDocumentoAsync("", dr.documentCode, False, numpol, dr.policyVersion) ' Dim sha1 = tsl5.crypt.SHA1(bpdf.documentFileContent.data) ' Dim docpol = p.documentospolizassg.FirstOrDefault(Function(x) x.Hash = sha1) ' If docpol Is Nothing Then ' docpol = New documentospolizassg() ' Dim fichero = New ficheros() ' fichero.Descripcion = "RECIBO" ' fichero.Fecha = Date.Now ' fichero.idTipo = tipoFichero ' fichero.Fichero = bpdf.documentFileContent.data ' fichero.NombreFichero = dr.documentCode & ".pdf" ' fichero.idAplicacion = p.idPoliza ' docpol.Descripcion = "RECIBO" ' docpol.ficheros = fichero ' docpol.FechaComprobacion = Date.Now ' docpol.Fecha = Date.Now ' docpol.Codigo = dr.documentCode ' docpol.Hash = sha1 ' docpol.Tipo = documentospolizassg.TipoDocumentoEnum.RECIBO ' docpol.idRecibo = r.idRecibo ' p.documentospolizassg.Add(docpol) ' Else ' docpol.Codigo = dr.documentCode ' docpol.Tipo = documentospolizassg.TipoDocumentoEnum.RECIBO ' End If ' bd.SaveChanges() ' dr = Nothing ' Catch ex As Exception ' Call bdGestionAsegasa.Utilidades.AñadeLog(tsl5.Enumeraciones.TipoLog.Fallo, "En ObtieneDocumentosRecibosPendientes.", "Rutina: ObtieneDocumentosRecibosPendientes. Recibo:" & r.CodigoRecibo & If(dr Is Nothing, "", " dc:" & dr.documentCode) & " " & bdGestionAsegasa.gestionasegasaEntities.bdga.Servidor & " " & ex.Message, ex) ' End Try ' Next ' Catch ex As Exception ' Call bdGestionAsegasa.Utilidades.AñadeLog(tsl5.Enumeraciones.TipoLog.Fallo, "En ObtieneDocumentosRecibosPendientes.", "Rutina: ObtieneDocumentosRecibosPendientes. " & bdGestionAsegasa.gestionasegasaEntities.bdga.Servidor & " " & ex.Message, ex) ' End Try ' End Function ' Private Shared Function ObtieneTipoDocumento(typeCode As String) As Integer ' Select Case typeCode ' Case "CL" ' Return documentospolizassg.TipoDocumentoEnum.PÓLIZA ' Case "CE" ' Return documentospolizassg.TipoDocumentoEnum.CERTIFICADO_SEGURO ' Case Else ' Return documentospolizassg.TipoDocumentoEnum.OTROS ' End Select ' End Function 'End Class