diff --git a/ce/ce0.cpp b/ce/ce0.cpp new file mode 100755 index 000000000..458b2fa71 --- /dev/null +++ b/ce/ce0.cpp @@ -0,0 +1,195 @@ +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +class TSESA_anagr : public TApplication +{ +protected: + virtual bool menu(MENU_TAG mt); + virtual bool create(); + +public: + bool split_address(TString& addr, TString& civ) const; + int write(TLocalisamfile& file, bool re); +}; + +bool TSESA_anagr::split_address(TString& addr, TString& civ) const +{ + bool ok = FALSE; + char* comma = strchr(addr, ','); + if (comma == NULL) + comma = strrchr(addr, ' '); + if (comma) + { + for (const char* c = comma+1; *c; c++) + { + if (isdigit(*c)) + { + *comma = '\0'; + civ = comma+1; + civ = civ.left(10); + ok = TRUE; + break; + } + } + } + addr = addr.left(50); + return ok; +} + +int TSESA_anagr::write(TLocalisamfile& file, bool re) +{ + int err = re ? file.rewrite() : file.write(); + if (err != NOERR) + err = re ? file.write() : file.rewrite(); + return err; +} + +bool TSESA_anagr::menu(MENU_TAG mt) +{ + TFilename tmp; tmp.tempdir(); + + TString cmdline(80); + cmdline << "sesadump ditte " << tmp; + TExternal_app app(cmdline); + int err = app.run(); + if (err != 0) + return error_box("Impossibile eseguire SesaDump.exe"); + + TFilename txt = tmp; txt.add("ditte.txt"); + TFilename ini = tmp; ini.add("ditte.ini"); + TFile_text file(txt, ini); + err = file.open('r'); + if (err != 0) + return error_box("Impossibile aprire il file ditte.txt"); + + TLocalisamfile ditte(LF_NDITTE); + TLocalisamfile anag(LF_ANAG); + TLocalisamfile anafis(LF_ANAGFIS); + TLocalisamfile anagiu(LF_ANAGGIU); + TLocalisamfile unloc(LF_UNLOC); + + TString ragsoc, comres, locres, indres, civres, capres; + + TRecord_text rec; + for (long rig = 1; file.read(rec) == 0; rig++) + { + const long codditta = atol(file.get_field(rec, "CODDITTA")); + if (codditta <= 0) + { + error_box("Codice ditta non valido alla riga %ld.", rig); + continue; + } + + const char tipoa = file.get_field(rec, "PERS_FIS") == "S" ? 'F' : 'G'; + ragsoc = file.get_field(rec, "RAGSOC"); + comres = file.get_field(rec, "COMUNE"); + locres = file.get_field(rec, "LOCALITA"); + indres = file.get_field(rec, "INDIR1"); + indres << file.get_field(rec, "INDIR2"); + split_address(indres, civres); + + ditte.zero(); + ditte.put(NDT_CODDITTA, codditta); + int err = ditte.read(_isequal, _lock); + + ditte.put(NDT_CODDITTA, codditta); + ditte.put(NDT_TIPOA, tipoa); + ditte.put(NDT_CODANAGR, codditta); + ditte.put(NDT_RAGSOC, ragsoc); + + err = write(ditte, err == NOERR); + if (err != NOERR) + error_box("Errore %d in scrittura\ndella ditta %ld", err, codditta); + + anag.put(ANA_TIPOA, tipoa); + anag.put(ANA_CODANAGR, codditta); + err = anag.read(_isequal, _lock); + + anag.put(ANA_TIPOA, tipoa); + anag.put(ANA_CODANAGR, codditta); + anag.put(ANA_RAGSOC, ragsoc); + anag.put(ANA_COMRES, comres); + anag.put(ANA_INDRES, indres); + anag.put(ANA_CIVRES, civres); + anag.put(ANA_CAPRES, capres); + anag.put(ANA_COFI, file.get_field(rec, "CODFISCALE")); + anag.put(ANA_PAIV, file.get_field(rec, "PART_IVA")); + + err = write(anag, err == NOERR); + if (err != NOERR) + error_box("Errore %d in scrittura\ndell'anagrafica %ld", err, codditta); + + if (tipoa == 'F') + { + anafis.put(ANF_CODANAGR, codditta); + err = anafis.read(_isequal, _lock); + + anafis.put(ANF_CODANAGR, codditta); + anafis.put(ANF_SESSO, file.get_field(rec, "SESSO")); + anafis.put(ANF_DATANASC, file.get_field(rec, "NASCITA")); + anafis.put(ANF_COMNASC, file.get_field(rec, "COMNASC")); + + err = write(anafis, err == NOERR); + if (err != NOERR) + error_box("Errore %d in scrittura\ndella persona fisica %ld", err, codditta); + } + else + { + anagiu.put(ANG_CODANAGR, codditta); + err = anagiu.read(_isequal, _lock); + + anagiu.put(ANG_CODANAGR, codditta); + anagiu.put(ANG_NATGIU, file.get_field(rec, "NAT_GIURID")); + + err = write(anagiu, err == NOERR); + if (err != NOERR) + error_box("Errore %d in scrittura\ndella persona giuridica %ld", err, codditta); + } + + unloc.put(ULC_CODDITTA, codditta); + unloc.put(ULC_CODULC, 1); + err = unloc.read(_isequal, _lock); + + unloc.put(ULC_CODDITTA, codditta); + unloc.put(ULC_CODULC, 1); + unloc.put(ULC_COMULC, comres); + unloc.put(ULC_INDULC, indres); + unloc.put(ULC_CIVULC, civres); + unloc.put(ULC_CAPULC, capres); + unloc.put(ULC_COMCCIAA, comres); + unloc.put(ULC_COMTRIB, comres); + + err = write(unloc, err == NOERR); + if (err != NOERR) + error_box("Errore %d in scrittura\ndell'unita' locale della ditta %ld", err, codditta); + } + + remove(txt); + remove(ini); + + return FALSE; +} + +bool TSESA_anagr::create() +{ + dispatch_e_menu(BAR_ITEM(1)); + return TRUE; +} + +int main(int argc, char** argv) +{ + TSESA_anagr app; + app.run(argc, argv, "Aggiornamento anagrafiche"); + exit(0); + return 0; +} + diff --git a/ce/ce0.url b/ce/ce0.url new file mode 100755 index 000000000..cd56f2780 --- /dev/null +++ b/ce/ce0.url @@ -0,0 +1,5 @@ +#include + +MENU TASK_MENUBAR + SUBMENU MENU_FILE "~File" + diff --git a/ce/columnst.cpp b/ce/columnst.cpp new file mode 100755 index 000000000..3fa4f0a98 --- /dev/null +++ b/ce/columnst.cpp @@ -0,0 +1,147 @@ +// sqlcols.cpp: implementation of the CColumns class +// +// This is a part of the Microsoft Foundation Classes C++ library. +// Copyright (C) 1992-1993 Microsoft Corporation +// All rights reserved. +// +// This source code is only intended as a supplement to the +// Microsoft Foundation Classes Reference and Microsoft +// QuickHelp and/or WinHelp documentation provided with the library. +// See these sources for detailed information regarding the +// Microsoft Foundation Classes product. + + +#include "stdafx.h" +#include "columnst.h" + +///////////////////////////////////////////////////////////////////////////// +// CColumns implementation + +// IMPLEMENT_DYNAMIC(CColumns, CRecordset) + +CColumns::CColumns(CDatabase* pDatabase) + : CRecordset(pDatabase) +{ + //{{AFX_FIELD_INIT(CColumns) + m_strQualifier = ""; + m_strOwner = ""; + m_strTableName = ""; + m_strColumnName = ""; + m_nDataType = 0; + m_strTypeName = ""; + m_lPrecision = 0; + m_lLength = 0; + m_nScale = 0; + m_nRadix = 0; + m_nFields = 11; + //}}AFX_FIELD_INIT + m_strQualifierParam = ""; + m_strOwnerParam = ""; + m_strTableNameParam = ""; + m_strColumnNameParam = ""; +} + +BOOL CColumns::Open(UINT nOpenType /* = snapshot */, + LPCSTR lpszSQL /* = NULL */, DWORD dwOptions /* = none */) +{ + RETCODE nRetCode; + ASSERT(lpszSQL == NULL); + + // Allocation and opening of database not supported + if (m_hstmt == SQL_NULL_HSTMT) + { + CString strDefaultConnect; + TRY + { + if (m_pDatabase == NULL) + { + m_pDatabase = new CDatabase(); + m_bRecordsetDb = TRUE; + } + + strDefaultConnect = GetDefaultConnect(); + // If not already opened, attempt to open + if (!m_pDatabase->IsOpen() && + !m_pDatabase->Open("", FALSE, FALSE, strDefaultConnect)) + return FALSE; + + AFX_SQL_SYNC(::SQLAllocStmt(m_pDatabase->m_hdbc, &m_hstmt)); + if (!Check(nRetCode)) + ThrowDBException(SQL_INVALID_HANDLE); + } + CATCH_ALL(e) + { +#ifdef _DEBUG + if (afxTraceFlags & 0x20) + TRACE0("Error: CDatabase create for CRecordset failed\n"); +#endif // _DEBUG + strDefaultConnect.Empty(); + if (m_bRecordsetDb) + { + delete m_pDatabase; + m_pDatabase = NULL; + } + ASSERT(m_hstmt == SQL_NULL_HSTMT); + THROW_LAST(); + } + END_CATCH_ALL + } + + TRY + { + // set any options, like timeouts, scrolling options + OnSetOptions(m_hstmt); + + // call the ODBC catalog function with data member params + RETCODE nRetCode; + AFX_SQL_ASYNC(this, ::SQLColumns(m_hstmt, + (m_strQualifierParam.IsEmpty()? (UCHAR FAR *)NULL: (UCHAR FAR *)(const char*)m_strQualifierParam), SQL_NTS, + (m_strOwnerParam.IsEmpty()? (UCHAR FAR *)NULL: (UCHAR FAR *)(const char*)m_strOwnerParam), SQL_NTS, + (m_strTableNameParam.IsEmpty()? (UCHAR FAR *)NULL: (UCHAR FAR *)(const char*)m_strTableNameParam), SQL_NTS, + NULL, SQL_NTS)); + if (!Check(nRetCode)) + { + AfxThrowDBException(nRetCode, m_pDatabase, m_hstmt); + } + // load first record + MoveFirst(); + } + CATCH_ALL(e) + { + Close(); + THROW_LAST(); + } + END_CATCH_ALL + return TRUE; +} + +CString CColumns::GetDefaultConnect() +{ + // this minimal connect string will cause ODBC login dialog to be brought up + return "ODBC;"; +} + +CString CColumns::GetDefaultSQL() +{ + // there is no default SQL - a direct ODBC call is made instead + ASSERT(FALSE); + return "!"; +} + +void CColumns::DoFieldExchange(CFieldExchange* pFX) +{ + //{{AFX_FIELD_MAP(CColumns) + pFX->SetFieldType(CFieldExchange::outputColumn); + RFX_Text(pFX, "table_qualifier", m_strQualifier); + RFX_Text(pFX, "table_owner", m_strOwner); + RFX_Text(pFX, "table_name", m_strTableName); + RFX_Text(pFX, "column_name", m_strColumnName); + RFX_Int(pFX, "data_type", m_nDataType); + RFX_Text(pFX, "type_name", m_strTypeName); + RFX_Long(pFX, "precision", m_lPrecision); + RFX_Long(pFX, "length", m_lLength); + RFX_Int(pFX, "scale", m_nScale); + RFX_Int(pFX, "radix", m_nRadix); + RFX_Int(pFX, "nullable", m_nNullable); + //}}AFX_FIELD_MAP +} diff --git a/ce/columnst.h b/ce/columnst.h new file mode 100755 index 000000000..edd9f6e2d --- /dev/null +++ b/ce/columnst.h @@ -0,0 +1,53 @@ +// columnst.h : interface of the CColumns class +// +// This is a part of the Microsoft Foundation Classes C++ library. +// Copyright (C) 1992-1993 Microsoft Corporation +// All rights reserved. +// +// This source code is only intended as a supplement to the +// Microsoft Foundation Classes Reference and Microsoft +// QuickHelp and/or WinHelp documentation provided with the library. +// See these sources for detailed information regarding the +// Microsoft Foundation Classes product. + +///////////////////////////////////////////////////////////////////////////// + +#ifndef __AFXWIN_H__ + #error include 'stdafx.h' before including this file for PCH +#endif + +class CColumns : public CRecordset +{ +// DECLARE_DYNAMIC(CColumns) + +public: + CColumns(CDatabase* pDatabase = NULL); + BOOL Open(UINT nOpenType = snapshot, LPCSTR lpszSQL = NULL, DWORD dwOptions = none); + +// Field/Param Data + //{{AFX_FIELD(CColumns, CRecordset) + CString m_strQualifier; + CString m_strOwner; + CString m_strTableName; + CString m_strColumnName; + int m_nDataType; + CString m_strTypeName; + long m_lPrecision; + long m_lLength; + int m_nScale; + int m_nRadix; + int m_nNullable; + //}}AFX_FIELD + + // Table we're enumerating columns for + CString m_strQualifierParam; + CString m_strOwnerParam; + CString m_strTableNameParam; + CString m_strColumnNameParam; + +// Implementation +protected: + virtual CString GetDefaultConnect(); // default connection string + virtual CString GetDefaultSQL(); // default SQL for Recordset + virtual void DoFieldExchange(CFieldExchange* pFX); // RFX support +}; diff --git a/ce/mainfrm.cpp b/ce/mainfrm.cpp new file mode 100755 index 000000000..f8a560e81 --- /dev/null +++ b/ce/mainfrm.cpp @@ -0,0 +1,71 @@ +// mainfrm.cpp : implementation of the CMainFrame class +// + +#include "stdafx.h" +#include "sesadump.h" + +#include "mainfrm.h" + +#include "sesadlg.h" +#include "sesa.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char BASED_CODE THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame + +IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) + +BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) + //{{AFX_MSG_MAP(CMainFrame) + ON_COMMAND(ID_FILE_OPEN, OnFileOpen) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame construction/destruction + +CMainFrame::CMainFrame() +{ + // TODO: add member initialization code here +} + +CMainFrame::~CMainFrame() +{ +} + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame diagnostics + +#ifdef _DEBUG +void CMainFrame::AssertValid() const +{ + CFrameWnd::AssertValid(); +} + +void CMainFrame::Dump(CDumpContext& dc) const +{ + CFrameWnd::Dump(dc); +} + +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame message handlers + +void CMainFrame::OnFileOpen() +{ + CSesaDlg dlg; + if (dlg.DoModal() == IDOK) + { + BOOL ok = SESA_OpenDatabase(dlg.m_strDSN, dlg.m_strConnect); + if (ok) + { + SESA_DumpTable(dlg.m_strTable); + SESA_CloseDatabase(); + } + } +} diff --git a/ce/mainfrm.h b/ce/mainfrm.h new file mode 100755 index 000000000..9a660f685 --- /dev/null +++ b/ce/mainfrm.h @@ -0,0 +1,33 @@ +// mainfrm.h : interface of the CMainFrame class +// +///////////////////////////////////////////////////////////////////////////// + +class CMainFrame : public CFrameWnd +{ +protected: // create from serialization only + CMainFrame(); + DECLARE_DYNCREATE(CMainFrame) + +// Attributes +public: + +// Operations +public: + +// Implementation +public: + virtual ~CMainFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +// Generated message map functions +protected: + //{{AFX_MSG(CMainFrame) + afx_msg void OnFileOpen(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// diff --git a/ce/resource.h b/ce/resource.h new file mode 100755 index 000000000..f4ad5eac3 --- /dev/null +++ b/ce/resource.h @@ -0,0 +1,22 @@ +//{{NO_DEPENDENCIES}} +// App Studio generated include file. +// Used by SESADUMP.RC +// +#define IDR_MAINFRAME 2 +#define IDD_ABOUTBOX 100 +#define IDD_CONNECTION 102 +#define IDC_DSN 1000 +#define IDC_CONNECT 1001 +#define IDC_TABLE 1002 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS + +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 32771 +#define _APS_NEXT_CONTROL_VALUE 1003 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/ce/sesa.cpp b/ce/sesa.cpp new file mode 100755 index 000000000..dc8773778 --- /dev/null +++ b/ce/sesa.cpp @@ -0,0 +1,441 @@ +#include "stdafx.h" + +#include +#include + +#include "columnst.h" +#include "sesa.h" + +static CDatabase _db; +static CString _strWorkDir; + +/////////////////////////////////////////////////////////// +// SESA field info +/////////////////////////////////////////////////////////// + +class SESA_Field : public CObject +{ + CString m_strName; + int m_nType; + + CString m_strValue; + CTime m_tValue; + double m_dValue; + BOOL m_bValue; + +public: + const CString& Name() const { return m_strName; } + int Type() const { return m_nType; } + + CString& StrValue() { return m_strValue; } + CTime& TimeValue() { return m_tValue; } + double& DoubleValue() { return m_dValue; } + BOOL& BoolValue() { return m_bValue; } + + SESA_Field(LPCSTR strName, int nType); + virtual ~SESA_Field() { } +}; + +SESA_Field::SESA_Field(LPCSTR strName, int nType) + : m_strName(strName), m_nType(nType), m_bValue(FALSE), m_dValue(0.0) +{ } + +class SESA_FieldList : public CObject +{ + CObList m_List; + +public: + void Add(const CString& strField, int nType); + POSITION GetHeadPosition() const; + SESA_Field& GetNext(POSITION& rPosition); + SESA_Field& Find(const CString& strField); + void RemoveAll(); + + int GetCount() const { return m_List.GetCount(); } + + virtual ~SESA_FieldList(); +}; + +void SESA_FieldList::Add(const CString& strName, int nType) +{ + SESA_Field* pField = new SESA_Field(strName, nType); + m_List.AddTail(pField); +} + +POSITION SESA_FieldList::GetHeadPosition() const +{ + return m_List.GetHeadPosition(); +} + +SESA_Field& SESA_FieldList::GetNext(POSITION& rPosition) +{ + SESA_Field* pField = (SESA_Field*)m_List.GetNext(rPosition); + ASSERT(pField); + return *pField; +} + +SESA_Field& SESA_FieldList::Find(const CString& strName) +{ + for (POSITION pos = GetHeadPosition(); pos;) + { + SESA_Field& fld = GetNext(pos); + if (fld.Name() == strName) + return fld; + } + return SESA_Field("", 0); +} + +void SESA_FieldList::RemoveAll() +{ + while (!m_List.IsEmpty()) + { + CObject* pField = m_List.RemoveHead(); + delete pField; + } +} + +SESA_FieldList::~SESA_FieldList() +{ + RemoveAll(); +} + +/////////////////////////////////////////////////////////// +// Sesa recordset +/////////////////////////////////////////////////////////// + +class SESA_Recordset : public CRecordset +{ +// DECLARE_DYNAMIC(SESA_Recordset) + SESA_FieldList m_FieldList; + CStringList m_DumpList; + +protected: + virtual CString GetDefaultConnect(); + virtual CString GetDefaultSQL(); + virtual void DoFieldExchange(CFieldExchange* pFX); + +public: + BOOL Open(LPCSTR strTable); + + void DumpHeader(ostream& out); + void ReadDumpList(const CString& strFile); + void DumpFields(ostream& out); + + SESA_Recordset(CDatabase* pDatabase); + virtual ~SESA_Recordset() { } +}; + +//IMPLEMENT_DYNAMIC(SESA_Recordset, CRecordset) + +CString SESA_Recordset::GetDefaultConnect() +{ + return "ODBC;"; // Copied from CATALOG sample application +} + +CString SESA_Recordset::GetDefaultSQL() +{ + ASSERT(FALSE); // Copied from CATALOG sample application + return "!"; +} + +BOOL SESA_Recordset::Open(LPCSTR strTable) +{ + CColumns Cols(&_db); + Cols.m_strTableNameParam = strTable; + BOOL ok = Cols.Open(CRecordset::forwardOnly, NULL, CRecordset::readOnly); + if (ok) + { + while (!Cols.IsEOF()) + { + m_FieldList.Add(Cols.m_strColumnName, Cols.m_nDataType); + Cols.MoveNext(); + } + RETCODE nRetCode; + AFX_SQL_SYNC(::SQLFreeStmt(Cols.m_hstmt, SQL_CLOSE)); + + m_nFields = m_FieldList.GetCount(); + } + + if (ok) + { + ok = CRecordset::Open(CRecordset::snapshot, strTable, CRecordset::readOnly); + if (!ok) + { + CString msg; + msg = "Can't open table "; + msg += strTable; + AfxMessageBox(msg, MB_OK | MB_ICONEXCLAMATION); + } + } + + return ok; +} + +void SESA_Recordset::DoFieldExchange(CFieldExchange* pFX) +{ + pFX->SetFieldType(CFieldExchange::outputColumn); + BOOL bLoad= pFX->m_nOperation == CFieldExchange::Fixup; + + int nField = 1; + for (POSITION pos = m_FieldList.GetHeadPosition(); pos; nField++) + { + SESA_Field& fld = m_FieldList.GetNext(pos); + CString& val = fld.StrValue(); + switch(fld.Type()) + { + case SQL_BIT: + { + BOOL& b = fld.BoolValue(); + RFX_Bool(pFX, fld.Name(), b); + if (bLoad) + { + if (b == FALSE || IsFieldFlagNull(nField, CFieldExchange::outputColumn)) + val.Empty(); + else + val = "X"; + } + } + break; + case SQL_CHAR: + case SQL_NUMERIC: + RFX_Text(pFX, fld.Name(), val); + break; + case SQL_DATE: + { + CTime& t = fld.TimeValue(); + RFX_Date(pFX, fld.Name(), t); + if (bLoad) + { + TIMESTAMP_STRUCT* pts = (TIMESTAMP_STRUCT*)m_pvFieldProxy[nField]; + if (pts->year == 0) + val.Empty(); + else + { + char* buf = val.GetBuffer(16); + sprintf(buf, "%02d-%02d-%04d", pts->day, pts->month, pts->year); + val.ReleaseBuffer(); + } + } + } + break; + case SQL_DOUBLE: + { + double& d = fld.DoubleValue(); + RFX_Double(pFX, fld.Name(), d); + if (bLoad) + { + if (d == 0.0 || IsFieldFlagNull(nField, CFieldExchange::outputColumn)) + { + val.Empty(); + } + else + { + char* buf = val.GetBuffer(32); + sprintf(buf, "%.12lg", d); + val.ReleaseBuffer(); + } + } + } + break; + default: + ASSERT(0); + break; + } + } +} + +void SESA_Recordset::DumpHeader(ostream& out) +{ + out << "[MAIN]" << endl + << "TYPEFIELD=-1" << endl + << "DECSEP=." << endl + << "FIELDSEP=|" << endl + << endl; + + out << "[RECORD]" << endl; + int num = 0; + for (POSITION pos = m_FieldList.GetHeadPosition(); pos; num++) + { + const SESA_Field& fld = m_FieldList.GetNext(pos); + out << "NAME(" << num << ") = " << fld.Name() << endl + << endl; + } +} + +void SESA_Recordset::ReadDumpList(const CString& strFile) +{ + char szField[16]; + char szName[16]; + char szFile[32]; + + // Mette .\ davanti al nome per cercare nella directory corrente, + // altrimenti lo cerca nella directory di Windows + sprintf(szFile, ".\\%s", strFile); + + for (int num = 0; ; num++) + { + sprintf(szField, "NAME(%d)", num); + GetPrivateProfileString("RECORD", szField, "", szName, sizeof(szName), szFile); + if (*szName) + m_DumpList.AddTail(szName); + else + break; + } +} + +void SESA_Recordset::DumpFields(ostream& out) +{ + if (m_DumpList.IsEmpty()) + { + int num = 0; + for (POSITION pos = m_FieldList.GetHeadPosition(); pos; num++) + { + SESA_Field& fld = m_FieldList.GetNext(pos); + if (num) out << '|'; + out << fld.StrValue(); + } + } + else + { + int num = 0; + for (POSITION npos = m_DumpList.GetHeadPosition(); npos; num++) + { + CString& strName = m_DumpList.GetNext(npos); + SESA_Field& fld = m_FieldList.Find(strName); + if (num) out << '|'; + out << fld.StrValue(); + } + } + + out << endl; +} + + +SESA_Recordset::SESA_Recordset(CDatabase* pDatabase) + : CRecordset(pDatabase) +{ } + +/////////////////////////////////////////////////////////// +// SESA functions +/////////////////////////////////////////////////////////// + +static BOOL UpdateODBCIni(LPCSTR szEntry, LPCSTR szDefault, BOOL bForce = FALSE) +{ + BOOL bWrite = bForce; + + if (!bForce) + { + char szBuffer[80]; + ::GetPrivateProfileString("SIGLAPP", szEntry, "", szBuffer, sizeof(szBuffer), "odbc.ini"); + bWrite = *szBuffer == '\0'; + } + + if (bWrite) + ::WritePrivateProfileString("SIGLAPP", szEntry, szDefault, "odbc.ini"); + + return bWrite; +} + +BOOL SESA_OpenDatabase(const char* lpszDSN, const char* lpszConnect) +{ + if (lpszDSN == NULL || *lpszDSN == '\0') + { + lpszDSN = "SIGLAPP"; + const char* SIGLAPP = getenv(lpszDSN); + if (SIGLAPP) + { + UpdateODBCIni("Driver", "simba.dll"); + UpdateODBCIni("Description", "Dati Comuni Sigla++"); + UpdateODBCIni("FileType", "FoxPro 2.5"); + UpdateODBCIni("DataDirectory", SIGLAPP, TRUE); + UpdateODBCIni("SingleUser", "False"); + } + } + if (lpszConnect == NULL || *lpszConnect == '\0') + lpszConnect = "ODBC;"; + + // DataSrc Excl ReadOnly ConnectString + BOOL ok = _db.Open(lpszDSN, FALSE, TRUE, lpszConnect); + if (!ok) + { + CString msg; + msg = "Can't connect to database "; + msg += lpszDSN; + msg += " using "; + msg += lpszConnect; + AfxMessageBox(msg, MB_OK | MB_ICONEXCLAMATION); + } + return ok; +} + +BOOL SESA_CloseDatabase() +{ + if (_db.IsOpen()) + _db.Close(); + return TRUE; +} + +BOOL SESA_DumpTable(const char* lpszTableName) +{ + const BOOL bWasOpen = _db.IsOpen(); + if (!bWasOpen) + { + BOOL bOk = SESA_OpenDatabase(); + if (!bOk) + return FALSE; + } + + SESA_Recordset rs(&_db); + BOOL ok = rs.Open(lpszTableName); + if (ok) + { + CString strName = _strWorkDir; + strName += lpszTableName; + strName += ".ini"; + + if (access(strName, 0x00) == 0) + { + rs.ReadDumpList(strName); + } + else + { + ofstream out(strName); + rs.DumpHeader(out); + } + + strName = _strWorkDir; + strName += lpszTableName; + strName += ".txt"; + ofstream out(strName); + while (!rs.IsEOF()) + { + rs.DumpFields(out); + rs.MoveNext(); + } + + RETCODE nRetCode; + AFX_SQL_SYNC(::SQLFreeStmt(rs.m_hstmt, SQL_CLOSE)); + } + else + { + CString msg; + msg = "Can't open table "; + msg += lpszTableName; + AfxMessageBox(msg, MB_OK | MB_ICONEXCLAMATION); + } + + if (!bWasOpen) + SESA_CloseDatabase(); + + return ok; +} + +BOOL SESA_WorkDir(const char* strDir) +{ + _strWorkDir = strDir; + _strWorkDir = _strWorkDir.SpanExcluding(" "); + const char& last = _strWorkDir[_strWorkDir.GetLength()-1]; + if (last != '\\' && last != '/') + _strWorkDir += "\\"; + return !_strWorkDir.IsEmpty(); +} diff --git a/ce/sesa.h b/ce/sesa.h new file mode 100755 index 000000000..a7026eb84 --- /dev/null +++ b/ce/sesa.h @@ -0,0 +1,4 @@ +BOOL SESA_WorkDir(const char* strDir); +BOOL SESA_OpenDatabase(const char* strDSN = NULL, const char* strConnect = NULL); +BOOL SESA_DumpTable(const char* strTableName); +BOOL SESA_CloseDatabase(); diff --git a/ce/sesaddoc.cpp b/ce/sesaddoc.cpp new file mode 100755 index 000000000..fd8454834 --- /dev/null +++ b/ce/sesaddoc.cpp @@ -0,0 +1,80 @@ +// sesaddoc.cpp : implementation of the CSesadumpDoc class +// + +#include "stdafx.h" +#include "sesadump.h" + +#include "sesaddoc.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char BASED_CODE THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CSesadumpDoc + +IMPLEMENT_DYNCREATE(CSesadumpDoc, CDocument) + +BEGIN_MESSAGE_MAP(CSesadumpDoc, CDocument) + //{{AFX_MSG_MAP(CSesadumpDoc) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CSesadumpDoc construction/destruction + +CSesadumpDoc::CSesadumpDoc() +{ + // TODO: add one-time construction code here +} + +CSesadumpDoc::~CSesadumpDoc() +{ +} + +BOOL CSesadumpDoc::OnNewDocument() +{ + if (!CDocument::OnNewDocument()) + return FALSE; + + // TODO: add reinitialization code here + // (SDI documents will reuse this document) + + return TRUE; +} + +///////////////////////////////////////////////////////////////////////////// +// CSesadumpDoc serialization + +void CSesadumpDoc::Serialize(CArchive& ar) +{ + if (ar.IsStoring()) + { + // TODO: add storing code here + } + else + { + // TODO: add loading code here + } +} + +///////////////////////////////////////////////////////////////////////////// +// CSesadumpDoc diagnostics + +#ifdef _DEBUG +void CSesadumpDoc::AssertValid() const +{ + CDocument::AssertValid(); +} + +void CSesadumpDoc::Dump(CDumpContext& dc) const +{ + CDocument::Dump(dc); +} +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CSesadumpDoc commands diff --git a/ce/sesaddoc.h b/ce/sesaddoc.h new file mode 100755 index 000000000..ad42e6be1 --- /dev/null +++ b/ce/sesaddoc.h @@ -0,0 +1,37 @@ +// sesaddoc.h : interface of the CSesadumpDoc class +// +///////////////////////////////////////////////////////////////////////////// + +class CSesadumpDoc : public CDocument +{ +protected: // create from serialization only + CSesadumpDoc(); + DECLARE_DYNCREATE(CSesadumpDoc) + +// Attributes +public: +// Operations +public: + +// Implementation +public: + virtual ~CSesadumpDoc(); + virtual void Serialize(CArchive& ar); // overridden for document i/o +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + virtual BOOL OnNewDocument(); + +// Generated message map functions +protected: + //{{AFX_MSG(CSesadumpDoc) + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// diff --git a/ce/sesadlg.cpp b/ce/sesadlg.cpp new file mode 100755 index 000000000..acdebda58 --- /dev/null +++ b/ce/sesadlg.cpp @@ -0,0 +1,48 @@ +// sesadlg.cpp : implementation file +// + +#include "stdafx.h" +#include + +#include "sesadump.h" +#include "sesadlg.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char BASED_CODE THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CSesaDlg dialog + + +CSesaDlg::CSesaDlg(CWnd* pParent /*=NULL*/) + : CDialog(CSesaDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CSesaDlg) + m_strDSN = "SIGLAPP"; + m_strConnect = "ODBC;"; + m_strTable = ""; + //}}AFX_DATA_INIT +} + +void CSesaDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CSesaDlg) + DDX_Text(pDX, IDC_DSN, m_strDSN); + DDX_Text(pDX, IDC_CONNECT, m_strConnect); + DDX_Text(pDX, IDC_TABLE, m_strTable); + DDV_MaxChars(pDX, m_strTable, 12); + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CSesaDlg, CDialog) + //{{AFX_MSG_MAP(CSesaDlg) + // NOTE: the ClassWizard will add message map macros here + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + + +///////////////////////////////////////////////////////////////////////////// +// CSesaDlg message handlers diff --git a/ce/sesadlg.h b/ce/sesadlg.h new file mode 100755 index 000000000..93b46dbec --- /dev/null +++ b/ce/sesadlg.h @@ -0,0 +1,30 @@ +// sesadlg.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CSesaDlg dialog + +class CSesaDlg : public CDialog +{ +// Construction +public: + CSesaDlg(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CSesaDlg) + enum { IDD = IDD_CONNECTION }; + CString m_strDSN; + CString m_strConnect; + CString m_strTable; + //}}AFX_DATA + +// Implementation +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + + // Generated message map functions + //{{AFX_MSG(CSesaDlg) + // NOTE: the ClassWizard will add member functions here + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; diff --git a/ce/sesadump.cpp b/ce/sesadump.cpp new file mode 100755 index 000000000..2297f27c6 --- /dev/null +++ b/ce/sesadump.cpp @@ -0,0 +1,147 @@ +// sesadump.cpp : Defines the class behaviors for the application. +// + +#include "stdafx.h" +#include "sesadump.h" + +#include "mainfrm.h" +#include "sesaddoc.h" +#include "sesadvw.h" +#include "sesa.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char BASED_CODE THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CSesadumpApp + +BEGIN_MESSAGE_MAP(CSesadumpApp, CWinApp) + //{{AFX_MSG_MAP(CSesadumpApp) + ON_COMMAND(ID_APP_ABOUT, OnAppAbout) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG_MAP + // Standard file based document commands + ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) + ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CSesadumpApp construction + +CSesadumpApp::CSesadumpApp() +{ + // TODO: add construction code here, + // Place all significant initialization in InitInstance +} + +///////////////////////////////////////////////////////////////////////////// +// The one and only CSesadumpApp object + +CSesadumpApp NEAR theApp; + +///////////////////////////////////////////////////////////////////////////// +// CSesadumpApp initialization + +BOOL CSesadumpApp::InitInstance() +{ + // Standard initialization + // If you are not using these features and wish to reduce the size + // of your final executable, you should remove from the following + // the specific initialization routines you do not need. + + SetDialogBkColor(); // Set dialog background color to gray + LoadStdProfileSettings(); // Load standard INI file options (including MRU) + + // Register the application's document templates. Document templates + // serve as the connection between documents, frame windows and views. + + CSingleDocTemplate* pDocTemplate; + pDocTemplate = new CSingleDocTemplate( + IDR_MAINFRAME, + RUNTIME_CLASS(CSesadumpDoc), + RUNTIME_CLASS(CMainFrame), // main SDI frame window + RUNTIME_CLASS(CSesadumpView)); + AddDocTemplate(pDocTemplate); + + if (m_lpCmdLine[0] != '\0') + { + CString strTable, strDir; + char* space = strchr(m_lpCmdLine, ' '); + if (space) + { + *space = '\0'; + strTable = m_lpCmdLine; + strDir = space+1; + *space = ' '; + } + else + { + strTable = m_lpCmdLine; + } + + SESA_WorkDir(strDir); + SESA_DumpTable(strTable); + + const UINT WM_WAKEUP = RegisterWindowMessage("WAKEUP"); + const HTASK ht = 0; // GetCurrentTask(); + PostMessage(HWND_BROADCAST, WM_WAKEUP, (WPARAM)ht, 0L); + + return FALSE; // Batch mode + } + + return TRUE; +} + +///////////////////////////////////////////////////////////////////////////// +// CAboutDlg dialog used for App About + +class CAboutDlg : public CDialog +{ +public: + CAboutDlg(); + +// Dialog Data + //{{AFX_DATA(CAboutDlg) + enum { IDD = IDD_ABOUTBOX }; + //}}AFX_DATA + +// Implementation +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //{{AFX_MSG(CAboutDlg) + // No message handlers + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) +{ + //{{AFX_DATA_INIT(CAboutDlg) + //}}AFX_DATA_INIT +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CAboutDlg) + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) + //{{AFX_MSG_MAP(CAboutDlg) + // No message handlers + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// App command to run the dialog +void CSesadumpApp::OnAppAbout() +{ + CAboutDlg aboutDlg; + aboutDlg.DoModal(); +} + +///////////////////////////////////////////////////////////////////////////// +// CSesadumpApp commands diff --git a/ce/sesadump.def b/ce/sesadump.def new file mode 100755 index 000000000..467fc3bca --- /dev/null +++ b/ce/sesadump.def @@ -0,0 +1,13 @@ +; sesadump.def : Declares the module parameters for the application. + +NAME SESADUMP +DESCRIPTION 'SESADUMP Windows Application' +EXETYPE WINDOWS + +CODE PRELOAD MOVEABLE DISCARDABLE +DATA PRELOAD MOVEABLE MULTIPLE + +HEAPSIZE 1024 ; initial heap size +; Stack size is passed as argument to linker's /STACK option + + diff --git a/ce/sesadump.h b/ce/sesadump.h new file mode 100755 index 000000000..ea1f7fe88 --- /dev/null +++ b/ce/sesadump.h @@ -0,0 +1,34 @@ +// sesadump.h : main header file for the SESADUMP application +// + +#ifndef __AFXWIN_H__ + #error include 'stdafx.h' before including this file for PCH +#endif + +#include "resource.h" // main symbols + +///////////////////////////////////////////////////////////////////////////// +// CSesadumpApp: +// See sesadump.cpp for the implementation of this class +// + +class CSesadumpApp : public CWinApp +{ +public: + CSesadumpApp(); + +// Overrides + virtual BOOL InitInstance(); + +// Implementation + + //{{AFX_MSG(CSesadumpApp) + afx_msg void OnAppAbout(); + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + + +///////////////////////////////////////////////////////////////////////////// diff --git a/ce/sesadump.ico b/ce/sesadump.ico new file mode 100755 index 000000000..b71839232 Binary files /dev/null and b/ce/sesadump.ico differ diff --git a/ce/sesadump.mak b/ce/sesadump.mak new file mode 100755 index 000000000..3c98c1bf2 --- /dev/null +++ b/ce/sesadump.mak @@ -0,0 +1,169 @@ +# Microsoft Visual C++ generated build script - Do not modify + +PROJ = SESADUMP +DEBUG = 1 +PROGTYPE = 0 +CALLER = +ARGS = ditte c:\temp\guy +DLLS = +D_RCDEFINES = /d_DEBUG +R_RCDEFINES = /dNDEBUG +ORIGIN = MSVC +ORIGIN_VER = 1.00 +PROJPATH = C:\U\GUY\SESADUMP\ +USEMFC = 1 +CC = cl +CPP = cl +CXX = cl +CCREATEPCHFLAG = +CPPCREATEPCHFLAG = /YcSTDAFX.H +CUSEPCHFLAG = +CPPUSEPCHFLAG = /YuSTDAFX.H +FIRSTC = +FIRSTCPP = STDAFX.CPP +RC = rc +CFLAGS_D_WEXE = /nologo /G2 /W3 /Zi /AL /Od /D "_DEBUG" /FR /GA /Fd"SESADUMP.PDB" +CFLAGS_R_WEXE = /nologo /Gs /G2 /W3 /AL /O1 /D "NDEBUG" /FR /GA +LFLAGS_D_WEXE = /NOLOGO /NOD /NOE /PACKC:61440 /STACK:10240 /ALIGN:16 /ONERROR:NOEXE /CO +LFLAGS_R_WEXE = /NOLOGO /NOD /PACKC:61440 /STACK:10240 /ALIGN:16 /ONERROR:NOEXE +LIBS_D_WEXE = lafxcwd oldnames libw llibcew commdlg.lib shell.lib +LIBS_R_WEXE = lafxcw oldnames libw llibcew commdlg.lib shell.lib +RCFLAGS = /nologo /z +RESFLAGS = /nologo /t +RUNFLAGS = +DEFFILE = SESADUMP.DEF +OBJS_EXT = +LIBS_EXT = ..\..\..\MSVC\LIB\ODBC.LIB +!if "$(DEBUG)" == "1" +CFLAGS = $(CFLAGS_D_WEXE) +LFLAGS = $(LFLAGS_D_WEXE) +LIBS = $(LIBS_D_WEXE) +MAPFILE = nul +RCDEFINES = $(D_RCDEFINES) +!else +CFLAGS = $(CFLAGS_R_WEXE) +LFLAGS = $(LFLAGS_R_WEXE) +LIBS = $(LIBS_R_WEXE) +MAPFILE = nul +RCDEFINES = $(R_RCDEFINES) +!endif +!if [if exist MSVC.BND del MSVC.BND] +!endif +SBRS = STDAFX.SBR \ + SESADUMP.SBR \ + MAINFRM.SBR \ + SESADDOC.SBR \ + SESADVW.SBR \ + SESA.SBR \ + COLUMNST.SBR \ + SESADLG.SBR + + +SESADUMP_RCDEP = c:\u\guy\sesadump\res\sesadump.ico \ + c:\u\guy\sesadump\res\sesadump.rc2 + + +STDAFX_DEP = c:\u\guy\sesadump\stdafx.h + + +SESADUMP_DEP = c:\u\guy\sesadump\stdafx.h \ + c:\u\guy\sesadump\sesadump.h \ + c:\u\guy\sesadump\mainfrm.h \ + c:\u\guy\sesadump\sesaddoc.h \ + c:\u\guy\sesadump\sesadvw.h + + +MAINFRM_DEP = c:\u\guy\sesadump\stdafx.h \ + c:\u\guy\sesadump\sesadump.h \ + c:\u\guy\sesadump\mainfrm.h + + +SESADDOC_DEP = c:\u\guy\sesadump\stdafx.h \ + c:\u\guy\sesadump\sesadump.h \ + c:\u\guy\sesadump\sesaddoc.h + + +SESADVW_DEP = c:\u\guy\sesadump\stdafx.h \ + c:\u\guy\sesadump\sesadump.h \ + c:\u\guy\sesadump\sesaddoc.h \ + c:\u\guy\sesadump\sesadvw.h + + +SESA_DEP = c:\u\guy\sesadump\stdafx.h \ + c:\u\guy\sesadump\columnst.h \ + c:\u\guy\sesadump\sesa.h + + +COLUMNST_DEP = c:\u\guy\sesadump\stdafx.h \ + c:\u\guy\sesadump\columnst.h + + +ODBC_DEP = + +all: $(PROJ).EXE $(PROJ).BSC + +SESADUMP.RES: SESADUMP.RC $(SESADUMP_RCDEP) + $(RC) $(RCFLAGS) $(RCDEFINES) -r SESADUMP.RC + +STDAFX.OBJ: STDAFX.CPP $(STDAFX_DEP) + $(CPP) $(CFLAGS) $(CPPCREATEPCHFLAG) /c STDAFX.CPP + +SESADUMP.OBJ: SESADUMP.CPP $(SESADUMP_DEP) + $(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c SESADUMP.CPP + +MAINFRM.OBJ: MAINFRM.CPP $(MAINFRM_DEP) + $(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c MAINFRM.CPP + +SESADDOC.OBJ: SESADDOC.CPP $(SESADDOC_DEP) + $(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c SESADDOC.CPP + +SESADVW.OBJ: SESADVW.CPP $(SESADVW_DEP) + $(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c SESADVW.CPP + +SESA.OBJ: SESA.CPP $(SESA_DEP) + $(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c SESA.CPP + +COLUMNST.OBJ: COLUMNST.CPP $(COLUMNST_DEP) + $(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c COLUMNST.CPP + +SESADLG.OBJ: SESADLG.CPP $(SESADLG_DEP) + $(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c SESADLG.CPP + + +$(PROJ).EXE:: SESADUMP.RES + +$(PROJ).EXE:: STDAFX.OBJ SESADUMP.OBJ MAINFRM.OBJ SESADDOC.OBJ SESADVW.OBJ SESA.OBJ \ + COLUMNST.OBJ SESADLG.OBJ $(OBJS_EXT) $(DEFFILE) + echo >NUL @<<$(PROJ).CRF +STDAFX.OBJ + +SESADUMP.OBJ + +MAINFRM.OBJ + +SESADDOC.OBJ + +SESADVW.OBJ + +SESA.OBJ + +COLUMNST.OBJ + +SESADLG.OBJ + +$(OBJS_EXT) +$(PROJ).EXE +$(MAPFILE) +c:\msvc\lib\+ +c:\msvc\mfc\lib\+ +..\..\..\MSVC\LIB\ODBC.LIB+ +$(LIBS) +$(DEFFILE); +<< + link $(LFLAGS) @$(PROJ).CRF + $(RC) $(RESFLAGS) SESADUMP.RES $@ + @copy $(PROJ).CRF MSVC.BND + +$(PROJ).EXE:: SESADUMP.RES + if not exist MSVC.BND $(RC) $(RESFLAGS) SESADUMP.RES $@ + +run: $(PROJ).EXE + $(PROJ) $(RUNFLAGS) + + +$(PROJ).BSC: $(SBRS) + bscmake @<< +/o$@ $(SBRS) +<< diff --git a/ce/sesadump.rc b/ce/sesadump.rc new file mode 100755 index 000000000..c07ecb603 --- /dev/null +++ b/ce/sesadump.rc @@ -0,0 +1,232 @@ +//Microsoft App Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +#ifdef APSTUDIO_INVOKED +////////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""sesadump.rc2"" // non-App Studio edited resources\r\n" + "\r\n" + "#include ""afxres.rc"" \011// Standard components\r\n" + "\0" +END + +///////////////////////////////////////////////////////////////////////////////////// +#endif // APSTUDIO_INVOKED + + +////////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +IDR_MAINFRAME ICON DISCARDABLE "SESADUMP.ICO" + +////////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_MAINFRAME MENU PRELOAD DISCARDABLE +BEGIN + POPUP "&File" + BEGIN + MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN + MENUITEM "&About Sesadump...", ID_APP_ABOUT + MENUITEM SEPARATOR + MENUITEM SEPARATOR + MENUITEM "E&xit", ID_APP_EXIT + END + POPUP "" + BEGIN + MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO + MENUITEM SEPARATOR + MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT + MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY + MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE + END +END + + +////////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE +BEGIN + "N", ID_FILE_NEW, VIRTKEY,CONTROL + "O", ID_FILE_OPEN, VIRTKEY,CONTROL + "S", ID_FILE_SAVE, VIRTKEY,CONTROL + "Z", ID_EDIT_UNDO, VIRTKEY,CONTROL + "X", ID_EDIT_CUT, VIRTKEY,CONTROL + "C", ID_EDIT_COPY, VIRTKEY,CONTROL + "V", ID_EDIT_PASTE, VIRTKEY,CONTROL + VK_BACK, ID_EDIT_UNDO, VIRTKEY,ALT + VK_DELETE, ID_EDIT_CUT, VIRTKEY,SHIFT + VK_INSERT, ID_EDIT_COPY, VIRTKEY,CONTROL + VK_INSERT, ID_EDIT_PASTE, VIRTKEY,SHIFT + VK_F6, ID_NEXT_PANE, VIRTKEY + VK_F6, ID_PREV_PANE, VIRTKEY,SHIFT +END + + +////////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOG DISCARDABLE 34, 22, 217, 55 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "About Sesadump" +FONT 8, "MS Sans Serif" +BEGIN + ICON IDR_MAINFRAME,IDC_STATIC,11,17,18,20 + LTEXT "Sesa Dump Application Version 1.0",IDC_STATIC,40,10,119, + 8 + LTEXT "Copyright \251 1997",IDC_STATIC,40,25,119,8 + DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP +END + +IDD_CONNECTION DIALOG DISCARDABLE 0, 0, 187, 76 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Connect to" +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "OK",IDOK,25,60,50,14 + PUSHBUTTON "Cancel",IDCANCEL,105,60,50,14 + EDITTEXT IDC_DSN,55,5,126,12,ES_AUTOHSCROLL + EDITTEXT IDC_CONNECT,55,25,126,12,ES_AUTOHSCROLL + LTEXT "Data source",IDC_STATIC,0,10,50,7 + LTEXT "Connection",IDC_STATIC,0,25,45,7 + LTEXT "Table",IDC_STATIC,0,45,45,7 + EDITTEXT IDC_TABLE,55,46,126,12,ES_AUTOHSCROLL +END + + +////////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE PRELOAD DISCARDABLE +BEGIN + IDR_MAINFRAME "Sesadump Windows Application\nSesadu\nSesadu Document\n\n\nSesadu.Document\nSesadu Document" +END + +STRINGTABLE PRELOAD DISCARDABLE +BEGIN + AFX_IDS_APP_TITLE "Sesadump Windows Application" + AFX_IDS_IDLEMESSAGE "Ready" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_INDICATOR_EXT "EXT" + ID_INDICATOR_CAPS "CAP" + ID_INDICATOR_NUM "NUM" + ID_INDICATOR_SCRL "SCRL" + ID_INDICATOR_OVR "OVR" + ID_INDICATOR_REC "REC" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_FILE_NEW "Create a new document" + ID_FILE_OPEN "Open an existing document" + ID_FILE_CLOSE "Close the active document" + ID_FILE_SAVE "Save the active document" + ID_FILE_SAVE_AS "Save the active document with a new name" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_APP_ABOUT "Display program information, version number and copyright" + ID_APP_EXIT "Quit the application; prompts to save documents" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_FILE_MRU_FILE1 "Open this document" + ID_FILE_MRU_FILE2 "Open this document" + ID_FILE_MRU_FILE3 "Open this document" + ID_FILE_MRU_FILE4 "Open this document" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_NEXT_PANE "Switch to the next window pane" + ID_PREV_PANE "Switch back to the previous window pane" +END + +STRINGTABLE DISCARDABLE +BEGIN + ID_EDIT_CLEAR "Erase the selection" + ID_EDIT_CLEAR_ALL "Erase everything" + ID_EDIT_COPY "Copy the selection and put it on the Clipboard" + ID_EDIT_CUT "Cut the selection and put it on the Clipboard" + ID_EDIT_FIND "Find the specified text" + ID_EDIT_PASTE "Insert Clipboard contents" + ID_EDIT_REPEAT "Repeat the last action" + ID_EDIT_REPLACE "Replace specific text with different text" + ID_EDIT_SELECT_ALL "Select the entire document" + ID_EDIT_UNDO "Undo the last action" + ID_EDIT_REDO "Redo the previously undone action" +END + +STRINGTABLE DISCARDABLE +BEGIN + AFX_IDS_SCSIZE "Change the window size" + AFX_IDS_SCMOVE "Change the window position" + AFX_IDS_SCMINIMIZE "Reduce the window to an icon" + AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" + AFX_IDS_SCNEXTWINDOW "Switch to the next document window" + AFX_IDS_SCPREVWINDOW "Switch to the previous document window" + AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents" +END + +STRINGTABLE DISCARDABLE +BEGIN + AFX_IDS_SCRESTORE "Restore the window to normal size" + AFX_IDS_SCTASKLIST "Activate Task List" +END + + +#ifndef APSTUDIO_INVOKED +//////////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +#include "sesadump.rc2" // non-App Studio edited resources + +#include "afxres.rc" // Standard components + +///////////////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/ce/sesadump.rc2 b/ce/sesadump.rc2 new file mode 100755 index 000000000..9ffe67ae6 --- /dev/null +++ b/ce/sesadump.rc2 @@ -0,0 +1,52 @@ +// +// SESADUMP.RC2 - resources App Studio does not edit directly +// + +#ifdef APSTUDIO_INVOKED + #error this file is not editable by App Studio +#endif //APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// Version stamp for this .EXE + +#include "ver.h" + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG|VS_FF_PRIVATEBUILD|VS_FF_PRERELEASE +#else + FILEFLAGS 0 // final version +#endif + FILEOS VOS_DOS_WINDOWS16 + FILETYPE VFT_APP + FILESUBTYPE 0 // not used +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" // Lang=US English, CharSet=Windows Multilingual + BEGIN + VALUE "CompanyName", "\0" + VALUE "FileDescription", "SESADUMP MFC Application\0" + VALUE "FileVersion", "1.0.001\0" + VALUE "InternalName", "SESADUMP\0" + VALUE "LegalCopyright", "\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename","SESADUMP.EXE\0" + VALUE "ProductName", "SESADUMP\0" + VALUE "ProductVersion", "1.0.001\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + // English language (0x409) and the Windows ANSI codepage (1252) + END +END + +///////////////////////////////////////////////////////////////////////////// +// Add additional manually edited resources here... + +///////////////////////////////////////////////////////////////////////////// diff --git a/ce/sesadvw.cpp b/ce/sesadvw.cpp new file mode 100755 index 000000000..76a718c06 --- /dev/null +++ b/ce/sesadvw.cpp @@ -0,0 +1,72 @@ +// sesadvw.cpp : implementation of the CSesadumpView class +// + +#include "stdafx.h" +#include "sesadump.h" + +#include "sesaddoc.h" +#include "sesadvw.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char BASED_CODE THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CSesadumpView + +IMPLEMENT_DYNCREATE(CSesadumpView, CView) + +BEGIN_MESSAGE_MAP(CSesadumpView, CView) + //{{AFX_MSG_MAP(CSesadumpView) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CSesadumpView construction/destruction + +CSesadumpView::CSesadumpView() +{ + // TODO: add construction code here +} + +CSesadumpView::~CSesadumpView() +{ +} + +///////////////////////////////////////////////////////////////////////////// +// CSesadumpView drawing + +void CSesadumpView::OnDraw(CDC* pDC) +{ + CSesadumpDoc* pDoc = GetDocument(); + ASSERT_VALID(pDoc); + + // TODO: add draw code for native data here +} + +///////////////////////////////////////////////////////////////////////////// +// CSesadumpView diagnostics + +#ifdef _DEBUG +void CSesadumpView::AssertValid() const +{ + CView::AssertValid(); +} + +void CSesadumpView::Dump(CDumpContext& dc) const +{ + CView::Dump(dc); +} + +CSesadumpDoc* CSesadumpView::GetDocument() // non-debug version is inline +{ + ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSesadumpDoc))); + return (CSesadumpDoc*)m_pDocument; +} +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CSesadumpView message handlers diff --git a/ce/sesadvw.h b/ce/sesadvw.h new file mode 100755 index 000000000..b144b9550 --- /dev/null +++ b/ce/sesadvw.h @@ -0,0 +1,43 @@ +// sesadvw.h : interface of the CSesadumpView class +// +///////////////////////////////////////////////////////////////////////////// + +class CSesadumpView : public CView +{ +protected: // create from serialization only + CSesadumpView(); + DECLARE_DYNCREATE(CSesadumpView) + +// Attributes +public: + CSesadumpDoc* GetDocument(); + +// Operations +public: + +// Implementation +public: + virtual ~CSesadumpView(); + virtual void OnDraw(CDC* pDC); // overridden to draw this view +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// Generated message map functions +protected: + //{{AFX_MSG(CSesadumpView) + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +#ifndef _DEBUG // debug version in sesadvw.cpp +inline CSesadumpDoc* CSesadumpView::GetDocument() + { return (CSesadumpDoc*)m_pDocument; } +#endif + +///////////////////////////////////////////////////////////////////////////// diff --git a/ce/stdafx.cpp b/ce/stdafx.cpp new file mode 100755 index 000000000..07f7b469e --- /dev/null +++ b/ce/stdafx.cpp @@ -0,0 +1,5 @@ +// stdafx.cpp : source file that includes just the standard includes +// stdafx.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" diff --git a/ce/stdafx.h b/ce/stdafx.h new file mode 100755 index 000000000..a0a602ee1 --- /dev/null +++ b/ce/stdafx.h @@ -0,0 +1,9 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#include // MFC core and standard components +#include // MFC extensions +#include // MFC collections +#include // MFC ODBC classes