3589 lines
111 KiB
C++
3589 lines
111 KiB
C++
// SptManager.cpp: implementation of the CSptManager class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "geomative.h"
|
|
#include "SptManager.h"
|
|
|
|
#include "Markup.h"
|
|
|
|
#include "MediumA.h"
|
|
#include "MediumB.h"
|
|
#include "MediumC.h"
|
|
#include "MediumD.h"
|
|
#include "MediumE.h"
|
|
#include "MediumK.h"
|
|
#include "MediumQ.h"
|
|
#include "MediumR.h"
|
|
#include "MediumS.h"
|
|
#include "MediumT.h"
|
|
#include "MediumU.h"
|
|
#include "MediumV.h"
|
|
#include "MediumW.h"
|
|
#include "MediumX.h"
|
|
#include "MediumY.h"
|
|
#include "MediumZ.h"
|
|
#include "MediumZA.h"
|
|
#include "MediumZB.h"
|
|
#include "MediumZC.h"
|
|
#include "MediumLogging.h"
|
|
#include "MediumStrongWenAndSch.h"
|
|
#include "MediumBasicWenAndSch.h"
|
|
#include "MediumAM.h"
|
|
#include "MediumAMN.h"
|
|
#include "opcreatesptdlg.h"
|
|
#include "opcreatecesptdlg.h"
|
|
#include "OpCreate3DSptDlg.h"
|
|
#include "MediumCustom2D.h"
|
|
#include "DialCreateNew3DSpt.h"
|
|
#include "GD10OperCmd.h"
|
|
#include "MediumUnityProfile.h"
|
|
#include "MediumEdgeGradient.h"
|
|
#include "MeidumBipoleUpHole.h"
|
|
#include "MediumTwoSideAMN.h"
|
|
#include "MediumMidGardientScan.h"
|
|
#include "MediumStrongGradient.h"
|
|
#include "MediumCrossHoleGeomative.h"
|
|
#include "MediumCrossHoleGeomativeAM.h"
|
|
#include "MediumLandfillAdjacent.h"
|
|
#include "MediumLandfillDiagonally.h"
|
|
#include "MediumS3P.h"
|
|
#include "OperTxtFile.h"
|
|
#include "DetcGD10Dev.h"
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
extern HHOOK hHook;
|
|
extern int g_iTransMode;
|
|
extern int g_iLanguage;
|
|
extern void TransDelay(int iTransMode, int iDS0, int iDS1, HWND hWnd = NULL);
|
|
extern BOOL DoEvent(HWND hWnd);
|
|
extern BOOL GetSubStringInHeadAndTail(const CString& szSource, CString& szSub, const CString& szHead, const CString& szTail);
|
|
extern void SplitterString(CStringArray &szArray,const CString& szSource, const CString& szSplitter);
|
|
extern int g_iTransFileMode;
|
|
extern int g_iUILanguage;
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Construction/Destruction
|
|
//////////////////////////////////////////////////////////////////////
|
|
extern HHOOK hHook;
|
|
extern CGeoMativeApp theApp;
|
|
extern LRESULT __stdcall CBTHookProc(long nCode, WPARAM wParam, LPARAM lParam);
|
|
CSptManager::CSptManager(_ConnectionPtr& pConnection)
|
|
{
|
|
ASSERT(NULL != pConnection);
|
|
//m_pConnection = pConnection;
|
|
m_sptLinkList.DeleteAll();
|
|
m_pOpCreateCESptDlg = NULL;
|
|
m_pNewScript = NULL;
|
|
m_pChannel = NULL;
|
|
InitialMedLinkList();
|
|
}
|
|
|
|
CSptManager::~CSptManager()
|
|
{
|
|
int iSptIndex = 0;
|
|
int iMedIndex = 0;
|
|
|
|
iSptIndex++;
|
|
|
|
while (NULL != m_sptLinkList.Find(iSptIndex))
|
|
{
|
|
delete m_sptLinkList.Find(iSptIndex);
|
|
iSptIndex++;
|
|
}
|
|
m_sptLinkList.DeleteAll();
|
|
|
|
iMedIndex++;
|
|
|
|
while (NULL != m_medLinkList.Find(iMedIndex))
|
|
{
|
|
delete m_medLinkList.Find(iMedIndex);
|
|
iMedIndex++;
|
|
}
|
|
m_medLinkList.DeleteAll();
|
|
|
|
if (NULL != m_pOpCreateCESptDlg)
|
|
{
|
|
delete m_pOpCreateCESptDlg;
|
|
m_pOpCreateCESptDlg = NULL;
|
|
}
|
|
|
|
if (NULL != m_pNewScript)
|
|
{
|
|
delete m_pNewScript;
|
|
m_pNewScript = NULL;
|
|
}
|
|
|
|
if (NULL != m_pChannel)
|
|
{
|
|
delete m_pChannel;
|
|
m_pChannel = NULL;
|
|
}
|
|
}
|
|
|
|
CScript* CSptManager::GetScript(DWORD dwHandle)
|
|
{
|
|
CScript* pSpt = NULL;
|
|
DWORD dwID = (DWORD)VAL_ZERO;
|
|
int iStype = (DWORD)VAL_ZERO;
|
|
|
|
pSpt = m_sptLinkList.Get(dwHandle);
|
|
|
|
if (NULL == pSpt)
|
|
{
|
|
dwID = m_handleProcessor.GetIDFromHandle(dwHandle);
|
|
|
|
switch (m_handleProcessor.GetStyleFromHandle(dwHandle))
|
|
{
|
|
case PZ_STYLE_SCON_CE:
|
|
pSpt = new CScriptCE(dwID, theApp.m_pConnection);
|
|
break;
|
|
case PZ_STYLE_SCON_2D:
|
|
pSpt = new CScript2D(dwID, theApp.m_pConnection);
|
|
break;
|
|
case PZ_STYLE_SCON_3D:
|
|
pSpt = new CScript3D(dwID, theApp.m_pConnection);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
m_sptLinkList.Add(dwHandle, pSpt);
|
|
}
|
|
|
|
return pSpt;
|
|
}
|
|
|
|
void CSptManager::DeleteObjInMem(DWORD dwHandle)
|
|
{
|
|
delete m_sptLinkList.Find(dwHandle);
|
|
m_sptLinkList.Delete(dwHandle);
|
|
}
|
|
|
|
//DEL UINT CSptManager::CreateScriptFileInOffline(DWORD dwDevID)
|
|
//DEL {
|
|
//DEL _RecordsetPtr pRecSCon = NULL;
|
|
//DEL // _RecordsetPtr pRecScript = NULL;
|
|
//DEL
|
|
//DEL _CommandPtr pCmdInsSF = NULL;
|
|
//DEL
|
|
//DEL UINT uExecCode = (UINT)VAL_ZERO;
|
|
//DEL INT_PTR lRet = (long)VAL_ZERO;
|
|
//DEL
|
|
//DEL DWORD dwSconHandle = (DWORD)VAL_ZERO;
|
|
//DEL DWORD dwSConID = (DWORD)VAL_ZERO;
|
|
//DEL
|
|
//DEL DWORD dwSFRamount = (DWORD)VAL_ZERO;
|
|
//DEL
|
|
//DEL int iIndex = (int)VAL_ZERO;
|
|
//DEL
|
|
//DEL CString szSql;
|
|
//DEL CString szSFname;
|
|
//DEL
|
|
//DEL COpCreateSFDlg* pOpCreateSFDlg = new COpCreateSFDlg((INT_PTR*)&lRet);
|
|
//DEL
|
|
//DEL CListCtrl& sptList = pOpCreateSFDlg->m_sptList;
|
|
//DEL
|
|
//DEL pOpCreateSFDlg->Create(IDD_OP_SF_L_C, AfxGetMainWnd());
|
|
//DEL
|
|
//DEL try
|
|
//DEL {
|
|
//DEL InitialSptList(pOpCreateSFDlg->m_sptList, dwDevID);
|
|
//DEL
|
|
//DEL pOpCreateSFDlg->ShowWindow(SW_SHOW);
|
|
//DEL
|
|
//DEL while (!lRet)
|
|
//DEL {
|
|
//DEL DoEvent(pOpCreateSFDlg->m_hWnd);
|
|
//DEL }
|
|
//DEL
|
|
//DEL pRecSCon.CreateInstance(_uuidof(Recordset));
|
|
//DEL // pRecScript.CreateInstance(_uuidof(Recordset));
|
|
//DEL
|
|
//DEL pCmdInsSF.CreateInstance(_uuidof(Command));
|
|
//DEL pCmdInsSF->ActiveConnection = m_pConnection;
|
|
//DEL
|
|
//DEL switch (lRet)
|
|
//DEL {
|
|
//DEL case RET_OK:
|
|
//DEL while (iIndex < sptList.GetItemCount())
|
|
//DEL {
|
|
//DEL if (sptList.GetCheck(iIndex))
|
|
//DEL {
|
|
//DEL dwSconHandle = sptList.GetItemData(iIndex);
|
|
//DEL dwSConID = m_handleProcessor.GetIDFromHandle(dwSconHandle);
|
|
//DEL
|
|
//DEL szSql.Empty();
|
|
//DEL szSql.Format("select CN from scon where ID = %u", dwSConID);
|
|
//DEL pRecSCon->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
//DEL
|
|
//DEL szSFname.Empty();
|
|
//DEL szSFname.Format("%s.scr", (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("CN")));
|
|
//DEL pRecSCon->Close();
|
|
//DEL
|
|
//DEL szSql.Empty();
|
|
//DEL szSql.Format(_T("insert into sfile(SFname,SCID,Cdate,DEID) values('%s',%u,Date(),%u)"), szSFname, dwSConID, dwDevID);
|
|
//DEL
|
|
//DEL pCmdInsSF->CommandText = szSql.AllocSysString();
|
|
//DEL pCmdInsSF->Execute(NULL, NULL, adCmdText);
|
|
//DEL }
|
|
//DEL iIndex ++;
|
|
//DEL }
|
|
//DEL uExecCode = APP_SUCCESS;
|
|
//DEL break;
|
|
//DEL case RET_CANCLE:
|
|
//DEL uExecCode = APP_CANCLE;
|
|
//DEL break;
|
|
//DEL default:
|
|
//DEL uExecCode = APP_FAIL;
|
|
//DEL break;
|
|
//DEL }
|
|
//DEL
|
|
//DEL pOpCreateSFDlg->DestroyWindow();
|
|
//DEL delete pOpCreateSFDlg;
|
|
//DEL return uExecCode;
|
|
//DEL }
|
|
//DEL catch (_com_error e)
|
|
//DEL {
|
|
//DEL pOpCreateSFDlg->DestroyWindow();
|
|
//DEL delete pOpCreateSFDlg;
|
|
//DEL
|
|
//DEL throw;
|
|
//DEL }
|
|
//DEL }
|
|
|
|
UINT CSptManager::Create2DSConInDB(DWORD& dwSConID)
|
|
{
|
|
CString szCN = _T("");
|
|
CString szSql = _T("");
|
|
CString szSName = _T("");
|
|
CString szDefiner = _T("");
|
|
CString szDeDate = _T("");
|
|
CString szScDesc = _T("");
|
|
|
|
_RecordsetPtr pRecSCID = NULL;
|
|
_RecordsetPtr pRecCHID = NULL;
|
|
|
|
_CommandPtr pCmdIns = NULL;
|
|
_CommandPtr pCmdUpd = NULL;
|
|
|
|
int iChCount = (int)VAL_ZERO;
|
|
int iChIndex = (int)VAL_ZERO;
|
|
POSITION posCh = NULL;
|
|
|
|
int iRecCount = (int)VAL_ZERO;
|
|
int iRecIndex = (int)VAL_ZERO;
|
|
|
|
int iTpAmount = (int)VAL_ZERO;
|
|
int iTsn = (int)VAL_ZERO;
|
|
|
|
// DWORD dwSCID = (DWORD)VAL_ZERO;
|
|
DWORD dwCHID = (DWORD)VAL_ZERO;
|
|
|
|
UINT uExecCode = (UINT)VAL_ZERO;
|
|
INT_PTR lRet = (long)VAL_ZERO;
|
|
INT_PTR lRetBackup = lRet;
|
|
|
|
CScript2D* pNewScript = new CScript2D((DWORD)VAL_ZERO, theApp.m_pConnection);
|
|
CChannel* pChannel = NULL;
|
|
CSptRecord* pSptRecord = NULL;
|
|
CString strPoleStep = _T("0");
|
|
int iAR = 0;
|
|
|
|
COpCreateSptDlg* pOpCreateSptDlg = new COpCreateSptDlg(pNewScript, &m_medLinkList, (INT_PTR*)&lRet);
|
|
|
|
pOpCreateSptDlg->Create(IDD_OP_SPT_DB_C, AfxGetMainWnd());
|
|
|
|
try
|
|
{
|
|
this->InitialCreateSConDlg(pOpCreateSptDlg);
|
|
|
|
pOpCreateSptDlg->ShowWindow(SW_SHOW);
|
|
|
|
lRet = pOpCreateSptDlg->RunModalLoop(MLF_SHOWONIDLE); // 开始非模态窗口模态循环
|
|
lRetBackup = lRet;
|
|
switch (lRet)
|
|
{
|
|
case RET_OK:
|
|
theApp.m_pConnection->BeginTrans();
|
|
pRecSCID.CreateInstance(_uuidof(Recordset));
|
|
pRecCHID.CreateInstance(_uuidof(Recordset));
|
|
|
|
pCmdIns.CreateInstance(_uuidof(Command));
|
|
pCmdIns->ActiveConnection = theApp.m_pConnection;
|
|
|
|
pCmdUpd.CreateInstance(_uuidof(Command));
|
|
pCmdUpd->ActiveConnection = theApp.m_pConnection;
|
|
|
|
szCN.Empty();
|
|
szCN = this->m_guCodeCreator.GenerateGUIDCode();
|
|
szSName.Empty();
|
|
((CEdit*)pOpCreateSptDlg->GetDlgItem(IDC_SPT_SNAME))->GetWindowText(szSName);
|
|
szSName.TrimLeft();
|
|
szSName.TrimRight();
|
|
szDefiner.Empty();
|
|
((CEdit*)pOpCreateSptDlg->GetDlgItem(IDC_SPT_DEFINER))->GetWindowText(szDefiner);
|
|
szScDesc.Empty();
|
|
((CEdit*)pOpCreateSptDlg->GetDlgItem(IDC_SPT_SCDESC))->GetWindowText(szScDesc);
|
|
|
|
pNewScript->m_iSType = 1; //脚本类型 1d,2d
|
|
iChCount = pNewScript->m_chaList.GetCount();//这个不知道,得到1
|
|
|
|
/////////////////////////////////检测是否有相同的名称的脚本/////////////////////////////////////////
|
|
szSql.Empty();
|
|
//Stype=1,二维列表
|
|
szSql.Format(_T("select * from scon where Sname = '%s' and Stype=1"),szSName);
|
|
pRecSCID->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecSCID->GetRecordCount())
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("脚本已存在."));
|
|
else
|
|
MessageBoxEx(NULL, _T("Script has been alreay exists."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
pRecSCID->Close();
|
|
theApp.m_pConnection->RollbackTrans();
|
|
pNewScript->m_chaList.RemoveAll();
|
|
delete pNewScript;
|
|
pOpCreateSptDlg->DestroyWindow();
|
|
delete pOpCreateSptDlg;
|
|
return APP_FAIL;
|
|
}
|
|
pRecSCID->Close();
|
|
iAR = ((CChannel*)pNewScript->m_chaList.GetAt(pNewScript->m_chaList.FindIndex(iChIndex)))->m_pMedium->m_iAR;
|
|
|
|
if (iAR == AR_DIP_DIP)
|
|
{
|
|
strPoleStep.Empty();
|
|
strPoleStep.Format(_T("%f"),pOpCreateSptDlg->GetDipoleSpt());
|
|
}
|
|
//////////////////////////////////////////////////////////////////////////
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into scon(CN,Sname,Stype,Eamount,CHamount,TPamount,definer,DEdate,SCdesc,Rect,RectLoc,PoleDistance,PoleStep) "
|
|
"values('%s','%s',%d,%d,%d,%d,'%s',#%s#,'%s','%s','%s','%s','%s')"),
|
|
szCN,
|
|
szSName,
|
|
pNewScript->m_iSType,
|
|
pNewScript->m_iEAmount,//电极总数
|
|
iChCount,//通道数
|
|
iTpAmount,//应该是测点数
|
|
szDefiner,
|
|
pOpCreateSptDlg->m_edDeDate.FormatGmt("%Y-%m-%d"),
|
|
szScDesc,
|
|
// 1,
|
|
// 1,
|
|
// pNewScript->m_iEAmount,
|
|
"0,0,0,0",
|
|
"0",
|
|
"0",
|
|
strPoleStep);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
//取得scon表中ID最大的ITEM
|
|
pRecSCID->Open(_T("select max(ID) as ID from scon"), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecSCID->GetRecordCount())//返回1
|
|
{
|
|
dwSConID = (DWORD)pRecSCID->GetCollect(_T("ID")).ulVal;//返回206就是最大的那个ID序号
|
|
}
|
|
pRecSCID->Close();
|
|
|
|
posCh = NULL;
|
|
iChIndex = (int)VAL_ZERO;
|
|
|
|
while (iChIndex < iChCount)//iChCount = 1
|
|
{
|
|
posCh = pNewScript->m_chaList.FindIndex(iChIndex);
|
|
pChannel = (CChannel*)pNewScript->m_chaList.GetAt(posCh);
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into channel(SCID,CHnumber,AR,MaxLayer) values(%u,%d,%d,%d) "),
|
|
dwSConID,
|
|
pChannel->m_iChNumber,
|
|
pChannel->m_pMedium->m_iAR,
|
|
pChannel->m_iMaxLevel);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
pRecCHID->Open(_T("select max(ID) as ID from channel"), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecCHID->GetRecordCount())
|
|
{
|
|
dwCHID = (DWORD)pRecCHID->GetCollect(_T("ID")).ulVal; //dwchid = 195
|
|
}
|
|
pRecCHID->Close();
|
|
|
|
iRecIndex = (int)VAL_ZERO;
|
|
iRecCount = (int)VAL_ZERO;
|
|
iTpAmount = (int)VAL_ZERO;
|
|
iTsn = (int)VAL_ONE;
|
|
|
|
iRecCount = pChannel->m_sptRecArray.GetSize(); //IREADCOUNT = 84
|
|
while (iRecIndex < iRecCount)
|
|
{
|
|
pSptRecord = (CSptRecord*)pChannel->m_sptRecArray.GetAt(iRecIndex);
|
|
if (TRUE == pSptRecord->m_bIsSel)
|
|
{
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into script2d(CHID,TSN,C1,C2,P1,P2,K,N,Layer,XPos) values(%u,%d,%d,%d,%d,%d,%f,%d,%d,%f) "),
|
|
dwCHID,
|
|
iTsn, //如是多通道,则此处需修改
|
|
pSptRecord->m_iC1,
|
|
pSptRecord->m_iC2,
|
|
pSptRecord->m_iP1,
|
|
pSptRecord->m_iP2,
|
|
pSptRecord->m_fK,
|
|
pSptRecord->m_iN,
|
|
pSptRecord->m_iLevel,
|
|
pSptRecord->m_fSptXPos);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
iTpAmount++;
|
|
iTsn++;
|
|
}
|
|
delete pSptRecord;
|
|
pSptRecord = NULL;
|
|
iRecIndex++;
|
|
}
|
|
pChannel->m_sptRecArray.RemoveAll();
|
|
|
|
szSql.Empty();
|
|
if (AR_CROSS_HOLE_TYPE == pChannel->m_pMedium->m_iAR
|
|
|| AR_CROSS_HOLE_GEOMATIVE == pChannel->m_pMedium->m_iAR)
|
|
{
|
|
float fCrossHole = 0;
|
|
CString strCrosshole = _T("");
|
|
pChannel->m_pMedium->GetParamVal(&fCrossHole);
|
|
strCrosshole.Format(_T("0,%.2f"),fCrossHole);
|
|
szSql.Format(_T("update scon set TPamount = %d, PoleDistance = '%s' where ID = %d"), iTpAmount, strCrosshole, dwSConID);
|
|
}
|
|
else
|
|
szSql.Format(_T("update scon set TPamount = %d where ID = %d"), iTpAmount, dwSConID);
|
|
pCmdUpd->CommandText = szSql.AllocSysString();
|
|
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
|
|
|
delete pChannel;
|
|
pChannel = NULL;
|
|
|
|
iChIndex++;
|
|
}
|
|
pNewScript->m_chaList.RemoveAll();
|
|
|
|
uExecCode = APP_SUCCESS;
|
|
theApp.m_pConnection->CommitTrans();
|
|
break;
|
|
case RET_CANCEL:
|
|
uExecCode = APP_CANCLE;
|
|
break;
|
|
default:
|
|
uExecCode = APP_FAIL;
|
|
break;
|
|
}
|
|
delete pNewScript;
|
|
|
|
pOpCreateSptDlg->DestroyWindow();
|
|
delete pOpCreateSptDlg;
|
|
|
|
return uExecCode;
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
//如果返回的是OK,肯定进行了数据库的相关操作,此时需要进行回滚
|
|
if (RET_OK == lRetBackup)
|
|
{
|
|
theApp.m_pConnection->RollbackTrans();
|
|
}
|
|
pOpCreateSptDlg->DestroyWindow();
|
|
AfxMessageBox(e.Description());
|
|
delete pOpCreateSptDlg;
|
|
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void CSptManager::Delete2DSConInDB(DWORD dwSConID)
|
|
{
|
|
_RecordsetPtr pRecCha = NULL;
|
|
|
|
_CommandPtr pCmdDel;
|
|
_CommandPtr pCmdUpd;
|
|
|
|
CString szSql = _T("");
|
|
|
|
pRecCha.CreateInstance(_uuidof(Recordset));
|
|
|
|
pCmdDel.CreateInstance(_uuidof(Command));
|
|
pCmdDel->ActiveConnection = theApp.m_pConnection;
|
|
|
|
pCmdUpd.CreateInstance(_uuidof(Command));
|
|
pCmdUpd->ActiveConnection = theApp.m_pConnection;
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ID from channel where SCID = %d"), dwSConID);
|
|
pRecCha->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecCha->adoEOF)
|
|
{
|
|
szSql.Empty();
|
|
szSql.Format(_T("delete from script2d where CHID = %u"), (DWORD)pRecCha->GetCollect(_T("ID")).ulVal);
|
|
pCmdDel->CommandText = szSql.AllocSysString();
|
|
pCmdDel->Execute(NULL, NULL, adCmdText);
|
|
|
|
pRecCha->MoveNext();
|
|
} //while ((short)VAL_ZERO == pRecCha->adoEOF)
|
|
pRecCha->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("delete from channel where SCID = %u"), dwSConID);
|
|
pCmdDel->CommandText = szSql.AllocSysString();
|
|
pCmdDel->Execute(NULL, NULL, adCmdText);
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("delete from scon where ID = %u"), dwSConID);
|
|
pCmdDel->CommandText = szSql.AllocSysString();
|
|
pCmdDel->Execute(NULL, NULL, adCmdText);
|
|
}
|
|
|
|
UINT CSptManager::CreateCESConInDB(DWORD& dwSConID)
|
|
{
|
|
INT_PTR lRet = (long)VAL_ZERO;
|
|
INT_PTR lRetBackup = lRet;
|
|
|
|
UINT uExecCode = (UINT)VAL_ZERO;
|
|
|
|
m_pNewScript = new CScriptCE((DWORD)VAL_ZERO, theApp.m_pConnection);
|
|
|
|
m_pNewScript->m_iEAmount = 4;
|
|
m_pNewScript->m_iSType = 0;
|
|
|
|
m_pChannel = new CChannel;
|
|
m_pChannel->m_iChNumber = (int)VAL_ONE;
|
|
m_pNewScript->m_chaList.AddTail((void*)m_pChannel);
|
|
|
|
m_pOpCreateCESptDlg = new COpCreateCESptDlg(m_pNewScript, &m_medLinkList, (INT_PTR*)&lRet);
|
|
if (NULL == m_pOpCreateCESptDlg)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
m_pOpCreateCESptDlg->Create(IDD_OP_SPT_DB_C, AfxGetMainWnd());
|
|
|
|
try
|
|
{
|
|
this->InitialCreateCESConDlg(m_pOpCreateCESptDlg);
|
|
|
|
m_pOpCreateCESptDlg->ShowWindow(SW_SHOW);
|
|
|
|
lRet = m_pOpCreateCESptDlg->RunModalLoop(MLF_SHOWONIDLE);
|
|
int iChCount = (int)VAL_ZERO;
|
|
lRetBackup = lRet;
|
|
lRetBackup = lRet;
|
|
switch (lRet)
|
|
{
|
|
case RET_OK:
|
|
{
|
|
|
|
CString szCN = _T("");
|
|
CString szSql = _T("");
|
|
CString szSName = _T("");
|
|
CString szDefiner = _T("");
|
|
CString szDeDate = _T("");
|
|
CString szScDesc = _T("");
|
|
|
|
_RecordsetPtr pRecSCID = NULL;
|
|
_RecordsetPtr pRecCHID = NULL;
|
|
|
|
_CommandPtr pCmdIns = NULL;
|
|
_CommandPtr pCmdUpd = NULL;
|
|
|
|
int iChCount = (int)VAL_ZERO;
|
|
int iChIndex = (int)VAL_ZERO;
|
|
POSITION posCh = NULL;
|
|
|
|
int iRecCount = (int)VAL_ZERO;
|
|
int iRecIndex = (int)VAL_ZERO;
|
|
|
|
int iTpAmount = (int)VAL_ZERO;
|
|
int iTsn = (int)VAL_ZERO;
|
|
|
|
// DWORD dwSCID = (DWORD)VAL_ZERO;
|
|
//DWORD dwSConID = (DWORD)VAL_ZERO;
|
|
DWORD dwCHID = (DWORD)VAL_ZERO;
|
|
INT_PTR lRet = (long)VAL_ZERO;
|
|
INT_PTR lRetBackup = lRet;
|
|
|
|
CSptRecord* pSptRecord = NULL;
|
|
UINT uExecCode = (UINT)VAL_ZERO;
|
|
try
|
|
{
|
|
theApp.m_pConnection->BeginTrans();
|
|
pRecSCID.CreateInstance(_uuidof(Recordset));
|
|
pRecCHID.CreateInstance(_uuidof(Recordset));
|
|
|
|
pCmdIns.CreateInstance(_uuidof(Command));
|
|
pCmdIns->ActiveConnection = theApp.m_pConnection;
|
|
|
|
pCmdUpd.CreateInstance(_uuidof(Command));
|
|
pCmdUpd->ActiveConnection = theApp.m_pConnection;
|
|
|
|
szCN.Empty();
|
|
szCN = m_guCodeCreator.GenerateGUIDCode();
|
|
szSName.Empty();
|
|
((CEdit*)m_pOpCreateCESptDlg->GetDlgItem(IDC_SPT_SNAME))->GetWindowText(szSName);
|
|
szSName.TrimLeft();
|
|
szSName.TrimRight();
|
|
szDefiner.Empty();
|
|
//CEdit* p = ((CEdit*)pThis->m_pOpCreateCESptDlg->GetDlgItem(IDC_SPT_DEFINER));
|
|
CEdit *p = m_pOpCreateCESptDlg->GetEdDefiner();
|
|
p->GetWindowText(szDefiner);
|
|
//((CEdit*)pThis->m_pOpCreateCESptDlg->GetDlgItem(IDC_SPT_DEFINER))->GetWindowText(szDefiner);
|
|
szScDesc.Empty();
|
|
p = m_pOpCreateCESptDlg->GetEdScDesc();
|
|
p->GetWindowText(szScDesc);
|
|
//((CEdit*)pThis->m_pOpCreateCESptDlg->GetDlgItem(IDC_SPT_SCDESC))->GetWindowText(szScDesc);
|
|
|
|
m_pNewScript->m_iSType = 0;
|
|
iChCount = m_pNewScript->m_chaList.GetCount();
|
|
/////////////////////////////////检测是否有相同的名称的脚本/////////////////////////////////////////
|
|
szSql.Empty();
|
|
szSql.Format(_T("select * from scon where Sname = '%s'"), szSName);
|
|
pRecSCID->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecSCID->GetRecordCount())
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("脚本已存在."));
|
|
else
|
|
MessageBoxEx(NULL, _T("Script has been alreay exists."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
pRecSCID->Close();
|
|
theApp.m_pConnection->RollbackTrans();
|
|
m_pNewScript->m_chaList.RemoveAll();
|
|
if (NULL != m_pNewScript)
|
|
{
|
|
delete m_pNewScript;
|
|
m_pNewScript = NULL;
|
|
}
|
|
|
|
m_pOpCreateCESptDlg->DestroyWindow();
|
|
if (NULL != m_pOpCreateCESptDlg)
|
|
{
|
|
delete m_pOpCreateCESptDlg;
|
|
m_pOpCreateCESptDlg = NULL;
|
|
}
|
|
return APP_FAIL;
|
|
}
|
|
pRecSCID->Close();
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into scon(CN,Sname,Stype,Eamount,CHamount,TPamount,definer,DEdate,SCdesc,Rect,RectLoc,PoleDistance,PoleStep) "
|
|
"values('%s','%s',%d,%d,%d,%d,'%s',#%s#,'%s','%s','%s','%s','%s')"),
|
|
szCN,
|
|
szSName,
|
|
m_pNewScript->m_iSType,
|
|
m_pNewScript->m_iEAmount,
|
|
iChCount,
|
|
iTpAmount,
|
|
szDefiner,
|
|
m_pOpCreateCESptDlg->m_edDeDate.FormatGmt("%Y-%m-%d"),
|
|
szScDesc,
|
|
"0,0,0,0",
|
|
"0",
|
|
"0",
|
|
"0");
|
|
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
pRecSCID->Open(_T("select max(ID) as ID from scon"), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecSCID->GetRecordCount())
|
|
{
|
|
dwSConID = (DWORD)pRecSCID->GetCollect(_T("ID")).ulVal;
|
|
}
|
|
pRecSCID->Close();
|
|
|
|
posCh = NULL;
|
|
iChIndex = (int)VAL_ZERO;
|
|
|
|
while (iChIndex < iChCount)
|
|
{
|
|
posCh = m_pNewScript->m_chaList.FindIndex(iChIndex);
|
|
m_pChannel = (CChannel*)m_pNewScript->m_chaList.GetAt(posCh);
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into channel(SCID,CHnumber,AR) values(%u,%d,%d) "),
|
|
dwSConID,
|
|
m_pChannel->m_iChNumber,
|
|
m_pChannel->m_pMedium->m_iAR);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
pRecCHID->Open(_T("select max(ID) as ID from channel"), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecCHID->GetRecordCount())
|
|
{
|
|
dwCHID = (DWORD)pRecCHID->GetCollect(_T("ID")).ulVal;
|
|
}
|
|
pRecCHID->Close();
|
|
|
|
iRecIndex = (int)VAL_ZERO;
|
|
iRecCount = (int)VAL_ZERO;
|
|
iTpAmount = (int)VAL_ZERO;
|
|
|
|
iTpAmount = m_pChannel->m_sptRecArray.GetSize();
|
|
|
|
while (iRecIndex < iTpAmount)
|
|
{
|
|
pSptRecord = (CSptRecord*)m_pChannel->m_sptRecArray.GetAt(iRecIndex);
|
|
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into script1d(CHID,TSN,a,b,x,y,K,N) values(%u,%d,%.2f,%.2f,%.2f,%.2f,%f,%d) "),
|
|
dwCHID,
|
|
pSptRecord->m_iTsn, //如是多通道,则此处需修改
|
|
pSptRecord->m_fA,
|
|
pSptRecord->m_fB,
|
|
pSptRecord->m_fX,
|
|
pSptRecord->m_fY,
|
|
pSptRecord->m_fK,
|
|
pSptRecord->m_iN);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
delete pSptRecord;
|
|
pSptRecord = NULL;
|
|
iRecIndex++;
|
|
}
|
|
m_pChannel->m_sptRecArray.RemoveAll();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("update scon set TPamount = %d where ID = %d"), iTpAmount, dwSConID);
|
|
pCmdUpd->CommandText = szSql.AllocSysString();
|
|
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
|
|
|
if (NULL != m_pChannel)
|
|
{
|
|
delete m_pChannel;
|
|
m_pChannel = NULL;
|
|
}
|
|
iChIndex++;
|
|
}
|
|
m_pNewScript->m_chaList.RemoveAll();
|
|
uExecCode = APP_SUCCESS;
|
|
theApp.m_pConnection->CommitTrans();
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
if (RET_OK == lRetBackup)
|
|
{
|
|
theApp.m_pConnection->RollbackTrans();
|
|
}
|
|
m_pOpCreateCESptDlg->DestroyWindow();
|
|
delete m_pOpCreateCESptDlg;
|
|
AfxMessageBox(e.Description());
|
|
|
|
throw e;
|
|
}
|
|
}
|
|
break;
|
|
case RET_CANCEL:
|
|
uExecCode = APP_CANCLE;
|
|
break;
|
|
default:
|
|
uExecCode = APP_FAIL;
|
|
break;
|
|
}
|
|
|
|
|
|
//HANDLE handle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)SaveTestPointToDBThread, this, 0, NULL);
|
|
//WaitForSingleObject(handle, INFINITE);//added 20210821
|
|
//CloseHandle(handle);
|
|
|
|
if (NULL != m_pNewScript)
|
|
{
|
|
delete m_pNewScript;
|
|
m_pNewScript = NULL;
|
|
}
|
|
|
|
m_pOpCreateCESptDlg->DestroyWindow();
|
|
if (NULL != m_pOpCreateCESptDlg)
|
|
{
|
|
delete m_pOpCreateCESptDlg;
|
|
m_pOpCreateCESptDlg = NULL;
|
|
}
|
|
return uExecCode;
|
|
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
if (RET_OK == lRetBackup)
|
|
{
|
|
theApp.m_pConnection->RollbackTrans();
|
|
}
|
|
m_pOpCreateCESptDlg->DestroyWindow();
|
|
if (NULL != m_pOpCreateCESptDlg)
|
|
{
|
|
delete m_pOpCreateCESptDlg;
|
|
m_pOpCreateCESptDlg = NULL;
|
|
}
|
|
AfxMessageBox(e.Description());
|
|
|
|
throw e;
|
|
}
|
|
|
|
}
|
|
|
|
//保存脚本测点到数据库线程
|
|
UINT CSptManager::SaveTestPointToDBThread(LPVOID lPrama)
|
|
{
|
|
CSptManager* pThis = (CSptManager*)lPrama;
|
|
if (NULL == pThis)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
CString szCN = _T("");
|
|
CString szSql = _T("");
|
|
CString szSName = _T("");
|
|
CString szDefiner = _T("");
|
|
CString szDeDate = _T("");
|
|
CString szScDesc = _T("");
|
|
|
|
_RecordsetPtr pRecSCID = NULL;
|
|
_RecordsetPtr pRecCHID = NULL;
|
|
|
|
_CommandPtr pCmdIns = NULL;
|
|
_CommandPtr pCmdUpd = NULL;
|
|
|
|
int iChCount = (int)VAL_ZERO;
|
|
int iChIndex = (int)VAL_ZERO;
|
|
POSITION posCh = NULL;
|
|
|
|
int iRecCount = (int)VAL_ZERO;
|
|
int iRecIndex = (int)VAL_ZERO;
|
|
|
|
int iTpAmount = (int)VAL_ZERO;
|
|
int iTsn = (int)VAL_ZERO;
|
|
|
|
// DWORD dwSCID = (DWORD)VAL_ZERO;
|
|
DWORD dwSConID = (DWORD)VAL_ZERO;
|
|
DWORD dwCHID = (DWORD)VAL_ZERO;
|
|
INT_PTR lRet = (long)VAL_ZERO;
|
|
INT_PTR lRetBackup = lRet;
|
|
|
|
CSptRecord* pSptRecord = NULL;
|
|
UINT uExecCode = (UINT)VAL_ZERO;
|
|
try
|
|
{
|
|
theApp.m_pConnection->BeginTrans();
|
|
pRecSCID.CreateInstance(_uuidof(Recordset));
|
|
pRecCHID.CreateInstance(_uuidof(Recordset));
|
|
|
|
pCmdIns.CreateInstance(_uuidof(Command));
|
|
pCmdIns->ActiveConnection = theApp.m_pConnection;
|
|
|
|
pCmdUpd.CreateInstance(_uuidof(Command));
|
|
pCmdUpd->ActiveConnection = theApp.m_pConnection;
|
|
|
|
szCN.Empty();
|
|
szCN = pThis->m_guCodeCreator.GenerateGUIDCode();
|
|
szSName.Empty();
|
|
((CEdit*)pThis->m_pOpCreateCESptDlg->GetDlgItem(IDC_SPT_SNAME))->GetWindowText(szSName);
|
|
szSName.TrimLeft();
|
|
szSName.TrimRight();
|
|
szDefiner.Empty();
|
|
//CEdit* p = ((CEdit*)pThis->m_pOpCreateCESptDlg->GetDlgItem(IDC_SPT_DEFINER));
|
|
CEdit *p = pThis->m_pOpCreateCESptDlg->GetEdDefiner();
|
|
p->GetWindowText(szDefiner);
|
|
//((CEdit*)pThis->m_pOpCreateCESptDlg->GetDlgItem(IDC_SPT_DEFINER))->GetWindowText(szDefiner);
|
|
szScDesc.Empty();
|
|
p = pThis->m_pOpCreateCESptDlg->GetEdScDesc();
|
|
p->GetWindowText(szScDesc);
|
|
//((CEdit*)pThis->m_pOpCreateCESptDlg->GetDlgItem(IDC_SPT_SCDESC))->GetWindowText(szScDesc);
|
|
|
|
|
|
|
|
pThis->m_pNewScript->m_iSType = 0;
|
|
iChCount = pThis->m_pNewScript->m_chaList.GetCount();
|
|
/////////////////////////////////检测是否有相同的名称的脚本/////////////////////////////////////////
|
|
szSql.Empty();
|
|
szSql.Format(_T("select * from scon where Sname = '%s'"), szSName);
|
|
pRecSCID->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecSCID->GetRecordCount())
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("脚本已存在."));
|
|
else
|
|
MessageBoxEx(NULL, _T("Script has been alreay exists."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
pRecSCID->Close();
|
|
theApp.m_pConnection->RollbackTrans();
|
|
pThis->m_pNewScript->m_chaList.RemoveAll();
|
|
if (NULL != pThis->m_pNewScript)
|
|
{
|
|
delete pThis->m_pNewScript;
|
|
pThis->m_pNewScript = NULL;
|
|
}
|
|
|
|
pThis->m_pOpCreateCESptDlg->DestroyWindow();
|
|
if (NULL != pThis->m_pOpCreateCESptDlg)
|
|
{
|
|
delete pThis->m_pOpCreateCESptDlg;
|
|
pThis->m_pOpCreateCESptDlg = NULL;
|
|
}
|
|
return APP_FAIL;
|
|
}
|
|
pRecSCID->Close();
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into scon(CN,Sname,Stype,Eamount,CHamount,TPamount,definer,DEdate,SCdesc,Rect,RectLoc,PoleDistance,PoleStep) "
|
|
"values('%s','%s',%d,%d,%d,%d,'%s',#%s#,'%s','%s','%s','%s','%s')"),
|
|
szCN,
|
|
szSName,
|
|
pThis->m_pNewScript->m_iSType,
|
|
pThis->m_pNewScript->m_iEAmount,
|
|
iChCount,
|
|
iTpAmount,
|
|
szDefiner,
|
|
pThis->m_pOpCreateCESptDlg->m_edDeDate.FormatGmt("%Y-%m-%d"),
|
|
szScDesc,
|
|
"0,0,0,0",
|
|
"0",
|
|
"0",
|
|
"0");
|
|
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
pRecSCID->Open(_T("select max(ID) as ID from scon"), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecSCID->GetRecordCount())
|
|
{
|
|
dwSConID = (DWORD)pRecSCID->GetCollect(_T("ID")).ulVal;
|
|
}
|
|
pRecSCID->Close();
|
|
|
|
posCh = NULL;
|
|
iChIndex = (int)VAL_ZERO;
|
|
|
|
while (iChIndex < iChCount)
|
|
{
|
|
posCh = pThis->m_pNewScript->m_chaList.FindIndex(iChIndex);
|
|
pThis->m_pChannel = (CChannel*)pThis->m_pNewScript->m_chaList.GetAt(posCh);
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into channel(SCID,CHnumber,AR) values(%u,%d,%d) "),
|
|
dwSConID,
|
|
pThis->m_pChannel->m_iChNumber,
|
|
pThis->m_pChannel->m_pMedium->m_iAR);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
pRecCHID->Open(_T("select max(ID) as ID from channel"), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecCHID->GetRecordCount())
|
|
{
|
|
dwCHID = (DWORD)pRecCHID->GetCollect(_T("ID")).ulVal;
|
|
}
|
|
pRecCHID->Close();
|
|
|
|
iRecIndex = (int)VAL_ZERO;
|
|
iRecCount = (int)VAL_ZERO;
|
|
iTpAmount = (int)VAL_ZERO;
|
|
|
|
iTpAmount = pThis->m_pChannel->m_sptRecArray.GetSize();
|
|
|
|
while (iRecIndex < iTpAmount)
|
|
{
|
|
pSptRecord = (CSptRecord*)pThis->m_pChannel->m_sptRecArray.GetAt(iRecIndex);
|
|
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into script1d(CHID,TSN,a,b,x,y,K,N) values(%u,%d,%.2f,%.2f,%.2f,%.2f,%f,%d) "),
|
|
dwCHID,
|
|
pSptRecord->m_iTsn, //如是多通道,则此处需修改
|
|
pSptRecord->m_fA,
|
|
pSptRecord->m_fB,
|
|
pSptRecord->m_fX,
|
|
pSptRecord->m_fY,
|
|
pSptRecord->m_fK,
|
|
pSptRecord->m_iN);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
delete pSptRecord;
|
|
pSptRecord = NULL;
|
|
iRecIndex++;
|
|
}
|
|
pThis->m_pChannel->m_sptRecArray.RemoveAll();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("update scon set TPamount = %d where ID = %d"), iTpAmount, dwSConID);
|
|
pCmdUpd->CommandText = szSql.AllocSysString();
|
|
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
|
|
|
if (NULL != pThis->m_pChannel)
|
|
{
|
|
delete pThis->m_pChannel;
|
|
pThis->m_pChannel = NULL;
|
|
}
|
|
iChIndex++;
|
|
}
|
|
pThis->m_pNewScript->m_chaList.RemoveAll();
|
|
uExecCode = APP_SUCCESS;
|
|
theApp.m_pConnection->CommitTrans();
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
if (RET_OK == lRetBackup)
|
|
{
|
|
theApp.m_pConnection->RollbackTrans();
|
|
}
|
|
pThis->m_pOpCreateCESptDlg->DestroyWindow();
|
|
delete pThis->m_pOpCreateCESptDlg;
|
|
AfxMessageBox(e.Description());
|
|
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
void CSptManager::DeleteCESConInDB(DWORD dwSConID)
|
|
{
|
|
_RecordsetPtr pRecCha = NULL;
|
|
|
|
_CommandPtr pCmdDel;
|
|
_CommandPtr pCmdUpd;
|
|
|
|
CString szSql = _T("");
|
|
|
|
pRecCha.CreateInstance(_uuidof(Recordset));
|
|
|
|
pCmdDel.CreateInstance(_uuidof(Command));
|
|
pCmdDel->ActiveConnection = theApp.m_pConnection;
|
|
|
|
pCmdUpd.CreateInstance(_uuidof(Command));
|
|
pCmdUpd->ActiveConnection = theApp.m_pConnection;
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ID from channel where SCID = %d"), dwSConID);
|
|
pRecCha->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecCha->adoEOF)
|
|
{
|
|
szSql.Empty();
|
|
szSql.Format(_T("delete from script1d where CHID = %u"), (DWORD)pRecCha->GetCollect(_T("ID")).ulVal);
|
|
pCmdDel->CommandText = szSql.AllocSysString();
|
|
pCmdDel->Execute(NULL, NULL, adCmdText);
|
|
|
|
pRecCha->MoveNext();
|
|
} //while ((short)VAL_ZERO == pRecCha->adoEOF)
|
|
pRecCha->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("delete from channel where SCID = %u"), dwSConID);
|
|
|
|
pCmdDel->CommandText = szSql.AllocSysString();
|
|
pCmdDel->Execute(NULL, NULL, adCmdText);
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("delete from scon where ID = %u"), dwSConID);
|
|
pCmdDel->CommandText = szSql.AllocSysString();
|
|
pCmdDel->Execute(NULL, NULL, adCmdText);
|
|
}
|
|
|
|
void CSptManager::Initial2DSptList(CListCtrl &sptList)
|
|
{
|
|
_RecordsetPtr pRecSptList = NULL;
|
|
_RecordsetPtr pRecSCon = NULL;
|
|
_RecordsetPtr pRecMed = NULL;
|
|
|
|
DWORD dwSptHandle = (DWORD)VAL_ZERO;
|
|
|
|
int iIndex = (int)VAL_ZERO;
|
|
CString szSql;
|
|
CString szLabel;
|
|
|
|
pRecMed.CreateInstance(_uuidof(Recordset));
|
|
pRecSptList.CreateInstance(_uuidof(Recordset));
|
|
pRecSCon.CreateInstance(_uuidof(Recordset));
|
|
|
|
pRecSptList->Open(_T("select ID,CN,Sname,Eamount,CHamount,TPamount,definer,Format(DEdate,'YYYY-MM-DD') as DEdate,SCdesc from scon where Stype = 1"),
|
|
_variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecSptList->adoEOF)
|
|
{
|
|
sptList.InsertItem(iIndex, pRecSptList->GetCollect(_T("CN")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("CN")));
|
|
|
|
sptList.SetItemText(iIndex, 1, pRecSptList->GetCollect(_T("Sname")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("Sname")));
|
|
|
|
sptList.SetItemText(iIndex, 2, pRecSptList->GetCollect(_T("Eamount")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("Eamount")));
|
|
sptList.SetItemText(iIndex, 3, pRecSptList->GetCollect(_T("CHamount")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("CHamount")));
|
|
|
|
sptList.SetItemText(iIndex, 4, pRecSptList->GetCollect(_T("TPamount")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("TPamount")));
|
|
sptList.SetItemText(iIndex, 5, pRecSptList->GetCollect(_T("definer")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("definer")));
|
|
sptList.SetItemText(iIndex, 6, pRecSptList->GetCollect(_T("DEdate")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("DEdate")));
|
|
|
|
sptList.SetItemText(iIndex, 7, pRecSptList->GetCollect(_T("SCdesc")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("SCdesc")));
|
|
|
|
dwSptHandle = m_handleProcessor.GenerateHandle((DWORD)pRecSptList->GetCollect(_T("ID")).ulVal, PZ_STYLE_SCON_2D);
|
|
|
|
sptList.SetItemData(iIndex, dwSptHandle);
|
|
|
|
iIndex++;
|
|
|
|
pRecSptList->MoveNext();
|
|
|
|
} //while (VAL_ZERO == pRecProID->adoEOF)
|
|
pRecSptList->Close();
|
|
|
|
sptList.SetHotItem((int)VAL_ZERO);
|
|
}
|
|
|
|
void CSptManager::InitialSptList(CListCtrl &sptList)
|
|
{
|
|
_RecordsetPtr pRecSptList = NULL;
|
|
_RecordsetPtr pRecCm = NULL;
|
|
|
|
DWORD dwSptHandle = (DWORD)VAL_ZERO;
|
|
|
|
int iIndex = (int)VAL_ZERO;
|
|
CString szSql = _T("");
|
|
CString szLabel = _T("");
|
|
|
|
sptList.DeleteAllItems();
|
|
|
|
pRecSptList.CreateInstance(_uuidof(Recordset));
|
|
pRecCm.CreateInstance(_uuidof(Recordset));
|
|
|
|
pRecSptList->Open(_T("select ID,CN,Sname,Stype,Eamount,TPamount,definer,Format(DEdate,'YYYY-MM-DD') as DEdate,SCdesc from scon"),
|
|
_variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecSptList->adoEOF)
|
|
{
|
|
//注释原因:去掉CN那一列,直接显示名字
|
|
// sptList.InsertItem(iIndex, pRecSptList->GetCollect(_T("CN")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("CN")));
|
|
|
|
// sptList.SetItemText(iIndex, 1, pRecSptList->GetCollect(_T("Sname")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("Sname")));
|
|
|
|
//新增
|
|
sptList.InsertItem(iIndex, pRecSptList->GetCollect(_T("Sname")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("Sname")));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Stype' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecSptList->GetCollect(_T("Stype")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("Stype")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
|
{
|
|
sptList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
sptList.SetItemText(iIndex, 2, pRecSptList->GetCollect(_T("Eamount")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("Eamount")));
|
|
|
|
sptList.SetItemText(iIndex, 3, pRecSptList->GetCollect(_T("TPamount")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("TPamount")));
|
|
sptList.SetItemText(iIndex, 4, pRecSptList->GetCollect(_T("definer")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("definer")));
|
|
sptList.SetItemText(iIndex, 5, pRecSptList->GetCollect(_T("DEdate")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("DEdate")));
|
|
|
|
sptList.SetItemText(iIndex, 6, pRecSptList->GetCollect(_T("SCdesc")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("SCdesc")));
|
|
|
|
sptList.SetItemData(iIndex, (DWORD)pRecSptList->GetCollect(_T("ID")).ulVal);
|
|
|
|
iIndex++;
|
|
|
|
pRecSptList->MoveNext();
|
|
}
|
|
pRecSptList->Close();
|
|
|
|
sptList.SetHotItem((int)VAL_ZERO);
|
|
}
|
|
|
|
void CSptManager::InitialCreateSConDlg(COpCreateSptDlg* const pOpCreateSptDlg)
|
|
{
|
|
_RecordsetPtr pRecAR = NULL;
|
|
|
|
CString szSql = _T("");
|
|
|
|
CComboBox * pCbAR = NULL;
|
|
|
|
pCbAR = (CComboBox*)pOpCreateSptDlg->GetDlgItem(IDC_SPT_AR);
|
|
|
|
pRecAR.CreateInstance(_uuidof(Recordset));
|
|
//获取配置文件
|
|
g_iLanguage = GetPrivateProfileInt(_T("UI"), _T("Language"), 0, _T("./config.ini"));
|
|
szSql.Empty();
|
|
szSql.Format(_T("select AR,MEname from medium where AR in (%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d) and LANG = %d"), \
|
|
AR_WENNER_ALPHA, AR_WENNER_BETA, AR_WENNER_GAMMA, AR_POLE_DIPOLE_AMN, AR_DIPOLE_POLE_MNB,AR_POLE_POLE_AM,\
|
|
AR_DIP_DIP, AR_SCHLUMBERGER, AR_CROSS_HOLE_TYPE, AR_WENNER_SCH_BASIC, AR_WENNER_SCHLUMBERGER, AR_EDGE_GARDIENT, AR_BIPOLE_HOLE_SPT, AR_DOUBLE_SIZE_3P, AR_STRONG_GRADIENT,AR_S3P_MEDIUM, g_iLanguage);
|
|
//louis add 50 AR_WENNER_SCH_BASIC
|
|
pRecAR->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecAR->adoEOF)
|
|
{
|
|
pCbAR->AddString((LPCTSTR)(_bstr_t)pRecAR->GetCollect(_T("MEname")));
|
|
pCbAR->SetItemData(pCbAR->GetCount()-1, pRecAR->GetCollect(_T("AR")).iVal);
|
|
pRecAR->MoveNext();
|
|
}
|
|
//最后放入自定义装置
|
|
if (LANG_ZHCN == g_iLanguage)
|
|
{
|
|
pCbAR->AddString(_T("自定义"));
|
|
pCbAR->SetItemData(pCbAR->GetCount()-1, 40);
|
|
}
|
|
else
|
|
{
|
|
pCbAR->AddString(_T("Custom"));
|
|
pCbAR->SetItemData(pCbAR->GetCount()-1, 40);
|
|
}
|
|
|
|
pRecAR->Close();
|
|
}
|
|
|
|
void CSptManager::InitialCreateCESConDlg(COpCreateCESptDlg* const pOpCreateCESptDlg)
|
|
{
|
|
|
|
}
|
|
|
|
void CSptManager::InitialCreate3DSConDlg(COpCreate3DSptDlg* const pOpCreate3DSptDlg)
|
|
{
|
|
|
|
}
|
|
|
|
void CSptManager::InitialMedLinkList()
|
|
{
|
|
CMedium* pMed = NULL;
|
|
|
|
DWORD dwHandle = (DWORD)VAL_ZERO;
|
|
int iAR = (int)VAL_ZERO;
|
|
|
|
_RecordsetPtr pRecAR = NULL;
|
|
|
|
m_medLinkList.DeleteAll();
|
|
pRecAR.CreateInstance(_uuidof(Recordset));
|
|
try
|
|
{
|
|
pRecAR->Open(_T("select distinct AR as AR from medium order by AR"), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
while ((short)VAL_ZERO == pRecAR->adoEOF)
|
|
{
|
|
pMed = NULL;
|
|
iAR = pRecAR->GetCollect(_T("AR")).iVal;
|
|
switch (iAR)
|
|
{
|
|
case 1:
|
|
pMed = new CMediumA(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 2:
|
|
pMed = new CMediumB(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 3:
|
|
pMed = new CMediumC(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case AR_POLE_DIPOLE_AMN:
|
|
pMed = new CMediumD(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case AR_DIPOLE_POLE_MNB:
|
|
pMed = new CMediumE(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 6:
|
|
pMed = new CMediumAM(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 7:
|
|
pMed = new CMediumAMN(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 8:
|
|
break;
|
|
case 9:
|
|
pMed = new CMediumZC(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 10:
|
|
break;
|
|
case 11:
|
|
pMed = new CMediumK(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 12:
|
|
break;
|
|
case 13:
|
|
break;
|
|
case 14:
|
|
break;
|
|
case 15:
|
|
break;
|
|
case AR_CROSS_HOLE_TYPE:
|
|
pMed = new CMediumLogging(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case AR_CROSS_HOLE_GEOMATIVE:
|
|
{
|
|
pMed = new CMediumCrossHoleGeomative(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
}
|
|
break;
|
|
case AR_CROSS_HOLE_GEOMATIVE_AM:
|
|
{
|
|
pMed = new CMediumCrossHoleGeomativeAM(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
}
|
|
break;
|
|
case 17:
|
|
pMed = new CMediumQ(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 18:
|
|
pMed = new CMediumR(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 19:
|
|
pMed = new CMediumS(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 20:
|
|
pMed = new CMediumT(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 21:
|
|
pMed = new CMediumU(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 22:
|
|
pMed = new CMediumV(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 23:
|
|
pMed = new CMediumW(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 24:
|
|
pMed = new CMediumX(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 25:
|
|
pMed = new CMediumY(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 26:
|
|
pMed = new CMediumZ(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 27:
|
|
pMed = new CMediumZA(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 28:
|
|
pMed = new CMediumZB(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 29:
|
|
pMed = new CMediumMidGardientScan(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
//一维的联合剖面,28-32之间预留给三维
|
|
case 33:
|
|
pMed = new CMediumUnityProfile(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case AR_WENNER_SCH_BASIC://louis added
|
|
pMed = new CMediumBasicWenAndSch(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 39:
|
|
pMed = new CMediumStrongWenAndSch(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case AR_CUSTOM_2D_TYPE:
|
|
pMed = new CMediumCustom2D(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 41:
|
|
pMed = new CMediumEdgeGradient(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case AR_BIPOLE_HOLE_SPT:
|
|
pMed = new CMediumBipoleUpHole(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
|
|
case 43:
|
|
pMed = new CMediumTwoSideAMN(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case AR_STRONG_GRADIENT:
|
|
{
|
|
pMed = new CMediumStrongGradient(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
}
|
|
break;
|
|
case AR_S3P_MEDIUM:
|
|
{
|
|
pMed = new CMediumS3P(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
}
|
|
break;
|
|
case AR_LAND_FILL_ONE:
|
|
{
|
|
pMed = new CMediumLandfillDiagonally(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
}
|
|
break;
|
|
case AR_LAND_FILL_TWO:
|
|
{
|
|
pMed = new CMediumLandfillAdjacent(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
pRecAR->MoveNext();
|
|
}
|
|
pRecAR->Close();
|
|
|
|
}
|
|
|
|
catch (_com_error e)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
CString strInfo = _T("");
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strInfo.Format(_T("初始装置链接失败!errormsg = %s, descmsg = %s"),
|
|
(LPCTSTR)e.ErrorMessage(), (LPCTSTR)e.Description());
|
|
AfxMessageBox(strInfo);
|
|
}
|
|
else
|
|
{
|
|
strInfo.Format(_T("Initial Medium Link failed!errormsg = %s, descmsg = %s"),
|
|
(LPCTSTR)e.ErrorMessage(), (LPCTSTR)e.Description());
|
|
MessageBoxEx(NULL, strInfo, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
return ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BOOL CSptManager::InitialSptListForDev(CListCtrl &sptList, CString szDeSN)
|
|
{
|
|
_RecordsetPtr pRecSpt = NULL;
|
|
_RecordsetPtr pRecCm = NULL;
|
|
|
|
CString szSql = _T("");
|
|
CString szLabel = _T("");
|
|
|
|
int iIndex = (int)VAL_ZERO;
|
|
BOOL bIsSyned = FALSE;
|
|
|
|
sptList.DeleteAllItems();
|
|
pRecSpt.CreateInstance(_uuidof(Recordset));
|
|
pRecCm.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select IsSyned,SCCN,SptName,Stype,SptFileName from dev_syn_spt where DESN = '%s'"), szDeSN);
|
|
pRecSpt->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
//
|
|
while ((short)VAL_ZERO == pRecSpt->adoEOF)
|
|
{
|
|
CString strSptFileName = (LPCTSTR)(_bstr_t)pRecSpt->GetCollect(_T("SptName"));
|
|
//如果发现是标准脚本则不显示
|
|
if (-1 != strSptFileName.Find(_T("standard script")))
|
|
{
|
|
pRecSpt->MoveNext();
|
|
continue;
|
|
}
|
|
if (-1 == pRecSpt->GetCollect(_T("IsSyned")).boolVal)
|
|
{
|
|
szLabel.Empty();
|
|
szLabel.LoadString(IDS_YES);
|
|
bIsSyned = TRUE;
|
|
}
|
|
else
|
|
{
|
|
szLabel.Empty();
|
|
szLabel.LoadString(IDS_NO);
|
|
bIsSyned = FALSE;
|
|
}
|
|
|
|
sptList.InsertItem(iIndex, szLabel);
|
|
//sptList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecSpt->GetCollect(_T("SCCN")));
|
|
sptList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecSpt->GetCollect(_T("SptName")));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Stype' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, (LPCTSTR)(_bstr_t)pRecSpt->GetCollect(_T("Stype")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
|
{
|
|
sptList.SetItemText(iIndex, 2, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
sptList.SetItemText(iIndex, 3, (LPCTSTR)(_bstr_t)pRecSpt->GetCollect(_T("SptFileName")));
|
|
|
|
|
|
sptList.SetItemData(iIndex, bIsSyned);
|
|
|
|
pRecSpt->MoveNext();
|
|
iIndex++;
|
|
}
|
|
pRecSpt->Close();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
void CSptManager::InitialCESptListForSyn(CListCtrl &sptList, CString szDeSN)
|
|
{
|
|
_RecordsetPtr pRecSptList = NULL;
|
|
_RecordsetPtr pRecSCon = NULL;
|
|
_RecordsetPtr pRecMed = NULL;
|
|
|
|
DWORD dwSptHandle = (DWORD)VAL_ZERO;
|
|
|
|
int iIndex = (int)VAL_ZERO;
|
|
CString szSql;
|
|
CString szLabel;
|
|
|
|
pRecMed.CreateInstance(_uuidof(Recordset));
|
|
pRecSptList.CreateInstance(_uuidof(Recordset));
|
|
pRecSCon.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ID,CN,Sname,Eamount,CHamount,TPamount,definer,Format(DEdate,'YYYY-MM-DD') as DEdate,SCdesc from scon where CN in (select SCCN from dev_syn_spt where DESN = '%s' and Stype = 0) "
|
|
"and Stype = 0"), szDeSN);
|
|
|
|
pRecSptList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecSptList->adoEOF)
|
|
{
|
|
sptList.InsertItem(iIndex, pRecSptList->GetCollect(_T("CN")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("CN")));
|
|
|
|
sptList.SetItemText(iIndex, 1, pRecSptList->GetCollect(_T("Sname")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("Sname")));
|
|
|
|
sptList.SetItemText(iIndex, 2, pRecSptList->GetCollect(_T("Eamount")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("Eamount")));
|
|
|
|
sptList.SetItemText(iIndex, 3, pRecSptList->GetCollect(_T("TPamount")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("TPamount")));
|
|
sptList.SetItemText(iIndex, 4, pRecSptList->GetCollect(_T("definer")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("definer")));
|
|
sptList.SetItemText(iIndex, 5, pRecSptList->GetCollect(_T("DEdate")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("DEdate")));
|
|
|
|
sptList.SetItemText(iIndex, 6, pRecSptList->GetCollect(_T("SCdesc")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("SCdesc")));
|
|
|
|
dwSptHandle = m_handleProcessor.GenerateHandle((DWORD)pRecSptList->GetCollect(_T("ID")).ulVal, PZ_STYLE_SCON_2D);
|
|
|
|
sptList.SetItemData(iIndex, dwSptHandle);
|
|
|
|
iIndex++;
|
|
|
|
pRecSptList->MoveNext();
|
|
|
|
} //while (VAL_ZERO == pRecProID->adoEOF)
|
|
pRecSptList->Close();
|
|
|
|
sptList.SetHotItem((int)VAL_ZERO);
|
|
}
|
|
|
|
void CSptManager::Initial2DSptListForSyn(CListCtrl &sptList, CString szDeSN)
|
|
{
|
|
_RecordsetPtr pRecSptList = NULL;
|
|
_RecordsetPtr pRecSCon = NULL;
|
|
_RecordsetPtr pRecMed = NULL;
|
|
|
|
DWORD dwSptHandle = (DWORD)VAL_ZERO;
|
|
|
|
int iIndex = (int)VAL_ZERO;
|
|
CString szSql;
|
|
CString szLabel;
|
|
|
|
pRecMed.CreateInstance(_uuidof(Recordset));
|
|
pRecSptList.CreateInstance(_uuidof(Recordset));
|
|
pRecSCon.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ID,CN,Sname,Eamount,CHamount,TPamount,definer,Format(DEdate,'YYYY-MM-DD') as DEdate,SCdesc from scon where CN in (select SCCN from dev_syn_spt where DESN = '%s' and Stype = 1) "
|
|
"and Stype = 1"), szDeSN);
|
|
pRecSptList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecSptList->adoEOF)
|
|
{
|
|
sptList.InsertItem(iIndex, pRecSptList->GetCollect(_T("CN")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("CN")));
|
|
|
|
sptList.SetItemText(iIndex, 1, pRecSptList->GetCollect(_T("Sname")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("Sname")));
|
|
|
|
sptList.SetItemText(iIndex, 2, pRecSptList->GetCollect(_T("Eamount")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("Eamount")));
|
|
sptList.SetItemText(iIndex, 3, pRecSptList->GetCollect(_T("CHamount")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("CHamount")));
|
|
|
|
sptList.SetItemText(iIndex, 4, pRecSptList->GetCollect(_T("TPamount")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("TPamount")));
|
|
sptList.SetItemText(iIndex, 5, pRecSptList->GetCollect(_T("definer")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("definer")));
|
|
sptList.SetItemText(iIndex, 6, pRecSptList->GetCollect(_T("DEdate")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("DEdate")));
|
|
|
|
sptList.SetItemText(iIndex, 7, pRecSptList->GetCollect(_T("SCdesc")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("SCdesc")));
|
|
|
|
dwSptHandle = m_handleProcessor.GenerateHandle((DWORD)pRecSptList->GetCollect(_T("ID")).ulVal, PZ_STYLE_SCON_2D);
|
|
|
|
sptList.SetItemData(iIndex, dwSptHandle);
|
|
|
|
iIndex++;
|
|
|
|
pRecSptList->MoveNext();
|
|
|
|
} //while (VAL_ZERO == pRecProID->adoEOF)
|
|
pRecSptList->Close();
|
|
|
|
sptList.SetHotItem((int)VAL_ZERO);
|
|
}
|
|
|
|
UINT CSptManager::PutScriptToDev(DWORD dwSCID, CDevice* const pDev)
|
|
{
|
|
int iTsn = 0;
|
|
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
CString szRes = _T("");
|
|
|
|
int iPollingTime = (int)VAL_ZERO;
|
|
|
|
_RecordsetPtr pRecSCon = NULL;
|
|
_RecordsetPtr pRecCha = NULL;
|
|
_RecordsetPtr pRecSptTsn = NULL;
|
|
_RecordsetPtr pRecSptChn = NULL;
|
|
_RecordsetPtr pRecSynSpt = NULL;
|
|
_RecordsetPtr pRecChannel = NULL;
|
|
_CommandPtr pCmdIns = NULL;
|
|
|
|
CString szSql = _T("");
|
|
|
|
CString szSCCN = _T("");
|
|
CString szSCName = _T("");
|
|
CString szSType = _T("");
|
|
CString szMedium = _T("");
|
|
|
|
CString szHostFilePath = _T("");
|
|
CString szFilePath = _T("");
|
|
CString szFileName = _T("");
|
|
CString szFile = _T("");
|
|
|
|
// CString szRect = _T("");
|
|
// CString szRectLoc = _T("");
|
|
// CString szPoleDistance = _T("");
|
|
// CString szPoleStep = _T("");
|
|
|
|
char aResBuff[2048] = {0};
|
|
int iResSize = (int)VAL_ZERO;
|
|
|
|
int iSType = (int)VAL_ZERO;
|
|
int iAR = (int)VAL_ZERO;
|
|
UINT uExecCode = (UINT)VAL_ZERO;
|
|
|
|
DWORD dwPrID = (DWORD)VAL_ZERO;
|
|
|
|
CMarkup* pXML = new CMarkup;
|
|
|
|
pRecSCon.CreateInstance(_uuidof(Recordset));
|
|
pRecSynSpt.CreateInstance(_uuidof(Recordset));
|
|
pRecCha.CreateInstance(_uuidof(Recordset));
|
|
pRecSptTsn.CreateInstance(_uuidof(Recordset));
|
|
pRecSptChn.CreateInstance(_uuidof(Recordset));
|
|
pCmdIns.CreateInstance(_uuidof(Command));
|
|
pRecChannel.CreateInstance(_uuidof(Recordset));
|
|
|
|
|
|
//取得CHANNEL表中对应脚本的装置类型
|
|
szSql.Empty();
|
|
szSql.Format(_T("select AR from channel where SCID = %u"), dwSCID);
|
|
pRecChannel->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecChannel->GetRecordCount())
|
|
{
|
|
szMedium = (LPCTSTR)(_bstr_t)pRecChannel->GetCollect(_T("AR"));
|
|
}
|
|
pRecChannel->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select CN,Sname,Stype,Eamount,CHamount,TPamount,definer,Format(DEdate,'YYYY-MM-DD') as DEdate,SCdesc, Rect, RectLoc, PoleDistance, PoleStep,AR from scon,channel where channel.SCID=scon.ID and scon.ID = %u"), dwSCID);
|
|
pRecSCon->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecSCon->GetRecordCount())
|
|
{
|
|
szSType = (CString)(LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("Stype"));
|
|
szSCCN = (CString)(LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("CN"));
|
|
szSCName = (CString)(LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("Sname"));
|
|
|
|
iSType = pRecSCon->GetCollect(_T("Stype")).iVal;
|
|
iAR = pRecSCon->GetCollect(_T("AR")).iVal;
|
|
switch (iSType)
|
|
{
|
|
case 0:
|
|
szFileName = _T("VES")+(CString)(LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("CN"))+_T(".scr");
|
|
break;
|
|
case 1:
|
|
szFileName = _T("ERI")+(CString)(LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("CN"))+_T(".scr");
|
|
break;
|
|
case 2:
|
|
szFileName = _T("ERT")+(CString)(LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("CN"))+_T(".scr");
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select * from dev_syn_spt where DESN = '%s' and SCCN = '%s'"), pDev->m_szDevSN, szSCCN);
|
|
pRecSynSpt->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO == pRecSynSpt->GetRecordCount())
|
|
{
|
|
if (pRecSCon->GetCollect(_T("TPamount")).iVal > 5000)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("由于测试点数量较多,操作需要一些时间,请等待且不要关闭Geomative Studio."));
|
|
else
|
|
MessageBoxEx(NULL, _T("The test point is too much, so it may use several minutes to response, don't close the Geomative Studio."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
|
|
uExecCode = this->AddScriptInDev(szFileName.Mid(0, 35),szSCName,szMedium, pDev);
|
|
|
|
if (APP_SUCCESS == uExecCode)
|
|
{
|
|
szFilePath.Empty();
|
|
szFilePath.GetBufferSetLength(256);
|
|
::GetCurrentDirectory(szFilePath.GetLength(), szFilePath.GetBuffer(szFilePath.GetLength()));
|
|
szFilePath.ReleaseBuffer();
|
|
|
|
szFilePath = szFilePath + _T("\\CACHE\\scripts\\");
|
|
if (!PathFileExistsA(szFilePath)) {
|
|
::CreateDirectoryA(szFilePath, nullptr);
|
|
}
|
|
szFile = szFilePath + szFileName;
|
|
pXML->SetDoc("<?xml version=\"1.0\" encoding=\"ansi\"?>\r\n");
|
|
pXML->AddElem("script");
|
|
pXML->AddChildElem(_T("cn"), (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("CN")));
|
|
pXML->AddChildElem(_T("name"), (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("Sname")));
|
|
pXML->AddChildElem(_T("type"), pRecSCon->GetCollect(_T("Stype")).iVal);
|
|
pXML->AddChildElem(_T("description"), pRecSCon->GetCollect(_T("SCdesc")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("SCdesc")));
|
|
pXML->AddChildElem(_T("definer"), (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("definer")));
|
|
pXML->AddChildElem(_T("date"), (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("DEdate")));
|
|
|
|
|
|
switch (iSType)
|
|
{
|
|
case 0:
|
|
//1D,2D脚本rect,rect_loc,pole_distance,pole_step三个字段为空
|
|
pXML->AddChildElem(_T("rect"), _T(""));
|
|
pXML->AddChildElem(_T("rect_loc"), _T(""));
|
|
pXML->AddChildElem(_T("pole_distance"), _T(""));
|
|
pXML->AddChildElem(_T("pole_step"), _T(""));
|
|
|
|
pXML->AddChildElem(_T("pole_count"), (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("Eamount")));
|
|
pXML->AddChildElem(_T("point_count"), (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("TPamount")));
|
|
pXML->AddChildElem(_T("pole_start"), "1");
|
|
break;
|
|
case 1:
|
|
pXML->AddChildElem(_T("rect"), _T(""));
|
|
pXML->AddChildElem(_T("rect_loc"), _T(""));
|
|
//这里由于2D中可能涉及到跨井钻孔,而跨井的距离系数存储在pole_step中,所以需要将PoleDistance的值写入
|
|
pXML->AddChildElem(_T("pole_distance"), (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("PoleDistance")));
|
|
pXML->AddChildElem(_T("pole_step"), _T(""));
|
|
|
|
pXML->AddChildElem(_T("pole_count"), (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("Eamount")));
|
|
pXML->AddChildElem(_T("point_count"), (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("TPamount")));
|
|
pXML->AddChildElem(_T("pole_start"), "1");
|
|
break;
|
|
case 2:
|
|
pXML->AddChildElem(_T("rect"), (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("Rect")));
|
|
pXML->AddChildElem(_T("rect_loc"), (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("RectLoc")));
|
|
pXML->AddChildElem(_T("pole_distance"), (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("PoleDistance")));
|
|
pXML->AddChildElem(_T("pole_step"), (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("PoleStep")));
|
|
if (AR_LAND_FILL_ONE == iAR)
|
|
{
|
|
//填埋场装置1,修改电极总数为电极总数+1
|
|
int iEamount = pRecSCon->GetCollect(_T("Eamount")).iVal;
|
|
CString strText;
|
|
strText.Format(_T("%d"), iEamount+1);
|
|
pXML->AddChildElem(_T("pole_count"), strText);
|
|
}
|
|
else
|
|
{
|
|
pXML->AddChildElem(_T("pole_count"), (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("Eamount")));
|
|
}
|
|
pXML->AddChildElem(_T("point_count"), (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("TPamount")));
|
|
pXML->AddChildElem(_T("pole_start"), "1");
|
|
break;
|
|
}
|
|
pXML->AddChildElem(_T("channel_count"), (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("CHamount")));
|
|
pXML->AddChildElem(_T("channel"));
|
|
pXML->IntoElem();
|
|
szSql.Empty();
|
|
szSql.Format(_T("select CHnumber&':'&AR as CA,MaxLayer from channel where SCID = %d order by CHnumber"), dwSCID);
|
|
pRecCha->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while (0 == pRecCha->adoEOF)
|
|
{
|
|
pXML->AddChildElem(_T("ar"), (LPCTSTR)(_bstr_t)pRecCha->GetCollect(_T("CA")));
|
|
//如果是二维信息的话,则添加通道的最大层数信息
|
|
if (1 == iSType)
|
|
{
|
|
int iMinLayer =0, iMaxLayer = 0;
|
|
szSql.Empty();
|
|
szSql.Format(_T("select min(Layer) as min_layer, max(Layer) as max_layer from script2d where CHID in (select ID from channel where SCID = %d)"), dwSCID);;
|
|
pRecSptTsn->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if (pRecSptTsn->GetRecordCount() > 0)
|
|
{
|
|
iMaxLayer = atoi((LPCTSTR)(_bstr_t)pRecSptTsn->GetCollect(_T("max_layer")));
|
|
iMinLayer = atoi((LPCTSTR)(_bstr_t)pRecSptTsn->GetCollect(_T("min_layer")));
|
|
pXML->AddChildAttrib(_T("max_layer"), iMaxLayer);
|
|
pXML->AddChildAttrib(_T("min_layer"), iMinLayer);
|
|
}
|
|
pRecSptTsn->Close();
|
|
}
|
|
|
|
pRecCha->MoveNext();
|
|
|
|
}
|
|
pRecCha->Close();
|
|
pXML->OutOfElem();
|
|
|
|
//跨孔(Geomative)装置新增一个字段电极坐标文件名,附加坐标文件
|
|
if (AR_CROSS_HOLE_GEOMATIVE == atoi(szMedium)
|
|
|| AR_CROSS_HOLE_GEOMATIVE_AM == atoi(szMedium))
|
|
{
|
|
CString strFileName;
|
|
CTime t = CTime::GetCurrentTime();
|
|
|
|
strFileName.Format(_T("%s%s.log"), szSCName, t.Format("%Y%m%d%H%M%S"));
|
|
pXML->AddChildElem(_T("C_H_Script"), strFileName);
|
|
|
|
CString strTempPath, strDestPath;
|
|
strTempPath.Format(_T("%s\\%s"), szFilePath, strFileName);
|
|
strDestPath.Format(_T("%sSD\\scripts\\%s"), CDetcGD10Dev::GetInstance()->GetGD10DevAddr(), strFileName);
|
|
CFile cf;
|
|
BOOL bRes = false;
|
|
CString strRawContent;
|
|
bRes = cf.Open(strTempPath, CFile::modeCreate | CFile::modeReadWrite);
|
|
if (bRes)
|
|
{
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ElectrodeID,X,Y,Z from TCoordinatesInfo where ScriptCN='%s'"), szSCCN);
|
|
pRecSptTsn->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
while (0 == pRecSptTsn->adoEOF)
|
|
{
|
|
//Addr,x,y,z
|
|
strRawContent.Empty();
|
|
strRawContent.Format(_T("%s,%s,%s,%s\r\n"), \
|
|
(LPCTSTR)(_bstr_t)pRecSptTsn->GetCollect(_T("ElectrodeID")), \
|
|
(LPCTSTR)(_bstr_t)pRecSptTsn->GetCollect(_T("X")), \
|
|
(LPCTSTR)(_bstr_t)pRecSptTsn->GetCollect(_T("Y")), \
|
|
(LPCTSTR)(_bstr_t)pRecSptTsn->GetCollect(_T("Z")));
|
|
cf.Write(strRawContent, strRawContent.GetLength());
|
|
pRecSptTsn->MoveNext();
|
|
}
|
|
pRecSptTsn->Close();
|
|
cf.Close();
|
|
|
|
BYTE bTimes = 0;
|
|
bool bRes = false;
|
|
do
|
|
{
|
|
//覆盖已有文件
|
|
bRes = CopyFile(strTempPath, strDestPath, FALSE);
|
|
if (false == bRes)
|
|
{
|
|
CFileOperTools::GetInstance()->WriteComLog(_T("zm:CSptManager::PutScriptToDev copy file failed!"));
|
|
Sleep(5000);
|
|
}
|
|
bTimes++;
|
|
} while (!bRes && (bTimes <= 3));
|
|
|
|
if (bRes == false && bTimes > 3)
|
|
{
|
|
CFileOperTools::GetInstance()->WriteComLog(_T("zm:CSptManager::PutScriptToDev copy file Failed!"));
|
|
return bRes;
|
|
}
|
|
|
|
bTimes = 0;
|
|
do
|
|
{
|
|
bRes = DeleteFile(strTempPath);
|
|
if (false == bRes)
|
|
{
|
|
CFileOperTools::GetInstance()->WriteComLog(_T("zm:CSptManager::PutScriptToDev delete file failed!"));
|
|
Sleep(5000);
|
|
}
|
|
bTimes++;
|
|
} while (!bRes && (bTimes <= 3));
|
|
|
|
if (bRes == false && bTimes > 3)
|
|
{
|
|
CFileOperTools::GetInstance()->WriteComLog(_T("zm:CSptManager::PutScriptToDev delete file Failed!"));
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
pXML->AddChildElem(_T("layout"));
|
|
pXML->IntoElem();
|
|
CString strFullSptCN = _T("");
|
|
switch (iSType)
|
|
{
|
|
case 0:
|
|
szSql.Empty();
|
|
szSql.Format(_T("select count(*) as CH, TSN, max(a) as a, max(b) as b, max(N) as N from script1d where CHID in (select ID from channel where SCID = %d) group by TSN order by TSN"), dwSCID);
|
|
pRecSptTsn->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
while (0 == pRecSptTsn->adoEOF)
|
|
{
|
|
iTsn = pRecSptTsn->GetCollect(_T("TSN")).lVal;
|
|
pXML->AddChildElem(_T("array"));
|
|
pXML->AddChildAttrib(_T("tsn"), iTsn);
|
|
pXML->AddChildAttrib(_T("ch"), (LPCTSTR)(_bstr_t)pRecSptTsn->GetCollect(_T("CH")));
|
|
pXML->AddChildAttrib(_T("c1"), (LPCTSTR)(_bstr_t)pRecSptTsn->GetCollect(_T("a")));
|
|
pXML->AddChildAttrib(_T("c2"), (LPCTSTR)(_bstr_t)pRecSptTsn->GetCollect(_T("b")));
|
|
pXML->AddChildAttrib(_T("n"), (LPCTSTR)(_bstr_t)pRecSptTsn->GetCollect(_T("N")));
|
|
pXML->IntoElem();
|
|
szSql.Empty();
|
|
szSql.Format(_T("select CHnumber,x&','&y as xy,K from channel a,script1d b where a.ID = b.CHID and a.SCID = %d and b.TSN = %d"), dwSCID, iTsn);
|
|
pRecSptChn->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while (0 == pRecSptChn->adoEOF)
|
|
{
|
|
pXML->AddChildElem(_T("ch"), (LPCTSTR)(_bstr_t)pRecSptChn->GetCollect(_T("xy")));
|
|
pXML->AddChildAttrib(_T("n"), pRecSptChn->GetCollect(_T("CHnumber")).iVal);
|
|
pXML->AddChildAttrib(_T("ks"), (LPCTSTR)(_bstr_t)pRecSptChn->GetCollect(_T("K")));
|
|
pRecSptChn->MoveNext();
|
|
}
|
|
pRecSptChn->Close();
|
|
pXML->OutOfElem();
|
|
pRecSptTsn->MoveNext();
|
|
}
|
|
pRecSptTsn->Close();
|
|
pXML->OutOfElem();
|
|
DeleteFile(szFile);
|
|
pXML->Save(szFile);
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("script_add(\"VES%s\",\"%s\",\"%s\")\r\n"), szSCCN, szSCName,szMedium);
|
|
strFullSptCN.Empty();
|
|
strFullSptCN.Format(_T("VES%s"),szSCCN);
|
|
break;
|
|
case 1:
|
|
szSql.Empty();
|
|
szSql.Format(_T("select count(*) as CH, TSN, max(C1) as C1, max(C2) as C2, max(N) as N from script2d where CHID in (select ID from channel where SCID = %d) group by TSN order by TSN"), dwSCID);
|
|
pRecSptTsn->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
while (0 == pRecSptTsn->adoEOF)
|
|
{
|
|
iTsn = pRecSptTsn->GetCollect(_T("TSN")).lVal;
|
|
pXML->AddChildElem(_T("array"));
|
|
pXML->AddChildAttrib(_T("tsn"), iTsn);
|
|
pXML->AddChildAttrib(_T("ch"), (LPCTSTR)(_bstr_t)pRecSptTsn->GetCollect(_T("CH")));
|
|
pXML->AddChildAttrib(_T("c1"), (LPCTSTR)(_bstr_t)pRecSptTsn->GetCollect(_T("C1")));
|
|
pXML->AddChildAttrib(_T("c2"), (LPCTSTR)(_bstr_t)pRecSptTsn->GetCollect(_T("C2")));
|
|
pXML->AddChildAttrib(_T("n"), (LPCTSTR)(_bstr_t)pRecSptTsn->GetCollect(_T("N")));
|
|
pXML->IntoElem();
|
|
szSql.Empty();
|
|
szSql.Format(_T("select CHnumber,P1&','&P2 as P1P2,K,Layer,XPos from channel a,script2d b where a.ID = b.CHID and a.SCID = %d and b.TSN = %d"), dwSCID, iTsn);
|
|
pRecSptChn->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
while (0 == pRecSptChn->adoEOF)
|
|
{
|
|
pXML->AddChildElem(_T("ch"), (LPCTSTR)(_bstr_t)pRecSptChn->GetCollect(_T("P1P2")));
|
|
pXML->AddChildAttrib(_T("n"), pRecSptChn->GetCollect(_T("CHnumber")).iVal);
|
|
pXML->AddChildAttrib(_T("ks"), (LPCTSTR)(_bstr_t)pRecSptChn->GetCollect(_T("K")));
|
|
pXML->AddChildAttrib(_T("layer"), (VT_NULL==pRecSptChn->GetCollect(_T("Layer")).vt)?_T(""):(LPCTSTR)(_bstr_t)pRecSptChn->GetCollect(_T("Layer")));
|
|
pXML->AddChildAttrib(_T("xpos"), (VT_NULL==pRecSptChn->GetCollect(_T("XPos")).vt)?_T(""):(LPCTSTR)(_bstr_t)pRecSptChn->GetCollect(_T("XPos")));
|
|
pRecSptChn->MoveNext();
|
|
}
|
|
pRecSptChn->Close();
|
|
pXML->OutOfElem();
|
|
pRecSptTsn->MoveNext();
|
|
}
|
|
pRecSptTsn->Close();
|
|
pXML->OutOfElem();
|
|
DeleteFile(szFile);
|
|
pXML->Save(szFile);
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("script_add(\"ERI%s\",\"%s\",\"%s\")\r\n"), szSCCN, szSCName,szMedium);
|
|
strFullSptCN.Empty();
|
|
strFullSptCN.Format(_T("ERI%s"),szSCCN);
|
|
break;
|
|
case 2:
|
|
szSql.Empty();
|
|
szSql.Format(_T("select count(*) as CH, TSN, max(C1) as C1, max(C2) as C2, max(N) as N from script3d where CHID in (select ID from channel where SCID = %d) group by TSN order by TSN"), dwSCID);
|
|
pRecSptTsn->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
while (0 == pRecSptTsn->adoEOF)
|
|
{
|
|
iTsn = pRecSptTsn->GetCollect(_T("TSN")).lVal;
|
|
pXML->AddChildElem(_T("array"));
|
|
pXML->AddChildAttrib(_T("tsn"), iTsn);
|
|
pXML->AddChildAttrib(_T("ch"), (LPCTSTR)(_bstr_t)pRecSptTsn->GetCollect(_T("CH")));
|
|
pXML->AddChildAttrib(_T("c1"), (LPCTSTR)(_bstr_t)pRecSptTsn->GetCollect(_T("C1")));
|
|
pXML->AddChildAttrib(_T("c2"), (LPCTSTR)(_bstr_t)pRecSptTsn->GetCollect(_T("C2")));
|
|
pXML->AddChildAttrib(_T("n"), (LPCTSTR)(_bstr_t)pRecSptTsn->GetCollect(_T("N")));
|
|
pXML->IntoElem();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select CHnumber,P1&','&P2 as P1P2,K from channel a,script3d b where a.ID = b.CHID and a.SCID = %d and b.TSN = %d"), dwSCID, iTsn);
|
|
pRecSptChn->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while (0 == pRecSptChn->adoEOF)
|
|
{
|
|
pXML->AddChildElem(_T("ch"), (LPCTSTR)(_bstr_t)pRecSptChn->GetCollect(_T("P1P2")));
|
|
pXML->AddChildAttrib(_T("n"), pRecSptChn->GetCollect(_T("CHnumber")).iVal);
|
|
pXML->AddChildAttrib(_T("ks"), (LPCTSTR)(_bstr_t)pRecSptChn->GetCollect(_T("K")));
|
|
pRecSptChn->MoveNext();
|
|
}
|
|
|
|
pRecSptChn->Close();
|
|
pXML->OutOfElem();
|
|
pRecSptTsn->MoveNext();
|
|
}
|
|
pRecSptTsn->Close();
|
|
pXML->OutOfElem();
|
|
DeleteFile(szFile);
|
|
pXML->Save(szFile);
|
|
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("script_add(\"ERT%s\",\"%s\",\"%s\")\r\n"), szSCCN, szSCName,szMedium);
|
|
strFullSptCN.Empty();
|
|
strFullSptCN.Format(_T("ERT%s"),szSCCN);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
delete pXML;
|
|
szHostFilePath.Empty();
|
|
szHostFilePath = _T("/SD/scripts/");
|
|
TransDelay(g_iTransMode, 10, 50, NULL);
|
|
|
|
if (TRUE == pDev->SendFile(szHostFilePath, szFilePath, szFileName))
|
|
{
|
|
TransDelay(g_iTransMode, 100, 200, NULL);
|
|
try
|
|
{
|
|
//deleted by lsq 20160427
|
|
//由于前面的一段已经有增加脚本的代码,这段是重复的,不需要加
|
|
/*
|
|
pDev->m_sComPort.ClearCommReceiveBuff();
|
|
pDev->m_sComPort.ClearCommSendBuff();
|
|
|
|
pDev->m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
szOrder.ReleaseBuffer();
|
|
// TransDelay(g_iTransMode, 20, 50);
|
|
|
|
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++;
|
|
}
|
|
|
|
if (MAX_POLLING_TIME == iPollingTime)
|
|
{
|
|
uExecCode = APP_FAIL;
|
|
}
|
|
|
|
GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]"));
|
|
|
|
if (_T("1") != szRes)
|
|
{
|
|
uExecCode = APP_FAIL;
|
|
}
|
|
*/
|
|
theApp.m_pConnection->BeginTrans();
|
|
|
|
pCmdIns->ActiveConnection = theApp.m_pConnection;
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into dev_syn_spt(DESN,SCCN,SptName,Stype,SptFileName,IsSyned) values('%s','%s','%s',%d,'%s',true)"), pDev->m_szDevSN, szSCCN, szSCName, iSType, szFileName);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
theApp.m_pConnection->CommitTrans();
|
|
uExecCode = APP_SUCCESS;
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
theApp.m_pConnection->RollbackTrans();
|
|
uExecCode = APP_FAIL;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("发送脚本文件失败,请重试."));
|
|
else
|
|
MessageBoxEx(NULL, _T("Send Script file failed! Please Retry"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
uExecCode = APP_FAIL;
|
|
DeleteSConInDev(szFileName.Mid(0, 35), pDev);
|
|
}
|
|
DeleteFile(szFile);
|
|
}
|
|
else if (APP_OVERFLOW == uExecCode)
|
|
{
|
|
// hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
// AfxMessageBox("TestingZone amount overflow!");
|
|
uExecCode = APP_FAIL;
|
|
}
|
|
}
|
|
pRecSynSpt->Close();
|
|
}
|
|
|
|
pRecSCon->Close();
|
|
|
|
return uExecCode;
|
|
}
|
|
|
|
UINT CSptManager::LoadScriptFromDev(CString szSptFileName, CDevice* const pDev)
|
|
{
|
|
CMarkup xml;
|
|
UINT uExecCode = (UINT)VAL_ZERO;
|
|
|
|
_CommandPtr pCmdIns = NULL;
|
|
_CommandPtr pCmdUpd = NULL;
|
|
|
|
_RecordsetPtr pRecSCon = NULL;
|
|
_RecordsetPtr pRecCha = NULL;
|
|
_RecordsetPtr pRecSpt = NULL;
|
|
|
|
CString szSql = _T("");
|
|
|
|
CString szLocFilePath = _T("");
|
|
CString szLocFile = _T("");
|
|
|
|
CString szHostFilePath = _T("/SD/scripts/");
|
|
CString szHostFile = _T("");
|
|
|
|
CString szCN = _T("");
|
|
CString szName = _T("");
|
|
int iType = (int)VAL_ZERO;
|
|
CString szDesc = _T("");
|
|
CString szDefiner = _T("");
|
|
CString szDate = _T("");
|
|
|
|
CString RectLoc = _T("");
|
|
|
|
CString szMN = _T("");
|
|
CStringArray saMN;
|
|
|
|
int iPoleCount = (int)VAL_ZERO;
|
|
int iPtCount = (int)VAL_ZERO;
|
|
int iChCount = (int)VAL_ZERO;
|
|
|
|
CString szAR = _T("");
|
|
int iAR = (int)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;
|
|
|
|
float fC1 = (float)VAL_ZERO;
|
|
float fC2 = (float)VAL_ZERO;
|
|
float fP1 = (float)VAL_ZERO;
|
|
float fP2 = (float)VAL_ZERO;
|
|
|
|
int iN = (int)VAL_ZERO;
|
|
float fKS = (float)VAL_ZERO;
|
|
|
|
DWORD dwSCID = (DWORD)VAL_ZERO;
|
|
DWORD dwCHID = (DWORD)VAL_ZERO;
|
|
|
|
|
|
CString szRect = _T("");
|
|
CString szRectLoc = _T("");
|
|
CString szPoleDistance = _T("");
|
|
CString szPoleStep = _T("");
|
|
|
|
// int x0 = 0;
|
|
// int y0 = 0;
|
|
// int x1 = 0;
|
|
// int y1 = 0;
|
|
|
|
//-------------------------------------------------------------
|
|
|
|
_RecordsetPtr pRecSptCheck = NULL;
|
|
pRecSptCheck.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format("select ID from scon where CN = \"%s\"", szSptFileName.Mid(3,32));
|
|
pRecSptCheck->Open(szSql.GetBuffer(0), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecSptCheck->GetRecordCount())
|
|
{
|
|
//这个脚本已经存在,不需要上传
|
|
return APP_FAIL;
|
|
}
|
|
|
|
pRecSptCheck->Close();
|
|
|
|
//-------------------------------------------------------------
|
|
szHostFile = szHostFilePath + szSptFileName;
|
|
|
|
pRecSCon.CreateInstance(_uuidof(Recordset));
|
|
pRecCha.CreateInstance(_uuidof(Recordset));
|
|
pRecSpt.CreateInstance(_uuidof(Recordset));
|
|
|
|
pCmdUpd.CreateInstance(_uuidof(Command));
|
|
pCmdUpd->ActiveConnection = theApp.m_pConnection;
|
|
|
|
pCmdIns.CreateInstance(_uuidof(Command));
|
|
pCmdIns->ActiveConnection = theApp.m_pConnection;
|
|
|
|
szLocFilePath.Empty();
|
|
szLocFilePath.GetBufferSetLength(256);
|
|
::GetCurrentDirectory(szLocFilePath.GetLength(), szLocFilePath.GetBuffer(szLocFilePath.GetLength()));
|
|
szLocFilePath.ReleaseBuffer();
|
|
|
|
szLocFilePath = szLocFilePath + _T("\\CACHE\\scripts\\");
|
|
if (!PathFileExistsA(szLocFilePath)) {
|
|
::CreateDirectoryA(szLocFilePath, nullptr);
|
|
}
|
|
szLocFile = szLocFilePath + szSptFileName;
|
|
|
|
if (TRUE == pDev->ReceiveFile(szLocFilePath, szHostFile))
|
|
{
|
|
try
|
|
{ CStringArray sa;
|
|
sa.RemoveAll();
|
|
|
|
theApp.m_pConnection->BeginTrans();
|
|
xml.Load(szLocFile);
|
|
xml.FindElem(_T("script"));
|
|
xml.FindChildElem(_T("cn"));
|
|
szCN = xml.GetChildData();
|
|
xml.FindChildElem(_T("name"));
|
|
szName = xml.GetChildData();
|
|
xml.FindChildElem(_T("type"));
|
|
iType = atoi(xml.GetChildData());
|
|
xml.FindChildElem(_T("description"));
|
|
szDesc = xml.GetChildData();
|
|
xml.FindChildElem(_T("definer"));
|
|
szDefiner = xml.GetChildData();
|
|
xml.FindChildElem(_T("date"));
|
|
szDate = xml.GetChildData();
|
|
|
|
xml.FindChildElem(_T("rect"));//取得坐标
|
|
szRect = xml.GetChildData();
|
|
|
|
xml.FindChildElem(_T("rect_loc"));
|
|
szRectLoc = xml.GetChildData();
|
|
|
|
xml.FindChildElem(_T("pole_distance"));
|
|
szPoleDistance = xml.GetChildData();
|
|
|
|
xml.FindChildElem(_T("pole_step"));
|
|
szPoleStep = xml.GetChildData();
|
|
|
|
// SplitterString(sa, szRect, _T(","));
|
|
// x0 = atoi(sa.GetAt(0));
|
|
// y0 = atoi(sa.GetAt(1));
|
|
// x1 = atoi(sa.GetAt(2));
|
|
// y1 = atoi(sa.GetAt(3));
|
|
|
|
xml.FindChildElem(_T("pole_count"));
|
|
iPoleCount = atoi(xml.GetChildData());
|
|
xml.FindChildElem(_T("point_count"));
|
|
iPtCount = atoi(xml.GetChildData());
|
|
xml.FindChildElem(_T("channel_count"));
|
|
iChCount = atoi(xml.GetChildData());
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into scon(CN,Sname,Stype,Eamount,CHamount,TPamount,definer,DEdate,SCdesc,Rect,RectLoc,PoleDistance,PoleStep) "
|
|
"values('%s','%s',%d,%d,%d,%d,'%s',#%s#,'%s','%s','%s','%s','%s')"),
|
|
szCN,
|
|
szName,
|
|
iType,
|
|
iPoleCount,
|
|
iChCount,
|
|
iPtCount,
|
|
szDefiner,
|
|
szDate,
|
|
szDesc,
|
|
szRect,
|
|
szRectLoc,
|
|
szPoleDistance,
|
|
szPoleStep);
|
|
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
pRecSCon->Open(_T("select max(ID) as SCID from scon"), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecSCon->GetRecordCount())
|
|
{
|
|
dwSCID = (int)pRecSCon->GetCollect(_T("SCID")).ulVal;
|
|
}
|
|
pRecSCon->Close();
|
|
|
|
xml.FindChildElem(_T("channel"));
|
|
xml.IntoElem();
|
|
xml.FindChildElem(_T("ar"));
|
|
szAR = xml.GetChildData();
|
|
|
|
sa.RemoveAll();
|
|
SplitterString(sa, szAR, _T(":"));
|
|
iChNum = atoi(sa.GetAt(0));
|
|
|
|
iAR = atoi(sa.GetAt(1));
|
|
xml.OutOfElem();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into channel(SCID,CHnumber,AR) values(%u,%d,%d)"),
|
|
dwSCID,
|
|
iChNum,
|
|
iAR);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
pRecCha->Open(_T("select max(ID) as CHID from channel"), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecCha->GetRecordCount())
|
|
{
|
|
dwCHID = (int)pRecCha->GetCollect(_T("CHID")).ulVal;
|
|
}
|
|
pRecCha->Close();
|
|
|
|
switch (iType)
|
|
{
|
|
case 0:
|
|
xml.FindChildElem(_T("layout"));
|
|
xml.IntoElem();
|
|
while (xml.FindChildElem(_T("array")))
|
|
{
|
|
iTSN = atoi(xml.GetChildAttrib(_T("tsn")));
|
|
fC1 = (float)atof(xml.GetChildAttrib(_T("c1")));
|
|
fC2 = (float)atof(xml.GetChildAttrib(_T("c2")));
|
|
iN = atoi(xml.GetChildAttrib(_T("n")));
|
|
xml.IntoElem();
|
|
while (xml.FindChildElem(_T("ch")))
|
|
{
|
|
iChNum = atoi(xml.GetChildAttrib(_T("n")));
|
|
fKS = (float)atof(xml.GetChildAttrib(_T("ks")));
|
|
|
|
// fP1 = (float)atof(xml.GetChildData());
|
|
// fP2 = (float)atof(xml.GetChildData());
|
|
|
|
szMN = xml.GetChildData();
|
|
SplitterString(saMN, szMN, _T(","));
|
|
|
|
iP1 = atoi(saMN.GetAt(0));
|
|
iP2 = atoi(saMN.GetAt(1));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into script1d(CHID,TSN,a,b,x,y,K,N) values(%u,%d,%f,%f,%f,%f,%f,%d) "),
|
|
dwCHID,
|
|
iTSN,
|
|
fC1,
|
|
fC2,
|
|
fP1,
|
|
fP2,
|
|
fKS,
|
|
iN);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
}
|
|
xml.OutOfElem();
|
|
}
|
|
xml.OutOfElem();
|
|
|
|
break;
|
|
case 1:
|
|
xml.FindChildElem(_T("layout"));
|
|
xml.IntoElem();
|
|
while (xml.FindChildElem(_T("array")))
|
|
{
|
|
iTSN = atoi(xml.GetChildAttrib(_T("tsn")));
|
|
iC1 = atoi(xml.GetChildAttrib(_T("c1")));
|
|
iC2 = atoi(xml.GetChildAttrib(_T("c2")));
|
|
iN = atoi(xml.GetChildAttrib(_T("n")));
|
|
xml.IntoElem();
|
|
while (xml.FindChildElem(_T("ch")))
|
|
{
|
|
iChNum = atoi(xml.GetChildAttrib(_T("n")));
|
|
fKS = (float)atof(xml.GetChildAttrib(_T("ks")));
|
|
|
|
szMN = xml.GetChildData();
|
|
SplitterString(saMN, szMN, _T(","));
|
|
|
|
iP1 = atoi(saMN.GetAt(0));
|
|
iP2 = atoi(saMN.GetAt(1));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into script2d(CHID,TSN,C1,C2,P1,P2,K,N) values(%u,%d,%d,%d,%d,%d,%f,%d) "),
|
|
dwCHID,
|
|
iTSN,
|
|
iC1,
|
|
iC2,
|
|
iP1,
|
|
iP2,
|
|
fKS,
|
|
iN);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
}
|
|
xml.OutOfElem();
|
|
}
|
|
xml.OutOfElem();
|
|
break;
|
|
case 2:
|
|
xml.FindChildElem(_T("layout"));
|
|
xml.IntoElem();
|
|
while (xml.FindChildElem(_T("array")))
|
|
{
|
|
iTSN = atoi(xml.GetChildAttrib(_T("tsn")));
|
|
iC1 = atoi(xml.GetChildAttrib(_T("c1")));
|
|
iC2 = atoi(xml.GetChildAttrib(_T("c2")));
|
|
iN = atoi(xml.GetChildAttrib(_T("n")));
|
|
xml.IntoElem();
|
|
while (xml.FindChildElem(_T("ch")))
|
|
{
|
|
iChNum = atoi(xml.GetChildAttrib(_T("n")));
|
|
fKS = (float)atof(xml.GetChildAttrib(_T("ks")));
|
|
|
|
szMN = xml.GetChildData();
|
|
SplitterString(saMN, szMN, _T(","));
|
|
|
|
iP1 = atoi(saMN.GetAt(0));
|
|
iP2 = atoi(saMN.GetAt(1));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into script3d(CHID,TSN,C1,C2,P1,P2,K,N) values(%u,%d,%d,%d,%d,%d,%f,%d) "),
|
|
dwCHID,
|
|
iTSN,
|
|
iC1,
|
|
iC2,
|
|
iP1,
|
|
iP2,
|
|
fKS,
|
|
iN);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
}
|
|
xml.OutOfElem();
|
|
}
|
|
xml.OutOfElem();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("update dev_syn_spt set IsSyned = true where SCCN = '%s' and DESN = '%s'"), szCN, pDev->m_szDevSN);
|
|
pCmdUpd->CommandText = szSql.AllocSysString();
|
|
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
|
|
|
//dwSCID
|
|
szSql.Empty();
|
|
szSql.Format(_T("update td set SCID = %u where SCCN = '%s'"), dwSCID, szCN);
|
|
pCmdUpd->CommandText = szSql.AllocSysString();
|
|
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
|
|
|
theApp.m_pConnection->CommitTrans();
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
AfxMessageBox(e.Description());
|
|
theApp.m_pConnection->RollbackTrans();
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
uExecCode = APP_FAIL;
|
|
}
|
|
|
|
return uExecCode;
|
|
}
|
|
|
|
UINT CSptManager::AddScriptInDev(CString szSCCN, CString szSCCName,CString szType,CDevice* const pDev)
|
|
{
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
CString szRes = _T("");
|
|
|
|
int iPollingTime = (int)VAL_ZERO;
|
|
int iResSize = (int)VAL_ZERO;
|
|
char aResBuff[2048] = {0};
|
|
|
|
if (EN_TRANSFER_FILE_BY_USB == g_iTransFileMode)
|
|
{
|
|
//在这里由于只操作单个文件,所以失败了也不用进行原子操作的回滚
|
|
int iRes = CGD10OperCmd::GetInstance()->script_add(szSCCN, szSCCName, szType);
|
|
szRes.Empty();
|
|
szRes.Format(_T("%d"),iRes);
|
|
}
|
|
else
|
|
{
|
|
//////////////////////////////////////////////////////////////////////////
|
|
szOrder.Format(_T("script_add(\"%s\",\"%s\",\"%s\")\r\n"), szSCCN,szSCCName,szType);
|
|
if (FALSE == pDev->ExecuteOrder(szOrder, ">" , &szResBuff))
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("下发脚本信息到主机设备失败."));
|
|
else
|
|
MessageBoxEx(NULL, _T("Download script to device failed!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return APP_FAIL;
|
|
}
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
/////////////////////////在这里注释掉,用ExecuteOrder命令来代替//////////
|
|
/*
|
|
pDev->m_sComPort.ClearCommSendBuff();
|
|
pDev->m_sComPort.ClearCommReceiveBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("\r\n"));
|
|
pDev->m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
Sleep(500);
|
|
|
|
szOrder.ReleaseBuffer();
|
|
szOrder.Empty();
|
|
|
|
pDev->m_sComPort.ClearCommSendBuff();
|
|
pDev->m_sComPort.ClearCommReceiveBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("script_add(\"%s\",\"%s\",\"%s\")\r\n"), szSCCN,szSCCName,szType);
|
|
// MessageBox(szOrder);
|
|
Sleep(100);
|
|
|
|
pDev->m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
szOrder.ReleaseBuffer();
|
|
// TransDelay(g_iTransMode, 20, 50);
|
|
|
|
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++;
|
|
}
|
|
|
|
if (MAX_POLLING_TIME == iPollingTime)
|
|
{
|
|
return APP_FAIL;
|
|
}
|
|
*/
|
|
//////////////////////////////////////////////////////////////////////////
|
|
GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]"));
|
|
}
|
|
|
|
if (_T("-3") == szRes)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("在设备中添加脚本失败,设备中的脚本数量超过允许的最大值."));
|
|
else
|
|
MessageBoxEx(NULL, _T("Add script to device failed, the number of script in device are overflow!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return APP_OVERFLOW;
|
|
}
|
|
else if ((_T("0") == szRes) || (_T("-1") == szRes) || (_T("-2") == szRes))
|
|
{
|
|
CString strErr = _T("");
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strErr.Format(_T("添加脚本到设备失败,错误码= %s"), szRes);
|
|
AfxMessageBox(strErr);
|
|
}
|
|
else
|
|
{
|
|
strErr.Format(_T("Add script to device failed, errorno = %s"), szRes);
|
|
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
return APP_FAIL;
|
|
}
|
|
|
|
return APP_SUCCESS;
|
|
}
|
|
|
|
void CSptManager::InitialCESptList(CListCtrl &sptList)
|
|
{
|
|
_RecordsetPtr pRecSptList = NULL;
|
|
_RecordsetPtr pRecSCon = NULL;
|
|
_RecordsetPtr pRecMed = NULL;
|
|
|
|
DWORD dwSptHandle = (DWORD)VAL_ZERO;
|
|
|
|
int iIndex = (int)VAL_ZERO;
|
|
CString szSql;
|
|
CString szLabel;
|
|
|
|
pRecMed.CreateInstance(_uuidof(Recordset));
|
|
pRecSptList.CreateInstance(_uuidof(Recordset));
|
|
pRecSCon.CreateInstance(_uuidof(Recordset));
|
|
|
|
pRecSptList->Open(_T("select ID,CN,Sname,Eamount,CHamount,TPamount,definer,Format(DEdate,'YYYY-MM-DD') as DEdate,SCdesc from scon where Stype = 0"),
|
|
_variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecSptList->adoEOF)
|
|
{
|
|
sptList.InsertItem(iIndex, pRecSptList->GetCollect(_T("CN")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("CN")));
|
|
|
|
sptList.SetItemText(iIndex, 1, pRecSptList->GetCollect(_T("Sname")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("Sname")));
|
|
|
|
sptList.SetItemText(iIndex, 2, pRecSptList->GetCollect(_T("Eamount")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("Eamount")));
|
|
|
|
sptList.SetItemText(iIndex, 3, pRecSptList->GetCollect(_T("TPamount")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("TPamount")));
|
|
sptList.SetItemText(iIndex, 4, pRecSptList->GetCollect(_T("definer")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("definer")));
|
|
sptList.SetItemText(iIndex, 5, pRecSptList->GetCollect(_T("DEdate")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("DEdate")));
|
|
|
|
sptList.SetItemText(iIndex, 6, pRecSptList->GetCollect(_T("SCdesc")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSptList->GetCollect(_T("SCdesc")));
|
|
|
|
dwSptHandle = m_handleProcessor.GenerateHandle((DWORD)pRecSptList->GetCollect(_T("ID")).ulVal, PZ_STYLE_SCON_2D);
|
|
|
|
sptList.SetItemData(iIndex, dwSptHandle);
|
|
|
|
iIndex++;
|
|
|
|
pRecSptList->MoveNext();
|
|
|
|
} //while (VAL_ZERO == pRecProID->adoEOF)
|
|
pRecSptList->Close();
|
|
|
|
sptList.SetHotItem((int)VAL_ZERO);
|
|
}
|
|
|
|
|
|
BOOL CSptManager::DeleteSConInDev(CString szSCCN, CDevice* const pDev)
|
|
{
|
|
_CommandPtr pCmdDel = NULL;
|
|
CString szSql = _T("");
|
|
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
CString szRes = _T("");
|
|
CString strError = _T("");
|
|
|
|
int iPollingTime = (int)VAL_ZERO;
|
|
int iResSize = (int)VAL_ZERO;
|
|
char aResBuff[2048] = {0};
|
|
if (EN_TRANSFER_FILE_BY_USB == g_iTransFileMode)
|
|
{
|
|
if (CGD10OperCmd::GetInstance()->script_delete(szSCCN))
|
|
{
|
|
szRes = _T("1");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//////////////////////////////////////////////////////////////////////////
|
|
szOrder.Format(_T("script_delete(\"%s\")\r\n"), szSCCN);
|
|
if (FALSE == pDev->ExecuteOrder(szOrder, ">", &szResBuff))
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("发送删除脚本命令失败."));
|
|
else
|
|
MessageBoxEx(NULL, _T("Send reomve sript command failed!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return FALSE;
|
|
}
|
|
//////////////////////////////////////////////////////////////////////////
|
|
GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]"));
|
|
}
|
|
|
|
|
|
///////////////////////////用ExcuteOrder命令代替//////////////////////////
|
|
/*
|
|
pDev->m_sComPort.ClearCommSendBuff();
|
|
pDev->m_sComPort.ClearCommReceiveBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("\r\n"));
|
|
pDev->m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
Sleep(500);
|
|
|
|
szOrder.ReleaseBuffer();
|
|
szOrder.Empty();
|
|
|
|
pDev->m_sComPort.ClearCommSendBuff();
|
|
pDev->m_sComPort.ClearCommReceiveBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("script_delete(\"%s\")\r\n"), szSCCN);
|
|
// MessageBox(szOrder);
|
|
Sleep(100);
|
|
pDev->m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
szOrder.ReleaseBuffer();
|
|
|
|
// TransDelay(g_iTransMode, 20, 50);
|
|
|
|
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++;
|
|
}
|
|
// hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
// AfxMessageBox(szResBuff);
|
|
|
|
if (MAX_POLLING_TIME == iPollingTime)
|
|
{
|
|
return FALSE;
|
|
}
|
|
*/
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
if (_T("1") != szRes)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strError.Format(_T("删除脚本失败, 错误 = %s"), szRes);
|
|
AfxMessageBox(strError);
|
|
}
|
|
else
|
|
{
|
|
strError.Format(_T("Remove script failed, error = %s"), szRes);
|
|
MessageBoxEx(NULL, strError, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
pCmdDel.CreateInstance(_uuidof(Command));
|
|
pCmdDel->ActiveConnection = theApp.m_pConnection;
|
|
|
|
try
|
|
{
|
|
theApp.m_pConnection->BeginTrans();
|
|
szSql.Empty();
|
|
szSql.Format(_T("delete from dev_syn_spt where DESN = '%s' and SCCN = '%s'"), pDev->m_szDevSN, szSCCN.Right(32));
|
|
|
|
pCmdDel->CommandText = szSql.AllocSysString();
|
|
pCmdDel->Execute(NULL, NULL, adCmdText);
|
|
|
|
theApp.m_pConnection->CommitTrans();
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
AfxMessageBox((LPCTSTR)e.Description());
|
|
theApp.m_pConnection->RollbackTrans();
|
|
return FALSE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
UINT CSptManager::Create3DSConInDB(DWORD *dwSConID)
|
|
{
|
|
CString szCN = _T("");
|
|
CString szSql = _T("");
|
|
CString szSName = _T("");
|
|
CString szDefiner = _T("");
|
|
CString szDeDate = _T("");
|
|
CString szScDesc = _T("");
|
|
CString szSplittedNum = _T("");
|
|
CString szTmp = _T("");
|
|
|
|
int i = 0;
|
|
|
|
int nSplittedNum = 0;
|
|
|
|
_RecordsetPtr pRecSCID = NULL;
|
|
_RecordsetPtr pRecCHID = NULL;
|
|
|
|
_CommandPtr pCmdIns = NULL;
|
|
_CommandPtr pCmdUpd = NULL;
|
|
|
|
int iChCount = (int)VAL_ZERO;
|
|
int iChIndex = (int)VAL_ZERO;
|
|
POSITION posCh = NULL;
|
|
|
|
int iRecCount = (int)VAL_ZERO;
|
|
int iRecIndex = (int)VAL_ZERO;
|
|
|
|
int iTpAmount = (int)VAL_ZERO;
|
|
int iTsn = (int)VAL_ZERO;
|
|
|
|
DWORD dwCHID = (DWORD)VAL_ZERO;
|
|
|
|
UINT uExecCode = (UINT)VAL_ZERO;
|
|
INT_PTR lRet = (long)VAL_ZERO;
|
|
INT_PTR lRetBackup = lRet;
|
|
CScript3D* pNewScript = new CScript3D((DWORD)VAL_ZERO, theApp.m_pConnection);
|
|
CChannel* pChannel = NULL;
|
|
CSptRecord* pSptRecord = NULL;
|
|
////////////////////////////test//////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
CDialCreateNew3DSpt* pCreate3DSptDlg = new CDialCreateNew3DSpt(pNewScript, &m_medLinkList, (INT_PTR*)&lRet);
|
|
|
|
pCreate3DSptDlg->Create(IDD_DIALOG_NEW_3D_SPT, AfxGetMainWnd());//因为修改了对话框的create函数,所以这里传什么值无所谓
|
|
|
|
// this->InitialCreate3DSConDlg(pOpCreate3DSptDlg);
|
|
|
|
pCreate3DSptDlg->ShowWindow(SW_SHOW);
|
|
try
|
|
{
|
|
lRet = pCreate3DSptDlg->RunModalLoop(MLF_SHOWONIDLE); // 开始非模态窗口模态循环
|
|
lRetBackup = lRet;
|
|
switch (lRet)
|
|
{
|
|
case RET_OK:
|
|
theApp.m_pConnection->BeginTrans();
|
|
nSplittedNum = pCreate3DSptDlg->GetSplitSptNumber();
|
|
dwSConID[0] = nSplittedNum;//第一个元素放元素总数
|
|
|
|
for (i = 0; i < nSplittedNum; i++)
|
|
{
|
|
pRecSCID.CreateInstance(_uuidof(Recordset));
|
|
pRecCHID.CreateInstance(_uuidof(Recordset));
|
|
|
|
pCmdIns.CreateInstance(_uuidof(Command));
|
|
pCmdIns->ActiveConnection = theApp.m_pConnection;
|
|
|
|
pCmdUpd.CreateInstance(_uuidof(Command));
|
|
pCmdUpd->ActiveConnection = theApp.m_pConnection;
|
|
|
|
szCN = this->m_guCodeCreator.GenerateGUIDCode();
|
|
|
|
szSName.Empty();
|
|
szTmp = pCreate3DSptDlg->GetSptName();
|
|
|
|
|
|
if (1 == nSplittedNum)//如果该值为1,则标示该脚本不做拆分,命名后面不跟类似"(1)"结尾
|
|
{
|
|
szSName = szTmp;
|
|
}
|
|
else
|
|
{
|
|
szSName.Format("%s(%d)",szTmp, i + 1);
|
|
}
|
|
|
|
szDefiner.Empty();
|
|
szDefiner = pCreate3DSptDlg->GetSptOperator();
|
|
szScDesc.Empty();
|
|
szScDesc = pCreate3DSptDlg->GetSptMark();
|
|
|
|
|
|
pNewScript->m_iSType = 2; //脚本类型 3d
|
|
iChCount = pNewScript->m_chaList.GetCount();//通道列表数
|
|
|
|
/////////////////////////////////检测是否有相同的名称的脚本/////////////////////////////////////////
|
|
szSql.Empty();
|
|
szSql.Format(_T("select * from scon where Sname = '%s' and Stype=%d"),szSName, pNewScript->m_iSType);
|
|
pRecSCID->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecSCID->GetRecordCount())
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("脚本已经存在."));
|
|
else
|
|
MessageBoxEx(NULL, _T("Script has been alreay exists"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
pRecSCID->Close();
|
|
theApp.m_pConnection->RollbackTrans();
|
|
pNewScript->m_chaList.RemoveAll();
|
|
delete pNewScript;
|
|
delete pCreate3DSptDlg;
|
|
return APP_FAIL;
|
|
}
|
|
pRecSCID->Close();
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into scon(CN,Sname,Stype,Eamount,CHamount,TPamount,definer,DEdate,SCdesc,Rect,RectLoc,PoleDistance,PoleStep,LineDirection) "
|
|
"values('%s','%s',%d,%d,%d,%d,'%s',#%s#,'%s','%s', '%s', '%s', '%s',%d)"),
|
|
szCN,
|
|
szSName,
|
|
pNewScript->m_iSType,
|
|
pNewScript->m_iEAmount,
|
|
iChCount,
|
|
pNewScript->m_PointNum[i],
|
|
szDefiner,
|
|
pCreate3DSptDlg->m_CreateDate.FormatGmt("%Y-%m-%d"),
|
|
szScDesc,
|
|
pCreate3DSptDlg->GetRect(),
|
|
pCreate3DSptDlg->GetPoleStart(),
|
|
pCreate3DSptDlg->GetPoleDistance(),
|
|
pCreate3DSptDlg->GetPoleStep(),
|
|
pCreate3DSptDlg->GetLineDirection());
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
//取得scon表中ID最大的ITEM
|
|
pRecSCID->Open(_T("select max(ID) as ID from scon"), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecSCID->GetRecordCount())//返回1
|
|
{
|
|
dwSConID[i + 1] = (DWORD)pRecSCID->GetCollect(_T("ID")).ulVal;
|
|
}
|
|
pRecSCID->Close();
|
|
|
|
posCh = NULL;
|
|
iChIndex = (int)VAL_ZERO;
|
|
|
|
while (iChIndex < iChCount)//iChCount = 1
|
|
{
|
|
posCh = pNewScript->m_chaList.FindIndex(iChIndex);
|
|
pChannel = (CChannel*)pNewScript->m_chaList.GetAt(posCh);
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into channel(SCID,CHnumber,AR) values(%u,%d,%d) "),
|
|
dwSConID[i + 1],
|
|
pChannel->m_iChNumber,
|
|
pChannel->m_pMedium->m_iAR);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
pRecCHID->Open(_T("select max(ID) as ID from channel"), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecCHID->GetRecordCount())
|
|
{
|
|
dwCHID = (DWORD)pRecCHID->GetCollect(_T("ID")).ulVal;
|
|
}
|
|
pRecCHID->Close();
|
|
|
|
iRecIndex = (int)VAL_ZERO;
|
|
iRecCount = (int)VAL_ZERO;
|
|
iTsn = (int)VAL_ONE;
|
|
|
|
while (iRecIndex < pChannel->m_sptRecArray.GetSize())
|
|
{
|
|
pSptRecord = (CSptRecord*)pChannel->m_sptRecArray.GetAt(iRecIndex);
|
|
|
|
if (pSptRecord->m_SubScriptIndex == i)
|
|
{
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into script3d(CHID,TSN,C1,C2,P1,P2,K,N) values(%u,%d,%d,%d,%d,%d,%f,%d) "),
|
|
dwCHID,
|
|
iTsn, //如是多通道,则此处需修改
|
|
pSptRecord->m_iC1,
|
|
pSptRecord->m_iC2,
|
|
pSptRecord->m_iP1,
|
|
pSptRecord->m_iP2,
|
|
pSptRecord->m_fK,
|
|
pSptRecord->m_iN);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
|
|
try
|
|
{
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
AfxMessageBox((LPCTSTR)e.Description());
|
|
}
|
|
//iTpAmount++;
|
|
iTsn++;
|
|
}
|
|
iRecIndex++;
|
|
}
|
|
iTsn = 0;
|
|
iRecIndex = 0;
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("update scon set TPamount = %d where ID = %d"), pNewScript->m_PointNum[i]/*iTpAmount*/,dwSConID[i + 1]);
|
|
pCmdUpd->CommandText = szSql.AllocSysString();
|
|
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
|
|
|
iChIndex++;
|
|
}
|
|
}
|
|
|
|
pChannel->m_sptRecArray.RemoveAll();
|
|
pNewScript->m_chaList.RemoveAll();
|
|
|
|
delete pChannel;
|
|
pChannel = NULL;
|
|
theApp.m_pConnection->CommitTrans();
|
|
break;
|
|
case RET_CANCEL:
|
|
delete pNewScript;
|
|
delete pCreate3DSptDlg;
|
|
return APP_CANCLE;
|
|
//break;
|
|
default:
|
|
break;
|
|
}
|
|
delete pNewScript;
|
|
delete pCreate3DSptDlg;
|
|
return 0;
|
|
}
|
|
catch(_com_error e)
|
|
{
|
|
if (RET_OK == lRetBackup)
|
|
{
|
|
theApp.m_pConnection->RollbackTrans();
|
|
}
|
|
delete pNewScript;
|
|
delete pCreate3DSptDlg;
|
|
throw e;
|
|
|
|
}
|
|
}
|
|
|
|
void CSptManager::Delete3DSConInDB(DWORD dwSConID)
|
|
{
|
|
_RecordsetPtr pRecCha = NULL;
|
|
|
|
_CommandPtr pCmdDel;
|
|
_CommandPtr pCmdUpd;
|
|
|
|
CString szSql = _T("");
|
|
|
|
pRecCha.CreateInstance(_uuidof(Recordset));
|
|
|
|
pCmdDel.CreateInstance(_uuidof(Command));
|
|
pCmdDel->ActiveConnection = theApp.m_pConnection;
|
|
|
|
pCmdUpd.CreateInstance(_uuidof(Command));
|
|
pCmdUpd->ActiveConnection = theApp.m_pConnection;
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ID from channel where SCID = %d"), dwSConID);
|
|
pRecCha->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecCha->adoEOF)
|
|
{
|
|
szSql.Empty();
|
|
szSql.Format(_T("delete from script3d where CHID = %u"), (DWORD)pRecCha->GetCollect(_T("ID")).ulVal);
|
|
pCmdDel->CommandText = szSql.AllocSysString();
|
|
pCmdDel->Execute(NULL, NULL, adCmdText);
|
|
|
|
pRecCha->MoveNext();
|
|
} //while ((short)VAL_ZERO == pRecCha->adoEOF)
|
|
|
|
pRecCha->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("delete from channel where SCID = %u"), dwSConID);
|
|
|
|
pCmdDel->CommandText = szSql.AllocSysString();
|
|
pCmdDel->Execute(NULL, NULL, adCmdText);
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("delete from scon where ID = %u"), dwSConID);
|
|
pCmdDel->CommandText = szSql.AllocSysString();
|
|
pCmdDel->Execute(NULL, NULL, adCmdText);
|
|
}
|
|
|
|
void CSptManager::Browse2DScript(DWORD dwScId)
|
|
{
|
|
INT_PTR lRet = (long)VAL_ZERO;
|
|
|
|
_RecordsetPtr pRecSpt = NULL;
|
|
pRecSpt.CreateInstance(_uuidof(Recordset));
|
|
CString strSql = _T("");
|
|
strSql.Format(_T("select AR from channel where SCID = %u"), dwScId);
|
|
pRecSpt->Open(strSql.GetBuffer(0), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO == pRecSpt->GetRecordCount())
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("查询脚本装置类型失败"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Query script array type failed."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
pRecSpt->Close();
|
|
return;
|
|
}
|
|
short iAR = pRecSpt->GetCollect(_T("AR")).iVal;
|
|
pRecSpt->Close();
|
|
if (AR_EDGE_GARDIENT == iAR || AR_BIPOLE_HOLE_SPT == iAR || AR_DOUBLE_SIZE_3P == iAR ||AR_CUSTOM_2D_TYPE == iAR ||
|
|
AR_MID_GARDIENT_SCAN == iAR || AR_CROSS_HOLE_TYPE == iAR || AR_CROSS_HOLE_GEOMATIVE == iAR || AR_S3P_MEDIUM == iAR)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("不支持."));
|
|
else
|
|
MessageBoxEx(NULL, _T("Not support."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return ;
|
|
}
|
|
|
|
CBrowse2DScriptDlg* pBrowse = new CBrowse2DScriptDlg();
|
|
|
|
pBrowse->Create(IDD_BROWSE_SCRIPT_2D, AfxGetMainWnd());
|
|
|
|
//直接在这里操作view类
|
|
//---------画图
|
|
|
|
InitBrowse2DView(pBrowse,dwScId);
|
|
|
|
//---------画图
|
|
pBrowse->CenterWindow();
|
|
|
|
pBrowse->ShowWindow(SW_SHOW);
|
|
|
|
pBrowse->RunModalLoop(MLF_SHOWONIDLE); // 开始非模态窗口模态循环
|
|
}
|
|
|
|
bool CSptManager::Export3DSConInDB(DWORD dwSConID, CString strFilePath)
|
|
{
|
|
_RecordsetPtr pRecSpt = NULL;
|
|
pRecSpt.CreateInstance(_uuidof(Recordset));
|
|
COperTxtFile operTxtFile;
|
|
if (!operTxtFile.OpenFileforWrite(strFilePath))
|
|
{
|
|
return false;
|
|
}
|
|
CStringArray strTextArr;
|
|
strTextArr.RemoveAll();
|
|
strTextArr.Add(_T("ID"));
|
|
strTextArr.Add(_T("A"));
|
|
strTextArr.Add(_T("B"));
|
|
strTextArr.Add(_T("M"));
|
|
strTextArr.Add(_T("N"));
|
|
strTextArr.Add(_T("K"));
|
|
operTxtFile.WriteFileContent(strTextArr);
|
|
|
|
|
|
CString szSql = _T("");
|
|
szSql.Format(_T("select a.TSN as TSN, a.C1 as C1,a.C2 as C2,a.P1 as P1,a.P2 as P2,a.K as K from script3d a, channel b ")
|
|
_T("where a.CHID = b.ID and b.SCID = %d"), dwSConID);
|
|
pRecSpt->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
float fK = 0;
|
|
CString strInfo = _T("");
|
|
bool bRes = true;
|
|
while ((short)VAL_ZERO == pRecSpt->adoEOF)
|
|
{
|
|
strTextArr.RemoveAll();
|
|
strTextArr.Add((VT_NULL == pRecSpt->GetCollect(_T("TSN")).vt) ? _T("") : (LPCTSTR)(_bstr_t)pRecSpt->GetCollect(_T("TSN")));
|
|
strTextArr.Add((LPCTSTR)(_bstr_t)pRecSpt->GetCollect(_T("C1")));
|
|
strTextArr.Add((LPCTSTR)(_bstr_t)pRecSpt->GetCollect(_T("C2")));
|
|
strTextArr.Add((LPCTSTR)(_bstr_t)pRecSpt->GetCollect(_T("P1")));
|
|
strTextArr.Add((LPCTSTR)(_bstr_t)pRecSpt->GetCollect(_T("P2")));
|
|
fK = (VT_NULL == pRecSpt->GetCollect(_T("K")).vt) ? 0 : pRecSpt->GetCollect(_T("K")).fltVal;
|
|
strInfo.Empty();
|
|
strInfo.Format(_T("%f"), fK);
|
|
strTextArr.Add(strInfo);
|
|
if (!operTxtFile.WriteFileContent(strTextArr))
|
|
{
|
|
bRes = false;
|
|
break;
|
|
}
|
|
pRecSpt->MoveNext();
|
|
}
|
|
pRecSpt->Close();
|
|
operTxtFile.CloseFile();
|
|
return bRes;
|
|
|
|
}
|
|
|
|
bool CSptManager::Export2DSConInDB(DWORD dwSConID, CString strFilePath)
|
|
{
|
|
_RecordsetPtr pRecSpt = NULL;
|
|
pRecSpt.CreateInstance(_uuidof(Recordset));
|
|
COperTxtFile operTxtFile;
|
|
if (!operTxtFile.OpenFileforWrite(strFilePath))
|
|
{
|
|
return false;
|
|
}
|
|
CStringArray strTextArr;
|
|
strTextArr.RemoveAll();
|
|
strTextArr.Add(_T("ID"));
|
|
strTextArr.Add(_T("A"));
|
|
strTextArr.Add(_T("B"));
|
|
strTextArr.Add(_T("M"));
|
|
strTextArr.Add(_T("N"));
|
|
strTextArr.Add(_T("K"));
|
|
operTxtFile.WriteFileContent(strTextArr);
|
|
|
|
|
|
CString szSql = _T("");
|
|
szSql.Format(_T("select a.TSN as TSN, a.C1 as C1,a.C2 as C2,a.P1 as P1,a.P2 as P2,a.K as K from script2d a, channel b ")
|
|
_T("where a.CHID = b.ID and b.SCID = %d order by a.TSN"), dwSConID);
|
|
pRecSpt->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
float fK = 0;
|
|
CString strInfo = _T("");
|
|
bool bRes = true;
|
|
while ((short)VAL_ZERO == pRecSpt->adoEOF)
|
|
{
|
|
strTextArr.RemoveAll();
|
|
strTextArr.Add((VT_NULL == pRecSpt->GetCollect(_T("TSN")).vt) ? _T("") : (LPCTSTR)(_bstr_t)pRecSpt->GetCollect(_T("TSN")));
|
|
strTextArr.Add((LPCTSTR)(_bstr_t)pRecSpt->GetCollect(_T("C1")));
|
|
strTextArr.Add((LPCTSTR)(_bstr_t)pRecSpt->GetCollect(_T("C2")));
|
|
strTextArr.Add((LPCTSTR)(_bstr_t)pRecSpt->GetCollect(_T("P1")));
|
|
strTextArr.Add((LPCTSTR)(_bstr_t)pRecSpt->GetCollect(_T("P2")));
|
|
fK = (VT_NULL == pRecSpt->GetCollect(_T("K")).vt) ? 0 : pRecSpt->GetCollect(_T("K")).fltVal;
|
|
strInfo.Empty();
|
|
strInfo.Format(_T("%f"), fK);
|
|
strTextArr.Add(strInfo);
|
|
if (!operTxtFile.WriteFileContent(strTextArr))
|
|
{
|
|
bRes = false;
|
|
break;
|
|
}
|
|
pRecSpt->MoveNext();
|
|
}
|
|
pRecSpt->Close();
|
|
operTxtFile.CloseFile();
|
|
return bRes;
|
|
|
|
}
|
|
|
|
void CSptManager::InitBrowse2DView(CBrowse2DScriptDlg* f_pBrowse,DWORD f_dwScid)
|
|
{
|
|
CString szSql = _T("");
|
|
|
|
int nAr = 0; //装置类型
|
|
int nEamount = 0; //电极数量
|
|
int nCHamount = 0; //通道数量
|
|
int nCHnum = 0; //通道编号(第几个通道)
|
|
float fDipSep = 0;
|
|
CString strPoleStep;
|
|
|
|
DWORD dwScId = 0;
|
|
DWORD dwChId = 0;
|
|
|
|
_RecordsetPtr pRecSCID = NULL;
|
|
_RecordsetPtr pRecCHID = NULL;
|
|
_RecordsetPtr pRecSCNum = NULL;
|
|
|
|
pRecCHID.CreateInstance(_uuidof(Recordset));
|
|
pRecSCID.CreateInstance(_uuidof(Recordset));
|
|
pRecSCNum.CreateInstance(_uuidof(Recordset));
|
|
|
|
//-----------取脚本信息
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ID,Eamount,CHamount,PoleStep from scon where ID = %u"), f_dwScid);
|
|
|
|
pRecSCID->Open(szSql.GetBuffer(0), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecSCID->GetRecordCount())
|
|
{
|
|
dwScId = (DWORD)pRecSCID->GetCollect(_T("ID")).ulVal;
|
|
nEamount = pRecSCID->GetCollect(_T("Eamount")).ulVal;
|
|
nCHamount = pRecSCID->GetCollect(_T("CHamount")).ulVal;
|
|
strPoleStep = (pRecSCID->GetCollect(_T("PoleStep")).vt == VT_NULL) ? _T("0") : (LPCTSTR)(_bstr_t)pRecSCID->GetCollect(_T("PoleStep"));
|
|
|
|
}
|
|
|
|
pRecSCID->Close();
|
|
|
|
//--------取装置类型
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ID,AR,CHnumber from channel where SCID = %u"), dwScId);
|
|
|
|
pRecCHID->Open(szSql.GetBuffer(0), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecCHID->GetRecordCount())
|
|
{
|
|
dwChId = (DWORD)pRecCHID->GetCollect(_T("ID")).ulVal;
|
|
nAr = pRecCHID->GetCollect(_T("AR")).ulVal;
|
|
nCHnum = pRecCHID->GetCollect(_T("CHnumber")).ulVal;
|
|
}
|
|
|
|
pRecCHID->Close();
|
|
|
|
//将脚本取出来保存到结构中
|
|
CPtrArray sptrArray;
|
|
CSptRecord *SpRecord = NULL;
|
|
|
|
int count = 0;
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select TSN,C1,C2,P1,P2,K,N from script2d where CHID = %u order by TSN"), dwChId);
|
|
|
|
pRecSCNum->Open(szSql.GetBuffer(0), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecSCNum->GetRecordCount())
|
|
{
|
|
count = pRecSCNum->GetRecordCount();
|
|
SpRecord = new CSptRecord[count];
|
|
|
|
while ((short)VAL_ZERO == pRecSCNum->adoEOF)
|
|
{
|
|
SpRecord->m_iC1 = pRecSCNum->GetCollect(_T("C1")).iVal;
|
|
SpRecord->m_iC2 = pRecSCNum->GetCollect(_T("C2")).iVal;
|
|
SpRecord->m_iP1 = pRecSCNum->GetCollect(_T("P1")).iVal;
|
|
SpRecord->m_iP2 = pRecSCNum->GetCollect(_T("P2")).iVal;
|
|
SpRecord->m_iTsn = pRecSCNum->GetCollect(_T("TSN")).lVal;
|
|
SpRecord->m_iN = pRecSCNum->GetCollect(_T("N")).iVal;
|
|
SpRecord->m_fK = pRecSCNum->GetCollect(_T("K")).fltVal;
|
|
sptrArray.Add(SpRecord);
|
|
SpRecord++;
|
|
pRecSCNum->MoveNext();
|
|
}
|
|
}
|
|
|
|
pRecSCNum->Close();
|
|
|
|
//计算成图所需的数据
|
|
CSptRecord* pSptRecord = NULL;
|
|
CMedium* pMedium = NULL;
|
|
|
|
CChannel* pChannel = new CChannel;
|
|
pChannel->m_iChNumber = (int)VAL_ONE;
|
|
|
|
f_pBrowse->m_BrowseScript->m_bIsDraw = FALSE;
|
|
|
|
// f_pBrowse->m_BrowseScript->SetSelectPoint(&ptrArray);
|
|
f_pBrowse->m_BrowseScript->m_pNewChannel = pChannel;
|
|
f_pBrowse->m_BrowseScript->m_iEAmount = nEamount;
|
|
|
|
DWORD dwMedHandle = (DWORD)VAL_ZERO;
|
|
|
|
dwMedHandle = m_handleProcessor.GenerateHandle(nAr, PZ_STYLE_MED_DEF);
|
|
|
|
pChannel->m_pMedium = m_medLinkList.Find(dwMedHandle);
|
|
pMedium = pChannel->m_pMedium;
|
|
|
|
pChannel->ClearSptRecList();
|
|
|
|
if (NULL != pMedium)
|
|
{
|
|
if (nAr == AR_DIP_DIP)
|
|
{
|
|
fDipSep = atof(strPoleStep);
|
|
if (fDipSep < 1)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("偶极空间单位设置误差"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Dipole space units set error"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
else
|
|
pMedium->SetParamVal(&fDipSep);
|
|
}
|
|
pMedium->GenerateSptRecElecVal(nEamount, &(pChannel->m_iMaxLevel), &(pChannel->m_iPtAmount), &(pChannel->m_sptRecArray));
|
|
pMedium->ReSortPoint(&(pChannel->m_sptRecArray));
|
|
}
|
|
Browse2DScriptColorChange(&sptrArray, &(pChannel->m_sptRecArray));
|
|
|
|
f_pBrowse->m_BrowseScript->m_bIsDraw = TRUE;
|
|
|
|
f_pBrowse->m_BrowseScript->m_iMul = 3;
|
|
|
|
f_pBrowse->m_BrowseScript->Invalidate(FALSE);
|
|
f_pBrowse->m_BrowseScript->SetFocus();
|
|
|
|
if (SpRecord)
|
|
{
|
|
sptrArray.RemoveAll();
|
|
SpRecord -= count; //将指针指向队头进行删除
|
|
delete [] SpRecord;
|
|
SpRecord = NULL;
|
|
}
|
|
}
|
|
|
|
void CSptManager::Browse2DScriptColorChange(CPtrArray *f_scr_array, CPtrArray *f_tar_array)
|
|
{
|
|
CSptRecord *scrRecord; //数据库中取出的数据
|
|
CSptRecord *tarRecord; //脚本生成的数据
|
|
|
|
CString szSrcK = _T("");
|
|
CString szTarK = _T("");
|
|
|
|
for (int j = 0; j < f_tar_array->GetSize(); j++)
|
|
{
|
|
((CSptRecord *)f_tar_array->GetAt(j))->m_colorREF = RGB(150, 255, 255);
|
|
}
|
|
|
|
//利用2个循环查找被选中的点
|
|
for (int i = 0; i < f_scr_array->GetSize(); i++)
|
|
{
|
|
scrRecord = (CSptRecord *)f_scr_array->GetAt(i);
|
|
|
|
for(int n = 0; n < f_tar_array->GetSize(); n++)
|
|
{
|
|
tarRecord = (CSptRecord *)f_tar_array->GetAt(n);
|
|
// if (scrRecord->m_iTsn != tarRecord->m_iTsn)
|
|
// continue;
|
|
|
|
if (scrRecord->m_iC1 != tarRecord->m_iC1)
|
|
continue;
|
|
|
|
if (scrRecord->m_iC2 != tarRecord->m_iC2)
|
|
continue;
|
|
|
|
if (scrRecord->m_iP1 != tarRecord->m_iP1)
|
|
continue;
|
|
|
|
if (scrRecord->m_iP2 != tarRecord->m_iP2)
|
|
continue;
|
|
|
|
// if (scrRecord->m_iN != tarRecord->m_iN)
|
|
// continue;
|
|
|
|
//浮点型无法直接参与条件比较,由于该算法对精度要求不高,故先转为CString
|
|
//类型再进行比较
|
|
|
|
szSrcK.Format("%.6f", scrRecord->m_fK);
|
|
szTarK.Format("%.6f", tarRecord->m_fK);
|
|
//由于FK转换成字符串的时候,可能存在这小数点精确位的约进,从而造成字符串不相等
|
|
//所以在这里进行取消,仅任务ABMN相等,则就相等。因为不存在着2个ABMN一模一样的点
|
|
// if (szSrcK != szTarK)
|
|
// continue;
|
|
|
|
tarRecord->m_colorREF = RGB(0,255,0);
|
|
}
|
|
}
|
|
}
|