In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

ErroySys con envio de correo ?

Foro público de Xailer en español
Responder
Avatar de Usuario
gabo1
Mensajes: 127
Registrado: Lun Oct 13, 2014 9:42 am

ErroySys con envio de correo ?

Mensaje por gabo1 »

Algun compañero que pueda compartir el control de errores y que envie por correo los errores de la aplicacion ?
Saludos!
hgarciaj
Mensajes: 107
Registrado: Jue Sep 23, 2010 12:44 am

Re: ErroySys con envio de correo ?

Mensaje por hgarciaj »

/*
* Xailer source code:
*
* ErrorForm.prg
* Clase TErrorForm()
*
Aquí el código que uso es necesario incluir cdomail y los datos del smtp
* Copyright 2003, 2007 Jose F. Gimenez
* Copyright 2003, 2007 Xailer.com
* All rights reserved
*
*/

#include "Xailer.ch"
#include "Values.ch"


//--------------------------------------------------------------------------

CLASS TErrorForm FROM TForm

COMPONENT oMemo1
COMPONENT oMemo2
COMPONENT oDetails
COMPONENT oSend

DATA cMessage
DATA aOptions

METHOD CreateForm() // --> Self
METHOD Details( oSender ) // --> Nil
METHOD Envio( oSender ) // --> Nil

RESERVED:
METHOD WMNCLButtonDblClk( nHitTest )

ENDCLASS

//--------------------------------------------------------------------------

METHOD CreateForm() CLASS TErrorForm

LOCAL i

::nWidth := 600
::nHeight := 140
::nClientHeight := 107
::cText := LT( XA_MSG_ERROR_TITLE )
::oIcon := IDI_HAND
::nBorderStyle := bsDIALOG
::lMinimizeBox := .F.
::lAutoScroll := .F.
::oFont := Application:oFont:Clone()
::Create()

WITH OBJECT ::oMemo1 := TMemo():New( Self )
:SetBounds( 6, 8, 582, 60 )
:lReadOnly := .T.
:lVScroll := .F.
:nAnchors := akLEFTTOPRIGHT
:cText := ::cMessage
:Create()
END

/* FOR i := 1 TO Len( ::aOptions )
WITH OBJECT TButton():New( Self )
:SetBounds( ( i - 1 ) * 80 + 5, 75, 75, 25 )
:cText := ::aOptions[ i ]
:nModalResult := i
:Create()
END
NEXT
*/
WITH OBJECT ::oSend:=TButton():New( Self )
:SetBounds( 312, 75, 75, 25 )
:nAnchors := akTOPRIGHT
:cText := "Continuar"
:OnClick := "Envio"
:Create()
END

/* WITH OBJECT ::oDetails := TButton():New( Self )
:SetBounds( 512, 75, 75, 25 )
:nAnchors := akTOPRIGHT
:cText := LT( XA_MSG_ERROR_DETAILS ) + " >>>"
:OnClick := "Details"
:Create()
END
*/
WITH OBJECT ::oMemo2 := TMemo():New( Self )
:SetBounds( 6, 110, 582, 150 )
:lReadOnly := .T.
:cText := MemoRead( "Error.log" )
:oFont := TFont():Create( "Courier New" )
:lVisible := .F.
:Create()
END

::oActiveControl := ::aControls[ 2 ]
::oSend:lDefault := .T.

RETURN Self

//--------------------------------------------------------------------------

METHOD WMNCLButtonDblClk( nHitTest ) CLASS TErrorForm

/* NOTA: Esto se usa para maximizar la ventana al hacer doble click en el titulo,
aunque sea un dialogo y no tenga boton de maximizar - [JFG]
NOTE: This is used to maximize the window when the user double clicks on the
caption, although it's a dialog and doesn't have a maximize button - [JFG]
*/
IF nHitTest == HTCAPTION
IF IsZoomed( ::Handle )
::Restore()
::oDetails:Enable()
ELSE
IF !( ::oDetails:cText = "<" )
::Details()
ENDIF
::Maximize()
::oDetails:Disable()
ENDIF
::oMemo2:SetBounds( ,, ::nClientWidth - 13, ::nClientHeight - ::oMemo2:nTop - 6 )
RETURN 0
ENDIF

RETURN Nil

//--------------------------------------------------------------------------

METHOD Details( oSender ) CLASS TErrorForm

IF ::oDetails:cText = "<"
::oDetails:cText := LT( XA_MSG_ERROR_DETAILS ) + " >>>"
::oDetails:oParent:nClientHeight := MulDiv( 107, Application:nScale, 100 )
::oMemo2:Hide()
ELSE
::oDetails:cText := "<<< " + LT( XA_MSG_ERROR_DETAILS )
::oDetails:oParent:nClientHeight := MulDiv( 265, Application:nScale, 100 )
::oMemo2:SelectAll()
::oMemo2:SendMsg( WM_COPY, 0, 0 )
::oMemo2:SelectNone()
::oMemo2:Show()
ENDIF

RETURN Nil

//--------------------------------------------------------------------------
//--------------------------------------------------------------------------

METHOD Envio( oSender ) CLASS TErrorForm
WITH OBJECT TCDOMail():New()
:nPort := Appdata:nPort //porta do servidor
:lAuthenticate := Appdata:lAuthenticate //requer autenticação
:lSSL := Appdata:lSSL //autenticação SSL
:cServer := Appdata:cServer //servidor smtp
:cUser := Appdata:cUser //usuário
:cPassword := Appdata:cPassword //senha
:cFrom := Appdata:cFrom //e-mail remetente
// :cFrom:=::oEdiFrom:Value
:cTO:="Soporte Técnico <xxx@mail.com>"
:cSubject:="Error.log"
:cMessage:=MemoRead( "Error.log" )
:Create()
waiton("Enviando correo...")
IF :Send()
waitoff()
MsgInfo("Correo enviado exitosamente")
ELSE
waitoff()
MsgInfo("error al enviar el mensaje")
ENDIF
:Destroy()
END
quit
RETURN Nil
Saludos
Héctor García
Avatar de Usuario
gabo1
Mensajes: 127
Registrado: Lun Oct 13, 2014 9:42 am

Re: ErroySys con envio de correo ?

Mensaje por gabo1 »

Muchas Gracias Hector!
Saludos!
hgarciaj
Mensajes: 107
Registrado: Jue Sep 23, 2010 12:44 am

Re: ErroySys con envio de correo ?

Mensaje por hgarciaj »

Gabo
Olvidé mencionar que si trabajas con Mariadb el errorsys no atrapa los mensajes de error y no lo podrás recibir, hay que modificar la clase Mariadb y atrapar los errores para hacer el mismo proceso
Saludos
Héctor García
Responder