123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- // 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<zcdata> 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<zcdata>::iterator it = zc.begin(); it != zc.end(); it++ )
- {
- zc2lyfz(*it, ischild);
- cout << "第:" << ++i << "条" << endl;
- }
- }
- else
- {
- cout << "#打开数据库失败, 请查看配置是否正确" << endl;
- }
- }
- end:
- system("pause");
-
- return nRetCode;
- }
|