123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- /*************************************************************
- /* Copyright (C), 2014-2020, lyfz. Co., Ltd.
- /* 文件名: 当前控制台
- /* 作者: Jeff.w
- /* 创建日期: 2014-08-22
- /* 版本号: V1.0
- /* 描述: 统一升级包
- /* 其它:
- /* 主要类模块:
- /* 历史修改记录:
- /* 作者 时间 版本 描述
- /* Jeff.w 14/08/18 1.0 创建这个模块
- /*
- /* 已实现:
- /* 1.根据加密狗信息自动判断是否Enterprise版本来升级相应的资源;
- /* 2.需要添加加密狗的支持功能;
- ***************************************************************/
- // lyfzUpgrade.cpp : 定义控制台应用程序的入口点。
- //
- #include "stdafx.h"
- #include "lyfzUpgrade.h"
- #include "Executor.h"
- #include "my32.h"
- #include "SQLStatementImpl.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- typedef struct __STVERSION__
- {
- int nVersion;
- CString strVersion;
- }STVersion, *pSTVersion;
- STVersion g_stVersion[6] =
- {
- { 0, _T("儿童座席版") },
- { 1, _T("婚纱座席版") },
- { 2, _T("儿童企业版") },
- { 3, _T("婚纱企业版") },
- { 4, _T("儿童全能版") },
- { 5, _T("婚纱全能版") }
- };
- // 唯一的应用程序对象
- CWinApp theApp;
- using namespace std;
- int MyTest()
- {
- FindAndCloseProcess(_T("E:\\lyfzbin\\Services\\lyfzServices.exe"));
- return 0;
- CSQLStatementImpl::GetInstancePtr()->ReSetKind(_T("dindan"), _T("where id='120456465465'"), KIND_UPDATE, 10);
- CSQLStatementImpl::GetInstancePtr()->AddElement(_T("satisfaction1"),1);
- CSQLStatementImpl::GetInstancePtr()->AddElement(_T("satisfaction2"),2);
- CSQLStatementImpl::GetInstancePtr()->AddElement(_T("satisfaction3"),3);
- CSQLStatementImpl::GetInstancePtr()->AddElement(_T("satisfaction4"),4);
- CSQLStatementImpl::GetInstancePtr()->AddElement(_T("satisfaction5"), 5);
- CSQLStatementImpl::GetInstancePtr()->AddElement(_T("satisfaction6"), 6);
- CSQLStatementImpl::GetInstancePtr()->AddElement(_T("satisfaction7"), 7);
- CSQLStatementImpl::GetInstancePtr()->AddElement(_T("satisfaction8"), 8);
- CSQLStatementImpl::GetInstancePtr()->AddElement(_T("bz5"), _T("22333"));
- CString sql = CSQLStatementImpl::GetInstancePtr()->ReturnSQL();
- return 0;
- }
- int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
- {
- int nRetCode = 0;
- //return MyTest();
- // 获取升级的文件版本;
- //GetFileVersion(NULL, g_arrFileVersion);
- GetProductVersion((HMODULE)NULL, g_arrFileVersion);
- // 对进程提权;
- GetDebugPriv();
- // 初始化 MFC 并在失败时显示错误
- if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
- {
- _tprintf(_T("错误: MFC 初始化失败\n"));
- nRetCode = 1;
- }
- else
- {
- HANDLE hObject = CreateMutex(NULL, FALSE, _T("lyfzUpgradeRuning"));
- if (GetLastError() == ERROR_ALREADY_EXISTS)
- {
- #ifdef USE_CONSOLE
- AfxMessageBox(_T("升级程序已启动!"));
- #else
- _tprintf(_T("升级程序已启动\n"));
- #endif
- return false;
- }
- // 1.加载配置文件;
- if (GetIniInfo() == -1)
- {
- #ifdef USE_CONSOLE
- AfxMessageBox(_T("没有找到ServiceInof.ini文件,请修改默认生成的ServiceInof.ini后重新更新!"));
- #else
- _tprintf(_T("没有找到ServiceInof.ini文件,请修改默认生成的ServiceInof.ini后重新更新\n"));
- #endif
- TCHAR szExecuteFile[MAX_PATH] = _T("");
- _stprintf_s(szExecuteFile, _T("%sServiceInfo.ini"), g_ModulePath);
- CExecutor::UpdateFile(ServiceInfo, _T("INI"), szExecuteFile);
- return -1;
- }
- // 2.预留第二步:获取加密狗信息,以判断是否升级为相信的版本;
- /*
- int nVersion = GetSoftWareVersion();
- if (nVersion == -1)
- {
- #ifdef USE_CONSOLE
- AfxMessageBox(_T("未找到加密狗,程序退出……!"));
- #else
- _tprintf(_T("未找到加密狗,程序退出……\n"));
- #endif
- return -1;
- }
- else
- {
- #ifdef USE_CONSOLE
- AfxMessageBox(g_stVersion[g_nVersion].strVersion);
- #else
- _tprintf(_T("当前版:%s\n"), g_stVersion[g_nVersion].strVersion);
- #endif
- }*/
- #ifdef USE_CONSOLE
- //AfxMessageBox(_T("升级完成后会提示 '升级成功' 如没有提示,请重启电脑后再次安装!"));
- #else
- _tprintf(_T("升级完成后会提示 '升级成功' 如没有提示,请重启电脑后再次安装!\n"));
- #endif
- TCHAR szDealFile[MAX_PATH] = _T("");
- _stprintf_s(szDealFile, _T("%s\\日志.txt"), g_ModulePath);
- lyfzCopyFileEx(szDealFile,szDealFile,TRUE);
- ::DeleteFile(szDealFile);
- _stprintf_s(szDealFile, _T("%s\\升级包日志.txt"), g_ModulePath);
- ::DeleteFile(szDealFile);
- // 3.执行更新;
- CExecutor tagExecutor;
- #if 1
- if (tagExecutor.ConnectDatabase() == -1)
- return 0;
- // if (tagExecutor.UpgradeSQL() == -1)
- // return AfxMessageBox(_T("数据库升级失败"));
- // else
- // AfxMessageBox(_T("数据库升级成功"));
- #endif
- tagExecutor.InitMaster();
- //AfxMessageBox(_T("查看有无订单相片记录张数不符情况"));
- //tagExecutor.VerifyCurrentNoQuestion();
- //AfxMessageBox(_T("结束查看订单相片记录张数不符情况"));
- if (tagExecutor.UpgradeExe(FALSE) == -1)
- return 0;
- //AfxMessageBox(_T("更新文件成功"));
- //AfxMessageBox(_T("结束数据库连接"));
- tagExecutor.DisConnectDatabase();
- }
- return nRetCode;
- }
|