zc2lyfz.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. // zc2lyfz.cpp : Defines the entry point for the console application.
  2. //
  3. #include "stdafx.h"
  4. #include "zc2lyfz.h"
  5. #ifdef _DEBUG
  6. #define new DEBUG_NEW
  7. #undef THIS_FILE
  8. static char THIS_FILE[] = __FILE__;
  9. #endif
  10. /////////////////////////////////////////////////////////////////////////////
  11. // The one and only application object
  12. CWinApp theApp;
  13. using namespace std;
  14. int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
  15. {
  16. int nRetCode = 0;
  17. // initialize MFC and print and error on failure
  18. if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
  19. {
  20. // TODO: change error code to suit your needs
  21. cerr << _T("Fatal Error: MFC initialization failed") << endl;
  22. nRetCode = 1;
  23. }
  24. else
  25. {
  26. // TODO: code your application's behavior here.
  27. CString strHello = "智城数据 转换 利亚方舟数据";
  28. cout << (LPCTSTR)strHello << endl;
  29. // 读取配置;
  30. GetIniInfo();
  31. // 打开数据库;
  32. if ( OpenDatabase(g_szDBSource, g_szDBServerPort, g_szDBAccount, g_szDBPassWord, g_szDBName) )
  33. {
  34. cout << "打开数据库成功!" << endl;
  35. // 创建version表;
  36. if ( IsTableExists("version") )
  37. {
  38. cout << "#version表存在!" << endl;
  39. }
  40. else
  41. {
  42. cout << "#version表不存在,即将创建!" << endl;
  43. if (g_pDBPtr)
  44. {
  45. try {
  46. g_pDBPtr->ExecuteSQL(g_sqlVerion.c_str());
  47. cout << "#创建version表成功!" << endl;
  48. }
  49. catch(CDBException* e)
  50. {
  51. cout << "#创建version表失败!" << e->m_strError << endl;
  52. }
  53. }
  54. g_pDBPtr->ExecuteSQL("insert into version(version) values('666')");
  55. }
  56. if ( IsTableExists("NetShareInfo") )
  57. {
  58. cout << "#NetShareInfo表存在!" << endl;
  59. }
  60. else
  61. {
  62. cout << "#NetShareInfo表不存在,即将创建!" << endl;
  63. if (g_pDBPtr)
  64. {
  65. try {
  66. g_pDBPtr->ExecuteSQL(g_sqlNetshare.c_str());
  67. cout << "#创建NetShareInfo表成功!" << endl;
  68. }
  69. catch(CDBException* e)
  70. {
  71. cout << "#创建NetShareInfo表失败!" << e->m_strError << endl;
  72. }
  73. }
  74. }
  75. 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");
  76. 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");
  77. 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");
  78. 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");
  79. cout << "设置所有用户密码为1234" << endl;
  80. g_pDBPtr->ExecuteSQL("update [user] set psw = '81dc9bdb52d04dc20036dbd8313ed055'");
  81. // 获取zc数据;
  82. vector<zcdata> zc;
  83. getzcdata(zc);
  84. cout << "#获取zc数据:" << zc.size() << "条\n" << endl;
  85. if ( zc.size() == 0 )
  86. {
  87. cout << "没有数据可以转换!" << endl;
  88. goto end;
  89. }
  90. int i = 0;
  91. bool ischild = false;
  92. char _cin = 'n';
  93. cout << "是否儿童版本,是(y),否(任意字符):" << endl;
  94. cin >> _cin;
  95. ischild = _cin == 'y' ? true: false;
  96. cout << "开始转换数据" << endl;
  97. for ( vector<zcdata>::iterator it = zc.begin(); it != zc.end(); it++ )
  98. {
  99. zc2lyfz(*it, ischild);
  100. cout << "第:" << ++i << "条" << endl;
  101. }
  102. }
  103. else
  104. {
  105. cout << "#打开数据库失败, 请查看配置是否正确" << endl;
  106. }
  107. }
  108. end:
  109. system("pause");
  110. return nRetCode;
  111. }