/*
* 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