a
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,189 @@
|
||||
// DetcGD10Dev.cpp: implementation of the CDetcGD10Dev class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "geomative.h"
|
||||
#include "DetcGD10Dev.h"
|
||||
#include <sys/stat.h>
|
||||
#include "GD10OperCmd.h"
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
#define GD10DEVICE _T("GD20")
|
||||
extern SYSTEMTIME g_sysCurTime;
|
||||
extern int g_iUILanguage;
|
||||
extern CGeoMativeApp theApp;
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
CDetcGD10Dev* CDetcGD10Dev::m_pDetcDev = NULL;
|
||||
CDetcGD10Dev::CDetcGD10Dev()
|
||||
{
|
||||
m_bGD10DevIsCon = false;
|
||||
m_strDevAddr = _T("");
|
||||
m_pLogFile = NULL;
|
||||
m_pLogFile = fopen("LOG\\detect_gd20_log.txt","ab+");
|
||||
if (NULL == m_pLogFile)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("打开 detect_gd20_log.txt 失败."));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Open detect_gd20_log.txt failed!!!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
CDetcGD10Dev::~CDetcGD10Dev()
|
||||
{
|
||||
fclose(m_pLogFile);
|
||||
m_pLogFile = NULL;
|
||||
|
||||
}
|
||||
|
||||
CDetcGD10Dev* CDetcGD10Dev::GetInstance()
|
||||
{
|
||||
if (NULL == m_pDetcDev)
|
||||
{
|
||||
m_pDetcDev = new CDetcGD10Dev();
|
||||
}
|
||||
return m_pDetcDev;
|
||||
}
|
||||
|
||||
CString CDetcGD10Dev::GetGD10DevAddr()
|
||||
{
|
||||
return m_strDevAddr;
|
||||
}
|
||||
|
||||
void CDetcGD10Dev::DetectGD10Dev()
|
||||
{
|
||||
m_strDevAddr.Empty();
|
||||
PrintLog(_T("Now is ready to find gd20-device!"));
|
||||
CString strDevName = (EN_MULTI_CHANNEL == theApp.m_ucIsMultiChannel) ? GD10DEVICE : _T("GD10");
|
||||
m_strDevAddr = FindUsbDevice(strDevName);
|
||||
m_bGD10DevIsCon = m_strDevAddr.IsEmpty() ? false : true;
|
||||
}
|
||||
|
||||
bool CDetcGD10Dev::CompareDriverName(CString strDriName,CString strDriverAddr)
|
||||
{
|
||||
bool bRes = false;
|
||||
if (strDriverAddr.IsEmpty())
|
||||
{
|
||||
PrintLog(_T("Driver address can not be empty!"));
|
||||
return bRes;
|
||||
}
|
||||
|
||||
TCHAR chVolName[MAX_PATH+1];
|
||||
TCHAR chFileSys[MAX_PATH+1];
|
||||
memset(chVolName, 0, sizeof(TCHAR)*(MAX_PATH+1));
|
||||
memset(chFileSys, 0, sizeof(TCHAR)*(MAX_PATH+1));
|
||||
CString strText = _T("");
|
||||
if (0 == GetVolumeInformation(strDriverAddr,chVolName,MAX_PATH+1,NULL,NULL,NULL,chFileSys,MAX_PATH+1))
|
||||
{
|
||||
strText.Format(_T("Get Volume Information failed, errorno = %d"),GetLastError());
|
||||
PrintLog(strText);
|
||||
}
|
||||
else
|
||||
{
|
||||
CString strVal = chVolName;
|
||||
strText.Empty();
|
||||
strText.Format(_T("Get Volume Information success, volume_name = %s"),strVal);
|
||||
bRes = (0 == strVal.Compare(strDriName)) ? true : false;
|
||||
}
|
||||
return bRes;
|
||||
}
|
||||
|
||||
|
||||
CString CDetcGD10Dev::FindUsbDevice(CString strDevName)
|
||||
{
|
||||
UINT DiskType;
|
||||
CString strLog;
|
||||
CString strText = _T("");
|
||||
CString strDir = _T("");
|
||||
size_t szAllDriveStrings = GetLogicalDriveStrings(0,NULL);
|
||||
if (0 == szAllDriveStrings)
|
||||
{
|
||||
ASSERT(0 == szAllDriveStrings);
|
||||
return strDir;
|
||||
}
|
||||
|
||||
char *pDriveStrings = new char[szAllDriveStrings + sizeof(_T( " "))];
|
||||
char *pAddr = pDriveStrings;
|
||||
GetLogicalDriveStrings(szAllDriveStrings,pDriveStrings);
|
||||
size_t szDriveString = strlen(pDriveStrings);
|
||||
while(szDriveString > 0)
|
||||
{
|
||||
DiskType=GetDriveType(pDriveStrings);
|
||||
switch(DiskType)
|
||||
{
|
||||
case DRIVE_REMOVABLE:
|
||||
{
|
||||
strDir.Empty();
|
||||
strDir.Format(_T("%s"),pDriveStrings);
|
||||
strText.Empty();
|
||||
strText.Format(_T("detect removable drive(%s), ready to parser device"),strDir);
|
||||
PrintLog(strText);
|
||||
//如果名字相等则认为匹配成功
|
||||
if (CompareDriverName(strDevName, strDir))
|
||||
{
|
||||
delete[]pAddr;
|
||||
return strDir;
|
||||
}
|
||||
else
|
||||
{
|
||||
//规避有的电脑怎么改,u盘都不是GD10/GD20的问题 by quyx 20180517 //"\SD\equipment\equipment.xml"
|
||||
struct _stat fileStat;
|
||||
CString str = "\SD\\equipment";
|
||||
CString strPath = strDir + str;
|
||||
if ((_stat(strPath.GetBuffer(0), &fileStat) == 0) && (fileStat.st_mode & _S_IFDIR))
|
||||
{
|
||||
delete[]pAddr;
|
||||
return strDir;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case DRIVE_FIXED:
|
||||
break;
|
||||
case DRIVE_REMOTE:
|
||||
break;
|
||||
case DRIVE_CDROM:
|
||||
break;
|
||||
case DRIVE_NO_ROOT_DIR:
|
||||
{
|
||||
strText.Empty();
|
||||
strText.Format(_T("Unknow driver string (%s)"),pDriveStrings);
|
||||
MessageBoxEx(NULL, strText, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
break;
|
||||
// return _T("");
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
pDriveStrings += szDriveString + 1;
|
||||
szDriveString = strlen(pDriveStrings);
|
||||
}
|
||||
delete []pAddr;
|
||||
return _T("");
|
||||
|
||||
}
|
||||
|
||||
void CDetcGD10Dev::PrintLog(CString strLog)
|
||||
{
|
||||
if (NULL == m_pLogFile)
|
||||
{
|
||||
MessageBox(NULL, "can't write device_log, log File point is NULL", "LOG_ERROR", MB_OK);
|
||||
return;
|
||||
}
|
||||
CString strOutPut = _T("");
|
||||
strOutPut.Format(_T("%04d-%02d-%02d %02d:%02d:%02d.%03d %s \r\n"),g_sysCurTime.wYear, g_sysCurTime.wMonth, g_sysCurTime.wDay,
|
||||
g_sysCurTime.wHour, g_sysCurTime.wMinute, g_sysCurTime.wSecond, g_sysCurTime.wMilliseconds, strLog.GetBuffer(0));
|
||||
fwrite(strOutPut.GetBuffer(0), 1, strOutPut.GetLength(), m_pLogFile);
|
||||
fflush(m_pLogFile);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,757 @@
|
||||
// DialCustomSptInput.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "geomative.h"
|
||||
#include "DialCustomSptInput.h"
|
||||
#include "CustomSptQueryDial.h"
|
||||
#include "excel.h"
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
using namespace excel9;
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDialCustomSptInput dialog
|
||||
extern HHOOK hHook;
|
||||
extern LRESULT __stdcall CBTHookProc(long nCode, WPARAM wParam, LPARAM lParam);
|
||||
extern bool bIsPostiveInteger(CString strTxt);
|
||||
extern bool bIsFloat(CString strTxt);
|
||||
extern int g_iUILanguage;
|
||||
//extern CString CovertVarToCString(const VARIANT& vtVal);
|
||||
CDialCustomSptInput::CDialCustomSptInput(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CDialCustomSptInput::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CDialCustomSptInput)
|
||||
m_strA = _T("");
|
||||
m_strB = _T("");
|
||||
m_strStacking = _T("1");
|
||||
m_strK = _T("");
|
||||
m_strLayer = _T("");
|
||||
m_strM = _T("");
|
||||
m_strN = _T("");
|
||||
//}}AFX_DATA_INIT
|
||||
m_iA = 0;
|
||||
m_iB = 0;
|
||||
m_iM = 0;
|
||||
m_iN = 0;
|
||||
m_iLayer = 0;
|
||||
m_iIteration = 1;
|
||||
m_fK = 0;
|
||||
m_iTsn = 0;
|
||||
// pComApp = NULL;
|
||||
}
|
||||
|
||||
|
||||
void CDialCustomSptInput::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CDialCustomSptInput)
|
||||
DDX_Control(pDX, IDC_LIST_CUSTOM_SPT, m_listCustomSpt);
|
||||
DDX_Text(pDX, IDC_EDIT_CUSTOMSPT_A, m_strA);
|
||||
DDX_Text(pDX, IDC_EDIT_CUSTOMSPT_B, m_strB);
|
||||
DDX_Text(pDX, IDC_EDIT_CUSTOMSPT_ITERATION, m_strStacking);
|
||||
DDX_Text(pDX, IDC_EDIT_CUSTOMSPT_K, m_strK);
|
||||
DDX_Text(pDX, IDC_EDIT_CUSTOMSPT_LAYER, m_strLayer);
|
||||
DDX_Text(pDX, IDC_EDIT_CUSTOMSPT_M, m_strM);
|
||||
DDX_Text(pDX, IDC_EDIT_CUSTOMSPT_N, m_strN);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CDialCustomSptInput, CDialog)
|
||||
//{{AFX_MSG_MAP(CDialCustomSptInput)
|
||||
ON_BN_CLICKED(IDC_BUTTON_ADD_LIST, OnButtonAddList)
|
||||
ON_BN_CLICKED(IDC_BUTTON_DEL_LIST, OnButtonDelList)
|
||||
ON_BN_CLICKED(IDC_BUTTON_MODIFY_LIST, OnButtonModifyList)
|
||||
ON_NOTIFY(NM_CLICK, IDC_LIST_CUSTOM_SPT, OnClickListCustomSpt)
|
||||
ON_BN_CLICKED(IDC_RADIO_HAND_INPUT, OnRadioHandInput)
|
||||
ON_BN_CLICKED(IDC_RADIO_AUTO_CALC, OnRadioAutoCalc)
|
||||
ON_BN_CLICKED(IDC_BUTTON_IMPORT, OnButtonImport)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDialCustomSptInput message handlers
|
||||
|
||||
void CDialCustomSptInput::OnButtonAddList()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
if (!CheckInputIsValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (0 == m_iA || 0 == m_iB || 0 == m_iM || 0 == m_iN)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("A,B,M,N的值不能为零!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("The value of A,B,M,N cannot be zero!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
if (m_iLayer < 1)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("层数值错误!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Layer's value error!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
if (!CalculateK())
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_iTsn++;
|
||||
|
||||
CString szLabel = _T("");
|
||||
int iRecIndex = m_listCustomSpt.GetItemCount();
|
||||
|
||||
m_listCustomSpt.InsertItem(iRecIndex,_T(""));
|
||||
|
||||
szLabel.Empty();
|
||||
szLabel.Format(_T("%d"), m_iTsn);
|
||||
m_listCustomSpt.SetItemText(iRecIndex, 0, szLabel);
|
||||
|
||||
szLabel.Empty();
|
||||
szLabel.Format(_T("%d"), m_iA);
|
||||
m_listCustomSpt.SetItemText(iRecIndex, 1, szLabel);
|
||||
|
||||
szLabel.Empty();
|
||||
szLabel.Format(_T("%d"), m_iB);
|
||||
m_listCustomSpt.SetItemText(iRecIndex, 2, szLabel);
|
||||
|
||||
szLabel.Empty();
|
||||
szLabel.Format(_T("%d"), m_iM);
|
||||
m_listCustomSpt.SetItemText(iRecIndex, 3, szLabel);
|
||||
|
||||
szLabel.Empty();
|
||||
szLabel.Format(_T("%d"), m_iN);
|
||||
m_listCustomSpt.SetItemText(iRecIndex, 4, szLabel);
|
||||
|
||||
szLabel.Empty();
|
||||
szLabel.Format(_T("%f"), m_fK);
|
||||
m_listCustomSpt.SetItemText(iRecIndex, 5, szLabel);
|
||||
|
||||
szLabel.Empty();
|
||||
szLabel.Format(_T("%d"), m_iIteration);
|
||||
m_listCustomSpt.SetItemText(iRecIndex, 6, szLabel);
|
||||
|
||||
szLabel.Empty();
|
||||
szLabel.Format(_T("%d"), m_iLayer);
|
||||
m_listCustomSpt.SetItemText(iRecIndex, 7, szLabel);
|
||||
|
||||
}
|
||||
|
||||
void CDialCustomSptInput::OnButtonDelList()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
int iIndex = 0;
|
||||
POSITION pos = m_listCustomSpt.GetFirstSelectedItemPosition();
|
||||
if (pos == NULL)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("请先选择需要删除的数据!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Please chose the data which you want to delete!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return ;
|
||||
}
|
||||
|
||||
while (pos)
|
||||
{
|
||||
iIndex = m_listCustomSpt.GetNextSelectedItem(pos);
|
||||
m_listCustomSpt.DeleteItem(iIndex);
|
||||
pos = m_listCustomSpt.GetFirstSelectedItemPosition();
|
||||
}
|
||||
}
|
||||
|
||||
void CDialCustomSptInput::OnButtonModifyList()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
|
||||
int nCnt = 0, nItem = 0;
|
||||
POSITION pos = m_listCustomSpt.GetFirstSelectedItemPosition();
|
||||
if (NULL != pos)
|
||||
{
|
||||
while (pos)
|
||||
{
|
||||
nCnt++;
|
||||
nItem = m_listCustomSpt.GetNextSelectedItem(pos);
|
||||
}
|
||||
}
|
||||
if (0 == nCnt)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("请先选择数据!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Please chose data firstly!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
if (1 != nCnt)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("请选择一行数据!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Please chose one item data!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CheckInputIsValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!CalculateK())
|
||||
{
|
||||
return;
|
||||
}
|
||||
CString szLabel;
|
||||
|
||||
szLabel.Empty();
|
||||
szLabel.Format(_T("%d"), m_iA);
|
||||
m_listCustomSpt.SetItemText(nItem, 1, szLabel);
|
||||
|
||||
szLabel.Empty();
|
||||
szLabel.Format(_T("%d"), m_iB);
|
||||
m_listCustomSpt.SetItemText(nItem, 2, szLabel);
|
||||
|
||||
szLabel.Empty();
|
||||
szLabel.Format(_T("%d"), m_iM);
|
||||
m_listCustomSpt.SetItemText(nItem, 3, szLabel);
|
||||
|
||||
szLabel.Empty();
|
||||
szLabel.Format(_T("%d"), m_iN);
|
||||
m_listCustomSpt.SetItemText(nItem, 4, szLabel);
|
||||
|
||||
szLabel.Empty();
|
||||
szLabel.Format(_T("%f"), m_fK);
|
||||
m_listCustomSpt.SetItemText(nItem, 5, szLabel);
|
||||
|
||||
szLabel.Empty();
|
||||
szLabel.Format(_T("%d"), m_iIteration);
|
||||
m_listCustomSpt.SetItemText(nItem, 6, szLabel);
|
||||
|
||||
szLabel.Empty();
|
||||
szLabel.Format(_T("%d"), m_iLayer);
|
||||
m_listCustomSpt.SetItemText(nItem, 7, szLabel);
|
||||
}
|
||||
|
||||
void CDialCustomSptInput::OnOK()
|
||||
{
|
||||
// TODO: Add extra validation here
|
||||
if (0 == m_listCustomSpt.GetItemCount() )
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("脚本数据不能为空!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Script Data can't be zero!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
BOOL CDialCustomSptInput::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
// TODO: Add extra initialization here
|
||||
|
||||
InitalListHeaderInfo();
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
SetWindowText(_T("自定义脚本"));
|
||||
GetDlgItem(IDC_RADIO_AUTO_CALC)->SetWindowText(_T("自动"));
|
||||
GetDlgItem(IDC_RADIO_HAND_INPUT)->SetWindowText(_T("手动"));
|
||||
GetDlgItem(IDC_BUTTON_ADD_LIST)->SetWindowText(_T("增加"));
|
||||
GetDlgItem(IDC_BUTTON_MODIFY_LIST)->SetWindowText(_T("修改"));
|
||||
GetDlgItem(IDC_BUTTON_DEL_LIST)->SetWindowText(_T("删除"));
|
||||
GetDlgItem(IDC_BUTTON_IMPORT)->SetWindowText(_T("导入"));
|
||||
GetDlgItem(IDOK)->SetWindowText(_T("完成"));
|
||||
GetDlgItem(IDCANCEL)->SetWindowText(_T("取消"));
|
||||
|
||||
}
|
||||
|
||||
((CButton *)GetDlgItem(IDC_RADIO_AUTO_CALC))->SetCheck(TRUE);
|
||||
((CButton *)GetDlgItem(IDC_RADIO_HAND_INPUT))->SetCheck(FALSE);
|
||||
GetDlgItem(IDC_EDIT_CUSTOMSPT_K)->EnableWindow(FALSE);
|
||||
|
||||
((CEdit*)GetDlgItem(IDC_EDIT_CUSTOMSPT_A))->SetLimitText(7);
|
||||
((CEdit*)GetDlgItem(IDC_EDIT_CUSTOMSPT_B))->SetLimitText(7);
|
||||
((CEdit*)GetDlgItem(IDC_EDIT_CUSTOMSPT_M))->SetLimitText(7);
|
||||
((CEdit*)GetDlgItem(IDC_EDIT_CUSTOMSPT_N))->SetLimitText(7);
|
||||
((CEdit*)GetDlgItem(IDC_EDIT_CUSTOMSPT_ITERATION))->SetLimitText(7);
|
||||
((CEdit*)GetDlgItem(IDC_EDIT_CUSTOMSPT_LAYER))->SetLimitText(7);
|
||||
((CEdit*)GetDlgItem(IDC_EDIT_CUSTOMSPT_K))->SetLimitText(18);
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void CDialCustomSptInput::OnClickListCustomSpt(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
int nCnt = 0, nItem = 0;
|
||||
POSITION pos = m_listCustomSpt.GetFirstSelectedItemPosition();
|
||||
if (NULL != pos)
|
||||
{
|
||||
while (pos)
|
||||
{
|
||||
nCnt++;
|
||||
nItem = m_listCustomSpt.GetNextSelectedItem(pos);
|
||||
}
|
||||
}
|
||||
if (0 == nCnt)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (1 != nCnt)
|
||||
{
|
||||
return;
|
||||
}
|
||||
CString strVal = _T("");
|
||||
strVal.Empty();
|
||||
strVal = m_listCustomSpt.GetItemText(nItem, 1);
|
||||
m_strA = strVal;
|
||||
m_iA = atoi(strVal);
|
||||
|
||||
strVal.Empty();
|
||||
strVal = m_listCustomSpt.GetItemText(nItem, 2);
|
||||
m_strB = strVal;
|
||||
m_iB = atoi(strVal);
|
||||
|
||||
strVal.Empty();
|
||||
strVal = m_listCustomSpt.GetItemText(nItem, 3);
|
||||
m_strM = strVal;
|
||||
m_iM = atoi(strVal);
|
||||
|
||||
strVal.Empty();
|
||||
strVal = m_listCustomSpt.GetItemText(nItem, 4);
|
||||
m_strN = strVal;
|
||||
m_iN = atoi(strVal);
|
||||
|
||||
strVal.Empty();
|
||||
strVal = m_listCustomSpt.GetItemText(nItem, 5);
|
||||
m_strK = strVal;
|
||||
m_fK = atof(strVal);
|
||||
|
||||
strVal.Empty();
|
||||
strVal = m_listCustomSpt.GetItemText(nItem, 6);
|
||||
m_strStacking = strVal;
|
||||
m_iIteration = atoi(strVal);
|
||||
|
||||
strVal.Empty();
|
||||
strVal = m_listCustomSpt.GetItemText(nItem, 7);
|
||||
m_strLayer = strVal;
|
||||
m_iLayer = atoi(strVal);
|
||||
|
||||
UpdateData(FALSE);
|
||||
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
void CDialCustomSptInput::InitalListHeaderInfo()
|
||||
{
|
||||
CString strColTitle=_T("");
|
||||
int iColIndex = (int)VAL_ZERO;
|
||||
|
||||
m_listCustomSpt.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP
|
||||
| LVS_EX_ONECLICKACTIVATE | LVS_EX_GRIDLINES|LVS_EX_MULTIWORKAREAS);
|
||||
|
||||
iColIndex++;
|
||||
strColTitle.Empty();
|
||||
strColTitle.LoadString(IDS_DB_SCRIPT_TSN);
|
||||
m_listCustomSpt.InsertColumn(iColIndex, strColTitle, LVCFMT_CENTER, 100);
|
||||
|
||||
iColIndex++;
|
||||
strColTitle.Empty();
|
||||
strColTitle.LoadString(IDS_DB_SCRIPT_C1);
|
||||
m_listCustomSpt.InsertColumn(iColIndex, strColTitle, LVCFMT_CENTER, 50);
|
||||
|
||||
|
||||
iColIndex++;
|
||||
strColTitle.Empty();
|
||||
strColTitle.LoadString(IDS_DB_SCRIPT_C2);
|
||||
m_listCustomSpt.InsertColumn(iColIndex, strColTitle, LVCFMT_CENTER, 50);
|
||||
|
||||
iColIndex++;
|
||||
strColTitle.Empty();
|
||||
strColTitle.LoadString(IDS_DB_SCRIPT_P1);
|
||||
m_listCustomSpt.InsertColumn(iColIndex, strColTitle, LVCFMT_CENTER, 50);
|
||||
|
||||
iColIndex++;
|
||||
strColTitle.Empty();
|
||||
strColTitle.LoadString(IDS_DB_SCRIPT_P2);
|
||||
m_listCustomSpt.InsertColumn(iColIndex, strColTitle, LVCFMT_CENTER, 50);
|
||||
|
||||
iColIndex++;
|
||||
strColTitle.Empty();
|
||||
strColTitle.LoadString(IDS_DB_SCRIPT_K);
|
||||
m_listCustomSpt.InsertColumn(iColIndex, strColTitle, LVCFMT_CENTER, 100);
|
||||
|
||||
iColIndex++;
|
||||
strColTitle.Empty();
|
||||
strColTitle.LoadString(IDS_DB_SCRIPT_N);
|
||||
m_listCustomSpt.InsertColumn(iColIndex, strColTitle, LVCFMT_CENTER, 50);
|
||||
|
||||
iColIndex++;
|
||||
strColTitle.Empty();
|
||||
strColTitle.LoadString(IDS_DB_SCRIPT_LEVEL);
|
||||
m_listCustomSpt.InsertColumn(iColIndex, strColTitle, LVCFMT_CENTER, 50);
|
||||
|
||||
}
|
||||
|
||||
void CDialCustomSptInput::OnRadioHandInput()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
if (BST_CHECKED == ((CButton *)GetDlgItem(IDC_RADIO_HAND_INPUT))->GetCheck())
|
||||
{
|
||||
((CButton *)GetDlgItem(IDC_RADIO_AUTO_CALC))->SetCheck(FALSE);
|
||||
GetDlgItem(IDC_EDIT_CUSTOMSPT_K)->EnableWindow(TRUE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CDialCustomSptInput::OnRadioAutoCalc()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
if (BST_CHECKED == ((CButton *)GetDlgItem(IDC_RADIO_AUTO_CALC))->GetCheck())
|
||||
{
|
||||
((CButton *)GetDlgItem(IDC_RADIO_HAND_INPUT))->SetCheck(FALSE);
|
||||
GetDlgItem(IDC_EDIT_CUSTOMSPT_K)->SetWindowText(_T(""));
|
||||
GetDlgItem(IDC_EDIT_CUSTOMSPT_K)->EnableWindow(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
bool CDialCustomSptInput::CheckInputIsValid()
|
||||
{
|
||||
if (!UpdateData(TRUE))
|
||||
{
|
||||
MessageBoxEx(NULL, _T("Retrieve data failed."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return false;
|
||||
}
|
||||
//A
|
||||
if ((-1 != atoi(m_strA)) && !bIsPostiveInteger(m_strA))
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("A的值须为正数或者-1!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("A has to be positive or minus 1!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return false;
|
||||
}
|
||||
m_iA = atoi(m_strA);
|
||||
//B 无穷大只会是-1
|
||||
if ((-1 != atoi(m_strB)) && !bIsPostiveInteger(m_strB))
|
||||
{
|
||||
m_iB = atoi(m_strB);
|
||||
if (m_iB != -1)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("B的值须为正数或者-1!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("B has to be positive or minus 1!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
m_iB = atoi(m_strB);
|
||||
//M
|
||||
if ((-1 != atoi(m_strM)) && !bIsPostiveInteger(m_strM))
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("M的值须为正数或者-1!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("M has to be positive or minus 1!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return false;
|
||||
}
|
||||
m_iM = atoi(m_strM);
|
||||
//N
|
||||
if ((-1 != atoi(m_strN)) && !bIsPostiveInteger(m_strN))
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("N的值须为正数或者-1!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("N has to be positive or minus 1!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return false;
|
||||
}
|
||||
m_iN = atoi(m_strN);
|
||||
//Layer
|
||||
if (!bIsPostiveInteger(m_strLayer))
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("层数的值须为正数!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Please input a positive number on Layer."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return false;
|
||||
}
|
||||
m_iLayer = atoi(m_strLayer);
|
||||
//Stacking
|
||||
if (!bIsPostiveInteger(m_strStacking))
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("迭代数的值须为正数!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Please input a positive number on Stacking."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return false;
|
||||
}
|
||||
m_iIteration = atoi(m_strStacking);
|
||||
if (m_iIteration < 1 || m_iIteration > 255)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("迭代数错误,请输入一个从1到255的整数!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Stacking number input error!please input an integer from 1 to 255!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return false;
|
||||
}
|
||||
|
||||
//K
|
||||
if (BST_CHECKED == ((CButton *)GetDlgItem(IDC_RADIO_HAND_INPUT))->GetCheck())
|
||||
{
|
||||
if (!bIsFloat(m_strK))
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("K值输入错误!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Please input number on K.!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return false;
|
||||
}
|
||||
m_fK = atof(m_strK);//m_fK = fabs(atof(m_strK));//by quyx 20180514 K值可为负
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDialCustomSptInput::CalculateK()
|
||||
{
|
||||
//如果设置成自动计算则此时需要进行计算
|
||||
if (BST_CHECKED == ((CButton *)GetDlgItem(IDC_RADIO_AUTO_CALC))->GetCheck())
|
||||
{
|
||||
int iAM = fabs(float(m_iA - m_iM));
|
||||
int iAN = fabs(float(m_iA - m_iN));
|
||||
int iBM = fabs(float(m_iB - m_iM));
|
||||
int iBN = fabs(float(m_iB - m_iN));
|
||||
//AM装置,存在BN等于0的情况
|
||||
if (0 == iAM || 0 == iAN || 0 == iBM /*|| 0 == iBN*/)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("任意2个电极之间的距离都不能为零!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("The position of any two electrodes can not be equal!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return false;
|
||||
}
|
||||
float fAMCal = 1.0/iAM;
|
||||
float fANCal = 1.0/iAN;
|
||||
float fBMCal = 1.0/iBM;
|
||||
float fBNCal = 1.0/iBN;
|
||||
if (m_iA < 0)
|
||||
{
|
||||
fAMCal = 0;
|
||||
fANCal = 0;
|
||||
}
|
||||
if (m_iB < 0)
|
||||
{
|
||||
fBMCal = 0;
|
||||
fBNCal = 0;
|
||||
}
|
||||
if (m_iM < 0)
|
||||
{
|
||||
fAMCal = 0;
|
||||
fBMCal = 0;
|
||||
}
|
||||
if (m_iN < 0)
|
||||
{
|
||||
fANCal = 0;
|
||||
fBNCal = 0;
|
||||
}
|
||||
//float fTmp = fabs(fAMCal - fANCal - fBMCal + fBNCal);
|
||||
float fTmp = (fAMCal - fANCal - fBMCal + fBNCal);//by quyx 20180514 K值可为负
|
||||
if (0 == fTmp)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("自动计算K值错误,请检查输入!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Automatic calculate K error,please check your input value!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return false;
|
||||
}
|
||||
m_fK = 1;//2*VAL_PI/fTmp;
|
||||
}
|
||||
/*if (m_fK <= 0) //by quyx 20180514 K值可为负
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("K值计算错误!"));
|
||||
else
|
||||
AfxMessageBox(_T("The value of K error!"));
|
||||
return false;
|
||||
}*/
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
CString CDialCustomSptInput::GetListItemText(int iIndex, int iSubIndex)
|
||||
{
|
||||
CString strRes = _T("");
|
||||
if (iIndex < 0 || iSubIndex < 0)
|
||||
{
|
||||
MessageBoxEx(NULL, _T("Input parameter error in GetListItemText!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return strRes;
|
||||
}
|
||||
strRes = m_listCustomSpt.GetItemText(iIndex, iSubIndex);
|
||||
return strRes;
|
||||
}
|
||||
|
||||
void CDialCustomSptInput::OnButtonImport()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
|
||||
CString strCaption = _T("");
|
||||
CString strFileName = _T("");
|
||||
CString strText = _T("");
|
||||
strCaption.LoadString(IDS_OPEN);
|
||||
CFileDialog *pDlgOpenFile = NULL;
|
||||
pDlgOpenFile = new CFileDialog (TRUE , NULL, NULL, OFN_HIDEREADONLY|OFN_FILEMUSTEXIST|OFN_NOCHANGEDIR,
|
||||
_T("Excel file(*.xlsx)|*.xlsx||"),this);
|
||||
pDlgOpenFile->m_ofn.lpstrTitle = strCaption;
|
||||
if (IDOK != pDlgOpenFile->DoModal())
|
||||
{
|
||||
return;
|
||||
}
|
||||
strFileName = pDlgOpenFile->GetPathName();
|
||||
delete pDlgOpenFile;
|
||||
|
||||
_Application ComApp;
|
||||
Workbooks comBooks;
|
||||
_Workbook comBook;
|
||||
Sheets comSheets;
|
||||
_Worksheet comSheet01;
|
||||
Range objRange;
|
||||
VARIANT vRet;
|
||||
COleVariant VOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
|
||||
|
||||
if( !ComApp.CreateDispatch(_T("Excel.Application"), NULL) )
|
||||
{
|
||||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||||
MessageBoxEx(NULL, _T("Can't build excel application!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
ComApp.Quit();
|
||||
return ;
|
||||
}
|
||||
|
||||
comBooks = ComApp.GetWorkbooks();
|
||||
comBook = comBooks.Open(strFileName, VOptional, VOptional, VOptional, VOptional, VOptional, VOptional, VOptional, VOptional, VOptional, VOptional, VOptional, VOptional, VOptional, VOptional);
|
||||
comSheets = comBook.GetWorksheets();
|
||||
comSheet01 = comSheets.GetItem(COleVariant((short)1));
|
||||
|
||||
objRange = comSheet01.GetUsedRange();
|
||||
// 取行列数
|
||||
vRet = objRange.GetValue(VOptional);
|
||||
COleSafeArray oleSA(vRet);
|
||||
long lNumRows;
|
||||
long lNumCols = 7;
|
||||
|
||||
oleSA.GetUBound(1, &lNumRows);
|
||||
|
||||
if (lNumRows <= 1)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
strText = (_T("在sheet1处没有数据!"));
|
||||
AfxMessageBox(strText);
|
||||
}
|
||||
else
|
||||
{
|
||||
strText.Format(_T("No data in sheet1(%s)"), strFileName);
|
||||
MessageBoxEx(NULL, strText, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
|
||||
objRange.Clear();
|
||||
comBook.Close(COleVariant((short)FALSE),VOptional,VOptional);
|
||||
comBooks.Close();
|
||||
ComApp.Quit();
|
||||
ComApp.ReleaseDispatch();
|
||||
}
|
||||
|
||||
int iRecIndex = 0;
|
||||
int iTsn = 0;
|
||||
if (m_listCustomSpt.GetItemCount() != 0)
|
||||
{
|
||||
CCustomSptQueryDial CustQueDial;
|
||||
CustQueDial.DoModal();
|
||||
int nOperRes = CustQueDial.GetOperResult();
|
||||
if (EN_QUE_APPEND == nOperRes)
|
||||
{
|
||||
iRecIndex = m_listCustomSpt.GetItemCount();
|
||||
iTsn = atoi(m_listCustomSpt.GetItemText(iRecIndex-1, 0));
|
||||
}
|
||||
else if (EN_QUE_REPLACE == nOperRes)
|
||||
{
|
||||
m_listCustomSpt.DeleteAllItems();
|
||||
}
|
||||
else
|
||||
{
|
||||
objRange.Clear();
|
||||
comBook.Close(COleVariant((short)FALSE),VOptional,VOptional);
|
||||
comBooks.Close();
|
||||
ComApp.Quit();
|
||||
ComApp.ReleaseDispatch();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//在这里固定取前7列
|
||||
lNumCols = 7;
|
||||
|
||||
TCHAR tCh = _T('A');
|
||||
CString strTitle = _T("");
|
||||
//行数从1开始,并且第一行是数据的标题
|
||||
for (int i = 2; i <= lNumRows; i++)
|
||||
{
|
||||
m_listCustomSpt.InsertItem(iRecIndex+i-2,_T(""));
|
||||
iTsn++;
|
||||
strText.Empty();
|
||||
strText.Format(_T("%d"),iTsn);
|
||||
m_listCustomSpt.SetItemText(iRecIndex+i-2, 0, strText);
|
||||
for (int j = 0; j < lNumCols; j++)
|
||||
{
|
||||
strTitle.Empty();
|
||||
strTitle.Format(_T("%c%d"),tCh+j, i);
|
||||
strText.Empty();
|
||||
Range rangeVal=comSheet01.GetRange(COleVariant(strTitle),COleVariant(strTitle));
|
||||
COleVariant rValue;
|
||||
rValue=COleVariant(rangeVal.GetValue2());
|
||||
rValue.ChangeType(VT_BSTR);
|
||||
strText = CString(rValue.bstrVal);
|
||||
if (strText.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
strText.Format(_T("从Excel获取 %s 数据失败!"), strTitle);
|
||||
AfxMessageBox(strText);
|
||||
}
|
||||
else
|
||||
{
|
||||
strText.Format(_T("Get %s data in excel failed!"), strTitle);
|
||||
MessageBoxEx(NULL, strText, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
|
||||
objRange.Clear();
|
||||
comBook.Close(COleVariant((short)FALSE),VOptional,VOptional);
|
||||
comBooks.Close();
|
||||
ComApp.Quit();
|
||||
ComApp.ReleaseDispatch();
|
||||
return;
|
||||
}
|
||||
m_listCustomSpt.SetItemText(iRecIndex+i-2, j+1, strText);
|
||||
}
|
||||
}
|
||||
|
||||
objRange.Clear();
|
||||
comBook.Close(COleVariant((short)FALSE),VOptional,VOptional);
|
||||
comBooks.Close();
|
||||
ComApp.Quit();
|
||||
ComApp.ReleaseDispatch();
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("导入文件成功!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Import file success."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
// ExecOperator.cpp: implementation of the CExecOperator class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "geomative.h"
|
||||
#include "ExecOperator.h"
|
||||
#include "navsptview.h"
|
||||
#include "Constant.h"
|
||||
|
||||
#include "opexec2drsptestsetdlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
extern CGeoMativeApp theApp;
|
||||
extern int g_iLanguage;
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CExecOperator::CExecOperator(_ConnectionPtr& pConnection)
|
||||
{
|
||||
ASSERT(NULL != pConnection);
|
||||
m_pConnection = pConnection;
|
||||
}
|
||||
|
||||
CExecOperator::~CExecOperator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CExecOperator::ExecRSPTest()
|
||||
{
|
||||
long lRet = VAL_ZERO;
|
||||
int iCurSel = VAL_MINUS_ONE;
|
||||
|
||||
COpExec2DRSPTestSetDlg* pOpExec2DRSPTestSetDlg = new COpExec2DRSPTestSetDlg(m_pConnection);
|
||||
pOpExec2DRSPTestSetDlg->Create(IDD_OP_TDH_S_C, AfxGetMainWnd());
|
||||
this->InitialExec2DRSPTestSetDlg(pOpExec2DRSPTestSetDlg);
|
||||
|
||||
pOpExec2DRSPTestSetDlg->ShowWindow(SW_SHOW);
|
||||
|
||||
lRet = pOpExec2DRSPTestSetDlg->RunModalLoop(MLF_SHOWONIDLE); // 开始非模态窗口模态循环
|
||||
|
||||
if (RET_OK == lRet)
|
||||
{
|
||||
iCurSel = pOpExec2DRSPTestSetDlg->m_sptTab.GetCurSel();
|
||||
switch (iCurSel)
|
||||
{
|
||||
case TAB_INDEX_CE:
|
||||
theApp.m_pExecManager->ExecCERSPTest(pOpExec2DRSPTestSetDlg, theApp.m_pSptManager->m_medLinkList);
|
||||
break;
|
||||
|
||||
case TAB_INDEX_2D:
|
||||
theApp.m_pExecManager->Exec2DRSPTest(pOpExec2DRSPTestSetDlg, theApp.m_pSptManager->m_medLinkList);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
pOpExec2DRSPTestSetDlg->m_sptTab.SetFocus();
|
||||
|
||||
}
|
||||
|
||||
pOpExec2DRSPTestSetDlg->DestroyWindow();
|
||||
delete pOpExec2DRSPTestSetDlg;
|
||||
|
||||
}
|
||||
|
||||
void CExecOperator::InitialExec2DRSPTestSetDlg(COpExec2DRSPTestSetDlg* pOpExec2DRSPTestSetDlg)
|
||||
{
|
||||
_RecordsetPtr pRecCm = NULL;
|
||||
_RecordsetPtr pRecPro = NULL;
|
||||
_RecordsetPtr pRecDev = NULL;
|
||||
CDevice* pDevice = NULL;
|
||||
|
||||
int iIndex = (int)VAL_ZERO;
|
||||
|
||||
CString szSql = _T("");
|
||||
|
||||
pRecCm.CreateInstance(_uuidof(Recordset));
|
||||
pRecPro.CreateInstance(_uuidof(Recordset));
|
||||
pRecDev.CreateInstance(_uuidof(Recordset));
|
||||
|
||||
iIndex = (int)VAL_ZERO;
|
||||
pOpExec2DRSPTestSetDlg->m_cbDESN.ResetContent();
|
||||
pRecDev->Open(_T("select ID,SN from device order by ID"), _variant_t((IDispatch*)m_pConnection, true),
|
||||
adOpenStatic, adLockOptimistic, adCmdText);
|
||||
while ((short)VAL_ZERO == pRecDev->adoEOF)
|
||||
{
|
||||
pDevice = NULL;
|
||||
pDevice = theApp.m_pDevManager->GetDeviceByID((DWORD)pRecDev->GetCollect(_T("ID")).ulVal);
|
||||
if (pDevice != NULL)
|
||||
{
|
||||
if (PZ_STATE_ONLINE == pDevice->m_uState)
|
||||
{
|
||||
iIndex = pOpExec2DRSPTestSetDlg->m_cbDESN.AddString(pDevice->m_szDevSN);
|
||||
pOpExec2DRSPTestSetDlg->m_cbDESN.SetItemDataPtr(iIndex, pDevice);
|
||||
}
|
||||
}
|
||||
pRecDev->MoveNext();
|
||||
}
|
||||
pRecDev->Close();
|
||||
|
||||
iIndex = (int)VAL_ZERO;
|
||||
|
||||
//由于GD10主机上只实现了Cvalue的前四个,所以在sql语句中做限制
|
||||
pOpExec2DRSPTestSetDlg->m_cbCLayout.ResetContent();
|
||||
szSql.Empty();
|
||||
szSql.Format(_T("select Clabel from cm where Cname = 'Clayout' and Lang = %d and Cvalue >= 0 and Cvalue < 4 order by Cvalue"), g_iLanguage);
|
||||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
|
||||
while ((short)VAL_ZERO == pRecCm->adoEOF)
|
||||
{
|
||||
pOpExec2DRSPTestSetDlg->m_cbCLayout.AddString((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||||
pRecCm->MoveNext();
|
||||
}
|
||||
pRecCm->Close();
|
||||
/*
|
||||
pOpExec2DRSPTestSetDlg->m_cbTRWave.ResetContent();
|
||||
szSql.Empty();
|
||||
szSql.Format(_T("select Clabel from cm where Cname = 'Trwave' and Lang = %d order by Cvalue"), g_iLanguage);
|
||||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
|
||||
while ((short)VAL_ZERO == pRecCm->adoEOF)
|
||||
{
|
||||
pOpExec2DRSPTestSetDlg->m_cbTRWave.AddString((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||||
pRecCm->MoveNext();
|
||||
}
|
||||
pRecCm->Close();
|
||||
*/
|
||||
//由于GD10只实现了从1~6范围内的频率
|
||||
pOpExec2DRSPTestSetDlg->m_cbTRFrequency.ResetContent();
|
||||
szSql.Empty();
|
||||
szSql.Format(_T("select Clabel from cm where Cname = 'Trfrequency' and Lang = %d and Cvalue > 0 and Cvalue < 7 order by Cvalue"), g_iLanguage);
|
||||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
|
||||
while ((short)VAL_ZERO == pRecCm->adoEOF)
|
||||
{
|
||||
pOpExec2DRSPTestSetDlg->m_cbTRFrequency.AddString((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||||
pRecCm->MoveNext();
|
||||
}
|
||||
pRecCm->Close();
|
||||
|
||||
/*
|
||||
// pOpExec2DRSPTestSetDlg->m_cbIFrequency.ResetContent();
|
||||
szSql.Empty();
|
||||
szSql.Format(_T("select Clabel from cm where Cname = 'Ifrequency' and Lang = %d order by Cvalue"), g_iLanguage);
|
||||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
while ((short)VAL_ZERO == pRecCm->adoEOF)
|
||||
{
|
||||
// pOpExec2DRSPTestSetDlg->m_cbIFrequency.AddString((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||||
pRecCm->MoveNext();
|
||||
}
|
||||
pRecCm->Close();
|
||||
|
||||
// pOpExec2DRSPTestSetDlg->m_cbTMode.ResetContent();
|
||||
szSql.Empty();
|
||||
szSql.Format(_T("select Clabel from cm where Cname = 'Tmode' and Lang = %d order by Cvalue"), g_iLanguage);
|
||||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
while ((short)VAL_ZERO == pRecCm->adoEOF)
|
||||
{
|
||||
// pOpExec2DRSPTestSetDlg->m_cbTMode.AddString((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||||
pRecCm->MoveNext();
|
||||
}
|
||||
pRecCm->Close();
|
||||
*/
|
||||
|
||||
pOpExec2DRSPTestSetDlg->m_cbSAFrequency.ResetContent();
|
||||
szSql.Empty();
|
||||
szSql.Format(_T("select Clabel from cm where Cname = 'SAfrequency50' and Lang = %d and Cvalue > 0 order by Cvalue"), g_iLanguage);
|
||||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
while ((short)VAL_ZERO == pRecCm->adoEOF)
|
||||
{
|
||||
pOpExec2DRSPTestSetDlg->m_cbSAFrequency.AddString((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||||
pRecCm->MoveNext();
|
||||
}
|
||||
pRecCm->Close();
|
||||
|
||||
|
||||
pOpExec2DRSPTestSetDlg->m_cbWeather.ResetContent();
|
||||
szSql.Empty();
|
||||
szSql.Format(_T("select Clabel from cm where Cname = 'weather' and Lang = %d order by Cvalue"), g_iLanguage);
|
||||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
while ((short)VAL_ZERO == pRecCm->adoEOF)
|
||||
{
|
||||
pOpExec2DRSPTestSetDlg->m_cbWeather.AddString((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||||
pRecCm->MoveNext();
|
||||
}
|
||||
pRecCm->Close();
|
||||
|
||||
pOpExec2DRSPTestSetDlg->m_cbWDIR.ResetContent();
|
||||
szSql.Empty();
|
||||
szSql.Format(_T("select Clabel from cm where Cname = 'WDIR' and Lang = %d order by Cvalue"), g_iLanguage);
|
||||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
while ((short)VAL_ZERO == pRecCm->adoEOF)
|
||||
{
|
||||
pOpExec2DRSPTestSetDlg->m_cbWDIR.AddString((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||||
pRecCm->MoveNext();
|
||||
}
|
||||
pRecCm->Close();
|
||||
|
||||
// theApp.m_pSptManager->Initial2DSptList(pOpExec2DRSPTestSetDlg->m_op2DSptSelDlg.m_sptList);
|
||||
// theApp.m_pSptManager->InitialCESptList(pOpExec2DRSPTestSetDlg->m_opCESptSelDlg.m_ceSptList);
|
||||
|
||||
// pOpExec2DRSPTestSetDlg->m_ckIsGr.SetCheck(BST_CHECKED);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
// InputPasswordDial.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "geomative.h"
|
||||
#include "InputPasswordDial.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
extern int g_iUILanguage;
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CInputPasswordDial dialog
|
||||
|
||||
|
||||
CInputPasswordDial::CInputPasswordDial(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CInputPasswordDial::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CInputPasswordDial)
|
||||
m_edPassword = _T("");
|
||||
//}}AFX_DATA_INIT
|
||||
m_bIsDirectVerify = true;
|
||||
m_strGeoPassword = _T("");
|
||||
}
|
||||
|
||||
|
||||
void CInputPasswordDial::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CInputPasswordDial)
|
||||
DDX_Text(pDX, IDC_EDIT_INPUT_PASSWORD, m_edPassword);
|
||||
DDV_MaxChars(pDX, m_edPassword, 50);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CInputPasswordDial, CDialog)
|
||||
//{{AFX_MSG_MAP(CInputPasswordDial)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CInputPasswordDial message handlers
|
||||
|
||||
void CInputPasswordDial::OnOK()
|
||||
{
|
||||
// TODO: Add extra validation here
|
||||
if (!UpdateData(TRUE))
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("输入密码错误!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Input Password Error!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_bIsDirectVerify)
|
||||
{
|
||||
if (m_edPassword != m_strGeoPassword)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("密码错误!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Password Error!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
BOOL CInputPasswordDial::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
// TODO: Add extra initialization here
|
||||
if (m_bIsDirectVerify)
|
||||
{
|
||||
if (m_strGeoPassword.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("获取Geomative 初始化密码失败!!!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Get Geomative Initial Password Failed!!!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
GetDlgItem(IDC_EDIT_INPUT_PASSWORD)->SetFocus();
|
||||
return FALSE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void CInputPasswordDial::OnCancel()
|
||||
{
|
||||
// TODO: Add extra cleanup here
|
||||
int nRet = 0;
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
nRet = AfxMessageBox(_T("您要放弃输入密码吗?"), MB_YESNO);
|
||||
else
|
||||
nRet = MessageBoxEx(NULL, _T("Do you want to give up input password?"), STRING_MESSAGEBOXEX_TITLE, MB_YESNO, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
if (IDYES != nRet)
|
||||
return;
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
@@ -0,0 +1,496 @@
|
||||
// LicenseUpgrade.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "geomative.h"
|
||||
#include "LicenseUpgrade.h"
|
||||
#include <DbgHelp.h>
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CLicenseUpgrade dialog
|
||||
|
||||
extern CGeoMativeApp theApp;
|
||||
extern int g_iUILanguage;
|
||||
|
||||
CLicenseUpgrade::CLicenseUpgrade(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CLicenseUpgrade::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CLicenseUpgrade)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
m_bIsCrulInitaled = false;
|
||||
}
|
||||
|
||||
|
||||
void CLicenseUpgrade::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CLicenseUpgrade)
|
||||
DDX_Control(pDX, IDC_PRG_LCI_UPG, m_proDownFile);
|
||||
DDX_Control(pDX, IDC_COMBO_DEV_ONLINE, m_comDev);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CLicenseUpgrade, CDialog)
|
||||
//{{AFX_MSG_MAP(CLicenseUpgrade)
|
||||
ON_WM_TIMER()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CLicenseUpgrade message handlers
|
||||
|
||||
BOOL CLicenseUpgrade::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
// TODO: Add extra initialization here
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
SetWindowText(_T("升级License"));
|
||||
GetDlgItem(IDC_STATIC_DEVICE_NAME)->SetWindowText(_T("设备:"));
|
||||
GetDlgItem(IDC_STATIC_DOWN_FILE)->SetWindowText(_T("进度:"));
|
||||
GetDlgItem(IDOK)->SetWindowText(_T("升级"));
|
||||
|
||||
}
|
||||
m_bIsCrulInitaled = false;
|
||||
m_bIsUpdating = false;
|
||||
int iIndex = (int)VAL_ZERO;
|
||||
CPtrArray olDevList;
|
||||
CDevice* pDev = NULL;
|
||||
olDevList.RemoveAll();
|
||||
theApp.m_pDevManager->GetOLDevList(&olDevList);
|
||||
iIndex = (int)VAL_ZERO;
|
||||
m_comDev.Clear();
|
||||
while (iIndex < olDevList.GetSize())
|
||||
{
|
||||
pDev = NULL;
|
||||
pDev = (CDevice*)olDevList.GetAt(iIndex);
|
||||
|
||||
if (PZ_STATE_NEW != pDev->m_uState)
|
||||
{
|
||||
m_comDev.AddString(pDev->m_szDevSN);
|
||||
m_comDev.SetItemDataPtr(m_comDev.GetCount() - 1, pDev);
|
||||
}
|
||||
iIndex++;
|
||||
}
|
||||
if (0 == m_comDev.GetCount())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("请先连接主机设备!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("There is no online device,please connect to device!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_comDev.SetCurSel(0);
|
||||
m_proDownFile.SetRange(0,100);
|
||||
m_proDownFile.SetPos(0);
|
||||
UpdateData(FALSE);
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void CLicenseUpgrade::OnOK()
|
||||
{
|
||||
// TODO: Add extra validation here
|
||||
UpdateData(TRUE);
|
||||
if (m_bIsUpdating)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("正在升级,请稍后..."));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Now is updating, please wait...."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
CString strDevice = _T("");
|
||||
if (m_comDev.GetCurSel() < 0)
|
||||
{
|
||||
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("请先选择设备."));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Please select device"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
m_comDev.GetLBText(m_comDev.GetCurSel(), strDevice);
|
||||
if (strDevice.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("获取设备名失败!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Get Device-Name failed!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
CDevice *pDev = (CDevice*)(m_comDev.GetItemDataPtr(m_comDev.GetCurSel()));
|
||||
if (NULL == pDev)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("获取设备失败!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Get Device-Ptr failed!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
|
||||
m_bIsUpdating = true;
|
||||
|
||||
|
||||
if (GetLicenseFile(strDevice))
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("下载新License成功,正在将License升级到主机设备中,请等待."));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Donwload new license successfully\r\nplease wait to upgrade the license of mainframe now."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
GetDlgItem(IDC_STATIC_DOWN_FILE)->SetWindowText(_T("Download complete!"));
|
||||
GetDlgItem(IDC_STATIC_LCI_RATE)->SetWindowText(_T(""));
|
||||
UpdateGD10Dev(&(pDev->m_sComPort));
|
||||
//装载完成后删除文件
|
||||
DeleteFile(".\\tools\\FACTORY");
|
||||
DeleteFile(".\\tools\\LICENSE");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("升级License失败."));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Upgrade license failed!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
|
||||
m_bIsUpdating = false;
|
||||
|
||||
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
bool CLicenseUpgrade::GetLicenseFile(CString strDev)
|
||||
{
|
||||
CString strFolderInfo = ".\\tools\\";
|
||||
// bool bRes = false;
|
||||
//首先检查是否创建用于存放更新文件的文件夹
|
||||
if(!MakeSureDirectoryPathExists(strFolderInfo.GetBuffer(0)))
|
||||
{
|
||||
CString strShow = _T("");
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
strShow.Format(_T("创建文件夹更新失败! 错误码 = %d"), GetLastError());
|
||||
AfxMessageBox(strShow.GetBuffer(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
strShow.Format(_T("Create folder updats failed! errorcode = %d"), GetLastError());
|
||||
MessageBoxEx(NULL, strShow, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_FileTransfer.Inital())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("文件转发初始化失败!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("FileTransfer Initail Failed!!!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return false;
|
||||
}
|
||||
|
||||
// if (!m_bIsCrulInitaled)
|
||||
// {
|
||||
// if (!m_FileTransfer.Inital())
|
||||
// {
|
||||
// AfxMessageBox("FileTransfer Initail Failed!!!");
|
||||
// return false;
|
||||
// }
|
||||
// m_bIsCrulInitaled = true;
|
||||
// }
|
||||
SetTimer(1,300,NULL);
|
||||
|
||||
std::vector<CString> vtDonwFileInfo;
|
||||
vtDonwFileInfo.clear();
|
||||
vtDonwFileInfo.push_back(_T("FACTORY.txt"));
|
||||
vtDonwFileInfo.push_back(_T("LICENSE.txt"));
|
||||
|
||||
std::vector<CString> vtSaveFileInfo;
|
||||
vtSaveFileInfo.clear();
|
||||
vtSaveFileInfo.push_back(_T("FACTORY"));
|
||||
vtSaveFileInfo.push_back(_T("LICENSE"));
|
||||
|
||||
m_FileTransfer.SetOption(OPT_TIMEOUT, "60");
|
||||
m_FileTransfer.SetOption(OPT_NEED_PROGRESS, "", true);
|
||||
m_FileTransfer.SetOption(OPT_DOWNLOAD_PATH, ".\\tools\\");
|
||||
// m_FileTransfer.SetOption(OPT_HTTPS_ACCESS, "", true);
|
||||
// m_FileTransfer.SetOption(OPT_SSL_CERTIFY, "", false);
|
||||
|
||||
for (int i = 0; i < vtDonwFileInfo.size(); i++)
|
||||
{
|
||||
/* m_bIsUpdating = true;*/
|
||||
m_FileTransfer.SetOption(OPT_DOWNLOAD_NAME, vtDonwFileInfo[i]);
|
||||
CString strUrl =_T("");
|
||||
// strUrl.Format(_T("http://192.168.1.110:8080/liushq/%s"), strSrcFile.GetBuffer(0));
|
||||
// strUrl.Format(_T("http://192.168.1.110:8080/liushq/%s/%s"), strDev.GetBuffer(0),vtDonwFileInfo[i].GetBuffer(0));
|
||||
strUrl.Format(_T("%s%s/%s"), theApp.m_strUpgUrl,strDev.GetBuffer(0),vtDonwFileInfo[i].GetBuffer(0));
|
||||
m_FileTransfer.SetOption(OPT_URL_ADDRESS, strUrl);
|
||||
m_FileTransfer.SetOption(OPT_DOWNLOAD_NAME, vtSaveFileInfo[i]);
|
||||
|
||||
CString strTmp = _T("");
|
||||
strTmp.Format(_T("Downloading %s..."), vtDonwFileInfo[i].GetBuffer(0));
|
||||
GetDlgItem(IDC_STATIC_DOWN_FILE)->SetWindowText(strTmp.GetBuffer(0));
|
||||
m_proDownFile.SetPos(0);
|
||||
GetDlgItem(IDC_STATIC_LCI_RATE)->SetWindowText("0%");
|
||||
if (!m_FileTransfer.DownloadFile())
|
||||
{
|
||||
// strTmp.Empty();
|
||||
// strTmp.Format("DownLoadUpdateFiles %s_%s failed!!!", vtDonwFileInfo[i].GetBuffer(0));
|
||||
//AfxMessageBox(strTmp);
|
||||
// strTmp.Format(_T("[%d] download file failed!, index = %d, url = %s"),__LINE__, i+1, strUrl.GetBuffer(0));
|
||||
//如果下载LICENSE失败,则需要删除FACTORY文件
|
||||
if (1 == i)
|
||||
{
|
||||
DeleteFile(".\\tools\\FACTORY");
|
||||
}
|
||||
m_FileTransfer.UnInital();
|
||||
KillTimer(1);
|
||||
|
||||
return false;
|
||||
}
|
||||
m_proDownFile.SetPos(100);
|
||||
GetDlgItem(IDC_STATIC_LCI_RATE)->SetWindowText("100%");
|
||||
}
|
||||
|
||||
m_FileTransfer.UnInital();
|
||||
KillTimer(1);
|
||||
return true;
|
||||
/*
|
||||
if (!m_bIsCrulInitaled)
|
||||
{
|
||||
if (!m_FileTransfer.Inital())
|
||||
{
|
||||
AfxMessageBox("FileTransfer Initail Failed!!!");
|
||||
return false;
|
||||
}
|
||||
m_bIsCrulInitaled = true;
|
||||
}
|
||||
CString strDstUrl = _T("");
|
||||
// CString strDstFileName = _T("LICENSE.bin");
|
||||
strDstUrl.Format(_T("http://218.17.161.7:9520/liushq/%s/LICENSE.bin"),strDev.GetBuffer(0));
|
||||
|
||||
m_FileTransfer.SetOption(OPT_URL_ADDRESS, strDstUrl);
|
||||
m_FileTransfer.SetOption(OPT_DOWNLOAD_PATH, ".\\tools\\");
|
||||
m_FileTransfer.SetOption(OPT_DOWNLOAD_NAME, "LICENSE.bin");
|
||||
m_FileTransfer.SetOption(OPT_TIMEOUT, "30");
|
||||
m_FileTransfer.SetOption(OPT_NEED_PROGRESS, "", true);
|
||||
return m_FileTransfer.DownloadFile();
|
||||
*/
|
||||
}
|
||||
|
||||
void CLicenseUpgrade::OnTimer(UINT nIDEvent)
|
||||
{
|
||||
// TODO: Add your message handler code here and/or call default
|
||||
if (1 == nIDEvent)
|
||||
{
|
||||
// CString strTmp
|
||||
// CString strDownFileName =_T("");
|
||||
// m_FileTransfer.GetFileName(strDownFileName);
|
||||
//当前下载文件的总大小
|
||||
curl_off_t lFileTotalSize = m_FileTransfer.GetFileTotalSize();
|
||||
//当前下载文件的大小
|
||||
curl_off_t lCurFileSize = m_FileTransfer.GetCurDownloadSize();
|
||||
CString strShow =_T("");
|
||||
// strShow.Format(_T("update %s ...."), strDownFileName.GetBuffer(0));
|
||||
// GetDlgItem(IDC_TITLE)->SetWindowText(strShow.GetBuffer(0));
|
||||
if (lFileTotalSize > 0)
|
||||
{
|
||||
int nPos = 100 * lCurFileSize / lFileTotalSize;
|
||||
strShow.Empty();
|
||||
strShow.Format(_T("%d%%"), nPos);
|
||||
GetDlgItem(IDC_STATIC_LCI_RATE)->SetWindowText(strShow.GetBuffer(0));
|
||||
m_proDownFile.SetPos(nPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_proDownFile.SetPos(0);
|
||||
GetDlgItem(IDC_STATIC_LCI_RATE)->SetWindowText("0%");
|
||||
}
|
||||
|
||||
}
|
||||
CDialog::OnTimer(nIDEvent);
|
||||
}
|
||||
|
||||
void CLicenseUpgrade::UpdateGD10Dev(CSComPort *pCom)
|
||||
{
|
||||
//刷固件:
|
||||
// if(!MakeSureDirectoryPathExists(_T(".\\tools\\")))
|
||||
// {
|
||||
// hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||||
// AfxMessageBox("tools file had been miss please contact admimnistrator");
|
||||
// return false;
|
||||
// }
|
||||
|
||||
CString szFolderName = "tools";
|
||||
CString szFilePath = ".//";
|
||||
CString szBatPath;
|
||||
|
||||
CString szOrder = _T("");
|
||||
szOrder = "isp()\r\n";
|
||||
if (!pCom->ExecuteNoResOrder(szOrder))
|
||||
{
|
||||
//HOOKhHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("下发升级License命令(isp)失败."));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Update license(isp) failed!!!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return ;
|
||||
}
|
||||
|
||||
Sleep(5000);
|
||||
|
||||
char cReadBuff[1024]; int nLength = 0;
|
||||
memset(cReadBuff, 0, 1024);
|
||||
pCom->ReceiveDataDirectly(cReadBuff, &nLength);
|
||||
|
||||
//判断是否电量低
|
||||
if (nLength != 0)
|
||||
{
|
||||
CString strRcv = cReadBuff;
|
||||
//当找到Low字符时,认为此时的电量不足
|
||||
if (strRcv.Find("Low") != -1)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("电量太低,请先充电."));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Bettery is low, please charge"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
szBatPath = ".\\tools\\License-GD20.bat";
|
||||
|
||||
PROCESS_INFORMATION ProcessInfo;
|
||||
|
||||
STARTUPINFO StartupInfo; //入口参数
|
||||
memset(&ProcessInfo, 0, sizeof(ProcessInfo));
|
||||
ZeroMemory(&StartupInfo, sizeof(StartupInfo));
|
||||
|
||||
StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
|
||||
StartupInfo.wShowWindow = SW_SHOW;
|
||||
//////////////////////////////////////////////////////////////////////////???
|
||||
StartupInfo.cb = sizeof(StartupInfo); //分配大小
|
||||
|
||||
unsigned long nTime = 0;
|
||||
int nAbandondeCount = 0;
|
||||
int nTimeoutCount = 0;
|
||||
bool bWriteFlash = false;
|
||||
|
||||
if(CreateProcess(szBatPath, NULL,NULL,NULL,FALSE,0,NULL,NULL,&StartupInfo,&ProcessInfo))
|
||||
{
|
||||
while(TRUE)
|
||||
{
|
||||
//如果烧写成功,则烧写下一个
|
||||
if (bWriteFlash)
|
||||
{
|
||||
break;
|
||||
}
|
||||
switch(WaitForSingleObject(ProcessInfo.hProcess,500))
|
||||
{
|
||||
case WAIT_ABANDONED:
|
||||
nTime += 500;
|
||||
if (nAbandondeCount++ > 200)
|
||||
{
|
||||
CloseHandle(ProcessInfo.hThread);
|
||||
CloseHandle(ProcessInfo.hProcess);
|
||||
return ;
|
||||
}
|
||||
break;
|
||||
case WAIT_TIMEOUT:
|
||||
nTime += 500;
|
||||
if (nTimeoutCount++ > 900)
|
||||
{
|
||||
CloseHandle(ProcessInfo.hThread);
|
||||
CloseHandle(ProcessInfo.hProcess);
|
||||
return ;
|
||||
}
|
||||
break;
|
||||
case WAIT_OBJECT_0:
|
||||
CloseHandle(ProcessInfo.hThread);
|
||||
CloseHandle(ProcessInfo.hProcess);
|
||||
if (nTime > 40000)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("更新License文件失败,请检查操作系统环境."));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("UpDate License failed, please check operation system environment"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return ;
|
||||
}
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("升级成功."));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Upgrade success."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
bWriteFlash = true;
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
szBatPath = ".\\tools\\LICENSE.bat";
|
||||
memset(&ProcessInfo, 0, sizeof(ProcessInfo));
|
||||
ZeroMemory(&StartupInfo, sizeof(StartupInfo));
|
||||
|
||||
StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
|
||||
StartupInfo.wShowWindow = SW_SHOW;
|
||||
StartupInfo.cb = sizeof(StartupInfo); //分配大小
|
||||
nTime = 0;
|
||||
nAbandondeCount = 0;
|
||||
nTimeoutCount = 0;
|
||||
|
||||
if(CreateProcess(szBatPath, NULL,NULL,NULL,FALSE,0,NULL,NULL,&StartupInfo,&ProcessInfo))
|
||||
{
|
||||
while(TRUE)
|
||||
{
|
||||
switch(WaitForSingleObject(ProcessInfo.hProcess,500))
|
||||
{
|
||||
case WAIT_ABANDONED:
|
||||
nTime += 500;
|
||||
if (nAbandondeCount++ > 200)
|
||||
{
|
||||
CloseHandle(ProcessInfo.hThread);
|
||||
CloseHandle(ProcessInfo.hProcess);
|
||||
return ;
|
||||
}
|
||||
break;
|
||||
case WAIT_TIMEOUT:
|
||||
nTime += 500;
|
||||
if (nTimeoutCount++ > 900)
|
||||
{
|
||||
CloseHandle(ProcessInfo.hThread);
|
||||
CloseHandle(ProcessInfo.hProcess);
|
||||
return ;
|
||||
}
|
||||
break;
|
||||
case WAIT_OBJECT_0:
|
||||
CloseHandle(ProcessInfo.hThread);
|
||||
CloseHandle(ProcessInfo.hProcess);
|
||||
if (nTime > 40000)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("更新License文件失败,请检查操作系统环境."));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Update License failed, please check operation system environment"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return ;
|
||||
}
|
||||
return ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
// OperMediumPt.cpp: implementation of the COperMediumPt class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "geomative.h"
|
||||
#include "OperMediumPt.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
extern int g_iUILanguage;
|
||||
COperMediumPt::COperMediumPt(int iAR)
|
||||
{
|
||||
m_iAR = iAR;
|
||||
m_mapDepthSort.clear();
|
||||
|
||||
}
|
||||
|
||||
COperMediumPt::~COperMediumPt()
|
||||
{
|
||||
m_mapDepthSort.clear();
|
||||
|
||||
}
|
||||
|
||||
bool COperMediumPt::InitiSortInfo(int iMethod)
|
||||
{
|
||||
if (1 == iMethod )
|
||||
{
|
||||
if ((m_iAR > 16 && m_iAR < 39) || AR_CROSS_HOLE_TYPE == m_iAR || AR_BIPOLE_HOLE_SPT == m_iAR)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("不支持深度排序"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Unsupport sort by depth medium"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return false;
|
||||
}
|
||||
m_mapDepthSort.clear();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("未知排序方法"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Unknow sort method"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool COperMediumPt::AddSortPtInfo(int iA, int iB, int iM, int iN, int iLayer,int iIndex)
|
||||
{
|
||||
STDepthSortKey stDepSortKey;
|
||||
stDepSortKey.fXPos = GetUniSptXPos(iA, iB, iM, iN);
|
||||
stDepSortKey.iLayer = iLayer;
|
||||
m_mapDepthSort[stDepSortKey] = iIndex;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
float COperMediumPt::GetUniSptXPos(int iA, int iB, int iM, int iN)
|
||||
{
|
||||
|
||||
int iMin = 100000, iMax = 0, iTotalVal = 0;
|
||||
int iDataArr[4] = {iA, iB, iM, iN};
|
||||
int iNegativeCnt = 0;//非正整数的个数
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (iDataArr[i] > 0)
|
||||
{
|
||||
if (iDataArr[i] > iMax)
|
||||
{
|
||||
iMax = iDataArr[i];
|
||||
}
|
||||
if (iDataArr[i] < iMin)
|
||||
{
|
||||
iMin = iDataArr[i];
|
||||
}
|
||||
iTotalVal += iDataArr[i];
|
||||
}
|
||||
else
|
||||
iNegativeCnt++;
|
||||
}
|
||||
//如果全部是正整数(四级装置),则此时iTotalVal表示的是四个数的总和,那么需要剪掉最大的和最小的
|
||||
if (0 == iNegativeCnt)
|
||||
return (iTotalVal-iMin-iMax)*1.0/2;
|
||||
|
||||
//如果此时是三级装置,那么此时只需要减掉最小值即可
|
||||
if (1 == iNegativeCnt)
|
||||
return (iTotalVal-iMin)*1.0/2;
|
||||
|
||||
//如果是二级装置,则不需进行再处理
|
||||
if (2 == iNegativeCnt)
|
||||
return iTotalVal*1.0/2;
|
||||
|
||||
CString strErr;
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
strErr.Format(_T("GetUniSptXPos错误,负数为%d"), iNegativeCnt);
|
||||
AfxMessageBox(strErr);
|
||||
}
|
||||
else
|
||||
{
|
||||
strErr.Format(_T("GetUniSptXPos error,number of negative is %d"), iNegativeCnt);
|
||||
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int COperMediumPt::GetFirstSortID(int iMethod)
|
||||
{
|
||||
m_iterSortDepth = m_mapDepthSort.begin();
|
||||
if (m_iterSortDepth == m_mapDepthSort.end())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return m_iterSortDepth->second;
|
||||
|
||||
}
|
||||
|
||||
int COperMediumPt::GetNextSortID()
|
||||
{
|
||||
m_iterSortDepth++;
|
||||
if (m_iterSortDepth == m_mapDepthSort.end())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return m_iterSortDepth->second;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,863 @@
|
||||
// SptOperator.cpp: implementation of the CSptOperator class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "geomative.h"
|
||||
#include "SptOperator.h"
|
||||
#include "navsptview.h"
|
||||
#include "Constant.h"
|
||||
|
||||
#include "appsptview.h"
|
||||
#include "appcesptview.h"
|
||||
|
||||
#include "appsptdetaillistview.h"
|
||||
#include "appsptconlistview.h"
|
||||
#include "appcesptconlistview.h"
|
||||
#include "appsptchannellistview.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
extern CGeoMativeApp theApp;
|
||||
extern int g_iLanguage;
|
||||
extern int g_iTransFileMode;
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
extern HHOOK hHook;
|
||||
extern LRESULT __stdcall CBTHookProc(long nCode, WPARAM wParam, LPARAM lParam);
|
||||
CSptOperator::CSptOperator(_ConnectionPtr& pConnection)
|
||||
{
|
||||
ASSERT(NULL != pConnection);
|
||||
m_pConnection = pConnection;
|
||||
}
|
||||
|
||||
CSptOperator::~CSptOperator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool CSptOperator::InitialNavExecView(CNavSptView* pNavExecView)
|
||||
{
|
||||
if (NULL != pNavExecView)
|
||||
{
|
||||
if (EN_TRANSFER_FILE_BY_CLOUND != g_iTransFileMode)
|
||||
{
|
||||
if (true != InitialNavExecCEDlg(pNavExecView->m_navCEDlg))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (true != InitialNavExec2DDlg(pNavExecView->m_nav2DDlg))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (true != InitialNavExec3DDlg(pNavExecView->m_nav3DDlg))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSptOperator::ShowCEScriptConInfo(DWORD dwSptHandle, CView* pAppExecView)
|
||||
{
|
||||
((CScript2D*)theApp.m_pSptManager->GetScript(dwSptHandle))->ShowSptDetailInfo(((CAppSptDetailListView*)(((CAppCESptView*)pAppExecView)->m_pDetailListView))->GetListCtrl());
|
||||
((CScript2D*)theApp.m_pSptManager->GetScript(dwSptHandle))->ShowChannelList(((CAppSptChannelListView*)(((CAppCESptView*)pAppExecView)->m_pContentListView))->GetListCtrl());
|
||||
((CScript2D*)theApp.m_pSptManager->GetScript(dwSptHandle))->ShowSptConInfo(((CAppCESptConListView*)(((CAppCESptView*)pAppExecView)->m_pScriptListView))->GetListCtrl());
|
||||
}
|
||||
|
||||
void CSptOperator::Show2DScriptConInfo(DWORD dwSptHandle, CView* pAppExecView)
|
||||
{
|
||||
((CScript2D*)theApp.m_pSptManager->GetScript(dwSptHandle))->ShowSptDetailInfo(((CAppSptDetailListView*)(((CAppSptView*)pAppExecView)->m_pDetailListView))->GetListCtrl());
|
||||
((CScript2D*)theApp.m_pSptManager->GetScript(dwSptHandle))->ShowChannelList(((CAppSptChannelListView*)(((CAppSptView*)pAppExecView)->m_pContentListView))->GetListCtrl());
|
||||
((CScript2D*)theApp.m_pSptManager->GetScript(dwSptHandle))->ShowSptConInfo(((CAppSptConListView*)(((CAppSptView*)pAppExecView)->m_pScriptListView))->GetListCtrl());
|
||||
((CAppSptConListView*)(((CAppSptView*)pAppExecView)->m_pScriptListView))->Invalidate();
|
||||
|
||||
}
|
||||
|
||||
void CSptOperator::Show3DScriptConInfo(DWORD dwSptHandle, CView* pAppExecView)
|
||||
{
|
||||
((CScript2D*)theApp.m_pSptManager->GetScript(dwSptHandle))->ShowSptDetailInfo(((CAppSptDetailListView*)(((CAppSptView*)pAppExecView)->m_pDetailListView))->GetListCtrl());
|
||||
((CScript2D*)theApp.m_pSptManager->GetScript(dwSptHandle))->ShowChannelList(((CAppSptChannelListView*)(((CAppSptView*)pAppExecView)->m_pContentListView))->GetListCtrl());
|
||||
((CScript2D*)theApp.m_pSptManager->GetScript(dwSptHandle))->ShowSptConInfo(((CAppSptConListView*)(((CAppSptView*)pAppExecView)->m_pScriptListView))->GetListCtrl());
|
||||
((CAppSptConListView*)(((CAppSptView*)pAppExecView)->m_pScriptListView))->Invalidate();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
bool CSptOperator::InitialNavExecMedDlg(CNavExecMedDlg& navExecMedDlg)
|
||||
{
|
||||
CString szRootLabel = _T("");
|
||||
CString szSql = _T("");
|
||||
|
||||
_RecordsetPtr pRecMed = NULL;
|
||||
HTREEITEM hMedRootItem = NULL;
|
||||
HTREEITEM hMedItem = NULL;
|
||||
DWORD dwMedHandle = (DWORD)VAL_ZERO;
|
||||
|
||||
UINT uMedDefImageState = (UINT)VAL_ZERO;
|
||||
|
||||
CTreeCtrl& medTree = navExecMedDlg.m_medTree;
|
||||
|
||||
uMedDefImageState = m_stateProcessor.ChangeToImageState(PZ_STATE_DB);
|
||||
pRecMed.CreateInstance(_uuidof(Recordset));
|
||||
|
||||
szRootLabel.Empty();
|
||||
szRootLabel.LoadString(IDS_MED_DEFAULT);
|
||||
hMedRootItem = medTree.InsertItem((LPCTSTR)szRootLabel);
|
||||
dwMedHandle = m_handleProcessor.GenerateHandle(VAL_ZERO, PZ_STYLE_MED_DEF);
|
||||
medTree.SetItemData(hMedRootItem, dwMedHandle);
|
||||
medTree.SetItemState(hMedRootItem, TVIS_BOLD, TVIS_BOLD);
|
||||
|
||||
szSql.Empty();
|
||||
szSql.Format(_T("select AR,MEname from medium where LANG = %d"), g_iLanguage);
|
||||
pRecMed->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
|
||||
while (VAL_ZERO == pRecMed->adoEOF)
|
||||
{
|
||||
hMedItem = medTree.InsertItem(pRecMed->GetCollect(_T("MEname")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecMed->GetCollect(_T("MEname")),
|
||||
hMedRootItem);
|
||||
dwMedHandle = m_handleProcessor.GenerateHandle((DWORD)pRecMed->GetCollect(_T("AR")).ulVal, PZ_STYLE_MED_DEF);
|
||||
medTree.SetItemData(hMedItem, dwMedHandle);
|
||||
medTree.SetItemState(hMedItem, uMedDefImageState, TVIS_STATEIMAGEMASK);
|
||||
|
||||
pRecMed->MoveNext();
|
||||
}
|
||||
pRecMed->Close();
|
||||
|
||||
medTree.Expand(hMedRootItem, TVE_EXPAND);
|
||||
|
||||
szRootLabel.Empty();
|
||||
szRootLabel.LoadString(IDS_MED_CUSTOM);
|
||||
hMedRootItem = medTree.InsertItem((LPCTSTR)szRootLabel);
|
||||
dwMedHandle = m_handleProcessor.GenerateHandle(VAL_ZERO, PZ_STYLE_MED_CUS);
|
||||
medTree.SetItemData(hMedRootItem, dwMedHandle);
|
||||
medTree.SetItemState(hMedRootItem, TVIS_BOLD, TVIS_BOLD);
|
||||
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
void CSptOperator::ShowScriptFileInfo(DWORD dwSFHandle, CView* pAppExecView)
|
||||
{
|
||||
CString szSql = _T("");
|
||||
DWORD dwSFID = (DWORD)VAL_ZERO;
|
||||
DWORD dwSConID = (DWORD)VAL_ZERO;
|
||||
_RecordsetPtr pRecSF = NULL;
|
||||
|
||||
dwSFID = m_handleProcessor.GetIDFromHandle(dwSFHandle);
|
||||
|
||||
pRecSF.CreateInstance(_uuidof(Recordset));
|
||||
szSql.Empty();
|
||||
szSql.Format(_T("select SCID from sfile where ID = %u"), dwSFID);
|
||||
pRecSF->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
|
||||
if ((long)VAL_ZERO != pRecSF->GetRecordCount())
|
||||
{
|
||||
dwSConID = (DWORD)pRecSF->GetCollect(_T("SCID")).ulVal;
|
||||
ShowScriptConInfo(dwSConID, pAppExecView);
|
||||
}
|
||||
pRecSF->Close();
|
||||
}
|
||||
|
||||
void CSptOperator::ShowDevInfoInExecMng(DWORD dwDevHandle, CView *pAppExecView)
|
||||
{
|
||||
DWORD dwDevID = (DWORD)VAL_ZERO;
|
||||
|
||||
dwDevID = this->m_handleProcessor.GetIDFromHandle(dwDevHandle);
|
||||
theApp.m_pDevManager->GetDeviceByID(dwDevID)->ShowDetailInfo(((CAppExecDevDetailListView*)(((CAppExecDevView*)pAppExecView)->m_pDetailListView))->GetListCtrl());
|
||||
theApp.m_pSptManager->ShowScriptFileList(dwDevHandle, ((CAppExecSptFileListView*)(((CAppExecDevView*)pAppExecView)->m_pContentListView))->GetListCtrl());
|
||||
}
|
||||
|
||||
UINT CSptOperator::CreateScriptFileInOffline(CNavSptView* pNavExecView)
|
||||
{
|
||||
UINT uExecCode = (UINT)VAL_ZERO;
|
||||
|
||||
HTREEITEM hDevItem = NULL;
|
||||
DWORD dwDevHandle = (DWORD)VAL_ZERO;
|
||||
DWORD dwDevID = (DWORD)VAL_ZERO;
|
||||
|
||||
hDevItem = pNavExecView->m_navSptDlg.m_sptTree.GetSelectedItem();
|
||||
dwDevHandle = pNavExecView->m_navSptDlg.m_sptTree.GetItemData(hDevItem);
|
||||
dwDevID = m_handleProcessor.GetIDFromHandle(dwDevHandle);
|
||||
|
||||
try
|
||||
{
|
||||
m_pConnection->BeginTrans();
|
||||
uExecCode = theApp.m_pSptManager->CreateScriptFileInOffline(dwDevID);
|
||||
|
||||
if (APP_SUCCESS == uExecCode)
|
||||
{
|
||||
AddSFItemToSptTree(pNavExecView->m_navSptDlg.m_sptTree);
|
||||
m_pConnection->CommitTrans();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pConnection->RollbackTrans();
|
||||
}
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
theApp.GetMainWnd()->EnableWindow(TRUE);
|
||||
m_pConnection->RollbackTrans();
|
||||
return APP_ERR_DB;
|
||||
}
|
||||
|
||||
pNavExecView->m_navSptDlg.m_sptTree.SelectItem(NULL);
|
||||
pNavExecView->m_navSptDlg.m_sptTree.SelectItem(hDevItem);
|
||||
return uExecCode;
|
||||
}
|
||||
|
||||
UINT CSptOperator::DeleteScriptFileInLoc(CNavSptView* pNavExecView)
|
||||
{
|
||||
UINT uExecCode = (UINT)VAL_ZERO;
|
||||
|
||||
HTREEITEM hDevItem = NULL;
|
||||
HTREEITEM hSFItem = NULL;
|
||||
DWORD dwSFHandle = (DWORD)VAL_ZERO;
|
||||
DWORD dwSFID = (DWORD)VAL_ZERO;
|
||||
|
||||
hSFItem = pNavExecView->m_navSptDlg.m_sptTree.GetSelectedItem();
|
||||
hDevItem = pNavExecView->m_navSptDlg.m_sptTree.GetParentItem(hSFItem);
|
||||
dwSFHandle = pNavExecView->m_navSptDlg.m_sptTree.GetItemData(hSFItem);
|
||||
dwSFID = m_handleProcessor.GetIDFromHandle(dwSFHandle);
|
||||
|
||||
try
|
||||
{
|
||||
m_pConnection->BeginTrans();
|
||||
theApp.m_pSptManager->DeleteScriptFileInLoc(dwSFID);
|
||||
|
||||
m_pConnection->CommitTrans();
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
m_pConnection->RollbackTrans();
|
||||
return APP_ERR_DB;
|
||||
}
|
||||
|
||||
pNavExecView->m_navSptDlg.m_sptTree.DeleteItem(hSFItem);
|
||||
pNavExecView->m_navSptDlg.m_sptTree.SelectItem(NULL);
|
||||
pNavExecView->m_navSptDlg.m_sptTree.SelectItem(hDevItem);
|
||||
|
||||
return APP_SUCCESS;
|
||||
}
|
||||
|
||||
HTREEITEM CSptOperator::FindSFItemInNavSptTree(DWORD dwDevID, CString szSFName, CTreeCtrl& sptTree)
|
||||
{
|
||||
HTREEITEM hDevItem = NULL;
|
||||
HTREEITEM hSFItem = NULL;
|
||||
_RecordsetPtr pRecSFID = NULL;
|
||||
|
||||
DWORD dwDevHandle = (DWORD)VAL_ZERO;
|
||||
DWORD dwSFHandle = (DWORD)VAL_ZERO;
|
||||
DWORD dwSFID = (DWORD)VAL_ZERO;
|
||||
|
||||
CString szSql;
|
||||
pRecSFID.CreateInstance(_uuidof(Recordset));
|
||||
|
||||
szSql.Empty();
|
||||
szSql.Format(_T("select ID from sfile where SFname = '%s'"), szSFName);
|
||||
|
||||
pRecSFID->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
|
||||
if ((long)VAL_ZERO != pRecSFID->GetRecordCount())
|
||||
{
|
||||
dwSFID = pRecSFID->GetCollect(_T("ID")).ulVal;
|
||||
|
||||
dwSFHandle = m_handleProcessor.GenerateHandle(dwSFID, PZ_STYLE_SPT_FILE);
|
||||
dwDevHandle = m_handleProcessor.GenerateHandle(dwDevID, PZ_STYLE_DEV_SPT);
|
||||
|
||||
hDevItem = sptTree.GetRootItem();
|
||||
hDevItem = sptTree.GetNextSiblingItem(hDevItem);
|
||||
|
||||
hDevItem = sptTree.GetChildItem(hDevItem);
|
||||
|
||||
while (NULL != hDevItem)
|
||||
{
|
||||
if ((sptTree.GetItemData(hDevItem) == dwDevHandle) && (sptTree.ItemHasChildren(hDevItem)))
|
||||
{
|
||||
hSFItem = sptTree.GetChildItem(hDevItem);
|
||||
while (NULL != hSFItem)
|
||||
{
|
||||
if (sptTree.GetItemData(hSFItem) == dwSFHandle)
|
||||
{
|
||||
return hSFItem;
|
||||
}
|
||||
hSFItem = sptTree.GetNextSiblingItem(hSFItem);
|
||||
}
|
||||
}
|
||||
hDevItem = sptTree.GetNextSiblingItem(hDevItem);
|
||||
}
|
||||
}
|
||||
|
||||
pRecSFID->Close();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
HTREEITEM CSptOperator::FindSFItemInNavSptTree(DWORD dwDevID, DWORD dwSFID, CTreeCtrl& sptTree)
|
||||
{
|
||||
HTREEITEM hDevItem = NULL;
|
||||
HTREEITEM hSFItem = NULL;
|
||||
|
||||
DWORD dwDevHandle = (DWORD)VAL_ZERO;
|
||||
DWORD dwSFHandle = (DWORD)VAL_ZERO;
|
||||
|
||||
dwSFHandle = m_handleProcessor.GenerateHandle(dwSFID, PZ_STYLE_SPT_FILE);
|
||||
dwDevHandle = m_handleProcessor.GenerateHandle(dwDevID, PZ_STYLE_DEV_SPT);
|
||||
|
||||
hDevItem = sptTree.GetRootItem();
|
||||
hDevItem = sptTree.GetNextSiblingItem(hDevItem);
|
||||
|
||||
hDevItem = sptTree.GetChildItem(hDevItem);
|
||||
|
||||
while (NULL != hDevItem)
|
||||
{
|
||||
if ((sptTree.GetItemData(hDevItem) == dwDevHandle) && (sptTree.ItemHasChildren(hDevItem)))
|
||||
{
|
||||
hSFItem = sptTree.GetChildItem(hDevItem);
|
||||
while (NULL != hSFItem)
|
||||
{
|
||||
if (sptTree.GetItemData(hSFItem) == dwSFHandle)
|
||||
{
|
||||
return hSFItem;
|
||||
}
|
||||
hSFItem = sptTree.GetNextSiblingItem(hSFItem);
|
||||
}
|
||||
}
|
||||
hDevItem = sptTree.GetNextSiblingItem(hDevItem);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
void CSptOperator::AddSFItemToSptTree(CTreeCtrl& sptTree)
|
||||
{
|
||||
_RecordsetPtr pRecSF = NULL;
|
||||
|
||||
CString szSql = _T("");
|
||||
|
||||
HTREEITEM hSFItem = NULL;
|
||||
HTREEITEM hDevItem = NULL;
|
||||
|
||||
DWORD dwSFHandle = (DWORD)VAL_ZERO;
|
||||
DWORD dwDevHandle = (DWORD)VAL_ZERO;
|
||||
DWORD dwDevID = (DWORD)VAL_ZERO;
|
||||
|
||||
UINT uSFImageState = (UINT)VAL_ZERO;
|
||||
|
||||
hDevItem = sptTree.GetSelectedItem();
|
||||
dwDevHandle = sptTree.GetItemData(hDevItem);
|
||||
dwDevID = m_handleProcessor.GetIDFromHandle(dwDevHandle);
|
||||
|
||||
uSFImageState = m_stateProcessor.ChangeToImageState(PZ_STATE_LOC);
|
||||
pRecSF.CreateInstance(_uuidof(Recordset));
|
||||
|
||||
szSql.Empty();
|
||||
szSql.Format(_T("select ID,SFname from sfile where DEID = %u order by ID"), dwDevID);
|
||||
|
||||
pRecSF->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
|
||||
while ((short)VAL_ZERO == pRecSF->adoEOF)
|
||||
{
|
||||
if (NULL == FindSFItemInNavSptTree(dwDevID, (DWORD)pRecSF->GetCollect(_T("ID")).ulVal, sptTree))
|
||||
{
|
||||
hSFItem = sptTree.InsertItem(pRecSF->GetCollect(_T("SFname")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSF->GetCollect(_T("SFname")),
|
||||
hDevItem);
|
||||
dwSFHandle = m_handleProcessor.GenerateHandle((DWORD)pRecSF->GetCollect(_T("ID")).ulVal, PZ_STYLE_SPT_FILE);
|
||||
|
||||
sptTree.SetItemData(hSFItem, dwSFHandle);
|
||||
sptTree.SetItemState(hSFItem, uSFImageState, TVIS_STATEIMAGEMASK);
|
||||
}
|
||||
pRecSF->MoveNext();
|
||||
}
|
||||
pRecSF->Close();
|
||||
|
||||
sptTree.Expand(hDevItem, TVE_EXPAND);
|
||||
}
|
||||
*/
|
||||
|
||||
bool CSptOperator::InitialNavExecCEDlg(CNavSptCEDlg &navExecCEDlg)
|
||||
{
|
||||
_RecordsetPtr pRecSCon = NULL;
|
||||
CListCtrl& ceList = navExecCEDlg.m_ceList;
|
||||
int iIndex = 0;
|
||||
DWORD dwHandle = 0;
|
||||
|
||||
UINT uImageState = (UINT)VAL_ZERO;
|
||||
|
||||
ceList.DeleteAllItems();
|
||||
|
||||
uImageState = m_stateProcessor.ChangeToImageState(PZ_STATE_DB);
|
||||
pRecSCon.CreateInstance(_uuidof(Recordset));
|
||||
|
||||
pRecSCon->Open(_T("select ID,Sname,definer,Format(DEdate,'YYYY-MM-DD') as DEdate from scon where Stype = 0 order by DEdate desc"),
|
||||
_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
|
||||
while ((short)VAL_ZERO == pRecSCon->adoEOF)
|
||||
{
|
||||
ceList.InsertItem(iIndex, (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("Sname")));
|
||||
ceList.SetItemText(iIndex, 1, pRecSCon->GetCollect(_T("definer")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("definer")));
|
||||
|
||||
ceList.SetItemText(iIndex, 2, (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("DEdate")));
|
||||
|
||||
dwHandle = m_handleProcessor.GenerateHandle((DWORD)pRecSCon->GetCollect(_T("ID")).ulVal, PZ_STYLE_SCON_CE);
|
||||
ceList.SetItemData(iIndex, dwHandle);
|
||||
ceList.SetItemState(iIndex, uImageState, LVIS_STATEIMAGEMASK);
|
||||
|
||||
iIndex++;
|
||||
pRecSCon->MoveNext();
|
||||
}
|
||||
pRecSCon->Close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CSptOperator::InitialNavExec2DDlg(CNavSpt2DDlg &navExec2DDlg)
|
||||
{
|
||||
_RecordsetPtr pRecSCon = NULL;
|
||||
CListCtrl& sconList = navExec2DDlg.m_2dList;
|
||||
int iIndex = 0;
|
||||
DWORD dwHandle = 0;
|
||||
|
||||
UINT uImageState = (UINT)VAL_ZERO;
|
||||
|
||||
sconList.DeleteAllItems();
|
||||
|
||||
uImageState = m_stateProcessor.ChangeToImageState(PZ_STATE_DB);
|
||||
pRecSCon.CreateInstance(_uuidof(Recordset));
|
||||
|
||||
pRecSCon->Open(_T("select ID,Sname,definer,Format(DEdate,'YYYY-MM-DD') as DEdate from scon where Stype = 1 order by DEdate desc"),
|
||||
_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
|
||||
while ((short)VAL_ZERO == pRecSCon->adoEOF)
|
||||
{
|
||||
sconList.InsertItem(iIndex, (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("Sname")));
|
||||
sconList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("definer")));
|
||||
sconList.SetItemText(iIndex, 2, (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("DEdate")));
|
||||
|
||||
dwHandle = m_handleProcessor.GenerateHandle((DWORD)pRecSCon->GetCollect(_T("ID")).ulVal, PZ_STYLE_SCON_2D);
|
||||
sconList.SetItemData(iIndex, dwHandle);
|
||||
sconList.SetItemState(iIndex, uImageState, LVIS_STATEIMAGEMASK);
|
||||
|
||||
iIndex++;
|
||||
pRecSCon->MoveNext();
|
||||
}
|
||||
pRecSCon->Close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CSptOperator::InitialNavExec3DDlg(CNavSpt3DDlg &navExec3DDlg)
|
||||
{
|
||||
_RecordsetPtr pRecSCon = NULL;
|
||||
CListCtrl& sconList = navExec3DDlg.m_3dList;
|
||||
int iIndex = 0;
|
||||
DWORD dwHandle = 0;
|
||||
|
||||
UINT uImageState = (UINT)VAL_ZERO;
|
||||
|
||||
sconList.DeleteAllItems();
|
||||
|
||||
uImageState = m_stateProcessor.ChangeToImageState(PZ_STATE_DB);
|
||||
pRecSCon.CreateInstance(_uuidof(Recordset));
|
||||
|
||||
pRecSCon->Open(_T("select ID,Sname,definer,Format(DEdate,'YYYY-MM-DD') as DEdate from scon where Stype = 2 order by DEdate desc"),
|
||||
_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
|
||||
while ((short)VAL_ZERO == pRecSCon->adoEOF)
|
||||
{
|
||||
sconList.InsertItem(iIndex, (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("Sname")));
|
||||
sconList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("definer")));
|
||||
sconList.SetItemText(iIndex, 2, (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("DEdate")));
|
||||
|
||||
dwHandle = m_handleProcessor.GenerateHandle((DWORD)pRecSCon->GetCollect(_T("ID")).ulVal, PZ_STYLE_SCON_3D);
|
||||
sconList.SetItemData(iIndex, dwHandle);
|
||||
sconList.SetItemState(iIndex, uImageState, LVIS_STATEIMAGEMASK);
|
||||
|
||||
iIndex++;
|
||||
pRecSCon->MoveNext();
|
||||
}
|
||||
pRecSCon->Close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
UINT CSptOperator::Create2DSConInDB(CNavSptView* pNavExecView)
|
||||
{
|
||||
DWORD dwSConID = (DWORD)VAL_ZERO;
|
||||
UINT uExecCode = (UINT)VAL_ZERO;
|
||||
|
||||
try
|
||||
{
|
||||
// m_pConnection->BeginTrans();
|
||||
uExecCode = theApp.m_pSptManager->Create2DSConInDB(dwSConID);
|
||||
if (APP_SUCCESS == uExecCode)
|
||||
{
|
||||
this->AddSConItemToSConList(dwSConID, pNavExecView->m_nav2DDlg.m_2dList);
|
||||
// m_pConnection->CommitTrans();
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// m_pConnection->RollbackTrans();
|
||||
// }
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
// m_pConnection->RollbackTrans();
|
||||
return APP_ERR_DB;
|
||||
}
|
||||
|
||||
return uExecCode;
|
||||
}
|
||||
|
||||
UINT CSptOperator::Delete2DSConInDB(CNavSptView* pNavExecView)
|
||||
{
|
||||
_RecordsetPtr pRecSFID = NULL;
|
||||
|
||||
int iSConIndex = (int)VAL_ZERO;
|
||||
POSITION posSCon;
|
||||
|
||||
DWORD dwSConHandle = (DWORD)VAL_ZERO;
|
||||
DWORD dwSConID = (DWORD)VAL_ZERO;
|
||||
|
||||
CString szSql = _T("");
|
||||
|
||||
posSCon = pNavExecView->m_nav2DDlg.m_2dList.GetFirstSelectedItemPosition();
|
||||
iSConIndex = pNavExecView->m_nav2DDlg.m_2dList.GetNextSelectedItem(posSCon);
|
||||
|
||||
dwSConHandle = pNavExecView->m_nav2DDlg.m_2dList.GetItemData(iSConIndex);
|
||||
|
||||
dwSConID = m_handleProcessor.GetIDFromHandle(dwSConHandle);
|
||||
|
||||
try
|
||||
{
|
||||
m_pConnection->BeginTrans();
|
||||
|
||||
theApp.m_pSptManager->Delete2DSConInDB(dwSConID);
|
||||
theApp.m_pSptManager->DeleteObjInMem(dwSConHandle);
|
||||
|
||||
pNavExecView->m_nav2DDlg.m_2dList.DeleteItem(iSConIndex);
|
||||
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
m_pConnection->RollbackTrans();
|
||||
return APP_ERR_DB;
|
||||
}
|
||||
|
||||
m_pConnection->CommitTrans();
|
||||
|
||||
return APP_SUCCESS;
|
||||
}
|
||||
|
||||
UINT CSptOperator::Export2DSConInDB(CNavSptView* pNavExecView)
|
||||
{
|
||||
_RecordsetPtr pRecSpt = NULL;
|
||||
|
||||
int iSConIndex = (int)VAL_ZERO;
|
||||
POSITION posSCon;
|
||||
|
||||
DWORD dwSConHandle = (DWORD)VAL_ZERO;
|
||||
DWORD dwSConID = (DWORD)VAL_ZERO;
|
||||
|
||||
posSCon = pNavExecView->m_nav2DDlg.m_2dList.GetFirstSelectedItemPosition();
|
||||
iSConIndex = pNavExecView->m_nav2DDlg.m_2dList.GetNextSelectedItem(posSCon);
|
||||
|
||||
dwSConHandle = pNavExecView->m_nav2DDlg.m_2dList.GetItemData(iSConIndex);
|
||||
|
||||
dwSConID = m_handleProcessor.GetIDFromHandle(dwSConHandle);
|
||||
CString strSptFilePath = pNavExecView->m_nav2DDlg.m_2dList.GetItemText(iSConIndex,0);
|
||||
CString strBackName = strSptFilePath;
|
||||
|
||||
CFileDialog* pFileDial = new CFileDialog(FALSE, _T("txt"), _T(""), OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY|OFN_NOCHANGEDIR,
|
||||
_T("txt files(*.txt)|*.txt|All Files (*.*)|*.*||"), NULL);
|
||||
pFileDial->m_ofn.lpstrTitle = _T("save files");
|
||||
pFileDial->m_ofn.lpstrFile = strBackName.GetBuffer(MAX_PATH);
|
||||
pFileDial->m_ofn.nMaxFile = MAX_PATH;
|
||||
if (IDOK != pFileDial->DoModal())
|
||||
{
|
||||
delete pFileDial;
|
||||
return APP_CANCLE;
|
||||
}
|
||||
strBackName.ReleaseBuffer();
|
||||
strSptFilePath = pFileDial->GetPathName();
|
||||
delete pFileDial;
|
||||
|
||||
if (theApp.m_pSptManager->Export2DSConInDB(dwSConID, strSptFilePath))
|
||||
{
|
||||
return APP_SUCCESS;
|
||||
}
|
||||
return APP_FAIL;
|
||||
}
|
||||
|
||||
UINT CSptOperator::Export3DSConInDB(CNavSptView* pNavExecView)
|
||||
{
|
||||
|
||||
int iSConIndex = (int)VAL_ZERO;
|
||||
POSITION posSCon;
|
||||
|
||||
DWORD dwSConHandle = (DWORD)VAL_ZERO;
|
||||
DWORD dwSConID = (DWORD)VAL_ZERO;
|
||||
|
||||
posSCon = pNavExecView->m_nav3DDlg.m_3dList.GetFirstSelectedItemPosition();
|
||||
iSConIndex = pNavExecView->m_nav3DDlg.m_3dList.GetNextSelectedItem(posSCon);
|
||||
|
||||
dwSConHandle = pNavExecView->m_nav3DDlg.m_3dList.GetItemData(iSConIndex);
|
||||
|
||||
dwSConID = m_handleProcessor.GetIDFromHandle(dwSConHandle);
|
||||
CString strSptFilePath = pNavExecView->m_nav3DDlg.m_3dList.GetItemText(iSConIndex,0);
|
||||
CString strBackName = strSptFilePath;
|
||||
CFileDialog* pFileDial= new CFileDialog(FALSE, _T("txt"), _T(""), OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY|OFN_NOCHANGEDIR,
|
||||
_T("txt files(*.txt)|*.txt|All Files (*.*)|*.*||"), NULL);
|
||||
pFileDial->m_ofn.lpstrTitle = _T("save files");
|
||||
pFileDial->m_ofn.lpstrFile = strBackName.GetBuffer(MAX_PATH);
|
||||
pFileDial->m_ofn.nMaxFile = MAX_PATH;
|
||||
if (IDOK != pFileDial->DoModal())
|
||||
{
|
||||
strBackName.ReleaseBuffer();
|
||||
delete pFileDial;
|
||||
return APP_CANCLE;
|
||||
}
|
||||
strBackName.ReleaseBuffer();
|
||||
strSptFilePath = pFileDial->GetPathName();
|
||||
delete pFileDial;
|
||||
if (theApp.m_pSptManager->Export3DSConInDB(dwSConID, strSptFilePath))
|
||||
{
|
||||
return APP_SUCCESS;
|
||||
}
|
||||
return APP_FAIL;
|
||||
|
||||
}
|
||||
|
||||
UINT CSptOperator::CreateCESConInDB(CNavSptView* pNavExecView)
|
||||
{
|
||||
DWORD dwSConID = (DWORD)VAL_ZERO;
|
||||
UINT uExecCode = (UINT)VAL_ZERO;
|
||||
|
||||
try
|
||||
{
|
||||
// m_pConnection->BeginTrans();
|
||||
uExecCode = theApp.m_pSptManager->CreateCESConInDB(dwSConID);
|
||||
if (APP_SUCCESS == uExecCode)
|
||||
{
|
||||
this->AddSConItemToSConList(dwSConID, pNavExecView->m_navCEDlg.m_ceList);
|
||||
// m_pConnection->CommitTrans();
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// m_pConnection->RollbackTrans();
|
||||
// }
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
// m_pConnection->RollbackTrans();
|
||||
return APP_ERR_DB;
|
||||
}
|
||||
|
||||
return uExecCode;
|
||||
}
|
||||
|
||||
UINT CSptOperator::DeleteCESConInDB(CNavSptView* pNavExecView)
|
||||
{
|
||||
_RecordsetPtr pRecSFID = NULL;
|
||||
|
||||
int iSConIndex = (int)VAL_ZERO;
|
||||
POSITION posSCon;
|
||||
|
||||
DWORD dwSConHandle = (DWORD)VAL_ZERO;
|
||||
DWORD dwSConID = (DWORD)VAL_ZERO;
|
||||
|
||||
CString szSql = _T("");
|
||||
|
||||
posSCon = pNavExecView->m_navCEDlg.m_ceList.GetFirstSelectedItemPosition();
|
||||
iSConIndex = pNavExecView->m_navCEDlg.m_ceList.GetNextSelectedItem(posSCon);
|
||||
|
||||
dwSConHandle = pNavExecView->m_navCEDlg.m_ceList.GetItemData(iSConIndex);
|
||||
|
||||
dwSConID = m_handleProcessor.GetIDFromHandle(dwSConHandle);
|
||||
|
||||
try
|
||||
{
|
||||
m_pConnection->BeginTrans();
|
||||
|
||||
theApp.m_pSptManager->DeleteCESConInDB(dwSConID);
|
||||
theApp.m_pSptManager->DeleteObjInMem(dwSConHandle);
|
||||
|
||||
pNavExecView->m_navCEDlg.m_ceList.DeleteItem(iSConIndex);
|
||||
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||||
AfxMessageBox(e.Description());
|
||||
m_pConnection->RollbackTrans();
|
||||
return APP_ERR_DB;
|
||||
}
|
||||
|
||||
m_pConnection->CommitTrans();
|
||||
|
||||
return APP_SUCCESS;
|
||||
}
|
||||
|
||||
void CSptOperator::AddSConItemToSConList(DWORD dwSConID, CListCtrl &sconList)
|
||||
{
|
||||
UINT uImageState = (UINT)VAL_ZERO;
|
||||
|
||||
int iIndex = (int)VAL_ZERO;
|
||||
|
||||
DWORD dwSConHandle = (DWORD)VAL_ZERO;
|
||||
|
||||
_RecordsetPtr pRecSCon = NULL;
|
||||
CString szSql = _T("");
|
||||
|
||||
pRecSCon.CreateInstance(_uuidof(Recordset));
|
||||
|
||||
szSql.Empty();
|
||||
szSql.Format(_T("select ID,Sname,Stype,definer,Format(DEdate,'YYYY-MM-DD') as DEdate from scon where ID = %u"), dwSConID);
|
||||
pRecSCon->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
|
||||
if ((long)VAL_ZERO != pRecSCon->GetRecordCount())
|
||||
{
|
||||
sconList.InsertItem(iIndex, (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("Sname")));
|
||||
sconList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("definer")));
|
||||
sconList.SetItemText(iIndex, 2, (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("DEdate")));
|
||||
|
||||
switch ((int)pRecSCon->GetCollect(_T("Stype")).iVal)
|
||||
{
|
||||
case 0:
|
||||
dwSConHandle = m_handleProcessor.GenerateHandle((DWORD)pRecSCon->GetCollect(_T("ID")).ulVal, PZ_STYLE_SCON_CE);
|
||||
break;
|
||||
case 1:
|
||||
dwSConHandle = m_handleProcessor.GenerateHandle((DWORD)pRecSCon->GetCollect(_T("ID")).ulVal, PZ_STYLE_SCON_2D);
|
||||
break;
|
||||
case 2:
|
||||
dwSConHandle = m_handleProcessor.GenerateHandle((DWORD)pRecSCon->GetCollect(_T("ID")).ulVal, PZ_STYLE_SCON_3D);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
sconList.SetItemData(iIndex, dwSConHandle);
|
||||
|
||||
uImageState = m_stateProcessor.ChangeToImageState(PZ_STATE_DB);
|
||||
sconList.SetItemState(iIndex, uImageState | LVIS_SELECTED | LVIS_FOCUSED, LVIS_STATEIMAGEMASK | LVIS_SELECTED | LVIS_FOCUSED);
|
||||
}
|
||||
pRecSCon->Close();
|
||||
}
|
||||
|
||||
//add by waston
|
||||
UINT CSptOperator::Create3DSConInDB(CNavSptView* pNavExecView)
|
||||
{
|
||||
DWORD dwSConID[128];//最多分割成128个子脚本,此处为适应脚本分割需求的修改
|
||||
memset(dwSConID, -1, 128);
|
||||
UINT uExecCode = (UINT)VAL_ZERO;
|
||||
|
||||
try
|
||||
{
|
||||
// m_pConnection->BeginTrans();
|
||||
uExecCode = theApp.m_pSptManager->Create3DSConInDB(dwSConID);
|
||||
if (APP_SUCCESS == uExecCode)
|
||||
{
|
||||
for(int i = 0; i < dwSConID[0] + 1; i++)
|
||||
{
|
||||
this->AddSConItemToSConList(dwSConID[i + 1], pNavExecView->m_nav3DDlg.m_3dList);
|
||||
}
|
||||
// m_pConnection->CommitTrans();
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// m_pConnection->RollbackTrans();
|
||||
// }
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
// m_pConnection->RollbackTrans();
|
||||
AfxMessageBox(e.Description());
|
||||
return APP_ERR_DB;
|
||||
}
|
||||
|
||||
return uExecCode;
|
||||
}
|
||||
|
||||
|
||||
UINT CSptOperator::Delete3DSConInDB(CNavSptView *pNavExecView)
|
||||
{
|
||||
_RecordsetPtr pRecSFID = NULL;
|
||||
|
||||
int iSConIndex = (int)VAL_ZERO;
|
||||
POSITION posSCon;
|
||||
|
||||
DWORD dwSConHandle = (DWORD)VAL_ZERO;
|
||||
DWORD dwSConID = (DWORD)VAL_ZERO;
|
||||
|
||||
CString szSql = _T("");
|
||||
|
||||
posSCon = pNavExecView->m_nav3DDlg.m_3dList.GetFirstSelectedItemPosition();
|
||||
iSConIndex = pNavExecView->m_nav3DDlg.m_3dList.GetNextSelectedItem(posSCon);
|
||||
|
||||
dwSConHandle = pNavExecView->m_nav3DDlg.m_3dList.GetItemData(iSConIndex);
|
||||
|
||||
dwSConID = m_handleProcessor.GetIDFromHandle(dwSConHandle);
|
||||
|
||||
try
|
||||
{
|
||||
m_pConnection->BeginTrans();
|
||||
|
||||
theApp.m_pSptManager->Delete3DSConInDB(dwSConID);
|
||||
theApp.m_pSptManager->DeleteObjInMem(dwSConHandle);
|
||||
|
||||
pNavExecView->m_nav3DDlg.m_3dList.DeleteItem(iSConIndex);
|
||||
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
m_pConnection->RollbackTrans();
|
||||
return APP_ERR_DB;
|
||||
}
|
||||
|
||||
m_pConnection->CommitTrans();
|
||||
|
||||
return APP_SUCCESS;
|
||||
}
|
||||
|
||||
UINT CSptOperator::Browse2DScript(CNavSptView *pNavExecView)
|
||||
{
|
||||
_RecordsetPtr pRecSFID = NULL;
|
||||
|
||||
int iSConIndex = (int)VAL_ZERO;
|
||||
POSITION posSCon;
|
||||
|
||||
DWORD dwSConHandle = (DWORD)VAL_ZERO;
|
||||
DWORD dwSConID = (DWORD)VAL_ZERO;
|
||||
|
||||
CString szSql = _T("");
|
||||
|
||||
posSCon = pNavExecView->m_nav2DDlg.m_2dList.GetFirstSelectedItemPosition();
|
||||
iSConIndex = pNavExecView->m_nav2DDlg.m_2dList.GetNextSelectedItem(posSCon);
|
||||
|
||||
dwSConHandle = pNavExecView->m_nav2DDlg.m_2dList.GetItemData(iSConIndex);
|
||||
|
||||
dwSConID = m_handleProcessor.GetIDFromHandle(dwSConHandle);
|
||||
|
||||
try
|
||||
{
|
||||
theApp.m_pSptManager->Browse2DScript(dwSConID);
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
return APP_ERR_DB;
|
||||
}
|
||||
|
||||
return APP_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
// SynOperator.cpp: implementation of the CSynOperator class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "geomative.h"
|
||||
#include "SynOperator.h"
|
||||
|
||||
#include "opsyndlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
extern CGeoMativeApp theApp;
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CSynOperator::CSynOperator(_ConnectionPtr& pConnection)
|
||||
{
|
||||
ASSERT(NULL != pConnection);
|
||||
m_pConnection = pConnection;
|
||||
}
|
||||
|
||||
CSynOperator::~CSynOperator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CSynOperator::Syn()
|
||||
{
|
||||
long lRet = VAL_ZERO;
|
||||
|
||||
COpSynDlg* pOpSynDlg = new COpSynDlg(m_pConnection);
|
||||
|
||||
|
||||
pOpSynDlg->Create(IDD_OP_TDH_S_C, AfxGetMainWnd());
|
||||
|
||||
InitialSynDlg(pOpSynDlg);
|
||||
pOpSynDlg->InitialDevShow();
|
||||
|
||||
pOpSynDlg->ShowWindow(SW_SHOW);
|
||||
|
||||
lRet = pOpSynDlg->RunModalLoop(MLF_SHOWONIDLE); // 开始非模态窗口模态循环
|
||||
|
||||
if (RET_OK == lRet)
|
||||
{
|
||||
NULL;
|
||||
}
|
||||
|
||||
pOpSynDlg->DestroyWindow();
|
||||
delete pOpSynDlg;
|
||||
}
|
||||
|
||||
void CSynOperator::InitialSynDlg(COpSynDlg *pOpSynDlg)
|
||||
{
|
||||
int iIndex = (int)VAL_ZERO;
|
||||
CPtrArray olDevList;
|
||||
CDevice* pDev = NULL;
|
||||
|
||||
olDevList.RemoveAll();
|
||||
theApp.m_pDevManager->GetOLDevList(&olDevList);
|
||||
|
||||
iIndex = (int)VAL_ZERO;
|
||||
|
||||
while (iIndex < olDevList.GetSize())
|
||||
{
|
||||
pDev = NULL;
|
||||
pDev = (CDevice*)olDevList.GetAt(iIndex);
|
||||
|
||||
if (PZ_STATE_NEW != pDev->m_uState)
|
||||
{
|
||||
pOpSynDlg->m_cbDESN.AddString(pDev->m_szDevSN);
|
||||
pOpSynDlg->m_cbDESN.SetItemDataPtr(pOpSynDlg->m_cbDESN.GetCount() - 1, pDev);
|
||||
}
|
||||
iIndex++;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,873 @@
|
||||
// UpdateDataBase.cpp: implementation of the CUpdateDataBase class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "geomative.h"
|
||||
#include "UpdateDataBase.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
extern SYSTEMTIME g_sysCurTime;
|
||||
extern int g_iUILanguage;
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CUpdateDataBase::CUpdateDataBase(_ConnectionPtr pConnection, CString strVer)
|
||||
{
|
||||
|
||||
m_strPreVersion = _T("");
|
||||
m_vtUpdateDBInfo.clear();
|
||||
m_pConnection = pConnection;
|
||||
m_pLog = fopen("LOG\\update_db.log", "ab+");
|
||||
m_strCurVer = strVer;
|
||||
if (NULL == m_pLog)
|
||||
{
|
||||
CString strLog = _T("");
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
strLog.Format(_T("打开 update_db.log 失败! 错误码 = %d"), GetLastError());
|
||||
AfxMessageBox(strLog);
|
||||
}
|
||||
else
|
||||
{
|
||||
strLog.Format(_T("Open update_db.log failed! error = %d"), GetLastError());
|
||||
MessageBoxEx(NULL, strLog, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CUpdateDataBase::~CUpdateDataBase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool CUpdateDataBase::QueryPreVersion()
|
||||
{
|
||||
|
||||
if (!CheckNecessaryVersion())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CString szSql= _T("select version from versioninfo");
|
||||
_RecordsetPtr pRecPro = NULL;
|
||||
|
||||
pRecPro.CreateInstance(_uuidof(Recordset));
|
||||
|
||||
pRecPro->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
if ((long)VAL_ZERO != pRecPro->GetRecordCount())
|
||||
{
|
||||
m_strPreVersion = pRecPro->GetCollect(_T("version")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("version"));
|
||||
}
|
||||
else
|
||||
{
|
||||
CString strTmp = _T("");
|
||||
pRecPro->Close();
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
strTmp.Format(_T("[%d]获取版本信息失败!!!"), __LINE__);
|
||||
AfxMessageBox(strTmp.GetBuffer(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
strTmp.Format(_T("[%d]Get version info failed!!!"), __LINE__);
|
||||
MessageBoxEx(NULL, strTmp, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
PrintLog(strTmp);
|
||||
return false;
|
||||
}
|
||||
pRecPro->Close();
|
||||
CString strTmp = _T("");
|
||||
strTmp.Format(_T("[%d] query version is %s"), m_strPreVersion.GetBuffer(0));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CUpdateDataBase::CheckNecessaryVersion()
|
||||
{
|
||||
CString szSql= _T("select version from versioninfo");
|
||||
_RecordsetPtr pRecPro = NULL;
|
||||
|
||||
pRecPro.CreateInstance(_uuidof(Recordset));
|
||||
|
||||
pRecPro->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||||
//如果查询到之前的版本信息,则不做任何操作,返回真
|
||||
if ((long)VAL_ZERO != pRecPro->GetRecordCount())
|
||||
{
|
||||
pRecPro->Close();
|
||||
return true;
|
||||
}
|
||||
//如果之前没有版本信息,则认为是1.5版本,插入相应的版本号
|
||||
pRecPro->Close();
|
||||
_CommandPtr pCmdUpd = NULL;
|
||||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||||
pCmdUpd->ActiveConnection = m_pConnection;
|
||||
try
|
||||
{
|
||||
m_pConnection->BeginTrans();
|
||||
szSql.Empty();
|
||||
szSql.Format(_T("insert into versioninfo(ID,version) values(1,'%s')"), _T("1.5.28"));
|
||||
pCmdUpd->CommandText = szSql.AllocSysString();
|
||||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||||
m_pConnection->CommitTrans();
|
||||
return true;
|
||||
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
m_pConnection->RollbackTrans();
|
||||
AfxMessageBox((LPCTSTR)e.Description());
|
||||
CString strLogInfo = _T("");
|
||||
strLogInfo.Format(_T("[%d] write necessary version failed, error_msg = %s"), __LINE__, (LPCTSTR)e.Description());
|
||||
PrintLog(strLogInfo);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CUpdateDataBase::WriteVersionToDB()
|
||||
{
|
||||
|
||||
CString strSql = _T("");
|
||||
CString strTmp = _T("");
|
||||
|
||||
if (m_strCurVer.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
strTmp.Format(_T("[%d] 版本参数为空!"), __LINE__);
|
||||
AfxMessageBox(strTmp.GetBuffer(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
strTmp.Format(_T("[%d] Version param is null!!!"), __LINE__);
|
||||
MessageBoxEx(NULL, strTmp, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
PrintLog(strTmp);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
_CommandPtr pCmdUpd = NULL;
|
||||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||||
pCmdUpd->ActiveConnection = m_pConnection;
|
||||
try
|
||||
{
|
||||
strSql.Format(_T("update versioninfo a set a.version = '%s' where a.id = 1;"), m_strCurVer.GetBuffer(0));
|
||||
m_pConnection->BeginTrans();
|
||||
pCmdUpd->CommandText = strSql.AllocSysString();
|
||||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||||
|
||||
m_pConnection->CommitTrans();
|
||||
return true;
|
||||
|
||||
strTmp.Empty();
|
||||
strTmp.Format(_T("[%d] write version is %s"), m_strPreVersion.GetBuffer(0));
|
||||
PrintLog(strTmp);
|
||||
return true;
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
m_pConnection->RollbackTrans();
|
||||
AfxMessageBox((LPCTSTR)e.Description());
|
||||
CString strLogInfo = _T("");
|
||||
strLogInfo.Format(_T("[%d] write version %s failed, error_msg = %s"), __LINE__,
|
||||
m_strCurVer.GetBuffer(0), (LPCTSTR)e.Description());
|
||||
PrintLog(strLogInfo);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
STColInfo CUpdateDataBase::GetColumnInfo(int nType)
|
||||
{
|
||||
STColInfo stCol;
|
||||
stCol.strColName = m_opXml.GetChildAttrib(_T("name"));
|
||||
CString strVal = _T("");
|
||||
strVal = m_opXml.GetChildAttrib(_T("modify_type"));
|
||||
if (!strVal.IsEmpty())
|
||||
{
|
||||
stCol.nModifyType = atoi(strVal.GetBuffer(0));
|
||||
strVal.Empty();
|
||||
}
|
||||
//增加表的操作
|
||||
if ((1 == nType) || (3 == nType && 1 == stCol.nModifyType) )
|
||||
{
|
||||
strVal = m_opXml.GetChildAttrib(_T("is_primary_key"));
|
||||
if (!strVal.IsEmpty())
|
||||
{
|
||||
stCol.nIsPrimaryKey = atoi(strVal.GetBuffer(0));
|
||||
}
|
||||
|
||||
strVal = m_opXml.GetChildAttrib(_T("value_type"));
|
||||
if (!strVal.IsEmpty())
|
||||
{
|
||||
stCol.nValueType = atoi(strVal.GetBuffer(0));
|
||||
}
|
||||
|
||||
strVal = m_opXml.GetChildAttrib(_T("attribute_value"));
|
||||
if (!strVal.IsEmpty())
|
||||
{
|
||||
stCol.nAttrType = atoi(strVal.GetBuffer(0));
|
||||
}
|
||||
|
||||
strVal = m_opXml.GetChildAttrib(_T("index"));
|
||||
if (!strVal.IsEmpty())
|
||||
{
|
||||
stCol.nIndex = atoi(strVal.GetBuffer(0));
|
||||
}
|
||||
|
||||
strVal = m_opXml.GetChildAttrib(_T("is_foreign_key"));
|
||||
if (!strVal.IsEmpty())
|
||||
{
|
||||
stCol.nIsForeignKey = atoi(strVal.GetBuffer(0));
|
||||
if (1 == stCol.nIsForeignKey)
|
||||
{
|
||||
stCol.strRefTableName = m_opXml.GetChildAttrib(_T("refer_table_name"));
|
||||
stCol.strRefTableCol = m_opXml.GetChildAttrib(_T("refer_table_col"));
|
||||
}
|
||||
}
|
||||
|
||||
strVal = m_opXml.GetChildAttrib(_T("is_empty"));
|
||||
if (!strVal.IsEmpty())
|
||||
{
|
||||
stCol.nIsEmpty = atoi(strVal.GetBuffer(0));
|
||||
}
|
||||
|
||||
strVal = m_opXml.GetChildAttrib(_T("is_compress"));
|
||||
if (!strVal.IsEmpty())
|
||||
{
|
||||
stCol.nIsCompress = atoi(strVal.GetBuffer(0));
|
||||
}
|
||||
|
||||
}
|
||||
else if (3 == nType && 3 == stCol.nModifyType)
|
||||
{
|
||||
strVal = m_opXml.GetChildAttrib(_T("value_type"));
|
||||
if (!strVal.IsEmpty())
|
||||
stCol.nValueType = atoi(strVal.GetBuffer(0));
|
||||
else
|
||||
stCol.nValueType = 0;
|
||||
|
||||
strVal = m_opXml.GetChildAttrib(_T("attribute_value"));
|
||||
if (!strVal.IsEmpty())
|
||||
stCol.nAttrType = atoi(strVal.GetBuffer(0));
|
||||
else
|
||||
stCol.nAttrType = 0;
|
||||
|
||||
strVal = m_opXml.GetChildAttrib(_T("index_modify"));
|
||||
if (!strVal.IsEmpty())
|
||||
stCol.nIndex = atoi(strVal.GetBuffer(0));
|
||||
else
|
||||
stCol.nIndex = 255;
|
||||
|
||||
strVal = m_opXml.GetChildAttrib(_T("foreign_key_modify"));
|
||||
if (!strVal.IsEmpty())
|
||||
{
|
||||
stCol.nIsForeignKey = atoi(strVal.GetBuffer(0));
|
||||
if (1 == stCol.nIsForeignKey)
|
||||
{
|
||||
stCol.strRefTableName = m_opXml.GetChildAttrib(_T("refer_table_name"));
|
||||
stCol.strRefTableCol = m_opXml.GetChildAttrib(_T("refer_table_col"));
|
||||
}
|
||||
}
|
||||
else
|
||||
stCol.nIsForeignKey = 255;
|
||||
|
||||
strVal = m_opXml.GetChildAttrib(_T("empty_modify"));
|
||||
if (!strVal.IsEmpty())
|
||||
stCol.nIsEmpty = atoi(strVal.GetBuffer(0));
|
||||
else
|
||||
stCol.nIsEmpty = 255;
|
||||
|
||||
}
|
||||
|
||||
return stCol;
|
||||
}
|
||||
|
||||
bool CUpdateDataBase::GetDBUpdatesInfo()
|
||||
{
|
||||
//此时的必须是解析到pre_version的元素上
|
||||
m_opXml.IntoElem();
|
||||
bool bFind = false;
|
||||
CString strTmp = _T("");
|
||||
while(m_opXml.FindElem(_T("table")))
|
||||
{
|
||||
bFind = true;
|
||||
STTableInfo stTbale;
|
||||
stTbale.strTableName = m_opXml.GetAttrib(_T("name"));
|
||||
stTbale.nModifyType = atoi(m_opXml.GetAttrib(_T("modify_type")).GetBuffer(0));
|
||||
//获取table 的name 和 modify_type
|
||||
if (stTbale.strTableName.IsEmpty() || stTbale.nModifyType < 1 || stTbale.nModifyType > 3)
|
||||
{
|
||||
strTmp.Empty();
|
||||
strTmp.Format(_T("[%d] Get Table name or modifytype error, table_name = %s, modify_type = %d"), __LINE__,
|
||||
stTbale.strTableName.GetBuffer(0), stTbale.nModifyType);
|
||||
PrintLog(strTmp);
|
||||
m_vtUpdateDBInfo.clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
//如果是删除数据库表,则只需获得数据库表名即可。
|
||||
if (2 == stTbale.nModifyType)
|
||||
{
|
||||
m_vtUpdateDBInfo.push_back(stTbale);
|
||||
continue;
|
||||
}
|
||||
|
||||
//查询子元素column
|
||||
bool bPrimaryKey = false;
|
||||
while(m_opXml.FindChildElem(_T("column")))
|
||||
{
|
||||
STColInfo stColumn = GetColumnInfo(stTbale.nModifyType);
|
||||
if (stColumn.strColName.IsEmpty())
|
||||
{
|
||||
strTmp.Empty();
|
||||
strTmp.Format(_T("[%d] column name is empty in modify_type:%d"), __LINE__, stTbale.nModifyType);
|
||||
PrintLog(strTmp);
|
||||
m_vtUpdateDBInfo.clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (1 == stColumn.nIsPrimaryKey)
|
||||
{
|
||||
bPrimaryKey = true;
|
||||
}
|
||||
stTbale.vtColInfo.push_back(stColumn);
|
||||
}
|
||||
//如果是增加数据表,但是又没有配置主键,则报错
|
||||
if ((1 == stTbale.nModifyType) && !bPrimaryKey)
|
||||
{
|
||||
strTmp.Empty();
|
||||
strTmp.Format(_T("[%d] can not found primary key in add table"), __LINE__);
|
||||
m_vtUpdateDBInfo.clear();
|
||||
return false;
|
||||
}
|
||||
m_vtUpdateDBInfo.push_back(stTbale);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
bool CUpdateDataBase::ParserUpdateDBXml()
|
||||
{
|
||||
//如果没有这个文件,则说明不需要更新数据库
|
||||
bool bRes = m_opXml.Load(_T("updates\\database_modify.xml"));
|
||||
CString strTmp = _T("");
|
||||
if (!bRes)
|
||||
{
|
||||
strTmp.Format(_T("[%d] load database_modify.xml failed, error_msg = %s"), __LINE__, m_opXml.GetError().GetBuffer(0));
|
||||
PrintLog(strTmp);
|
||||
return true;
|
||||
}
|
||||
|
||||
m_opXml.ResetPos();
|
||||
if (!m_opXml.FindElem(_T("current_version")))
|
||||
{
|
||||
strTmp.Format(_T("[%d] find element current_version failed, error_msg = %s"), __LINE__, m_opXml.GetError().GetBuffer(0));
|
||||
PrintLog(strTmp);
|
||||
return false;
|
||||
}
|
||||
|
||||
CString strVer = m_opXml.GetAttrib(_T("value"));
|
||||
if (strVer.IsEmpty())
|
||||
{
|
||||
strTmp.Format(_T("[%d] current version info is empty"), __LINE__);
|
||||
PrintLog(strTmp);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (0 != m_strCurVer.Compare(strVer.GetBuffer(0)))
|
||||
{
|
||||
strTmp.Format(_T("[%d] current version is not equal to xml's version info, curVer = %s, xmlCurVer = %s"),
|
||||
__LINE__, m_strCurVer.GetBuffer(0), strVer.GetBuffer(0));
|
||||
PrintLog(strTmp);
|
||||
return true;
|
||||
}
|
||||
|
||||
strTmp.Empty();
|
||||
m_opXml.IntoElem();
|
||||
|
||||
//查询之前的版本信息的更改记录
|
||||
if (!QueryPreVersion())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// if (!m_opXml.FindElem(_T("pre_version")))
|
||||
// {
|
||||
// strTmp.Format(_T("[%d] find element pre_version failed, error_msg = %s"), __LINE__, m_opXml.GetError().GetBuffer(0));
|
||||
// PrintLog(strTmp);
|
||||
// return false;
|
||||
// }
|
||||
// CString strPreVer = m_opXml.GetAttrib(_T("value"));
|
||||
CString strPreVer = _T("NULL");
|
||||
|
||||
while(0 != m_strPreVersion.Compare(strPreVer.GetBuffer(0)))
|
||||
{
|
||||
if (!m_opXml.FindElem(_T("pre_version")))
|
||||
{
|
||||
strTmp.Empty();
|
||||
strTmp.Format(_T("[%d] can not found version = %s modify information"), __LINE__, m_strPreVersion.GetBuffer(0));
|
||||
PrintLog(strTmp);
|
||||
return true;
|
||||
}
|
||||
strPreVer = m_opXml.GetAttrib(_T("value"));
|
||||
}
|
||||
|
||||
if (!GetDBUpdatesInfo())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
void CUpdateDataBase::PrintLog(CString& strLog)
|
||||
{
|
||||
if (NULL == m_pLog)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("无法写入device_log,日志文件点为空"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Can't write device_log, log File point is NULL"), _T("LOG_ERROR"), MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
CString strOutPut = _T("");
|
||||
strOutPut.Format(_T("%04d-%02d-%02d %02d:%02d:%02d.%03d %s \r\n"),g_sysCurTime.wYear, g_sysCurTime.wMonth, g_sysCurTime.wDay,
|
||||
g_sysCurTime.wHour, g_sysCurTime.wMinute, g_sysCurTime.wSecond, g_sysCurTime.wMilliseconds, strLog.GetBuffer(0));
|
||||
fwrite(strOutPut.GetBuffer(0), 1, strOutPut.GetLength(), m_pLog);
|
||||
fflush(m_pLog);
|
||||
}
|
||||
|
||||
bool CUpdateDataBase::AddDBTable( STTableInfo stTable)
|
||||
{
|
||||
CString strSql = _T("");
|
||||
CString strTmp = _T("");
|
||||
strSql.Format(_T("create table %s ("), stTable.strTableName.GetBuffer(0));
|
||||
std::vector<int> vtIndexCol;
|
||||
std::vector<int> vtForeignCol;
|
||||
vtIndexCol.clear();
|
||||
vtForeignCol.clear();
|
||||
//生成创建表的SQL语句
|
||||
int i = 0;
|
||||
for (i = 0; i < stTable.vtColInfo.size(); i++)
|
||||
{
|
||||
STColInfo stCol = stTable.vtColInfo[i];
|
||||
strTmp.Empty();
|
||||
//添加列名和属性
|
||||
if (1 == stCol.nValueType || 2 == stCol.nValueType)
|
||||
{
|
||||
strTmp.Format(_T("%s %s(%d)"), stCol.strColName.GetBuffer(0),
|
||||
chValueType[stCol.nValueType-1], stCol.nAttrType);
|
||||
if (1 == stCol.nIsCompress)
|
||||
{
|
||||
strTmp += " with compression";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (1 == stCol.nIsCompress)
|
||||
{
|
||||
CString strLog = _T("");
|
||||
strLog.Format(_T("[%d] can not set compress in value_type = %d"), __LINE__, stCol.nValueType);
|
||||
PrintLog(strLog);
|
||||
}
|
||||
strTmp.Format(_T("%s %s"), stCol.strColName.GetBuffer(0), chValueType[stCol.nValueType-1]);
|
||||
}
|
||||
strSql += strTmp;
|
||||
|
||||
//添加其他属性
|
||||
if (1 == stCol.nIsPrimaryKey)
|
||||
{
|
||||
strSql += _T(" primary key");
|
||||
}
|
||||
|
||||
if (1 == stCol.nIsForeignKey)
|
||||
{
|
||||
// strSql += _T(" foreign key");
|
||||
vtForeignCol.push_back(i);
|
||||
}
|
||||
|
||||
if (0 == stCol.nIsEmpty)
|
||||
{
|
||||
strSql += _T(" not null");
|
||||
}
|
||||
else if(1 == stCol.nIsEmpty)
|
||||
{
|
||||
strSql += _T(" null");
|
||||
}
|
||||
|
||||
if (1 == stCol.nIndex || 2 == stCol.nIndex)
|
||||
{
|
||||
vtIndexCol.push_back(i);
|
||||
}
|
||||
|
||||
if (i != (stTable.vtColInfo.size()-1))
|
||||
strSql += _T(",\r");
|
||||
else
|
||||
strSql += _T(");");
|
||||
}
|
||||
|
||||
//创建索引
|
||||
std::vector<CString> vtExtSql;
|
||||
vtExtSql.clear();
|
||||
for (i = 0; i < vtIndexCol.size(); i++ )
|
||||
{
|
||||
CString strIndexSql = _T("");
|
||||
STColInfo stIndexCol = stTable.vtColInfo[vtIndexCol[i]];
|
||||
if (1 == stIndexCol.nIndex)
|
||||
strIndexSql.Format(_T("create index i%s on %s (%s);"), stIndexCol.strColName.GetBuffer(0),
|
||||
stTable.strTableName.GetBuffer(0), stIndexCol.strColName.GetBuffer(0));
|
||||
else
|
||||
strIndexSql.Format(_T("create unique index i%s on %s (%s);"), stIndexCol.strColName.GetBuffer(0),
|
||||
stTable.strTableName.GetBuffer(0), stIndexCol.strColName.GetBuffer(0));
|
||||
vtExtSql.push_back(strIndexSql);
|
||||
}
|
||||
|
||||
//创建外键约束
|
||||
for (i = 0; i < vtForeignCol.size(); i++ )
|
||||
{
|
||||
CString strAddConsSql = _T("");
|
||||
strAddConsSql.Format(_T("alter table %s add constraint FK_%s foreign key (%s) references %s (%s) on update cascade on delete cascade;"),
|
||||
stTable.strTableName.GetBuffer(0), stTable.vtColInfo[vtForeignCol[i]].strColName.GetBuffer(0),
|
||||
stTable.vtColInfo[vtForeignCol[i]].strColName.GetBuffer(0),
|
||||
stTable.vtColInfo[vtForeignCol[i]].strRefTableName.GetBuffer(0),
|
||||
stTable.vtColInfo[vtForeignCol[i]].strRefTableCol.GetBuffer(0));
|
||||
|
||||
vtExtSql.push_back(strAddConsSql);
|
||||
}
|
||||
|
||||
_CommandPtr pCmdUpd = NULL;
|
||||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||||
pCmdUpd->ActiveConnection = m_pConnection;
|
||||
|
||||
//执行数据库操作
|
||||
try
|
||||
{
|
||||
m_pConnection->BeginTrans();
|
||||
pCmdUpd->CommandText = strSql.AllocSysString();
|
||||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||||
for (i = 0; i < vtExtSql.size(); i++)
|
||||
{
|
||||
pCmdUpd->CommandText = vtExtSql[i].AllocSysString();
|
||||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||||
}
|
||||
m_pConnection->CommitTrans();
|
||||
return true;
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
m_pConnection->RollbackTrans();
|
||||
AfxMessageBox((LPCTSTR)e.Description());
|
||||
CString strLogInfo = _T("");
|
||||
strLogInfo.Format(_T("[%d] create table %s failed, error_msg = %s"), __LINE__,
|
||||
stTable.strTableName.GetBuffer(0), (LPCTSTR)e.Description());
|
||||
PrintLog(strLogInfo);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CUpdateDataBase::DeleteDBTable(STTableInfo stTable)
|
||||
{
|
||||
_CommandPtr pCmdUpd = NULL;
|
||||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||||
pCmdUpd->ActiveConnection = m_pConnection;
|
||||
|
||||
try
|
||||
{
|
||||
m_pConnection->BeginTrans();
|
||||
CString strSql = _T("");
|
||||
strSql.Format(_T("drop table %s;"), stTable.strTableName.GetBuffer(0));
|
||||
pCmdUpd->CommandText = strSql.AllocSysString();
|
||||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||||
m_pConnection->CommitTrans();
|
||||
return true;
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
m_pConnection->RollbackTrans();
|
||||
AfxMessageBox((LPCTSTR)e.Description());
|
||||
CString strLogInfo = _T("");
|
||||
strLogInfo.Format(_T("[%d] drop table %s failed, error_msg = %s"), __LINE__,
|
||||
stTable.strTableName.GetBuffer(0), (LPCTSTR)e.Description());
|
||||
PrintLog(strLogInfo);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool CUpdateDataBase::AddTableCol(CString strTable, STColInfo stCol, std::vector<CString>& vtSql)
|
||||
{
|
||||
CString strSql = _T("");
|
||||
CString strTmp =_T("");
|
||||
strSql.Format(_T("alter table %s add "), strTable.GetBuffer(0));
|
||||
|
||||
//添加列名和属性
|
||||
if (1 == stCol.nValueType || 2 == stCol.nValueType)
|
||||
{
|
||||
strTmp.Format(_T("%s %s(%d)"), stCol.strColName.GetBuffer(0),
|
||||
chValueType[stCol.nValueType-1], stCol.nAttrType);
|
||||
if (1 == stCol.nIsCompress)
|
||||
{
|
||||
strTmp += " with compression";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (1 == stCol.nIsCompress)
|
||||
{
|
||||
CString strLog = _T("");
|
||||
strLog.Format(_T("[%d] can not set compress in value_type = %d"), __LINE__, stCol.nValueType);
|
||||
PrintLog(strLog);
|
||||
}
|
||||
strTmp.Format(_T("%s %s"), stCol.strColName.GetBuffer(0), chValueType[stCol.nValueType-1]);
|
||||
}
|
||||
strSql += strTmp;
|
||||
|
||||
//添加其他属性
|
||||
if (1 == stCol.nIsPrimaryKey)
|
||||
{
|
||||
strSql += _T(" primary key");
|
||||
}
|
||||
|
||||
if (0 == stCol.nIsEmpty)
|
||||
{
|
||||
strSql += _T(" not null;");
|
||||
}
|
||||
|
||||
vtSql.push_back(strSql);
|
||||
|
||||
strSql.Empty();
|
||||
if (1 == stCol.nIndex)
|
||||
{
|
||||
strSql.Format(_T("create index i%s on %s (%s);"), stCol.strColName.GetBuffer(0),
|
||||
strTable.GetBuffer(0), stCol.strColName.GetBuffer(0));
|
||||
vtSql.push_back(strSql);
|
||||
}
|
||||
else if (2 == stCol.nIndex)
|
||||
{
|
||||
strSql.Format(_T("create unique index i%s on %s (%s);"), stCol.strColName.GetBuffer(0),
|
||||
strTable.GetBuffer(0), stCol.strColName.GetBuffer(0));
|
||||
vtSql.push_back(strSql);
|
||||
}
|
||||
|
||||
if (1 == stCol.nIsForeignKey)
|
||||
{
|
||||
strSql.Empty();
|
||||
strSql.Format(_T("alter table %s add constraint FK_%s foreign key(%s) references %s(%s) on update cascade on delete cascade;"),
|
||||
strTable.GetBuffer(0), stCol.strColName.GetBuffer(0), stCol.strColName.GetBuffer(0),
|
||||
stCol.strRefTableName.GetBuffer(0), stCol.strRefTableCol.GetBuffer(0));
|
||||
vtSql.push_back(strSql);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool CUpdateDataBase::ModifyTableCol(CString strTable, STColInfo stCol, std::vector<CString>& vtSql)
|
||||
{
|
||||
CString strSql = _T("");
|
||||
strSql.Format(_T("alter table %s alter column %s"), strTable.GetBuffer(0), stCol.strColName.GetBuffer(0));
|
||||
CString strTmp = _T("");
|
||||
if (stCol.nValueType > 0 && stCol.nValueType < 13)
|
||||
{
|
||||
if (stCol.nValueType < 3)
|
||||
{
|
||||
if (stCol.nAttrType < 1)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
strTmp.Format(_T("列属性的长度为列中的错误,长度= %d"), stCol.nAttrType);
|
||||
AfxMessageBox(strTmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
strTmp.Format(_T("The length of column's attribute is error in column, length = %d"), stCol.nAttrType);
|
||||
MessageBoxEx(NULL, strTmp, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
strTmp.Format(_T(" %s(%d)"), chValueType[stCol.nValueType-1], stCol.nAttrType);
|
||||
}
|
||||
else
|
||||
strTmp.Format(_T(" %s"), chValueType[stCol.nValueType-1]);
|
||||
|
||||
//暂时只支持添加可以为空的属性
|
||||
if (1 == stCol.nIsEmpty)
|
||||
strTmp += _T(" null;");
|
||||
else
|
||||
strTmp +=_T(";");
|
||||
|
||||
strSql += strTmp;
|
||||
vtSql.push_back(strSql);
|
||||
}
|
||||
|
||||
strSql.Empty();
|
||||
//删除索引
|
||||
if (0 == stCol.nIndex)
|
||||
{
|
||||
strSql.Format(_T("drop index i%s on %s;"), stCol.strColName.GetBuffer(0), strTable.GetBuffer(0));
|
||||
vtSql.push_back(strSql);
|
||||
}
|
||||
else
|
||||
{
|
||||
//为保证增加索引成功,先删除索引
|
||||
// strSql.Format(_T("drop index i%s on %s;"), stCol.strColName.GetBuffer(0), strTable.GetBuffer(0));
|
||||
// vtSql.push_back(strSql);
|
||||
|
||||
//增加索引
|
||||
if (1 == stCol.nIndex)
|
||||
{
|
||||
strSql.Format(_T("create index i%s on %s (%s);"), stCol.strColName.GetBuffer(0),
|
||||
strTable.GetBuffer(0), stCol.strColName.GetBuffer(0));
|
||||
vtSql.push_back(strSql);
|
||||
}
|
||||
else if (2 == stCol.nIndex)
|
||||
{
|
||||
strSql.Format(_T("create unique index i%s on %s (%s);"), stCol.strColName.GetBuffer(0),
|
||||
strTable.GetBuffer(0), stCol.strColName.GetBuffer(0));
|
||||
vtSql.push_back(strSql);
|
||||
}
|
||||
}
|
||||
|
||||
//增加外键约束
|
||||
if (1 == stCol.nIsForeignKey)
|
||||
{
|
||||
strSql.Empty();
|
||||
strSql.Format(_T("alter table %s add constraint FK_%s foregin key(%s) references %s(%s) on update cascade on delete cascade;"),
|
||||
strTable.GetBuffer(0), stCol.strColName.GetBuffer(0), stCol.strColName.GetBuffer(0),
|
||||
stCol.strRefTableName.GetBuffer(0), stCol.strRefTableCol.GetBuffer(0));
|
||||
vtSql.push_back(strSql);
|
||||
}
|
||||
//删除外键约束
|
||||
else if (0 == stCol.nIsForeignKey)
|
||||
{
|
||||
strSql.Empty();
|
||||
strSql.Format(_T("alter table %s drop constraint FK_%s;"), strTable.GetBuffer(0), stCol.strColName.GetBuffer(0));
|
||||
vtSql.push_back(strSql);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CUpdateDataBase::ModifyDBTable(STTableInfo stTable)
|
||||
{
|
||||
|
||||
_CommandPtr pCmdUpd = NULL;
|
||||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||||
pCmdUpd->ActiveConnection = m_pConnection;
|
||||
|
||||
try
|
||||
{
|
||||
m_pConnection->BeginTrans();
|
||||
|
||||
for (int i = 0; i < stTable.vtColInfo.size(); i++)
|
||||
{
|
||||
if (1 == stTable.vtColInfo[i].nModifyType)
|
||||
{
|
||||
std::vector<CString> vtAddColSql;
|
||||
vtAddColSql.clear();
|
||||
if (AddTableCol(stTable.strTableName, stTable.vtColInfo[i], vtAddColSql))
|
||||
{
|
||||
for (int j = 0; j < vtAddColSql.size(); j++)
|
||||
{
|
||||
pCmdUpd->CommandText = vtAddColSql[j].AllocSysString();
|
||||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (2 == stTable.vtColInfo[i].nModifyType)
|
||||
{
|
||||
CString strDelSql = _T("");
|
||||
strDelSql.Format(_T("alter table %s drop %s;"),stTable.strTableName.GetBuffer(0),
|
||||
stTable.vtColInfo[i].strColName.GetBuffer(0));
|
||||
pCmdUpd->CommandText = strDelSql.AllocSysString();
|
||||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||||
|
||||
}
|
||||
else if (3 == stTable.vtColInfo[i].nModifyType)
|
||||
{
|
||||
std::vector<CString> vtModifySql;
|
||||
vtModifySql.clear();
|
||||
if (ModifyTableCol(stTable.strTableName, stTable.vtColInfo[i], vtModifySql))
|
||||
{
|
||||
for (int j = 0; j < vtModifySql.size(); j++)
|
||||
{
|
||||
pCmdUpd->CommandText = vtModifySql[j].AllocSysString();
|
||||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m_pConnection->CommitTrans();
|
||||
return true;
|
||||
}
|
||||
|
||||
catch (_com_error e)
|
||||
{
|
||||
m_pConnection->RollbackTrans();
|
||||
AfxMessageBox((LPCTSTR)e.Description());
|
||||
CString strLogInfo = _T("");
|
||||
strLogInfo.Format(_T("[%d] ModifyDBTable table %s failed, error_msg = %s"), __LINE__,
|
||||
stTable.strTableName.GetBuffer(0), (LPCTSTR)e.Description());
|
||||
PrintLog(strLogInfo);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int CUpdateDataBase::UpdateDBInfo()
|
||||
{
|
||||
CString strTmp = _T("");
|
||||
if (!ParserUpdateDBXml())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("获取数据库更新信息错误"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Get Database update information error"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return enResFail;
|
||||
}
|
||||
|
||||
if (0 == m_vtUpdateDBInfo.size())
|
||||
{
|
||||
strTmp.Format(_T("[%d] there is no change database record"));
|
||||
PrintLog(strTmp);
|
||||
return enResNoUpdate;
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_vtUpdateDBInfo.size(); i++)
|
||||
{
|
||||
if (1 == m_vtUpdateDBInfo[i].nModifyType)
|
||||
{
|
||||
if (!AddDBTable(m_vtUpdateDBInfo[i]))
|
||||
{
|
||||
return enResFail;
|
||||
}
|
||||
}
|
||||
else if (2 == m_vtUpdateDBInfo[i].nModifyType)
|
||||
{
|
||||
if (!DeleteDBTable(m_vtUpdateDBInfo[i]))
|
||||
{
|
||||
return enResFail;
|
||||
}
|
||||
}
|
||||
else if (3 == m_vtUpdateDBInfo[i].nModifyType)
|
||||
{
|
||||
if (!ModifyDBTable(m_vtUpdateDBInfo[i]))
|
||||
{
|
||||
return enResFail;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (true == WriteVersionToDB()) ? enResSuccess : enResFail;
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
// DelElectrode.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "geomative.h"
|
||||
#include "DelElectrode.h"
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDelElectrode dialog
|
||||
extern void SplitterString(CStringArray &szArray,const CString& szSource, const CString& szSplitter);
|
||||
extern int g_iUILanguage;
|
||||
|
||||
CDelElectrode::CDelElectrode(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CDelElectrode::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CDelElectrode)
|
||||
m_strDelElectID = _T("");
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void CDelElectrode::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CDelElectrode)
|
||||
DDX_Text(pDX, IDC_EDIT_ELECTRODE_ID, m_strDelElectID);
|
||||
DDV_MaxChars(pDX, m_strDelElectID, 200);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CDelElectrode, CDialog)
|
||||
//{{AFX_MSG_MAP(CDelElectrode)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDelElectrode message handlers
|
||||
|
||||
BOOL CDelElectrode::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
// TODO: Add extra initialization here
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void CDelElectrode::OnOK()
|
||||
{
|
||||
// TODO: Add extra validation here
|
||||
if (!UpdateData(TRUE))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!CheckIDValidity())
|
||||
{
|
||||
return;
|
||||
}
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
bool CDelElectrode::CheckIDValidity()
|
||||
{
|
||||
if (m_strDelElectID.IsEmpty())
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("电极序号不能为空."));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Electrode index can not be empty!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return false;
|
||||
}
|
||||
m_strDelElectID.TrimLeft();//删除左边的空格
|
||||
m_strDelElectID.TrimRight();//删除右边的空格
|
||||
int iLen = m_strDelElectID.GetLength();
|
||||
TCHAR ch;
|
||||
for (int i = 0; i < iLen; i++)
|
||||
{
|
||||
ch = m_strDelElectID.GetAt(i);
|
||||
if ((ch != _T(',')) && (ch != _T('.')) && (ch < _T('0') || ch > _T('9')))
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("输入参数错误,请输入数字,数字之间用逗号分隔."));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Input parameter error! \r\nPlease enter into number (separated by comma)."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDelElectrode::GetElectrodeIDInfo(STDelElectInfo &stDelInfo)
|
||||
{
|
||||
stDelInfo.vtElectID.clear();
|
||||
CStringArray strArray;
|
||||
strArray.RemoveAll();
|
||||
SplitterString(strArray, m_strDelElectID, _T(","));
|
||||
CString strVal = _T("");
|
||||
float fID = 0;
|
||||
for (int i = 0; i < strArray.GetSize(); i++)
|
||||
{
|
||||
strVal = strArray.GetAt(i);
|
||||
fID = atof(strVal);
|
||||
stDelInfo.vtElectID.push_back(fID);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user