864 lines
27 KiB
C++
864 lines
27 KiB
C++
// SptOperator.cpp: implementation of the CSptOperator class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "geomative.h"
|
|
#include "SptOperator.h"
|
|
#include "navsptview.h"
|
|
#include "Constant.h"
|
|
|
|
#include "appsptview.h"
|
|
#include "appcesptview.h"
|
|
|
|
#include "appsptdetaillistview.h"
|
|
#include "appsptconlistview.h"
|
|
#include "appcesptconlistview.h"
|
|
#include "appsptchannellistview.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
extern CGeoMativeApp theApp;
|
|
extern int g_iLanguage;
|
|
extern int g_iTransFileMode;
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Construction/Destruction
|
|
//////////////////////////////////////////////////////////////////////
|
|
extern HHOOK hHook;
|
|
extern LRESULT __stdcall CBTHookProc(long nCode, WPARAM wParam, LPARAM lParam);
|
|
CSptOperator::CSptOperator(_ConnectionPtr& pConnection)
|
|
{
|
|
ASSERT(NULL != pConnection);
|
|
m_pConnection = pConnection;
|
|
}
|
|
|
|
CSptOperator::~CSptOperator()
|
|
{
|
|
|
|
}
|
|
|
|
bool CSptOperator::InitialNavExecView(CNavSptView* pNavExecView)
|
|
{
|
|
if (NULL != pNavExecView)
|
|
{
|
|
if (EN_TRANSFER_FILE_BY_CLOUND != g_iTransFileMode)
|
|
{
|
|
if (true != InitialNavExecCEDlg(pNavExecView->m_navCEDlg))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
if (true != InitialNavExec2DDlg(pNavExecView->m_nav2DDlg))
|
|
{
|
|
return false;
|
|
}
|
|
if (true != InitialNavExec3DDlg(pNavExecView->m_nav3DDlg))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void CSptOperator::ShowCEScriptConInfo(DWORD dwSptHandle, CView* pAppExecView)
|
|
{
|
|
((CScript2D*)theApp.m_pSptManager->GetScript(dwSptHandle))->ShowSptDetailInfo(((CAppSptDetailListView*)(((CAppCESptView*)pAppExecView)->m_pDetailListView))->GetListCtrl());
|
|
((CScript2D*)theApp.m_pSptManager->GetScript(dwSptHandle))->ShowChannelList(((CAppSptChannelListView*)(((CAppCESptView*)pAppExecView)->m_pContentListView))->GetListCtrl());
|
|
((CScript2D*)theApp.m_pSptManager->GetScript(dwSptHandle))->ShowSptConInfo(((CAppCESptConListView*)(((CAppCESptView*)pAppExecView)->m_pScriptListView))->GetListCtrl());
|
|
}
|
|
|
|
void CSptOperator::Show2DScriptConInfo(DWORD dwSptHandle, CView* pAppExecView)
|
|
{
|
|
((CScript2D*)theApp.m_pSptManager->GetScript(dwSptHandle))->ShowSptDetailInfo(((CAppSptDetailListView*)(((CAppSptView*)pAppExecView)->m_pDetailListView))->GetListCtrl());
|
|
((CScript2D*)theApp.m_pSptManager->GetScript(dwSptHandle))->ShowChannelList(((CAppSptChannelListView*)(((CAppSptView*)pAppExecView)->m_pContentListView))->GetListCtrl());
|
|
((CScript2D*)theApp.m_pSptManager->GetScript(dwSptHandle))->ShowSptConInfo(((CAppSptConListView*)(((CAppSptView*)pAppExecView)->m_pScriptListView))->GetListCtrl());
|
|
((CAppSptConListView*)(((CAppSptView*)pAppExecView)->m_pScriptListView))->Invalidate();
|
|
|
|
}
|
|
|
|
void CSptOperator::Show3DScriptConInfo(DWORD dwSptHandle, CView* pAppExecView)
|
|
{
|
|
((CScript2D*)theApp.m_pSptManager->GetScript(dwSptHandle))->ShowSptDetailInfo(((CAppSptDetailListView*)(((CAppSptView*)pAppExecView)->m_pDetailListView))->GetListCtrl());
|
|
((CScript2D*)theApp.m_pSptManager->GetScript(dwSptHandle))->ShowChannelList(((CAppSptChannelListView*)(((CAppSptView*)pAppExecView)->m_pContentListView))->GetListCtrl());
|
|
((CScript2D*)theApp.m_pSptManager->GetScript(dwSptHandle))->ShowSptConInfo(((CAppSptConListView*)(((CAppSptView*)pAppExecView)->m_pScriptListView))->GetListCtrl());
|
|
((CAppSptConListView*)(((CAppSptView*)pAppExecView)->m_pScriptListView))->Invalidate();
|
|
|
|
}
|
|
|
|
/*
|
|
bool CSptOperator::InitialNavExecMedDlg(CNavExecMedDlg& navExecMedDlg)
|
|
{
|
|
CString szRootLabel = _T("");
|
|
CString szSql = _T("");
|
|
|
|
_RecordsetPtr pRecMed = NULL;
|
|
HTREEITEM hMedRootItem = NULL;
|
|
HTREEITEM hMedItem = NULL;
|
|
DWORD dwMedHandle = (DWORD)VAL_ZERO;
|
|
|
|
UINT uMedDefImageState = (UINT)VAL_ZERO;
|
|
|
|
CTreeCtrl& medTree = navExecMedDlg.m_medTree;
|
|
|
|
uMedDefImageState = m_stateProcessor.ChangeToImageState(PZ_STATE_DB);
|
|
pRecMed.CreateInstance(_uuidof(Recordset));
|
|
|
|
szRootLabel.Empty();
|
|
szRootLabel.LoadString(IDS_MED_DEFAULT);
|
|
hMedRootItem = medTree.InsertItem((LPCTSTR)szRootLabel);
|
|
dwMedHandle = m_handleProcessor.GenerateHandle(VAL_ZERO, PZ_STYLE_MED_DEF);
|
|
medTree.SetItemData(hMedRootItem, dwMedHandle);
|
|
medTree.SetItemState(hMedRootItem, TVIS_BOLD, TVIS_BOLD);
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select AR,MEname from medium where LANG = %d"), g_iLanguage);
|
|
pRecMed->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while (VAL_ZERO == pRecMed->adoEOF)
|
|
{
|
|
hMedItem = medTree.InsertItem(pRecMed->GetCollect(_T("MEname")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecMed->GetCollect(_T("MEname")),
|
|
hMedRootItem);
|
|
dwMedHandle = m_handleProcessor.GenerateHandle((DWORD)pRecMed->GetCollect(_T("AR")).ulVal, PZ_STYLE_MED_DEF);
|
|
medTree.SetItemData(hMedItem, dwMedHandle);
|
|
medTree.SetItemState(hMedItem, uMedDefImageState, TVIS_STATEIMAGEMASK);
|
|
|
|
pRecMed->MoveNext();
|
|
}
|
|
pRecMed->Close();
|
|
|
|
medTree.Expand(hMedRootItem, TVE_EXPAND);
|
|
|
|
szRootLabel.Empty();
|
|
szRootLabel.LoadString(IDS_MED_CUSTOM);
|
|
hMedRootItem = medTree.InsertItem((LPCTSTR)szRootLabel);
|
|
dwMedHandle = m_handleProcessor.GenerateHandle(VAL_ZERO, PZ_STYLE_MED_CUS);
|
|
medTree.SetItemData(hMedRootItem, dwMedHandle);
|
|
medTree.SetItemState(hMedRootItem, TVIS_BOLD, TVIS_BOLD);
|
|
|
|
return true;
|
|
}
|
|
*/
|
|
/*
|
|
void CSptOperator::ShowScriptFileInfo(DWORD dwSFHandle, CView* pAppExecView)
|
|
{
|
|
CString szSql = _T("");
|
|
DWORD dwSFID = (DWORD)VAL_ZERO;
|
|
DWORD dwSConID = (DWORD)VAL_ZERO;
|
|
_RecordsetPtr pRecSF = NULL;
|
|
|
|
dwSFID = m_handleProcessor.GetIDFromHandle(dwSFHandle);
|
|
|
|
pRecSF.CreateInstance(_uuidof(Recordset));
|
|
szSql.Empty();
|
|
szSql.Format(_T("select SCID from sfile where ID = %u"), dwSFID);
|
|
pRecSF->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecSF->GetRecordCount())
|
|
{
|
|
dwSConID = (DWORD)pRecSF->GetCollect(_T("SCID")).ulVal;
|
|
ShowScriptConInfo(dwSConID, pAppExecView);
|
|
}
|
|
pRecSF->Close();
|
|
}
|
|
|
|
void CSptOperator::ShowDevInfoInExecMng(DWORD dwDevHandle, CView *pAppExecView)
|
|
{
|
|
DWORD dwDevID = (DWORD)VAL_ZERO;
|
|
|
|
dwDevID = this->m_handleProcessor.GetIDFromHandle(dwDevHandle);
|
|
theApp.m_pDevManager->GetDeviceByID(dwDevID)->ShowDetailInfo(((CAppExecDevDetailListView*)(((CAppExecDevView*)pAppExecView)->m_pDetailListView))->GetListCtrl());
|
|
theApp.m_pSptManager->ShowScriptFileList(dwDevHandle, ((CAppExecSptFileListView*)(((CAppExecDevView*)pAppExecView)->m_pContentListView))->GetListCtrl());
|
|
}
|
|
|
|
UINT CSptOperator::CreateScriptFileInOffline(CNavSptView* pNavExecView)
|
|
{
|
|
UINT uExecCode = (UINT)VAL_ZERO;
|
|
|
|
HTREEITEM hDevItem = NULL;
|
|
DWORD dwDevHandle = (DWORD)VAL_ZERO;
|
|
DWORD dwDevID = (DWORD)VAL_ZERO;
|
|
|
|
hDevItem = pNavExecView->m_navSptDlg.m_sptTree.GetSelectedItem();
|
|
dwDevHandle = pNavExecView->m_navSptDlg.m_sptTree.GetItemData(hDevItem);
|
|
dwDevID = m_handleProcessor.GetIDFromHandle(dwDevHandle);
|
|
|
|
try
|
|
{
|
|
m_pConnection->BeginTrans();
|
|
uExecCode = theApp.m_pSptManager->CreateScriptFileInOffline(dwDevID);
|
|
|
|
if (APP_SUCCESS == uExecCode)
|
|
{
|
|
AddSFItemToSptTree(pNavExecView->m_navSptDlg.m_sptTree);
|
|
m_pConnection->CommitTrans();
|
|
}
|
|
else
|
|
{
|
|
m_pConnection->RollbackTrans();
|
|
}
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
theApp.GetMainWnd()->EnableWindow(TRUE);
|
|
m_pConnection->RollbackTrans();
|
|
return APP_ERR_DB;
|
|
}
|
|
|
|
pNavExecView->m_navSptDlg.m_sptTree.SelectItem(NULL);
|
|
pNavExecView->m_navSptDlg.m_sptTree.SelectItem(hDevItem);
|
|
return uExecCode;
|
|
}
|
|
|
|
UINT CSptOperator::DeleteScriptFileInLoc(CNavSptView* pNavExecView)
|
|
{
|
|
UINT uExecCode = (UINT)VAL_ZERO;
|
|
|
|
HTREEITEM hDevItem = NULL;
|
|
HTREEITEM hSFItem = NULL;
|
|
DWORD dwSFHandle = (DWORD)VAL_ZERO;
|
|
DWORD dwSFID = (DWORD)VAL_ZERO;
|
|
|
|
hSFItem = pNavExecView->m_navSptDlg.m_sptTree.GetSelectedItem();
|
|
hDevItem = pNavExecView->m_navSptDlg.m_sptTree.GetParentItem(hSFItem);
|
|
dwSFHandle = pNavExecView->m_navSptDlg.m_sptTree.GetItemData(hSFItem);
|
|
dwSFID = m_handleProcessor.GetIDFromHandle(dwSFHandle);
|
|
|
|
try
|
|
{
|
|
m_pConnection->BeginTrans();
|
|
theApp.m_pSptManager->DeleteScriptFileInLoc(dwSFID);
|
|
|
|
m_pConnection->CommitTrans();
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
m_pConnection->RollbackTrans();
|
|
return APP_ERR_DB;
|
|
}
|
|
|
|
pNavExecView->m_navSptDlg.m_sptTree.DeleteItem(hSFItem);
|
|
pNavExecView->m_navSptDlg.m_sptTree.SelectItem(NULL);
|
|
pNavExecView->m_navSptDlg.m_sptTree.SelectItem(hDevItem);
|
|
|
|
return APP_SUCCESS;
|
|
}
|
|
|
|
HTREEITEM CSptOperator::FindSFItemInNavSptTree(DWORD dwDevID, CString szSFName, CTreeCtrl& sptTree)
|
|
{
|
|
HTREEITEM hDevItem = NULL;
|
|
HTREEITEM hSFItem = NULL;
|
|
_RecordsetPtr pRecSFID = NULL;
|
|
|
|
DWORD dwDevHandle = (DWORD)VAL_ZERO;
|
|
DWORD dwSFHandle = (DWORD)VAL_ZERO;
|
|
DWORD dwSFID = (DWORD)VAL_ZERO;
|
|
|
|
CString szSql;
|
|
pRecSFID.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ID from sfile where SFname = '%s'"), szSFName);
|
|
|
|
pRecSFID->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecSFID->GetRecordCount())
|
|
{
|
|
dwSFID = pRecSFID->GetCollect(_T("ID")).ulVal;
|
|
|
|
dwSFHandle = m_handleProcessor.GenerateHandle(dwSFID, PZ_STYLE_SPT_FILE);
|
|
dwDevHandle = m_handleProcessor.GenerateHandle(dwDevID, PZ_STYLE_DEV_SPT);
|
|
|
|
hDevItem = sptTree.GetRootItem();
|
|
hDevItem = sptTree.GetNextSiblingItem(hDevItem);
|
|
|
|
hDevItem = sptTree.GetChildItem(hDevItem);
|
|
|
|
while (NULL != hDevItem)
|
|
{
|
|
if ((sptTree.GetItemData(hDevItem) == dwDevHandle) && (sptTree.ItemHasChildren(hDevItem)))
|
|
{
|
|
hSFItem = sptTree.GetChildItem(hDevItem);
|
|
while (NULL != hSFItem)
|
|
{
|
|
if (sptTree.GetItemData(hSFItem) == dwSFHandle)
|
|
{
|
|
return hSFItem;
|
|
}
|
|
hSFItem = sptTree.GetNextSiblingItem(hSFItem);
|
|
}
|
|
}
|
|
hDevItem = sptTree.GetNextSiblingItem(hDevItem);
|
|
}
|
|
}
|
|
|
|
pRecSFID->Close();
|
|
return NULL;
|
|
}
|
|
|
|
HTREEITEM CSptOperator::FindSFItemInNavSptTree(DWORD dwDevID, DWORD dwSFID, CTreeCtrl& sptTree)
|
|
{
|
|
HTREEITEM hDevItem = NULL;
|
|
HTREEITEM hSFItem = NULL;
|
|
|
|
DWORD dwDevHandle = (DWORD)VAL_ZERO;
|
|
DWORD dwSFHandle = (DWORD)VAL_ZERO;
|
|
|
|
dwSFHandle = m_handleProcessor.GenerateHandle(dwSFID, PZ_STYLE_SPT_FILE);
|
|
dwDevHandle = m_handleProcessor.GenerateHandle(dwDevID, PZ_STYLE_DEV_SPT);
|
|
|
|
hDevItem = sptTree.GetRootItem();
|
|
hDevItem = sptTree.GetNextSiblingItem(hDevItem);
|
|
|
|
hDevItem = sptTree.GetChildItem(hDevItem);
|
|
|
|
while (NULL != hDevItem)
|
|
{
|
|
if ((sptTree.GetItemData(hDevItem) == dwDevHandle) && (sptTree.ItemHasChildren(hDevItem)))
|
|
{
|
|
hSFItem = sptTree.GetChildItem(hDevItem);
|
|
while (NULL != hSFItem)
|
|
{
|
|
if (sptTree.GetItemData(hSFItem) == dwSFHandle)
|
|
{
|
|
return hSFItem;
|
|
}
|
|
hSFItem = sptTree.GetNextSiblingItem(hSFItem);
|
|
}
|
|
}
|
|
hDevItem = sptTree.GetNextSiblingItem(hDevItem);
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
*/
|
|
|
|
/*
|
|
void CSptOperator::AddSFItemToSptTree(CTreeCtrl& sptTree)
|
|
{
|
|
_RecordsetPtr pRecSF = NULL;
|
|
|
|
CString szSql = _T("");
|
|
|
|
HTREEITEM hSFItem = NULL;
|
|
HTREEITEM hDevItem = NULL;
|
|
|
|
DWORD dwSFHandle = (DWORD)VAL_ZERO;
|
|
DWORD dwDevHandle = (DWORD)VAL_ZERO;
|
|
DWORD dwDevID = (DWORD)VAL_ZERO;
|
|
|
|
UINT uSFImageState = (UINT)VAL_ZERO;
|
|
|
|
hDevItem = sptTree.GetSelectedItem();
|
|
dwDevHandle = sptTree.GetItemData(hDevItem);
|
|
dwDevID = m_handleProcessor.GetIDFromHandle(dwDevHandle);
|
|
|
|
uSFImageState = m_stateProcessor.ChangeToImageState(PZ_STATE_LOC);
|
|
pRecSF.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ID,SFname from sfile where DEID = %u order by ID"), dwDevID);
|
|
|
|
pRecSF->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecSF->adoEOF)
|
|
{
|
|
if (NULL == FindSFItemInNavSptTree(dwDevID, (DWORD)pRecSF->GetCollect(_T("ID")).ulVal, sptTree))
|
|
{
|
|
hSFItem = sptTree.InsertItem(pRecSF->GetCollect(_T("SFname")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSF->GetCollect(_T("SFname")),
|
|
hDevItem);
|
|
dwSFHandle = m_handleProcessor.GenerateHandle((DWORD)pRecSF->GetCollect(_T("ID")).ulVal, PZ_STYLE_SPT_FILE);
|
|
|
|
sptTree.SetItemData(hSFItem, dwSFHandle);
|
|
sptTree.SetItemState(hSFItem, uSFImageState, TVIS_STATEIMAGEMASK);
|
|
}
|
|
pRecSF->MoveNext();
|
|
}
|
|
pRecSF->Close();
|
|
|
|
sptTree.Expand(hDevItem, TVE_EXPAND);
|
|
}
|
|
*/
|
|
|
|
bool CSptOperator::InitialNavExecCEDlg(CNavSptCEDlg &navExecCEDlg)
|
|
{
|
|
_RecordsetPtr pRecSCon = NULL;
|
|
CListCtrl& ceList = navExecCEDlg.m_ceList;
|
|
int iIndex = 0;
|
|
DWORD dwHandle = 0;
|
|
|
|
UINT uImageState = (UINT)VAL_ZERO;
|
|
|
|
ceList.DeleteAllItems();
|
|
|
|
uImageState = m_stateProcessor.ChangeToImageState(PZ_STATE_DB);
|
|
pRecSCon.CreateInstance(_uuidof(Recordset));
|
|
|
|
pRecSCon->Open(_T("select ID,Sname,definer,Format(DEdate,'YYYY-MM-DD') as DEdate from scon where Stype = 0 order by DEdate desc"),
|
|
_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecSCon->adoEOF)
|
|
{
|
|
ceList.InsertItem(iIndex, (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("Sname")));
|
|
ceList.SetItemText(iIndex, 1, pRecSCon->GetCollect(_T("definer")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("definer")));
|
|
|
|
ceList.SetItemText(iIndex, 2, (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("DEdate")));
|
|
|
|
dwHandle = m_handleProcessor.GenerateHandle((DWORD)pRecSCon->GetCollect(_T("ID")).ulVal, PZ_STYLE_SCON_CE);
|
|
ceList.SetItemData(iIndex, dwHandle);
|
|
ceList.SetItemState(iIndex, uImageState, LVIS_STATEIMAGEMASK);
|
|
|
|
iIndex++;
|
|
pRecSCon->MoveNext();
|
|
}
|
|
pRecSCon->Close();
|
|
|
|
return true;
|
|
}
|
|
|
|
bool CSptOperator::InitialNavExec2DDlg(CNavSpt2DDlg &navExec2DDlg)
|
|
{
|
|
_RecordsetPtr pRecSCon = NULL;
|
|
CListCtrl& sconList = navExec2DDlg.m_2dList;
|
|
int iIndex = 0;
|
|
DWORD dwHandle = 0;
|
|
|
|
UINT uImageState = (UINT)VAL_ZERO;
|
|
|
|
sconList.DeleteAllItems();
|
|
|
|
uImageState = m_stateProcessor.ChangeToImageState(PZ_STATE_DB);
|
|
pRecSCon.CreateInstance(_uuidof(Recordset));
|
|
|
|
pRecSCon->Open(_T("select ID,Sname,definer,Format(DEdate,'YYYY-MM-DD') as DEdate from scon where Stype = 1 order by DEdate desc"),
|
|
_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecSCon->adoEOF)
|
|
{
|
|
sconList.InsertItem(iIndex, (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("Sname")));
|
|
sconList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("definer")));
|
|
sconList.SetItemText(iIndex, 2, (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("DEdate")));
|
|
|
|
dwHandle = m_handleProcessor.GenerateHandle((DWORD)pRecSCon->GetCollect(_T("ID")).ulVal, PZ_STYLE_SCON_2D);
|
|
sconList.SetItemData(iIndex, dwHandle);
|
|
sconList.SetItemState(iIndex, uImageState, LVIS_STATEIMAGEMASK);
|
|
|
|
iIndex++;
|
|
pRecSCon->MoveNext();
|
|
}
|
|
pRecSCon->Close();
|
|
|
|
return true;
|
|
}
|
|
|
|
bool CSptOperator::InitialNavExec3DDlg(CNavSpt3DDlg &navExec3DDlg)
|
|
{
|
|
_RecordsetPtr pRecSCon = NULL;
|
|
CListCtrl& sconList = navExec3DDlg.m_3dList;
|
|
int iIndex = 0;
|
|
DWORD dwHandle = 0;
|
|
|
|
UINT uImageState = (UINT)VAL_ZERO;
|
|
|
|
sconList.DeleteAllItems();
|
|
|
|
uImageState = m_stateProcessor.ChangeToImageState(PZ_STATE_DB);
|
|
pRecSCon.CreateInstance(_uuidof(Recordset));
|
|
|
|
pRecSCon->Open(_T("select ID,Sname,definer,Format(DEdate,'YYYY-MM-DD') as DEdate from scon where Stype = 2 order by DEdate desc"),
|
|
_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecSCon->adoEOF)
|
|
{
|
|
sconList.InsertItem(iIndex, (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("Sname")));
|
|
sconList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("definer")));
|
|
sconList.SetItemText(iIndex, 2, (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("DEdate")));
|
|
|
|
dwHandle = m_handleProcessor.GenerateHandle((DWORD)pRecSCon->GetCollect(_T("ID")).ulVal, PZ_STYLE_SCON_3D);
|
|
sconList.SetItemData(iIndex, dwHandle);
|
|
sconList.SetItemState(iIndex, uImageState, LVIS_STATEIMAGEMASK);
|
|
|
|
iIndex++;
|
|
pRecSCon->MoveNext();
|
|
}
|
|
pRecSCon->Close();
|
|
|
|
return true;
|
|
}
|
|
|
|
UINT CSptOperator::Create2DSConInDB(CNavSptView* pNavExecView)
|
|
{
|
|
DWORD dwSConID = (DWORD)VAL_ZERO;
|
|
UINT uExecCode = (UINT)VAL_ZERO;
|
|
|
|
try
|
|
{
|
|
// m_pConnection->BeginTrans();
|
|
uExecCode = theApp.m_pSptManager->Create2DSConInDB(dwSConID);
|
|
if (APP_SUCCESS == uExecCode)
|
|
{
|
|
this->AddSConItemToSConList(dwSConID, pNavExecView->m_nav2DDlg.m_2dList);
|
|
// m_pConnection->CommitTrans();
|
|
}
|
|
// else
|
|
// {
|
|
// m_pConnection->RollbackTrans();
|
|
// }
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
// m_pConnection->RollbackTrans();
|
|
return APP_ERR_DB;
|
|
}
|
|
|
|
return uExecCode;
|
|
}
|
|
|
|
UINT CSptOperator::Delete2DSConInDB(CNavSptView* pNavExecView)
|
|
{
|
|
_RecordsetPtr pRecSFID = NULL;
|
|
|
|
int iSConIndex = (int)VAL_ZERO;
|
|
POSITION posSCon;
|
|
|
|
DWORD dwSConHandle = (DWORD)VAL_ZERO;
|
|
DWORD dwSConID = (DWORD)VAL_ZERO;
|
|
|
|
CString szSql = _T("");
|
|
|
|
posSCon = pNavExecView->m_nav2DDlg.m_2dList.GetFirstSelectedItemPosition();
|
|
iSConIndex = pNavExecView->m_nav2DDlg.m_2dList.GetNextSelectedItem(posSCon);
|
|
|
|
dwSConHandle = pNavExecView->m_nav2DDlg.m_2dList.GetItemData(iSConIndex);
|
|
|
|
dwSConID = m_handleProcessor.GetIDFromHandle(dwSConHandle);
|
|
|
|
try
|
|
{
|
|
m_pConnection->BeginTrans();
|
|
|
|
theApp.m_pSptManager->Delete2DSConInDB(dwSConID);
|
|
theApp.m_pSptManager->DeleteObjInMem(dwSConHandle);
|
|
|
|
pNavExecView->m_nav2DDlg.m_2dList.DeleteItem(iSConIndex);
|
|
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
m_pConnection->RollbackTrans();
|
|
return APP_ERR_DB;
|
|
}
|
|
|
|
m_pConnection->CommitTrans();
|
|
|
|
return APP_SUCCESS;
|
|
}
|
|
|
|
UINT CSptOperator::Export2DSConInDB(CNavSptView* pNavExecView)
|
|
{
|
|
_RecordsetPtr pRecSpt = NULL;
|
|
|
|
int iSConIndex = (int)VAL_ZERO;
|
|
POSITION posSCon;
|
|
|
|
DWORD dwSConHandle = (DWORD)VAL_ZERO;
|
|
DWORD dwSConID = (DWORD)VAL_ZERO;
|
|
|
|
posSCon = pNavExecView->m_nav2DDlg.m_2dList.GetFirstSelectedItemPosition();
|
|
iSConIndex = pNavExecView->m_nav2DDlg.m_2dList.GetNextSelectedItem(posSCon);
|
|
|
|
dwSConHandle = pNavExecView->m_nav2DDlg.m_2dList.GetItemData(iSConIndex);
|
|
|
|
dwSConID = m_handleProcessor.GetIDFromHandle(dwSConHandle);
|
|
CString strSptFilePath = pNavExecView->m_nav2DDlg.m_2dList.GetItemText(iSConIndex,0);
|
|
CString strBackName = strSptFilePath;
|
|
|
|
CFileDialog* pFileDial = new CFileDialog(FALSE, _T("txt"), _T(""), OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY|OFN_NOCHANGEDIR,
|
|
_T("txt files(*.txt)|*.txt|All Files (*.*)|*.*||"), NULL);
|
|
pFileDial->m_ofn.lpstrTitle = _T("save files");
|
|
pFileDial->m_ofn.lpstrFile = strBackName.GetBuffer(MAX_PATH);
|
|
pFileDial->m_ofn.nMaxFile = MAX_PATH;
|
|
if (IDOK != pFileDial->DoModal())
|
|
{
|
|
delete pFileDial;
|
|
return APP_CANCLE;
|
|
}
|
|
strBackName.ReleaseBuffer();
|
|
strSptFilePath = pFileDial->GetPathName();
|
|
delete pFileDial;
|
|
|
|
if (theApp.m_pSptManager->Export2DSConInDB(dwSConID, strSptFilePath))
|
|
{
|
|
return APP_SUCCESS;
|
|
}
|
|
return APP_FAIL;
|
|
}
|
|
|
|
UINT CSptOperator::Export3DSConInDB(CNavSptView* pNavExecView)
|
|
{
|
|
|
|
int iSConIndex = (int)VAL_ZERO;
|
|
POSITION posSCon;
|
|
|
|
DWORD dwSConHandle = (DWORD)VAL_ZERO;
|
|
DWORD dwSConID = (DWORD)VAL_ZERO;
|
|
|
|
posSCon = pNavExecView->m_nav3DDlg.m_3dList.GetFirstSelectedItemPosition();
|
|
iSConIndex = pNavExecView->m_nav3DDlg.m_3dList.GetNextSelectedItem(posSCon);
|
|
|
|
dwSConHandle = pNavExecView->m_nav3DDlg.m_3dList.GetItemData(iSConIndex);
|
|
|
|
dwSConID = m_handleProcessor.GetIDFromHandle(dwSConHandle);
|
|
CString strSptFilePath = pNavExecView->m_nav3DDlg.m_3dList.GetItemText(iSConIndex,0);
|
|
CString strBackName = strSptFilePath;
|
|
CFileDialog* pFileDial= new CFileDialog(FALSE, _T("txt"), _T(""), OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY|OFN_NOCHANGEDIR,
|
|
_T("txt files(*.txt)|*.txt|All Files (*.*)|*.*||"), NULL);
|
|
pFileDial->m_ofn.lpstrTitle = _T("save files");
|
|
pFileDial->m_ofn.lpstrFile = strBackName.GetBuffer(MAX_PATH);
|
|
pFileDial->m_ofn.nMaxFile = MAX_PATH;
|
|
if (IDOK != pFileDial->DoModal())
|
|
{
|
|
strBackName.ReleaseBuffer();
|
|
delete pFileDial;
|
|
return APP_CANCLE;
|
|
}
|
|
strBackName.ReleaseBuffer();
|
|
strSptFilePath = pFileDial->GetPathName();
|
|
delete pFileDial;
|
|
if (theApp.m_pSptManager->Export3DSConInDB(dwSConID, strSptFilePath))
|
|
{
|
|
return APP_SUCCESS;
|
|
}
|
|
return APP_FAIL;
|
|
|
|
}
|
|
|
|
UINT CSptOperator::CreateCESConInDB(CNavSptView* pNavExecView)
|
|
{
|
|
DWORD dwSConID = (DWORD)VAL_ZERO;
|
|
UINT uExecCode = (UINT)VAL_ZERO;
|
|
|
|
try
|
|
{
|
|
// m_pConnection->BeginTrans();
|
|
uExecCode = theApp.m_pSptManager->CreateCESConInDB(dwSConID);
|
|
if (APP_SUCCESS == uExecCode)
|
|
{
|
|
this->AddSConItemToSConList(dwSConID, pNavExecView->m_navCEDlg.m_ceList);
|
|
// m_pConnection->CommitTrans();
|
|
}
|
|
// else
|
|
// {
|
|
// m_pConnection->RollbackTrans();
|
|
// }
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
// m_pConnection->RollbackTrans();
|
|
return APP_ERR_DB;
|
|
}
|
|
|
|
return uExecCode;
|
|
}
|
|
|
|
UINT CSptOperator::DeleteCESConInDB(CNavSptView* pNavExecView)
|
|
{
|
|
_RecordsetPtr pRecSFID = NULL;
|
|
|
|
int iSConIndex = (int)VAL_ZERO;
|
|
POSITION posSCon;
|
|
|
|
DWORD dwSConHandle = (DWORD)VAL_ZERO;
|
|
DWORD dwSConID = (DWORD)VAL_ZERO;
|
|
|
|
CString szSql = _T("");
|
|
|
|
posSCon = pNavExecView->m_navCEDlg.m_ceList.GetFirstSelectedItemPosition();
|
|
iSConIndex = pNavExecView->m_navCEDlg.m_ceList.GetNextSelectedItem(posSCon);
|
|
|
|
dwSConHandle = pNavExecView->m_navCEDlg.m_ceList.GetItemData(iSConIndex);
|
|
|
|
dwSConID = m_handleProcessor.GetIDFromHandle(dwSConHandle);
|
|
|
|
try
|
|
{
|
|
m_pConnection->BeginTrans();
|
|
|
|
theApp.m_pSptManager->DeleteCESConInDB(dwSConID);
|
|
theApp.m_pSptManager->DeleteObjInMem(dwSConHandle);
|
|
|
|
pNavExecView->m_navCEDlg.m_ceList.DeleteItem(iSConIndex);
|
|
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
AfxMessageBox(e.Description());
|
|
m_pConnection->RollbackTrans();
|
|
return APP_ERR_DB;
|
|
}
|
|
|
|
m_pConnection->CommitTrans();
|
|
|
|
return APP_SUCCESS;
|
|
}
|
|
|
|
void CSptOperator::AddSConItemToSConList(DWORD dwSConID, CListCtrl &sconList)
|
|
{
|
|
UINT uImageState = (UINT)VAL_ZERO;
|
|
|
|
int iIndex = (int)VAL_ZERO;
|
|
|
|
DWORD dwSConHandle = (DWORD)VAL_ZERO;
|
|
|
|
_RecordsetPtr pRecSCon = NULL;
|
|
CString szSql = _T("");
|
|
|
|
pRecSCon.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ID,Sname,Stype,definer,Format(DEdate,'YYYY-MM-DD') as DEdate from scon where ID = %u"), dwSConID);
|
|
pRecSCon->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecSCon->GetRecordCount())
|
|
{
|
|
sconList.InsertItem(iIndex, (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("Sname")));
|
|
sconList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("definer")));
|
|
sconList.SetItemText(iIndex, 2, (LPCTSTR)(_bstr_t)pRecSCon->GetCollect(_T("DEdate")));
|
|
|
|
switch ((int)pRecSCon->GetCollect(_T("Stype")).iVal)
|
|
{
|
|
case 0:
|
|
dwSConHandle = m_handleProcessor.GenerateHandle((DWORD)pRecSCon->GetCollect(_T("ID")).ulVal, PZ_STYLE_SCON_CE);
|
|
break;
|
|
case 1:
|
|
dwSConHandle = m_handleProcessor.GenerateHandle((DWORD)pRecSCon->GetCollect(_T("ID")).ulVal, PZ_STYLE_SCON_2D);
|
|
break;
|
|
case 2:
|
|
dwSConHandle = m_handleProcessor.GenerateHandle((DWORD)pRecSCon->GetCollect(_T("ID")).ulVal, PZ_STYLE_SCON_3D);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
sconList.SetItemData(iIndex, dwSConHandle);
|
|
|
|
uImageState = m_stateProcessor.ChangeToImageState(PZ_STATE_DB);
|
|
sconList.SetItemState(iIndex, uImageState | LVIS_SELECTED | LVIS_FOCUSED, LVIS_STATEIMAGEMASK | LVIS_SELECTED | LVIS_FOCUSED);
|
|
}
|
|
pRecSCon->Close();
|
|
}
|
|
|
|
//add by waston
|
|
UINT CSptOperator::Create3DSConInDB(CNavSptView* pNavExecView)
|
|
{
|
|
DWORD dwSConID[128];//最多分割成128个子脚本,此处为适应脚本分割需求的修改
|
|
memset(dwSConID, -1, 128);
|
|
UINT uExecCode = (UINT)VAL_ZERO;
|
|
|
|
try
|
|
{
|
|
// m_pConnection->BeginTrans();
|
|
uExecCode = theApp.m_pSptManager->Create3DSConInDB(dwSConID);
|
|
if (APP_SUCCESS == uExecCode)
|
|
{
|
|
for(int i = 0; i < dwSConID[0] + 1; i++)
|
|
{
|
|
this->AddSConItemToSConList(dwSConID[i + 1], pNavExecView->m_nav3DDlg.m_3dList);
|
|
}
|
|
// m_pConnection->CommitTrans();
|
|
}
|
|
// else
|
|
// {
|
|
// m_pConnection->RollbackTrans();
|
|
// }
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
// m_pConnection->RollbackTrans();
|
|
AfxMessageBox(e.Description());
|
|
return APP_ERR_DB;
|
|
}
|
|
|
|
return uExecCode;
|
|
}
|
|
|
|
|
|
UINT CSptOperator::Delete3DSConInDB(CNavSptView *pNavExecView)
|
|
{
|
|
_RecordsetPtr pRecSFID = NULL;
|
|
|
|
int iSConIndex = (int)VAL_ZERO;
|
|
POSITION posSCon;
|
|
|
|
DWORD dwSConHandle = (DWORD)VAL_ZERO;
|
|
DWORD dwSConID = (DWORD)VAL_ZERO;
|
|
|
|
CString szSql = _T("");
|
|
|
|
posSCon = pNavExecView->m_nav3DDlg.m_3dList.GetFirstSelectedItemPosition();
|
|
iSConIndex = pNavExecView->m_nav3DDlg.m_3dList.GetNextSelectedItem(posSCon);
|
|
|
|
dwSConHandle = pNavExecView->m_nav3DDlg.m_3dList.GetItemData(iSConIndex);
|
|
|
|
dwSConID = m_handleProcessor.GetIDFromHandle(dwSConHandle);
|
|
|
|
try
|
|
{
|
|
m_pConnection->BeginTrans();
|
|
|
|
theApp.m_pSptManager->Delete3DSConInDB(dwSConID);
|
|
theApp.m_pSptManager->DeleteObjInMem(dwSConHandle);
|
|
|
|
pNavExecView->m_nav3DDlg.m_3dList.DeleteItem(iSConIndex);
|
|
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
m_pConnection->RollbackTrans();
|
|
return APP_ERR_DB;
|
|
}
|
|
|
|
m_pConnection->CommitTrans();
|
|
|
|
return APP_SUCCESS;
|
|
}
|
|
|
|
UINT CSptOperator::Browse2DScript(CNavSptView *pNavExecView)
|
|
{
|
|
_RecordsetPtr pRecSFID = NULL;
|
|
|
|
int iSConIndex = (int)VAL_ZERO;
|
|
POSITION posSCon;
|
|
|
|
DWORD dwSConHandle = (DWORD)VAL_ZERO;
|
|
DWORD dwSConID = (DWORD)VAL_ZERO;
|
|
|
|
CString szSql = _T("");
|
|
|
|
posSCon = pNavExecView->m_nav2DDlg.m_2dList.GetFirstSelectedItemPosition();
|
|
iSConIndex = pNavExecView->m_nav2DDlg.m_2dList.GetNextSelectedItem(posSCon);
|
|
|
|
dwSConHandle = pNavExecView->m_nav2DDlg.m_2dList.GetItemData(iSConIndex);
|
|
|
|
dwSConID = m_handleProcessor.GetIDFromHandle(dwSConHandle);
|
|
|
|
try
|
|
{
|
|
theApp.m_pSptManager->Browse2DScript(dwSConID);
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
return APP_ERR_DB;
|
|
}
|
|
|
|
return APP_SUCCESS;
|
|
}
|