// zc2lyfz.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "zc2lyfz.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // The one and only application object CWinApp theApp; using namespace std; int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) { int nRetCode = 0; // initialize MFC and print and error on failure if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) { // TODO: change error code to suit your needs cerr << _T("Fatal Error: MFC initialization failed") << endl; nRetCode = 1; } else { // TODO: code your application's behavior here. CString strHello = "智城数据 转换 利亚方舟数据"; cout << (LPCTSTR)strHello << endl; // 读取配置; GetIniInfo(); // 打开数据库; if ( OpenDatabase(g_szDBSource, g_szDBServerPort, g_szDBAccount, g_szDBPassWord, g_szDBName) ) { cout << "打开数据库成功!" << endl; // 创建version表; if ( IsTableExists("version") ) { cout << "#version表存在!" << endl; } else { cout << "#version表不存在,即将创建!" << endl; if (g_pDBPtr) { try { g_pDBPtr->ExecuteSQL(g_sqlVerion.c_str()); cout << "#创建version表成功!" << endl; } catch(CDBException* e) { cout << "#创建version表失败!" << e->m_strError << endl; } } g_pDBPtr->ExecuteSQL("insert into version(version) values('666')"); } if ( IsTableExists("NetShareInfo") ) { cout << "#NetShareInfo表存在!" << endl; } else { cout << "#NetShareInfo表不存在,即将创建!" << endl; if (g_pDBPtr) { try { g_pDBPtr->ExecuteSQL(g_sqlNetshare.c_str()); cout << "#创建NetShareInfo表成功!" << endl; } catch(CDBException* e) { cout << "#创建NetShareInfo表失败!" << e->m_strError << endl; } } } g_pDBPtr->ExecuteSQL("IF NOT EXISTS(select name FROM syscolumns WHERE id=object_id('dindan') AND name='xplrr') ALTER TABLE [dbo].[dindan] ADD [xplrr][nvarchar](50) NULL"); g_pDBPtr->ExecuteSQL("IF NOT EXISTS(select name FROM syscolumns WHERE id=object_id('dindan') AND name='xplrtime') ALTER TABLE [dbo].[dindan] ADD [xplrtime][nvarchar](50) NULL"); g_pDBPtr->ExecuteSQL("IF NOT EXISTS(select name FROM syscolumns WHERE id=object_id('shangpin') AND name='width') ALTER TABLE [dbo].[shangpin] ADD [width][nvarchar](16) NULL"); g_pDBPtr->ExecuteSQL("IF NOT EXISTS(select name FROM syscolumns WHERE id=object_id('shangpin') AND name='height') ALTER TABLE [dbo].[shangpin] ADD [height][nvarchar](16) NULL"); cout << "设置所有用户密码为1234" << endl; g_pDBPtr->ExecuteSQL("update [user] set psw = '81dc9bdb52d04dc20036dbd8313ed055'"); // 获取zc数据; vector zc; getzcdata(zc); cout << "#获取zc数据:" << zc.size() << "条\n" << endl; if ( zc.size() == 0 ) { cout << "没有数据可以转换!" << endl; goto end; } int i = 0; bool ischild = false; char _cin = 'n'; cout << "是否儿童版本,是(y),否(任意字符):" << endl; cin >> _cin; ischild = _cin == 'y' ? true: false; cout << "开始转换数据" << endl; for ( vector::iterator it = zc.begin(); it != zc.end(); it++ ) { zc2lyfz(*it, ischild); cout << "第:" << ++i << "条" << endl; } } else { cout << "#打开数据库失败, 请查看配置是否正确" << endl; } } end: system("pause"); return nRetCode; }