571 lines
19 KiB
C++
571 lines
19 KiB
C++
// ErOReprt.cpp : implementation file
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
#include "StdAfx.h"
|
|
|
|
#include "ErOReprt.hpp"
|
|
|
|
#include "ErO_Op.hpp"
|
|
#include "ErOTeam.hpp"
|
|
|
|
#include <mapi.h>
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
extern HMODULE g_hModule;
|
|
extern CString g_csModuleName;
|
|
|
|
HINSTANCE h_MAPI_DLL = NULL;
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// ErrorOperator_DialogReport dialog
|
|
|
|
BEGIN_MESSAGE_MAP(ErrorOperator_DialogReport, CDialog)
|
|
//{{AFX_MSG_MAP(ErrorOperator_DialogReport)
|
|
ON_BN_CLICKED(IDC_BUTTON_FILE_BROWSE, OnButtonFileBrowse)
|
|
ON_BN_CLICKED(IDC_RADIO_REPORT_CLIPBOARD, OnRadioReportClipboard)
|
|
ON_BN_CLICKED(IDC_RADIO_REPORT_FILE, OnRadioReportFile)
|
|
ON_BN_CLICKED(IDC_RADIO_REPORT_PRINTER, OnRadioReportPrinter)
|
|
ON_BN_CLICKED(IDC_RADIO_REPORT_MAIL, OnRadioReportMail)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
//***************************************************************************
|
|
ErrorOperator_DialogReport::ErrorOperator_DialogReport(CWnd* pParent /*=NULL*/)
|
|
: CDialog(IDD_DIALOG_REPORT, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(ErrorOperator_DialogReport)
|
|
m_iChosenReportType = 3;
|
|
m_csFileName = _T("");
|
|
m_bSendToMainProgrammer = TRUE;
|
|
m_bSendToSecondProgrammer = FALSE;
|
|
m_bSendToResponsible = FALSE;
|
|
m_bDeleteReport = FALSE;
|
|
m_csAddedComments = _T("");
|
|
//}}AFX_DATA_INIT
|
|
|
|
//Initializing file name
|
|
char a_cBuffer[MAX_PATH];
|
|
GetModuleFileName(g_hModule, a_cBuffer, MAX_PATH);
|
|
m_csFileName = a_cBuffer;
|
|
|
|
short wIndex = m_csFileName.ReverseFind('\\');
|
|
if ( wIndex != -1 )
|
|
m_csFileName = m_csFileName.Left(wIndex + 1);
|
|
|
|
if ( g_csModuleName.IsEmpty() )
|
|
m_csFileName += "Error_Report.txt";
|
|
else
|
|
{
|
|
//Computes date
|
|
SYSTEMTIME stSystemTime;
|
|
::GetLocalTime(&stSystemTime);
|
|
CTime cTime(stSystemTime);
|
|
CString csDate = cTime.Format("_%b_%d");
|
|
|
|
CString csFileName = CString("Rprt_") + g_csModuleName + csDate + ".txt";
|
|
|
|
m_csFileName += csFileName;
|
|
}
|
|
}
|
|
|
|
//***************************************************************************
|
|
void ErrorOperator_DialogReport::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(ErrorOperator_DialogReport)
|
|
DDX_Radio(pDX, IDC_RADIO_REPORT_FILE, m_iChosenReportType);
|
|
DDX_Text(pDX, IDC_EDIT_FILE_NAME, m_csFileName);
|
|
DDX_Check(pDX, IDC_CHECK_MAIN_PROGRAMMER, m_bSendToMainProgrammer);
|
|
DDX_Check(pDX, IDC_CHECK_SECOND_PROGRAMMER, m_bSendToSecondProgrammer);
|
|
DDX_Check(pDX, IDC_CHECK_RESPONSIBLE, m_bSendToResponsible);
|
|
DDX_Check(pDX, IDC_CHECK_DELETE_FILE, m_bDeleteReport);
|
|
DDX_Text(pDX, IDC_EDIT_USER_ADDS, m_csAddedComments);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// ErrorOperator_DialogReport message handlers
|
|
|
|
//***************************************************************************
|
|
BOOL ErrorOperator_DialogReport::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
OnRadioReportMail();
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
//***************************************************************************
|
|
void ErrorOperator_DialogReport::OnOK()
|
|
{
|
|
UpdateData(TRUE);
|
|
|
|
switch ( m_iChosenReportType )
|
|
{
|
|
case 0:
|
|
m_pri_fn_vSaveFile();
|
|
break;
|
|
case 1:
|
|
m_pri_fn_vPrint();
|
|
break;
|
|
case 2:
|
|
m_pri_fn_vCopyToClipboard();
|
|
break;
|
|
case 3:
|
|
m_pri_fn_vSendByMail();
|
|
break;
|
|
}
|
|
|
|
CDialog::OnOK();
|
|
}
|
|
|
|
// Private Functions
|
|
////////////////////////
|
|
|
|
//***************************************************************************
|
|
void ErrorOperator_DialogReport::m_pri_fn_vSaveFile()
|
|
{
|
|
CStdioFile clFile;
|
|
|
|
const CString csSpacing = " ";
|
|
const CString g_c_csUnknownn = "< Unknown >";
|
|
const CString g_c_csNone = "< None >";
|
|
|
|
if ( clFile.Open(m_csFileName, CFile::modeReadWrite | CFile::modeCreate | CFile::modeNoTruncate | CFile::typeText) )
|
|
{
|
|
clFile.WriteString("##################################\n");
|
|
clFile.WriteString("# Error Operator making a report #\n");
|
|
clFile.WriteString("##################################\n");
|
|
clFile.WriteString("\n");
|
|
|
|
//Computes date
|
|
SYSTEMTIME stSystemTime;
|
|
::GetLocalTime(&stSystemTime);
|
|
CTime cTime(stSystemTime);
|
|
CString csDate = cTime.Format("Date : %A, %B %d, %Y, %Hh%Mm \n");
|
|
clFile.WriteString(csDate);
|
|
clFile.WriteString("\n");
|
|
|
|
clFile.WriteString("Error has been detected in Module :\n");
|
|
CString csCurrentLine = csSpacing + (g_csModuleName.IsEmpty() ? g_c_csUnknownn : g_csModuleName) + "\n";
|
|
clFile.WriteString(csCurrentLine);
|
|
|
|
clFile.WriteString("Error level was :\n");
|
|
switch ( g_eErrorGravity )
|
|
{
|
|
case E_ERROR_GRAVITY_WARNING:
|
|
csCurrentLine = csSpacing + "Warning\n";
|
|
break;
|
|
case E_ERROR_GRAVITY_INSTABLE:
|
|
csCurrentLine = csSpacing + "Instable\n";
|
|
break;
|
|
case E_ERROR_GRAVITY_FATAL:
|
|
csCurrentLine = csSpacing + "Fatal\n";
|
|
break;
|
|
default:
|
|
csCurrentLine = csSpacing + g_c_csUnknownn + "\n";
|
|
break;
|
|
}
|
|
clFile.WriteString(csCurrentLine);
|
|
|
|
clFile.WriteString("\n");
|
|
clFile.WriteString("Current action was :\n");
|
|
csCurrentLine = csSpacing + (g_csCurrentAction.IsEmpty() ? g_c_csUnknownn : g_csCurrentAction) + "\n";
|
|
clFile.WriteString(csCurrentLine);
|
|
|
|
clFile.WriteString("\n");
|
|
clFile.WriteString("Calling function was :\n");
|
|
csCurrentLine = csSpacing + (g_csCurrentFunction.IsEmpty() ? g_c_csUnknownn : g_csCurrentFunction) + "\n";
|
|
clFile.WriteString(csCurrentLine);
|
|
|
|
clFile.WriteString("In source :\n");
|
|
csCurrentLine = csSpacing + (g_csCurrentFileName.IsEmpty() ? g_c_csUnknownn : g_csCurrentFileName) + "\n";
|
|
clFile.WriteString(csCurrentLine);
|
|
|
|
clFile.WriteString("At line :\n");
|
|
csCurrentLine.Format("%i", g_wCurrentFileLine);
|
|
csCurrentLine = csSpacing + (g_wCurrentFileLine < 0 ? g_c_csUnknownn : csCurrentLine) + "\n";
|
|
clFile.WriteString(csCurrentLine);
|
|
|
|
clFile.WriteString("\n");
|
|
clFile.WriteString("Additionnal informations were :\n");
|
|
csCurrentLine = csSpacing + (g_csAddedInfo.IsEmpty() ? g_c_csNone : g_csAddedInfo) + "\n";
|
|
clFile.WriteString(csCurrentLine);
|
|
|
|
clFile.WriteString("\n");
|
|
clFile.WriteString("Script in progress :\n");
|
|
csCurrentLine = csSpacing + (g_csCurrentScriptFileName.IsEmpty() ? g_c_csNone : g_csCurrentScriptFileName) + "\n";
|
|
clFile.WriteString(csCurrentLine);
|
|
|
|
clFile.WriteString("At line :\n");
|
|
csCurrentLine.Format("%i", g_wCurrentScriptLine);
|
|
csCurrentLine = csSpacing + (g_wCurrentScriptLine <= 0 ? g_c_csUnknownn : csCurrentLine) + "\n";
|
|
clFile.WriteString(csCurrentLine);
|
|
|
|
clFile.WriteString("\n");
|
|
clFile.WriteString("----------------------------------------------------------------------\n");
|
|
clFile.WriteString("\n");
|
|
|
|
clFile.Close();
|
|
}
|
|
else
|
|
MessageBox("Error Operator cannot open the file to write its report !", "Error Operator - Error", MB_OK|MB_ICONSTOP);
|
|
}
|
|
|
|
//***************************************************************************
|
|
void ErrorOperator_DialogReport::m_pri_fn_vPrint()
|
|
{
|
|
|
|
}
|
|
|
|
//***************************************************************************
|
|
void ErrorOperator_DialogReport::m_pri_fn_vCopyToClipboard()
|
|
{
|
|
const CString csSpacing = " ";
|
|
const CString g_c_csUnknownn = "< Unknown >";
|
|
const CString g_c_csNone = "< None >";
|
|
CString csGlobalText;
|
|
|
|
csGlobalText += "##################################\n";
|
|
csGlobalText += "# Error Operator making a report #\n";
|
|
csGlobalText += "##################################\n";
|
|
csGlobalText += "\n";
|
|
|
|
//Computes date
|
|
SYSTEMTIME stSystemTime;
|
|
::GetLocalTime(&stSystemTime);
|
|
CTime cTime(stSystemTime);
|
|
CString csDate = cTime.Format("Date : %A, %B %d, %Y, %Hh%Mm \n");
|
|
csGlobalText += csDate;
|
|
csGlobalText += "\n";
|
|
|
|
csGlobalText += "Error has been detected in Module :\n";
|
|
CString csCurrentLine = csSpacing + (g_csModuleName.IsEmpty() ? g_c_csUnknownn : g_csModuleName) + "\n";
|
|
csGlobalText += csCurrentLine;
|
|
|
|
csGlobalText += "Error level was :\n";
|
|
switch ( g_eErrorGravity )
|
|
{
|
|
case E_ERROR_GRAVITY_WARNING:
|
|
csCurrentLine = csSpacing + "Warning\n";
|
|
break;
|
|
case E_ERROR_GRAVITY_INSTABLE:
|
|
csCurrentLine = csSpacing + "Instable\n";
|
|
break;
|
|
case E_ERROR_GRAVITY_FATAL:
|
|
csCurrentLine = csSpacing + "Fatal\n";
|
|
break;
|
|
default:
|
|
csCurrentLine = csSpacing + g_c_csUnknownn + "\n";
|
|
break;
|
|
}
|
|
csGlobalText += csCurrentLine;
|
|
|
|
csGlobalText += "\n";
|
|
csGlobalText += "Current action was :\n";
|
|
csCurrentLine = csSpacing + (g_csCurrentAction.IsEmpty() ? g_c_csUnknownn : g_csCurrentAction) + "\n";
|
|
csGlobalText += csCurrentLine;
|
|
|
|
csGlobalText += "\n";
|
|
csGlobalText += "Calling function was :\n";
|
|
csCurrentLine = csSpacing + (g_csCurrentFunction.IsEmpty() ? g_c_csUnknownn : g_csCurrentFunction) + "\n";
|
|
csGlobalText += csCurrentLine;
|
|
|
|
csGlobalText += "In source :\n";
|
|
csCurrentLine = csSpacing + (g_csCurrentFileName.IsEmpty() ? g_c_csUnknownn : g_csCurrentFileName) + "\n";
|
|
csGlobalText += csCurrentLine;
|
|
|
|
csGlobalText += "At line :\n";
|
|
csCurrentLine.Format("%i", g_wCurrentFileLine);
|
|
csCurrentLine = csSpacing + (g_wCurrentFileLine < 0 ? g_c_csUnknownn : csCurrentLine) + "\n";
|
|
csGlobalText += csCurrentLine;
|
|
|
|
csGlobalText += "\n";
|
|
csGlobalText += "Additionnal informations were :\n";
|
|
csCurrentLine = csSpacing + (g_csAddedInfo.IsEmpty() ? g_c_csNone : g_csAddedInfo) + "\n";
|
|
csGlobalText += csCurrentLine;
|
|
|
|
csGlobalText += "\n";
|
|
csGlobalText += "Script in progress :\n";
|
|
csCurrentLine = csSpacing + (g_csCurrentScriptFileName.IsEmpty() ? g_c_csNone : g_csCurrentScriptFileName) + "\n";
|
|
csGlobalText += csCurrentLine;
|
|
|
|
csGlobalText += "At line :\n";
|
|
csCurrentLine.Format("%i", g_wCurrentScriptLine);
|
|
csCurrentLine = csSpacing + (g_wCurrentScriptLine <= 0 ? g_c_csUnknownn : csCurrentLine) + "\n";
|
|
csGlobalText += csCurrentLine;
|
|
|
|
csGlobalText += "\n";
|
|
csGlobalText += "----------------------------------------------------------------------\n";
|
|
csGlobalText += "\n";
|
|
|
|
m_pri_fn_vCopyIntoClipBoard(csGlobalText);
|
|
}
|
|
|
|
//***************************************************************************
|
|
void ErrorOperator_DialogReport::OnButtonFileBrowse()
|
|
{
|
|
CFileDialog cfFileDial(TRUE);
|
|
|
|
if ( cfFileDial.DoModal() == IDOK )
|
|
{
|
|
m_csFileName = cfFileDial.GetPathName();
|
|
|
|
UpdateData(FALSE);
|
|
}
|
|
}
|
|
|
|
//***************************************************************************
|
|
void ErrorOperator_DialogReport::OnRadioReportClipboard()
|
|
{
|
|
GetDlgItem(IDC_STATIC_FILE)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_EDIT_FILE_NAME)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_BUTTON_FILE_BROWSE)->ShowWindow(SW_HIDE);
|
|
|
|
GetDlgItem(IDC_CHECK_MAIN_PROGRAMMER)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_CHECK_SECOND_PROGRAMMER)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_CHECK_RESPONSIBLE)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_CHECK_DELETE_FILE)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_STATIC_ADD_COMMENTS)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_EDIT_USER_ADDS)->ShowWindow(SW_HIDE);
|
|
}
|
|
|
|
//***************************************************************************
|
|
void ErrorOperator_DialogReport::OnRadioReportFile()
|
|
{
|
|
GetDlgItem(IDC_STATIC_FILE)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_EDIT_FILE_NAME)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_BUTTON_FILE_BROWSE)->ShowWindow(SW_SHOW);
|
|
|
|
GetDlgItem(IDC_CHECK_MAIN_PROGRAMMER)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_CHECK_SECOND_PROGRAMMER)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_CHECK_RESPONSIBLE)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_CHECK_DELETE_FILE)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_STATIC_ADD_COMMENTS)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_EDIT_USER_ADDS)->ShowWindow(SW_HIDE);
|
|
}
|
|
|
|
//***************************************************************************
|
|
void ErrorOperator_DialogReport::OnRadioReportPrinter()
|
|
{
|
|
GetDlgItem(IDC_STATIC_FILE)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_EDIT_FILE_NAME)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_BUTTON_FILE_BROWSE)->ShowWindow(SW_HIDE);
|
|
|
|
GetDlgItem(IDC_CHECK_MAIN_PROGRAMMER)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_CHECK_SECOND_PROGRAMMER)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_CHECK_RESPONSIBLE)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_CHECK_DELETE_FILE)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_STATIC_ADD_COMMENTS)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_EDIT_USER_ADDS)->ShowWindow(SW_HIDE);
|
|
}
|
|
|
|
//***************************************************************************
|
|
void ErrorOperator_DialogReport::OnRadioReportMail()
|
|
{
|
|
GetDlgItem(IDC_CHECK_MAIN_PROGRAMMER)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_CHECK_SECOND_PROGRAMMER)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_CHECK_RESPONSIBLE)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_CHECK_DELETE_FILE)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_STATIC_ADD_COMMENTS)->ShowWindow(SW_SHOW);
|
|
GetDlgItem(IDC_EDIT_USER_ADDS)->ShowWindow(SW_SHOW);
|
|
|
|
GetDlgItem(IDC_STATIC_FILE)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_EDIT_FILE_NAME)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDC_BUTTON_FILE_BROWSE)->ShowWindow(SW_HIDE);
|
|
}
|
|
|
|
//***************************************************************************
|
|
void ErrorOperator_DialogReport::m_pri_fn_vCopyIntoClipBoard(CString csText)
|
|
{
|
|
if( OpenClipboard() )
|
|
{
|
|
if( EmptyClipboard() )
|
|
{
|
|
long lSize=csText.GetLength();
|
|
HANDLE hText=GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE,lSize+1);
|
|
|
|
if( hText != NULL )
|
|
{
|
|
LPVOID pvText=GlobalLock(hText);
|
|
|
|
if( pvText != NULL )
|
|
{
|
|
CopyMemory(pvText, LPCTSTR(csText), lSize+1);
|
|
|
|
HANDLE hRes = SetClipboardData(CF_TEXT, hText);
|
|
|
|
if( hRes == NULL )
|
|
MessageBox("Can't set clipboard data");
|
|
|
|
GlobalUnlock(hText);
|
|
}
|
|
else
|
|
MessageBox("Can't lock memory for clipboard operation");
|
|
}
|
|
else
|
|
MessageBox("Can't alloc memory for clipboard");
|
|
}
|
|
else
|
|
MessageBox("Can't empty clipboard");
|
|
|
|
CloseClipboard();
|
|
}
|
|
}
|
|
|
|
//***************************************************************************
|
|
void ErrorOperator_DialogReport::m_pri_fn_vSendByMail()
|
|
{
|
|
AfxGetApp()->DoWaitCursor(1);
|
|
|
|
if ( h_MAPI_DLL == NULL )
|
|
{
|
|
h_MAPI_DLL = LoadLibrary("MAPI32.dll");
|
|
|
|
if ( h_MAPI_DLL == NULL )
|
|
MessageBox("No mail will be sent !", "ErO Module Error !!", MB_ICONSTOP);
|
|
}
|
|
|
|
if ( h_MAPI_DLL != NULL )
|
|
{
|
|
// Get the addresses of all the API's supported by this object
|
|
// m_MAPILogon = ( LPMAPILOGON ) GetProcAddress ( hlibMAPI, "MAPILogon" );
|
|
// m_MAPISendDocuments = ( LPMAPISENDDOCUMENTS ) GetProcAddress ( hlibMAPI, "MAPISendDocuments" );
|
|
// m_MAPIFindNext = ( LPMAPIFINDNEXT ) GetProcAddress ( hlibMAPI, "MAPIFindNext" );
|
|
// m_MAPIReadMail = ( LPMAPIREADMAIL ) GetProcAddress ( hlibMAPI, "MAPIReadMail" );
|
|
// m_MAPIAddress = ( LPMAPIADDRESS ) GetProcAddress ( hlibMAPI, "MAPIAddress" );
|
|
// m_MAPILogoff = ( LPMAPILOGOFF ) GetProcAddress ( hlibMAPI, "MAPILogoff" );
|
|
// m_MAPIFreeBuffer = ( LPMAPIFREEBUFFER ) GetProcAddress ( hlibMAPI, "MAPIFreeBuffer" );
|
|
// m_MAPIDetails = ( LPMAPIDETAILS ) GetProcAddress ( hlibMAPI, "MAPIDetails" );
|
|
// m_MAPISaveMail = ( LPMAPISAVEMAIL ) GetProcAddress ( hlibMAPI, "MAPISaveMail" );
|
|
LPMAPIRESOLVENAME p_fn_MAPIResolveName = (LPMAPIRESOLVENAME)GetProcAddress(h_MAPI_DLL, "MAPIResolveName");
|
|
LPMAPISENDMAIL p_fn_MAPISendMail = (LPMAPISENDMAIL)GetProcAddress(h_MAPI_DLL, "MAPISendMail");
|
|
|
|
//Builds Recipients list
|
|
MapiRecipDesc RecipientArray[4];
|
|
|
|
char c_cI = 0;
|
|
for (;c_cI < 4 ; c_cI ++)
|
|
{
|
|
RecipientArray[c_cI].ulReserved = 0L;
|
|
RecipientArray[c_cI].ulEIDSize = 0L;
|
|
RecipientArray[c_cI].lpEntryID = NULL;
|
|
RecipientArray[c_cI].lpszAddress = NULL;
|
|
}
|
|
|
|
c_cI = 0;
|
|
//Gets Team
|
|
ErrorOperator_Team *pclTeam = g_clListOfTeams.m_pub_fn_pclGetTeamFromModuleName(g_csModuleName);
|
|
if ( pclTeam != NULL )
|
|
{
|
|
if ( m_bSendToMainProgrammer && (!pclTeam->m_csMainProgrammerName.IsEmpty()) )
|
|
{
|
|
//First recipient = MAIN PROGRAMMER
|
|
RecipientArray[c_cI].ulRecipClass = MAPI_TO;
|
|
RecipientArray[c_cI].lpszName = (char *)LPCTSTR(pclTeam->m_csMainProgrammerName);
|
|
c_cI ++;
|
|
}
|
|
if ( m_bSendToSecondProgrammer && (!pclTeam->m_csSecondProgrammerName.IsEmpty()) )
|
|
{
|
|
//Second recipient = SECOND PROGRAMMER
|
|
RecipientArray[c_cI].ulRecipClass = MAPI_TO;
|
|
RecipientArray[c_cI].lpszName = (char *)LPCTSTR(pclTeam->m_csSecondProgrammerName);
|
|
c_cI ++;
|
|
}
|
|
if ( m_bSendToResponsible && (!pclTeam->m_csResponsibleName.IsEmpty()) )
|
|
{
|
|
//Third recipient = SECOND PROGRAMMER
|
|
RecipientArray[c_cI].ulRecipClass = MAPI_CC;
|
|
RecipientArray[c_cI].lpszName = (char *)LPCTSTR(pclTeam->m_csResponsibleName);
|
|
c_cI ++;
|
|
}
|
|
|
|
//Fourth recipient = it's alaways me !!
|
|
RecipientArray[c_cI].ulRecipClass = MAPI_BCC;
|
|
RecipientArray[c_cI].lpszName = "Yves Babitch";
|
|
c_cI ++;
|
|
}
|
|
|
|
//Builds attachment
|
|
//Saves file
|
|
m_pri_fn_vSaveFile();
|
|
MapiFileDesc attachment =
|
|
{ 0, // ulReserved, must be 0
|
|
0, // no flags; this is a data file
|
|
(ULONG)-1, // position not specified
|
|
(char *)LPCTSTR(m_csFileName), // pathname
|
|
(char *)LPCTSTR(m_csFileName), // original filename
|
|
NULL // MapiFileTagExt unused
|
|
};
|
|
|
|
CString csSubject = "ErO Automatic Mail sender >>> The Module '" + g_csModuleName + "' has invoked ErO while '" + g_csCurrentAction + "'!";
|
|
CString csText = "\nHere is the report on the Error raised in ErO.\n";
|
|
if ( !m_csAddedComments.IsEmpty() )
|
|
{
|
|
csText += "The user wanted to add :\n";
|
|
csText += m_csAddedComments;
|
|
}
|
|
|
|
MapiMessage message =
|
|
{ 0, // reserved, must be 0
|
|
(char *)LPCTSTR(csSubject), //subject
|
|
(char *)LPCTSTR(csText), //note text
|
|
NULL, // NULL = interpersonal message
|
|
NULL, // no date; MAPISendMail ignores it
|
|
NULL, // no conversation ID
|
|
0L, // no flags, MAPISendMail ignores it
|
|
NULL, // no originator, this is ignored too
|
|
c_cI, // Number of recipients
|
|
RecipientArray, // NULL recipient array
|
|
1, // one attachment
|
|
&attachment // the attachment structure
|
|
};
|
|
|
|
//Sends mail
|
|
ULONG ulErrorCode;
|
|
ulErrorCode = p_fn_MAPISendMail(0L, // use implicit session.
|
|
0L, // ulUIParam; 0 is always valid
|
|
&message, // the message being sent
|
|
0L, // allow the user to edit the message
|
|
0L); // reserved; must be 0
|
|
|
|
if ( ulErrorCode != SUCCESS_SUCCESS )
|
|
{
|
|
CString csMessage = "Unknown reason";
|
|
switch ( ulErrorCode )
|
|
{
|
|
case MAPI_E_FAILURE:
|
|
csMessage = "Messaging system internal failure";
|
|
break;
|
|
case MAPI_E_ATTACHMENT_NOT_FOUND:
|
|
csMessage = "Attachment not found";
|
|
break;
|
|
case MAPI_E_ATTACHMENT_OPEN_FAILURE:
|
|
csMessage = "Attachment could not be open";
|
|
break;
|
|
case MAPI_E_ATTACHMENT_WRITE_FAILURE:
|
|
csMessage = "Attachment could not be written";
|
|
break;
|
|
};
|
|
|
|
csMessage = "Ero was unable to send the message : " + csMessage;
|
|
MessageBox(csMessage, "ErO Module Error !!", MB_ICONEXCLAMATION);
|
|
}
|
|
|
|
if ( m_bDeleteReport )
|
|
{
|
|
CFile cfFile;
|
|
cfFile.Remove(m_csFileName);
|
|
}
|
|
}
|
|
|
|
AfxGetApp()->DoWaitCursor(-1);
|
|
}
|