6839 lines
216 KiB
C++
6839 lines
216 KiB
C++
// TdManager.cpp: implementation of the CTdManager class.
|
||
//
|
||
//////////////////////////////////////////////////////////////////////
|
||
|
||
#include "geomative.h"
|
||
#include "TdManager.h"
|
||
#include "Constant.h"
|
||
#include "Rsp2DTd.h"
|
||
#include "Ipsp2DTd.h"
|
||
#include "RspCETd.h"
|
||
|
||
#include "SP2DTd.h"
|
||
#include "SP3DTd.h"
|
||
#include "SPCETd.h"
|
||
|
||
#include "IpspCETd.h"
|
||
#include "Ipsp3DTd.h"
|
||
|
||
#include "Rsp3DTd.h"
|
||
#include "optd2dto3ddlg.h"
|
||
#include "Res3DDatFile.h"
|
||
#include "GD10OperCmd.h"
|
||
#include "TaskProgressDlg.h"
|
||
#include "FileOperTools.h"
|
||
#include "TaskDataOper.h"
|
||
#include "DetcGD10Dev.h"
|
||
|
||
#include <iostream>
|
||
#include <string>
|
||
|
||
using namespace std; // Bringing the std namespace into scope
|
||
|
||
#ifdef _DEBUG
|
||
#undef THIS_FILE
|
||
static char THIS_FILE[]=__FILE__;
|
||
#define new DEBUG_NEW
|
||
#endif
|
||
extern CGeoMativeApp theApp;
|
||
extern int g_iTransFileMode;
|
||
extern int g_iLanguage;
|
||
extern int g_iTransMode;
|
||
extern void TransDelay(int iTransMode, int iDS0, int iDS1, HWND hWnd = NULL);
|
||
extern void SplitterString(CStringArray &szArray,const CString& szSource, const CString& szSplitter);
|
||
extern BOOL GetSubStringInHeadAndTail(const CString& szSource, CString& szSub, const CString& szHead, const CString& szTail);
|
||
extern CString GetGrCodeText(int iCode);
|
||
extern HHOOK hHook;
|
||
extern LRESULT __stdcall CBTHookProc(long nCode, WPARAM wParam, LPARAM lParam);
|
||
extern int g_iUILanguage;
|
||
extern CString OnLineLocalTaskState(BYTE ucTaskStats);
|
||
extern CString Tm2GmtStr(time_t t);
|
||
extern CString Tm2LocalStr(time_t t);
|
||
#define MODULE_NAME _T("CTdManager")
|
||
//////////////////////////////////////////////////////////////////////
|
||
// Construction/Destruction
|
||
//////////////////////////////////////////////////////////////////////
|
||
|
||
CTdManager::CTdManager(_ConnectionPtr& pConnection)
|
||
{
|
||
ASSERT(NULL != pConnection);
|
||
m_pConnection = pConnection;
|
||
m_tdLinkList.DeleteAll();
|
||
|
||
m_pFile = fopen("log\\td_time_error.txt", "ab");
|
||
m_log = _T("");
|
||
}
|
||
|
||
CTdManager::~CTdManager()
|
||
{
|
||
int iTdIndex = 0;
|
||
|
||
iTdIndex++;
|
||
|
||
while (NULL != m_tdLinkList.Find(iTdIndex))
|
||
{
|
||
delete m_tdLinkList.Find(iTdIndex);
|
||
iTdIndex++;
|
||
}
|
||
m_tdLinkList.DeleteAll();
|
||
}
|
||
|
||
bool CTdManager::ShowTdListByProject(DWORD dwProHandle, CListCtrl& tdList)
|
||
{
|
||
_RecordsetPtr pRecTdList = NULL;
|
||
_RecordsetPtr pRecTz = NULL;
|
||
_RecordsetPtr pRecTdHead = NULL;
|
||
_RecordsetPtr pRecDev = NULL;
|
||
_RecordsetPtr pRecPara = NULL;
|
||
_RecordsetPtr pRecCm = NULL;
|
||
|
||
CString szSql;
|
||
CString szLabel;
|
||
DWORD dwTdHandle = (DWORD)VAL_ZERO;
|
||
DWORD dwProID = m_handleProcessor.GetIDFromHandle(dwProHandle);
|
||
DWORD dwTzID = (DWORD)VAL_ZERO;
|
||
|
||
// dwTzID = m_handleProcessor.GetIDFromHandle(dwTzHandle);
|
||
|
||
int iIndex = (int)VAL_ZERO;
|
||
tdList.SetExtendedStyle(tdList.GetExtendedStyle() | LVS_EX_CHECKBOXES //复选框
|
||
| LVS_EX_FULLROWSELECT //选择后整行高亮
|
||
| LVS_EX_HEADERDRAGDROP //报表头可以拖拽
|
||
| LVS_EX_ONECLICKACTIVATE //单击激活
|
||
| LVS_EX_GRIDLINES //网格线(只适用与report风格的listctrl)
|
||
| LVS_EX_MULTIWORKAREAS);//多工作区
|
||
|
||
pRecTdList.CreateInstance(_uuidof(Recordset));
|
||
pRecTz.CreateInstance(_uuidof(Recordset));
|
||
pRecTdHead.CreateInstance(_uuidof(Recordset));
|
||
pRecDev.CreateInstance(_uuidof(Recordset));
|
||
pRecPara.CreateInstance(_uuidof(Recordset));
|
||
pRecCm.CreateInstance(_uuidof(Recordset));
|
||
|
||
if ((int)VAL_ZERO != tdList.GetItemCount())
|
||
{
|
||
tdList.DeleteAllItems();
|
||
}
|
||
|
||
try
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID 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())
|
||
{
|
||
CString strErr = _T("");
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strErr.Format(_T("项目缺少数据(%d)"), dwProID);
|
||
AfxMessageBox(strErr);
|
||
}
|
||
else
|
||
{
|
||
strErr.Format(_T("Data missing in project(%d)"), dwProID);
|
||
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
return false;
|
||
}
|
||
dwTzID = pRecTz->GetCollect(_T("ID")).lVal;
|
||
pRecTz->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID,TDname,Tlocation,DESN,SCCN,Sname,Stype,Ttype,Tmode,Eamount,TPamount,CHamount,N,TRwave,TRfrequency,Ifrequency,SAfrequency,Clayout,Espace,Edistance,weather,WDIR,"
|
||
"temperature,height,humidity,Format(Cdate,'YYYY-MM-DD') as Cdate,Format(Ctime,'HH:MM:SS') as Ctime,Format(Tdate,'YYYY-MM-DD') as Tdate,Format(Ttime,'HH:MM:SS') as Ttime, "
|
||
"Rdirection,CRtime,IIf(IsNull(PM),'',PM) as PM,IIf(IsNull(OP),'',OP) as OP,IIf(IsNull(QA),'',QA) as QA from td where TZID = %u"), dwTzID);
|
||
|
||
pRecTdList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
}
|
||
catch (_com_error e)
|
||
{
|
||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||
AfxMessageBox((LPCTSTR)e.Description(), MB_ICONINFORMATION);
|
||
}
|
||
|
||
while ((short)VAL_ZERO == pRecTdList->adoEOF)
|
||
{
|
||
tdList.InsertItem(iIndex, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("TDname")));
|
||
// tdList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Tlocation")));
|
||
tdList.SetItemText(iIndex, 1, (pRecTdList->GetCollect(_T("DESN")).vt==VT_NULL)?_T(""):(LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("DESN")));
|
||
tdList.SetItemText(iIndex, 2, (pRecTdList->GetCollect(_T("SCCN")).vt==VT_NULL)?_T(""):(LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("SCCN")));
|
||
tdList.SetItemText(iIndex, 3, (pRecTdList->GetCollect(_T("Sname")).vt==VT_NULL)?_T(""):(LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Sname")));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Stype' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Stype")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Stype")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 4, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Ttype' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Ttype")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Ttype")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 5, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Tmode' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Tmode")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Tmode")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 6, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
tdList.SetItemText(iIndex, 7, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Eamount")));
|
||
tdList.SetItemText(iIndex, 8, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("TPamount")));
|
||
tdList.SetItemText(iIndex, 9, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("CHamount")));
|
||
|
||
tdList.SetItemText(iIndex, 10, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("N")));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'TRwave' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("TRwave")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("TRwave")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 11, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
if ((0 == pRecTdList->GetCollect(_T("Ttype")).iVal) || (1 == pRecTdList->GetCollect(_T("Ttype")).iVal))
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Trfrequency' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Trfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Trfrequency")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 12, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
}
|
||
else if (2 == pRecTdList->GetCollect(_T("Ttype")).iVal)
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Trfrequencyself' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Trfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Trfrequency")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 12, pRecCm->GetCollect(_T("Clabel")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
}
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Ifrequency' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Ifrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Ifrequency")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 13, pRecCm->GetCollect(_T("Clabel")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
if (0 == pRecTdList->GetCollect(_T("Ifrequency")).iVal)
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'SAfrequency50' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("SAfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("SAfrequency")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 14, pRecCm->GetCollect(_T("Clabel")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
}
|
||
else if (1 == pRecTdList->GetCollect(_T("Ifrequency")).iVal)
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'SAfrequency60' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("SAfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("SAfrequency")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 14, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
}
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Clayout' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Clayout")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Clayout")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 15, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
tdList.SetItemText(iIndex, 16, (pRecTdList->GetCollect(_T("Espace")).vt==VT_NULL)?_T(""):(LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Espace")));
|
||
tdList.SetItemText(iIndex, 17, (pRecTdList->GetCollect(_T("Edistance")).vt==VT_NULL)?_T(""):(LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Edistance")));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'weather' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("weather")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("weather")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 18, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'WDIR' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("WDIR")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("WDIR")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 19, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
CString szDefault = _T("");
|
||
|
||
szDefault = (pRecTdList->GetCollect(_T("temperature")).vt==VT_NULL)?_T(""):(LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("temperature"));
|
||
|
||
if (szDefault == "-9999")//若为该值则不显示东西
|
||
{
|
||
szDefault = "";
|
||
}
|
||
|
||
tdList.SetItemText(iIndex, 20, szDefault);
|
||
|
||
tdList.SetItemText(iIndex, 21, (pRecTdList->GetCollect(_T("height")).vt==VT_NULL)?_T(""):(LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("height")));
|
||
szDefault.Empty();
|
||
szDefault = (pRecTdList->GetCollect(_T("humidity")).vt==VT_NULL)?_T(""):(LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("humidity"));
|
||
|
||
if (szDefault == "-9999")//若为该值则不显示东西
|
||
{
|
||
szDefault = "";
|
||
}
|
||
|
||
tdList.SetItemText(iIndex, 22, szDefault);
|
||
tdList.SetItemText(iIndex, 23, (pRecTdList->GetCollect(_T("Cdate")).vt==VT_NULL)?_T(""):(LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Cdate")));
|
||
tdList.SetItemText(iIndex, 24, (pRecTdList->GetCollect(_T("Ctime")).vt==VT_NULL)?_T(""):(LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Ctime")));
|
||
|
||
tdList.SetItemText(iIndex, 25, (pRecTdList->GetCollect(_T("Tdate")).vt==VT_NULL)?_T(""):(LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Tdate")));
|
||
tdList.SetItemText(iIndex, 26, (pRecTdList->GetCollect(_T("Ttime")).vt==VT_NULL)?_T(""):(LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Ttime")));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Rdirection' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Rdirection")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Rdirection")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 27, pRecCm->GetCollect(_T("Clabel")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
tdList.SetItemText(iIndex, 28, (pRecTdList->GetCollect(_T("CRtime")).vt==VT_NULL)?_T(""):(LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("CRtime")));
|
||
tdList.SetItemText(iIndex, 29, (pRecTdList->GetCollect(_T("PM")).vt==VT_NULL)?_T(""):(LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("PM")));
|
||
tdList.SetItemText(iIndex, 30, (pRecTdList->GetCollect(_T("OP")).vt==VT_NULL)?_T(""):(LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("OP")));
|
||
tdList.SetItemText(iIndex, 31, (pRecTdList->GetCollect(_T("QA")).vt==VT_NULL)?_T(""):(LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("QA")));
|
||
|
||
|
||
switch (pRecTdList->GetCollect(_T("Ttype")).iVal)
|
||
{
|
||
case 0:
|
||
switch (pRecTdList->GetCollect(_T("Stype")).iVal)
|
||
{
|
||
case 0:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_CERSP);
|
||
break;
|
||
case 1:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_2DRSP);
|
||
break;
|
||
case 2:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_3DRSP);
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
break;
|
||
case 1:
|
||
switch (pRecTdList->GetCollect(_T("Stype")).iVal)
|
||
{
|
||
case 0:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_CEIPSP);
|
||
break;
|
||
case 1:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_2DIPSP);
|
||
break;
|
||
case 2:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_3DIPSP);
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
break;
|
||
case 2:
|
||
switch (pRecTdList->GetCollect(_T("Stype")).iVal)
|
||
{
|
||
case 0:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_CESP);
|
||
break;
|
||
case 1:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_2DSP);
|
||
break;
|
||
case 2:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_3DSP);
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
tdList.SetItemData(iIndex, dwTdHandle);
|
||
|
||
iIndex++;
|
||
pRecTdList->MoveNext();
|
||
}
|
||
|
||
pRecTdList->Close();
|
||
|
||
return true;
|
||
|
||
}
|
||
|
||
bool CTdManager::ShowTdListByTz(DWORD dwTzHandle, CListCtrl& tdList)
|
||
{
|
||
_RecordsetPtr pRecTdList = NULL;
|
||
_RecordsetPtr pRecTdHead = NULL;
|
||
_RecordsetPtr pRecDev = NULL;
|
||
_RecordsetPtr pRecPara = NULL;
|
||
_RecordsetPtr pRecCm = NULL;
|
||
|
||
CString szSql;
|
||
CString szLabel;
|
||
DWORD dwTdHandle = (DWORD)VAL_ZERO;
|
||
DWORD dwTzID = (DWORD)VAL_ZERO;
|
||
|
||
dwTzID = m_handleProcessor.GetIDFromHandle(dwTzHandle);
|
||
|
||
int iIndex = (int)VAL_ZERO;
|
||
|
||
pRecTdList.CreateInstance(_uuidof(Recordset));
|
||
pRecTdHead.CreateInstance(_uuidof(Recordset));
|
||
pRecDev.CreateInstance(_uuidof(Recordset));
|
||
pRecPara.CreateInstance(_uuidof(Recordset));
|
||
pRecCm.CreateInstance(_uuidof(Recordset));
|
||
|
||
if ((int)VAL_ZERO != tdList.GetItemCount())
|
||
{
|
||
tdList.DeleteAllItems();
|
||
}
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID,TDname,Tlocation,DESN,SCCN,Sname,Stype,Ttype,Tmode,Eamount,TPamount,CHamount,N,TRwave,TRfrequency,Ifrequency,SAfrequency,Clayout,Espace,Edistance,weather,WDIR,"
|
||
"temperature,height,humidity,Format(Cdate,'YYYY-MM-DD') as Cdate,Format(Ctime,'HH:MM:SS') as Ctime,Format(Tdate,'YYYY-MM-DD') as Tdate,Format(Ttime,'HH:MM:SS') as Ttime, "
|
||
"Rdirection,CRtime,IIf(IsNull(PM),'',PM) as PM,IIf(IsNull(OP),'',OP) as OP,IIf(IsNull(QA),'',QA) as QA from td where TZID = %u"), dwTzID);
|
||
|
||
try
|
||
{
|
||
pRecTdList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
}
|
||
catch (_com_error e)
|
||
{
|
||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||
AfxMessageBox((LPCTSTR)e.Description(), MB_ICONINFORMATION);
|
||
}
|
||
|
||
while ((short)VAL_ZERO == pRecTdList->adoEOF)
|
||
{
|
||
tdList.InsertItem(iIndex, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("TDname")));
|
||
// tdList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Tlocation")));
|
||
tdList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("DESN")));
|
||
tdList.SetItemText(iIndex, 2, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("SCCN")));
|
||
tdList.SetItemText(iIndex, 3, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Sname")));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Stype' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Stype")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Stype")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 4, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Ttype' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Ttype")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Ttype")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 5, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Tmode' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Tmode")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Tmode")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 6, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
tdList.SetItemText(iIndex, 7, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Eamount")));
|
||
tdList.SetItemText(iIndex, 8, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("TPamount")));
|
||
tdList.SetItemText(iIndex, 9, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("CHamount")));
|
||
|
||
tdList.SetItemText(iIndex, 10, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("N")));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'TRwave' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("TRwave")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("TRwave")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 11, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
if ((0 == pRecTdList->GetCollect(_T("Ttype")).iVal) || (1 == pRecTdList->GetCollect(_T("Ttype")).iVal))
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Trfrequency' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Trfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Trfrequency")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 12, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
}
|
||
else if (2 == pRecTdList->GetCollect(_T("Ttype")).iVal)
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Trfrequencyself' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Trfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Trfrequency")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 12, pRecCm->GetCollect(_T("Clabel")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
}
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Ifrequency' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Ifrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Ifrequency")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 13, pRecCm->GetCollect(_T("Clabel")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
if (0 == pRecTdList->GetCollect(_T("Ifrequency")).iVal)
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'SAfrequency50' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("SAfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("SAfrequency")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 14, pRecCm->GetCollect(_T("Clabel")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
}
|
||
else if (1 == pRecTdList->GetCollect(_T("Ifrequency")).iVal)
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'SAfrequency60' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("SAfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("SAfrequency")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 14, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
}
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Clayout' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Clayout")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Clayout")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 15, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
tdList.SetItemText(iIndex, 16, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Espace")));
|
||
tdList.SetItemText(iIndex, 17, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Edistance")));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'weather' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("weather")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("weather")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 18, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'WDIR' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("WDIR")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("WDIR")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 19, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
tdList.SetItemText(iIndex, 20, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("temperature")));
|
||
tdList.SetItemText(iIndex, 21, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("height")));
|
||
|
||
tdList.SetItemText(iIndex, 22, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("humidity")));
|
||
tdList.SetItemText(iIndex, 23, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Cdate")));
|
||
tdList.SetItemText(iIndex, 24, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Ctime")));
|
||
|
||
tdList.SetItemText(iIndex, 25, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Tdate")));
|
||
tdList.SetItemText(iIndex, 26, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Ttime")));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Rdirection' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Rdirection")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Rdirection")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 27, pRecCm->GetCollect(_T("Clabel")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
tdList.SetItemText(iIndex, 28, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("CRtime")));
|
||
|
||
switch (pRecTdList->GetCollect(_T("Ttype")).iVal)
|
||
{
|
||
case 0:
|
||
switch (pRecTdList->GetCollect(_T("Stype")).iVal)
|
||
{
|
||
case 0:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_CERSP);
|
||
break;
|
||
case 1:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_2DRSP);
|
||
break;
|
||
case 2:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_3DRSP);
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
break;
|
||
case 1:
|
||
switch (pRecTdList->GetCollect(_T("Stype")).iVal)
|
||
{
|
||
case 0:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_CEIPSP);
|
||
break;
|
||
case 1:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_2DIPSP);
|
||
break;
|
||
case 2:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_3DIPSP);
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
break;
|
||
case 2:
|
||
switch (pRecTdList->GetCollect(_T("Stype")).iVal)
|
||
{
|
||
case 0:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_CESP);
|
||
break;
|
||
case 1:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_2DSP);
|
||
break;
|
||
case 2:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_3DSP);
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
tdList.SetItemData(iIndex, dwTdHandle);
|
||
|
||
iIndex++;
|
||
pRecTdList->MoveNext();
|
||
}
|
||
|
||
pRecTdList->Close();
|
||
|
||
return true;
|
||
}
|
||
|
||
bool CTdManager::ShowTd2DListByTz(DWORD dwTzHandle, int iEAmount, float fEDistance, int iAR, CListCtrl& tdList)
|
||
{
|
||
_RecordsetPtr pRecTdList = NULL;
|
||
_RecordsetPtr pRecTdHead = NULL;
|
||
_RecordsetPtr pRecDev = NULL;
|
||
_RecordsetPtr pRecPara = NULL;
|
||
_RecordsetPtr pRecCm = NULL;
|
||
|
||
CString szSql;
|
||
CString szLabel;
|
||
DWORD dwTdHandle = (DWORD)VAL_ZERO;
|
||
DWORD dwTzID = (DWORD)VAL_ZERO;
|
||
|
||
dwTzID = m_handleProcessor.GetIDFromHandle(dwTzHandle);
|
||
|
||
int iIndex = (int)VAL_ZERO;
|
||
|
||
pRecTdList.CreateInstance(_uuidof(Recordset));
|
||
pRecTdHead.CreateInstance(_uuidof(Recordset));
|
||
pRecDev.CreateInstance(_uuidof(Recordset));
|
||
pRecPara.CreateInstance(_uuidof(Recordset));
|
||
pRecCm.CreateInstance(_uuidof(Recordset));
|
||
|
||
if ((int)VAL_ZERO != tdList.GetItemCount())
|
||
{
|
||
tdList.DeleteAllItems();
|
||
}
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID,TDname,Tlocation,DESN,SCCN,Sname,Stype,Ttype,Tmode,Eamount,TPamount,CHamount,N,TRwave,TRfrequency,Ifrequency,SAfrequency,Clayout,Espace,Edistance,weather,WDIR,"
|
||
"temperature,height,humidity,Format(Cdate,'YYYY-MM-DD') as Cdate,Format(Ctime,'HH:MM:SS') as Ctime,Format(Tdate,'YYYY-MM-DD') as Tdate,Format(Ttime,'HH:MM:SS') as Ttime, "
|
||
"Rdirection,CRtime,IIf(IsNull(PM),'',PM) as PM,IIf(IsNull(OP),'',OP) as OP,IIf(IsNull(QA),'',QA) as QA from td where TZID = %u and Stype = 1 and Eamount = %d and Edistance = %.1f "
|
||
"and ID in (select TDID from tdchannel where AR = %d)"), dwTzID, iEAmount, fEDistance, iAR);
|
||
|
||
try
|
||
{
|
||
pRecTdList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
}
|
||
catch (_com_error e)
|
||
{
|
||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||
AfxMessageBox((LPCTSTR)e.Description(), MB_ICONINFORMATION);
|
||
}
|
||
|
||
while ((short)VAL_ZERO == pRecTdList->adoEOF)
|
||
{
|
||
tdList.InsertItem(iIndex, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("TDname")));
|
||
tdList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Tlocation")));
|
||
tdList.SetItemText(iIndex, 2, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("DESN")));
|
||
tdList.SetItemText(iIndex, 3, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("SCCN")));
|
||
tdList.SetItemText(iIndex, 4, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Sname")));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Stype' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Stype")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Stype")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 5, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Ttype' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Ttype")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Ttype")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 6, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Tmode' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Tmode")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Tmode")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 7, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
tdList.SetItemText(iIndex, 8, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Eamount")));
|
||
tdList.SetItemText(iIndex, 9, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("TPamount")));
|
||
tdList.SetItemText(iIndex, 10, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("CHamount")));
|
||
|
||
tdList.SetItemText(iIndex, 11, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("N")));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'TRwave' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("TRwave")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("TRwave")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 12, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
if ((0 == pRecTdList->GetCollect(_T("Ttype")).iVal) || (1 == pRecTdList->GetCollect(_T("Ttype")).iVal))
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Trfrequency' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Trfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Trfrequency")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 13, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
}
|
||
else if (2 == pRecTdList->GetCollect(_T("Ttype")).iVal)
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Trfrequencyself' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Trfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Trfrequency")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 13, pRecCm->GetCollect(_T("Clabel")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
}
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Ifrequency' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Ifrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Ifrequency")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 14, pRecCm->GetCollect(_T("Clabel")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
if (0 == pRecTdList->GetCollect(_T("Ifrequency")).iVal)
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'SAfrequency50' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("SAfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("SAfrequency")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 15, pRecCm->GetCollect(_T("Clabel")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
}
|
||
else if (1 == pRecTdList->GetCollect(_T("Ifrequency")).iVal)
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'SAfrequency60' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("SAfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("SAfrequency")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 15, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
}
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Clayout' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Clayout")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Clayout")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 16, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
tdList.SetItemText(iIndex, 17, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Espace")));
|
||
tdList.SetItemText(iIndex, 18, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Edistance")));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'weather' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("weather")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("weather")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 19, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'WDIR' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("WDIR")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("WDIR")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 20, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
tdList.SetItemText(iIndex, 21, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("temperature")));
|
||
tdList.SetItemText(iIndex, 22, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("height")));
|
||
|
||
tdList.SetItemText(iIndex, 23, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("humidity")));
|
||
tdList.SetItemText(iIndex, 24, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Cdate")));
|
||
tdList.SetItemText(iIndex, 25, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Ctime")));
|
||
|
||
tdList.SetItemText(iIndex, 26, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Tdate")));
|
||
tdList.SetItemText(iIndex, 27, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Ttime")));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Rdirection' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Rdirection")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Rdirection")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 28, pRecCm->GetCollect(_T("Clabel")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
tdList.SetItemText(iIndex, 29, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("CRtime")));
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_2DRSP);
|
||
|
||
/*
|
||
switch (pRecTdList->GetCollect(_T("Ttype")).iVal)
|
||
{
|
||
case 0:
|
||
switch (pRecTdList->GetCollect(_T("Stype")).iVal)
|
||
{
|
||
case 0:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_CERSP);
|
||
break;
|
||
case 1:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_2DRSP);
|
||
break;
|
||
case 2:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_3DRSP);
|
||
break;
|
||
default:
|
||
break;
|
||
|
||
}
|
||
break;
|
||
case 1:
|
||
switch (pRecTdList->GetCollect(_T("Stype")).iVal)
|
||
{
|
||
case 0:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_CEIPSP);
|
||
break;
|
||
case 1:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_2DIPSP);
|
||
break;
|
||
case 2:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_3DIPSP);
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
*/
|
||
tdList.SetItemData(iIndex, dwTdHandle);
|
||
|
||
iIndex++;
|
||
pRecTdList->MoveNext();
|
||
}
|
||
|
||
pRecTdList->Close();
|
||
|
||
return true;
|
||
}
|
||
|
||
|
||
bool CTdManager::ShowTdListByDev(DWORD dwDevHandle, CListCtrl& tdList)
|
||
{
|
||
_RecordsetPtr pRecTdList = NULL;
|
||
_RecordsetPtr pRecTdHead = NULL;
|
||
_RecordsetPtr pRecDev = NULL;
|
||
_RecordsetPtr pRecPara = NULL;
|
||
_RecordsetPtr pRecCm = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szLabel = _T("");
|
||
DWORD dwTdHandle = (DWORD)VAL_ZERO;
|
||
DWORD dwDevID = (DWORD)VAL_ZERO;
|
||
|
||
dwDevID = m_handleProcessor.GetIDFromHandle(dwDevHandle);
|
||
|
||
int iIndex = (int)VAL_ZERO;
|
||
|
||
pRecTdList.CreateInstance(_uuidof(Recordset));
|
||
pRecTdHead.CreateInstance(_uuidof(Recordset));
|
||
pRecDev.CreateInstance(_uuidof(Recordset));
|
||
pRecPara.CreateInstance(_uuidof(Recordset));
|
||
pRecCm.CreateInstance(_uuidof(Recordset));
|
||
|
||
if ((int)VAL_ZERO != tdList.GetItemCount())
|
||
{
|
||
tdList.DeleteAllItems();
|
||
}
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID,TDname,Tlocation,DESN,SCCN,Sname,Stype,Ttype,Tmode,Eamount,TPamount,CHamount,N,TRwave,TRfrequency,Ifrequency,SAfrequency,Clayout,Espace,Edistance,weather,WDIR,"
|
||
"temperature,height,humidity,Format(Cdate,'YYYY-MM-DD') as Cdate,Format(Ctime,'HH:MM:SS') as Ctime,Format(Tdate,'YYYY-MM-DD') as Tdate,Format(Ttime,'HH:MM:SS') as Ttime,"
|
||
"Rdirection,CRtime,IIf(IsNull(PM),'',PM) as PM,IIf(IsNull(OP),'',OP) as OP,IIf(IsNull(QA),'',QA) as QA from td where DEID = %u"), dwDevID);
|
||
pRecTdList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
while ((short)VAL_ZERO == pRecTdList->adoEOF)
|
||
{
|
||
tdList.InsertItem(iIndex, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("TDname")));
|
||
// tdList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Tlocation")));
|
||
tdList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("DESN")));
|
||
tdList.SetItemText(iIndex, 2, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("SCCN")));
|
||
tdList.SetItemText(iIndex, 3, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Sname")));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Stype' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Stype")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Stype")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 4, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Ttype' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Ttype")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Ttype")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 5, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Tmode' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Tmode")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Tmode")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 6, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
tdList.SetItemText(iIndex, 7, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Eamount")));
|
||
tdList.SetItemText(iIndex, 8, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("TPamount")));
|
||
tdList.SetItemText(iIndex, 9, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("CHamount")));
|
||
|
||
tdList.SetItemText(iIndex, 10, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("N")));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'TRwave' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("TRwave")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("TRwave")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 11, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
if ((0 == pRecTdList->GetCollect(_T("Ttype")).iVal) || (1 == pRecTdList->GetCollect(_T("Ttype")).iVal))
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Trfrequency' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Trfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Trfrequency")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 12, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
}
|
||
else if (2 == pRecTdList->GetCollect(_T("Ttype")).iVal)
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Trfrequencyself' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Trfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Trfrequency")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 12, pRecCm->GetCollect(_T("Clabel")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
}
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Ifrequency' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Ifrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Ifrequency")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 13, pRecCm->GetCollect(_T("Clabel")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
if (0 == pRecTdList->GetCollect(_T("Ifrequency")).iVal)
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'SAfrequency50' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("SAfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("SAfrequency")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 14, pRecCm->GetCollect(_T("Clabel")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
}
|
||
else if (1 == pRecTdList->GetCollect(_T("Ifrequency")).iVal)
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'SAfrequency60' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("SAfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("SAfrequency")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 14, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
}
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Clayout' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Clayout")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Clayout")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 15, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
tdList.SetItemText(iIndex, 16, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Espace")));
|
||
tdList.SetItemText(iIndex, 17, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Edistance")));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'weather' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("weather")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("weather")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 18, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'WDIR' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("WDIR")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("WDIR")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 19, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
CString szDefault = _T("");
|
||
|
||
szDefault = (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("temperature"));
|
||
|
||
if (szDefault == "-9999")//若为该值则不显示东西
|
||
{
|
||
szDefault = "";
|
||
}
|
||
|
||
tdList.SetItemText(iIndex, 20, szDefault);
|
||
|
||
tdList.SetItemText(iIndex, 21, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("height")));
|
||
szDefault.Empty();
|
||
szDefault = (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("humidity"));
|
||
|
||
if (szDefault == "-9999")//若为该值则不显示东西
|
||
{
|
||
szDefault = "";
|
||
}
|
||
|
||
tdList.SetItemText(iIndex, 22, szDefault);
|
||
|
||
|
||
// tdList.SetItemText(iIndex, 21, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("temperature")));
|
||
// tdList.SetItemText(iIndex, 22, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("height")));
|
||
|
||
// tdList.SetItemText(iIndex, 23, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("humidity")));
|
||
tdList.SetItemText(iIndex, 23, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Cdate")));
|
||
tdList.SetItemText(iIndex, 24, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Ctime")));
|
||
|
||
tdList.SetItemText(iIndex, 25, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Tdate")));
|
||
tdList.SetItemText(iIndex, 26, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Ttime")));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Rdirection' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, pRecTdList->GetCollect(_T("Rdirection")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("Rdirection")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 27, pRecCm->GetCollect(_T("Clabel")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
tdList.SetItemText(iIndex, 28, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("CRtime")));
|
||
tdList.SetItemText(iIndex, 29, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("PM")));
|
||
tdList.SetItemText(iIndex, 30, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("OP")));
|
||
tdList.SetItemText(iIndex, 31, (LPCTSTR)(_bstr_t)pRecTdList->GetCollect(_T("QA")));
|
||
|
||
switch (pRecTdList->GetCollect(_T("Ttype")).iVal)
|
||
{
|
||
case 0:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_2DRSP);
|
||
break;
|
||
case 1:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_2DIPSP);
|
||
break;
|
||
case 2:
|
||
dwTdHandle = m_handleProcessor.GenerateHandle((DWORD)pRecTdList->GetCollect(_T("ID")).ulVal, PZ_STYLE_TD_2DSP);
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
tdList.SetItemData(iIndex, dwTdHandle);
|
||
|
||
iIndex++;
|
||
pRecTdList->MoveNext();
|
||
}
|
||
|
||
pRecTdList->Close();
|
||
|
||
return true;
|
||
}
|
||
void CTdManager::GetTaskAttr(DWORD dwHandle, DWORD& dwTdID, int& iStyle)
|
||
{
|
||
dwTdID = iStyle = 0;
|
||
iStyle = m_handleProcessor.GetStyleFromHandle(dwHandle);
|
||
dwTdID = m_handleProcessor.GetIDFromHandle(dwHandle);
|
||
|
||
}
|
||
CTestingData* CTdManager::GetTestingData(DWORD dwHandle)
|
||
{
|
||
CTestingData* pTd = NULL;
|
||
UINT uStyle = (UINT)VAL_ZERO;
|
||
DWORD dwID = (DWORD)VAL_ZERO;
|
||
uStyle = m_handleProcessor.GetStyleFromHandle(dwHandle);
|
||
pTd = m_tdLinkList.Get(dwHandle);
|
||
|
||
if (NULL == pTd)
|
||
{
|
||
dwID = m_handleProcessor.GetIDFromHandle(dwHandle);
|
||
|
||
switch (uStyle)
|
||
{
|
||
case PZ_STYLE_TD_3DRSP:
|
||
pTd = new CRsp3DTd(dwID, m_pConnection);
|
||
break;
|
||
case PZ_STYLE_TD_3DIPSP:
|
||
pTd = new CIpsp3DTd(dwID, m_pConnection);
|
||
break;
|
||
case PZ_STYLE_TD_2DRSP:
|
||
pTd = new CRsp2DTd(dwID, m_pConnection);
|
||
break;
|
||
case PZ_STYLE_TD_2DIPSP:
|
||
pTd = new CIpsp2DTd(dwID, m_pConnection);
|
||
break;
|
||
case PZ_STYLE_TD_CERSP:
|
||
pTd = new CRspCETd(dwID, m_pConnection);
|
||
break;
|
||
case PZ_STYLE_TD_CEIPSP:
|
||
pTd = new CIpspCETd(dwID, m_pConnection);
|
||
break;
|
||
case PZ_STYLE_TD_CESP:
|
||
pTd = new CSPCETd(dwID, m_pConnection);
|
||
break;
|
||
case PZ_STYLE_TD_2DSP:
|
||
pTd = new CSP2DTd(dwID, m_pConnection);
|
||
break;
|
||
case PZ_STYLE_TD_3DSP:
|
||
pTd = new CSP3DTd(dwID, m_pConnection);
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
m_tdLinkList.Add(dwHandle, pTd);
|
||
}
|
||
|
||
return pTd;
|
||
}
|
||
|
||
void CTdManager::DeleteRspCETd(DWORD dwID)
|
||
{
|
||
_RecordsetPtr pRecTd = NULL;
|
||
_CommandPtr pCmdDelRspTd = NULL;
|
||
_CommandPtr pCmdUpd = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szTdCN = _T("");
|
||
CString szDESN = _T("");
|
||
|
||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||
|
||
pCmdDelRspTd.CreateInstance(_uuidof(Command));
|
||
pCmdDelRspTd->ActiveConnection = m_pConnection;
|
||
|
||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||
pCmdUpd->ActiveConnection = m_pConnection;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select TdCN,DESN from td where ID = %u"), dwID);
|
||
pRecTd->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
if ((long)VAL_ZERO != pRecTd->GetRecordCount())
|
||
{
|
||
szTdCN.Empty();
|
||
szTdCN = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TdCN")).bstrVal;
|
||
|
||
szDESN.Empty();
|
||
szDESN = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("DESN")).bstrVal;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("update dev_syn_td set IsSyned = false where TdCN = '%s' and DESN = '%s'"), szTdCN, szDESN);
|
||
pCmdUpd->CommandText = szSql.AllocSysString();
|
||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||
}
|
||
|
||
pRecTd->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from td1dcon where TCHID in (select ID from tdchannel where TDID = %u)"), dwID);
|
||
|
||
pCmdDelRspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelRspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from tdchannel where TDID = %u"), dwID);
|
||
|
||
pCmdDelRspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelRspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from td where ID = %u"), dwID);
|
||
|
||
pCmdDelRspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelRspTd->Execute(NULL, NULL, adCmdText);
|
||
}
|
||
|
||
void CTdManager::DeleteIpspCETd(DWORD dwID)
|
||
{
|
||
_RecordsetPtr pRecTd = NULL;
|
||
_CommandPtr pCmdDelIpspTd = NULL;
|
||
_CommandPtr pCmdUpd = NULL;
|
||
_CommandPtr pCmdTW = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szTdCN = _T("");
|
||
CString szDESN = _T("");
|
||
|
||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||
|
||
pCmdDelIpspTd.CreateInstance(_uuidof(Command));
|
||
pCmdDelIpspTd->ActiveConnection = m_pConnection;
|
||
|
||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||
pCmdUpd->ActiveConnection = m_pConnection;
|
||
|
||
pCmdTW.CreateInstance(_uuidof(Command));
|
||
pCmdTW->ActiveConnection = m_pConnection;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from ac where TDID = %u"), dwID);
|
||
pCmdTW->CommandText = szSql.AllocSysString();
|
||
pCmdTW->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select TdCN,DESN from td where ID = %u"), dwID);
|
||
pRecTd->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
if ((long)VAL_ZERO != pRecTd->GetRecordCount())
|
||
{
|
||
szTdCN.Empty();
|
||
szTdCN = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TdCN")).bstrVal;
|
||
|
||
szDESN.Empty();
|
||
szDESN = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("DESN")).bstrVal;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("update dev_syn_td set IsSyned = false where TdCN = '%s' and DESN = '%s'"), szTdCN, szDESN);
|
||
pCmdUpd->CommandText = szSql.AllocSysString();
|
||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||
}
|
||
|
||
pRecTd->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from td1dcon where TCHID in (select ID from tdchannel where TDID = %u)"), dwID);
|
||
|
||
pCmdDelIpspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelIpspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from tdchannel where TDID = %u"), dwID);
|
||
|
||
pCmdDelIpspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelIpspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from td where ID = %u"), dwID);
|
||
|
||
pCmdDelIpspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelIpspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
|
||
}
|
||
|
||
void CTdManager::DeleteRsp2DTd(DWORD dwID)
|
||
{
|
||
_RecordsetPtr pRecTd = NULL;
|
||
_CommandPtr pCmdDelRspTd = NULL;
|
||
_CommandPtr pCmdUpd = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szTdCN = _T("");
|
||
CString szDESN = _T("");
|
||
|
||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||
|
||
pCmdDelRspTd.CreateInstance(_uuidof(Command));
|
||
pCmdDelRspTd->ActiveConnection = m_pConnection;
|
||
|
||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||
pCmdUpd->ActiveConnection = m_pConnection;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select TdCN,DESN from td where ID = %u"), dwID);
|
||
pRecTd->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
if ((long)VAL_ZERO != pRecTd->GetRecordCount())
|
||
{
|
||
szTdCN.Empty();
|
||
szTdCN = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TdCN")).bstrVal;
|
||
|
||
szDESN.Empty();
|
||
szDESN = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("DESN")).bstrVal;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("update dev_syn_td set IsSyned = false where TdCN = '%s' and DESN = '%s'"), szTdCN, szDESN);
|
||
pCmdUpd->CommandText = szSql.AllocSysString();
|
||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||
}
|
||
|
||
pRecTd->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from td2dcon where TCHID in (select ID from tdchannel where TDID = %u)"), dwID);
|
||
|
||
pCmdDelRspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelRspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from tdchannel where TDID = %u"), dwID);
|
||
|
||
pCmdDelRspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelRspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from gr where TDID = %u"), dwID);
|
||
|
||
pCmdDelRspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelRspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from td where ID = %u"), dwID);
|
||
|
||
pCmdDelRspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelRspTd->Execute(NULL, NULL, adCmdText);
|
||
}
|
||
|
||
void CTdManager::DeleteIpsp2DTd(DWORD dwID)
|
||
{
|
||
_RecordsetPtr pRecTd = NULL;
|
||
_CommandPtr pCmdDelIpspTd = NULL;
|
||
_CommandPtr pCmdUpd = NULL;
|
||
_CommandPtr pCmdTW = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szTdCN = _T("");
|
||
CString szDESN = _T("");
|
||
|
||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||
|
||
pCmdDelIpspTd.CreateInstance(_uuidof(Command));
|
||
pCmdDelIpspTd->ActiveConnection = m_pConnection;
|
||
|
||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||
pCmdUpd->ActiveConnection = m_pConnection;
|
||
|
||
pCmdTW.CreateInstance(_uuidof(Command));
|
||
pCmdTW->ActiveConnection = m_pConnection;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from ac where TDID = %u"), dwID);
|
||
pCmdTW->CommandText = szSql.AllocSysString();
|
||
pCmdTW->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select TdCN,DESN from td where ID = %u"), dwID);
|
||
pRecTd->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
if ((long)VAL_ZERO != pRecTd->GetRecordCount())
|
||
{
|
||
szTdCN.Empty();
|
||
szTdCN = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TdCN")).bstrVal;
|
||
|
||
szDESN.Empty();
|
||
szDESN = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("DESN")).bstrVal;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("update dev_syn_td set IsSyned = false where TdCN = '%s' and DESN = '%s'"), szTdCN, szDESN);
|
||
pCmdUpd->CommandText = szSql.AllocSysString();
|
||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||
}
|
||
|
||
pRecTd->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from td2dcon where TCHID in (select ID from tdchannel where TDID = %u)"), dwID);
|
||
|
||
pCmdDelIpspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelIpspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from tdchannel where TDID = %u"), dwID);
|
||
|
||
pCmdDelIpspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelIpspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from gr where TDID = %u"), dwID);
|
||
|
||
pCmdDelIpspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelIpspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from td where ID = %u"), dwID);
|
||
|
||
pCmdDelIpspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelIpspTd->Execute(NULL, NULL, adCmdText);
|
||
}
|
||
|
||
void CTdManager::DeleteObjInMem(DWORD dwHandle)
|
||
{
|
||
delete m_tdLinkList.Find(dwHandle);
|
||
m_tdLinkList.Delete(dwHandle);
|
||
}
|
||
BOOL CTdManager::OnlineSevTDListSynToDB(STRemTaskArg *ptTaskArg, CString szDeSN)
|
||
{
|
||
_CommandPtr pCmdUpd = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szLabel = _T("");
|
||
|
||
int iIndex = (int)VAL_ZERO;
|
||
BOOL bIsSyned = FALSE;
|
||
|
||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||
pCmdUpd->ActiveConnection = theApp.m_pConnection;
|
||
|
||
try
|
||
{
|
||
theApp.m_pConnection->BeginTrans();
|
||
|
||
szSql.Empty();
|
||
CString strDownloadTime;// = cDownloadTime.Format(_T("%Y-%m-%d %H:%M:%S"));
|
||
CTime cTime = CTime::GetCurrentTime();
|
||
time_t tmDownload = cTime.GetTime();
|
||
CString strTestDate = _T(" "), strTestTime = _T(" ");
|
||
time_t tTmp = ptTaskArg->uiStartTime;
|
||
CString strEdistance, strRectGrid, strElecStep;
|
||
//三维电极间距
|
||
if (2 == ptTaskArg->stMeasuArg.ucSptType)
|
||
strEdistance.Format(_T("%.2f,%.2f"), ptTaskArg->stMeasuArg.fXElecDistance, ptTaskArg->stMeasuArg.fYElecDistance);
|
||
else
|
||
strEdistance.Format(_T("%.2f"), ptTaskArg->stMeasuArg.fXElecDistance);
|
||
strElecStep.Format(_T("%.2f,%.2f"), ptTaskArg->stMeasuArg.fXElecStep, ptTaskArg->stMeasuArg.fYElecStep);
|
||
strRectGrid.Format(_T("%d,%d,%d,%d"), ptTaskArg->stMeasuArg.rcGridSize.left, ptTaskArg->stMeasuArg.rcGridSize.top, ptTaskArg->stMeasuArg.rcGridSize.right, ptTaskArg->stMeasuArg.rcGridSize.bottom);
|
||
|
||
if (tTmp > 0)
|
||
{
|
||
tm* tmStartTime;
|
||
tmStartTime = localtime(&tTmp);
|
||
strTestDate.Format(_T("%d-%d-%d"), tmStartTime->tm_year + 1900, tmStartTime->tm_mon + 1, tmStartTime->tm_mday);
|
||
strTestTime.Format(_T("%d:%d:%d"), tmStartTime->tm_hour, tmStartTime->tm_min, tmStartTime->tm_sec);
|
||
szSql.Format(_T("update td set TPamount = %d,TdName = '%s',Sname = '%s',Ttype = %d, TRfrequency = %d, Tmode = %d,Clayout = %d,N = %d,SAfrequency = %d, Stype = %d,Edistance ='%s',Espace='%s',rect='%s',LineDirection=%d,STime = %d,ETime = %d,TTimer = %u,OrgFlg = %d,DownloadTime=%u,TestGRFlag=%d,Tdate='%s',Ttime='%s',CreateTime=%d where DESN = '%s' and TDCN = '%s'"),
|
||
ptTaskArg->uiTotalNum, ptTaskArg->ucTDName, ptTaskArg->ucSciptName,
|
||
ptTaskArg->stMeasuArg.ucTestType, ptTaskArg->stMeasuArg.ucTxPeriod, ptTaskArg->stMeasuArg.ucArrayType,
|
||
ptTaskArg->stMeasuArg.ucCableLayout, ptTaskArg->stMeasuArg.ucStacking, ptTaskArg->stMeasuArg.iSAInterval, ptTaskArg->stMeasuArg.ucSptType,
|
||
strEdistance,strElecStep,strRectGrid,ptTaskArg->stMeasuArg.byLineDirection, ptTaskArg->uiStartTime, ptTaskArg->uiEndTime,
|
||
(long)ptTaskArg->uiTimerTime, ptTaskArg->ucOrgFlg, (long)tmDownload, ptTaskArg->ucTestGRFlag, strTestDate, strTestTime, ptTaskArg->uiCreateTime,
|
||
szDeSN, ptTaskArg->ucTaskID);
|
||
}
|
||
else
|
||
{
|
||
szSql.Format(_T("update td set TPamount = %d,TdName = '%s',Sname = '%s',Ttype = %d, TRfrequency = %d, Tmode = %d,Clayout = %d,N = %d,SAfrequency = %d, Stype = %d,Edistance = '%s',Espace='%s',rect='%s',LineDirection=%d, STime = %d,ETime = %d,TTimer = %u,OrgFlg = %d,DownloadTime=%u,TestGRFlag=%d,CreateTime=%d where DESN = '%s' and TDCN = '%s'"),
|
||
ptTaskArg->uiTotalNum, ptTaskArg->ucTDName, ptTaskArg->ucSciptName,
|
||
ptTaskArg->stMeasuArg.ucTestType, ptTaskArg->stMeasuArg.ucTxPeriod, ptTaskArg->stMeasuArg.ucArrayType,
|
||
ptTaskArg->stMeasuArg.ucCableLayout, ptTaskArg->stMeasuArg.ucStacking, ptTaskArg->stMeasuArg.iSAInterval, ptTaskArg->stMeasuArg.ucSptType,
|
||
strEdistance, strElecStep, strRectGrid, ptTaskArg->stMeasuArg.byLineDirection, ptTaskArg->uiStartTime, ptTaskArg->uiEndTime,
|
||
(long)ptTaskArg->uiTimerTime, ptTaskArg->ucOrgFlg, (long)tmDownload, ptTaskArg->ucTestGRFlag, ptTaskArg->uiCreateTime,
|
||
szDeSN, ptTaskArg->ucTaskID);
|
||
}
|
||
|
||
pCmdUpd->CommandText = szSql.AllocSysString();
|
||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||
strDownloadTime.Format(_T("[%s][%d]:recent task download time, update database sql %s\n"), MODULE_NAME, __LINE__, szSql);
|
||
CFileOperTools::GetInstance()->WriteComLog(strDownloadTime);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("update tdchannel set AR = %d where TDID in(select ID from td where TDCN = '%s')"), ptTaskArg->stMeasuArg.ucArrayType, ptTaskArg->ucTaskID);
|
||
pCmdUpd->CommandText = szSql.AllocSysString();
|
||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||
|
||
theApp.m_pConnection->CommitTrans();
|
||
}
|
||
catch (_com_error e)
|
||
{
|
||
AfxMessageBox(e.Description());
|
||
}
|
||
|
||
return TRUE;
|
||
}
|
||
BOOL CTdManager::InitialCableListByOnLineForSyn(CListCtrl &CableList, CString szDeSN, STRemCableCallInfo *ptLocalCableInfo)
|
||
{
|
||
_RecordsetPtr pRecTd = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szLabel = _T("");
|
||
|
||
int iIndex = (int)VAL_ZERO;
|
||
BOOL bIsSyned = FALSE;
|
||
|
||
CableList.DeleteAllItems();
|
||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select TolNum,N_ID,N_dir,N_Pow from CableInfo where SN = '%s'"), szDeSN);
|
||
pRecTd->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
while ((short)VAL_ZERO == pRecTd->adoEOF)
|
||
{
|
||
CableList.InsertItem(iIndex, szLabel);
|
||
if (0 == iIndex)
|
||
{
|
||
//CableList.SetItemText(iIndex, 0, (LPCTSTR)(_bstr_t)szDeSN);
|
||
//CableList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TolNum")));
|
||
ptLocalCableInfo->ucTotalCount = pRecTd->GetCollect(_T("TolNum")).uintVal;
|
||
}
|
||
CString szStr;
|
||
szStr.Empty(); szStr.Format("%c", pRecTd->GetCollect(_T("N_dir")).bVal);
|
||
CableList.SetItemText(iIndex, 0, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("N_ID")).bVal);
|
||
CableList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)szStr);
|
||
CableList.SetItemText(iIndex, 2, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("N_Pow")));
|
||
ptLocalCableInfo->stCableInfo[iIndex].ucID = pRecTd->GetCollect(_T("N_ID")).bVal;
|
||
ptLocalCableInfo->stCableInfo[iIndex].ucDir = pRecTd->GetCollect(_T("N_dir")).bVal;
|
||
ptLocalCableInfo->stCableInfo[iIndex].ucPowe = pRecTd->GetCollect(_T("N_Pow")).bVal;
|
||
pRecTd->MoveNext();
|
||
iIndex++;
|
||
}
|
||
pRecTd->Close();
|
||
|
||
return TRUE;
|
||
}
|
||
BOOL CTdManager::InitialDevListByOnLineForSyn(CListCtrl &DevList, CString szDeSN, STSynDevParam *ptLocalDevParam)
|
||
{
|
||
_RecordsetPtr pRecTd = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szLabel = _T("");
|
||
|
||
//DevList.DeleteAllItems();
|
||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select HWV ,SWV, BatVol, PowerFreq,CableType, GrTh, BatAlarm,Stack, ChanNum,DownNum from device where SN = '%s'"),szDeSN);
|
||
pRecTd->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
int iIndex = (int)VAL_ZERO;
|
||
CString str;
|
||
if (!pRecTd->adoEOF)
|
||
{
|
||
//DevList.InsertItem(iIndex, szLabel);
|
||
DevList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)szDeSN); iIndex++;
|
||
DevList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("HWV")).bstrVal); iIndex++;
|
||
DevList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("SWV")).bstrVal); iIndex++;
|
||
iIndex++;//温度暂不显示
|
||
str.Empty(); str.Format(_T("%d"),pRecTd->GetCollect(_T("BatVol")).uiVal);
|
||
DevList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)str); iIndex++;
|
||
DevList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("PowerFreq")).bVal); iIndex++;
|
||
DevList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("CableType")).bVal); iIndex++;
|
||
str.Empty(); str.Format(_T("%d"),pRecTd->GetCollect(_T("GrTh")).uintVal);
|
||
DevList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)str); iIndex++;
|
||
str.Empty(); str.Format(_T("%d"),pRecTd->GetCollect(_T("BatAlarm")).uiVal);
|
||
DevList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)str); iIndex++;
|
||
DevList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Stack")).bVal); iIndex++;
|
||
DevList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("ChanNum")).bVal); iIndex++;
|
||
DevList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("DownNum")).bVal); iIndex++;
|
||
//pRecTd->MoveNext();
|
||
CString szHwVer = pRecTd->GetCollect(_T("HWV")).bstrVal;
|
||
if (szHwVer.GetLength() >= 4)
|
||
{
|
||
ptLocalDevParam->ucHWVer[0] = szHwVer.GetAt(1);
|
||
ptLocalDevParam->ucHWVer[1] = szHwVer.GetAt(3);
|
||
}
|
||
CString szSwVer = pRecTd->GetCollect(_T("SWV")).bstrVal;
|
||
if (szSwVer.GetLength() >= 10)
|
||
{
|
||
ptLocalDevParam->ucSWVer[0] = szSwVer.GetAt(1);
|
||
ptLocalDevParam->ucSWVer[1] = szSwVer.GetAt(3);
|
||
ptLocalDevParam->ucSWVer[2] = szSwVer.GetAt(5);
|
||
ptLocalDevParam->ucSWVer[3] = atoi(szSwVer.Mid(8));
|
||
}
|
||
ptLocalDevParam->fBatteryVol = pRecTd->GetCollect(_T("BatVol")).uiVal;
|
||
ptLocalDevParam->ucPowerFreq = pRecTd->GetCollect(_T("PowerFreq")).bVal;
|
||
ptLocalDevParam->ucCableType = pRecTd->GetCollect(_T("CableType")).bVal;
|
||
ptLocalDevParam->iGrThreshold = pRecTd->GetCollect(_T("GrTh")).intVal;
|
||
ptLocalDevParam->ucBatteryAlarm = pRecTd->GetCollect(_T("BatAlarm")).bVal;
|
||
ptLocalDevParam->ucStacking = pRecTd->GetCollect(_T("Stack")).bVal;
|
||
ptLocalDevParam->ucChannelNum = pRecTd->GetCollect(_T("ChanNum")).bVal;
|
||
ptLocalDevParam->ucDownLoadNum = pRecTd->GetCollect(_T("DownNum")).bVal;
|
||
}
|
||
pRecTd->Close();
|
||
|
||
return TRUE;
|
||
}
|
||
BOOL CTdManager::InitialTDListByOnLineForSyn(CListCtrl &tdList, CString szDeSN,UINT32 &uiTotNum)
|
||
{
|
||
_RecordsetPtr pRecTd = NULL;
|
||
//_RecordsetPtr pRecCm = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szLabel = _T("");
|
||
|
||
int iIndex = (int)VAL_ZERO;
|
||
BOOL bIsSyned = FALSE;
|
||
|
||
tdList.DeleteAllItems();
|
||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||
//pRecCm.CreateInstance(_uuidof(Recordset));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select TdName,TdStatus,TDCN,TPamount,Sname, Ttype, TRfrequency, Tmode, Clayout, N, SAfrequency, Stype, Edistance, \
|
||
rect,rect_loc,STime,ETime,TTimer from td where DESN = '%s'"), szDeSN);
|
||
pRecTd->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
//
|
||
CString str;
|
||
while ((short)VAL_ZERO == pRecTd->adoEOF)
|
||
{
|
||
/*if (-1 == pRecTd->GetCollect(_T("IsSyned")).boolVal)
|
||
{
|
||
szLabel.Empty();
|
||
szLabel.LoadString(IDS_YES);
|
||
bIsSyned = TRUE;
|
||
}
|
||
else
|
||
{
|
||
szLabel.Empty();
|
||
szLabel.LoadString(IDS_NO);
|
||
bIsSyned = FALSE;
|
||
}*/
|
||
//tdList.SetItemData(iIndex, bIsSyned);
|
||
CString Rect = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("rect")).bstrVal;
|
||
CString RectLocal = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("rect_loc")).bstrVal;
|
||
CStringArray strArray;
|
||
strArray.RemoveAll();
|
||
SplitterString(strArray, Rect, ",");
|
||
int uiStartElec = 0;
|
||
int uiEndElec = 0;
|
||
//if (!strArray.IsEmpty()&&(2 <= strArray.GetSize()))
|
||
if (2 <= strArray.GetSize())
|
||
{
|
||
uiStartElec = atoi(strArray.GetAt(0));
|
||
uiEndElec = atoi(strArray.GetAt(1));
|
||
}
|
||
strArray.RemoveAll();
|
||
SplitterString(strArray, RectLocal, ",");
|
||
int uiStartLayer = 1;
|
||
int uiEndLayer = 1;
|
||
//if (!strArray.IsEmpty()&&(2 <= strArray.GetSize()))
|
||
if (2 <= strArray.GetSize())
|
||
{
|
||
uiStartLayer = atoi(strArray.GetAt(0));
|
||
uiEndLayer = atoi(strArray.GetAt(1));
|
||
}
|
||
BYTE bTdStatus = pRecTd->GetCollect(_T("TdStatus")).bVal;
|
||
CString szTdStatus = OnLineLocalTaskState(bTdStatus);
|
||
|
||
tdList.InsertItem(iIndex, szLabel);
|
||
tdList.SetItemText(iIndex, 0, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TdName")));
|
||
tdList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)szTdStatus);
|
||
tdList.SetItemText(iIndex, 2, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TDCN")));
|
||
tdList.SetItemText(iIndex, 3, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Sname")));
|
||
tdList.SetItemText(iIndex, 4, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Ttype")));
|
||
tdList.SetItemText(iIndex, 5, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TRfrequency")));
|
||
tdList.SetItemText(iIndex, 6, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Tmode")).bVal);
|
||
tdList.SetItemText(iIndex, 7, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Clayout")));
|
||
tdList.SetItemText(iIndex, 8, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("N")));
|
||
tdList.SetItemText(iIndex, 9, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("SAfrequency")));
|
||
tdList.SetItemText(iIndex, 10, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Stype")));
|
||
tdList.SetItemText(iIndex, 11, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Edistance")));
|
||
str.Empty(); str.Format(_T("%d"),uiStartElec);
|
||
tdList.SetItemText(iIndex, 12, (LPCTSTR)(_bstr_t)str);
|
||
str.Empty(); str.Format(_T("%d"),uiEndElec);
|
||
tdList.SetItemText(iIndex, 13, (LPCTSTR)(_bstr_t)str);
|
||
str.Empty(); str.Format(_T("%d"),uiStartLayer);
|
||
tdList.SetItemText(iIndex, 14, (LPCTSTR)(_bstr_t)str);
|
||
str.Empty(); str.Format(_T("%d"),uiEndLayer);
|
||
tdList.SetItemText(iIndex, 15, (LPCTSTR)(_bstr_t)str);
|
||
time_t tmTime; CString szTime;
|
||
tmTime = pRecTd->GetCollect(_T("STime")).uintVal; szTime = Tm2LocalStr(tmTime);//Tm2GmtStr(tmTime);
|
||
tdList.SetItemText(iIndex, 16, (LPCTSTR)((_bstr_t)szTime));
|
||
tmTime = pRecTd->GetCollect(_T("ETime")).uintVal; szTime = Tm2LocalStr(tmTime);//Tm2GmtStr(tmTime);
|
||
tdList.SetItemText(iIndex, 17, (LPCTSTR)((_bstr_t)szTime));
|
||
tmTime = pRecTd->GetCollect(_T("TTimer")).uintVal; szTime = Tm2LocalStr(tmTime);//Tm2GmtStr(tmTime);
|
||
tdList.SetItemText(iIndex, 18, (LPCTSTR)((_bstr_t)szTime));
|
||
tdList.SetItemText(iIndex, 19, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TPamount")));
|
||
pRecTd->MoveNext();
|
||
iIndex++;
|
||
}
|
||
pRecTd->Close();
|
||
uiTotNum = iIndex;
|
||
return TRUE;
|
||
}
|
||
BOOL CTdManager::InitialTDListByProForSyn(CListCtrl &tdList, CString szDeSN, CString szPrCN)
|
||
{
|
||
_RecordsetPtr pRecTd = NULL;
|
||
_RecordsetPtr pRecCm = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szLabel = _T("");
|
||
|
||
int iIndex = (int)VAL_ZERO;
|
||
BOOL bIsSyned = FALSE;
|
||
|
||
tdList.DeleteAllItems();
|
||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||
pRecCm.CreateInstance(_uuidof(Recordset));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select IsSyned,TdCN,SubTaskCN,TdName,Ttype,Stype,Format(Cdate,'YYYY-MM-DD') as Cdate,Format(Ctime,'HH:MM:SS') as Ctime,PrName,PrCN,TzName,TzCN from dev_syn_td where DESN = '%s' and PrCN = '%s' and TdCN is not NULL"), szDeSN, szPrCN);
|
||
pRecTd->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
//
|
||
CString strSubTask;
|
||
while ((short)VAL_ZERO == pRecTd->adoEOF)
|
||
{
|
||
if (-1 == pRecTd->GetCollect(_T("IsSyned")).boolVal)
|
||
{
|
||
szLabel.Empty();
|
||
szLabel.LoadString(IDS_YES);
|
||
bIsSyned = TRUE;
|
||
}
|
||
else
|
||
{
|
||
szLabel.Empty();
|
||
szLabel.LoadString(IDS_NO);
|
||
bIsSyned = FALSE;
|
||
}
|
||
|
||
tdList.InsertItem(iIndex, szLabel);
|
||
// tdList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TdCN")));
|
||
tdList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TdName")));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Ttype' and Lang = %d and Cvalue = %s"), g_iLanguage, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Ttype")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 2, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'stype' and Lang = %d and Cvalue = %s"), g_iLanguage, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Stype")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 3, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
tdList.SetItemText(iIndex, 4, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Cdate")));
|
||
tdList.SetItemText(iIndex, 5, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Ctime")));
|
||
|
||
tdList.SetItemText(iIndex, 6, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TdCN")));
|
||
|
||
// tdList.SetItemText(iIndex, 6, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("PrName")));
|
||
tdList.SetItemText(iIndex, 7, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("PrCN")));
|
||
// tdList.SetItemText(iIndex, 8, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TzName")));
|
||
tdList.SetItemText(iIndex, 8, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TzCN")));
|
||
|
||
strSubTask.Empty();
|
||
strSubTask = (VT_NULL == pRecTd->GetCollect(_T("SubTaskCN")).vt) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("SubTaskCN"));
|
||
if (!strSubTask.IsEmpty())
|
||
tdList.SetItemText(iIndex, 9, strSubTask);
|
||
tdList.SetItemData(iIndex, bIsSyned);
|
||
|
||
pRecTd->MoveNext();
|
||
iIndex++;
|
||
}
|
||
pRecTd->Close();
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL CTdManager::InitialTDListByTzForSyn(CListCtrl &tdList, CString szDeSN, CString szTzCN)
|
||
{
|
||
_RecordsetPtr pRecTd = NULL;
|
||
_RecordsetPtr pRecCm = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szLabel = _T("");
|
||
|
||
int iIndex = (int)VAL_ZERO;
|
||
BOOL bIsSyned = FALSE;
|
||
|
||
tdList.DeleteAllItems();
|
||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||
pRecCm.CreateInstance(_uuidof(Recordset));
|
||
|
||
if (NULL == pRecTd || NULL == pRecCm)
|
||
return FALSE;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select IsSyned,TdCN,SubTaskCN,TdName,Ttype,Stype,Format(Cdate,'YYYY-MM-DD') as Cdate,Format(Ctime,'HH:MM:SS') as Ctime,PrName,PrCN,TzName,TzCN from dev_syn_td where DESN = '%s' and TzCN = '%s' and TdCN is not NULL"), szDeSN, szTzCN);
|
||
pRecTd->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
CString strSubTask;
|
||
while ((short)VAL_ZERO == pRecTd->adoEOF)
|
||
{
|
||
if (-1 == pRecTd->GetCollect(_T("IsSyned")).boolVal)
|
||
{
|
||
szLabel.Empty();
|
||
szLabel.LoadString(IDS_YES);
|
||
bIsSyned = TRUE;
|
||
}
|
||
else
|
||
{
|
||
szLabel.Empty();
|
||
szLabel.LoadString(IDS_NO);
|
||
bIsSyned = FALSE;
|
||
}
|
||
|
||
tdList.InsertItem(iIndex, szLabel);
|
||
// tdList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TdCN")));
|
||
tdList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TdName")));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'Ttype' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Ttype")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 2, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Clabel from cm where Cname = 'stype' and Lang = %d and Cvalue = %s"),
|
||
g_iLanguage, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Stype")));
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdList.SetItemText(iIndex, 3, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
tdList.SetItemText(iIndex, 4, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Cdate")));
|
||
tdList.SetItemText(iIndex, 5, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Ctime")));
|
||
|
||
tdList.SetItemText(iIndex, 6, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TdCN")));
|
||
|
||
// tdList.SetItemText(iIndex, 6, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("PrName")));
|
||
tdList.SetItemText(iIndex, 7, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("PrCN")));
|
||
// tdList.SetItemText(iIndex, 8, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TzName")));
|
||
tdList.SetItemText(iIndex, 8, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TzCN")));
|
||
|
||
strSubTask.Empty();
|
||
strSubTask = (VT_NULL == pRecTd->GetCollect(_T("SubTaskCN")).vt) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("SubTaskCN"));
|
||
if (!strSubTask.IsEmpty())
|
||
tdList.SetItemText(iIndex, 9, strSubTask);
|
||
tdList.SetItemData(iIndex, bIsSyned);
|
||
pRecTd->MoveNext();
|
||
iIndex++;
|
||
}
|
||
pRecTd->Close();
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL CTdManager::UploadCETdFromDev(CString szPrCN, CString szTzCN, CString szTdCN, CString strSubTdCN, CDevice* const pDev)
|
||
{
|
||
DWORD dwTzID = (DWORD)VAL_ZERO;
|
||
DWORD dwTdID = (DWORD)VAL_ZERO;
|
||
|
||
_RecordsetPtr pRecTdID = NULL;
|
||
_RecordsetPtr pRecTzID = NULL;
|
||
_CommandPtr pCmdUpd = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szLocFilePath = _T("");
|
||
CString szFileName = _T("");
|
||
CString szHostPath = _T("");
|
||
CString strLog = _T("");
|
||
pRecTdID.CreateInstance(_uuidof(Recordset));
|
||
pRecTzID.CreateInstance(_uuidof(Recordset));
|
||
|
||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||
pCmdUpd->ActiveConnection = m_pConnection;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID from td where TdCN = '%s' and DESN = '%s'"), szTzCN, pDev->m_szDevSN);
|
||
pRecTdID->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecTdID->GetRecordCount())
|
||
{
|
||
pRecTdID->Close();
|
||
return FALSE;
|
||
}
|
||
pRecTdID->Close();
|
||
|
||
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 += "\\";
|
||
|
||
szFileName.Empty();
|
||
szFileName = szTdCN + _T(".xml");
|
||
|
||
szHostPath = _T("/SD/projects/") + szPrCN + _T("/") + szTzCN;
|
||
|
||
CTaskProgressDlg* pTaskProgessDlg = NULL;
|
||
pTaskProgessDlg = new CTaskProgressDlg(FALSE, 4, pDev);
|
||
pTaskProgessDlg->Create(IDD_TASK_PROGRESS);
|
||
pTaskProgessDlg->ShowWindow(SW_SHOW);
|
||
|
||
HWND hWnd = pTaskProgessDlg->m_hWnd;
|
||
|
||
string strRawPath = CDetcGD10Dev::GetInstance()->GetGD10DevAddr() + szHostPath;
|
||
strRawPath.append("/");
|
||
string strFindPath = strRawPath;
|
||
strFindPath.append(szTdCN + "*.*");
|
||
WIN32_FIND_DATAA winFindData;
|
||
HANDLE hTemp = FindFirstFileA(strFindPath.c_str(), &winFindData);
|
||
if (INVALID_HANDLE_VALUE != hTemp)
|
||
{
|
||
do
|
||
{
|
||
string strOldName = winFindData.cFileName;
|
||
if ("." == strOldName || ".." == strOldName)
|
||
continue;
|
||
if (winFindData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
|
||
{
|
||
continue;
|
||
}
|
||
strOldName = strRawPath;
|
||
strOldName.append(winFindData.cFileName);
|
||
CString dst = szLocFilePath + winFindData.cFileName;
|
||
CopyFileExA(strOldName.c_str(), dst, nullptr, this, nullptr, 0);
|
||
} while (FindNextFileA(hTemp, &winFindData));
|
||
FindClose(hTemp);
|
||
}
|
||
|
||
{
|
||
try
|
||
{
|
||
m_pConnection->BeginTrans();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID from tz where CN = '%s'"), szTzCN);
|
||
pRecTzID->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecTzID->GetRecordCount())
|
||
{
|
||
dwTzID = pRecTzID->GetCollect(_T("ID")).ulVal;
|
||
}
|
||
pRecTzID->Close();
|
||
::SendMessage(hWnd, WM_UPDATE_TIPS, 0, (LPARAM)(LPCTSTR)(szFileName));
|
||
dwTdID = this->ImportTdHeadToDB(dwTzID, szLocFilePath+szFileName, pDev);
|
||
|
||
if (0 == dwTdID)
|
||
{
|
||
m_pConnection->RollbackTrans();
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
return FALSE;
|
||
}
|
||
|
||
szFileName.Empty();
|
||
szFileName = szTdCN + _T(".dat");
|
||
::SendMessage(hWnd, WM_UPDATE_TIPS, 0, (LPARAM)(LPCTSTR)(szFileName));
|
||
if (TRUE == this->ImportCETdConToDB(dwTdID, szLocFilePath + szFileName, pDev))
|
||
{
|
||
szFileName.Empty();
|
||
szFileName = szTdCN + _T(".org");
|
||
{
|
||
if (TRUE == this->ImportCETdOrgToDB(dwTdID, szLocFilePath + szFileName, pDev))
|
||
{
|
||
}
|
||
else
|
||
{
|
||
if (pTaskProgessDlg)
|
||
{
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
}
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (pTaskProgessDlg)
|
||
{
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
}
|
||
DeleteFile(szLocFilePath + szFileName);
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
////
|
||
|
||
szFileName.Empty();
|
||
szFileName = szTdCN + _T(".res");
|
||
::SendMessage(hWnd, WM_UPDATE_TIPS, 0, (LPARAM)(LPCTSTR)(szFileName));
|
||
//添加GR
|
||
if (TRUE == this->ImportCETGRToDB(dwTdID, szLocFilePath + szFileName))
|
||
{
|
||
DeleteFile(szLocFilePath + szFileName);
|
||
}
|
||
else
|
||
{
|
||
DeleteFile(szLocFilePath + szFileName);
|
||
m_pConnection->RollbackTrans();
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
return FALSE;
|
||
}
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("update dev_syn_td set IsSyned = true where DESN = '%s' and TdCN = '%s'"),
|
||
pDev->m_szDevSN, szTdCN);
|
||
pCmdUpd->CommandText = szSql.AllocSysString();
|
||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||
m_pConnection->CommitTrans();
|
||
}
|
||
catch (_com_error e)
|
||
{
|
||
if (pTaskProgessDlg)
|
||
{
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
}
|
||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||
AfxMessageBox((LPCTSTR)e.Description());
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
}
|
||
|
||
if (pTaskProgessDlg)
|
||
{
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
}
|
||
return TRUE;
|
||
}
|
||
#ifdef TBR
|
||
BOOL CTdManager::Upload2DTdFromDev(CString szPrCN, CString szTzCN, CString szTdCN, CString strSubTdCN, CDevice* const pDev)
|
||
{
|
||
DWORD dwTzID = (DWORD)VAL_ZERO;
|
||
DWORD dwTdID = (DWORD)VAL_ZERO;
|
||
DWORD dwExTdID = (DWORD)VAL_ZERO;
|
||
|
||
_RecordsetPtr pRecTdID = NULL;
|
||
_RecordsetPtr pRecTzID = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szLocFilePath = _T("");
|
||
CString szFileName = _T("");
|
||
CString strSaveFileName = _T("");
|
||
CString szHostFile = _T("");
|
||
CString strGDFile = _T("");
|
||
|
||
_CommandPtr pCmdUpd = NULL;
|
||
|
||
|
||
|
||
pRecTdID.CreateInstance(_uuidof(Recordset));
|
||
pRecTzID.CreateInstance(_uuidof(Recordset));
|
||
|
||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||
pCmdUpd->ActiveConnection = m_pConnection;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID from td where TdCN = '%s' and DESN = '%s'"), szTdCN, pDev->m_szDevSN);
|
||
pRecTdID->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecTdID->GetRecordCount())
|
||
{
|
||
pRecTdID->Close();
|
||
return FALSE;
|
||
}
|
||
pRecTdID->Close();
|
||
|
||
szLocFilePath.Empty();
|
||
szLocFilePath.GetBufferSetLength(256);
|
||
::GetCurrentDirectory(szLocFilePath.GetLength(), szLocFilePath.GetBuffer(szLocFilePath.GetLength()));
|
||
szLocFilePath.ReleaseBuffer();
|
||
|
||
szLocFilePath = szLocFilePath + _T("\\CACHE\\");
|
||
|
||
//log
|
||
m_log += "\r\nReceiveFile2d.xml-------begin\r\n";
|
||
fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
fflush(m_pFile);
|
||
//log
|
||
//计算出总任务的个数,用于界面显示进度
|
||
CString strTemp;
|
||
int iTaskCount = 0;
|
||
int iDefaultTotalFileNum = 4;
|
||
CString strSaveSubTdCN = strSubTdCN;
|
||
if (!strSubTdCN.IsEmpty())
|
||
{
|
||
int iPos = -1;
|
||
strTemp = strSubTdCN;
|
||
do
|
||
{
|
||
iTaskCount++;
|
||
iPos = strTemp.Find(',');
|
||
if (iPos > 0)
|
||
strTemp = strTemp.Mid(iPos + 1);
|
||
} while (iPos > 0);
|
||
iDefaultTotalFileNum = (iTaskCount + 1) * 4;
|
||
}
|
||
CTaskProgressDlg* pTaskProgessDlg = NULL;
|
||
pTaskProgessDlg = new CTaskProgressDlg(FALSE, iDefaultTotalFileNum, pDev);
|
||
pTaskProgessDlg->Create(IDD_TASK_PROGRESS);
|
||
pTaskProgessDlg->ShowWindow(SW_SHOWNORMAL);
|
||
Sleep(1000);
|
||
|
||
CString strTDCNTemp = _T("");
|
||
//if (pTaskProgessDlg->StartTransferFile(szLocFilePath, szHostFile))
|
||
//if (TRUE == pDev->ReceiveFile(szLocFilePath, szHostFile))
|
||
if (1)
|
||
{
|
||
//log
|
||
m_log += "nReceiveFile.xml.true-------end\r\n";
|
||
fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
fflush(m_pFile);
|
||
//log
|
||
try
|
||
{
|
||
m_pConnection->BeginTrans();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID from tz where CN = '%s'"), szTzCN);
|
||
pRecTzID->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecTzID->GetRecordCount())
|
||
{
|
||
dwTzID = pRecTzID->GetCollect(_T("ID")).ulVal;
|
||
}
|
||
pRecTzID->Close();
|
||
|
||
strTDCNTemp = szTdCN;
|
||
int pTSN = (int)VAL_ONE;
|
||
int iTSN = (int)VAL_ONE;
|
||
//BOOL bUpdateTDTPamount = TRUE;
|
||
do
|
||
{
|
||
szFileName.Empty();
|
||
szFileName = strTDCNTemp + _T(".xml");
|
||
szHostFile = _T("/SD/projects/") + szPrCN + _T("/") + szTzCN + _T("/") + szFileName;
|
||
|
||
strGDFile.Empty();
|
||
strGDFile.Format(_T("%s%s"), CDetcGD10Dev::GetInstance()->GetGD10DevAddr(), szHostFile);
|
||
dwTdID = this->ImportTdHeadToDB(dwTzID, strGDFile, pDev, &dwExTdID);
|
||
//DeleteFile(szLocFilePath+szFileName);
|
||
//如果有辅助脚本,则需要额外增加传送2个文件,分别是辅助脚本的.dat,.org
|
||
if (0 != dwExTdID)
|
||
{
|
||
pTaskProgessDlg->AddExtFileNumber(2);
|
||
}
|
||
|
||
szFileName.Empty();
|
||
strSaveFileName = strTDCNTemp;
|
||
szFileName = strTDCNTemp + _T(".dat");
|
||
szHostFile = _T("/SD/projects/") + szPrCN + _T("/") + szTzCN + _T("/") + szFileName;
|
||
|
||
//log
|
||
m_log += "\r\nReceiveFile2d.dat-------begin\r\n";
|
||
fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
fflush(m_pFile);
|
||
|
||
if (pTaskProgessDlg->StartTransferFile(szLocFilePath, szHostFile))
|
||
// if (TRUE == pDev->ReceiveFile(szLocFilePath, szHostFile))
|
||
{
|
||
|
||
//log
|
||
m_log += "nReceiveFile.dat.true-------end\r\n";
|
||
fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
fflush(m_pFile);
|
||
//log
|
||
strGDFile.Empty();
|
||
strGDFile.Format(_T("%s%s"), CDetcGD10Dev::GetInstance()->GetGD10DevAddr(), szHostFile);
|
||
if (TRUE == this->Import2DTdConToDB(dwTdID, strGDFile, pDev, &pTSN))
|
||
{
|
||
DeleteFile(szLocFilePath + szFileName);
|
||
|
||
//去掉解析org数据部分
|
||
szFileName.Empty();
|
||
szFileName = strTDCNTemp + _T(".org");
|
||
szHostFile = _T("/SD/projects/") + szPrCN + _T("/") + szTzCN + _T("/") + szFileName;
|
||
|
||
//log
|
||
m_log += "\r\nnReceiveFile2d.org-------end\r\n";
|
||
fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
fflush(m_pFile);
|
||
//log
|
||
if (pTaskProgessDlg->StartTransferFile(szLocFilePath, szHostFile))
|
||
// if (TRUE == pDev->ReceiveFile(szLocFilePath, szHostFile))
|
||
{
|
||
//log
|
||
m_log += "nReceiveFile.org.true-------end\r\n";
|
||
fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
fflush(m_pFile);
|
||
//log
|
||
strGDFile.Empty();
|
||
strGDFile.Format(_T("%s%s"), CDetcGD10Dev::GetInstance()->GetGD10DevAddr(), szHostFile);
|
||
if (TRUE == this->Import2DTdOrgToDB(dwTdID, strGDFile, pDev))
|
||
{
|
||
DeleteFile(szLocFilePath + szFileName);
|
||
}
|
||
else
|
||
{
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
pTaskProgessDlg->ExitTransfile();
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
m_pConnection->RollbackTrans();
|
||
|
||
//log
|
||
m_log += "nReceiveFile.org.false-------end\r\n";
|
||
fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
fflush(m_pFile);
|
||
return FALSE;
|
||
//log
|
||
}
|
||
|
||
}
|
||
else
|
||
{
|
||
if (pTaskProgessDlg)
|
||
{
|
||
pTaskProgessDlg->ExitTransfile();
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
}
|
||
DeleteFile(szLocFilePath + szFileName);
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
pTaskProgessDlg->ExitTransfile();
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
//log
|
||
m_log += "nReceiveFile.dat.false-------end\r\n";
|
||
fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
fflush(m_pFile);
|
||
//log
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
|
||
//遍历子任务节点
|
||
strTDCNTemp.Empty();
|
||
if (!strSubTdCN.IsEmpty())
|
||
{
|
||
int iPos = strSubTdCN.Find(',');
|
||
if (iPos > 0)
|
||
{
|
||
strTDCNTemp = strSubTdCN.Mid(0, iPos);
|
||
strSubTdCN = strSubTdCN.Mid(iPos + 1);
|
||
}
|
||
else
|
||
{
|
||
strTDCNTemp = strSubTdCN;
|
||
strSubTdCN.Empty();
|
||
}
|
||
}
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("update td set TPamount=%d where ID =%d"), pTSN - 1, dwTdID);
|
||
pCmdUpd->CommandText = szSql.AllocSysString();
|
||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||
} while (!strTDCNTemp.IsEmpty());
|
||
|
||
//上传辅助脚本的任务的相关信息
|
||
if (0 != dwExTdID)
|
||
{
|
||
CString strExFileName = strSaveFileName + _T("_1.dat");
|
||
szHostFile = _T("/SD/projects/") + szPrCN + _T("/") + szTzCN + _T("/") + strExFileName;
|
||
if (pTaskProgessDlg->StartTransferFile(szLocFilePath, szHostFile))
|
||
{
|
||
strGDFile.Empty();
|
||
strGDFile.Format(_T("%s%s"), CDetcGD10Dev::GetInstance()->GetGD10DevAddr(), szHostFile);
|
||
if (TRUE == this->Import2DTdConToDB(dwExTdID, strGDFile/*szLocFilePath+strExFileName*/, pDev, &iTSN))
|
||
{
|
||
DeleteFile(szLocFilePath + strExFileName);
|
||
strExFileName.Empty();
|
||
strExFileName = strSaveFileName + _T("_1.org");
|
||
szHostFile = _T("/SD/projects/") + szPrCN + _T("/") + szTzCN + _T("/") + strExFileName;
|
||
if (pTaskProgessDlg->StartTransferFile(szLocFilePath, szHostFile))
|
||
{
|
||
strGDFile.Empty();
|
||
strGDFile.Format(_T("%s%s"), CDetcGD10Dev::GetInstance()->GetGD10DevAddr(), szHostFile);
|
||
if (TRUE == this->Import2DTdOrgToDB(dwExTdID, strGDFile/*szLocFilePath+strExFileName*/, pDev))
|
||
{
|
||
DeleteFile(szLocFilePath + strExFileName);
|
||
}
|
||
else
|
||
{
|
||
DeleteFile(szLocFilePath + strExFileName);
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
pTaskProgessDlg->ExitTransfile();
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (pTaskProgessDlg)
|
||
{
|
||
pTaskProgessDlg->ExitTransfile();
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
}
|
||
DeleteFile(szLocFilePath + strExFileName);
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
pTaskProgessDlg->ExitTransfile();
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
}
|
||
|
||
// if (strSaveSubTdCN.IsEmpty())
|
||
// {
|
||
szFileName.Empty();
|
||
szFileName = szTdCN + _T(".res");
|
||
szHostFile = _T("/SD/projects/") + szPrCN + _T("/") + szTzCN + _T("/") + szFileName;
|
||
|
||
//log
|
||
m_log += "\r\nnReceiveFile2d.res-------end\r\n";
|
||
fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
fflush(m_pFile);
|
||
// }
|
||
// else
|
||
// {
|
||
// int iPos = -1;
|
||
// iPos = strSaveSubTdCN.ReverseFind(',');
|
||
// if (iPos != -1)
|
||
// {
|
||
// strSaveSubTdCN = strSaveSubTdCN.Mid(iPos + 1);
|
||
// }
|
||
// szFileName.Empty();
|
||
// szFileName = strSaveSubTdCN + _T(".res");
|
||
// szHostFile = _T("/SD/projects/") + szPrCN + _T("/") + szTzCN + _T("/") + szFileName;
|
||
//
|
||
// //log
|
||
// m_log += "\r\nnReceiveFile2d.res-------end\r\n";
|
||
// fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
// fflush(m_pFile);
|
||
// }
|
||
//log
|
||
|
||
if (pTaskProgessDlg->StartTransferFile(szLocFilePath, szHostFile))
|
||
{
|
||
//log
|
||
m_log += "nReceiveFile.res.true-------end\r\n";
|
||
fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
fflush(m_pFile);
|
||
//log
|
||
|
||
if (TRUE == this->Import2DGRToDB(dwTdID, szLocFilePath + szFileName, pDev))
|
||
{
|
||
if (dwExTdID != 0)
|
||
{
|
||
if (TRUE == this->Import2DGRToDB(dwExTdID, szLocFilePath + szFileName, pDev))
|
||
{
|
||
DeleteFile(szLocFilePath + szFileName);
|
||
}
|
||
else
|
||
{
|
||
DeleteFile(szLocFilePath + szFileName);
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
}
|
||
DeleteFile(szLocFilePath + szFileName);
|
||
}
|
||
else
|
||
{
|
||
DeleteFile(szLocFilePath + szFileName);
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (pTaskProgessDlg)
|
||
{
|
||
pTaskProgessDlg->ExitTransfile();
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
}
|
||
//log
|
||
m_log += "nReceiveFile.res.false-------end\r\n";
|
||
fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
fflush(m_pFile);
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
//log
|
||
}
|
||
// else
|
||
// {
|
||
// m_pConnection->RollbackTrans();
|
||
// return FALSE;
|
||
// }
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("update dev_syn_td set IsSyned = true where DESN = '%s' and TdCN = '%s'"), pDev->m_szDevSN, szTdCN);
|
||
pCmdUpd->CommandText = szSql.AllocSysString();
|
||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||
// if (0 != dwExTdID)
|
||
// {
|
||
// szSql.Empty();
|
||
// szSql.Format(_T("update dev_syn_td set IsSyned = true where DESN = '%s' and TdCN = '%s'"), pDev->m_szDevSN, szTdCN+"_1");
|
||
// pCmdUpd->CommandText = szSql.AllocSysString();
|
||
// pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||
// }
|
||
|
||
|
||
|
||
m_pConnection->CommitTrans();
|
||
}
|
||
catch (_com_error e)
|
||
{
|
||
if (pTaskProgessDlg)
|
||
{
|
||
pTaskProgessDlg->ExitTransfile();
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
}
|
||
hHook = SetWindowsHookEx(WH_CBT, (HOOKPROC)CBTHookProc, AfxGetInstanceHandle(), NULL);
|
||
AfxMessageBox(e.Description());
|
||
m_pConnection->RollbackTrans();
|
||
|
||
//log
|
||
CTime t;
|
||
t = CTime::GetCurrentTime();
|
||
m_log = t.Format("%Y-%m-%d,%H:%M:%S:");
|
||
m_log += "ERROR IN CATCH_0x02 " + szLocFilePath + szFileName + (LPCTSTR)e.Description() + "\r\n";
|
||
fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
fflush(m_pFile);
|
||
//log
|
||
|
||
return FALSE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
|
||
pTaskProgessDlg->ExitTransfile();
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
|
||
//log
|
||
m_log += "nReceiveFile.xml.false-------end\r\n";
|
||
fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
fflush(m_pFile);
|
||
return FALSE;
|
||
//log
|
||
}
|
||
if (pTaskProgessDlg)
|
||
{
|
||
pTaskProgessDlg->ExitTransfile();
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
}
|
||
return TRUE;
|
||
}
|
||
#else
|
||
BOOL CTdManager::Upload2DTdFromDev(CString szPrCN, CString szTzCN, CString szTdCN, CString strSubTdCN, CDevice* const pDev)
|
||
{
|
||
DWORD dwTzID = (DWORD)VAL_ZERO;
|
||
DWORD dwTdID = (DWORD)VAL_ZERO;
|
||
DWORD dwExTdID = (DWORD)VAL_ZERO;
|
||
|
||
_RecordsetPtr pRecTdID = NULL;
|
||
_RecordsetPtr pRecTzID = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szLocFilePath = _T("");
|
||
CString szFileName = _T("");
|
||
CString strSaveFileName = _T("");
|
||
CString szHostPath = _T("");
|
||
CString strGDFile = _T("");
|
||
|
||
_CommandPtr pCmdUpd = NULL;
|
||
|
||
|
||
|
||
pRecTdID.CreateInstance(_uuidof(Recordset));
|
||
pRecTzID.CreateInstance(_uuidof(Recordset));
|
||
|
||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||
pCmdUpd->ActiveConnection = m_pConnection;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID from td where TdCN = '%s' and DESN = '%s'"), szTdCN, pDev->m_szDevSN);
|
||
pRecTdID->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecTdID->GetRecordCount())
|
||
{
|
||
pRecTdID->Close();
|
||
return FALSE;
|
||
}
|
||
pRecTdID->Close();
|
||
|
||
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 += "\\";
|
||
|
||
szFileName.Empty();
|
||
szFileName = szTdCN + _T(".xml");
|
||
szHostPath = _T("/SD/projects/") + szPrCN + _T("/") + szTzCN;
|
||
|
||
//计算出总任务的个数,用于界面显示进度
|
||
CString strTemp;
|
||
int iTaskCount = 0;
|
||
int iDefaultTotalFileNum = 4;
|
||
CString strSaveSubTdCN = strSubTdCN;
|
||
if (!strSubTdCN.IsEmpty())
|
||
{
|
||
int iPos = -1;
|
||
strTemp = strSubTdCN;
|
||
do
|
||
{
|
||
iTaskCount++;
|
||
iPos = strTemp.Find(',');
|
||
if (iPos > 0)
|
||
strTemp = strTemp.Mid(iPos + 1);
|
||
} while (iPos > 0);
|
||
iDefaultTotalFileNum = (iTaskCount + 1) * 4;
|
||
}
|
||
CTaskProgressDlg *pTaskProgessDlg = NULL;
|
||
pTaskProgessDlg = new CTaskProgressDlg(FALSE, iDefaultTotalFileNum, pDev);
|
||
pTaskProgessDlg->Create(IDD_TASK_PROGRESS);
|
||
pTaskProgessDlg->ShowWindow(SW_SHOWNORMAL);
|
||
Sleep(500);
|
||
|
||
HWND hWnd = pTaskProgessDlg->m_hWnd;
|
||
|
||
string strRawPath = CDetcGD10Dev::GetInstance()->GetGD10DevAddr() + szHostPath;
|
||
strRawPath.append("/");
|
||
string strFindPath = strRawPath;
|
||
strFindPath.append(szTdCN+"*.*");
|
||
WIN32_FIND_DATAA winFindData;
|
||
HANDLE hTemp = FindFirstFileA(strFindPath.c_str(), &winFindData);
|
||
if (INVALID_HANDLE_VALUE != hTemp)
|
||
{
|
||
do
|
||
{
|
||
string strOldName = winFindData.cFileName;
|
||
if ("." == strOldName || ".." == strOldName)
|
||
continue;
|
||
if (winFindData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
|
||
{
|
||
continue;
|
||
}
|
||
strOldName = strRawPath;
|
||
strOldName.append(winFindData.cFileName);
|
||
CString dst = szLocFilePath + winFindData.cFileName;
|
||
CopyFileExA(strOldName.c_str(), dst, nullptr, this, nullptr, 0);
|
||
}while (FindNextFileA(hTemp, &winFindData));
|
||
FindClose(hTemp);
|
||
}
|
||
|
||
CString strTDCNTemp = _T("");
|
||
try
|
||
{
|
||
m_pConnection->BeginTrans();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID from tz where CN = '%s'"), szTzCN);
|
||
pRecTzID->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecTzID->GetRecordCount())
|
||
{
|
||
dwTzID = pRecTzID->GetCollect(_T("ID")).ulVal;
|
||
}
|
||
pRecTzID->Close();
|
||
|
||
::SendMessage(hWnd, WM_UPDATE_TIPS, 0, (LPARAM)(LPCTSTR)(szFileName));
|
||
|
||
dwTdID = this->ImportTdHeadToDB(dwTzID, szLocFilePath + szFileName, pDev, &dwExTdID);
|
||
//如果有辅助脚本,则需要额外增加传送2个文件,分别是辅助脚本的.dat,.org
|
||
if (0 != dwExTdID)
|
||
{
|
||
}
|
||
|
||
strTDCNTemp = szTdCN;
|
||
int pTSN = (int)VAL_ONE;
|
||
int iTSN = (int)VAL_ONE;
|
||
do
|
||
{
|
||
szFileName.Empty();
|
||
strSaveFileName = strTDCNTemp;
|
||
szFileName = strTDCNTemp + _T(".dat");
|
||
|
||
::SendMessage(hWnd, WM_UPDATE_TIPS, 0, (LPARAM)(LPCTSTR)(szFileName));
|
||
|
||
if (TRUE == this->Import2DTdConToDB(dwTdID, szLocFilePath + szFileName, pDev, &pTSN))
|
||
{
|
||
szFileName.Empty();
|
||
szFileName = strTDCNTemp + _T(".org");
|
||
|
||
::SendMessage(hWnd, WM_UPDATE_TIPS, 0, (LPARAM)(LPCTSTR)(szFileName));
|
||
|
||
if (TRUE != this->Import2DTdOrgToDB(dwTdID, szLocFilePath + szFileName, pDev))
|
||
{
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (pTaskProgessDlg)
|
||
{
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
}
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
|
||
//遍历子任务节点
|
||
strTDCNTemp.Empty();
|
||
if (!strSubTdCN.IsEmpty())
|
||
{
|
||
int iPos = strSubTdCN.Find(',');
|
||
if (iPos > 0)
|
||
{
|
||
strTDCNTemp = strSubTdCN.Mid(0, iPos);
|
||
strSubTdCN = strSubTdCN.Mid(iPos + 1);
|
||
}
|
||
else
|
||
{
|
||
strTDCNTemp = strSubTdCN;
|
||
strSubTdCN.Empty();
|
||
}
|
||
}
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("update td set TPamount=%d where ID =%d"), pTSN - 1, dwTdID);
|
||
pCmdUpd->CommandText = szSql.AllocSysString();
|
||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||
} while (!strTDCNTemp.IsEmpty());
|
||
|
||
//上传辅助脚本的任务的相关信息
|
||
if (0 != dwExTdID)
|
||
{
|
||
CString strExFileName = strSaveFileName + _T("_1.dat");
|
||
if (TRUE == this->Import2DTdConToDB(dwExTdID, szLocFilePath + strExFileName, pDev, &iTSN))
|
||
{
|
||
strExFileName.Empty();
|
||
strExFileName = strSaveFileName + _T("_1.org");
|
||
{
|
||
if (TRUE != this->Import2DTdOrgToDB(dwExTdID, szLocFilePath + strExFileName, pDev))
|
||
{
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (pTaskProgessDlg)
|
||
{
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
}
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
|
||
}
|
||
|
||
szFileName.Empty();
|
||
szFileName = szTdCN + _T(".res");
|
||
|
||
::SendMessage(hWnd, WM_UPDATE_TIPS, 0, (LPARAM)(LPCTSTR)(szFileName));
|
||
|
||
if (TRUE == this->Import2DGRToDB(dwTdID, szLocFilePath + szFileName, pDev))
|
||
{
|
||
if (dwExTdID != 0)
|
||
{
|
||
if (TRUE != this->Import2DGRToDB(dwExTdID, szLocFilePath + szFileName, pDev))
|
||
{
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("update dev_syn_td set IsSyned = true where DESN = '%s' and TdCN = '%s'"), pDev->m_szDevSN, szTdCN);
|
||
pCmdUpd->CommandText = szSql.AllocSysString();
|
||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||
|
||
m_pConnection->CommitTrans();
|
||
}
|
||
catch (_com_error e)
|
||
{
|
||
if (pTaskProgessDlg)
|
||
{
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
}
|
||
hHook = SetWindowsHookEx(WH_CBT, (HOOKPROC)CBTHookProc, AfxGetInstanceHandle(), NULL);
|
||
AfxMessageBox(e.Description());
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
|
||
if (pTaskProgessDlg)
|
||
{
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
}
|
||
return TRUE;
|
||
}
|
||
#endif
|
||
DWORD CTdManager::OnLineImportTdHeadToDB(STRemTaskArg *ptTaskArg, CString szDevSN)
|
||
{
|
||
//跳过抽头和滚动目前暂不实现
|
||
int iSkipCable = 0;
|
||
int iRollCnt = 0;
|
||
_CommandPtr pCmdIns = NULL;
|
||
_RecordsetPtr pRecTd = NULL;
|
||
_RecordsetPtr pRecScon = NULL;
|
||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||
pRecScon.CreateInstance(_uuidof(Recordset));
|
||
pCmdIns.CreateInstance(_uuidof(Command));
|
||
pCmdIns->ActiveConnection = theApp.m_pConnection;
|
||
|
||
ST2DTaskParam stTaskParam;
|
||
stTaskParam.strSptName = ptTaskArg->ucSciptName;
|
||
stTaskParam.strTDName = ptTaskArg->ucTDName;
|
||
stTaskParam.strTestPlace = "";
|
||
//stTaskParam.fEspace = ptTaskArg->stMeasuArg.fElecSpace;
|
||
stTaskParam.iAR = ptTaskArg->stMeasuArg.ucArrayType;// m_iAR; //装置类型
|
||
stTaskParam.iCableLayout = ptTaskArg->stMeasuArg.ucCableLayout;
|
||
stTaskParam.iEAmount = ptTaskArg->uiEndElec - ptTaskArg->uiStartElec + 1;
|
||
stTaskParam.iEndElec = ptTaskArg->uiEndElec;
|
||
stTaskParam.iEndLayer = ptTaskArg->uiEndLayer;
|
||
stTaskParam.iRollCnt = iRollCnt;
|
||
stTaskParam.iSAInterval = ptTaskArg->stMeasuArg.iSAInterval;
|
||
stTaskParam.iSkipCable = iSkipCable;
|
||
stTaskParam.iSptID = 0;//tTaskArg->stMeasuArg;
|
||
stTaskParam.iSptType = ptTaskArg->stMeasuArg.ucSptType;
|
||
stTaskParam.iStacking = ptTaskArg->stMeasuArg.ucStacking;
|
||
stTaskParam.iStartElec = ptTaskArg->uiStartElec;
|
||
stTaskParam.iStartLayer = ptTaskArg->uiStartLayer;
|
||
stTaskParam.iTestType = ptTaskArg->stMeasuArg.ucTestType;
|
||
stTaskParam.iTxPeriod = ptTaskArg->stMeasuArg.ucTxPeriod;
|
||
stTaskParam.ucOrgFlg = ptTaskArg->ucOrgFlg;
|
||
stTaskParam.iTxWave = 6;
|
||
stTaskParam.ucTestGRFlag = ptTaskArg->ucTestGRFlag;
|
||
|
||
CString strTaskCN = ptTaskArg->ucTaskID;// m_guCodeCreator.GenerateGUIDCode();
|
||
CString strCreateDate = _T(""), strCreateTime = _T(""); //ptTaskArg->uiEndTime;
|
||
//strCreateDate.Format(_T("%04d-%02d-%02d"), g_sysCurTime.wYear, g_sysCurTime.wMonth, g_sysCurTime.wDay);
|
||
//strCreateTime.Format(_T("%02d:%02d:%02d"), g_sysCurTime.wHour, g_sysCurTime.wMinute, g_sysCurTime.wSecond);
|
||
CString strValildLayer = _T("");
|
||
strValildLayer.Format(_T("%d,%d"), stTaskParam.iStartLayer, stTaskParam.iEndLayer);
|
||
//strEspace.Format(_T("%f"), stTaskParam.fEspace);
|
||
|
||
CString strEdistance, strRectGrid, strElecStep;
|
||
//三维电极间距
|
||
if (2 == ptTaskArg->stMeasuArg.ucSptType)
|
||
{
|
||
strEdistance.Format(_T("%.2f,%.2f"), ptTaskArg->stMeasuArg.fXElecDistance, ptTaskArg->stMeasuArg.fYElecDistance);
|
||
strRectGrid.Format(_T("%d,%d,%d,%d"), ptTaskArg->stMeasuArg.rcGridSize.left, ptTaskArg->stMeasuArg.rcGridSize.top, ptTaskArg->stMeasuArg.rcGridSize.right, ptTaskArg->stMeasuArg.rcGridSize.bottom);
|
||
}
|
||
else
|
||
{
|
||
strEdistance.Format(_T("%.2f"), ptTaskArg->stMeasuArg.fXElecDistance);
|
||
strRectGrid.Format(_T("%d,%d"), stTaskParam.iStartElec, stTaskParam.iEndElec);
|
||
}
|
||
strElecStep.Format(_T("%.2f,%.2f"), ptTaskArg->stMeasuArg.fXElecStep, ptTaskArg->stMeasuArg.fYElecStep);
|
||
int iTaskID = 0;
|
||
CString szSql;
|
||
try
|
||
{
|
||
/*szSql.Empty();
|
||
szSql.Format(_T("select TPamount from scon where id = %d"), stTaskParam.iSptID);
|
||
pRecScon->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if (pRecScon->GetRecordCount() < 1)
|
||
{
|
||
pRecScon->Close();
|
||
CString strErr = _T("");
|
||
strErr.Format(_T("查询脚本信息(%d)失败"), stTaskParam.iSptID);
|
||
AfxMessageBox(strErr);
|
||
return -1;
|
||
}
|
||
int iTPmount = pRecScon->GetCollect(_T("TPamount")).lVal;
|
||
pRecScon->Close();*/
|
||
|
||
int iTPmount = ptTaskArg->uiTotalNum;
|
||
//获取测区ID
|
||
int iTzID = 1;
|
||
CString strDownloadTime;// = cDownloadTime.Format(_T("%Y-%m-%d %H:%M:%S"));
|
||
CTime cTime = CTime::GetCurrentTime();
|
||
time_t tmDownload = cTime.GetTime();
|
||
theApp.m_pConnection->BeginTrans();
|
||
szSql.Empty();
|
||
CString strTestDate = _T(" "), strTestTime = _T(" ");
|
||
time_t tTmp = ptTaskArg->uiStartTime;
|
||
if (tTmp > 0)
|
||
{
|
||
tm* tmStartTime;
|
||
tmStartTime = localtime(&tTmp);
|
||
strTestDate.Format(_T("%d-%d-%d"), tmStartTime->tm_year + 1900, tmStartTime->tm_mon + 1, tmStartTime->tm_mday);
|
||
strTestTime.Format(_T("%d:%d:%d"), tmStartTime->tm_hour, tmStartTime->tm_min, tmStartTime->tm_sec);
|
||
szSql.Format(_T("insert into td(TDname,TDCN,Tlocation,TZID,SCID,Sname,Stype,Ttype,StartElec,EndElec,Eamount,TPamount,CHamount,N,TRwave,TRfrequency,SAfrequency,"
|
||
"Clayout, SkipCable, CRTime, Edistance, rect, rect_loc,DESN,STime,ETime,TTimer,OrgFlg,DownloadTime,TestGRFlag,Tdate,Ttime,CreateTime,Espace,LineDirection) "
|
||
"values('%s','%s','%s',%d,%u,'%s',%u,%u,%d,%d,%d,%d,1,%d,%d,%d,%d, %d, %d, %d, '%s', '%s', '%s','%s',%d,%d,%d,%d,%d,%d,'%s','%s',%d,'%s',%d)"),
|
||
stTaskParam.strTDName, strTaskCN, stTaskParam.strTestPlace, iTzID,
|
||
stTaskParam.iSptID, stTaskParam.strSptName, stTaskParam.iSptType,
|
||
stTaskParam.iTestType,stTaskParam.iStartElec, stTaskParam.iEndElec, stTaskParam.iEAmount, iTPmount, stTaskParam.iStacking,
|
||
stTaskParam.iTxWave, stTaskParam.iTxPeriod, stTaskParam.iSAInterval,
|
||
stTaskParam.iCableLayout, stTaskParam.iSkipCable, stTaskParam.iRollCnt,
|
||
strEdistance, strRectGrid, strValildLayer, szDevSN, ptTaskArg->uiStartTime, \
|
||
ptTaskArg->uiEndTime, ptTaskArg->uiTimerTime, stTaskParam.ucOrgFlg, (long)tmDownload, stTaskParam.ucTestGRFlag, strTestDate, strTestTime, ptTaskArg->uiCreateTime, strElecStep, ptTaskArg->stMeasuArg.byLineDirection);
|
||
}
|
||
else
|
||
{
|
||
szSql.Format(_T("insert into td(TDname,TDCN,Tlocation,TZID,SCID,Sname,Stype,Ttype,StartElec,EndElec,Eamount,TPamount,CHamount,N,TRwave,TRfrequency,SAfrequency,"
|
||
"Clayout, SkipCable, CRTime, Edistance, rect, rect_loc,DESN,STime,ETime,TTimer,OrgFlg,DownloadTime,TestGRFlag,CreateTime,Espace,LineDirection) "
|
||
"values('%s','%s','%s',%d,%u,'%s',%u,%u,%d,%d,%d,%d,1,%d,%d,%d,%d, %d, %d, %d, '%s', '%s', '%s','%s',%d,%d,%d,%d,%d,%d,%d,'%s',%d)"),
|
||
stTaskParam.strTDName, strTaskCN, stTaskParam.strTestPlace, iTzID,
|
||
stTaskParam.iSptID, stTaskParam.strSptName, stTaskParam.iSptType,
|
||
stTaskParam.iTestType, stTaskParam.iStartElec, stTaskParam.iEndElec, stTaskParam.iEAmount, iTPmount, stTaskParam.iStacking,
|
||
stTaskParam.iTxWave, stTaskParam.iTxPeriod, stTaskParam.iSAInterval,
|
||
stTaskParam.iCableLayout, stTaskParam.iSkipCable, stTaskParam.iRollCnt,
|
||
strEdistance, strRectGrid, strValildLayer, szDevSN, ptTaskArg->uiStartTime, \
|
||
ptTaskArg->uiEndTime, ptTaskArg->uiTimerTime, stTaskParam.ucOrgFlg, (long)tmDownload, stTaskParam.ucTestGRFlag, ptTaskArg->uiCreateTime, strElecStep, ptTaskArg->stMeasuArg.byLineDirection);
|
||
}
|
||
pCmdIns->CommandText = szSql.AllocSysString();
|
||
strDownloadTime.Format(_T("[%s][%d]zm:recent task download time, insert database sql%s"), MODULE_NAME, __LINE__, szSql);
|
||
CFileOperTools::GetInstance()->WriteComLog(strDownloadTime);
|
||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||
|
||
pRecTd->Open(_T("select max(ID) as ID from td "), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if (pRecTd->GetRecordCount() > 0)
|
||
{
|
||
iTaskID = pRecTd->GetCollect(_T("ID")).ulVal;
|
||
}
|
||
pRecTd->Close();
|
||
//插入tdchannel表
|
||
szSql.Empty();
|
||
szSql.Format(_T("insert into tdchannel(TDID, CHnumber, AR) values (%d, 1, %d)"), iTaskID, stTaskParam.iAR);
|
||
pCmdIns->CommandText = szSql.AllocSysString();
|
||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||
int iTdChID = 0;
|
||
pRecTd->Open(_T("select max(ID) as ID from tdchannel "), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if (pRecTd->GetRecordCount() > 0)
|
||
{
|
||
iTdChID = pRecTd->GetCollect(_T("ID")).ulVal;
|
||
}
|
||
pRecTd->Close();
|
||
|
||
|
||
////批量将脚本中的ABMN信息导入到任务中去
|
||
//szSql.Empty();
|
||
//szSql.Format(_T("insert into td2dcon(TCHID, TSN, C1,C2,P1,P2,N,K,I,V,R0,SP,bUse) select %d, TSN, C1, C2, P1, P2, N, K*%f as K_New,0,0,0,0,0 from script2d "
|
||
// "where CHID in (select ID from channel where SCID = %d and CHnumber = 1)"), iTdChID, stTaskParam.fEspace, stTaskParam.iSptID);
|
||
//pCmdIns->CommandText = szSql.AllocSysString();
|
||
//pCmdIns->Execute(NULL, NULL, adCmdText);
|
||
theApp.m_pConnection->CommitTrans();
|
||
return iTaskID;
|
||
}
|
||
catch (_com_error e)
|
||
{
|
||
theApp.m_pConnection->RollbackTrans();
|
||
AfxMessageBox(e.Description());
|
||
return -1;
|
||
}
|
||
|
||
return iTaskID;
|
||
}
|
||
DWORD CTdManager::ImportTdHeadToDB(DWORD dwTzID, CString szHeadFile, CDevice* const pDev,DWORD* pExTdID)
|
||
{
|
||
_RecordsetPtr pRecTdID = NULL;
|
||
_RecordsetPtr pRecDeID = NULL;
|
||
_RecordsetPtr pRecScID = NULL;
|
||
|
||
_CommandPtr pCmdIns = NULL;
|
||
CMarkup *pXML = NULL;
|
||
|
||
CString szSql = _T("");
|
||
DWORD dwTdID = (DWORD)VAL_ZERO;
|
||
|
||
CString szTdName = _T("");
|
||
CString szTdCN = _T("");
|
||
CString szTLocation = _T("");
|
||
DWORD dwDeID = (DWORD)VAL_ZERO;
|
||
CString szDESN = _T("");
|
||
DWORD dwScID = (DWORD)VAL_ZERO;
|
||
CString szSCCN = _T("");
|
||
CString szSName = _T("");
|
||
int iSType = (int)VAL_ZERO;
|
||
int iTType = (int)VAL_ZERO;
|
||
int iTMode = (int)VAL_ZERO;
|
||
int iEAmount = (int)VAL_ZERO;
|
||
int iTPAmount = (int)VAL_ZERO;
|
||
int iCHAmount = (int)VAL_ZERO;
|
||
int iN = (int)VAL_ZERO;
|
||
int iTrWave = (int)VAL_ZERO;
|
||
int iTrFrequency = (int)VAL_ZERO;
|
||
int iIFrequency = (int)VAL_ZERO;
|
||
int iSaFrequency = (int)VAL_ZERO;
|
||
int iCLayout = (int)VAL_ZERO;
|
||
int iInitalEAmount = (int)VAL_ZERO;
|
||
|
||
CString szESpace = _T("");
|
||
CString szDistance = _T("");
|
||
|
||
int iWeather = (int)VAL_ZERO;
|
||
int iWDIR = (int)VAL_ZERO;
|
||
float fTemperature = (float)VAL_ZERO;
|
||
float fHeight = (float)VAL_ZERO;
|
||
float fHumidity = (float)VAL_ZERO;
|
||
CString szCDate = _T("");
|
||
CString szCTime = _T("");
|
||
CString szTDate = _T("");
|
||
CString szTTime = _T("");
|
||
int iRDirection = (int)VAL_ZERO;
|
||
int iCRTime = (int)VAL_ZERO;
|
||
CString szPM = _T("");
|
||
CString szOP = _T("");
|
||
CString szQA = _T("");
|
||
CString szRect = _T("");
|
||
CString szRectLoc = _T("");
|
||
CString szChannel = _T("");
|
||
CStringArray saChArray;
|
||
|
||
//////////////////////////////海上测量变量定义////////////////////////////////////////////
|
||
float fSpacing = 0;
|
||
float fInterval = 0;
|
||
float fRecDistance = 0;
|
||
float fMoveSpeed = 0;
|
||
int iRecMode = -1;
|
||
int iCurPoleDepoly = -1;
|
||
int iDipoleNo = -1;
|
||
|
||
//////////////////////////////////////////////////////////////////////////
|
||
|
||
int iIndex = (int)VAL_ZERO;
|
||
int iAR[8] = {0};
|
||
///E:\\R&D\\GeomativeStudio\\Debug\\CACHE\\projects\\63EFC4AB5B284FC8B1B46F0CEB8F9DA4\\A9F3D38BDCF84401B8C3050D583BCBEE\\ERIR201106291331120026.xml
|
||
int iPos = szHeadFile.ReverseFind('/');
|
||
if (-1 != iPos)
|
||
{
|
||
szTdCN = szHeadFile.Mid(iPos+1);
|
||
iPos = szTdCN.ReverseFind('.');
|
||
if (-1 != iPos)
|
||
{
|
||
szTdCN = szTdCN.Mid(0, iPos);
|
||
}
|
||
}
|
||
if (szTdCN.GetLength() == 0)
|
||
{
|
||
iPos = szHeadFile.ReverseFind('\\');
|
||
if (-1 != iPos)
|
||
{
|
||
szTdCN = szHeadFile.Mid(iPos + 1);
|
||
iPos = szTdCN.ReverseFind('.');
|
||
if (-1 != iPos)
|
||
{
|
||
szTdCN = szTdCN.Mid(0, iPos);
|
||
}
|
||
}
|
||
}
|
||
/*szTdCN = szHeadFile.Right(22);
|
||
szTdCN = szTdCN.Left(18);*/
|
||
|
||
//log
|
||
m_log = "\r\nImportTdHeadToDB------------begin\r\n";
|
||
fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
fflush(m_pFile);
|
||
//log
|
||
|
||
pXML = new CMarkup;
|
||
pXML->Load(szHeadFile);
|
||
|
||
pXML->FindElem(_T("measure"));
|
||
|
||
pXML->FindChildElem(_T("measure_name"));
|
||
szTdName = pXML->GetChildData();
|
||
|
||
pXML->FindChildElem(_T("measure_location"));
|
||
szTLocation = pXML->GetChildData();
|
||
|
||
pXML->FindChildElem(_T("measure_script_id"));
|
||
szSCCN = pXML->GetChildData();
|
||
|
||
pXML->FindChildElem(_T("measure_script_name"));
|
||
szSName = pXML->GetChildData();
|
||
|
||
pXML->FindChildElem(_T("measure_script_type"));
|
||
iSType = atoi(pXML->GetChildData());
|
||
|
||
pXML->FindChildElem(_T("measure_type"));
|
||
iTType = atoi(pXML->GetChildData());
|
||
|
||
pXML->FindChildElem(_T("measure_mode"));
|
||
iTMode = atoi(pXML->GetChildData());
|
||
|
||
pXML->FindChildElem(_T("medium_set"));
|
||
pXML->IntoElem();
|
||
|
||
iIndex = (int)VAL_ZERO;
|
||
while (pXML->FindChildElem(_T("medium")))
|
||
{
|
||
saChArray.RemoveAll();
|
||
szChannel.Empty();
|
||
szChannel = pXML->GetChildData();
|
||
|
||
SplitterString(saChArray, szChannel, _T(":"));
|
||
|
||
iIndex = atoi(saChArray.GetAt(0))-1;
|
||
iAR[iIndex] = atoi(saChArray.GetAt(1));
|
||
}
|
||
pXML->OutOfElem();
|
||
|
||
pXML->FindChildElem(_T("pole_count"));
|
||
iEAmount = atoi(pXML->GetChildData());
|
||
|
||
//文本
|
||
pXML->FindChildElem(_T("pole_distance"));
|
||
szDistance = pXML->GetChildData();
|
||
|
||
//文本
|
||
pXML->FindChildElem(_T("pole_gap"));
|
||
szESpace = pXML->GetChildData();
|
||
|
||
//added by lsq 20160628
|
||
//在这里将二维的有效的电极填充到rect中去,如果是三维,则还是用rect
|
||
if (1 == iSType)
|
||
{
|
||
pXML->ResetChildPos();
|
||
pXML->FindChildElem(_T("valid_pole"));
|
||
szRect = pXML->GetChildData();
|
||
}
|
||
else
|
||
{
|
||
pXML->FindChildElem(_T("rect"));
|
||
szRect = pXML->GetChildData();
|
||
}
|
||
|
||
|
||
//文本
|
||
pXML->FindChildElem(_T("rect_loc"));
|
||
szRectLoc = pXML->GetChildData();
|
||
|
||
pXML->FindChildElem(_T("wires_layout"));
|
||
iCLayout = atoi(pXML->GetChildData());
|
||
|
||
pXML->FindChildElem(_T("point_count"));
|
||
iTPAmount = atoi(pXML->GetChildData());
|
||
|
||
pXML->FindChildElem(_T("rolling_times"));
|
||
iCRTime = atoi(pXML->GetChildData());
|
||
|
||
pXML->FindChildElem(_T("rolling_direction"));
|
||
iRDirection = atoi(pXML->GetChildData());
|
||
|
||
pXML->FindChildElem(_T("channel_count"));
|
||
iCHAmount = atoi(pXML->GetChildData());
|
||
|
||
pXML->FindChildElem(_T("iterations"));
|
||
iN = atoi(pXML->GetChildData());
|
||
|
||
pXML->FindChildElem(_T("wave_shape"));
|
||
iTrWave = atoi(pXML->GetChildData());
|
||
|
||
pXML->FindChildElem(_T("period"));
|
||
iTrFrequency = atoi(pXML->GetChildData());
|
||
|
||
pXML->FindChildElem(_T("industrial_frequency"));
|
||
iIFrequency = atoi(pXML->GetChildData());
|
||
|
||
pXML->FindChildElem(_T("sample_rate"));
|
||
iSaFrequency = atoi(pXML->GetChildData());
|
||
|
||
pXML->FindChildElem(_T("temperature"));
|
||
fTemperature = (float)atof(pXML->GetChildData());
|
||
|
||
pXML->FindChildElem(_T("height"));
|
||
fHeight = (float)atof(pXML->GetChildData());
|
||
|
||
pXML->FindChildElem(_T("humidity"));
|
||
fHumidity = (float)atof(pXML->GetChildData());
|
||
|
||
pXML->FindChildElem(_T("weather"));
|
||
iWeather = atoi(pXML->GetChildData());
|
||
|
||
pXML->FindChildElem(_T("wind_direction"));
|
||
iWDIR = atoi(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("PM"));
|
||
szPM = pXML->GetChildData();
|
||
|
||
pXML->FindChildElem(_T("OP"));
|
||
szOP = pXML->GetChildData();
|
||
|
||
pXML->FindChildElem(_T("QA"));
|
||
szQA = pXML->GetChildData();
|
||
|
||
|
||
|
||
//如果是二维的跨孔装置,那么则将孔深存储于电极间隔处
|
||
if ((1 == iSType) && (iAR[iIndex] == AR_CROSS_HOLE_TYPE))
|
||
{
|
||
//文本
|
||
if (pXML->FindChildElem(_T("initial_depth")))
|
||
szESpace = pXML->GetChildData();
|
||
else
|
||
szESpace = _T("0.00");
|
||
}
|
||
|
||
//时窗--------
|
||
pXML->FindChildElem(_T("apparent_chargeability"));
|
||
pXML->IntoElem();
|
||
|
||
CString szTmp = _T("");
|
||
CString szWinTime = _T("");
|
||
int nST[20] = {0};
|
||
int nTW[20] = {0};
|
||
int id;
|
||
|
||
for (int n = 0; n < 20; n++)
|
||
{
|
||
szTmp.Format("m%d", n);
|
||
if (!(pXML->FindChildElem(szTmp)))
|
||
{
|
||
continue;
|
||
}
|
||
szWinTime = pXML->GetChildData();
|
||
id = szWinTime.Find(",");
|
||
nST[n] = atoi(szWinTime.Left(id));
|
||
nTW[n] = atoi(szWinTime.Right(szWinTime.GetLength() - id - 1));
|
||
}
|
||
|
||
pXML->OutOfElem();
|
||
//added by lsq 20161224
|
||
//在这里进行二维多通道辅助脚本的查找
|
||
int iExMediumID = -1, iExPoleCnt = 0, iExPtCnt = 0;
|
||
CString strExSptName = _T(""), strExTdCN = _T(""), strExSCCN = _T("");
|
||
CString strExValidPole = szRect;
|
||
DWORD dwExScID = 0;
|
||
//strTDName_1.Format(_T("%s_%s"), szTdName, )
|
||
if (1 == iSType)
|
||
{
|
||
if (pXML->FindChildElem(_T("measure_cn_1")))
|
||
{
|
||
strExTdCN = pXML->GetChildData();
|
||
}
|
||
if (!strExTdCN.IsEmpty())
|
||
{
|
||
if (pXML->FindChildElem(_T("medium_id_1")))
|
||
{
|
||
iExMediumID = atoi(pXML->GetChildData());
|
||
}
|
||
if (pXML->FindChildElem(_T("measure_script_id_1")))
|
||
{
|
||
strExSCCN = pXML->GetChildData();
|
||
}
|
||
if (pXML->FindChildElem(_T("measure_script_name_1")))
|
||
{
|
||
strExSptName = pXML->GetChildData();
|
||
}
|
||
if (pXML->FindChildElem(_T("point_count_1")))
|
||
{
|
||
iExPtCnt = atoi(pXML->GetChildData());
|
||
}
|
||
if (pXML->FindChildElem(_T("pole_count_1")))
|
||
{
|
||
iExPoleCnt = atoi(pXML->GetChildData());
|
||
}
|
||
if (pXML->FindChildElem(_T("valid_pole_1")))
|
||
{
|
||
strExValidPole = pXML->GetChildData();
|
||
}
|
||
}
|
||
}
|
||
|
||
//added by lsq 20160615
|
||
//加入二维任务时,取数据的原始电极总数,因为二维的需要画剖面图
|
||
//而在标准脚本里,是可以进行电极的筛选的
|
||
if (pXML->FindChildElem(_T("init_pole_num")))
|
||
{
|
||
iInitalEAmount = atoi(pXML->GetChildData());
|
||
if (iInitalEAmount > 32000 || iInitalEAmount < 0)
|
||
{
|
||
CString strLogTest = _T("");
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strLogTest.Format(_T("Inital_Pole_Number的值超出了范围。值= %d"), iInitalEAmount);
|
||
AfxMessageBox(strLogTest);
|
||
}
|
||
else
|
||
{
|
||
strLogTest.Format(_T("The value of Inital_Pole_Number out of range. value = %d"), iInitalEAmount);
|
||
MessageBoxEx(NULL, strLogTest, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
iInitalEAmount = 0;
|
||
}
|
||
}
|
||
|
||
//added by lsq 20170302
|
||
//如果是海上测量的话,则需要单独添加属性
|
||
if (AR_MARINE == iAR[iIndex])
|
||
{
|
||
if (pXML->FindChildElem(_T("spacing")))
|
||
{
|
||
fSpacing = atof(pXML->GetChildData());
|
||
}
|
||
if (pXML->FindChildElem(_T("interval")))
|
||
{
|
||
fInterval = atof(pXML->GetChildData());
|
||
}
|
||
if (pXML->FindChildElem(_T("Dipole_No")))
|
||
{
|
||
iDipoleNo = atoi(pXML->GetChildData());
|
||
}
|
||
if (pXML->FindChildElem(_T("record_mode")))
|
||
{
|
||
iRecMode = atoi(pXML->GetChildData());
|
||
}
|
||
if (pXML->FindChildElem(_T("pole_deploy")))
|
||
{
|
||
iCurPoleDepoly = atoi(pXML->GetChildData());
|
||
}
|
||
if (pXML->FindChildElem(_T("moving_speed")))
|
||
{
|
||
fMoveSpeed = atof(pXML->GetChildData());
|
||
}
|
||
if (pXML->FindChildElem(_T("Record_distance")))
|
||
{
|
||
fRecDistance = atof(pXML->GetChildData());
|
||
}
|
||
|
||
}
|
||
|
||
//暂时只支持Cross-Hole(Geomative)装置
|
||
CString strCoordinatesFile;
|
||
if (iAR[iIndex] == AR_CROSS_HOLE_GEOMATIVE
|
||
|| iAR[iIndex] == AR_CROSS_HOLE_GEOMATIVE_AM)
|
||
{
|
||
pXML->FindChildElem(_T("C_H_Script"));
|
||
strCoordinatesFile = pXML->GetChildData();
|
||
}
|
||
|
||
//---------------
|
||
delete pXML;
|
||
|
||
if (_T("0000-00-00") == szTDate)
|
||
{
|
||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("测量没有完成!"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Measure is not finished!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return dwTdID;
|
||
}
|
||
|
||
pRecTdID.CreateInstance(_uuidof(Recordset));
|
||
pRecDeID.CreateInstance(_uuidof(Recordset));
|
||
pRecScID.CreateInstance(_uuidof(Recordset));
|
||
|
||
pCmdIns.CreateInstance(_uuidof(Command));
|
||
pCmdIns->ActiveConnection = m_pConnection;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID from device where SN = '%s'"), pDev->m_szDevSN);
|
||
pRecDeID->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
if ((long)VAL_ZERO != pRecDeID->GetRecordCount())
|
||
{
|
||
dwDeID = pRecDeID->GetCollect(_T("ID")).ulVal;
|
||
}
|
||
|
||
pRecDeID->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID from scon where CN = '%s'"), szSCCN);
|
||
pRecScID->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
//在这里GD10主机上的脚本可能并不存在于上位机,所以这里的脚本ID也可能是0
|
||
if ((long)VAL_ZERO != pRecScID->GetRecordCount())
|
||
{
|
||
dwScID = pRecScID->GetCollect(_T("ID")).ulVal;
|
||
}
|
||
else
|
||
{
|
||
pRecScID->Close();
|
||
|
||
//查询坐标文件是否存在,或者删除坐标文件再插入
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID from TCoordinatesInfo where ScriptCN = '%s'"), szSCCN);
|
||
pRecScID->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
//TCoordinatesInfo表中没有数据
|
||
if ((long)VAL_ZERO == pRecScID->GetRecordCount())
|
||
{
|
||
CString strFilePath, strRawContent, strSql;
|
||
strFilePath.Format(_T("%sSD\\scripts\\%s"), CDetcGD10Dev::GetInstance()->GetGD10DevAddr(), strCoordinatesFile);
|
||
//插入坐标文件
|
||
BOOL bRes = FALSE;
|
||
CStdioFile csf;
|
||
int i = 0,iIndex = 1;
|
||
//UINT32 uiID = 1;//ID
|
||
UINT iExists = 0;
|
||
char* pCurContent = NULL;
|
||
int iElecID = 0;
|
||
float fX, fY, fZ;
|
||
bRes = csf.Open(strFilePath, CStdioFile::modeReadWrite);
|
||
if (bRes)
|
||
{
|
||
while (csf.ReadString(strRawContent))
|
||
{
|
||
OutputDebugString(strRawContent + _T("\n"));
|
||
|
||
pCurContent = _tcstok(strRawContent.GetBuffer(), _T(","));
|
||
iElecID = atoi(pCurContent);
|
||
i = 0;
|
||
while ((pCurContent = _tcstok(NULL, _T(","))))
|
||
{
|
||
switch (i)
|
||
{
|
||
case 0://X
|
||
fX = atof(pCurContent);
|
||
break;
|
||
case 1://Y
|
||
fY = atof(pCurContent);
|
||
break;
|
||
case 2://Z
|
||
fZ = atof(pCurContent);
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
i++;
|
||
}
|
||
//插入数据库
|
||
strSql.Empty();
|
||
strSql.Format(_T("insert into TCoordinatesInfo(SSN,ScriptCN,ElectrodeID,X,Y,Z) values(%d,'%s',%d,%.2f,%.2f,%.2f)"),iIndex, szSCCN, iElecID, fX, fY, fZ);
|
||
pCmdIns->CommandText = strSql.AllocSysString();
|
||
try
|
||
{
|
||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||
}
|
||
catch (_com_error e)
|
||
{
|
||
AfxMessageBox((LPCTSTR)e.Description());
|
||
}
|
||
iIndex++;
|
||
}
|
||
csf.Close();
|
||
}
|
||
}
|
||
}
|
||
|
||
pRecScID->Close();
|
||
|
||
if (-1 != iExMediumID)
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID from scon where CN = '%s'"), strExSCCN);
|
||
pRecScID->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
//在这里GD10主机上的脚本可能并不存在于上位机,所以这里的脚本ID也可能是0
|
||
if ((long)VAL_ZERO != pRecScID->GetRecordCount())
|
||
{
|
||
dwExScID = pRecScID->GetCollect(_T("ID")).ulVal;
|
||
}
|
||
|
||
pRecScID->Close();
|
||
|
||
}
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("insert into td(TDname,TDCN,Tlocation,DEID,DESN,TZID,SCID,SCCN,Sname,Stype,Ttype,Tmode,Eamount,TPamount,CHamount,N,TRwave,TRfrequency,Ifrequency,"
|
||
"SAfrequency,Clayout,Espace,Edistance,weather,WDIR,temperature,height,humidity,Cdate,Ctime,Tdate,Ttime,Rdirection,CRtime,PM,OP,QA,rect,rect_loc,InitiEamount) "
|
||
"values('%s','%s','%s',%u,'%s',%u,%u,'%s','%s',%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,'%s','%s',%d,%d,%.2f,%.2f,%.2f,#%s#,#%s#,#%s#,#%s#,%d,%d,'%s','%s','%s','%s','%s',%d)"),
|
||
szTdName,
|
||
szTdCN,
|
||
szTLocation,
|
||
dwDeID,
|
||
pDev->m_szDevSN,
|
||
dwTzID,
|
||
dwScID,
|
||
szSCCN,
|
||
szSName,
|
||
iSType,
|
||
iTType,
|
||
iTMode,
|
||
iEAmount,
|
||
iTPAmount,
|
||
iCHAmount,
|
||
iN,
|
||
iTrWave,
|
||
iTrFrequency,
|
||
iIFrequency,
|
||
iSaFrequency,
|
||
iCLayout,
|
||
szESpace,
|
||
szDistance,
|
||
iWeather,
|
||
iWDIR,
|
||
fTemperature,
|
||
fHeight,
|
||
fHumidity,
|
||
// "2015-01-27",
|
||
// "10:20:30",
|
||
// szTDate,
|
||
// szTTime,
|
||
szCDate,
|
||
szCTime,
|
||
szTDate,
|
||
szTTime,
|
||
iRDirection,
|
||
iCRTime,
|
||
szPM,
|
||
szOP,
|
||
szQA,
|
||
szRect,
|
||
szRectLoc,
|
||
iInitalEAmount);
|
||
|
||
//log
|
||
CTime t;
|
||
t = CTime::GetCurrentTime();
|
||
m_log = t.Format("%Y-%m-%d,%H:%M:%S:");
|
||
m_log += "\r\n";
|
||
m_log += szSql;
|
||
m_log += "\r\n";
|
||
// fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
// fflush(m_pFile);
|
||
//log
|
||
|
||
pCmdIns->CommandText = szSql.AllocSysString();
|
||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||
|
||
pRecTdID->Open(_T("select max(ID) as ID from td "), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
if ((long)VAL_ZERO != pRecTdID->GetRecordCount())
|
||
{
|
||
dwTdID = pRecTdID->GetCollect(_T("ID")).ulVal;
|
||
}
|
||
|
||
pRecTdID->Close();
|
||
|
||
|
||
|
||
//如果有辅助脚本的话,则用来插入辅助任务信息,以主脚本的任务信息为主
|
||
//需要下位机加入测点总数(那么电极总数是否需要)
|
||
/*
|
||
strSql.Format(_T("insert into td_spc_attr(TCHID,TSN,THL,D,r,TWCNT,TW0Index,TW1Index,TW2Index,TW3Index,TW4Index,TW5Index,TW6Index,TW7Index,TW8Index,TW9Index) "
|
||
"select %d, TSN+%d,THL,D,r,TWCNT,TW0Index,TW1Index,TW2Index,TW3Index,TW4Index,TW5Index,TW6Index,TW7Index,TW8Index,TW9Index from td_spc_attr "
|
||
"where TCHID in (select ID from tdchannel where TDID = %d and CHnumber = 1) order by TSN"),
|
||
*/
|
||
if (-1 != iExMediumID)
|
||
{
|
||
CString strExTdName = _T("");
|
||
strExTdName.Format(_T("%s_auxiliary"),szTdName);
|
||
szSql.Format(_T("insert into td(TDname,SCID,SCCN,Sname,TDCN,TPamount,Eamount,rect,Tlocation,DEID,DESN,TZID,Stype,Ttype,Tmode,CHamount,N,TRwave,TRfrequency,Ifrequency,"
|
||
"SAfrequency,Clayout,Espace,Edistance,weather,WDIR,temperature,height,humidity,Cdate,Ctime,Tdate,Ttime,Rdirection,CRtime,PM,OP,QA,rect_loc,InitiEamount) "
|
||
"select '%s', %d, '%s', '%s', '%s', %d, %d, '%s', Tlocation,DEID,DESN,TZID,Stype,Ttype,Tmode,CHamount,N,TRwave,TRfrequency,Ifrequency, SAfrequency,Clayout,"
|
||
"Espace,Edistance,weather,WDIR,temperature,height,humidity,Cdate,Ctime,Tdate,Ttime,Rdirection,CRtime,PM,OP,QA,rect_loc,InitiEamount "
|
||
"from td where ID = %d"), strExTdName, dwExScID, strExSCCN, strExSptName, strExTdCN, iExPtCnt, iExPoleCnt,strExValidPole,dwTdID);
|
||
pCmdIns->CommandText = szSql.AllocSysString();
|
||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||
if (pExTdID)
|
||
{
|
||
pRecTdID->Open(_T("select max(ID) as ID from td "), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecTdID->GetRecordCount())
|
||
{
|
||
*pExTdID = pRecTdID->GetCollect(_T("ID")).ulVal;
|
||
}
|
||
pRecTdID->Close();
|
||
}
|
||
}
|
||
|
||
|
||
int iTdChannelID = -1;
|
||
|
||
iIndex = (int)VAL_ZERO;
|
||
|
||
while ((0 != iAR[iIndex]) && (iIndex < 8))
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("insert into tdchannel(TDID,CHnumber,AR) values(%u,%d,%d)"), dwTdID, iIndex+1, iAR[iIndex]);
|
||
|
||
//log
|
||
CTime t;
|
||
t = CTime::GetCurrentTime();
|
||
m_log = t.Format("%Y-%m-%d,%H:%M:%S:");
|
||
m_log += "\r\n";
|
||
m_log += szSql;
|
||
m_log += "\r\n";
|
||
// fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
// fflush(m_pFile);
|
||
//log
|
||
|
||
pCmdIns->CommandText = szSql.AllocSysString();
|
||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||
pRecTdID->Open(_T("select max(ID) as ID from tdchannel "), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecTdID->GetRecordCount())
|
||
{
|
||
iTdChannelID = pRecTdID->GetCollect(_T("ID")).ulVal;
|
||
}
|
||
pRecTdID->Close();
|
||
|
||
if (-1 != iExMediumID && pExTdID)
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("insert into tdchannel(TDID,CHnumber,AR) values(%u,%d,%d)"), *pExTdID, iIndex+1, iExMediumID);
|
||
pCmdIns->CommandText = szSql.AllocSysString();
|
||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||
iIndex++;
|
||
break;
|
||
}
|
||
iIndex++;
|
||
}
|
||
|
||
//插入海上测量
|
||
if (AR_MARINE == iAR[0])
|
||
{
|
||
if (iTdChannelID < 0)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("获取TdChannel表的ID错误"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Get TdChannel table ID error"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
iTdChannelID = 0;
|
||
}
|
||
CString strTmpSql = _T("");
|
||
strTmpSql.Format(_T("insert into td1dSpcAttr (TCHID,RecordMode,Spacing,PoleInterval,DipoleNo,CurPoleDepoly,MovingSpeed,RecordDistance) values (%u, %d, %f, %f, %d, %d, %f, %f)"),
|
||
iTdChannelID, iRecMode, fSpacing, fInterval, iDipoleNo, iCurPoleDepoly, fMoveSpeed, fRecDistance);
|
||
|
||
pCmdIns->CommandText = strTmpSql.AllocSysString();
|
||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||
|
||
}
|
||
|
||
//插入时窗
|
||
if (iTType == 1)
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("insert into ac(TDID,M0ST,M0TW,M1ST,M1TW,M2ST,M2TW,M3ST,M3TW,M4ST,M4TW,M5ST,M5TW,M6ST,M6TW,M7ST,M7TW,"
|
||
"M8ST,M8TW,M9ST,M9TW,M10ST,M10TW,M11ST,M11TW,M12ST,M12TW,M13ST,M13TW,M14ST,M14TW,M15ST,M15TW,M16ST,M16TW,"
|
||
"M17ST,M17TW,M18ST,M18TW,M19ST,M19TW) values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %d,%d, %d, %d, %d, %d, %d,"
|
||
"%d, %d, %d, %d, %d, %d, %d, %d, %d,%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)"),
|
||
dwTdID,
|
||
nST[0],nTW[0],
|
||
nST[1],nTW[1],
|
||
nST[2],nTW[2],
|
||
nST[3],nTW[3],
|
||
nST[4],nTW[4],
|
||
nST[5],nTW[5],
|
||
nST[6],nTW[6],
|
||
nST[7],nTW[7],
|
||
nST[8],nTW[8],
|
||
nST[9],nTW[9],
|
||
nST[10],nTW[10],
|
||
nST[11],nTW[11],
|
||
nST[12],nTW[12],
|
||
nST[13],nTW[13],
|
||
nST[14],nTW[14],
|
||
nST[15],nTW[15],
|
||
nST[16],nTW[16],
|
||
nST[17],nTW[17],
|
||
nST[18],nTW[18],
|
||
nST[19],nTW[19]
|
||
);
|
||
|
||
//log
|
||
CTime t;
|
||
t = CTime::GetCurrentTime();
|
||
m_log = t.Format("%Y-%m-%d,%H:%M:%S:");
|
||
m_log += "\r\n";
|
||
m_log += szSql;
|
||
m_log += "\r\n";
|
||
// fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
// fflush(m_pFile);
|
||
//log
|
||
|
||
pCmdIns->CommandText = szSql.AllocSysString();
|
||
|
||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||
//如果存在子脚本,则子脚本所对应任务的时窗依然沿用主脚本任务的
|
||
if (-1 != iExMediumID && pExTdID)
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("insert into ac(TDID,M0ST,M0TW,M1ST,M1TW,M2ST,M2TW,M3ST,M3TW,M4ST,M4TW,M5ST,M5TW,M6ST,M6TW,M7ST,M7TW,"
|
||
"M8ST,M8TW,M9ST,M9TW,M10ST,M10TW,M11ST,M11TW,M12ST,M12TW,M13ST,M13TW,M14ST,M14TW,M15ST,M15TW,M16ST,M16TW,"
|
||
"M17ST,M17TW,M18ST,M18TW,M19ST,M19TW) values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %d,%d, %d, %d, %d, %d, %d,"
|
||
"%d, %d, %d, %d, %d, %d, %d, %d, %d,%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)"),
|
||
*pExTdID,
|
||
nST[0],nTW[0],
|
||
nST[1],nTW[1],
|
||
nST[2],nTW[2],
|
||
nST[3],nTW[3],
|
||
nST[4],nTW[4],
|
||
nST[5],nTW[5],
|
||
nST[6],nTW[6],
|
||
nST[7],nTW[7],
|
||
nST[8],nTW[8],
|
||
nST[9],nTW[9],
|
||
nST[10],nTW[10],
|
||
nST[11],nTW[11],
|
||
nST[12],nTW[12],
|
||
nST[13],nTW[13],
|
||
nST[14],nTW[14],
|
||
nST[15],nTW[15],
|
||
nST[16],nTW[16],
|
||
nST[17],nTW[17],
|
||
nST[18],nTW[18],
|
||
nST[19],nTW[19]
|
||
);
|
||
pCmdIns->CommandText = szSql.AllocSysString();
|
||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||
}
|
||
}
|
||
|
||
//log
|
||
m_log = "ImportTdHeadToDB------------end\r\n";
|
||
fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
fflush(m_pFile);
|
||
//log
|
||
|
||
return dwTdID;
|
||
}
|
||
|
||
BOOL CTdManager::Import2DTdConToDB(DWORD dwTdID, CString szDatFile, CDevice* const pDev, int* pTSN)
|
||
{
|
||
_RecordsetPtr pRecChID = NULL;
|
||
_CommandPtr pCmdIns = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szTsn = _T("");
|
||
CString szTdCon = _T("");
|
||
CStringArray saTdCon;
|
||
|
||
CString szNodeName = _T("");
|
||
|
||
int iIndex = (int)VAL_ZERO;
|
||
DWORD aChID[8] = {0};
|
||
DWORD dwChID = (DWORD)VAL_ZERO;
|
||
|
||
int iTsn = (int)VAL_ZERO;
|
||
int iChNum = (int)VAL_ZERO;
|
||
int iC1 = (int)VAL_ZERO;
|
||
int iC2 = (int)VAL_ZERO;
|
||
int iP1 = (int)VAL_ZERO;
|
||
int iP2 = (int)VAL_ZERO;
|
||
int iN = (int)VAL_ZERO;
|
||
|
||
float fK = (float)VAL_ZERO;
|
||
float fI = (float)VAL_ZERO;
|
||
float fV = (float)VAL_ZERO;
|
||
float fR0 = (float)VAL_ZERO;
|
||
float fSP = (float)VAL_ZERO;
|
||
float fR0LC = (float)VAL_ZERO;
|
||
float fM0LC = (float)VAL_ZERO;
|
||
|
||
//log
|
||
m_log = "\r\nImport2DTdConToDB------------begin\r\n";
|
||
fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
fflush(m_pFile);
|
||
//log
|
||
CMarkup *pXML = new CMarkup;
|
||
try
|
||
{
|
||
|
||
pRecChID.CreateInstance(_uuidof(Recordset));
|
||
pCmdIns.CreateInstance(_uuidof(Command));
|
||
pCmdIns->ActiveConnection = m_pConnection;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID from tdchannel where TDID = %u"), dwTdID);
|
||
|
||
pRecChID->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
iIndex = (int)VAL_ZERO;
|
||
while ((short)VAL_ZERO == pRecChID->adoEOF)
|
||
{
|
||
aChID[iIndex] = pRecChID->GetCollect(_T("ID")).ulVal;
|
||
|
||
iIndex++;
|
||
pRecChID->MoveNext();
|
||
}
|
||
|
||
pRecChID->Close();
|
||
|
||
|
||
pXML->Load(szDatFile);
|
||
|
||
pXML->FindElem(_T("TD"));
|
||
|
||
pXML->FindChildElem("param");
|
||
|
||
pXML->FindChildElem("Data");
|
||
pXML->IntoElem();
|
||
|
||
iTsn = (int)VAL_ONE;
|
||
if (NULL != pTSN)
|
||
{
|
||
iTsn = *pTSN;
|
||
}
|
||
|
||
szNodeName.Empty();
|
||
szNodeName.Format(_T("D%.5d"), iTsn);
|
||
CString strShowErr = _T("");
|
||
bool bIsWirteCheckLC = true;//是否需要对离叉信息进行写日志
|
||
bool bIsHaveLC = false;
|
||
int iTestFlag, iLayer;
|
||
while (pXML->FindChildElem(szNodeName))
|
||
{
|
||
szTdCon.Empty();
|
||
szTdCon = pXML->GetChildData();
|
||
if (szTdCon.IsEmpty())
|
||
{
|
||
strShowErr.Empty();
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strShowErr.Format(_T("获取 %s 子数据为空!!!"), szNodeName.GetBuffer(0));
|
||
AfxMessageBox(strShowErr.GetBuffer(0));
|
||
}
|
||
else
|
||
{
|
||
strShowErr.Format(_T("Get %s childdata is empty!!!"), szNodeName.GetBuffer(0));
|
||
MessageBoxEx(NULL, strShowErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
}
|
||
|
||
SplitterString(saTdCon, szTdCon, _T(";"));
|
||
|
||
if (saTdCon.GetSize() < 20)
|
||
{
|
||
strShowErr.Empty();
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strShowErr.Format(_T("%s的元素大小错误,应该至少为20,但实际上是%d"), szNodeName.GetBuffer(0), saTdCon.GetSize());
|
||
AfxMessageBox(strShowErr.GetBuffer(0));
|
||
}
|
||
else
|
||
{
|
||
strShowErr.Format(_T("%s 's element size error, should be at least 20 but actually is %d"), szNodeName.GetBuffer(0), saTdCon.GetSize());
|
||
MessageBoxEx(NULL, strShowErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
pXML->OutOfElem();
|
||
delete pXML;
|
||
return FALSE;
|
||
}
|
||
bIsHaveLC = false;
|
||
//判断是否存在R0_LC和MO_LC,如果不存在,则认为是以前的版本,写错误日志
|
||
if (saTdCon.GetSize() < 22)
|
||
{
|
||
if (bIsWirteCheckLC)
|
||
{
|
||
CString strErrLog = _T("");
|
||
strErrLog.Format(_T("[%d][Td2d]deviation_iteratin data is not exits in Task(%d), node = %s, vector's size = %d "),
|
||
__LINE__, dwTdID, szNodeName, saTdCon.GetSize());
|
||
CFileOperTools::GetInstance()->WriteComLog(strErrLog);
|
||
//日志信息只写一次
|
||
bIsWirteCheckLC = false;
|
||
}
|
||
}
|
||
else
|
||
bIsHaveLC = true;
|
||
|
||
|
||
//最后一个为是否测试的标记位,只有等于1才表示进行了测试
|
||
iTestFlag = atoi(saTdCon.GetAt(19));
|
||
iLayer = atoi(saTdCon.GetAt(18));
|
||
if (1 == iTestFlag)
|
||
{
|
||
iC1 = atoi(saTdCon.GetAt(0));
|
||
iC2 = atoi(saTdCon.GetAt(1));
|
||
iP1 = atoi(saTdCon.GetAt(2));
|
||
iP2 = atoi(saTdCon.GetAt(3));
|
||
iChNum = atoi(saTdCon.GetAt(4));
|
||
dwChID = aChID[iChNum-1];
|
||
iN = atoi(saTdCon.GetAt(5));
|
||
fK = (float)atof(saTdCon.GetAt(6));
|
||
fI = (float)atof(saTdCon.GetAt(7));
|
||
fV = (float)atof(saTdCon.GetAt(8));
|
||
fR0 = (float)atof(saTdCon.GetAt(9));
|
||
fSP = (float)atof(saTdCon.GetAt(10));
|
||
|
||
if (bIsHaveLC)
|
||
{
|
||
fR0LC = (float)atof(saTdCon.GetAt(20));
|
||
fM0LC = (float)atof(saTdCon.GetAt(21));
|
||
}
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("insert into td2dcon(TCHID,TSN,C1,C2,P1,P2,N,K,I,V,R0,SP,bUse,Layer,R0_LC,M0_LC) values(%u,%d,%d,%d,%d,%d,%d,%f,%f,%f,%f,%f,%d,%d,%f,%f)"),
|
||
dwChID,iTsn,iC1,iC2,iP1,iP2,iN,fK,fI,fV,fR0,fSP,TRUE,iLayer,fR0LC,fM0LC);
|
||
|
||
|
||
|
||
|
||
//log
|
||
// CTime t;
|
||
// t = CTime::GetCurrentTime();
|
||
// m_log = t.Format("%Y-%m-%d,%H:%M:%S:");
|
||
// m_log += "\r\n";
|
||
// m_log += szSql;
|
||
// m_log += "\r\n";
|
||
// fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
// fflush(m_pFile);
|
||
//log
|
||
|
||
pCmdIns->CommandText = szSql.AllocSysString();
|
||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||
|
||
}
|
||
|
||
|
||
iTsn++;
|
||
szNodeName.Empty();
|
||
if (iTsn <= 99999)
|
||
{
|
||
szNodeName.Format(_T("D%.5d"), iTsn);
|
||
}
|
||
else
|
||
{
|
||
szNodeName.Format(_T("D%d"), iTsn);
|
||
}
|
||
}
|
||
pXML->OutOfElem();
|
||
delete pXML;
|
||
|
||
}
|
||
catch(_com_error e)
|
||
{
|
||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||
AfxMessageBox(e.Description());
|
||
delete pXML;
|
||
return FALSE;
|
||
|
||
}
|
||
//log
|
||
m_log = "Import2DTdConToDB------------end\r\n";
|
||
fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
fflush(m_pFile);
|
||
//log
|
||
*pTSN = iTsn;
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL CTdManager::ImportCETdConToDB(DWORD dwTdID, CString szDatFile, CDevice* const pDev)
|
||
{
|
||
_RecordsetPtr pRecChID = NULL;
|
||
_CommandPtr pCmdIns = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szTsn = _T("");
|
||
CString szTdCon = _T("");
|
||
CStringArray saTdCon;
|
||
|
||
CString szNodeName = _T("");
|
||
CString datetime = _T("");
|
||
|
||
DWORD aChID[8] = {0};
|
||
DWORD dwChID = (DWORD)VAL_ZERO;
|
||
|
||
int iIndex = (int)VAL_ZERO;
|
||
int iTsn = (int)VAL_ZERO;
|
||
int iChNum = (int)VAL_ZERO;
|
||
float fA = (float)VAL_ZERO;
|
||
float fB = (float)VAL_ZERO;
|
||
float fX = (float)VAL_ZERO;
|
||
float fY = (float)VAL_ZERO;
|
||
int iN = (int)VAL_ZERO;
|
||
|
||
float fK = (float)VAL_ZERO;
|
||
float fI = (float)VAL_ZERO;
|
||
float fV = (float)VAL_ZERO;
|
||
float fR0 = (float)VAL_ZERO;
|
||
float fSP = (float)VAL_ZERO;
|
||
float fR0LC = (float)VAL_ZERO;
|
||
float fM0LC = (float)VAL_ZERO;
|
||
CMarkup *pXML = new CMarkup;
|
||
|
||
try
|
||
{
|
||
|
||
|
||
pRecChID.CreateInstance(_uuidof(Recordset));
|
||
pCmdIns.CreateInstance(_uuidof(Command));
|
||
pCmdIns->ActiveConnection = m_pConnection;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID from tdchannel where TDID = %u"), dwTdID);
|
||
pRecChID->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
iIndex = (int)VAL_ZERO;
|
||
while ((short)VAL_ZERO == pRecChID->adoEOF)
|
||
{
|
||
aChID[iIndex] = pRecChID->GetCollect(_T("ID")).ulVal;
|
||
|
||
iIndex++;
|
||
pRecChID->MoveNext();
|
||
}
|
||
|
||
pRecChID->Close();
|
||
|
||
|
||
pXML->Load(szDatFile);
|
||
|
||
pXML->FindElem(_T("TD"));
|
||
|
||
pXML->FindChildElem(_T("param"));
|
||
|
||
pXML->FindChildElem(_T("Data"));
|
||
pXML->IntoElem();
|
||
|
||
iTsn = (int)VAL_ONE;
|
||
szNodeName.Empty();
|
||
szNodeName.Format(_T("D%.5d"), iTsn);
|
||
|
||
//log
|
||
m_log += "\r\nImportCETdConToDB------------begin\r\n";
|
||
fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
fflush(m_pFile);
|
||
//log
|
||
CString strShowErr = _T("");
|
||
bool bIsWirteCheckLC = true;
|
||
while (pXML->FindChildElem(szNodeName))
|
||
{
|
||
szTdCon.Empty();
|
||
szTdCon = pXML->GetChildData();
|
||
if (szTdCon.IsEmpty())
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strShowErr.Format(_T("获取 %s 子数据为空!!!"), szNodeName.GetBuffer(0));
|
||
AfxMessageBox(strShowErr.GetBuffer(0));
|
||
}
|
||
else
|
||
{
|
||
strShowErr.Format(_T("Get %s childdata is empty!!!"), szNodeName.GetBuffer(0));
|
||
MessageBoxEx(NULL, strShowErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
}
|
||
|
||
SplitterString(saTdCon, szTdCon, _T(";"));
|
||
//如果解析的列数不对,则认为产生严重错误,此时应该跳出函数,并且返回错误
|
||
if (saTdCon.GetSize() < 20)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strShowErr.Format(_T("%s的元素大小错误,应该至少为20,但实际上是%d"), szNodeName.GetBuffer(0), saTdCon.GetSize());
|
||
AfxMessageBox(strShowErr.GetBuffer(0));
|
||
}
|
||
else
|
||
{
|
||
strShowErr.Format(_T("%s 's element size error, should be at least 20 but actually is %d"), szNodeName.GetBuffer(0), saTdCon.GetSize());
|
||
MessageBoxEx(NULL, strShowErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
pXML->OutOfElem();
|
||
delete pXML;
|
||
return FALSE;
|
||
}
|
||
|
||
bool bIsHaveLC = false;
|
||
//判断是否存在R0_LC和MO_LC,如果不存在,则认为是以前的版本,写错误日志
|
||
if (saTdCon.GetSize() < 22)
|
||
{
|
||
if (bIsWirteCheckLC)
|
||
{
|
||
CString strErrLog = _T("");
|
||
strErrLog.Format(_T("[%d][Td1d]deviation_iteratin data is not exits in Task(%d), node = %s, vector's size = %d "),
|
||
__LINE__, dwTdID, szNodeName, saTdCon.GetSize());
|
||
CFileOperTools::GetInstance()->WriteComLog(strErrLog);
|
||
//日志信息只写一次
|
||
bIsWirteCheckLC = false;
|
||
}
|
||
}
|
||
else
|
||
bIsHaveLC = true;
|
||
|
||
|
||
int iTestFlag = atoi(saTdCon.GetAt(19));
|
||
//只有成功测试了的数据才插入到数据库中去
|
||
if (1 == iTestFlag || saTdCon.GetSize() > 25)
|
||
{
|
||
fA = (float)atof(saTdCon.GetAt(0));
|
||
fB = (float)atof(saTdCon.GetAt(1));
|
||
fX = (float)atof(saTdCon.GetAt(2));
|
||
fY = (float)atof(saTdCon.GetAt(3));
|
||
iChNum = atoi(saTdCon.GetAt(4));
|
||
dwChID = aChID[iChNum-1];
|
||
iN = atoi(saTdCon.GetAt(5));
|
||
fK = (float)atof(saTdCon.GetAt(6));
|
||
fI = (float)atof(saTdCon.GetAt(7));
|
||
fV = (float)atof(saTdCon.GetAt(8));
|
||
fR0 = (float)atof(saTdCon.GetAt(9));
|
||
fSP = (float)atof(saTdCon.GetAt(10));
|
||
|
||
if (bIsHaveLC)
|
||
{
|
||
fR0LC = (float)atof(saTdCon.GetAt(20));
|
||
fM0LC = (float)atof(saTdCon.GetAt(21));
|
||
}
|
||
|
||
szSql.Empty();
|
||
if (saTdCon.GetSize() > 25)
|
||
{
|
||
datetime = saTdCon.GetAt(24);
|
||
szSql.Format(_T("insert into td1dcon(TCHID,TSN,a,b,x,y,N,K,I,V,R0,SP,bUse,R0_LC,M0_LC,dt,POINT_NUM,TEST_FLAG) values(%u,%d,%.1f,%.1f,%.1f,%.1f,%d,%f,%f,%f,%f,%f,%d,%f,%f,#%s#,%d,%d)"),
|
||
dwChID, iTsn, fA, fB, fX, fY, iN, fK, fI, fV, fR0, fSP, TRUE, fR0LC, fM0LC, datetime, atoi(saTdCon.GetAt(25)),iTestFlag);
|
||
}
|
||
else if (saTdCon.GetSize() > 24)
|
||
{
|
||
datetime = saTdCon.GetAt(24);
|
||
szSql.Format(_T("insert into td1dcon(TCHID,TSN,a,b,x,y,N,K,I,V,R0,SP,bUse,R0_LC,M0_LC,dt) values(%u,%d,%.1f,%.1f,%.1f,%.1f,%d,%f,%f,%f,%f,%f,%d,%f,%f,#%s#)"),
|
||
dwChID, iTsn, fA, fB, fX, fY, iN, fK, fI, fV, fR0, fSP, TRUE, fR0LC, fM0LC, datetime);
|
||
}
|
||
else
|
||
{
|
||
szSql.Format(_T("insert into td1dcon(TCHID,TSN,a,b,x,y,N,K,I,V,R0,SP,bUse,R0_LC,M0_LC) values(%u,%d,%.1f,%.1f,%.1f,%.1f,%d,%f,%f,%f,%f,%f,%d,%f,%f)"),
|
||
dwChID, iTsn, fA, fB, fX, fY, iN, fK, fI, fV, fR0, fSP, TRUE, fR0LC, fM0LC);
|
||
}
|
||
|
||
//TRACE("szSql = %s\n", szSql);
|
||
//log
|
||
// CTime t;
|
||
// t = CTime::GetCurrentTime();
|
||
// m_log = t.Format("%Y-%m-%d,%H:%M:%S:");
|
||
// m_log += "\r\n";
|
||
// m_log += szSql;
|
||
// m_log += "\r\n";
|
||
// fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
// fflush(m_pFile);
|
||
//log
|
||
|
||
pCmdIns->CommandText = szSql.AllocSysString();
|
||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||
}
|
||
iTsn++;
|
||
szNodeName.Empty();
|
||
if (iTsn <= 99999)
|
||
{
|
||
szNodeName.Format(_T("D%.5d"), iTsn);
|
||
}
|
||
else
|
||
{
|
||
szNodeName.Format(_T("D%d"), iTsn);
|
||
}
|
||
}
|
||
|
||
pXML->OutOfElem();
|
||
delete pXML;
|
||
}
|
||
catch (_com_error e)
|
||
{
|
||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||
AfxMessageBox(e.Description());
|
||
delete pXML;
|
||
return FALSE;
|
||
|
||
}
|
||
|
||
|
||
//log
|
||
m_log += "ImportCETdConToDB------------end\r\n";
|
||
fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
fflush(m_pFile);
|
||
//log
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL CTdManager::Import2DGRToDB(DWORD dwTdID, CString szGRFile, CDevice* const pDev)
|
||
{
|
||
//temp delete由于接地电阻接口改变
|
||
// return TRUE;
|
||
|
||
//log
|
||
m_log = "\r\nImportTdHeadToDB------------begin\r\n";
|
||
fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
fflush(m_pFile);
|
||
//log
|
||
|
||
_CommandPtr pCmdIns = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szECode = _T("");
|
||
CString szDT = _T("");
|
||
CString szMDate = _T("");
|
||
CString szMTime = _T("");
|
||
CString strCode = _T("");
|
||
CString strCode1 = _T("");
|
||
|
||
int iOMValue = (int)VAL_ZERO;
|
||
int iOM1Value = (int)VAL_ZERO;
|
||
int iResCode = (int)VAL_ZERO;
|
||
int iResCode1 = (int)VAL_ZERO;
|
||
|
||
CString szTdGR = _T("");
|
||
CStringArray saTdGR;
|
||
|
||
CString szNodeName = _T("");
|
||
|
||
int iIndex = (int)VAL_ZERO;
|
||
|
||
pCmdIns.CreateInstance(_uuidof(Command));
|
||
pCmdIns->ActiveConnection = m_pConnection;
|
||
|
||
CMarkup *pXML = new CMarkup;
|
||
pXML->Load(szGRFile);
|
||
|
||
pXML->FindElem(_T("TD"));
|
||
|
||
pXML->FindChildElem("param");
|
||
|
||
pXML->FindChildElem("Data");
|
||
pXML->IntoElem();
|
||
|
||
iIndex = (int)VAL_ONE;
|
||
szNodeName.Empty();
|
||
szNodeName.Format(_T("D%.5d"), iIndex);
|
||
|
||
while (pXML->FindChildElem(szNodeName))
|
||
{
|
||
szTdGR = pXML->GetChildData();
|
||
SplitterString(saTdGR, szTdGR, _T(";"));
|
||
|
||
szECode.Empty();
|
||
szECode = saTdGR.GetAt(0);
|
||
szECode.TrimLeft();
|
||
szECode.TrimRight();
|
||
|
||
iOMValue = atoi(saTdGR.GetAt(1));
|
||
iResCode = atoi(saTdGR.GetAt(2));
|
||
|
||
iOM1Value = atoi(saTdGR.GetAt(3));
|
||
iResCode1 = atoi(saTdGR.GetAt(4));
|
||
|
||
szDT.Empty();
|
||
szDT = saTdGR.GetAt(5);
|
||
|
||
szDT.TrimLeft();
|
||
szDT.TrimRight();
|
||
|
||
szMDate.Empty();
|
||
szMDate.Format(_T("%s-%s-%s"), szDT.Mid(0, 4), szDT.Mid(4, 2), szDT.Mid(6, 2));
|
||
|
||
szMTime.Empty();
|
||
szMTime.Format(_T("%s:%s:%s"), szDT.Mid(8, 2), szDT.Mid(10, 2), szDT.Mid(12, 2));
|
||
|
||
if (szMTime == "1900-01-00")
|
||
{
|
||
szMTime = "1900-01-01";
|
||
}
|
||
|
||
if (szMDate == "1900-01-00")
|
||
{
|
||
szMDate = "1900-01-01";
|
||
}
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("insert into gr(TDID,Ecode,OMvalue,Mdate,Mtime,StatusCode,OM1value,StatusCode1) values(%u,'%s',%d,#%s#,#%s#,%d,%d,%d)"),
|
||
dwTdID, szECode, iOMValue, /*"2015-01-27"*/szMDate, /*"10:20:20"*/szMTime,iResCode, iOM1Value, iResCode1);
|
||
|
||
//log
|
||
CTime t;
|
||
t = CTime::GetCurrentTime();
|
||
m_log = t.Format("%Y-%m-%d,%H:%M:%S:");
|
||
m_log += "\r\n";
|
||
m_log += szSql;
|
||
m_log += "\r\n";
|
||
// fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
// fflush(m_pFile);
|
||
//log
|
||
|
||
pCmdIns->CommandText = szSql.AllocSysString();
|
||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||
|
||
iIndex++;
|
||
szNodeName.Empty();
|
||
if (iIndex <= 99999)
|
||
{
|
||
szNodeName.Format(_T("D%.5d"), iIndex);
|
||
}
|
||
else
|
||
{
|
||
szNodeName.Format(_T("D%d"), iIndex);
|
||
}
|
||
|
||
}
|
||
|
||
|
||
//log
|
||
m_log = "ImportTdHeadToDB------------end";
|
||
fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
fflush(m_pFile);
|
||
//log
|
||
|
||
delete pXML;
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL CTdManager::ImportCETGRToDB(DWORD dwTdID, CString szGRFile)
|
||
{
|
||
|
||
_CommandPtr pCmdIns = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szECode = _T("");
|
||
CString szDT = _T("");
|
||
CString szMDate = _T("");
|
||
CString szMTime = _T("");
|
||
CString strCode = _T("");
|
||
CString strCode1 = _T("");
|
||
|
||
int iOMValue = (int)VAL_ZERO;
|
||
int iOM1Value = (int)VAL_ZERO;
|
||
int iResCode = (int)VAL_ZERO;
|
||
int iResCode1 = (int)VAL_ZERO;
|
||
|
||
CString szTdGR = _T("");
|
||
CStringArray saTdGR;
|
||
|
||
CString szNodeName = _T("");
|
||
|
||
int iIndex = (int)VAL_ZERO;
|
||
|
||
pCmdIns.CreateInstance(_uuidof(Command));
|
||
pCmdIns->ActiveConnection = m_pConnection;
|
||
|
||
CMarkup *pXML = new CMarkup;
|
||
pXML->Load(szGRFile);
|
||
|
||
pXML->FindElem(_T("TD"));
|
||
|
||
pXML->FindChildElem("param");
|
||
|
||
pXML->FindChildElem("Data");
|
||
pXML->IntoElem();
|
||
|
||
iIndex = (int)VAL_ONE;
|
||
szNodeName.Empty();
|
||
szNodeName.Format(_T("D%.5d"), iIndex);
|
||
|
||
while (pXML->FindChildElem(szNodeName))
|
||
{
|
||
szTdGR = pXML->GetChildData();
|
||
SplitterString(saTdGR, szTdGR, _T(";"));
|
||
|
||
szECode.Empty();
|
||
szECode = saTdGR.GetAt(0);
|
||
szECode.TrimLeft();
|
||
szECode.TrimRight();
|
||
|
||
iOMValue = atoi(saTdGR.GetAt(1));
|
||
iResCode = atoi(saTdGR.GetAt(2));
|
||
|
||
iOM1Value = atoi(saTdGR.GetAt(3));
|
||
iResCode1 = atoi(saTdGR.GetAt(4));
|
||
|
||
szDT.Empty();
|
||
szDT = saTdGR.GetAt(5);
|
||
|
||
szDT.TrimLeft();
|
||
szDT.TrimRight();
|
||
|
||
szMDate.Empty();
|
||
szMDate.Format(_T("%s-%s-%s"), szDT.Mid(0, 4), szDT.Mid(4, 2), szDT.Mid(6, 2));
|
||
|
||
szMTime.Empty();
|
||
szMTime.Format(_T("%s:%s:%s"), szDT.Mid(8, 2), szDT.Mid(10, 2), szDT.Mid(12, 2));
|
||
|
||
if (szMTime == "1900-01-00")
|
||
{
|
||
szMTime = "1900-01-01";
|
||
}
|
||
|
||
if (szMDate == "1900-01-00")
|
||
{
|
||
szMDate = "1900-01-01";
|
||
}
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("insert into gr(TDID,Ecode,OMvalue,Mdate,Mtime,StatusCode,OM1value,StatusCode1) values(%u,'%s',%d,#%s#,#%s#,%d,%d,%d)"),
|
||
dwTdID, szECode, iOMValue, /*"2015-01-27"*/szMDate, /*"10:20:20"*/szMTime,iResCode, iOM1Value, iResCode1);
|
||
|
||
|
||
pCmdIns->CommandText = szSql.AllocSysString();
|
||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||
|
||
iIndex++;
|
||
szNodeName.Empty();
|
||
if (iIndex <= 99999)
|
||
{
|
||
szNodeName.Format(_T("D%.5d"), iIndex);
|
||
}
|
||
else
|
||
{
|
||
szNodeName.Format(_T("D%d"), iIndex);
|
||
}
|
||
|
||
}
|
||
|
||
delete pXML;
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL CTdManager::DeleteTdInDev(CString szPrCN, CString szTzCN, CString szTdCN, CDevice* const pDev)
|
||
{
|
||
_CommandPtr pCmdDel = NULL;
|
||
|
||
CString szOrder = _T("");
|
||
CString szResBuff = _T("");
|
||
CString szRes = _T("");
|
||
CString szSql = _T("");
|
||
CString strErr = _T("");
|
||
|
||
if (EN_TRANSFER_FILE_BY_USB == g_iTransFileMode)
|
||
{
|
||
if (CGD10OperCmd::GetInstance()->meas_delete(szPrCN, szTzCN, szTdCN))
|
||
{
|
||
szRes = _T("1");
|
||
}
|
||
else
|
||
{
|
||
szRes = _T("-1");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
szOrder.Empty();
|
||
szOrder.Format(_T("meas_delete(\"%s\",\"%s\",\"%s\")\r\n"), szPrCN, szTzCN, szTdCN);
|
||
|
||
if (!pDev->ExecuteOrder(szOrder,_T(">"),&szResBuff))
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("删除任务超时."));
|
||
else
|
||
MessageBoxEx(NULL, _T("Delete task in device timeout!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return FALSE;
|
||
}
|
||
/*
|
||
int iPollingTime = (int)VAL_ZERO;
|
||
int iResSize = (int)VAL_ZERO;
|
||
char aResBuff[2048] = {0};
|
||
|
||
pDev->m_sComPort.ClearCommSendBuff();
|
||
pDev->m_sComPort.ClearCommReceiveBuff();
|
||
pDev->m_sComPort.SendDataDirectly("\r\n", 2);
|
||
// TransDelay(g_iTransMode, 10, 50);
|
||
|
||
iResSize = (int)VAL_ZERO;
|
||
memset(aResBuff, 0, sizeof(aResBuff));
|
||
szResBuff.Empty();
|
||
iPollingTime = 0;
|
||
while ((szResBuff.Find(">") == -1) && (iPollingTime < 500))
|
||
{
|
||
|
||
while (pDev->m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
||
{
|
||
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
||
|
||
iResSize = (int)VAL_ZERO;
|
||
memset(aResBuff, 0, sizeof(aResBuff));
|
||
}
|
||
iPollingTime++;
|
||
}
|
||
|
||
if (iPollingTime == MAX_POLLING_TIME)
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
pDev->m_sComPort.ClearCommSendBuff();
|
||
pDev->m_sComPort.ClearCommReceiveBuff();
|
||
|
||
szOrder.Empty();
|
||
szOrder.Format(_T("meas_delete(\"%s\",\"%s\",\"%s\")\r\n"), szPrCN, szTzCN, szTdCN);
|
||
|
||
pDev->m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
||
szOrder.ReleaseBuffer();
|
||
|
||
// TransDelay(g_iTransMode, 100, 200);
|
||
|
||
// hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||
// AfxMessageBox(szOrder);
|
||
|
||
iResSize = (int)VAL_ZERO;
|
||
memset(aResBuff, 0, sizeof(aResBuff));
|
||
|
||
szResBuff.Empty();
|
||
iPollingTime = 0;
|
||
while ((szResBuff.Find(">") == -1) && (iPollingTime < 500))
|
||
{
|
||
// Sleep(100);
|
||
while (pDev->m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
||
{
|
||
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
||
|
||
iResSize = (int)VAL_ZERO;
|
||
memset(aResBuff, 0, sizeof(aResBuff));
|
||
}
|
||
iPollingTime++;
|
||
}
|
||
|
||
// AfxMessageBox(szResBuff);
|
||
|
||
if (MAX_POLLING_TIME == iPollingTime)
|
||
{
|
||
return FALSE;
|
||
}
|
||
*/
|
||
GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]"));
|
||
|
||
}
|
||
|
||
|
||
|
||
if (_T("1") == szRes)
|
||
{
|
||
pCmdDel.CreateInstance(_uuidof(Command));
|
||
pCmdDel->ActiveConnection = m_pConnection;
|
||
|
||
try
|
||
{
|
||
m_pConnection->BeginTrans();
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from dev_syn_td where DESN = '%s' and TdCN = '%s'"), pDev->m_szDevSN, szTdCN);
|
||
|
||
pCmdDel->CommandText = szSql.AllocSysString();
|
||
pCmdDel->Execute(NULL, NULL, adCmdText);
|
||
|
||
m_pConnection->CommitTrans();
|
||
}
|
||
catch (_com_error e)
|
||
{
|
||
strErr.Empty();
|
||
strErr.Format(_T("ErrorMsg = %s,\r\n DescMsg = %s"),(LPCTSTR)e.ErrorMessage(),(LPCTSTR)e.Description());
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
return TRUE;
|
||
}
|
||
else
|
||
{
|
||
strErr.Empty();
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strErr.Format(_T("删除任务失败!返回值 = %s"), szRes);
|
||
AfxMessageBox(strErr);
|
||
}
|
||
else
|
||
{
|
||
strErr.Format(_T("Delete task in device failed!res = %s"), szRes);
|
||
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
return FALSE;
|
||
|
||
/*
|
||
pDev->m_sComPort.ClearCommSendBuff();
|
||
pDev->m_sComPort.ClearCommReceiveBuff();
|
||
pDev->m_sComPort.SendDataDirectly("\r\n", 2);
|
||
// TransDelay(g_iTransMode, 10, 50);
|
||
|
||
iResSize = (int)VAL_ZERO;
|
||
memset(aResBuff, 0, sizeof(aResBuff));
|
||
szResBuff.Empty();
|
||
iPollingTime = 0;
|
||
while ((szResBuff.Find(">") == -1) && (iPollingTime < 3))
|
||
{
|
||
|
||
while (pDev->m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
||
{
|
||
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
||
|
||
iResSize = (int)VAL_ZERO;
|
||
memset(aResBuff, 0, sizeof(aResBuff));
|
||
}
|
||
iPollingTime++;
|
||
}
|
||
|
||
if (iPollingTime == MAX_POLLING_TIME)
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
|
||
pDev->m_sComPort.ClearCommSendBuff();
|
||
pDev->m_sComPort.ClearCommReceiveBuff();
|
||
|
||
szOrder.Empty();
|
||
szOrder.Format(_T("meas_delete(\"%s\",\"%s\",\"%s\")\r\n"), szPrCN, szTzCN, szTdCN);
|
||
|
||
pDev->m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
||
szOrder.ReleaseBuffer();
|
||
// TransDelay(g_iTransMode, 100, 200);
|
||
// hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||
// AfxMessageBox(szOrder);
|
||
|
||
iResSize = (int)VAL_ZERO;
|
||
memset(aResBuff, 0, sizeof(aResBuff));
|
||
|
||
szResBuff.Empty();
|
||
iPollingTime = 0;
|
||
while ((szResBuff.Find(">") == -1) && (iPollingTime < 3))
|
||
{
|
||
Sleep(500);
|
||
while (pDev->m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
||
{
|
||
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
||
|
||
iResSize = (int)VAL_ZERO;
|
||
memset(aResBuff, 0, sizeof(aResBuff));
|
||
}
|
||
iPollingTime++;
|
||
}
|
||
|
||
if (iPollingTime == MAX_POLLING_TIME)
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]"));
|
||
|
||
if (_T("1") == szRes)
|
||
{
|
||
pCmdDel.CreateInstance(_uuidof(Command));
|
||
pCmdDel->ActiveConnection = m_pConnection;
|
||
|
||
try
|
||
{
|
||
m_pConnection->BeginTrans();
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from dev_syn_td where DESN = '%s' and TdCN = '%s'"), pDev->m_szDevSN, szTdCN);
|
||
|
||
pCmdDel->CommandText = szSql.AllocSysString();
|
||
pCmdDel->Execute(NULL, NULL, adCmdText);
|
||
|
||
m_pConnection->CommitTrans();
|
||
}
|
||
catch (_com_error e)
|
||
{
|
||
m_pConnection->RollbackTrans();
|
||
return APP_FAIL;
|
||
}
|
||
|
||
return TRUE;
|
||
}
|
||
else
|
||
{
|
||
return FALSE;
|
||
}
|
||
*/
|
||
}
|
||
}
|
||
|
||
BOOL CTdManager::Import2DTdOrgToDB(DWORD dwTdID, CString szOrgFile, CDevice* const pDev)
|
||
{
|
||
_RecordsetPtr pRecTdCon = NULL;
|
||
_RecordsetPtr pRecChID = NULL;
|
||
_RecordsetPtr pRecTd = NULL;
|
||
_CommandPtr pCmdUpd = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szTsn = _T("");
|
||
CString szVRawData = _T("");
|
||
CString szIRawData = _T("");
|
||
|
||
CString szNodeName = _T("");
|
||
CString strText = _T("");
|
||
|
||
DWORD aChID[8] = {0};
|
||
|
||
int iIndex = (int)VAL_ZERO;
|
||
int iTsn = (int)VAL_ZERO;
|
||
int iChNum = (int)VAL_ZERO;
|
||
int iTType = (int)VAL_ZERO;
|
||
|
||
pRecTdCon.CreateInstance(_uuidof(Recordset));
|
||
pRecChID.CreateInstance(_uuidof(Recordset));
|
||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||
pCmdUpd->ActiveConnection = m_pConnection;
|
||
|
||
//获取测试数据类型
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Ttype from td where ID = %u"), dwTdID);
|
||
pRecTd->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO == pRecTd->GetRecordCount())
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strText.Format(_T("Td表中没有这个TdID(%d)"), dwTdID);
|
||
AfxMessageBox(strText);
|
||
}
|
||
else
|
||
{
|
||
strText.Format(_T("There is not TdID(%d) in td table!"), dwTdID);
|
||
MessageBoxEx(NULL, strText, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
return FALSE;
|
||
}
|
||
iTType = pRecTd->GetCollect(_T("Ttype")).lVal;
|
||
pRecTd->Close();
|
||
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID from tdchannel where TDID = %u"), dwTdID);
|
||
pRecChID->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
iIndex = (int)VAL_ZERO;
|
||
while ((short)VAL_ZERO == pRecChID->adoEOF)
|
||
{
|
||
aChID[iIndex] = pRecChID->GetCollect(_T("ID")).ulVal;
|
||
|
||
iIndex++;
|
||
pRecChID->MoveNext();
|
||
}
|
||
|
||
pRecChID->Close();
|
||
|
||
CMarkup *pXML = new CMarkup;
|
||
pXML->Load(szOrgFile);
|
||
|
||
pXML->FindElem(_T("Origin"));
|
||
int nTWCnt = 0;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select TSN from td2dcon where TCHID = %u order by TSN"), aChID[0]);
|
||
pRecTdCon->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
|
||
while ((short)VAL_ZERO == pRecTdCon->adoEOF)
|
||
{
|
||
iTsn = (int)pRecTdCon->GetCollect(_T("TSN")).lVal;
|
||
|
||
if (iTsn <= 99999)
|
||
{
|
||
szNodeName.Format(_T("D%.5d"), iTsn);
|
||
}
|
||
else
|
||
{
|
||
szNodeName.Format(_T("D%d"), iTsn);
|
||
}
|
||
bool bRes = pXML->FindChildElem(szNodeName);
|
||
if (!bRes)
|
||
{
|
||
pXML->ResetChildPos();
|
||
bRes = pXML->FindChildElem(szNodeName);
|
||
}
|
||
if (bRes)
|
||
{
|
||
pXML->IntoElem();
|
||
|
||
pXML->FindChildElem(_T("V"));
|
||
szVRawData.Empty();
|
||
szVRawData = pXML->GetChildData();
|
||
|
||
pXML->FindChildElem(_T("I"));
|
||
szIRawData.Empty();
|
||
szIRawData = pXML->GetChildData();
|
||
//如果是激电数据,则去获取激电的指标
|
||
if (1 == iTType)
|
||
{
|
||
CStringArray strIndexArray;
|
||
strIndexArray.RemoveAll();
|
||
CString strTW= _T("");
|
||
if (pXML->FindChildElem(_T("IP_Index")))
|
||
{
|
||
pXML->IntoElem();
|
||
nTWCnt = 0;
|
||
strText.Empty();
|
||
strText = pXML->GetAttrib(_T("TW_Count"));
|
||
if (!strText.IsEmpty())
|
||
{
|
||
nTWCnt = atoi(strText);
|
||
}
|
||
strText.Empty();
|
||
strText = pXML->GetAttrib(_T("Thl"));
|
||
if (!strText.IsEmpty())
|
||
{
|
||
strIndexArray.Add(strText);
|
||
}
|
||
|
||
strText.Empty();
|
||
strText = pXML->GetAttrib(_T("D"));
|
||
if (!strText.IsEmpty())
|
||
{
|
||
strIndexArray.Add(strText);
|
||
}
|
||
|
||
strText.Empty();
|
||
strText = pXML->GetAttrib(_T("r"));
|
||
if (!strText.IsEmpty())
|
||
{
|
||
strIndexArray.Add(strText);
|
||
}
|
||
|
||
strText.Empty();
|
||
strText.Format(_T("%d"),nTWCnt);
|
||
strIndexArray.Add(strText);
|
||
for (int i = 0; i < nTWCnt; i++)
|
||
{
|
||
strTW.Empty();
|
||
strTW.Format(_T("M%d"),i);
|
||
if (false == pXML->FindChildElem(strTW))
|
||
{
|
||
strText.Empty();
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strText.Format(_T("在%s文件中时间窗信息验证错误"), szOrgFile);
|
||
AfxMessageBox(strText);
|
||
}
|
||
else
|
||
{
|
||
strText.Format(_T("The information of time window verfied error in %s"), szOrgFile);
|
||
MessageBoxEx(NULL, strText, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
strIndexArray.RemoveAll();
|
||
break;
|
||
}
|
||
strText.Empty();
|
||
strText = pXML->GetChildData();
|
||
strIndexArray.Add(strText);
|
||
}
|
||
if (strIndexArray.GetSize() > 3)
|
||
{
|
||
ImportTdSpecAttr(strIndexArray, iTType, aChID[0],iTsn);
|
||
}
|
||
pXML->OutOfElem();
|
||
}
|
||
|
||
}
|
||
|
||
pXML->OutOfElem();
|
||
|
||
if ((szVRawData.GetLength() != (int)VAL_ZERO) && (szIRawData.GetLength() != (int)VAL_ZERO))
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("update td2dcon set Vrawdata = ?, Irawdata = ? where TCHID = %u and TSN = %d"), aChID[0], iTsn);
|
||
|
||
//log
|
||
// CTime t;
|
||
// t = CTime::GetCurrentTime();
|
||
// m_log = t.Format("%Y-%m-%d,%H:%M:%S:");
|
||
// m_log += "\r\n";
|
||
// m_log += szSql;
|
||
// m_log += "\r\n";
|
||
// fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
// fflush(m_pFile);
|
||
//log
|
||
|
||
pCmdUpd->CommandType =adCmdText;
|
||
pCmdUpd->CommandText = szSql.AllocSysString();
|
||
|
||
pCmdUpd->Parameters->Append(pCmdUpd->CreateParameter("Vrawdata", adBSTR, adParamInput, szSql.GetLength(), _variant_t(szVRawData.AllocSysString())));
|
||
pCmdUpd->Parameters->Append(pCmdUpd->CreateParameter("Irawdata", adBSTR, adParamInput, szSql.GetLength(), _variant_t(szIRawData.AllocSysString())));
|
||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||
|
||
if (pCmdUpd->Parameters->GetCount() != VAL_ZERO)
|
||
{
|
||
pCmdUpd->Parameters->Delete(_variant_t("Vrawdata"));
|
||
pCmdUpd->Parameters->Delete(_variant_t("Irawdata"));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strText.Format(_T("(%s) Vrawdata和Irawdata都不能为空!TCHID = %d"), szNodeName, aChID[0]);
|
||
AfxMessageBox(strText);
|
||
}
|
||
else
|
||
{
|
||
strText.Format(_T("(%s)Neither Vrawdata nor Irawdata can be empty!TCHID = %d"), szNodeName, aChID[0]);
|
||
MessageBoxEx(NULL, strText, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
pRecTdCon->Close();
|
||
delete pXML;
|
||
return FALSE;
|
||
|
||
}
|
||
}
|
||
|
||
pRecTdCon->MoveNext();
|
||
|
||
}
|
||
pRecTdCon->Close();
|
||
|
||
|
||
delete pXML;
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL CTdManager::ImportCETdOrgToDB(DWORD dwTdID, CString szOrgFile, CDevice* const pDev)
|
||
{
|
||
_RecordsetPtr pRecTdCon = NULL;
|
||
_RecordsetPtr pRecChID = NULL;
|
||
_RecordsetPtr pRecTd = NULL;
|
||
_CommandPtr pCmdUpd = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szTsn = _T("");
|
||
CString szVRawData = _T("");
|
||
CString szIRawData = _T("");
|
||
CString strText = _T("");
|
||
|
||
CString szNodeName = _T("");
|
||
|
||
DWORD aChID[8] = {0};
|
||
|
||
int iIndex = (int)VAL_ZERO;
|
||
int iTsn = (int)VAL_ZERO;
|
||
int iChNum = (int)VAL_ZERO;
|
||
int iTType = (int)VAL_ZERO;
|
||
|
||
pRecTdCon.CreateInstance(_uuidof(Recordset));
|
||
pRecChID.CreateInstance(_uuidof(Recordset));
|
||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||
|
||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||
pCmdUpd->ActiveConnection = m_pConnection;
|
||
|
||
|
||
//获取测试数据类型
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Ttype from td where ID = %u"), dwTdID);
|
||
pRecTd->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO == pRecTd->GetRecordCount())
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strText.Format(_T("Td表中没有这个TdID(%d)"), dwTdID);
|
||
AfxMessageBox(strText);
|
||
}
|
||
else
|
||
{
|
||
strText.Format(_T("There is not TdID(%d) in td table!"), dwTdID);
|
||
MessageBoxEx(NULL, strText, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
return FALSE;
|
||
}
|
||
iTType = pRecTd->GetCollect(_T("Ttype")).lVal;
|
||
pRecTd->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID from tdchannel where TDID = %u"), dwTdID);
|
||
pRecChID->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
iIndex = (int)VAL_ZERO;
|
||
while ((short)VAL_ZERO == pRecChID->adoEOF)
|
||
{
|
||
aChID[iIndex] = pRecChID->GetCollect(_T("ID")).ulVal;
|
||
|
||
iIndex++;
|
||
pRecChID->MoveNext();
|
||
}
|
||
|
||
pRecChID->Close();
|
||
|
||
CMarkup *pXML = new CMarkup;
|
||
pXML->Load(szOrgFile);
|
||
|
||
pXML->FindElem(_T("Origin"));
|
||
int nTWCnt = 0;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select TSN from td1dcon where TCHID = %u order by TSN"), aChID[0]);
|
||
pRecTdCon->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
|
||
while ((short)VAL_ZERO == pRecTdCon->adoEOF)
|
||
{
|
||
iTsn = (int)pRecTdCon->GetCollect(_T("TSN")).lVal;
|
||
|
||
szNodeName.Empty();
|
||
if (iTsn <= 99999)
|
||
{
|
||
szNodeName.Format(_T("D%.5d"), iTsn);
|
||
}
|
||
else
|
||
{
|
||
szNodeName.Format(_T("D%d"), iTsn);
|
||
}
|
||
bool bRes = pXML->FindChildElem(szNodeName);
|
||
if (!bRes)
|
||
{
|
||
pXML->ResetChildPos();
|
||
bRes = pXML->FindChildElem(szNodeName);
|
||
}
|
||
if (bRes)
|
||
{
|
||
pXML->IntoElem();
|
||
|
||
pXML->FindChildElem(_T("V"));
|
||
szVRawData.Empty();
|
||
szVRawData = pXML->GetChildData();
|
||
|
||
pXML->FindChildElem(_T("I"));
|
||
szIRawData.Empty();
|
||
szIRawData = pXML->GetChildData();
|
||
|
||
//如果是激电数据,则去获取激电的指标
|
||
if (1 == iTType)
|
||
{
|
||
CStringArray strIndexArray;
|
||
strIndexArray.RemoveAll();
|
||
CString strTW= _T("");
|
||
if (pXML->FindChildElem(_T("IP_Index")))
|
||
{
|
||
pXML->IntoElem();
|
||
nTWCnt = 0;
|
||
strText.Empty();
|
||
strText = pXML->GetAttrib(_T("TW_Count"));
|
||
if (!strText.IsEmpty())
|
||
{
|
||
nTWCnt = atoi(strText);
|
||
}
|
||
strText.Empty();
|
||
strText = pXML->GetAttrib(_T("Thl"));
|
||
if (!strText.IsEmpty())
|
||
{
|
||
strIndexArray.Add(strText);
|
||
}
|
||
|
||
strText.Empty();
|
||
strText = pXML->GetAttrib(_T("D"));
|
||
if (!strText.IsEmpty())
|
||
{
|
||
strIndexArray.Add(strText);
|
||
}
|
||
|
||
strText.Empty();
|
||
strText = pXML->GetAttrib(_T("r"));
|
||
if (!strText.IsEmpty())
|
||
{
|
||
strIndexArray.Add(strText);
|
||
}
|
||
|
||
strText.Empty();
|
||
strText.Format(_T("%d"),nTWCnt);
|
||
strIndexArray.Add(strText);
|
||
for (int i = 0; i < nTWCnt; i++)
|
||
{
|
||
strTW.Empty();
|
||
strTW.Format(_T("M%d"),i);
|
||
if (false == pXML->FindChildElem(strTW))
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strText.Format(_T("在%s文件中时间窗信息验证错误"), szOrgFile);
|
||
AfxMessageBox(strText);
|
||
}
|
||
else
|
||
{
|
||
strText.Format(_T("The information of time window verfied error in %s"), szOrgFile);
|
||
MessageBoxEx(NULL, strText, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
strIndexArray.RemoveAll();
|
||
break;
|
||
}
|
||
strText.Empty();
|
||
strText = pXML->GetChildData();
|
||
strIndexArray.Add(strText);
|
||
}
|
||
if (strIndexArray.GetSize() > 3)
|
||
{
|
||
ImportTdSpecAttr(strIndexArray, iTType, aChID[0], iTsn);
|
||
}
|
||
pXML->OutOfElem();
|
||
}
|
||
|
||
}
|
||
|
||
pXML->OutOfElem();
|
||
|
||
if ((szVRawData.GetLength() != (int)VAL_ZERO) && (szIRawData.GetLength() != (int)VAL_ZERO))
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("update td1dcon set Vrawdata = ?, Irawdata = ? where TCHID = %u and TSN = %d"), aChID[0], iTsn);
|
||
|
||
//log
|
||
CTime t;
|
||
t = CTime::GetCurrentTime();
|
||
m_log = t.Format("%Y-%m-%d,%H:%M:%S:");
|
||
m_log += "\r\n";
|
||
m_log += szSql;
|
||
m_log += "\r\n";
|
||
// fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
// fflush(m_pFile);
|
||
//log
|
||
|
||
pCmdUpd->CommandType =adCmdText;
|
||
pCmdUpd->CommandText = szSql.AllocSysString();
|
||
|
||
pCmdUpd->Parameters->Append(pCmdUpd->CreateParameter("Vrawdata", adBSTR, adParamInput, szSql.GetLength(), _variant_t(szVRawData.AllocSysString())));
|
||
pCmdUpd->Parameters->Append(pCmdUpd->CreateParameter("Irawdata", adBSTR, adParamInput, szSql.GetLength(), _variant_t(szIRawData.AllocSysString())));
|
||
|
||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||
|
||
if (pCmdUpd->Parameters->GetCount() != VAL_ZERO)
|
||
{
|
||
pCmdUpd->Parameters->Delete(_variant_t("Vrawdata"));
|
||
pCmdUpd->Parameters->Delete(_variant_t("Irawdata"));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strText.Format(_T("(%s) Vrawdata和Irawdata都不能为空!TCHID = %d"), szNodeName, aChID[0]);
|
||
AfxMessageBox(strText);
|
||
}
|
||
else
|
||
{
|
||
strText.Format(_T("(%s)Neither Vrawdata nor Irawdata can be empty!TCHID = %d"), szNodeName, aChID[0]);
|
||
MessageBoxEx(NULL, strText, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
pRecTdCon->Close();
|
||
delete pXML;
|
||
return FALSE;
|
||
|
||
}
|
||
}
|
||
|
||
pRecTdCon->MoveNext();
|
||
}
|
||
pRecTdCon->Close();
|
||
|
||
delete pXML;
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL CTdManager::Convert2DTo3D(DWORD dwTzHandle)
|
||
{
|
||
long lRet = VAL_ZERO;
|
||
int iIndex = (int)VAL_ZERO;
|
||
int iCableCount = (int)VAL_ZERO;
|
||
|
||
int iMedium = (int)VAL_ZERO;
|
||
|
||
int iPoleCount = (int)VAL_ZERO;
|
||
|
||
int iRowCount = (int)VAL_ZERO;
|
||
int iColCount = (int)VAL_ZERO;
|
||
|
||
float fRowSpacing = (float)VAL_ZERO;
|
||
float fColSpacing = (float)VAL_ZERO;
|
||
|
||
int iTPCount = (int)VAL_ZERO;
|
||
|
||
int iC1 = (int)VAL_ZERO;
|
||
int iC2 = (int)VAL_ZERO;
|
||
int iP1 = (int)VAL_ZERO;
|
||
int iP2 = (int)VAL_ZERO;
|
||
|
||
float fR0 = (float)VAL_ZERO;
|
||
|
||
DWORD dwTdHandle = (DWORD)VAL_ZERO;
|
||
|
||
DWORD dwTdID = (DWORD)VAL_ZERO;
|
||
DWORD dwChID = (DWORD)VAL_ZERO;
|
||
|
||
CString szValue = _T("");
|
||
CString szFile = _T("");
|
||
|
||
_RecordsetPtr pRecCh = NULL;
|
||
_RecordsetPtr pRecTdCon = NULL;
|
||
|
||
CString szSql = _T("");
|
||
|
||
CString szCurFilePath = _T("");
|
||
|
||
CFileDialog* pDlgSaveFile = new CFileDialog(FALSE, "dat", "", OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY |OFN_NOCHANGEDIR, "DAT file(*.dat)|*.dat||", AfxGetMainWnd());
|
||
|
||
CRes3DDatFile* pRes3DDatFile = new CRes3DDatFile;
|
||
COpTd2DTo3DDlg* pOpTd2DTo3DDlg = new COpTd2DTo3DDlg(this, dwTzHandle);
|
||
|
||
pOpTd2DTo3DDlg->Create(IDD_OP_TD_2DTO3D, AfxGetMainWnd());
|
||
this->InitialTd2DTo3DDlg(pOpTd2DTo3DDlg);
|
||
|
||
pOpTd2DTo3DDlg->ShowWindow(SW_SHOW);
|
||
lRet = pOpTd2DTo3DDlg->RunModalLoop(MLF_SHOWONIDLE);
|
||
|
||
if (RET_OK == lRet)
|
||
{
|
||
szCurFilePath.Empty();
|
||
szCurFilePath.GetBufferSetLength(256);
|
||
::GetCurrentDirectory(szCurFilePath.GetLength(), szCurFilePath.GetBuffer(szCurFilePath.GetLength()));
|
||
szCurFilePath.ReleaseBuffer();
|
||
|
||
pDlgSaveFile->m_ofn.lpstrTitle = _T("Save");
|
||
pDlgSaveFile->m_ofn.lpstrInitialDir = szCurFilePath;
|
||
|
||
if (pDlgSaveFile->DoModal() == IDOK)
|
||
{
|
||
szFile.Empty();
|
||
szFile = pDlgSaveFile->GetPathName();
|
||
|
||
pRecCh.CreateInstance(_uuidof(Recordset));
|
||
pRecTdCon.CreateInstance(_uuidof(Recordset));
|
||
|
||
szValue.Empty();
|
||
pOpTd2DTo3DDlg->m_edTitle.GetWindowText(szValue);
|
||
pRes3DDatFile->SetTitle(szValue);
|
||
|
||
|
||
iMedium = (int)pOpTd2DTo3DDlg->m_cbMedium.GetItemData(pOpTd2DTo3DDlg->m_cbMedium.GetCurSel());
|
||
pRes3DDatFile->SetMedium(iMedium);
|
||
|
||
szValue.Empty();
|
||
pOpTd2DTo3DDlg->m_edPoleSpace.GetWindowText(szValue);
|
||
fColSpacing = (float)atof(szValue);
|
||
|
||
szValue.Empty();
|
||
pOpTd2DTo3DDlg->m_edRowSpace.GetWindowText(szValue);
|
||
fRowSpacing = (float)atof(szValue);
|
||
|
||
pRes3DDatFile->SetSpacing(fRowSpacing, fColSpacing);
|
||
|
||
iTPCount = (int)VAL_ZERO;
|
||
iCableCount = (int)VAL_ZERO;
|
||
iIndex = (int)VAL_ZERO;
|
||
pRes3DDatFile->ClearAllRecord();
|
||
|
||
while (iIndex < pOpTd2DTo3DDlg->m_tdList.GetItemCount())
|
||
{
|
||
if (TRUE == pOpTd2DTo3DDlg->m_tdList.GetCheck(iIndex))
|
||
{
|
||
iCableCount ++;
|
||
|
||
dwTdHandle = pOpTd2DTo3DDlg->m_tdList.GetItemData(iIndex);
|
||
dwTdID = this->m_handleProcessor.GetIDFromHandle(dwTdHandle);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID from tdchannel where TDID = %u"), dwTdID);
|
||
pRecCh->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
if ((long)VAL_ZERO != pRecCh->GetRecordCount())
|
||
{
|
||
dwChID = (DWORD)pRecCh->GetCollect(_T("ID")).ulVal;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select C1,C2,P1,P2,R0 from td2dcon where TCHID = %u order by TSN"), dwChID);
|
||
pRecTdCon->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
while ((short)VAL_ZERO == pRecTdCon->adoEOF)
|
||
{
|
||
iC1 = (int)pRecTdCon->GetCollect(_T("C1")).iVal;
|
||
iC2 = (int)pRecTdCon->GetCollect(_T("C2")).iVal;
|
||
iP1 = (int)pRecTdCon->GetCollect(_T("P1")).iVal;
|
||
iP2 = (int)pRecTdCon->GetCollect(_T("P2")).iVal;
|
||
|
||
fR0 = (float)pRecTdCon->GetCollect(_T("R0")).fltVal;
|
||
pRes3DDatFile->AddRecord(iCableCount, iC1, iC2, iP1, iP2, fR0);
|
||
|
||
pRecTdCon->MoveNext();
|
||
}
|
||
|
||
pRecTdCon->Close();
|
||
}
|
||
|
||
pRecCh->Close();
|
||
|
||
}
|
||
iIndex ++;
|
||
}
|
||
|
||
szValue.Empty();
|
||
pOpTd2DTo3DDlg->m_edPoleCount.GetWindowText(szValue);
|
||
iPoleCount = atoi(szValue);
|
||
|
||
pRes3DDatFile->SetGriding(iCableCount, iPoleCount);
|
||
|
||
pRes3DDatFile->Generate(szFile);
|
||
|
||
}
|
||
|
||
}
|
||
|
||
delete pOpTd2DTo3DDlg;
|
||
delete pRes3DDatFile;
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL CTdManager::InitialTd2DTo3DDlg(COpTd2DTo3DDlg *pOpTd2DTo3DDlg)
|
||
{
|
||
_RecordsetPtr pRecMed = NULL;
|
||
CString szSql = _T("");
|
||
|
||
int iIndex = (int)VAL_ZERO;
|
||
|
||
pRecMed.CreateInstance(_uuidof(Recordset));
|
||
|
||
pOpTd2DTo3DDlg->m_cbMedium.ResetContent();
|
||
|
||
iIndex = (int)VAL_ZERO;
|
||
szSql.Empty();
|
||
szSql.Format(_T("select AR,MEname from medium where LANG = %d and AR in (1,2,3,4,5,9,11)"), g_iLanguage);
|
||
|
||
pRecMed->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
while ((short)VAL_ZERO == pRecMed->adoEOF)
|
||
{
|
||
iIndex = pOpTd2DTo3DDlg->m_cbMedium.AddString((LPCTSTR)(_bstr_t)pRecMed->GetCollect(_T("MEname")));
|
||
pOpTd2DTo3DDlg->m_cbMedium.SetItemData(iIndex, (DWORD)pRecMed->GetCollect(_T("AR")).ulVal);
|
||
pRecMed->MoveNext();
|
||
}
|
||
|
||
pRecMed->Close();
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL CTdManager::Upload3DTdFromDev(CString szPrCN, CString szTzCN, CString szTdCN, CString strSubTdCN, CDevice* const pDev)
|
||
{
|
||
DWORD dwTzID = (DWORD)VAL_ZERO;
|
||
DWORD dwTdID = (DWORD)VAL_ZERO;
|
||
|
||
_RecordsetPtr pRecTdID = NULL;
|
||
_RecordsetPtr pRecTzID = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szLocFilePath = _T("");
|
||
CString szFileName = _T("");
|
||
CString szHostPath = _T("");
|
||
|
||
_CommandPtr pCmdUpd = NULL;
|
||
|
||
pRecTdID.CreateInstance(_uuidof(Recordset));
|
||
pRecTzID.CreateInstance(_uuidof(Recordset));
|
||
|
||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||
pCmdUpd->ActiveConnection = m_pConnection;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID from td where TdCN = '%s' and DESN = '%s'"), szTdCN, pDev->m_szDevSN);
|
||
pRecTdID->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecTdID->GetRecordCount())
|
||
{
|
||
pRecTdID->Close();
|
||
return FALSE;
|
||
}
|
||
pRecTdID->Close();
|
||
|
||
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 += "\\";
|
||
|
||
szFileName.Empty();
|
||
szFileName = szTdCN + _T(".xml");
|
||
szHostPath = _T("/SD/projects/") + szPrCN + _T("/") + szTzCN;
|
||
|
||
//计算出总任务的个数,用于界面显示进度
|
||
CString strSaveSubTdCN = strSubTdCN;
|
||
CString strTemp;
|
||
int iTaskCount = 0;
|
||
int iDefaultTotalFileNum = 4;
|
||
if (!strSubTdCN.IsEmpty())
|
||
{
|
||
int iPos = -1;
|
||
strTemp = strSubTdCN;
|
||
do
|
||
{
|
||
iTaskCount++;
|
||
iPos = strTemp.Find(',');
|
||
if (iPos > 0)
|
||
strTemp = strTemp.Mid(iPos + 1);
|
||
} while (iPos > 0);
|
||
iDefaultTotalFileNum = (iTaskCount + 1) * 4;
|
||
}
|
||
CTaskProgressDlg *pTaskProgessDlg = NULL;
|
||
pTaskProgessDlg = new CTaskProgressDlg(FALSE, iDefaultTotalFileNum, pDev);
|
||
pTaskProgessDlg->Create(IDD_TASK_PROGRESS);
|
||
pTaskProgessDlg->ShowWindow(SW_SHOW);
|
||
|
||
HWND hWnd = pTaskProgessDlg->m_hWnd;
|
||
|
||
string strRawPath = CDetcGD10Dev::GetInstance()->GetGD10DevAddr() + szHostPath;
|
||
strRawPath.append("/");
|
||
string strFindPath = strRawPath;
|
||
strFindPath.append(szTdCN + "*.*");
|
||
WIN32_FIND_DATAA winFindData;
|
||
HANDLE hTemp = FindFirstFileA(strFindPath.c_str(), &winFindData);
|
||
if (INVALID_HANDLE_VALUE != hTemp)
|
||
{
|
||
do
|
||
{
|
||
string strOldName = winFindData.cFileName;
|
||
if ("." == strOldName || ".." == strOldName)
|
||
continue;
|
||
if (winFindData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
|
||
{
|
||
continue;
|
||
}
|
||
strOldName = strRawPath;
|
||
strOldName.append(winFindData.cFileName);
|
||
CString dst = szLocFilePath + winFindData.cFileName;
|
||
CopyFileExA(strOldName.c_str(), dst, nullptr, this, nullptr, 0);
|
||
} while (FindNextFileA(hTemp, &winFindData));
|
||
FindClose(hTemp);
|
||
}
|
||
|
||
CString strTDCNTemp = _T("");
|
||
try
|
||
{
|
||
m_pConnection->BeginTrans();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID from tz where CN = '%s'"), szTzCN);
|
||
pRecTzID->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecTzID->GetRecordCount())
|
||
{
|
||
dwTzID = pRecTzID->GetCollect(_T("ID")).ulVal;
|
||
}
|
||
pRecTzID->Close();
|
||
|
||
::SendMessage(hWnd, WM_UPDATE_TIPS, 0, (LPARAM)(LPCTSTR)(szFileName));
|
||
|
||
dwTdID = this->ImportTdHeadToDB(dwTzID, szLocFilePath + szFileName, pDev);
|
||
|
||
strTDCNTemp = szTdCN;
|
||
int pTSN = (int)VAL_ONE;
|
||
do
|
||
{
|
||
szFileName.Empty();
|
||
szFileName = strTDCNTemp + _T(".dat");
|
||
|
||
::SendMessage(hWnd, WM_UPDATE_TIPS, 0, (LPARAM)(LPCTSTR)(szFileName));
|
||
|
||
if (TRUE == this->Import3DTdConToDB(dwTdID, szLocFilePath + szFileName, pDev, &pTSN))
|
||
{
|
||
szFileName.Empty();
|
||
szFileName = strTDCNTemp + _T(".org");
|
||
|
||
::SendMessage(hWnd, WM_UPDATE_TIPS, 0, (LPARAM)(LPCTSTR)(szFileName));
|
||
|
||
if (TRUE == this->Import3DTdOrgToDB(dwTdID, szLocFilePath + szFileName, pDev))
|
||
{
|
||
//test111,为了做测试,暂时不删除源文件
|
||
}
|
||
else
|
||
{
|
||
if (pTaskProgessDlg)
|
||
{
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
}
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (pTaskProgessDlg)
|
||
{
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
}
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
|
||
//遍历子任务节点
|
||
strTDCNTemp.Empty();
|
||
if (!strSubTdCN.IsEmpty())
|
||
{
|
||
int iPos = strSubTdCN.Find(',');
|
||
if (iPos > 0)
|
||
{
|
||
strTDCNTemp = strSubTdCN.Mid(0, iPos);
|
||
strSubTdCN = strSubTdCN.Mid(iPos + 1);
|
||
}
|
||
else
|
||
{
|
||
strTDCNTemp = strSubTdCN;
|
||
strSubTdCN.Empty();
|
||
}
|
||
}
|
||
} while (!strTDCNTemp.IsEmpty());
|
||
|
||
/*szFileName.Empty();
|
||
szFileName = szTdCN + _T(".res");
|
||
szHostFile = _T("/SD/projects/") + szPrCN + _T("/") + szTzCN + _T("/") + szFileName;*/
|
||
|
||
if (strSaveSubTdCN.IsEmpty())
|
||
{
|
||
szFileName.Empty();
|
||
szFileName = szTdCN + _T(".res");
|
||
}
|
||
else
|
||
{
|
||
int iPos = -1;
|
||
iPos = strSaveSubTdCN.ReverseFind(',');
|
||
if (iPos != -1)
|
||
{
|
||
strSaveSubTdCN = strSaveSubTdCN.Mid(iPos + 1);
|
||
}
|
||
szFileName.Empty();
|
||
szFileName = strSaveSubTdCN + _T(".res");
|
||
}
|
||
|
||
::SendMessage(hWnd, WM_UPDATE_TIPS, 0, (LPARAM)(LPCTSTR)(szFileName));
|
||
|
||
if (TRUE != this->Import3DGRToDB(dwTdID, szLocFilePath + szFileName, pDev))
|
||
{
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
szSql.Empty();
|
||
szSql.Format(_T("update dev_syn_td set IsSyned = true where DESN = '%s' and TdCN = '%s'"), pDev->m_szDevSN, szTdCN);
|
||
pCmdUpd->CommandText = szSql.AllocSysString();
|
||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||
|
||
m_pConnection->CommitTrans();
|
||
}
|
||
catch (_com_error e)
|
||
{
|
||
if (pTaskProgessDlg)
|
||
{
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
}
|
||
hHook = SetWindowsHookEx(WH_CBT, (HOOKPROC)CBTHookProc, AfxGetInstanceHandle(), NULL);
|
||
AfxMessageBox(e.Description());
|
||
m_pConnection->RollbackTrans();
|
||
return FALSE;
|
||
}
|
||
|
||
if (pTaskProgessDlg)
|
||
{
|
||
pTaskProgessDlg->DestroyWindow();
|
||
delete pTaskProgessDlg;
|
||
pTaskProgessDlg = NULL;
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL CTdManager::UploadWellTdFromDev(CString szPrCN, CString szTzCN, CString szTdCN, CString strSubTdCN, CDevice* const pDev)
|
||
{
|
||
BOOL bXmlRes = FALSE;
|
||
CString strLocalXmlFilePath = _T("");
|
||
CString strLocalDatFilePath = _T("");
|
||
|
||
CString strCurrentPath = _T("");
|
||
CString strSrcXmlFilePath = _T("");
|
||
CString strSrcDatFilePath = _T("");
|
||
CString strSDRecordDir = _T("");
|
||
strSDRecordDir = CDetcGD10Dev::GetInstance()->GetGD10DevAddr();
|
||
strSrcXmlFilePath.Format(_T("%sSD/projects/%s/%s/%s.xml"), strSDRecordDir, szPrCN, szTzCN, szTdCN);
|
||
strSrcDatFilePath.Format(_T("%sSD/projects/%s/%s/%s.dat"), strSDRecordDir, szPrCN, szTzCN, szTdCN);
|
||
|
||
char szFilePath[MAX_PATH] = { 0 };
|
||
GetModuleFileName(NULL, szFilePath, MAX_PATH);
|
||
|
||
strCurrentPath = szFilePath;
|
||
int iFlag = strCurrentPath.ReverseFind('\\');
|
||
if (iFlag != -1)
|
||
{
|
||
strCurrentPath = strCurrentPath.Mid(0, iFlag);
|
||
}
|
||
else
|
||
{
|
||
iFlag = strCurrentPath.ReverseFind('/');
|
||
if (iFlag != -1)
|
||
{
|
||
strCurrentPath = strCurrentPath.Mid(0, iFlag);
|
||
}
|
||
}
|
||
|
||
strLocalXmlFilePath.Format(_T("%s/logging/%s.xml"), strCurrentPath, szTdCN);
|
||
strLocalDatFilePath.Format(_T("%s/logging/%s.dat"), strCurrentPath, szTdCN);
|
||
|
||
CString strErr;
|
||
int iTimes = 0;
|
||
do
|
||
{
|
||
bXmlRes = CopyFile(strSrcXmlFilePath, strLocalXmlFilePath, FALSE);
|
||
if (false == bXmlRes)
|
||
{
|
||
strErr.Format(_T("CTdManager::UploadWellTdFromDev CopyFile %s file failed!,code=%d"), strSrcXmlFilePath, GetLastError());
|
||
CFileOperTools::GetInstance()->WriteComLog(strErr);
|
||
Sleep(5000);
|
||
}
|
||
iTimes++;
|
||
} while (!bXmlRes && (iTimes <= 3));
|
||
|
||
if (bXmlRes == false && iTimes > 3)
|
||
{
|
||
strErr.Format(_T("CTdManager::UploadWellTdFromDev CopyFile %s file failed!,code=%d"), strSrcXmlFilePath, GetLastError());
|
||
CFileOperTools::GetInstance()->WriteComLog(strErr);
|
||
return bXmlRes;
|
||
}
|
||
|
||
iTimes = 0;
|
||
do
|
||
{
|
||
bXmlRes = CopyFile(strSrcDatFilePath, strLocalDatFilePath, FALSE);
|
||
if (false == bXmlRes)
|
||
{
|
||
strErr.Format(_T("CTdManager::UploadWellTdFromDev CopyFile %s file failed!,code=%d"), strSrcDatFilePath, GetLastError());
|
||
CFileOperTools::GetInstance()->WriteComLog(strErr);
|
||
Sleep(5000);
|
||
}
|
||
iTimes++;
|
||
} while (!bXmlRes && (iTimes <= 3));
|
||
|
||
if (bXmlRes == false && iTimes > 3)
|
||
{
|
||
strErr.Format(_T("CTdManager::UploadWellTdFromDev CopyFile %s file failed!,code=%d"), strSrcDatFilePath, GetLastError());
|
||
CFileOperTools::GetInstance()->WriteComLog(strErr);
|
||
return bXmlRes;
|
||
}
|
||
|
||
return bXmlRes;
|
||
}
|
||
|
||
BOOL CTdManager::Import3DTdOrgToDB(DWORD dwTdID, CString szOrgFile, CDevice* const pDev)
|
||
{
|
||
_RecordsetPtr pRecTdCon = NULL;
|
||
_RecordsetPtr pRecChID = NULL;
|
||
_RecordsetPtr pRecTd = NULL;
|
||
_CommandPtr pCmdUpd = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szTsn = _T("");
|
||
CString szVRawData = _T("");
|
||
CString szIRawData = _T("");
|
||
|
||
CString szNodeName = _T("");
|
||
CString strShowInfo = _T("");
|
||
CString strText = _T("");
|
||
|
||
DWORD aChID[8] = {0};
|
||
|
||
int iIndex = (int)VAL_ZERO;
|
||
int iTsn = (int)VAL_ZERO;
|
||
int iChNum = (int)VAL_ZERO;
|
||
int iTType = (int)VAL_ZERO;
|
||
|
||
pRecTdCon.CreateInstance(_uuidof(Recordset));
|
||
pRecChID.CreateInstance(_uuidof(Recordset));
|
||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||
|
||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||
pCmdUpd->ActiveConnection = m_pConnection;
|
||
|
||
//获取测试数据类型
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Ttype from td where ID = %u"), dwTdID);
|
||
pRecTd->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO == pRecTd->GetRecordCount())
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strText.Format(_T("Td表中没有这个TdID(%d)"), dwTdID);
|
||
AfxMessageBox(strText);
|
||
}
|
||
else
|
||
{
|
||
strText.Format(_T("There is not TdID(%d) in td table!"), dwTdID);
|
||
MessageBoxEx(NULL, strText, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
return FALSE;
|
||
}
|
||
iTType = pRecTd->GetCollect(_T("Ttype")).lVal;
|
||
pRecTd->Close();
|
||
|
||
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID from tdchannel where TDID = %u"), dwTdID);
|
||
pRecChID->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
iIndex = (int)VAL_ZERO;
|
||
while ((short)VAL_ZERO == pRecChID->adoEOF)
|
||
{
|
||
aChID[iIndex] = pRecChID->GetCollect(_T("ID")).ulVal;
|
||
|
||
iIndex++;
|
||
pRecChID->MoveNext();
|
||
}
|
||
|
||
pRecChID->Close();
|
||
|
||
CMarkup *pXML = new CMarkup;
|
||
pXML->Load(szOrgFile);
|
||
|
||
pXML->FindElem(_T("Origin"));
|
||
|
||
int nTWCnt = 0;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select TSN from td3dcon where TCHID = %u order by TSN"), aChID[0]);
|
||
pRecTdCon->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
|
||
while ((short)VAL_ZERO == pRecTdCon->adoEOF)
|
||
{
|
||
iTsn = (int)pRecTdCon->GetCollect(_T("TSN")).lVal;
|
||
|
||
if (iTsn <= 99999)
|
||
{
|
||
szNodeName.Format(_T("D%.5d"), iTsn);
|
||
}
|
||
else
|
||
{
|
||
szNodeName.Format(_T("D%d"), iTsn);
|
||
}
|
||
bool bRes = pXML->FindChildElem(szNodeName);
|
||
if (!bRes)
|
||
{
|
||
pXML->ResetChildPos();
|
||
bRes = pXML->FindChildElem(szNodeName);
|
||
}
|
||
if (bRes)
|
||
{
|
||
pXML->IntoElem();
|
||
|
||
if (!pXML->FindChildElem(_T("V")))
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strShowInfo.Format(_T("无法在%s和tchid = %u行中找到vrawdata"), szNodeName.GetBuffer(0), aChID[0]);
|
||
AfxMessageBox(strShowInfo.GetBuffer(0));
|
||
}
|
||
else
|
||
{
|
||
strShowInfo.Format(_T("Can not found vrawdata in row %s and tchid = %u"), szNodeName.GetBuffer(0), aChID[0]);
|
||
MessageBoxEx(NULL, strShowInfo, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
}
|
||
|
||
szVRawData.Empty();
|
||
szVRawData = pXML->GetChildData();
|
||
|
||
if(!pXML->FindChildElem(_T("I")))
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strShowInfo.Format(_T("无法在%s和tchid = %u行中找到vrawdata"), szNodeName.GetBuffer(0), aChID[0]);
|
||
AfxMessageBox(strShowInfo.GetBuffer(0));
|
||
}
|
||
else
|
||
{
|
||
strShowInfo.Format(_T("Can not found vrawdata in row %s and tchid = %u"), szNodeName.GetBuffer(0), aChID[0]);
|
||
MessageBoxEx(NULL, strShowInfo, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
}
|
||
szIRawData.Empty();
|
||
szIRawData = pXML->GetChildData();
|
||
|
||
//如果是激电数据,则去获取激电的指标
|
||
if (1 == iTType)
|
||
{
|
||
CStringArray strIndexArray;
|
||
strIndexArray.RemoveAll();
|
||
CString strTW= _T("");
|
||
if (pXML->FindChildElem(_T("IP_Index")))
|
||
{
|
||
pXML->IntoElem();
|
||
nTWCnt = 0;
|
||
strText.Empty();
|
||
strText = pXML->GetAttrib(_T("TW_Count"));
|
||
if (!strText.IsEmpty())
|
||
{
|
||
nTWCnt = atoi(strText);
|
||
}
|
||
strText.Empty();
|
||
strText = pXML->GetAttrib(_T("Thl"));
|
||
if (!strText.IsEmpty())
|
||
{
|
||
strIndexArray.Add(strText);
|
||
}
|
||
|
||
strText.Empty();
|
||
strText = pXML->GetAttrib(_T("D"));
|
||
if (!strText.IsEmpty())
|
||
{
|
||
strIndexArray.Add(strText);
|
||
}
|
||
|
||
strText.Empty();
|
||
strText = pXML->GetAttrib(_T("r"));
|
||
if (!strText.IsEmpty())
|
||
{
|
||
strIndexArray.Add(strText);
|
||
}
|
||
|
||
strText.Empty();
|
||
strText.Format(_T("%d"),nTWCnt);
|
||
strIndexArray.Add(strText);
|
||
for (int i = 0; i < nTWCnt; i++)
|
||
{
|
||
strTW.Empty();
|
||
strTW.Format(_T("M%d"),i);
|
||
if (false == pXML->FindChildElem(strTW))
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strText.Format(_T("在%s文件中时间窗信息验证错误"), szOrgFile);
|
||
AfxMessageBox(strText);
|
||
}
|
||
else
|
||
{
|
||
strText.Format(_T("The information of time window verfied error in %s"), szOrgFile);
|
||
MessageBoxEx(NULL, strText, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
strIndexArray.RemoveAll();
|
||
break;
|
||
}
|
||
strText.Empty();
|
||
strText = pXML->GetChildData();
|
||
strIndexArray.Add(strText);
|
||
}
|
||
if (strIndexArray.GetSize() > 3)
|
||
{
|
||
ImportTdSpecAttr(strIndexArray, iTType, aChID[0], iTsn);
|
||
}
|
||
pXML->OutOfElem();
|
||
}
|
||
|
||
}
|
||
|
||
pXML->OutOfElem();
|
||
|
||
if ((szVRawData.GetLength() != (int)VAL_ZERO) && (szIRawData.GetLength() != (int)VAL_ZERO))
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("update td3dcon set Vrawdata = ?, Irawdata = ? where TCHID = %u and TSN = %d"), aChID[0], iTsn);
|
||
|
||
//log
|
||
// CTime t;
|
||
// t = CTime::GetCurrentTime();
|
||
// m_log = t.Format("%Y-%m-%d,%H:%M:%S:");
|
||
// m_log += "\r\n";
|
||
// m_log += szSql;
|
||
// m_log += "\r\n";
|
||
// fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
// fflush(m_pFile);
|
||
//log
|
||
|
||
pCmdUpd->CommandType =adCmdText;
|
||
pCmdUpd->CommandText = szSql.AllocSysString();
|
||
|
||
pCmdUpd->Parameters->Append(pCmdUpd->CreateParameter("Vrawdata", adBSTR, adParamInput, szSql.GetLength(), _variant_t(szVRawData.AllocSysString())));
|
||
pCmdUpd->Parameters->Append(pCmdUpd->CreateParameter("Irawdata", adBSTR, adParamInput, szSql.GetLength(), _variant_t(szIRawData.AllocSysString())));
|
||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||
|
||
if (pCmdUpd->Parameters->GetCount() != VAL_ZERO)
|
||
{
|
||
pCmdUpd->Parameters->Delete(_variant_t("Vrawdata"));
|
||
pCmdUpd->Parameters->Delete(_variant_t("Irawdata"));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strText.Format(_T("(%s) Vrawdata和Irawdata都不能为空!TCHID = %d"), szNodeName, aChID[0]);
|
||
AfxMessageBox(strText);
|
||
}
|
||
else
|
||
{
|
||
strText.Format(_T("(%s)Neither Vrawdata nor Irawdata can be empty!TCHID = %d"), szNodeName, aChID[0]);
|
||
MessageBoxEx(NULL, strText, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
pRecTdCon->Close();
|
||
delete pXML;
|
||
return FALSE;
|
||
}
|
||
}
|
||
|
||
pRecTdCon->MoveNext();
|
||
|
||
}
|
||
pRecTdCon->Close();
|
||
|
||
|
||
delete pXML;
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL CTdManager::Import3DTdConToDB(DWORD dwTdID, CString szDatFile, CDevice* const pDev, int* pTSN)
|
||
{
|
||
_RecordsetPtr pRecChID = NULL;
|
||
_CommandPtr pCmdIns = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szTsn = _T("");
|
||
CString szTdCon = _T("");
|
||
CStringArray saTdCon;
|
||
|
||
CString szNodeName = _T("");
|
||
|
||
int iIndex = (int)VAL_ZERO;
|
||
DWORD aChID[8] = {0};
|
||
DWORD dwChID = (DWORD)VAL_ZERO;
|
||
|
||
int iTsn = (int)VAL_ZERO;
|
||
int iChNum = (int)VAL_ZERO;
|
||
int iC1 = (int)VAL_ZERO;
|
||
int iC2 = (int)VAL_ZERO;
|
||
int iP1 = (int)VAL_ZERO;
|
||
int iP2 = (int)VAL_ZERO;
|
||
int iN = (int)VAL_ZERO;
|
||
|
||
float fK = (float)VAL_ZERO;
|
||
float fI = (float)VAL_ZERO;
|
||
float fV = (float)VAL_ZERO;
|
||
float fR0 = (float)VAL_ZERO;
|
||
float fSP = (float)VAL_ZERO;
|
||
float fR0LC = (float)VAL_ZERO;
|
||
float fM0LC = (float)VAL_ZERO;
|
||
CMarkup *pXML = new CMarkup;
|
||
try
|
||
{
|
||
pRecChID.CreateInstance(_uuidof(Recordset));
|
||
pCmdIns.CreateInstance(_uuidof(Command));
|
||
pCmdIns->ActiveConnection = m_pConnection;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID from tdchannel where TDID = %u"), dwTdID);
|
||
pRecChID->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
iIndex = (int)VAL_ZERO;
|
||
while ((short)VAL_ZERO == pRecChID->adoEOF)
|
||
{
|
||
aChID[iIndex] = pRecChID->GetCollect(_T("ID")).ulVal;
|
||
|
||
iIndex++;
|
||
pRecChID->MoveNext();
|
||
}
|
||
|
||
pRecChID->Close();
|
||
|
||
|
||
pXML->Load(szDatFile);
|
||
|
||
pXML->FindElem(_T("TD"));
|
||
|
||
pXML->FindChildElem("param");
|
||
|
||
pXML->FindChildElem("Data");
|
||
pXML->IntoElem();
|
||
|
||
iTsn = (int)VAL_ONE;
|
||
if (NULL != pTSN)
|
||
{
|
||
iTsn = *pTSN;
|
||
}
|
||
|
||
szNodeName.Empty();
|
||
szNodeName.Format(_T("D%.5d"), iTsn);
|
||
CString strShowErr = _T("");
|
||
bool bIsWirteCheckLC = true;
|
||
while (pXML->FindChildElem(szNodeName))
|
||
{
|
||
|
||
szTdCon.Empty();
|
||
szTdCon = pXML->GetChildData();
|
||
if (szTdCon.IsEmpty())
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strShowErr.Format(_T("获取 %s 子数据为空!!!"), szNodeName.GetBuffer(0));
|
||
AfxMessageBox(strShowErr.GetBuffer(0));
|
||
}
|
||
else
|
||
{
|
||
strShowErr.Format(_T("Get %s childdata is empty!!!"), szNodeName.GetBuffer(0));
|
||
MessageBoxEx(NULL, strShowErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
}
|
||
|
||
SplitterString(saTdCon, szTdCon, _T(";"));
|
||
if (saTdCon.GetSize() < 20)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strShowErr.Format(_T("%s元素的大小错误,应该小于20但实际值=%d"), szNodeName.GetBuffer(0), saTdCon.GetSize());
|
||
AfxMessageBox(strShowErr.GetBuffer(0));
|
||
}
|
||
else
|
||
{
|
||
strShowErr.Format(_T("%s 's element size is error, should be at least 20 but actually is %d"), szNodeName.GetBuffer(0));
|
||
MessageBoxEx(NULL, strShowErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
|
||
pXML->OutOfElem();
|
||
delete pXML;
|
||
return FALSE;
|
||
}
|
||
|
||
bool bIsHaveLC = false;
|
||
//判断是否存在R0_LC和MO_LC,如果不存在,则认为是以前的版本,写错误日志
|
||
if (saTdCon.GetSize() < 22)
|
||
{
|
||
if (bIsWirteCheckLC)
|
||
{
|
||
CString strErrLog = _T("");
|
||
strErrLog.Format(_T("[%d][Td3d]deviation_iteratin data is not exits in Task(%d), node = %s, vector's size = %d "),
|
||
__LINE__, dwTdID, szNodeName, saTdCon.GetSize());
|
||
CFileOperTools::GetInstance()->WriteComLog(strErrLog);
|
||
//日志信息只写一次
|
||
bIsWirteCheckLC = false;
|
||
}
|
||
}
|
||
else
|
||
bIsHaveLC = true;
|
||
|
||
|
||
int iTestFlag = atoi(saTdCon.GetAt(19));
|
||
//只有成功测试了的数据才插入到数据库中去
|
||
if (1 == iTestFlag)
|
||
{
|
||
iC1 = atoi(saTdCon.GetAt(0));
|
||
iC2 = atoi(saTdCon.GetAt(1));
|
||
iP1 = atoi(saTdCon.GetAt(2));
|
||
iP2 = atoi(saTdCon.GetAt(3));
|
||
iChNum = atoi(saTdCon.GetAt(4));
|
||
dwChID = aChID[iChNum-1];
|
||
iN = atoi(saTdCon.GetAt(5));
|
||
fK = (float)atof(saTdCon.GetAt(6));
|
||
fI = (float)atof(saTdCon.GetAt(7));
|
||
fV = (float)atof(saTdCon.GetAt(8));
|
||
fR0 = (float)atof(saTdCon.GetAt(9));
|
||
fSP = (float)atof(saTdCon.GetAt(10));
|
||
|
||
if (bIsHaveLC)
|
||
{
|
||
fR0LC = (float)atof(saTdCon.GetAt(20));
|
||
fM0LC = (float)atof(saTdCon.GetAt(21));
|
||
}
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("insert into td3dcon(TCHID,TSN,C1,C2,P1,P2,N,K,I,V,R0,SP,bUse,R0_LC,M0_LC) values(%u,%d,%d,%d,%d,%d,%d,%f,%f,%f,%f,%f,%d,%f,%f)"),
|
||
dwChID,iTsn,iC1,iC2,iP1,iP2,iN,fK,fI,fV,fR0,fSP,TRUE,fR0LC,fM0LC);
|
||
|
||
//log
|
||
// CTime t;
|
||
// t = CTime::GetCurrentTime();
|
||
// m_log = t.Format("%Y-%m-%d,%H:%M:%S:");
|
||
// m_log += "\r\n";
|
||
// m_log += szSql;
|
||
// m_log += "\r\n";
|
||
// fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
// fflush(m_pFile);
|
||
//log
|
||
|
||
pCmdIns->CommandText = szSql.AllocSysString();
|
||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||
}
|
||
|
||
iTsn++;
|
||
szNodeName.Empty();
|
||
if (iTsn <= 99999)
|
||
{
|
||
szNodeName.Format(_T("D%.5d"), iTsn);
|
||
}
|
||
else
|
||
{
|
||
szNodeName.Format(_T("D%d"), iTsn);
|
||
}
|
||
}
|
||
pXML->OutOfElem();
|
||
|
||
delete pXML;
|
||
}
|
||
catch(_com_error e)
|
||
{
|
||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||
AfxMessageBox(e.Description());
|
||
delete pXML;
|
||
return FALSE;
|
||
|
||
}
|
||
|
||
*pTSN = iTsn;
|
||
return TRUE;
|
||
}
|
||
BOOL CTdManager::Import3DGRToDB(DWORD dwTdID, CString szGRFile, CDevice* const pDev)
|
||
{
|
||
//temp delete由于底层接地电阻修改格式,这里暂时屏蔽
|
||
// return TRUE;
|
||
|
||
//log
|
||
m_log = "\r\nImportTdHeadToDB------------begin\r\n";
|
||
fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
fflush(m_pFile);
|
||
//log
|
||
|
||
_CommandPtr pCmdIns = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szECode = _T("");
|
||
CString szDT = _T("");
|
||
CString szMDate = _T("");
|
||
CString szMTime = _T("");
|
||
CString strCode = _T("");
|
||
CString strCode1 = _T("");
|
||
|
||
int iOMValue = (int)VAL_ZERO;
|
||
int iOM1Value = (int)VAL_ZERO;
|
||
int iResCode = (int)VAL_ZERO;
|
||
int iResCode1 = (int)VAL_ZERO;
|
||
|
||
CString szTdGR = _T("");
|
||
CStringArray saTdGR;
|
||
|
||
CString szNodeName = _T("");
|
||
|
||
int iIndex = (int)VAL_ZERO;
|
||
|
||
pCmdIns.CreateInstance(_uuidof(Command));
|
||
pCmdIns->ActiveConnection = m_pConnection;
|
||
|
||
CMarkup *pXML = new CMarkup;
|
||
pXML->Load(szGRFile);
|
||
|
||
pXML->FindElem(_T("TD"));
|
||
|
||
pXML->FindChildElem("param");
|
||
|
||
pXML->FindChildElem("Data");
|
||
pXML->IntoElem();
|
||
|
||
iIndex = (int)VAL_ONE;
|
||
szNodeName.Empty();
|
||
szNodeName.Format(_T("D%.5d"), iIndex);
|
||
|
||
while (pXML->FindChildElem(szNodeName))
|
||
{
|
||
szTdGR = pXML->GetChildData();
|
||
SplitterString(saTdGR, szTdGR, _T(";"));
|
||
|
||
szECode.Empty();
|
||
szECode = saTdGR.GetAt(0);
|
||
szECode.TrimLeft();
|
||
szECode.TrimRight();
|
||
|
||
iOMValue = atoi(saTdGR.GetAt(1));
|
||
iResCode = atoi(saTdGR.GetAt(2));
|
||
|
||
iOM1Value = atoi(saTdGR.GetAt(3));
|
||
iResCode1 = atoi(saTdGR.GetAt(4));
|
||
|
||
szDT.Empty();
|
||
szDT = saTdGR.GetAt(5);
|
||
|
||
szDT.TrimLeft();
|
||
szDT.TrimRight();
|
||
|
||
szMDate.Empty();
|
||
szMDate.Format(_T("%s-%s-%s"), szDT.Mid(0, 4), szDT.Mid(4, 2), szDT.Mid(6, 2));
|
||
|
||
szMTime.Empty();
|
||
szMTime.Format(_T("%s:%s:%s"), szDT.Mid(8, 2), szDT.Mid(10, 2), szDT.Mid(12, 2));
|
||
|
||
if (szMTime == "1900-01-00")
|
||
{
|
||
szMTime = "1900-01-01";
|
||
}
|
||
|
||
if (szMDate == "1900-01-00")
|
||
{
|
||
szMDate = "1900-01-01";
|
||
}
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("insert into gr(TDID,Ecode,OMvalue,Mdate,Mtime,StatusCode,OM1value,StatusCode1) values(%u,'%s',%d,#%s#,#%s#,%d,%d,%d)"),
|
||
dwTdID, szECode, iOMValue, szMDate, szMTime, iResCode, iOM1Value, iResCode1);
|
||
|
||
|
||
//log
|
||
CTime t;
|
||
t = CTime::GetCurrentTime();
|
||
m_log = t.Format("%Y-%m-%d,%H:%M:%S:");
|
||
m_log += "\r\n";
|
||
m_log += szSql;
|
||
m_log += "\r\n";
|
||
// fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
// fflush(m_pFile);
|
||
//log
|
||
|
||
pCmdIns->CommandText = szSql.AllocSysString();
|
||
pCmdIns->Execute(NULL, NULL, adCmdText);
|
||
|
||
iIndex++;
|
||
szNodeName.Empty();
|
||
if (iIndex <= 99999)
|
||
{
|
||
szNodeName.Format(_T("D%.5d"), iIndex);
|
||
}
|
||
else
|
||
{
|
||
szNodeName.Format(_T("D%d"), iIndex);
|
||
}
|
||
|
||
}
|
||
|
||
delete pXML;
|
||
|
||
//log
|
||
m_log = "ImportTdHeadToDB------------end";
|
||
fwrite(m_log.GetBuffer(0), 1, m_log.GetLength(), m_pFile);
|
||
fflush(m_pFile);
|
||
//log
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
void CTdManager::DeleteIpsp3DTd(DWORD dwID)
|
||
{
|
||
_RecordsetPtr pRecTd = NULL;
|
||
_CommandPtr pCmdDelIpspTd = NULL;
|
||
_CommandPtr pCmdUpd = NULL;
|
||
_CommandPtr pCmdTW = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szTdCN = _T("");
|
||
CString szDESN = _T("");
|
||
|
||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||
|
||
pCmdDelIpspTd.CreateInstance(_uuidof(Command));
|
||
pCmdDelIpspTd->ActiveConnection = m_pConnection;
|
||
|
||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||
pCmdUpd->ActiveConnection = m_pConnection;
|
||
|
||
pCmdTW.CreateInstance(_uuidof(Command));
|
||
pCmdTW->ActiveConnection = m_pConnection;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from ac where TDID = %u"), dwID);
|
||
pCmdTW->CommandText = szSql.AllocSysString();
|
||
pCmdTW->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select TdCN,DESN from td where ID = %u"), dwID);
|
||
pRecTd->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
if ((long)VAL_ZERO != pRecTd->GetRecordCount())
|
||
{
|
||
szTdCN.Empty();
|
||
szTdCN = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TdCN")).bstrVal;
|
||
|
||
szDESN.Empty();
|
||
szDESN = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("DESN")).bstrVal;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("update dev_syn_td set IsSyned = false where TdCN = '%s' and DESN = '%s'"), szTdCN, szDESN);
|
||
pCmdUpd->CommandText = szSql.AllocSysString();
|
||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||
}
|
||
|
||
pRecTd->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from td3dcon where TCHID in (select ID from tdchannel where TDID = %u)"), dwID);
|
||
|
||
pCmdDelIpspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelIpspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from tdchannel where TDID = %u"), dwID);
|
||
|
||
pCmdDelIpspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelIpspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from gr where TDID = %u"), dwID);
|
||
|
||
pCmdDelIpspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelIpspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from td where ID = %u"), dwID);
|
||
|
||
pCmdDelIpspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelIpspTd->Execute(NULL, NULL, adCmdText);
|
||
}
|
||
|
||
void CTdManager::DeleteRsp3DTd(DWORD dwID)
|
||
{
|
||
_RecordsetPtr pRecTd = NULL;
|
||
_CommandPtr pCmdDelRspTd = NULL;
|
||
_CommandPtr pCmdUpd = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szTdCN = _T("");
|
||
CString szDESN = _T("");
|
||
|
||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||
|
||
pCmdDelRspTd.CreateInstance(_uuidof(Command));
|
||
pCmdDelRspTd->ActiveConnection = m_pConnection;
|
||
|
||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||
pCmdUpd->ActiveConnection = m_pConnection;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select TdCN,DESN from td where ID = %u"), dwID);
|
||
pRecTd->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
if ((long)VAL_ZERO != pRecTd->GetRecordCount())
|
||
{
|
||
szTdCN.Empty();
|
||
szTdCN = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TdCN")).bstrVal;
|
||
|
||
szDESN.Empty();
|
||
szDESN = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("DESN")).bstrVal;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("update dev_syn_td set IsSyned = false where TdCN = '%s' and DESN = '%s'"), szTdCN, szDESN);
|
||
pCmdUpd->CommandText = szSql.AllocSysString();
|
||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||
}
|
||
|
||
pRecTd->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from td3dcon where TCHID in (select ID from tdchannel where TDID = %u)"), dwID);
|
||
|
||
pCmdDelRspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelRspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from tdchannel where TDID = %u"), dwID);
|
||
|
||
pCmdDelRspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelRspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from gr where TDID = %u"), dwID);
|
||
|
||
pCmdDelRspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelRspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from td where ID = %u"), dwID);
|
||
|
||
pCmdDelRspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelRspTd->Execute(NULL, NULL, adCmdText);
|
||
}
|
||
|
||
void CTdManager::DeleteSP2DTd(DWORD dwID)
|
||
{
|
||
_RecordsetPtr pRecTd = NULL;
|
||
_CommandPtr pCmdDelRspTd = NULL;
|
||
_CommandPtr pCmdUpd = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szTdCN = _T("");
|
||
CString szDESN = _T("");
|
||
|
||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||
|
||
pCmdDelRspTd.CreateInstance(_uuidof(Command));
|
||
pCmdDelRspTd->ActiveConnection = m_pConnection;
|
||
|
||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||
pCmdUpd->ActiveConnection = m_pConnection;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select TdCN,DESN from td where ID = %u"), dwID);
|
||
pRecTd->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
if ((long)VAL_ZERO != pRecTd->GetRecordCount())
|
||
{
|
||
szTdCN.Empty();
|
||
szTdCN = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TdCN")).bstrVal;
|
||
|
||
szDESN.Empty();
|
||
szDESN = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("DESN")).bstrVal;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("update dev_syn_td set IsSyned = false where TdCN = '%s' and DESN = '%s'"), szTdCN, szDESN);
|
||
pCmdUpd->CommandText = szSql.AllocSysString();
|
||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||
}
|
||
|
||
pRecTd->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from td2dcon where TCHID in (select ID from tdchannel where TDID = %u)"), dwID);
|
||
|
||
pCmdDelRspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelRspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from tdchannel where TDID = %u"), dwID);
|
||
|
||
pCmdDelRspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelRspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from gr where TDID = %u"), dwID);
|
||
|
||
pCmdDelRspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelRspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from td where ID = %u"), dwID);
|
||
|
||
pCmdDelRspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelRspTd->Execute(NULL, NULL, adCmdText);
|
||
}
|
||
|
||
void CTdManager::DeleteSP3DTd(DWORD dwID)
|
||
{
|
||
_RecordsetPtr pRecTd = NULL;
|
||
_CommandPtr pCmdDelRspTd = NULL;
|
||
_CommandPtr pCmdUpd = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szTdCN = _T("");
|
||
CString szDESN = _T("");
|
||
|
||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||
|
||
pCmdDelRspTd.CreateInstance(_uuidof(Command));
|
||
pCmdDelRspTd->ActiveConnection = m_pConnection;
|
||
|
||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||
pCmdUpd->ActiveConnection = m_pConnection;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select TdCN,DESN from td where ID = %u"), dwID);
|
||
pRecTd->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
if ((long)VAL_ZERO != pRecTd->GetRecordCount())
|
||
{
|
||
szTdCN.Empty();
|
||
szTdCN = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TdCN")).bstrVal;
|
||
|
||
szDESN.Empty();
|
||
szDESN = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("DESN")).bstrVal;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("update dev_syn_td set IsSyned = false where TdCN = '%s' and DESN = '%s'"), szTdCN, szDESN);
|
||
pCmdUpd->CommandText = szSql.AllocSysString();
|
||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||
}
|
||
|
||
pRecTd->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from td3dcon where TCHID in (select ID from tdchannel where TDID = %u)"), dwID);
|
||
|
||
pCmdDelRspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelRspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from tdchannel where TDID = %u"), dwID);
|
||
|
||
pCmdDelRspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelRspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from gr where TDID = %u"), dwID);
|
||
|
||
pCmdDelRspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelRspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from td where ID = %u"), dwID);
|
||
|
||
pCmdDelRspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelRspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
}
|
||
|
||
void CTdManager::DeleteSPCETd(DWORD dwID)
|
||
{
|
||
_RecordsetPtr pRecTd = NULL;
|
||
_CommandPtr pCmdDelRspTd = NULL;
|
||
_CommandPtr pCmdUpd = NULL;
|
||
|
||
CString szSql = _T("");
|
||
CString szTdCN = _T("");
|
||
CString szDESN = _T("");
|
||
|
||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||
|
||
pCmdDelRspTd.CreateInstance(_uuidof(Command));
|
||
pCmdDelRspTd->ActiveConnection = m_pConnection;
|
||
|
||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||
pCmdUpd->ActiveConnection = m_pConnection;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select TdCN,DESN from td where ID = %u"), dwID);
|
||
pRecTd->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
|
||
if ((long)VAL_ZERO != pRecTd->GetRecordCount())
|
||
{
|
||
szTdCN.Empty();
|
||
szTdCN = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TdCN")).bstrVal;
|
||
|
||
szDESN.Empty();
|
||
szDESN = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("DESN")).bstrVal;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("update dev_syn_td set IsSyned = false where TdCN = '%s' and DESN = '%s'"), szTdCN, szDESN);
|
||
pCmdUpd->CommandText = szSql.AllocSysString();
|
||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||
}
|
||
|
||
pRecTd->Close();
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from td1dcon where TCHID in (select ID from tdchannel where TDID = %u)"), dwID);
|
||
|
||
pCmdDelRspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelRspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from tdchannel where TDID = %u"), dwID);
|
||
|
||
pCmdDelRspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelRspTd->Execute(NULL, NULL, adCmdText);
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("delete from td where ID = %u"), dwID);
|
||
|
||
pCmdDelRspTd->CommandText = szSql.AllocSysString();
|
||
pCmdDelRspTd->Execute(NULL, NULL, adCmdText);
|
||
}
|
||
|
||
//返回TRUE代表在指定工程、测区下,该任务不存在,反之,存在
|
||
BOOL CTdManager::OnlineCheckTdExist(CString szTdID, CString szDevSN, DWORD *TdId)
|
||
{
|
||
_RecordsetPtr pRecTdID = NULL;
|
||
|
||
DWORD dwPrID;
|
||
DWORD dwTzID;
|
||
CString szSql = _T("");
|
||
|
||
pRecTdID.CreateInstance(_uuidof(Recordset));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID from td where TDCN = '%s' and DESN = '%s' "), szTdID, szDevSN);
|
||
|
||
pRecTdID->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecTdID->GetRecordCount())
|
||
{
|
||
//该任务存在
|
||
*TdId = pRecTdID->GetCollect(_T("ID")).ulVal;
|
||
pRecTdID->Close();
|
||
return FALSE;
|
||
}
|
||
else
|
||
{
|
||
//该任务不存在
|
||
pRecTdID->Close();
|
||
return TRUE;
|
||
}
|
||
}
|
||
|
||
//返回TRUE代表在指定TCoordinatesInfo电极坐标信息不存在,反之,存在
|
||
BOOL CTdManager::OnlineCheckElecInfoExist(CString strTdID, CString szDevSN)
|
||
{
|
||
_RecordsetPtr pRecTdID = NULL;
|
||
|
||
DWORD dwPrID;
|
||
DWORD dwTzID;
|
||
CString szSql = _T("");
|
||
|
||
pRecTdID.CreateInstance(_uuidof(Recordset));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select * from TTaskBindElecInfo where TaskID='%s'"), strTdID);
|
||
|
||
pRecTdID->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecTdID->GetRecordCount())
|
||
{
|
||
//该任务存在
|
||
pRecTdID->Close();
|
||
return FALSE;
|
||
}
|
||
else
|
||
{
|
||
//该任务不存在
|
||
pRecTdID->Close();
|
||
return TRUE;
|
||
}
|
||
}
|
||
//返回TRUE代表在指定工程、测区下,该任务不存在,反之,存在
|
||
BOOL CTdManager::CheckTdExist(CString szPrCN, CString szTzCN, CString szTdCN, CDevice *const pDev, DWORD *TdId)
|
||
{
|
||
_RecordsetPtr pRecPro = NULL;
|
||
_RecordsetPtr pRecTz = NULL;
|
||
_RecordsetPtr pRecTdID = NULL;
|
||
|
||
DWORD dwPrID;
|
||
DWORD dwTzID;
|
||
CString szSql = _T("");
|
||
|
||
pRecPro.CreateInstance(_uuidof(Recordset));
|
||
pRecTz.CreateInstance(_uuidof(Recordset));
|
||
pRecTdID.CreateInstance(_uuidof(Recordset));
|
||
|
||
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())
|
||
{
|
||
dwPrID = pRecPro->GetCollect(_T("ID")).ulVal;
|
||
pRecPro->Close();
|
||
}
|
||
else
|
||
{ //该工程不存在,故该任务也不存在
|
||
pRecPro->Close();
|
||
return TRUE;
|
||
}
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID from tz where CN = '%s' and PRID = %d"), szTzCN, dwPrID);
|
||
pRecTz->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecTz->GetRecordCount())
|
||
{
|
||
dwTzID = pRecTz->GetCollect(_T("ID")).ulVal;
|
||
pRecTz->Close();
|
||
}
|
||
else
|
||
{
|
||
//该测区不存在,故该任务也不存在
|
||
pRecTz->Close();
|
||
return TRUE;
|
||
}
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID from td where TdCN = '%s' and TZID = %d and DESN = '%s' "), szTdCN, dwTzID,pDev->m_szDevSN);
|
||
|
||
pRecTdID->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecTdID->GetRecordCount())
|
||
{
|
||
//该任务存在
|
||
*TdId = pRecTdID->GetCollect(_T("ID")).ulVal;
|
||
pRecTdID->Close();
|
||
return FALSE;
|
||
}
|
||
else
|
||
{
|
||
//该任务不存在
|
||
pRecTdID->Close();
|
||
return TRUE;
|
||
}
|
||
}
|
||
|
||
bool CTdManager::ImportTdSpecAttr(const CStringArray& strAttrArray, int iDataType, DWORD dwChID, int iTSN)
|
||
{
|
||
if (strAttrArray.GetSize()<4)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("在ImportTdAttr中输入参数错误!"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Input param error in ImportTdAttr!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return false;
|
||
}
|
||
_CommandPtr pCmdExec = NULL;
|
||
CString strSql = _T("");
|
||
CString strAttr = _T("");
|
||
CString strVal = _T("");
|
||
CString strText = _T("");
|
||
|
||
switch (iDataType)
|
||
{
|
||
case EN_IP_TEST_TYPE:
|
||
{
|
||
int iTWCnt = atoi(strAttrArray.GetAt(3));
|
||
if (strAttrArray.GetSize() != (4 + iTWCnt))
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("在ImportTdAttr中参数认证失败!"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Param verified error in ImportTdAttr!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return false;
|
||
}
|
||
strAttr = _T("TCHID,TSN,THL,D,r,TWCNT");
|
||
strVal.Empty();
|
||
strVal.Format(_T("%u,%d,%d,%f,%f,%d"),dwChID, iTSN,atoi(strAttrArray.GetAt(0)),
|
||
atof(strAttrArray.GetAt(1)), atof(strAttrArray.GetAt(2)), iTWCnt);
|
||
|
||
for (int i = 0; i < iTWCnt; i++)
|
||
{
|
||
strText.Empty();
|
||
strText.Format(_T(",TW%dIndex"),i);
|
||
strAttr += strText;
|
||
strText.Empty();
|
||
strText.Format(_T(",'%s'"), strAttrArray.GetAt(4+i));
|
||
strVal += strText;
|
||
}
|
||
strSql.Empty();
|
||
strSql.Format(_T("insert into td_spc_attr (%s) values (%s)"),strAttr, strVal);
|
||
break;
|
||
}
|
||
default:
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strText.Format(_T("在ImportTdAttr中不支持数据类型(%d)!"), iDataType);
|
||
AfxMessageBox(strText);
|
||
}
|
||
else
|
||
{
|
||
strText.Format(_T("Not support datatype(%d) in ImportTdAttr!"), iDataType);
|
||
MessageBoxEx(NULL, strText, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
return false;
|
||
}
|
||
try
|
||
{
|
||
pCmdExec.CreateInstance(_uuidof(Command));
|
||
pCmdExec->ActiveConnection = m_pConnection;
|
||
m_pConnection->BeginTrans();
|
||
pCmdExec->CommandText = strSql.AllocSysString();
|
||
pCmdExec->Execute(NULL, NULL, adCmdText);
|
||
}
|
||
catch (_com_error e)
|
||
{
|
||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||
AfxMessageBox((LPCTSTR)e.Description(), MB_ICONINFORMATION);
|
||
m_pConnection->RollbackTrans();
|
||
return false;
|
||
}
|
||
m_pConnection->CommitTrans();
|
||
return true;
|
||
|
||
}
|
||
|
||
|