2054 lines
63 KiB
C++
2054 lines
63 KiB
C++
// ProManager.cpp: implementation of the CProManager class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "geomative.h"
|
|
#include "ProManager.h"
|
|
#include "Constant.h"
|
|
#include "DataMngStruct.h"
|
|
#include "opcreateprojectdlg.h"
|
|
#include "opcreatetzdlg.h"
|
|
#include "opcreatedmsdlg.h"
|
|
#include "DetcGD10Dev.h"
|
|
#include "GD10OperCmd.h"
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
extern CString g_szMacAddress;
|
|
extern int g_iTransMode;
|
|
extern void TransDelay(int iTransMode, int iDS0, int iDS1, HWND hWnd = NULL);
|
|
extern int g_iTransFileMode;
|
|
extern BOOL DoEvent(HWND hWnd);
|
|
extern BOOL GetSubStringInHeadAndTail(const CString& szSource, CString& szSub, const CString& szHead, const CString& szTail);
|
|
extern int g_iUILanguage;
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Construction/Destruction
|
|
//////////////////////////////////////////////////////////////////////
|
|
extern HHOOK hHook;
|
|
extern LRESULT __stdcall CBTHookProc(long nCode, WPARAM wParam, LPARAM lParam);
|
|
CProManager::CProManager(_ConnectionPtr& pConnection)
|
|
{
|
|
ASSERT(NULL != pConnection);
|
|
m_pConnection = pConnection;
|
|
m_dmsLinkList.DeleteAll();
|
|
}
|
|
|
|
CProManager::~CProManager()
|
|
{
|
|
int iDMSIndex = 0;
|
|
|
|
iDMSIndex++;
|
|
|
|
while (NULL != m_dmsLinkList.Find(iDMSIndex))
|
|
{
|
|
delete m_dmsLinkList.Find(iDMSIndex);
|
|
iDMSIndex++;
|
|
}
|
|
m_dmsLinkList.DeleteAll();
|
|
}
|
|
|
|
bool CProManager::ShowTzList(DWORD dwProHandle, CListCtrl& tzList)
|
|
{
|
|
_RecordsetPtr pRecTzList = NULL;
|
|
CString szSql;
|
|
|
|
DWORD dwHandle = (DWORD)VAL_ZERO;
|
|
DWORD dwProID = (DWORD)VAL_ZERO;
|
|
|
|
int iIndex = (int)VAL_ZERO;
|
|
|
|
dwProID = m_handleProcessor.GetIDFromHandle(dwProHandle);
|
|
|
|
pRecTzList.CreateInstance(_uuidof(Recordset));
|
|
if ((int)VAL_ZERO != tzList.GetItemCount())
|
|
{
|
|
tzList.DeleteAllItems();
|
|
}
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ID,TZname,TZtype,Format(Cdate,'YYYY-MM-DD') as Cdate,TZdesc,location from tz where PRID = %u"), dwProID);//xxxx
|
|
pRecTzList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecTzList->adoEOF)
|
|
{
|
|
//点击工程,在右边显示下面这些
|
|
tzList.InsertItem(iIndex, pRecTzList->GetCollect(_T("TZname")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecTzList->GetCollect(_T("TZname")));
|
|
tzList.SetItemText(iIndex, 1, pRecTzList->GetCollect(_T("TZtype")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecTzList->GetCollect(_T("TZtype")));
|
|
tzList.SetItemText(iIndex, 2, pRecTzList->GetCollect(_T("Cdate")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecTzList->GetCollect(_T("Cdate")));
|
|
tzList.SetItemText(iIndex, 3, pRecTzList->GetCollect(_T("TZdesc")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecTzList->GetCollect(_T("TZdesc")));
|
|
tzList.SetItemText(iIndex, 4, pRecTzList->GetCollect(_T("location")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecTzList->GetCollect(_T("location")));
|
|
|
|
dwHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTzList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TZ);
|
|
tzList.SetItemData(iIndex, dwHandle);
|
|
|
|
iIndex++;
|
|
pRecTzList->MoveNext();
|
|
}
|
|
|
|
pRecTzList->Close();
|
|
return true;
|
|
}
|
|
|
|
//DEL bool CProManager::ShowTzList(DWORD dwProHandle, DWORD dwDevHandle, CListCtrl& tzList)
|
|
//DEL {
|
|
//DEL _RecordsetPtr pRecTzList = NULL;
|
|
//DEL _RecordsetPtr pRecTzID = NULL;
|
|
//DEL
|
|
//DEL DWORD dwHandle = (DWORD)VAL_ZERO;
|
|
//DEL
|
|
//DEL DWORD dwProID = (DWORD)VAL_ZERO;
|
|
//DEL DWORD dwDevID = (DWORD)VAL_ZERO;
|
|
//DEL
|
|
//DEL dwProID = m_handleProcessor.GetIDFromHandle(dwProHandle);
|
|
//DEL dwDevID = m_handleProcessor.GetIDFromHandle(dwDevHandle);
|
|
//DEL
|
|
//DEL int iIndex = (int)VAL_ZERO;
|
|
//DEL CString szSql;
|
|
//DEL
|
|
//DEL pRecTzList.CreateInstance(_uuidof(Recordset));
|
|
//DEL pRecTzID.CreateInstance(_uuidof(Recordset));
|
|
//DEL
|
|
//DEL if ((int)VAL_ZERO != tzList.GetItemCount())
|
|
//DEL {
|
|
//DEL tzList.DeleteAllItems();
|
|
//DEL }
|
|
//DEL
|
|
//DEL szSql.Empty();
|
|
//DEL szSql.Format(_T("select TZID from dptt where DEID = %u and PRID = %u"), dwDevID, dwProID);
|
|
//DEL pRecTzID->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true),
|
|
//DEL adOpenStatic, adLockOptimistic, adCmdText);
|
|
//DEL
|
|
//DEL while ((short)VAL_ZERO == pRecTzID->adoEOF)
|
|
//DEL {
|
|
//DEL if (VT_NULL != pRecTzID->GetCollect(_T("TZID")).vt)
|
|
//DEL {
|
|
//DEL szSql.Empty();
|
|
//DEL szSql.Format(_T("select ID,TZname,Format(Cdate,'YYYY-MM-DD') as Cdate,TZdesc,location from tz where ID = %s"), pRecTzID->GetCollect(_T("TZID")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTzID->GetCollect(_T("TZID")));
|
|
//DEL pRecTzList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true),
|
|
//DEL adOpenStatic, adLockOptimistic, adCmdText);
|
|
//DEL
|
|
//DEL tzList.InsertItem(iIndex, pRecTzList->GetCollect(_T("TZname")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecTzList->GetCollect(_T("TZname")));
|
|
//DEL tzList.SetItemText(iIndex, 1, pRecTzList->GetCollect(_T("Cdate")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecTzList->GetCollect(_T("Cdate")));
|
|
//DEL tzList.SetItemText(iIndex, 2, pRecTzList->GetCollect(_T("TZdesc")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecTzList->GetCollect(_T("TZdesc")));
|
|
//DEL tzList.SetItemText(iIndex, 3, pRecTzList->GetCollect(_T("location")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecTzList->GetCollect(_T("location")));
|
|
//DEL
|
|
//DEL dwHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTzList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TZ);
|
|
//DEL tzList.SetItemData(iIndex, dwHandle);
|
|
//DEL
|
|
//DEL iIndex++;
|
|
//DEL
|
|
//DEL pRecTzList->Close();
|
|
//DEL } //if (VT_NULL != pRecTzID->GetCollect(_T("TZID")).vt)
|
|
//DEL
|
|
//DEL pRecTzID->MoveNext();
|
|
//DEL } //while (VAL_ZERO == pRecTzID->adoEOF)
|
|
//DEL pRecTzID->Close();
|
|
//DEL
|
|
//DEL return true;
|
|
//DEL }
|
|
|
|
|
|
|
|
CDataMngStruct* CProManager::GetDMS(DWORD dwHandle)
|
|
{
|
|
CDataMngStruct* pDMS = NULL;
|
|
UINT uStyle = (UINT)VAL_ZERO;
|
|
DWORD dwID = (DWORD)VAL_ZERO;
|
|
uStyle = m_handleProcessor.GetStyleFromHandle(dwHandle);
|
|
pDMS = m_dmsLinkList.Get(dwHandle);
|
|
|
|
if (NULL == pDMS)
|
|
{
|
|
dwID = m_handleProcessor.GetIDFromHandle(dwHandle);
|
|
|
|
switch (uStyle)
|
|
{
|
|
case PZ_STYLE_PRO:
|
|
pDMS = new CProject(dwID, m_pConnection);
|
|
break;
|
|
case PZ_STYLE_TZ:
|
|
pDMS = new CTestingZone(dwID, m_pConnection);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
m_dmsLinkList.Add(dwHandle, pDMS);
|
|
}
|
|
|
|
return pDMS;
|
|
}
|
|
|
|
bool CProManager::ShowProList(DWORD dwDevHandle, CListCtrl& proList)
|
|
{
|
|
_RecordsetPtr pRecProList = NULL;
|
|
_RecordsetPtr pRecProID = NULL;
|
|
DWORD dwHandle = (DWORD)VAL_ZERO;
|
|
DWORD dwDevID = (DWORD)VAL_ZERO;
|
|
|
|
dwDevID = m_handleProcessor.GetIDFromHandle(dwDevHandle);
|
|
|
|
int iIndex = (int)VAL_ZERO;
|
|
CString szSql = _T("");
|
|
|
|
pRecProList.CreateInstance(_uuidof(Recordset));
|
|
pRecProID.CreateInstance(_uuidof(Recordset));
|
|
|
|
if ((int)VAL_ZERO != proList.GetItemCount())
|
|
{
|
|
proList.DeleteAllItems();
|
|
}
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select distinct PRID from dptt where DEID = %u"), dwDevID);
|
|
pRecProID->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true),
|
|
adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecProID->adoEOF)
|
|
{
|
|
if (VT_NULL != pRecProID->GetCollect(_T("PRID")).vt)
|
|
{
|
|
szSql.Empty();
|
|
|
|
szSql.Format(_T("select CN,ID,PRname,PRdesc,location,Format(PRdate,'YYYY-MM-DD') as PRdate,duration,PS,CS,PM,QAS,standard from project where ID = %s"),
|
|
pRecProID->GetCollect(_T("PRID")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecProID->GetCollect(_T("PRID")));
|
|
pRecProList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true),
|
|
adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((short)VAL_ZERO != pRecProList->GetRecordCount())
|
|
{
|
|
proList.InsertItem(iIndex, pRecProList->GetCollect(_T("CN")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecProList->GetCollect(_T("CN")));
|
|
proList.SetItemText(iIndex, 1, pRecProList->GetCollect(_T("PRname")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecProList->GetCollect(_T("PRname")));
|
|
proList.SetItemText(iIndex, 2, pRecProList->GetCollect(_T("PRdesc")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecProList->GetCollect(_T("PRdesc")));
|
|
proList.SetItemText(iIndex, 3, pRecProList->GetCollect(_T("location")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecProList->GetCollect(_T("location")));
|
|
proList.SetItemText(iIndex, 4, pRecProList->GetCollect(_T("PRdate")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecProList->GetCollect(_T("PRdate")));
|
|
proList.SetItemText(iIndex, 5, pRecProList->GetCollect(_T("duration")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecProList->GetCollect(_T("duration")));
|
|
proList.SetItemText(iIndex, 6, pRecProList->GetCollect(_T("PS")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecProList->GetCollect(_T("PS")));
|
|
proList.SetItemText(iIndex, 7, pRecProList->GetCollect(_T("CS")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecProList->GetCollect(_T("CS")));
|
|
proList.SetItemText(iIndex, 8, pRecProList->GetCollect(_T("PM")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecProList->GetCollect(_T("PM")));
|
|
proList.SetItemText(iIndex, 9, pRecProList->GetCollect(_T("QAS")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecProList->GetCollect(_T("QAS")));
|
|
proList.SetItemText(iIndex, 10, pRecProList->GetCollect(_T("standard")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecProList->GetCollect(_T("standard")));
|
|
|
|
dwHandle = m_handleProcessor.GenerateHandle((DWORD)pRecProList->GetCollect(_T("ID")).ulVal, PZ_STYLE_PRO);
|
|
proList.SetItemData(iIndex, dwHandle);
|
|
|
|
iIndex++;
|
|
}
|
|
pRecProList->Close();
|
|
} //if (VT_NULL != pRecProID->GetCollect(_T("TZID")).vt)
|
|
|
|
pRecProID->MoveNext();
|
|
} //while (VAL_ZERO == pRecProID->adoEOF)
|
|
pRecProID->Close();
|
|
|
|
return true;
|
|
}
|
|
|
|
UINT CProManager::CreateProjectInDB(DWORD& dwID)
|
|
{
|
|
_RecordsetPtr pRecProID = NULL;
|
|
_CommandPtr pCmdInsPro = NULL;
|
|
UINT uExecCode;
|
|
|
|
CString szSql;
|
|
CString szCaption;
|
|
COpCreateProjectDlg opCreateProDlg;
|
|
|
|
INT_PTR lRet = -1;
|
|
|
|
lRet = opCreateProDlg.DoModal();
|
|
|
|
switch (lRet)
|
|
{
|
|
case IDOK:
|
|
pCmdInsPro.CreateInstance(_uuidof(Command));
|
|
pRecProID.CreateInstance(_uuidof(Recordset));
|
|
|
|
pCmdInsPro->ActiveConnection = m_pConnection;
|
|
|
|
opCreateProDlg.m_edName.TrimLeft();
|
|
opCreateProDlg.m_edName.TrimRight();
|
|
szSql.Empty();
|
|
szSql.Format(_T("select * from project where PRname = '%s'"),opCreateProDlg.m_edName);
|
|
pRecProID->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecProID->GetRecordCount())
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("工程名称已经存在!"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Project name has been already exists!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
pRecProID->Close();
|
|
return APP_FAIL;
|
|
}
|
|
pRecProID->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into project(CN,PRname,PRdesc,location,PRdate,duration,PS,CS,PM,QAS,standard) values('%s','%s','%s','%s',#%s#,%d,'%s','%s','%s','%s','%s')"),
|
|
opCreateProDlg.m_edCN, opCreateProDlg.m_edName, opCreateProDlg.m_edPrDesc, opCreateProDlg.m_edLocation, opCreateProDlg.m_edPrDate.FormatGmt("%Y-%m-%d"), opCreateProDlg.m_edDuration,
|
|
opCreateProDlg.m_edPS, opCreateProDlg.m_edCS, opCreateProDlg.m_edPM, opCreateProDlg.m_edQAS, opCreateProDlg.m_edStandard);
|
|
|
|
pCmdInsPro->CommandText = szSql.AllocSysString();
|
|
pCmdInsPro->Execute(NULL, NULL, adCmdText);
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ID from project where CN = '%s'"), opCreateProDlg.m_edCN);
|
|
pRecProID->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecProID->GetRecordCount())
|
|
{
|
|
dwID = pRecProID->GetCollect(_T("ID")).ulVal;
|
|
//加入默认测区
|
|
InsertDefaultTzToProject(dwID);
|
|
}
|
|
pRecProID->Close();
|
|
uExecCode = APP_SUCCESS;
|
|
|
|
break;
|
|
case IDCANCEL:
|
|
uExecCode = APP_CANCLE;
|
|
break;
|
|
default:
|
|
uExecCode = APP_FAIL;
|
|
break;
|
|
}
|
|
return uExecCode;
|
|
}
|
|
|
|
UINT CProManager::InsertDefaultTzToProject(DWORD dwProjectID)
|
|
{
|
|
_CommandPtr pCmdInsPro = NULL;
|
|
pCmdInsPro.CreateInstance(_uuidof(Command));
|
|
pCmdInsPro->ActiveConnection = m_pConnection;
|
|
|
|
CGUCodeCreator guCodeCreator;
|
|
CString strDefaultTzCN = guCodeCreator.GenerateGUIDCode();
|
|
CString strSql = _T("");
|
|
CString strDate = _T("1970-01-01");
|
|
//首先删除该工程下已经存在的默认测区
|
|
strSql.Format(_T("delete from tz where PRID = %d"), dwProjectID);
|
|
pCmdInsPro->CommandText = strSql.AllocSysString();
|
|
pCmdInsPro->Execute(NULL, NULL, adCmdText);
|
|
//再插入默认测区
|
|
strSql.Empty();
|
|
strSql.Format(_T("insert into tz(PRID,CN,TZname,TZtype,Cdate,TZdesc,location) values(%d,'%s','%s', %d, #%s#, '%s','%s')"),
|
|
dwProjectID, strDefaultTzCN, _T("DefaultTestZone"), 3, strDate, _T("None"), _T("None"));
|
|
pCmdInsPro->CommandText = strSql.AllocSysString();
|
|
pCmdInsPro->Execute(NULL, NULL, adCmdText);
|
|
|
|
return APP_SUCCESS;
|
|
}
|
|
|
|
UINT CProManager::CreateProjectInDev(DWORD dwID, CDevice* const pDev)
|
|
{
|
|
_RecordsetPtr pRecPro = NULL;
|
|
_RecordsetPtr pRecSynPro = NULL;
|
|
|
|
CString szSql = _T("");
|
|
|
|
CString szHostFilePath = _T("");
|
|
CString szFilePath = _T("");
|
|
CString szFileName = _T("");
|
|
CString szFile = _T("");
|
|
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
|
|
CString szPrCN = _T("");
|
|
|
|
char aResBuff[2048] = {0};
|
|
int iResSize = (int)VAL_ZERO;
|
|
|
|
UINT uExecCode = (UINT)VAL_ZERO;
|
|
|
|
pRecPro.CreateInstance(_uuidof(Recordset));
|
|
pRecSynPro.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select CN,PRname,PRdesc,location,Format(PRdate,'YYYY-MM-DD') as PRdate,duration,PS,CS,PM,QAS,standard from project where ID = %d"), dwID);
|
|
pRecPro->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true),
|
|
adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecPro->GetRecordCount())
|
|
{
|
|
szPrCN = (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("CN"));
|
|
szSql.Empty();
|
|
szSql.Format(_T("select * from dev_syn_td where TdCN is null and DESN = '%s' and PrCN = '%s'"), pDev->m_szDevSN, (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("CN")));
|
|
pRecSynPro->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true),
|
|
adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO == pRecSynPro->GetRecordCount())
|
|
{
|
|
uExecCode = AddProjectInDev(g_szMacAddress, szPrCN, pDev);
|
|
if (APP_SUCCESS == uExecCode)
|
|
{
|
|
szFilePath.Empty();
|
|
szFilePath.GetBufferSetLength(256);
|
|
::GetCurrentDirectory(szFilePath.GetLength(), szFilePath.GetBuffer(szFilePath.GetLength()));
|
|
szFilePath.ReleaseBuffer();
|
|
|
|
szFilePath = szFilePath + _T("\\CACHE\\projects\\");
|
|
szFilePath += szPrCN + "\\";
|
|
if (!PathFileExistsA(szFilePath)) {
|
|
::CreateDirectoryA(szFilePath, nullptr);
|
|
}
|
|
szFileName.Empty();
|
|
szFileName = _T("project.xml");
|
|
|
|
szFile.Empty();
|
|
szFile = szFilePath + szFileName;
|
|
|
|
CMarkup *pXML = new CMarkup;
|
|
CString szDoc = _T("<?xml version=\"1.0\" encoding=\"ansi\"?>\r\n");
|
|
|
|
pXML->SetDoc(szDoc);
|
|
pXML->AddElem(_T("project"));
|
|
pXML->AddChildElem(_T("project_name"), (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("PRname")));
|
|
pXML->AddChildElem(_T("cn"), szPrCN);
|
|
pXML->AddChildElem(_T("description"), (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("PRdesc")));
|
|
pXML->AddChildElem(_T("location"), (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("location")));
|
|
pXML->AddChildElem(_T("create_date"), (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("PRdate")));
|
|
pXML->AddChildElem(_T("create_time"), _T("00:00:00"));
|
|
pXML->AddChildElem(_T("test_date"), (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("PRdate")));
|
|
pXML->AddChildElem(_T("test_time"), _T("00:00:00"));
|
|
pXML->AddChildElem(_T("duration"), (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("duration")));
|
|
pXML->AddChildElem(_T("PS"), (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("PS")));
|
|
pXML->AddChildElem(_T("CS"), (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("CS")));
|
|
pXML->AddChildElem(_T("PM"), (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("PM")));
|
|
pXML->AddChildElem(_T("QA"), (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("QAS")));
|
|
pXML->AddChildElem(_T("standard"), (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("standard")));
|
|
pXML->AddChildElem(_T("testzone_count"), 0);
|
|
|
|
pXML->AddChildElem(_T("testzones"));
|
|
|
|
pXML->Save(szFile);
|
|
|
|
delete pXML;
|
|
|
|
szHostFilePath.Empty();
|
|
szHostFilePath.Format(_T("/SD/projects/%s/"), szPrCN);
|
|
|
|
if (TRUE == pDev->SendFile(szHostFilePath, szFilePath, szFileName))
|
|
{
|
|
uExecCode = APP_SUCCESS;
|
|
}
|
|
else
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("创建工程失败!"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Create Project failed!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
uExecCode = APP_FAIL;
|
|
DeleteProjectInDev(g_szMacAddress, szPrCN, pDev);
|
|
}
|
|
// DeleteFile(szFile);
|
|
}
|
|
else if (APP_DUPLICATE == uExecCode)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
CString strTips;
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strTips.Format(_T("工程: %s 已经存在!"), szPrCN);
|
|
AfxMessageBox(strTips);
|
|
}
|
|
else
|
|
{
|
|
strTips.Format(_T("The project %s has been in existence!"), szPrCN);
|
|
MessageBoxEx(NULL, strTips, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
uExecCode = APP_DUPLICATE;
|
|
}
|
|
else if (APP_OVERFLOW == uExecCode)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("工程数量超过最大允许值!"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Project amount overflow!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
uExecCode = APP_FAIL;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
uExecCode = APP_DUPLICATE;
|
|
}
|
|
pRecSynPro->Close();
|
|
}
|
|
pRecPro->Close();
|
|
|
|
return uExecCode;
|
|
}
|
|
|
|
UINT CProManager::CreateDefaultTzInDev(DWORD dwProID, CDevice* const pDev)
|
|
{
|
|
|
|
_RecordsetPtr pRecPro = NULL;
|
|
_RecordsetPtr pRecSynPro = NULL;
|
|
_RecordsetPtr pRecTz = NULL;
|
|
_RecordsetPtr pRecSynTz = NULL;
|
|
_CommandPtr pCmdIns = NULL;
|
|
|
|
CString szSql = _T("");
|
|
|
|
CString szHostFilePath = _T("");
|
|
CString szFilePath = _T("");
|
|
CString szFileName = _T("");
|
|
CString szFile = _T("");
|
|
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
|
|
CString szPrCN = _T("");
|
|
CString szPrName = _T("");
|
|
CString szTzCN = _T("");
|
|
CString szTzName = _T("");
|
|
CString szTzType = _T("");
|
|
char aResBuff[2048] = {0};
|
|
int iResSize = (int)VAL_ZERO;
|
|
|
|
UINT uExecCode = APP_SUCCESS;
|
|
|
|
pRecPro.CreateInstance(_uuidof(Recordset));
|
|
pRecSynPro.CreateInstance(_uuidof(Recordset));
|
|
pRecTz.CreateInstance(_uuidof(Recordset));
|
|
pRecSynTz.CreateInstance(_uuidof(Recordset));
|
|
pCmdIns.CreateInstance(_uuidof(Command));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ID,CN,TZname,TZtype,Format(Cdate,'YYYY-MM-DD') as Cdate,TZdesc,location from tz where PRID = %d order by ID"), dwProID);
|
|
pRecTz->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true),
|
|
adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecTz->GetRecordCount())
|
|
{
|
|
szTzCN.Empty();
|
|
szTzCN = (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("CN"));
|
|
szTzName.Empty();
|
|
szTzName = (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("TZname"));
|
|
szTzType.Empty();
|
|
szTzType = (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("TZtype"));
|
|
int iTzType = pRecTz->GetCollect(_T("TZtype")).lVal;
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select CN,PRname from project where ID = %u"), dwProID);
|
|
pRecPro->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecPro->GetRecordCount())
|
|
{
|
|
szPrCN.Empty();
|
|
szPrCN = (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("CN"));
|
|
szPrName.Empty();
|
|
szPrName = (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("PRname"));
|
|
}
|
|
pRecPro->Close();
|
|
//判断是否为默认测区
|
|
if (3 != pRecTz->GetCollect(_T("TZtype")).lVal)
|
|
{
|
|
CString strErr = _T("");
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strErr.Format(_T("TZType(%d) error in project(%s)"), iTzType, szPrName);
|
|
AfxMessageBox(strErr);
|
|
}
|
|
else
|
|
{
|
|
strErr.Format(_T("TZType(%d) error in project(%s)"), iTzType, szPrName);
|
|
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
pRecTz->Close();
|
|
return APP_FAIL;
|
|
}
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select * from dev_syn_td where TdCN is null and DESN = '%s' and TzCN = '%s'"), pDev->m_szDevSN, szTzCN);
|
|
pRecSynTz->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO == pRecSynTz->GetRecordCount())
|
|
{
|
|
uExecCode = AddTzInDev(szPrCN, szTzCN, szTzType,pDev);
|
|
if (APP_SUCCESS == uExecCode)
|
|
{
|
|
szFilePath.Empty();
|
|
szFilePath.GetBufferSetLength(2048);
|
|
::GetCurrentDirectory(szFilePath.GetLength(), szFilePath.GetBuffer(szFilePath.GetLength()));
|
|
szFilePath.ReleaseBuffer();
|
|
|
|
szFilePath = szFilePath + _T("\\CACHE\\projects\\");
|
|
szFilePath += szPrCN + "\\" + szTzCN + "\\";
|
|
if (!PathFileExistsA(szFilePath)) {
|
|
::CreateDirectoryA(szFilePath, nullptr);
|
|
}
|
|
szFileName = _T("testzone.xml");
|
|
szFile = szFilePath + szFileName;
|
|
|
|
CMarkup* pXML = new CMarkup;
|
|
pXML->SetDoc(_T("<?xml version=\"1.0\" encoding=\"ansi\"?>\r\n"));
|
|
pXML->AddElem(_T("testzone"));
|
|
pXML->AddChildElem(_T("type"), (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("TZtype")));
|
|
pXML->AddChildElem(_T("location"), (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("location")));
|
|
pXML->AddChildElem(_T("desc"), (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("TZdesc")));
|
|
pXML->AddChildElem(_T("create_date"), (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("Cdate")));
|
|
pXML->AddChildElem(_T("create_time"), _T("00:00:00"));
|
|
pXML->AddChildElem(_T("test_date"), (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("Cdate")));
|
|
pXML->AddChildElem(_T("test_time"), _T("00:00:00"));
|
|
pXML->AddChildElem(_T("cn"), (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("CN")));
|
|
pXML->AddChildElem(_T("testzone_name"), (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("TZname")));
|
|
pXML->AddChildElem(_T("testzone_3D_script"));
|
|
|
|
pXML->AddChildElem(_T("vess"));
|
|
pXML->AddChildElem(_T("eris"));
|
|
pXML->AddChildElem(_T("erts"));
|
|
pXML->AddChildElem(_T("wels"));
|
|
|
|
// DeleteFile(szFile);
|
|
pXML->Save(szFile);
|
|
// AfxMessageBox("puase");
|
|
// AfxMessageBox(szFile);
|
|
delete pXML;
|
|
|
|
szHostFilePath.Empty();
|
|
szHostFilePath.Format(_T("/SD/projects/%s/%s/"), szPrCN, szTzCN);
|
|
|
|
if (TRUE == pDev->SendFile(szHostFilePath, szFilePath, szFileName))
|
|
{
|
|
try
|
|
{
|
|
m_pConnection->BeginTrans();
|
|
|
|
pCmdIns->ActiveConnection = m_pConnection;
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into dev_syn_td(DESN,PrCN,PrName,TzCN,TzName,IsSyned) values('%s','%s','%s','%s','%s',true)"), pDev->m_szDevSN, szPrCN, szPrName, szTzCN, szTzName);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
m_pConnection->CommitTrans();
|
|
uExecCode = APP_SUCCESS;
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
m_pConnection->RollbackTrans();
|
|
uExecCode = APP_FAIL;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
CString strTips;
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strTips.Format(_T("发送文件 %s 失败!"), szFileName);
|
|
AfxMessageBox(strTips);
|
|
}
|
|
else
|
|
{
|
|
strTips.Format(_T("Send file %s failed!"), szFileName);
|
|
MessageBoxEx(NULL, strTips, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
|
|
uExecCode = APP_FAIL;
|
|
DeleteTzInDev(szPrCN, szTzCN,pDev);
|
|
}
|
|
// DeleteFile(szFile);
|
|
|
|
}
|
|
else if (APP_DUPLICATE == uExecCode)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
CString strTips;
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strTips.Format(_T("测试区%s已经存在!"), szFileName);
|
|
AfxMessageBox(strTips);
|
|
}
|
|
else
|
|
{
|
|
strTips.Format(_T("The testing zone %s has been in existence!"), szTzCN);
|
|
MessageBoxEx(NULL, strTips, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
uExecCode = APP_DUPLICATE;
|
|
}
|
|
else if (APP_OVERFLOW == uExecCode)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("测试区域数量溢出!"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Testing zone amount overflow!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
uExecCode = APP_FAIL;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
uExecCode = APP_DUPLICATE;
|
|
}
|
|
pRecSynTz->Close();
|
|
}
|
|
else
|
|
{
|
|
CString strErrInfo = _T("");
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strErrInfo.Format(_T("项目缺少Tz数据(%d)"), dwProID);
|
|
AfxMessageBox(strErrInfo);
|
|
}
|
|
else
|
|
{
|
|
strErrInfo.Format(_T("Tz data missing in project(%d)"), dwProID);
|
|
MessageBoxEx(NULL, strErrInfo, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
uExecCode = APP_FAIL;
|
|
}
|
|
pRecTz->Close();
|
|
|
|
return uExecCode;
|
|
}
|
|
|
|
UINT CProManager::CreateTzInDev(DWORD dwID, CDevice* const pDev)
|
|
{
|
|
/*
|
|
_RecordsetPtr pRecPrID = NULL;
|
|
_RecordsetPtr pRecTz = NULL;
|
|
_CommandPtr pCmdCreatePro;
|
|
CString szSql;
|
|
DWORD dwPrID = (DWORD)VAL_ZERO;
|
|
UINT uExecCode = (UINT)VAL_ZERO;
|
|
|
|
pRecPrID.CreateInstance(_uuidof(Recordset));
|
|
pRecTz.CreateInstance(_uuidof(Recordset));
|
|
pCmdCreatePro.CreateInstance(_uuidof(Command));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select PRID from tz where ID = %u"), dwID);
|
|
pRecPrID->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true),
|
|
adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
dwPrID = pRecPrID->GetCollect(_T("PRID")).vt == VT_NULL ? (DWORD)VAL_ZERO : pRecPrID->GetCollect(_T("PRID")).ulVal;
|
|
|
|
pRecPrID->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select * from dptt where DEID = %u and PRID = %u and TZID = %u"), dwDevID, dwPrID, dwID);
|
|
pRecTz->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true),
|
|
adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO == pRecTz->GetRecordCount())
|
|
{
|
|
|
|
CreateProjectInLoc(dwPrID, dwDevID);
|
|
pCmdCreatePro->ActiveConnection = m_pConnection;
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into dptt(DEID,PRID,TZID) values(%u, %u ,%u)"), dwDevID, dwPrID, dwID);
|
|
pCmdCreatePro->CommandText = szSql.AllocSysString();
|
|
pCmdCreatePro->Execute(NULL, NULL, adCmdText);
|
|
uExecCode = APP_SUCCESS;
|
|
}
|
|
else
|
|
{
|
|
uExecCode = APP_DUPLICATE;
|
|
}
|
|
|
|
pRecTz->Close();
|
|
|
|
return uExecCode;
|
|
*/
|
|
_RecordsetPtr pRecPro = NULL;
|
|
_RecordsetPtr pRecSynPro = NULL;
|
|
_RecordsetPtr pRecTz = NULL;
|
|
_RecordsetPtr pRecSynTz = NULL;
|
|
_CommandPtr pCmdIns = NULL;
|
|
|
|
CString szSql = _T("");
|
|
|
|
CString szHostFilePath = _T("");
|
|
CString szFilePath = _T("");
|
|
CString szFileName = _T("");
|
|
CString szFile = _T("");
|
|
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
|
|
CString szPrCN = _T("");
|
|
CString szPrName = _T("");
|
|
CString szTzCN = _T("");
|
|
CString szTzName = _T("");
|
|
CString szTzType = _T("");
|
|
char aResBuff[2048] = {0};
|
|
int iResSize = (int)VAL_ZERO;
|
|
|
|
UINT uExecCode = (UINT)VAL_ZERO;
|
|
|
|
DWORD dwPrID = (DWORD)VAL_ZERO;
|
|
|
|
pRecPro.CreateInstance(_uuidof(Recordset));
|
|
pRecSynPro.CreateInstance(_uuidof(Recordset));
|
|
pRecTz.CreateInstance(_uuidof(Recordset));
|
|
pRecSynTz.CreateInstance(_uuidof(Recordset));
|
|
pCmdIns.CreateInstance(_uuidof(Command));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select PRID,CN,TZname,TZtype,Format(Cdate,'YYYY-MM-DD') as Cdate,TZdesc,location from tz where ID = %d"), dwID);
|
|
pRecTz->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true),
|
|
adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecTz->GetRecordCount())
|
|
{
|
|
dwPrID = pRecTz->GetCollect(_T("PRID")).ulVal;
|
|
szTzCN.Empty();
|
|
szTzCN = (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("CN"));
|
|
szTzName.Empty();
|
|
szTzName = (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("TZname"));
|
|
szTzType.Empty();
|
|
szTzType = (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("TZtype"));
|
|
szSql.Empty();
|
|
szSql.Format(_T("select CN,PRname from project where ID = %u"), dwPrID);
|
|
pRecPro->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecPro->GetRecordCount())
|
|
{
|
|
szPrCN.Empty();
|
|
szPrCN = (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("CN"));
|
|
szPrName.Empty();
|
|
szPrName = (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("PRname"));
|
|
}
|
|
pRecPro->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select * from dev_syn_td where TdCN is null and DESN = '%s' and TzCN = '%s'"), pDev->m_szDevSN, szTzCN);
|
|
pRecSynTz->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO == pRecSynTz->GetRecordCount())
|
|
{
|
|
uExecCode = AddTzInDev(szPrCN, szTzCN, szTzType,pDev);
|
|
if (APP_SUCCESS == uExecCode)
|
|
{
|
|
szFilePath.Empty();
|
|
szFilePath.GetBufferSetLength(2048);
|
|
::GetCurrentDirectory(szFilePath.GetLength(), szFilePath.GetBuffer(szFilePath.GetLength()));
|
|
szFilePath.ReleaseBuffer();
|
|
|
|
szFilePath = szFilePath + _T("\\CACHE\\projects\\");
|
|
szFilePath += szPrCN + "\\" + szTzCN + "\\";
|
|
|
|
szFileName = _T("testzone.xml");
|
|
szFile = szFilePath + szFileName;
|
|
|
|
CMarkup* pXML = new CMarkup;
|
|
pXML->SetDoc(_T("<?xml version=\"1.0\" encoding=\"ansi\"?>\r\n"));
|
|
pXML->AddElem(_T("testzone"));
|
|
pXML->AddChildElem(_T("type"), (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("TZtype")));
|
|
pXML->AddChildElem(_T("location"), (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("location")));
|
|
pXML->AddChildElem(_T("desc"), (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("TZdesc")));
|
|
pXML->AddChildElem(_T("create_date"), (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("Cdate")));
|
|
pXML->AddChildElem(_T("create_time"), _T("00:00:00"));
|
|
pXML->AddChildElem(_T("test_date"), (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("Cdate")));
|
|
pXML->AddChildElem(_T("test_time"), _T("00:00:00"));
|
|
pXML->AddChildElem(_T("cn"), (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("CN")));
|
|
pXML->AddChildElem(_T("testzone_name"), (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("TZname")));
|
|
pXML->AddChildElem(_T("testzone_3D_script"));
|
|
|
|
pXML->AddChildElem(_T("vess"));
|
|
pXML->AddChildElem(_T("eris"));
|
|
pXML->AddChildElem(_T("erts"));
|
|
pXML->AddChildElem(_T("wels"));
|
|
|
|
// DeleteFile(szFile);
|
|
pXML->Save(szFile);
|
|
// AfxMessageBox("puase");
|
|
// AfxMessageBox(szFile);
|
|
delete pXML;
|
|
|
|
szHostFilePath.Empty();
|
|
szHostFilePath.Format(_T("/SD/projects/%s/%s/"), szPrCN, szTzCN);
|
|
|
|
if (TRUE == pDev->SendFile(szHostFilePath, szFilePath, szFileName))
|
|
{
|
|
try
|
|
{
|
|
m_pConnection->BeginTrans();
|
|
|
|
pCmdIns->ActiveConnection = m_pConnection;
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into dev_syn_td(DESN,PrCN,PrName,TzCN,TzName,IsSyned) values('%s','%s','%s','%s','%s',true)"), pDev->m_szDevSN, szPrCN, szPrName, szTzCN, szTzName);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
m_pConnection->CommitTrans();
|
|
uExecCode = APP_SUCCESS;
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
m_pConnection->RollbackTrans();
|
|
uExecCode = APP_FAIL;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
CString strTips;
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strTips.Format(_T("发送文件 %s 失败!"), szFileName);
|
|
AfxMessageBox(strTips);
|
|
}
|
|
else
|
|
{
|
|
strTips.Format(_T("Send file %s failed!"), szFileName);
|
|
MessageBoxEx(NULL, strTips, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
uExecCode = APP_FAIL;
|
|
DeleteTzInDev(szPrCN, szTzCN,pDev);
|
|
}
|
|
// DeleteFile(szFile);
|
|
|
|
}
|
|
else if (APP_DUPLICATE == uExecCode)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
CString strTips;
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strTips.Format(_T("测试区%s已经存在!"), szFileName);
|
|
AfxMessageBox(strTips);
|
|
}
|
|
else
|
|
{
|
|
strTips.Format(_T("The testing zone %s has been in existence!"), szTzCN);
|
|
MessageBoxEx(NULL, strTips, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
uExecCode = APP_DUPLICATE;
|
|
}
|
|
else if (APP_OVERFLOW == uExecCode)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("测试区域数量溢出!"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Testing zone amount overflow!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
uExecCode = APP_FAIL;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
uExecCode = APP_DUPLICATE;
|
|
}
|
|
pRecSynTz->Close();
|
|
}
|
|
pRecTz->Close();
|
|
|
|
return uExecCode;
|
|
}
|
|
|
|
UINT CProManager::CreateTzInDB(DWORD& dwID, DWORD dwPrID)
|
|
{
|
|
_RecordsetPtr pRecTzID = NULL;
|
|
_CommandPtr pCmdCreateTz;
|
|
UINT uExecCode;
|
|
|
|
CString szSql = _T("");
|
|
CString szCaption;
|
|
COpCreateTzDlg opCreateTzDlg;
|
|
INT_PTR lRet = -1;
|
|
|
|
lRet = opCreateTzDlg.DoModal();
|
|
|
|
switch (lRet)
|
|
{
|
|
case IDOK:
|
|
|
|
pCmdCreateTz.CreateInstance(_uuidof(Command));
|
|
pRecTzID.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ID from tz where PRID = %u and TZname = '%s'"), dwPrID, opCreateTzDlg.m_edName);
|
|
pRecTzID->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true),
|
|
adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecTzID->GetRecordCount())
|
|
{
|
|
dwID = pRecTzID->GetCollect(_T("ID")).ulVal;
|
|
}
|
|
pRecTzID->Close();
|
|
|
|
if ((DWORD)VAL_ZERO == dwID)
|
|
{
|
|
pCmdCreateTz->ActiveConnection = m_pConnection;
|
|
|
|
szSql.Empty();
|
|
//xxxx
|
|
szSql.Format(_T("insert into tz(PRID,TZname,TZtype,Cdate,location,TZdesc,CN) values(%u,'%s','%s',#%s#,'%s','%s','%s')"), dwPrID, opCreateTzDlg.m_edName,opCreateTzDlg.m_edTzType, opCreateTzDlg.m_edCDate.FormatGmt("%Y-%m-%d"), opCreateTzDlg.m_edLocation, opCreateTzDlg.m_edTzDesc, m_guCodeCreator.GenerateGUIDCode());
|
|
|
|
pCmdCreateTz->CommandText = szSql.AllocSysString();
|
|
pCmdCreateTz->Execute(NULL, NULL, adCmdText);
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ID from tz where PRID = %u and TZname = '%s'"), dwPrID, opCreateTzDlg.m_edName);
|
|
pRecTzID->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true),
|
|
adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecTzID->GetRecordCount())
|
|
{
|
|
dwID = pRecTzID->GetCollect(_T("ID")).ulVal;
|
|
}
|
|
pRecTzID->Close();
|
|
uExecCode = APP_SUCCESS;
|
|
}
|
|
else
|
|
{
|
|
uExecCode = APP_DUPLICATE;
|
|
}
|
|
|
|
break;
|
|
case IDCANCEL:
|
|
uExecCode = APP_CANCLE;
|
|
break;
|
|
default:
|
|
uExecCode = APP_FAIL;
|
|
break;
|
|
}
|
|
return uExecCode;
|
|
}
|
|
|
|
UINT CProManager::DeleteProjectInDev(CString szMac, CString szPrCN, CDevice* const pDev)
|
|
{
|
|
_CommandPtr pCmdDelPro = NULL;
|
|
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
CString szRes = _T("");
|
|
|
|
CString szSql = _T("");
|
|
CString strShowInfo = _T("");
|
|
if (EN_TRANSFER_FILE_BY_USB == g_iTransFileMode)
|
|
{
|
|
if (CGD10OperCmd::GetInstance()->project_delete(szMac, szPrCN))
|
|
{
|
|
szRes = _T("1");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("project_delete(\"%s\",\"%s\")\r\n"), szMac, szPrCN);
|
|
|
|
if (!pDev->ExecuteOrder(szOrder, "]", &szResBuff))
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strShowInfo.Format(_T("执行命令 %s 失败!!!"), szOrder.GetBuffer(0));
|
|
AfxMessageBox(strShowInfo.GetBuffer(0));
|
|
}
|
|
else
|
|
{
|
|
strShowInfo.Format(_T("Excute cmd %s failed!!!"), szOrder.GetBuffer(0));
|
|
MessageBoxEx(NULL, strShowInfo, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
return APP_FAIL;
|
|
}
|
|
|
|
GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]"));
|
|
|
|
}
|
|
|
|
|
|
if (_T("1") == szRes)
|
|
{
|
|
pCmdDelPro.CreateInstance(_uuidof(Command));
|
|
pCmdDelPro->ActiveConnection = m_pConnection;
|
|
|
|
try
|
|
{
|
|
m_pConnection->BeginTrans();
|
|
szSql.Empty();
|
|
szSql.Format(_T("delete from dev_syn_td where DESN = '%s' and PrCN = '%s'"), pDev->m_szDevSN, szPrCN);
|
|
|
|
pCmdDelPro->CommandText = szSql.AllocSysString();
|
|
pCmdDelPro->Execute(NULL, NULL, adCmdText);
|
|
|
|
m_pConnection->CommitTrans();
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
// CString strInfo=_T("");
|
|
strShowInfo.Empty();
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strShowInfo.Format(_T("删除工程信息失败!, msg = %s"), e.Description());
|
|
AfxMessageBox(strShowInfo.GetBuffer(0));
|
|
}
|
|
else
|
|
{
|
|
strShowInfo.Format(_T("Delete porjectinfo failed!, msg = %s"), e.Description());
|
|
MessageBoxEx(NULL, strShowInfo, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
|
|
m_pConnection->RollbackTrans();
|
|
return APP_FAIL;
|
|
}
|
|
|
|
return APP_SUCCESS;
|
|
}
|
|
else
|
|
{
|
|
return APP_FAIL;
|
|
}
|
|
|
|
}
|
|
|
|
void CProManager::DeleteProjectInDB(DWORD dwID)
|
|
{
|
|
_CommandPtr pCmdDelPro;
|
|
|
|
CString szSql;
|
|
|
|
pCmdDelPro.CreateInstance(_uuidof(Command));
|
|
pCmdDelPro->ActiveConnection = m_pConnection;
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("delete from project where ID = %u"), dwID);
|
|
|
|
pCmdDelPro->CommandText = szSql.AllocSysString();
|
|
pCmdDelPro->Execute(NULL, NULL, adCmdText);
|
|
|
|
/*
|
|
szSql.Empty();
|
|
szSql.Format(_T("delete from dptt where PRID = %u"), dwID);
|
|
|
|
pCmdDelPro->CommandText = szSql.AllocSysString();
|
|
pCmdDelPro->Execute(NULL, NULL, adCmdText);
|
|
*/
|
|
}
|
|
|
|
UINT CProManager::DeleteTzInDev(CString szPrCN, CString szTzCN, CDevice* const pDev)
|
|
{
|
|
_CommandPtr pCmdDelTz = NULL;
|
|
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
CString szRes = _T("");
|
|
CString szSql = _T("");
|
|
CString strShowInfo = _T("");
|
|
if (EN_TRANSFER_FILE_BY_USB == g_iTransFileMode)
|
|
{
|
|
if (1 == CGD10OperCmd::GetInstance()->testzone_delete(szPrCN, szTzCN))
|
|
{
|
|
szRes = _T("1");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("testzone_delete(\"%s\",\"%s\")\r\n"), szPrCN, szTzCN);
|
|
|
|
if (!pDev->ExecuteOrder(szOrder, "]", &szResBuff))
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strShowInfo.Format(_T("执行命令 %s 失败!!!"), szOrder.GetBuffer(0));
|
|
AfxMessageBox(strShowInfo.GetBuffer(0));
|
|
}
|
|
else
|
|
{
|
|
strShowInfo.Format(_T("Excute cmd %s failed!!!"), szOrder.GetBuffer(0));
|
|
MessageBoxEx(NULL, strShowInfo, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
return APP_FAIL;
|
|
}
|
|
|
|
GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]"));
|
|
|
|
|
|
}
|
|
|
|
if (_T("1") == szRes)
|
|
{
|
|
|
|
pCmdDelTz.CreateInstance(_uuidof(Command));
|
|
pCmdDelTz->ActiveConnection = m_pConnection;
|
|
|
|
try
|
|
{
|
|
m_pConnection->BeginTrans();
|
|
szSql.Empty();
|
|
szSql.Format(_T("delete from dev_syn_td where DESN = '%s' and TzCN = '%s'"), pDev->m_szDevSN, szTzCN);
|
|
|
|
pCmdDelTz->CommandText = szSql.AllocSysString();
|
|
pCmdDelTz->Execute(NULL, NULL, adCmdText);
|
|
|
|
m_pConnection->CommitTrans();
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
strShowInfo.Empty();
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strShowInfo.Format(_T("删除工程信息失败!, msg = %s"), e.Description());
|
|
AfxMessageBox(strShowInfo.GetBuffer(0));
|
|
}
|
|
else
|
|
{
|
|
strShowInfo.Format(_T("Delete porjectinfo failed!, msg = %s"), e.Description());
|
|
MessageBoxEx(NULL, strShowInfo, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
|
|
m_pConnection->RollbackTrans();
|
|
return APP_FAIL;
|
|
}
|
|
return APP_SUCCESS;
|
|
}
|
|
else
|
|
{
|
|
return APP_FAIL;
|
|
}
|
|
|
|
}
|
|
|
|
void CProManager::DeleteTzInDB(DWORD dwID)
|
|
{
|
|
_CommandPtr pCmdDelTz;
|
|
|
|
CString szSql;
|
|
|
|
pCmdDelTz.CreateInstance(_uuidof(Command));
|
|
pCmdDelTz->ActiveConnection = m_pConnection;
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("delete from tz where ID = %u"), dwID);
|
|
|
|
pCmdDelTz->CommandText = szSql.AllocSysString();
|
|
pCmdDelTz->Execute(NULL, NULL, adCmdText);
|
|
/*
|
|
szSql.Empty();
|
|
szSql.Format(_T("delete from dptt where TZID = %u"), dwID);
|
|
|
|
pCmdDelTz->CommandText = szSql.AllocSysString();
|
|
pCmdDelTz->Execute(NULL, NULL, adCmdText);
|
|
*/
|
|
}
|
|
|
|
void CProManager::DeleteObjInMem(DWORD dwHandle)
|
|
{
|
|
delete m_dmsLinkList.Find(dwHandle);
|
|
m_dmsLinkList.Delete(dwHandle);
|
|
}
|
|
|
|
bool CProManager::InitialOpDMSTreeForSyn(CTreeCtrl &dmsTree, CString szDeSN)
|
|
{
|
|
_RecordsetPtr pRecPro = NULL;
|
|
_RecordsetPtr pRecSynPro = NULL;
|
|
_RecordsetPtr pRecTz = NULL;
|
|
|
|
HTREEITEM hProItem = NULL;
|
|
HTREEITEM hTzItem = NULL;
|
|
|
|
HTREEITEM hParentItem = NULL;
|
|
|
|
DWORD dwHandle = (DWORD)VAL_ZERO;
|
|
DWORD dwRecCount = (DWORD)VAL_ZERO;
|
|
|
|
DWORD dwProID = (DWORD)VAL_ZERO;
|
|
DWORD dwTzID = (DWORD)VAL_ZERO;
|
|
|
|
CString szLabel = _T("");
|
|
CString szSql = _T("");
|
|
|
|
dmsTree.DeleteAllItems();
|
|
|
|
pRecPro.CreateInstance(_uuidof(Recordset));
|
|
pRecSynPro.CreateInstance(_uuidof(Recordset));
|
|
pRecTz.CreateInstance(_uuidof(Recordset));
|
|
|
|
pRecPro->Open(_T("select ID,PRname,CN from project order by ID"), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
dmsTree.ModifyStyle(TVS_CHECKBOXES, VAL_ZERO);
|
|
dmsTree.ModifyStyle(VAL_ZERO, TVS_CHECKBOXES); //针对MFC的BUG,解决无法选中Checkbox无法选中的问题
|
|
|
|
while ((short)VAL_ZERO == pRecPro->adoEOF)
|
|
{
|
|
szSql.Empty();
|
|
szSql.Format(_T("select PrCN from dev_syn_td where TdCN is null and DESN = '%s' and PrCN = '%s' "), szDeSN, (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("CN")));
|
|
pRecSynPro->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
dwRecCount = pRecSynPro->GetRecordCount();
|
|
pRecSynPro->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ID,TZname from tz where PRID = %u and CN not in (select TzCN from dev_syn_td where TdCN is null and DESN = '%s') order by ID" ),
|
|
pRecPro->GetCollect(_T("ID")).ulVal, szDeSN);
|
|
pRecTz->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecTz->GetRecordCount() || VAL_ZERO == dwRecCount)
|
|
{
|
|
|
|
hProItem = dmsTree.InsertItem((LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("PRname")));
|
|
|
|
dwProID = (DWORD)pRecPro->GetCollect(_T("ID")).ulVal;
|
|
dwHandle = m_handleProcessor.GenerateHandle(dwProID, PZ_STYLE_PRO);
|
|
dmsTree.SetItemData(hProItem, dwHandle);
|
|
/*
|
|
if ((long)VAL_ZERO != pRecTz->GetRecordCount() && VAL_ZERO != dwRecCount)
|
|
{
|
|
dmsTree.SetItemImage(hProItem, PZ_STATE_LOC, VAL_ZERO);
|
|
dmsTree.SetCheck(hProItem, TRUE);
|
|
}
|
|
else
|
|
{
|
|
dmsTree.SetItemImage(hProItem, PZ_STATE_DB, VAL_ZERO);
|
|
dmsTree.SetCheck(hProItem, FALSE);
|
|
}
|
|
*/
|
|
}
|
|
//在这里屏蔽测区的信息
|
|
/*
|
|
while ((short)VAL_ZERO == pRecTz->adoEOF)
|
|
{
|
|
hTzItem = dmsTree.InsertItem((pRecTz->GetCollect(_T("TZname")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("TZname")), hProItem);
|
|
dwTzID = (DWORD)pRecTz->GetCollect(_T("ID")).ulVal;
|
|
dwHandle = m_handleProcessor.GenerateHandle(dwTzID, PZ_STYLE_TZ);
|
|
dmsTree.SetItemData(hTzItem, dwHandle);
|
|
|
|
// dmsTree.SetItemImage(hTzItem, PZ_STATE_DB, VAL_ZERO);
|
|
dmsTree.SetCheck(hTzItem, FALSE);
|
|
|
|
pRecTz->MoveNext();
|
|
} //while (VAL_ZERO == pRecTz->adoEOF)
|
|
|
|
|
|
hParentItem = dmsTree.GetParentItem(hTzItem);
|
|
|
|
if (hParentItem != NULL)
|
|
{
|
|
dmsTree.Expand(hParentItem, TVE_EXPAND);
|
|
hParentItem = NULL;
|
|
} //if (hParentItem != NULL)
|
|
*/
|
|
pRecTz->Close();
|
|
|
|
pRecPro->MoveNext();
|
|
} //while (VAL_ZERO == pRecPro->adoEOF)
|
|
pRecPro->Close();
|
|
|
|
return true;
|
|
}
|
|
|
|
UINT CProManager::CreateDMSInDev(CString szDeSN, CDevice* const pDev)
|
|
{
|
|
// HTREEITEM hProTreeItem = NULL;
|
|
HTREEITEM hProNextItem = NULL;
|
|
HTREEITEM hProChildItem = NULL;
|
|
|
|
// HTREEITEM hTzTreeItem = NULL;
|
|
HTREEITEM hTzNextItem = NULL;
|
|
HTREEITEM hTzChildItem = NULL;
|
|
|
|
DWORD dwProID = (DWORD)VAL_ZERO;
|
|
DWORD dwTzID = (DWORD)VAL_ZERO;
|
|
|
|
_RecordsetPtr pRecProID = NULL;
|
|
_CommandPtr pCmdCreatePro = NULL;
|
|
UINT uExecCode = (UINT)VAL_ZERO;
|
|
|
|
CString szSql;
|
|
CString szCaption;
|
|
INT_PTR lRet = (long)VAL_ZERO;
|
|
COpCreateDmsDlg* pOpCreateDmsDlg = new COpCreateDmsDlg((INT_PTR*)&lRet);
|
|
|
|
pOpCreateDmsDlg->Create(IDD_OP_DMS_L_C, CWnd::FromHandle(::GetActiveWindow()));
|
|
|
|
try
|
|
{
|
|
InitialOpDMSTreeForSyn(pOpCreateDmsDlg->m_dmsTree, szDeSN);
|
|
pOpCreateDmsDlg->m_dmsTree.SelectSetFirstVisible(pOpCreateDmsDlg->m_dmsTree.GetRootItem());
|
|
pOpCreateDmsDlg->ShowWindow(SW_SHOW);
|
|
/*
|
|
while (!lRet)
|
|
{
|
|
DoEvent(pOpCreateDmsDlg->m_hWnd);
|
|
}
|
|
*/
|
|
lRet = pOpCreateDmsDlg->RunModalLoop(MLF_SHOWONIDLE);
|
|
switch (lRet)
|
|
{
|
|
case RET_OK:
|
|
hProNextItem = pOpCreateDmsDlg->m_dmsTree.GetRootItem();
|
|
while (NULL != hProNextItem)
|
|
{
|
|
if (pOpCreateDmsDlg->m_dmsTree.GetCheck(hProNextItem) == TRUE)
|
|
{
|
|
dwProID = m_handleProcessor.GetIDFromHandle(pOpCreateDmsDlg->m_dmsTree.GetItemData(hProNextItem));
|
|
if (1 == dwProID)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("工程下发失败.默认工程不可下发."));
|
|
else
|
|
AfxMessageBox(_T("Project download to failed. Default project cannot be downloaded."));
|
|
hProNextItem = pOpCreateDmsDlg->m_dmsTree.GetNextSiblingItem(hProNextItem);
|
|
uExecCode = APP_DEFAULT;
|
|
continue;
|
|
}
|
|
uExecCode = CreateProjectInDev(dwProID, pDev);
|
|
//此时由于至于一个默认测区,就不能允许下发工程时,返回是重复的值,只能是成功才能运行下发测区
|
|
if (APP_SUCCESS == uExecCode)
|
|
{
|
|
uExecCode = CreateDefaultTzInDev(dwProID, pDev);
|
|
if (APP_SUCCESS != uExecCode)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
uExecCode = APP_FAIL;
|
|
break;
|
|
}
|
|
|
|
|
|
//这段需要注释掉
|
|
/*
|
|
if ((APP_SUCCESS == uExecCode) || (APP_DUPLICATE == uExecCode))
|
|
{
|
|
if (pOpCreateDmsDlg->m_dmsTree.ItemHasChildren(hProNextItem))
|
|
{
|
|
hTzNextItem = pOpCreateDmsDlg->m_dmsTree.GetChildItem(hProNextItem);
|
|
while (NULL != hTzNextItem)
|
|
{
|
|
if (pOpCreateDmsDlg->m_dmsTree.GetCheck(hTzNextItem) == TRUE)
|
|
{
|
|
dwTzID = m_handleProcessor.GetIDFromHandle(pOpCreateDmsDlg->m_dmsTree.GetItemData(hTzNextItem));
|
|
// uExecCode = CreateTzInLoc(dwTzID, dwDevID);
|
|
uExecCode = CreateTzInDev(dwTzID, pDev);
|
|
}
|
|
hTzNextItem = pOpCreateDmsDlg->m_dmsTree.GetNextSiblingItem(hTzNextItem);
|
|
}
|
|
}
|
|
}*/
|
|
}
|
|
|
|
hProNextItem = pOpCreateDmsDlg->m_dmsTree.GetNextSiblingItem(hProNextItem);
|
|
}
|
|
break;
|
|
case RET_CANCEL:
|
|
uExecCode = APP_CANCLE;
|
|
break;
|
|
default:
|
|
uExecCode = APP_FAIL;
|
|
break;
|
|
}
|
|
|
|
pOpCreateDmsDlg->DestroyWindow();
|
|
delete pOpCreateDmsDlg;
|
|
return uExecCode;
|
|
}
|
|
catch (...)
|
|
{
|
|
pOpCreateDmsDlg->DestroyWindow();
|
|
delete pOpCreateDmsDlg;
|
|
throw;
|
|
}
|
|
}
|
|
|
|
BOOL CProManager::InitialDMSTreeForSyn(CTreeCtrl &dmsTree, CString szDeSN)
|
|
{
|
|
_RecordsetPtr pRecPro = NULL;
|
|
_RecordsetPtr pRecTz = NULL;
|
|
|
|
CString szSql = _T("");
|
|
CString szPrName = _T("");
|
|
CString* pPrCN = NULL;
|
|
|
|
CString szTzName = _T("");
|
|
CString* pTzCN = NULL;
|
|
|
|
HTREEITEM hProItem = NULL;
|
|
HTREEITEM hTzItem = NULL;
|
|
|
|
pRecPro.CreateInstance(_uuidof(Recordset));
|
|
pRecTz.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select max(PrName) as PrName,PrCN from dev_syn_td where DESN = '%s' and TdCN is NULL group by PrCN"), szDeSN);
|
|
pRecPro->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecPro->adoEOF)
|
|
{
|
|
szPrName = (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("PrName"));
|
|
|
|
pPrCN = NULL;
|
|
pPrCN = new CString;
|
|
*pPrCN = (LPCTSTR)(_bstr_t)pRecPro->GetCollect(_T("PrCN"));
|
|
|
|
hProItem = NULL;
|
|
hProItem = dmsTree.InsertItem(szPrName);
|
|
dmsTree.SetItemData(hProItem, (DWORD)pPrCN);
|
|
|
|
//删除测区的显示
|
|
/*
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select max(TzName) as TzName,TzCN from dev_syn_td where DESN = '%s' and PrCN = '%s' and TdCN is NULL group by TzCN "), szDeSN, *pPrCN);
|
|
pRecTz->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecTz->adoEOF)
|
|
{
|
|
szTzName = (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("TzName"));
|
|
pTzCN = NULL;
|
|
pTzCN = new CString;
|
|
*pTzCN = (LPCTSTR)(_bstr_t)pRecTz->GetCollect(_T("TzCN"));
|
|
|
|
hTzItem = NULL;
|
|
hTzItem = dmsTree.InsertItem(szTzName, hProItem);
|
|
dmsTree.SetItemData(hTzItem, (DWORD)pTzCN);
|
|
|
|
pRecTz->MoveNext();
|
|
}
|
|
|
|
pRecTz->Close();
|
|
*/
|
|
|
|
dmsTree.Expand(hProItem, TVE_EXPAND);
|
|
pRecPro->MoveNext();
|
|
}
|
|
pRecPro->Close();
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CProManager::ClearDMSTreeForSyn(CTreeCtrl &dmsTree)
|
|
{
|
|
HTREEITEM hProNextItem = NULL;
|
|
HTREEITEM hProChildItem = NULL;
|
|
|
|
HTREEITEM hTzNextItem = NULL;
|
|
HTREEITEM hTzChildItem = NULL;
|
|
CString *pCN = NULL;
|
|
|
|
hProNextItem = dmsTree.GetRootItem();
|
|
while (NULL != hProNextItem)
|
|
{
|
|
if (dmsTree.ItemHasChildren(hProNextItem))
|
|
{
|
|
hTzNextItem = dmsTree.GetChildItem(hProNextItem);
|
|
while (NULL != hTzNextItem)
|
|
{
|
|
pCN = NULL;
|
|
pCN = (CString*)dmsTree.GetItemData(hTzNextItem);
|
|
delete pCN;
|
|
dmsTree.SetItemData(hTzNextItem, 0);
|
|
|
|
hTzNextItem = dmsTree.GetNextSiblingItem(hTzNextItem);
|
|
}
|
|
}
|
|
|
|
pCN = NULL;
|
|
pCN = (CString*)dmsTree.GetItemData(hProNextItem);
|
|
delete pCN;
|
|
|
|
dmsTree.SetItemData(hProNextItem, 0);
|
|
hProNextItem = dmsTree.GetNextSiblingItem(hProNextItem);
|
|
}
|
|
|
|
// hProNextItem = dmsTree.GetRootItem();
|
|
// if (NULL != hProNextItem)
|
|
// {
|
|
// pCN = (CString*)dmsTree.GetItemData(hProNextItem);
|
|
// delete pCN;
|
|
// }
|
|
|
|
if (dmsTree.GetCount() > 0)
|
|
{
|
|
dmsTree.DeleteAllItems();
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
UINT CProManager::AddProjectInDev(CString szMac, CString szPrCN, CDevice* const pDev)
|
|
{
|
|
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
CString szRes = _T("");
|
|
|
|
szOrder.Empty();
|
|
if (EN_TRANSFER_FILE_BY_USB == g_iTransFileMode)
|
|
{
|
|
int iRes = CGD10OperCmd::GetInstance()->project_add(szMac, szPrCN);
|
|
//如果新建目录失败或者文件读写失败,则删除该工程,以防重复
|
|
if (-1 == iRes || -2 == iRes)
|
|
{
|
|
CGD10OperCmd::GetInstance()->project_delete(szMac, szPrCN);
|
|
return APP_FAIL;
|
|
}
|
|
else if(1 == iRes)
|
|
{
|
|
return APP_SUCCESS;
|
|
}
|
|
else
|
|
{
|
|
return APP_FAIL;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
szOrder.Format(_T("project_add(\"%s\",\"%s\")\r\n"), szMac, szPrCN);
|
|
if (!pDev->ExecuteOrder(szOrder, "]", &szResBuff))
|
|
{
|
|
CString strShow = _T("");
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strShow.Format(_T("执行 %s 失败!"), szOrder.GetBuffer(0));
|
|
AfxMessageBox(strShow.GetBuffer(0));
|
|
}
|
|
else
|
|
{
|
|
strShow.Format(_T("Excute %s failed!"), szOrder.GetBuffer(0));
|
|
MessageBoxEx(NULL, strShow, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
|
|
return APP_FAIL;
|
|
}
|
|
|
|
GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]"));
|
|
|
|
if (_T("-3") == szRes)
|
|
{
|
|
return APP_OVERFLOW;
|
|
}
|
|
else if (_T("-4") == szRes)
|
|
{
|
|
return APP_DUPLICATE;
|
|
}
|
|
else if ((_T("0") == szRes) || (_T("-1") == szRes) || (_T("-2") == szRes))
|
|
{
|
|
return APP_FAIL;
|
|
}
|
|
/*
|
|
UINT uiRes = APP_SUCCESS;
|
|
//如果选择的是通过USB来进行工程的下发,则
|
|
if (EN_TRANSFER_FILE_BY_USB == g_iTransFileMode)
|
|
{
|
|
if (!CDetcGD10Dev::GetInstance()->IsGD10DevConnect())
|
|
{
|
|
AfxMessageBox(_T("Geomative can not detect gd10 device!"));
|
|
uiRes = APP_FAIL;
|
|
}
|
|
CString strPath = _T("");
|
|
strPath.Format(_T("%s\\SD\\projects\\%s\\"),CDetcGD10Dev::GetInstance()->GetGD10DevAddr(),szPrCN);
|
|
if (!MakeSureDirectoryPathExists(strPath))
|
|
{
|
|
AfxMessageBox(_T("Add project ")+szPrCN+_T("to device failed!"));
|
|
uiRes = APP_FAIL;
|
|
}
|
|
|
|
return APP_SUCCESS;
|
|
}
|
|
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("project_delete(\"%s\",\"%s\")\r\n"), szMac, szPrCN);
|
|
*/
|
|
return APP_SUCCESS;
|
|
}
|
|
}
|
|
|
|
UINT CProManager::AddTzInDev(CString szPrCN, CString szTzCN, CString szTzTYPE, CDevice* const pDev)
|
|
{
|
|
//如果选择的是通过USB来进行工程的下发,则
|
|
/* if (EN_TRANSFER_FILE_BY_USB == g_iTransFileMode)
|
|
{
|
|
if (!CDetcGD10Dev::GetInstance()->IsGD10DevConnect())
|
|
{
|
|
AfxMessageBox(_T("Geomative can not detect gd10 device!"));
|
|
return APP_FAIL;
|
|
}
|
|
CString strPath = _T("");
|
|
strPath.Format(_T("%s\\SD\\projects\\%s\\%s\\"),CDetcGD10Dev::GetInstance()->GetGD10DevAddr(),szPrCN,szTzCN);
|
|
if (!MakeSureDirectoryPathExists(strPath))
|
|
{
|
|
AfxMessageBox(_T("Add testzone ")+szTzCN+_T("to device failed!"));
|
|
return APP_FAIL;
|
|
}
|
|
return APP_SUCCESS;
|
|
}*/
|
|
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
CString szRes = _T("");
|
|
|
|
if (EN_TRANSFER_FILE_BY_USB == g_iTransFileMode)
|
|
{
|
|
int iRes = CGD10OperCmd::GetInstance()->testzone_add(szPrCN, szTzCN, szTzTYPE);
|
|
//-2在这里表示些文件失败,因为是先创建目录再执行写文件的,所以此时要将创建的目录给删除
|
|
//-1表示的创建目录失败,由于先执行创建目录,如果在这里失败,此时也还写文件,所以不用删除测区
|
|
if (-2 == iRes)
|
|
{
|
|
CGD10OperCmd::GetInstance()->testzone_delete(szPrCN, szTzCN);
|
|
}
|
|
szRes.Empty();
|
|
szRes.Format(_T("%d"),iRes);
|
|
|
|
}
|
|
else
|
|
{
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("testzone_add(\"%s\",\"%s\",\"%s\")\r\n"), szPrCN, szTzCN, szTzTYPE);
|
|
|
|
if (!pDev->ExecuteOrder(szOrder, "]", &szResBuff))
|
|
{
|
|
CString strShow = _T("");
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strShow.Format(_T("执行 %s 失败!"), szOrder.GetBuffer(0));
|
|
AfxMessageBox(strShow.GetBuffer(0));
|
|
}
|
|
else
|
|
{
|
|
strShow.Format(_T("Excute %s failed!"), szOrder.GetBuffer(0));
|
|
MessageBoxEx(NULL, strShow, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
return APP_FAIL;
|
|
}
|
|
|
|
GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_T("-2") == szRes)
|
|
{
|
|
return APP_FAIL;
|
|
}
|
|
if (_T("-3") == szRes)
|
|
{
|
|
return APP_OVERFLOW;
|
|
}
|
|
else if (_T("-4") == szRes)
|
|
{
|
|
return APP_DUPLICATE;
|
|
}
|
|
else if ((_T("0") == szRes) || (_T("-1") == szRes))
|
|
{
|
|
return APP_FAIL;
|
|
}
|
|
|
|
return APP_SUCCESS;
|
|
}
|
|
|
|
DWORD CProManager::LoadProjectFromDev(CString szPrCN, CDevice * const pDev)
|
|
{
|
|
CString szPrName = _T("");
|
|
CString szDesc = _T("");
|
|
CString szLoc = _T("");
|
|
CString szCDate = _T("");
|
|
CString szCTime = _T("");
|
|
CString szTDate = _T("");
|
|
CString szTTime = _T("");
|
|
CString szDuration = _T("");
|
|
CString szPS = _T("");
|
|
CString szCS = _T("");
|
|
CString szPM = _T("");
|
|
CString szQA = _T("");
|
|
CString szStandard = _T("");
|
|
|
|
CString szLocFilePath = _T("");
|
|
CString szFileName = _T("");
|
|
CString szHostFile = _T("");
|
|
CString szLocFile = _T("");
|
|
|
|
CMarkup* pXML = NULL;
|
|
CString szSql = _T("");
|
|
DWORD dwPrID = (DWORD)VAL_ZERO;
|
|
|
|
_RecordsetPtr pRecPro = NULL;
|
|
_RecordsetPtr pRecPrID = NULL;
|
|
_CommandPtr pCmdIns = NULL;
|
|
|
|
pRecPro.CreateInstance(_uuidof(Recordset));
|
|
pRecPrID.CreateInstance(_uuidof(Recordset));
|
|
|
|
pCmdIns.CreateInstance(_uuidof(Command));
|
|
pCmdIns->ActiveConnection = m_pConnection;
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ID from project where CN = '%s'"), szPrCN);
|
|
pRecPro->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO == pRecPro->GetRecordCount())
|
|
{
|
|
szLocFilePath.Empty();
|
|
szLocFilePath.GetBufferSetLength(256);
|
|
::GetCurrentDirectory(szLocFilePath.GetLength(), szLocFilePath.GetBuffer(szLocFilePath.GetLength()));
|
|
szLocFilePath.ReleaseBuffer();
|
|
|
|
szLocFilePath = szLocFilePath + _T("\\CACHE\\projects\\");
|
|
szLocFilePath += szPrCN;
|
|
if (!PathFileExistsA(szLocFilePath)) {
|
|
::CreateDirectoryA(szLocFilePath, nullptr);
|
|
}
|
|
szLocFilePath += "\\";
|
|
szLocFile = szLocFilePath + _T("project.xml");
|
|
|
|
szHostFile = _T("/SD/projects/")+szPrCN+_T("/")+_T("project.xml");
|
|
if (TRUE == pDev->ReceiveFile(szLocFilePath, szHostFile))
|
|
{
|
|
pXML = new CMarkup;
|
|
|
|
pXML->Load(szLocFile);
|
|
pXML->FindElem(_T("project"));
|
|
pXML->FindChildElem(_T("project_name"));
|
|
szPrName = pXML->GetChildData();
|
|
pXML->FindChildElem(_T("description"));
|
|
szDesc = pXML->GetChildData();
|
|
pXML->FindChildElem(_T("location"));
|
|
szLoc = pXML->GetChildData();
|
|
pXML->FindChildElem(_T("create_date"));
|
|
szCDate = pXML->GetChildData();
|
|
pXML->FindChildElem(_T("create_time"));
|
|
szCTime = pXML->GetChildData();
|
|
pXML->FindChildElem(_T("test_date"));
|
|
szTDate = pXML->GetChildData();
|
|
pXML->FindChildElem(_T("test_time"));
|
|
szTTime = pXML->GetChildData();
|
|
pXML->FindChildElem(_T("duration"));
|
|
szDuration = pXML->GetChildData();
|
|
pXML->FindChildElem(_T("PS"));
|
|
szPS = pXML->GetChildData();
|
|
pXML->FindChildElem(_T("CS"));
|
|
szCS = pXML->GetChildData();
|
|
pXML->FindChildElem(_T("PM"));
|
|
szPM = pXML->GetChildData();
|
|
pXML->FindChildElem(_T("QA"));
|
|
szQA = pXML->GetChildData();
|
|
pXML->FindChildElem(_T("standard"));
|
|
szStandard = pXML->GetChildData();
|
|
|
|
delete pXML;
|
|
|
|
szSql.Empty();
|
|
|
|
szSql.Format(_T("insert into project(CN,PRname,PRdesc,location,PRdate,duration,PS,CS,PM,QAS,standard) values('%s','%s','%s','%s',#%s#,%s,'%s','%s','%s','%s','%s')"),
|
|
szPrCN,
|
|
szPrName,
|
|
szDesc,
|
|
szLoc,
|
|
szCDate,
|
|
szDuration,
|
|
szPS,
|
|
szCS,
|
|
szPM,
|
|
szQA,
|
|
szStandard);
|
|
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
pRecPrID->Open(_T("select max(ID) as ID from project"), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecPrID->GetRecordCount())
|
|
{
|
|
dwPrID = pRecPrID->GetCollect(_T("ID")).ulVal;
|
|
}
|
|
pRecPrID->Close();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
dwPrID = pRecPro->GetCollect(_T("ID")).ulVal;
|
|
}
|
|
pRecPro->Close();
|
|
|
|
return dwPrID;
|
|
}
|
|
|
|
DWORD CProManager::LoadTzFromDev(CString szPrCN, CString szTzCN, CDevice* const pDev)
|
|
{
|
|
CString szLoc = _T("");
|
|
CString szDesc = _T("");
|
|
CString szCDate = _T("");
|
|
CString szTDate = _T("");
|
|
CString szTTime = _T("");
|
|
CString TzName = _T("");
|
|
CString szTzType = _T("");
|
|
|
|
DWORD dwPrID = (DWORD)VAL_ZERO;
|
|
DWORD dwTzID = (DWORD)VAL_ZERO;
|
|
|
|
CString szLocFilePath = _T("");
|
|
CString szFileName = _T("");
|
|
CString szHostFile = _T("");
|
|
CString szLocFile = _T("");
|
|
|
|
CMarkup* pXML = NULL;
|
|
CMarkup* pType = NULL;
|
|
CString szSql = _T("");
|
|
|
|
_RecordsetPtr pRecTz = NULL;
|
|
_RecordsetPtr pRecTzID = NULL;
|
|
_CommandPtr pCmdIns = NULL;
|
|
_CommandPtr pCmdUpd = NULL;
|
|
|
|
try
|
|
{
|
|
m_pConnection->BeginTrans();
|
|
dwPrID = this->LoadProjectFromDev(szPrCN, pDev);
|
|
szTzType = this->GetTZType(szPrCN,szTzCN, pDev);//取测区类型
|
|
|
|
pRecTz.CreateInstance(_uuidof(Recordset));
|
|
pRecTzID.CreateInstance(_uuidof(Recordset));
|
|
|
|
pCmdUpd.CreateInstance(_uuidof(Command));
|
|
pCmdUpd->ActiveConnection = m_pConnection;
|
|
|
|
pCmdIns.CreateInstance(_uuidof(Command));
|
|
pCmdIns->ActiveConnection = m_pConnection;
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ID from tz where CN = '%s'"), szTzCN);
|
|
pRecTz->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO == pRecTz->GetRecordCount())
|
|
{
|
|
szLocFilePath.Empty();
|
|
szLocFilePath.GetBufferSetLength(256);
|
|
::GetCurrentDirectory(szLocFilePath.GetLength(), szLocFilePath.GetBuffer(szLocFilePath.GetLength()));
|
|
szLocFilePath.ReleaseBuffer();
|
|
|
|
szLocFilePath = szLocFilePath + _T("\\CACHE\\projects\\");
|
|
szLocFilePath += szPrCN;
|
|
if (!PathFileExistsA(szLocFilePath)) {
|
|
::CreateDirectoryA(szLocFilePath, nullptr);
|
|
}
|
|
szLocFilePath += "\\"+ szTzCN;
|
|
if (!PathFileExistsA(szLocFilePath)) {
|
|
::CreateDirectoryA(szLocFilePath, nullptr);
|
|
}
|
|
szLocFilePath += "\\";
|
|
szLocFile = szLocFilePath + _T("testzone.xml");
|
|
|
|
szHostFile = _T("/SD/projects/")+szPrCN+_T("/")+szTzCN+_T("/")+_T("testzone.xml");
|
|
if (TRUE == pDev->ReceiveFile(szLocFilePath, szHostFile))
|
|
{
|
|
pXML = new CMarkup;
|
|
if (NULL != pXML)
|
|
{
|
|
pXML->Load(szLocFile);
|
|
pXML->FindElem(_T("testzone"));
|
|
pXML->FindChildElem(_T("location"));
|
|
szLoc = pXML->GetChildData();
|
|
pXML->FindChildElem(_T("desc"));
|
|
szDesc = pXML->GetChildData();
|
|
pXML->FindChildElem(_T("create_date"));
|
|
szCDate = pXML->GetChildData();
|
|
pXML->FindChildElem(_T("test_date"));
|
|
szTDate = pXML->GetChildData();
|
|
pXML->FindChildElem(_T("test_time"));
|
|
szTTime = pXML->GetChildData();
|
|
pXML->FindChildElem(_T("testzone_name"));
|
|
TzName = pXML->GetChildData();
|
|
|
|
delete pXML;
|
|
pXML = NULL;
|
|
}
|
|
|
|
|
|
szSql.Empty();
|
|
//在这里一定要加上TdCN is NULL,表明只是对测区进行同步置位TRUE,如果不加,则会对测区下面的所有任务都置位为TRUE
|
|
szSql.Format(_T("update dev_syn_td set IsSyned = true where DESN = '%s' and TzCN = '%s' and TdCN is NULL"),
|
|
pDev->m_szDevSN, szTzCN);
|
|
pCmdUpd->CommandText = szSql.AllocSysString();
|
|
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into tz(PRID,TZname,TZtype,Cdate,location,TZdesc,CN) values(%u,'%s','%s',#%s#,'%s','%s','%s')"),
|
|
dwPrID,
|
|
TzName,
|
|
szTzType,
|
|
szCDate,
|
|
szLoc,
|
|
szDesc,
|
|
szTzCN);
|
|
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
pRecTzID->Open(_T("select max(ID) as ID from tz"), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecTzID->GetRecordCount())
|
|
{
|
|
dwTzID = pRecTzID->GetCollect(_T("ID")).ulVal;
|
|
}
|
|
pRecTzID->Close();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
dwTzID = pRecTz->GetCollect(_T("ID")).ulVal;
|
|
}
|
|
pRecTz->Close();
|
|
|
|
m_pConnection->CommitTrans();
|
|
}
|
|
catch (...)
|
|
{
|
|
m_pConnection->RollbackTrans();
|
|
return 0;
|
|
}
|
|
|
|
|
|
return dwTzID;
|
|
}
|
|
|
|
CString CProManager::GetTZType(CString szPrCN, CString szTzCN, CDevice *const pDev)
|
|
{
|
|
CString szLocFilePath = _T("");
|
|
CString szFileName = _T("");
|
|
CString szHostFile = _T("");
|
|
CString szLocFile = _T("");
|
|
CString szElmData = _T("");
|
|
CString szType = _T("");
|
|
|
|
CMarkup* pXML = NULL;
|
|
|
|
szLocFilePath.Empty();
|
|
szLocFilePath.GetBufferSetLength(256);
|
|
::GetCurrentDirectory(szLocFilePath.GetLength(), szLocFilePath.GetBuffer(szLocFilePath.GetLength()));
|
|
szLocFilePath.ReleaseBuffer();
|
|
|
|
szLocFilePath = szLocFilePath + _T("\\CACHE\\projects\\");
|
|
szLocFilePath += szPrCN;
|
|
if (!PathFileExistsA(szLocFilePath)) {
|
|
::CreateDirectoryA(szLocFilePath, nullptr);
|
|
}
|
|
szLocFilePath += "\\";
|
|
|
|
szLocFile = szLocFilePath + _T("project.xml");
|
|
|
|
szHostFile = _T("/SD/projects/")+szPrCN+_T("/")+_T("project.xml");
|
|
if (TRUE == pDev->ReceiveFile(szLocFilePath, szHostFile))
|
|
{
|
|
pXML = new CMarkup;
|
|
if (NULL != pXML)
|
|
{
|
|
pXML->Load(szLocFile);
|
|
pXML->FindChildElem("testzones");
|
|
pXML->IntoElem();
|
|
while (pXML->FindChildElem("testzone"))
|
|
{
|
|
szElmData = pXML->GetChildData();
|
|
if (szElmData == szTzCN)
|
|
{
|
|
szType = pXML->GetChildAttrib("type");
|
|
if (szType.GetLength() == 0)//兼容老的测区,老测区没有类型
|
|
{
|
|
//szType = "1";
|
|
//在新的方案里,全通测区用的值是3
|
|
szType = "3";
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
delete pXML;
|
|
}
|
|
}
|
|
return szType;
|
|
} |