Correzioni al programma di dump dei cespiti.

Porting a 32 bit del programma di scarico da ODBC.
Tradotti in italiano alcuni messaggi di errore.
Correzioni al programma di aggiornamento anagrafiche.
Cambiata la sequenza di ricerca: prima cerca il driver e poi
eventualmente la variabile d'ambiente SPPROOT.


git-svn-id: svn://10.65.10.50/trunk@5189 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
angelo 1997-09-11 14:43:55 +00:00
parent e6cbc87af9
commit edd8638c9a
6 changed files with 130 additions and 46 deletions

View File

@ -1,3 +1,4 @@
#include <windows.h>
#include <applicat.h> #include <applicat.h>
#include <filetext.h> #include <filetext.h>
#include <execp.h> #include <execp.h>
@ -17,10 +18,20 @@ protected:
virtual bool create(); virtual bool create();
public: public:
bool is_sigla32() const;
bool split_address(TString& addr, TString& civ) const; bool split_address(TString& addr, TString& civ) const;
int write(TLocalisamfile& file, bool re); int write(TLocalisamfile& file, bool re);
}; };
bool TSESA_anagr::is_sigla32() const
{
char szBuffer[80];
GetPrivateProfileString("SIGLAPP",
"Driver32",
"", szBuffer, sizeof(szBuffer), "odbc.ini");
return *szBuffer != '\0';
}
bool TSESA_anagr::split_address(TString& addr, TString& civ) const bool TSESA_anagr::split_address(TString& addr, TString& civ) const
{ {
bool ok = FALSE; bool ok = FALSE;
@ -41,7 +52,8 @@ bool TSESA_anagr::split_address(TString& addr, TString& civ) const
} }
} }
} }
addr = addr.left(50); addr.ltrim();
addr = addr.left(35);
return ok; return ok;
} }
@ -56,20 +68,27 @@ int TSESA_anagr::write(TLocalisamfile& file, bool re)
bool TSESA_anagr::menu(MENU_TAG mt) bool TSESA_anagr::menu(MENU_TAG mt)
{ {
TFilename tmp; tmp.tempdir(); TFilename tmp; tmp.tempdir();
TString cmdline(80); TString cmdline(80);
cmdline << "sesadump ditte " << tmp; cmdline = "dump";
if (is_sigla32())
cmdline << "32";
else
cmdline << "16";
cmdline << " ditte " << tmp;
TExternal_app app(cmdline); TExternal_app app(cmdline);
int err = app.run(); int err = app.run(FALSE,3);
if (err != 0) if (err != 0)
return error_box("Impossibile eseguire SesaDump.exe"); return error_box("Impossibile eseguire il programma di scarico anagrafiche");
TFilename txt = tmp; txt.add("ditte.txt"); TFilename txt = tmp; txt.add("ditte.txt");
TFilename ini = tmp; ini.add("ditte.ini"); TFilename ini = tmp; ini.add("ditte.ini");
TFile_text file(txt, ini); TFile_text file(txt, ini);
err = file.open('r'); err = file.open('r');
if (err != 0) if (err != 0)
return error_box("Impossibile aprire il file ditte.txt"); {
remove(ini); // Lo rimuove in caso lo crei vuoto il TConfig di TFile_text
return error_box("Aggiornamento anagrafiche non effettuato");
}
TLocalisamfile ditte(LF_NDITTE); TLocalisamfile ditte(LF_NDITTE);
TLocalisamfile anag(LF_ANAG); TLocalisamfile anag(LF_ANAG);

View File

@ -103,6 +103,11 @@ BOOL CColumns::Open(UINT nOpenType /* = snapshot */,
{ {
AfxThrowDBException(nRetCode, m_pDatabase, m_hstmt); AfxThrowDBException(nRetCode, m_pDatabase, m_hstmt);
} }
#ifdef WIN32
AllocStatusArrays();
AllocAndCacheFieldInfo();
AllocRowset();
#endif
// load first record // load first record
MoveFirst(); MoveFirst();
} }

View File

@ -9,11 +9,13 @@
static CDatabase _db; static CDatabase _db;
static CString _strWorkDir; static CString _strWorkDir;
#ifndef WIN32
#define S4DLL #define S4DLL
#include <d4all.h> #include <d4all.h>
static CODE4 _codebase; static CODE4 _codebase;
static DATA4 *_dbdata; static DATA4 *_dbdata;
#endif
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// SESA field info // SESA field info
@ -27,6 +29,7 @@ class SESA_Field : public CObject
CString m_strValue; CString m_strValue;
CTime m_tValue; CTime m_tValue;
double m_dValue; double m_dValue;
float m_fValue;
BOOL m_bValue; BOOL m_bValue;
public: public:
@ -36,6 +39,7 @@ public:
CString& StrValue() { return m_strValue; } CString& StrValue() { return m_strValue; }
CTime& TimeValue() { return m_tValue; } CTime& TimeValue() { return m_tValue; }
double& DoubleValue() { return m_dValue; } double& DoubleValue() { return m_dValue; }
float& FloatValue() { return m_fValue; }
BOOL& BoolValue() { return m_bValue; } BOOL& BoolValue() { return m_bValue; }
SESA_Field(LPCSTR strName, int nType); SESA_Field(LPCSTR strName, int nType);
@ -164,11 +168,11 @@ BOOL SESA_Recordset::Open(LPCSTR strTable)
if (ok) if (ok)
{ {
ok = CRecordset::Open(CRecordset::snapshot, strTable, CRecordset::readOnly); ok = CRecordset::Open(CRecordset::forwardOnly, strTable, CRecordset::readOnly);
if (!ok) if (!ok)
{ {
CString msg; CString msg;
msg = "Can't open table "; msg = "Impossibile aprire la tabella ";
msg += strTable; msg += strTable;
AfxMessageBox(msg, MB_OK | MB_ICONEXCLAMATION); AfxMessageBox(msg, MB_OK | MB_ICONEXCLAMATION);
} }
@ -195,7 +199,12 @@ void SESA_Recordset::DoFieldExchange(CFieldExchange* pFX)
RFX_Bool(pFX, fld.Name(), b); RFX_Bool(pFX, fld.Name(), b);
if (bLoad) if (bLoad)
{ {
if (b == FALSE || IsFieldFlagNull(nField, CFieldExchange::outputColumn)) if (b == FALSE ||
#ifdef WIN32
IsFieldNull(&b))
#else
IsFieldFlagNull(nField, CFieldExchange::outputColumn))
#endif
val.Empty(); val.Empty();
else else
val = "X"; val = "X";
@ -224,13 +233,43 @@ void SESA_Recordset::DoFieldExchange(CFieldExchange* pFX)
} }
} }
break; break;
case SQL_REAL:
{
float& d = fld.FloatValue();
RFX_Single(pFX, fld.Name(), d);
if (bLoad)
{
if (d == 0.0 ||
#ifdef WIN32
IsFieldNull(&d))
#else
IsFieldFlagNull(nField, CFieldExchange::outputColumn))
#endif
{
val.Empty();
}
else
{
char* buf = val.GetBuffer(32);
sprintf(buf, "%.12g", d);
val.ReleaseBuffer();
}
}
}
break;
case SQL_FLOAT:
case SQL_DOUBLE: case SQL_DOUBLE:
{ {
double& d = fld.DoubleValue(); double& d = fld.DoubleValue();
RFX_Double(pFX, fld.Name(), d); RFX_Double(pFX, fld.Name(), d);
if (bLoad) if (bLoad)
{ {
if (d == 0.0 || IsFieldFlagNull(nField, CFieldExchange::outputColumn)) if (d == 0.0 ||
#ifdef WIN32
IsFieldNull(&d))
#else
IsFieldFlagNull(nField, CFieldExchange::outputColumn))
#endif
{ {
val.Empty(); val.Empty();
} }
@ -349,13 +388,15 @@ BOOL SESA_OpenDatabase(const char* lpszDSN, const char* lpszConnect)
if (lpszDSN == NULL || *lpszDSN == '\0') if (lpszDSN == NULL || *lpszDSN == '\0')
lpszDSN = "SIGLAPP"; lpszDSN = "SIGLAPP";
if (lpszConnect == NULL || *lpszConnect == '\0') if (lpszConnect == NULL || *lpszConnect == '\0')
lpszConnect = "ODBC;"; lpszConnect = "ODBC;"; //UID=sa;PWD=";
BOOL ok; BOOL ok;
TRY TRY
{ {
// DataSrc Excl ReadOnly ConnectString // DataSrc Excl ReadOnly ConnectString
ok = _db.Open(lpszDSN, FALSE, TRUE, lpszConnect); ok = _db.Open(lpszDSN, FALSE, TRUE, lpszConnect);
if (ok)
_db.m_bStripTrailingSpaces = TRUE;
} }
CATCH_ALL(e) CATCH_ALL(e)
{ {
@ -366,9 +407,9 @@ BOOL SESA_OpenDatabase(const char* lpszDSN, const char* lpszConnect)
if (!ok) if (!ok)
{ {
CString msg; CString msg;
msg = "Can't connect to database "; msg = "Impossibile connetersi al database ";
msg += lpszDSN; msg += lpszDSN;
msg += " using "; msg += " usando ";
msg += lpszConnect; msg += lpszConnect;
AfxMessageBox(msg, MB_OK | MB_ICONEXCLAMATION); AfxMessageBox(msg, MB_OK | MB_ICONEXCLAMATION);
} }
@ -426,7 +467,7 @@ BOOL SESA_DumpTableODBC(const char* lpszTableName)
else else
{ {
CString msg; CString msg;
msg = "Can't open table "; msg = "Impossibile aprire la tabella ";
msg += lpszTableName; msg += lpszTableName;
AfxMessageBox(msg, MB_OK | MB_ICONEXCLAMATION); AfxMessageBox(msg, MB_OK | MB_ICONEXCLAMATION);
} }
@ -439,7 +480,8 @@ BOOL SESA_DumpTableODBC(const char* lpszTableName)
BOOL SESA_DumpTableCODEBASE(const char* SIGLAPP, const char* lpszTableName) BOOL SESA_DumpTableCODEBASE(const char* SIGLAPP, const char* lpszTableName)
{ {
BOOL ok; BOOL ok = TRUE;
#ifndef WIN32
CString filename; CString filename;
CString msg; CString msg;
@ -512,7 +554,7 @@ BOOL SESA_DumpTableCODEBASE(const char* SIGLAPP, const char* lpszTableName)
} }
else else
{ {
msg = "Can't get file header."; msg = "Impossibile reperire informazioni sulla testata del file";
AfxMessageBox(msg, MB_OK | MB_ICONEXCLAMATION); AfxMessageBox(msg, MB_OK | MB_ICONEXCLAMATION);
ok = FALSE; ok = FALSE;
} }
@ -561,7 +603,7 @@ BOOL SESA_DumpTableCODEBASE(const char* SIGLAPP, const char* lpszTableName)
} }
else else
{ {
msg = "Can't get field "; msg = "Impossibile reperire il campo ";
msg += fld_val; msg += fld_val;
AfxMessageBox(msg, MB_OK | MB_ICONEXCLAMATION); AfxMessageBox(msg, MB_OK | MB_ICONEXCLAMATION);
ok = FALSE; ok = FALSE;
@ -577,7 +619,7 @@ BOOL SESA_DumpTableCODEBASE(const char* SIGLAPP, const char* lpszTableName)
} }
else else
{ {
msg = "Can't open file "; msg = "Impossibile aprire il file ";
msg += filename; msg += filename;
AfxMessageBox(msg, MB_OK | MB_ICONEXCLAMATION); AfxMessageBox(msg, MB_OK | MB_ICONEXCLAMATION);
ok = FALSE; ok = FALSE;
@ -585,15 +627,31 @@ BOOL SESA_DumpTableCODEBASE(const char* SIGLAPP, const char* lpszTableName)
d4init_undo(&_codebase); d4init_undo(&_codebase);
#endif
return ok; return ok;
} }
BOOL SESA_DumpTable(const char* lpszTableName) BOOL SESA_DumpTable(const char* lpszTableName)
{ {
if (!SESA_DumpTableODBC(lpszTableName)) char szBuffer[80];
::GetPrivateProfileString("SIGLAPP",
#ifndef WIN32
"Driver",
#else
"Driver32",
#endif
"", szBuffer, sizeof(szBuffer), "odbc.ini");
if (*szBuffer == '\0' || !SESA_DumpTableODBC(lpszTableName))
{ {
const char *SIGLAPP = getenv("SPPROOT"); const char *SIGLAPP = getenv("SPPROOT");
return SIGLAPP ? SESA_DumpTableCODEBASE(SIGLAPP, lpszTableName) : FALSE; if (SIGLAPP)
return SESA_DumpTableCODEBASE(SIGLAPP, lpszTableName);
else
{
AfxMessageBox("Impossibile trovare la variabile d'ambiente SPPROOT", MB_OK | MB_ICONEXCLAMATION);
return FALSE;
}
} }
return TRUE; return TRUE;
} }

View File

@ -72,7 +72,7 @@ void CSesadumpDoc::AssertValid() const
void CSesadumpDoc::Dump(CDumpContext& dc) const void CSesadumpDoc::Dump(CDumpContext& dc) const
{ {
CDocument::Dump(dc); // CDocument::Dump(dc);
} }
#endif //_DEBUG #endif //_DEBUG

View File

@ -66,6 +66,8 @@ BOOL CSesadumpApp::InitInstance()
RUNTIME_CLASS(CSesadumpView)); RUNTIME_CLASS(CSesadumpView));
AddDocTemplate(pDocTemplate); AddDocTemplate(pDocTemplate);
OnFileNew();
if (m_lpCmdLine[0] != '\0') if (m_lpCmdLine[0] != '\0')
{ {
CString strTable, strDir; CString strTable, strDir;

View File

@ -55,7 +55,7 @@ IDR_MAINFRAME ICON DISCARDABLE "SESADUMP.ICO"
IDR_MAINFRAME MENU PRELOAD DISCARDABLE IDR_MAINFRAME MENU PRELOAD DISCARDABLE
BEGIN BEGIN
POPUP "&File" POPUP ""
BEGIN BEGIN
MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN
MENUITEM "&About Sesadump...", ID_APP_ABOUT MENUITEM "&About Sesadump...", ID_APP_ABOUT
@ -137,12 +137,12 @@ END
STRINGTABLE PRELOAD DISCARDABLE STRINGTABLE PRELOAD DISCARDABLE
BEGIN BEGIN
IDR_MAINFRAME "Sesadump Windows Application\nSesadu\nSesadu Document\n\n\nSesadu.Document\nSesadu Document" IDR_MAINFRAME "Sesadump\nPRASSI\nSesadu Document\n\n\nSesadu.Document\nSesadu Document"
END END
STRINGTABLE PRELOAD DISCARDABLE STRINGTABLE PRELOAD DISCARDABLE
BEGIN BEGIN
AFX_IDS_APP_TITLE "Sesadump Windows Application" AFX_IDS_APP_TITLE "Sesadump"
AFX_IDS_IDLEMESSAGE "Ready" AFX_IDS_IDLEMESSAGE "Ready"
END END