3378 lines
84 KiB
C++
3378 lines
84 KiB
C++
#include "stdafx.h"
|
||
#include <algorithm>
|
||
#include "initools.h"
|
||
#include "FilePath.h"
|
||
#include "KTCadUtility.h"
|
||
#include "KTModelLayoutXData.h"
|
||
#include "EquipmentLibraryDlg.h"
|
||
#include "CoreTools.h"
|
||
#include "aecdbewequipment.h"
|
||
#include "AcGiViewDraw.h"
|
||
#include "dbobjptr.h"
|
||
#include "EquInsDirJig.h"
|
||
#include "KTSetting.h"
|
||
#include "XKMMDlg.h"
|
||
#include "CFLEndFGsDlg.h"
|
||
#include "dbvisualstyle.h"
|
||
#include "acgs.h"
|
||
#include "CFZSBAddDlg.h"
|
||
|
||
#define SHOWWINDOW(id, sh) if (GetDlgItem(id)) GetDlgItem(id)->ShowWindow(sh);
|
||
|
||
#define EQU_DIR _T("\\equipment")
|
||
#define ZH_SB_BIM_REC _T("ZH_SB_BIM_REC")
|
||
#define ZH_SB_BLK_NAME _T("ZH_SB_BLK_NAME")
|
||
#define ZH_SB_BLK_EXT _T("ZH_SB_BLK_EXT")
|
||
#define ZH_SB_FLAG _T("ZH_SB_FLAG")
|
||
#define ZH_SB_NAME _T("ZH_SB_NAME")
|
||
#define ZH_SB_REF_FIELD _T("ZH_SB_REF_FIELD")
|
||
|
||
namespace
|
||
{
|
||
static std::map<int, CString> g_result;
|
||
|
||
void refreshSearchResult(CUIISQLiteServer &db
|
||
, bool bRefresh
|
||
, const CEquipmentLibraryDlg::EOPER &oper)
|
||
{
|
||
if (!bRefresh) return;
|
||
|
||
g_result.clear();
|
||
|
||
std::vector<std::vector<CString>> rr;
|
||
CString sTbl(oper == CEquipmentLibraryDlg::eManaZhSb ? _T("dwg") : _T("aec"))
|
||
, sql(_T(""));
|
||
sql.Format(_T("SELECT distinct %s_package.[id], %s_folder.[folder], %s_class.[class], %s_package.[name]")
|
||
_T("\nFROM %s_package")
|
||
_T("\nINNER JOIN %s_folder, %s_class")
|
||
_T("\nON(%s_package.[idclass] = %s_class.[id]")
|
||
_T("\nAND %s_class.[idfolder] = %s_folder.[id])"), sTbl, sTbl, sTbl, sTbl, sTbl
|
||
, sTbl, sTbl, sTbl, sTbl, sTbl, sTbl);
|
||
db.GetSelDataEx(sql, rr);
|
||
for (size_t i(0); i < rr.size(); ++i)
|
||
{
|
||
std::vector<CString> &ss(rr[i]);
|
||
if (ss.size() < 3) continue;
|
||
|
||
g_result.insert(
|
||
std::make_pair(TypeConvert::convert<int, LPCTSTR>(ss[0])
|
||
, (ss[1] + _T("\\") + ss[2] + _T("\\") + ss[3]).MakeUpper()));
|
||
}
|
||
}
|
||
|
||
void search(CUIISQLiteServer &db
|
||
, const std::vector<CString> &conditions
|
||
, std::map<int, CString> &result
|
||
, const CEquipmentLibraryDlg::EOPER &oper)
|
||
{
|
||
if (g_result.empty())
|
||
{
|
||
refreshSearchResult(db, true, oper);
|
||
}
|
||
|
||
bool bFind(true);
|
||
std::map<int, CString>::const_iterator it(g_result.begin());
|
||
for (it; it != g_result.end(); ++it)
|
||
{
|
||
const CString &s(it->second);
|
||
bFind = true;
|
||
for (size_t i(0); i < conditions.size(); ++i)
|
||
{
|
||
if (s.Find(conditions[i]) == -1)
|
||
{
|
||
bFind = false;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (bFind)
|
||
{
|
||
result.insert(*it);
|
||
}
|
||
}
|
||
}
|
||
|
||
HTREEITEM FindTreeItem(CTreeCtrl *pTreeCtrl, HTREEITEM hItem, const CString &strText)
|
||
{
|
||
// 如果当前节点的文本匹配,返回该节点
|
||
if (pTreeCtrl->GetItemText(hItem) == strText)
|
||
return hItem;
|
||
|
||
// 获取第一个子节点
|
||
HTREEITEM hChildItem = pTreeCtrl->GetChildItem(hItem);
|
||
while (hChildItem != NULL)
|
||
{
|
||
// 递归查找子节点
|
||
HTREEITEM hFoundItem = FindTreeItem(pTreeCtrl, hChildItem, strText);
|
||
if (hFoundItem != NULL)
|
||
return hFoundItem;
|
||
|
||
// 获取下一个兄弟节点
|
||
hChildItem = pTreeCtrl->GetNextSiblingItem(hChildItem);
|
||
}
|
||
|
||
// 如果没有找到,返回 nullptr
|
||
return NULL;
|
||
}
|
||
|
||
HTREEITEM FindItemInTreeCtrl(CTreeCtrl *pTreeCtrl, const CString &strText)
|
||
{
|
||
// 从根节点开始查找
|
||
HTREEITEM hRootItem = pTreeCtrl->GetRootItem();
|
||
while (hRootItem != NULL)
|
||
{
|
||
HTREEITEM hFoundItem = FindTreeItem(pTreeCtrl, hRootItem, strText);
|
||
if (hFoundItem != NULL)
|
||
return hFoundItem;
|
||
|
||
// 查找下一个兄弟节点
|
||
hRootItem = pTreeCtrl->GetNextSiblingItem(hRootItem);
|
||
}
|
||
|
||
return NULL; // 未找到返回 nullptr
|
||
}
|
||
|
||
// windows文件命不能含有“/\:*?"<>|”,统一替换为"'"
|
||
CString checkFileName(LPCTSTR sfile)
|
||
{
|
||
if (!sfile) return _T("");
|
||
CString s(sfile);
|
||
s.Replace(_T('/'), _T('\''));
|
||
s.Replace(_T('\\'), _T('\''));
|
||
s.Replace(_T(':'), _T('\''));
|
||
s.Replace(_T('*'), _T('\''));
|
||
s.Replace(_T('?'), _T('\''));
|
||
s.Replace(_T('\"'), _T('\''));
|
||
s.Replace(_T('<'), _T('\''));
|
||
s.Replace(_T('>'), _T('\''));
|
||
s.Replace(_T('|'), _T('\''));
|
||
return s;
|
||
}
|
||
|
||
CString getLastErrorMsg()
|
||
{
|
||
LPVOID lpMsgBuf;
|
||
::FormatMessage(
|
||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||
NULL,
|
||
GetLastError(),
|
||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||
(LPTSTR)&lpMsgBuf,
|
||
0,
|
||
NULL
|
||
);
|
||
CString sErr = (LPCTSTR)lpMsgBuf;
|
||
LocalFree(lpMsgBuf);
|
||
return sErr;
|
||
}
|
||
|
||
AecDbEwEquipment *makeEqu(LPCTSTR pszEqu, SH_BIM_BLOCK &bims)
|
||
{
|
||
if (!pszEqu) return NULL;
|
||
if (_taccess(pszEqu, 0x0) != 0x0) return NULL;
|
||
|
||
AecDbEwEquipment *pEqu = new AecDbEwEquipment();
|
||
if (!pEqu->ReadFromFile(pszEqu))
|
||
{
|
||
DELETE_PTR(pEqu);
|
||
return NULL;
|
||
}
|
||
|
||
bims.clear();
|
||
CoreTools::getBimDatas(pEqu, bims);
|
||
return pEqu;
|
||
}
|
||
|
||
void insertEqu(AecDbEwEquipment *pEqu)
|
||
{
|
||
if (!pEqu) return;
|
||
|
||
AecMInterfaces *pMInf = (AecMInterfaces *)pEqu;
|
||
|
||
CFZSBAddDlg dlg;
|
||
dlg.SetEqu(pEqu, pMInf);
|
||
if (IDOK == dlg.DoModal())
|
||
{
|
||
pEqu->SetAt(KEY_POSNO, dlg.m_sPosNo);
|
||
}
|
||
|
||
//设置osnap
|
||
AcDbObjectId idPipe;
|
||
double dEl = 0.0;
|
||
bool bdEl = false;
|
||
//选择插入点
|
||
ads_point ptRes;
|
||
while (TRUE)
|
||
{
|
||
acedInitGet(RSG_OTHER, _T("E R"));
|
||
int nRes = acedGetPoint(NULL, _T("\n选择插入位置点或[指定标高(E)/参考点(R)]:"), ptRes);
|
||
switch (nRes)
|
||
{
|
||
case RTNORM:
|
||
{
|
||
{
|
||
EQU_INSERT_POS:
|
||
acdbUcs2Wcs(ptRes, ptRes, false);
|
||
if (bdEl) ptRes[Z] = dEl;
|
||
|
||
AcGeVector3d vtMove = asPnt3d(ptRes).asVector();
|
||
AcGeMatrix3d mat;
|
||
mat.setToTranslation(vtMove);
|
||
pEqu->transformBy(mat);
|
||
|
||
struct resbuf rb;
|
||
acedGetVar(_T("INSUNITS"), &rb);
|
||
if (rb.resval.rint == AcDb::kUnitsMeters) //当前图是米制
|
||
{
|
||
AcGeMatrix3d scale;
|
||
scale.setToScaling(.001);
|
||
pEqu->AddTransform(scale);
|
||
}
|
||
|
||
//选择方向,插入
|
||
CEquInsDirJig jig;
|
||
jig.SetEqu(pEqu, asPnt3d(ptRes));
|
||
if (jig.DoIt())
|
||
{
|
||
AcGeVector3d vtDir = AcGeVector3d::kXAxis;
|
||
vtDir.rotateBy(jig.m_dAngle, AcGeVector3d::kZAxis);
|
||
AcGePoint3d ptIns = asPnt3d(ptRes);
|
||
pEqu->SetInsert(ptIns, vtDir);
|
||
|
||
if (dlg.m_nIndex1 != -1 && dlg.m_bByInf)
|
||
{
|
||
//移动接口到ins 位置
|
||
AecInterface infT;
|
||
pEqu->GetInterface(dlg.m_nIndex1, infT);
|
||
|
||
AcGeVector3d vtInfPos = ptIns - infT.ptPos;
|
||
mat.setToTranslation(vtInfPos);
|
||
pEqu->transformBy(mat);
|
||
}
|
||
|
||
AcDbObjectId idLayE, idLayC, idLayD;
|
||
idLayE = KTSetting::InitLayer(LAY_EQU);
|
||
idLayC = KTSetting::InitLayer(LAY_EQU_CENTER);
|
||
idLayD = KTSetting::InitLayer(LAY_EQU_DASH);
|
||
|
||
pEqu->setLayer(idLayE);
|
||
pEqu->SetCenterLayer(idLayC);
|
||
pEqu->SetDashLayer(idLayD);
|
||
|
||
//设备内部已经处理了单位
|
||
if (rb.resval.rint == AcDb::kUnitsMeters) //当前图是米制
|
||
{
|
||
pEqu->RemoveLastTransform();
|
||
}
|
||
|
||
CoreTools::AddToModelSpace(pEqu);
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
DELETE_PTR(pEqu);
|
||
return;
|
||
}
|
||
}
|
||
break;
|
||
}
|
||
case RTKWORD:
|
||
{
|
||
TCHAR szKey[3];
|
||
acedGetInput(szKey);
|
||
if (_tcsicmp(_T("E"), szKey) == 0)
|
||
{
|
||
CString sTip;
|
||
sTip.Format(_T("\n请输入标高<%.1f>:"), dEl);
|
||
|
||
nRes = acedGetReal(sTip, &dEl);
|
||
|
||
if (nRes == RTNORM || nRes == RTNONE)
|
||
{
|
||
bdEl = true;
|
||
continue;
|
||
}
|
||
else
|
||
{
|
||
return;
|
||
}
|
||
}
|
||
else if (_tcsicmp(_T("R"), szKey) == 0)
|
||
{
|
||
//参考点<退出>:
|
||
ads_point ptBase, pt22;
|
||
int nRelt = acedGetPoint(NULL, _T("\n参考点<退出>:"), ptBase);
|
||
if (nRelt == RTNORM)
|
||
{
|
||
//起点<退出>:
|
||
nRelt = acedGetPoint(ptBase, _T("\n指定相对位置为插入点<退出>:"), pt22);
|
||
if (nRelt == RTNORM)
|
||
{
|
||
ads_point_set(pt22, ptRes);
|
||
|
||
goto EQU_INSERT_POS;
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
}
|
||
default:
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
|
||
bool checkFileName(LPCTSTR pszName, LPCTSTR pszCondition)
|
||
{
|
||
if (!pszName || !pszCondition) return false;
|
||
CString sName(pszName), sCondition(pszCondition);
|
||
sName.MakeLower();
|
||
sCondition.MakeLower();
|
||
|
||
int idx = sName.Find(sCondition);
|
||
if (idx == -1) return false;
|
||
|
||
// 主要解决 在文件名中查找DN100 会得到 DN1000... 等结果
|
||
// 只判断 子串 后面第一个字符是否是数字即可
|
||
idx = idx + sCondition.GetLength();
|
||
if (idx >= sName.GetLength()) return true;
|
||
if (sName[idx] <= _T('9') && sName[idx] >= _T('0'))
|
||
return false;
|
||
return true;
|
||
}
|
||
|
||
HTREEITEM findSubDir(CTreeCtrl &tree, HTREEITEM hRoot, LPCTSTR pszSubDir)
|
||
{
|
||
if (!tree.ItemHasChildren(hRoot) || !pszSubDir) return NULL;
|
||
|
||
CString str(_T(""));
|
||
HTREEITEM hChildItem = tree.GetChildItem(hRoot);
|
||
while (hChildItem != NULL)
|
||
{
|
||
str = tree.GetItemText(hChildItem);
|
||
if (str == pszSubDir)
|
||
return hChildItem;
|
||
hChildItem = tree.GetNextItem(hChildItem, TVGN_NEXT);
|
||
}
|
||
return NULL;
|
||
}
|
||
|
||
void getAllChildrenItem(CTreeCtrl &tree, HTREEITEM hRoot, std::vector<HTREEITEM> &items)
|
||
{
|
||
if (!tree.ItemHasChildren(hRoot)) return;
|
||
|
||
HTREEITEM hChildItem = tree.GetChildItem(hRoot);
|
||
while (hChildItem != NULL)
|
||
{
|
||
items.push_back(hChildItem);
|
||
getAllChildrenItem(tree, hChildItem, items);
|
||
hChildItem = tree.GetNextItem(hChildItem, TVGN_NEXT);
|
||
}
|
||
}
|
||
|
||
void initTree(CTreeCtrl &tree
|
||
, CImageList &imglist
|
||
, CUIISQLiteServer &db
|
||
, const CEquipmentLibraryDlg::EOPER &oper)
|
||
{
|
||
tree.SetImageList(&imglist, TVSIL_NORMAL);
|
||
|
||
CString sTitle, sTbl;
|
||
if (oper != CEquipmentLibraryDlg::eManaZhSb && oper != CEquipmentLibraryDlg::eInsZhSb)
|
||
{
|
||
sTitle = _T("自定义设备");
|
||
sTbl = _T("aec");
|
||
}
|
||
else
|
||
{
|
||
sTitle = _T("组合设备");
|
||
sTbl = _T("dwg");
|
||
}
|
||
|
||
HTREEITEM hRoot = tree.InsertItem(sTitle, 0, 2, TVI_ROOT);
|
||
tree.SetItemData(hRoot, -1);
|
||
|
||
std::vector<std::vector<CString>> folders, dirs;
|
||
std::vector<std::vector<CString>>::const_iterator it_folder, it_dir;
|
||
db.GetSelDataEx(CString(_T("select id, folder from ")) + sTbl + _T("_folder"), folders);
|
||
std::vector<CString> subs;
|
||
for (it_folder = folders.begin(); it_folder != folders.end(); ++it_folder)
|
||
{
|
||
if (it_folder->size() < 2) continue;
|
||
// 一级目录 对应着 aec_folder 表
|
||
HTREEITEM hFolder = findSubDir(tree, hRoot, it_folder->at(1));
|
||
hRoot = tree.InsertItem(it_folder->at(1), 0, 2, hRoot);
|
||
tree.SetItemData(hRoot, TypeConvert::convert<int, LPCTSTR>(it_folder->at(0)));
|
||
// 二级目录 对应着 aec_class 表
|
||
|
||
dirs.clear();
|
||
db.GetSelDataEx(
|
||
CString(_T("select id, class from ")) + sTbl + _T("_class where idfolder = ") + it_folder->at(0),
|
||
dirs);
|
||
|
||
for (it_dir = dirs.begin(); it_dir != dirs.end(); ++it_dir)
|
||
{
|
||
if (it_dir->size() < 2) continue;
|
||
// 对二级目录进行拆分
|
||
subs.clear();
|
||
CoreTools::SplitString(it_dir->at(1), _T('\\'), subs);
|
||
if (subs.empty()) continue;
|
||
|
||
HTREEITEM hSub(NULL);
|
||
HTREEITEM hParent = hRoot;
|
||
for (size_t i = 0; i < subs.size(); ++i)
|
||
{
|
||
hSub = findSubDir(tree, hParent, subs[i]);
|
||
if (!hSub) // 没找到,新建
|
||
{
|
||
hParent = tree.InsertItem(subs[i], 0, 2, hParent);
|
||
tree.SetItemData(hParent, TypeConvert::convert<int, LPCTSTR>(it_dir->at(0)));
|
||
}
|
||
else
|
||
hParent = hSub;
|
||
}
|
||
}
|
||
|
||
hRoot = tree.GetRootItem();
|
||
}
|
||
tree.Expand(hRoot, TVE_EXPAND);
|
||
return;
|
||
}
|
||
|
||
bool isFolderItem(CTreeCtrl &tree, HTREEITEM hItem)
|
||
{
|
||
return tree.GetRootItem() == tree.GetParentItem(hItem);
|
||
}
|
||
|
||
bool isRootItem(CTreeCtrl &tree, HTREEITEM hItem)
|
||
{
|
||
return hItem == tree.GetRootItem();
|
||
}
|
||
|
||
bool isClassItem(CTreeCtrl &tree, HTREEITEM hItem)
|
||
{
|
||
return (!isRootItem(tree, hItem) && !isFolderItem(tree, hItem));
|
||
}
|
||
|
||
HTREEITEM getParentFolder(CTreeCtrl &tree, const HTREEITEM &hItem)
|
||
{
|
||
if (hItem == tree.GetRootItem()) return NULL;
|
||
if (isFolderItem(tree, hItem)) return hItem;
|
||
|
||
HTREEITEM h = tree.GetParentItem(hItem);
|
||
while (isClassItem(tree, h))
|
||
{
|
||
h = tree.GetParentItem(h);;
|
||
}
|
||
|
||
return h;
|
||
}
|
||
|
||
CString getClassName(CTreeCtrl &tree, const HTREEITEM &hItem)
|
||
{
|
||
if (!isClassItem(tree, hItem)) return _T("");
|
||
CString sItem = tree.GetItemText(hItem);
|
||
std::vector<CString> v;
|
||
HTREEITEM hParent(hItem);
|
||
while (isClassItem(tree, hParent))
|
||
{
|
||
v.push_back(tree.GetItemText(hParent));
|
||
hParent = tree.GetParentItem(hParent);
|
||
}
|
||
CString sClass(_T(""));
|
||
for (std::vector<CString>::reverse_iterator it = v.rbegin(); it != v.rend(); ++it)
|
||
{
|
||
sClass += *it;
|
||
sClass += _T("\\");
|
||
}
|
||
sClass = sClass.Left(sClass.ReverseFind(_T('\\')));
|
||
return sClass;
|
||
}
|
||
|
||
AecDbEwEquipment *makeEqu(CUIISQLiteServer &db, const int &fid)
|
||
{
|
||
CString sSQL(_T(""));
|
||
std::vector<CString> ss;
|
||
std::vector<std::vector<CString>> bims;
|
||
ss.clear();
|
||
sSQL.Format(_T("select id,name,idclass,rem from aec_package where ID='%d'"), fid);
|
||
if (!db.GetSelData(sSQL, ss)) return NULL;
|
||
if (ss.size() < 4) return NULL;
|
||
|
||
CString tmpFile(FilePath::getSystemTemporaryFolder() + _T("\\temp_$_$_.equ"));
|
||
sSQL.Format(_T("select package from aec_package where ID='%d'"), fid);
|
||
if (!db.GetSelBlob(sSQL, tmpFile)) return NULL;
|
||
|
||
AecDbEwEquipment *pEqu = new AecDbEwEquipment;
|
||
|
||
if (!pEqu->ReadFromFile(tmpFile))
|
||
{
|
||
DELETE_PTR(pEqu);
|
||
::DeleteFile(tmpFile);
|
||
return NULL;
|
||
}
|
||
::DeleteFile(tmpFile);
|
||
|
||
pEqu->GetSpecialtyData()->SetAt(KEY_ID, ss[0]);
|
||
pEqu->GetSpecialtyData()->SetAt(KEY_NAME, ss[1]);
|
||
pEqu->GetSpecialtyData()->SetAt(KEY_CLASSID, ss[2]);
|
||
pEqu->GetSpecialtyData()->SetAt(_T("_KEY_REM_"), ss[3]);
|
||
|
||
pEqu->setLayer(KTSetting::InitLayer(LAY_PIPE_OUTSIDE));
|
||
pEqu->SetDashLayer(KTSetting::InitLayer(LAY_FITN_DASH));
|
||
pEqu->SetCenterLayer(KTSetting::InitLayer(LAY_FITN_CENTER));
|
||
|
||
//关闭箭头,通常入库的设备元件箭头是关闭的
|
||
AecEqui::XPrimData xdata;
|
||
pEqu->ModifyPrimData(0, xdata, 10);
|
||
|
||
// BIM数据
|
||
sSQL.Format(_T("select name,value from aec_bims where equid='%d'"), fid);
|
||
if (db.GetSelDataEx(sSQL, bims))
|
||
{
|
||
SH_BIM_BLOCK datas;
|
||
for (size_t b = 0; b < bims.size(); ++b)
|
||
{
|
||
std::vector<CString> &s(bims[b]);
|
||
if (s.size() >= 2)
|
||
datas.push_back(std::make_pair(s[0], s[1]));
|
||
}
|
||
CoreTools::setBimDatas(pEqu, datas);
|
||
}
|
||
|
||
return pEqu;
|
||
}
|
||
|
||
CString getZhSbNameFromDb(CUIISQLiteServer &db, const int &fid)
|
||
{
|
||
CString sSQL(_T(""));
|
||
sSQL.Format(_T("SELECT dwg_folder.[Folder], dwg_class.[Class], dwg_package.[Name]")
|
||
_T(" FROM")
|
||
_T(" dwg_class INNER JOIN dwg_folder")
|
||
_T(" ON dwg_folder.[ID] = dwg_class.[IDFolder]")
|
||
_T(" INNER JOIN dwg_package")
|
||
_T(" ON dwg_package.[IDClass] = dwg_class.[ID]")
|
||
_T(" WHERE dwg_package.[ID] = '%d'"), fid);
|
||
|
||
std::vector<std::vector<CString>> v;
|
||
db.GetSelDataEx(sSQL, v);
|
||
|
||
if (v.empty()) return _T("");
|
||
if (v[0].size() < 2) return _T("");
|
||
|
||
CString ss(_T(""));
|
||
ss.Format(_T("%s\\%s\\%s"), v[0][0], v[0][1], v[0][2]);
|
||
ss.Replace(_T('\\'), _T('-'));
|
||
return ss;
|
||
}
|
||
|
||
std::shared_ptr<AcDbDatabase> getZhSbFileFromDb(CUIISQLiteServer &db, const int &fid)
|
||
{
|
||
CString sPath(FilePath::getSystemTemporaryFolder() + _T("\\temp_$_$_.dwg"));
|
||
if (_taccess(sPath, 0x0) == 0x0)
|
||
::DeleteFile(sPath);
|
||
|
||
CString sSQL(_T(""));
|
||
sSQL.Format(_T("select package from dwg_package where ID='%d'"), fid);
|
||
if (db.GetSelBlob(sSQL, sPath))
|
||
{
|
||
AcDbDatabase *p(new AcDbDatabase(false));
|
||
if (p->readDwgFile(sPath, AcDbDatabase::kTryForReadShare) == Acad::eOk)
|
||
return std::shared_ptr<AcDbDatabase>(p);
|
||
else
|
||
DELETE_PTR(p);
|
||
}
|
||
return std::shared_ptr<AcDbDatabase>();
|
||
}
|
||
|
||
bool readXDataFromZhSbFile(AcDbDatabase *pDb, AecDbObjXDataMap &xData)
|
||
{
|
||
if (!pDb) return false;
|
||
return KTModelLayoutXData::ReadModelNameObjXData(ZH_SB_BIM_REC, xData, pDb) == FALSE ? false : true;
|
||
}
|
||
|
||
bool writeXDataFromZhSbFile(AcDbDatabase *pDb, AecDbObjXDataMap &xData)
|
||
{
|
||
if (!pDb) return false;
|
||
if (KTModelLayoutXData::WriteModelNameObjXData(ZH_SB_BIM_REC, xData, pDb))
|
||
return pDb->saveAs(pDb->originalFileName(), true, AcDb::kDHL_CURRENT) == Acad::eOk;
|
||
return false;
|
||
}
|
||
|
||
bool getBimsFromZhSbFile(AcDbDatabase *pDb, SH_BIM_BLOCK &bims)
|
||
{
|
||
if (!pDb) return false;
|
||
AecDbObjXDataMap xDataMap;
|
||
readXDataFromZhSbFile(pDb, xDataMap);
|
||
CString s;
|
||
AecDbObjXDataMap::CIt it(xDataMap.Begin());
|
||
for (; it != xDataMap.End(); ++it)
|
||
{
|
||
if (xDataMap.GetAt(it->first, s))
|
||
bims.push_back(std::make_pair(it->first, s));
|
||
}
|
||
return !bims.empty();
|
||
}
|
||
|
||
bool getBimsFromZhSbId(CUIISQLiteServer &db, const int &fid, SH_BIM_BLOCK &bims)
|
||
{
|
||
std::shared_ptr<AcDbDatabase> pDb = getZhSbFileFromDb(db, fid);
|
||
return getBimsFromZhSbFile(pDb.get(), bims);
|
||
}
|
||
|
||
bool updateDwgPackage(CUIISQLiteServer &db, const int &fid, LPCTSTR pszPath)
|
||
{
|
||
if (!pszPath) return false;
|
||
CString sql(_T(""));
|
||
sql.Format(_T("update dwg_package set package=? where id='%d'"), fid);
|
||
return db.UpdateBlob(sql, pszPath) == 0 ? false : true;
|
||
}
|
||
|
||
bool addBimRecToZhSbFile(CUIISQLiteServer &db, const int &fid, const SH_BIM_REC &rec)
|
||
{
|
||
std::shared_ptr<AcDbDatabase> pDb = getZhSbFileFromDb(db, fid);
|
||
|
||
AecDbObjXDataMap xDataMap;
|
||
if (!readXDataFromZhSbFile(pDb.get(), xDataMap)) return false;
|
||
|
||
xDataMap.SetAt(rec.first, rec.second);
|
||
if (!writeXDataFromZhSbFile(pDb.get(), xDataMap)) return false;
|
||
|
||
return updateDwgPackage(db, fid, pDb->originalFileName());
|
||
}
|
||
|
||
bool delBimRecToZhSbFile(CUIISQLiteServer &db, const int &fid, LPCTSTR sKey)
|
||
{
|
||
std::shared_ptr<AcDbDatabase> pDb = getZhSbFileFromDb(db, fid);
|
||
|
||
AecDbObjXDataMap xDataMap;
|
||
if (!readXDataFromZhSbFile(pDb.get(), xDataMap)) return false;
|
||
|
||
xDataMap.RemoveAt(sKey);
|
||
if (!writeXDataFromZhSbFile(pDb.get(), xDataMap)) return false;
|
||
|
||
return updateDwgPackage(db, fid, pDb->originalFileName());
|
||
}
|
||
|
||
bool selectPath(LPCTSTR pszTitle, CString &strPath)
|
||
{
|
||
TCHAR szFolderPath[MAX_PATH] = { 0 };
|
||
CString strFolderPath = TEXT("");
|
||
BROWSEINFO sInfo;
|
||
::ZeroMemory(&sInfo, sizeof(BROWSEINFO));
|
||
sInfo.pidlRoot = 0;
|
||
sInfo.lpszTitle = pszTitle;
|
||
sInfo.ulFlags = BIF_RETURNONLYFSDIRS | BIF_EDITBOX | BIF_DONTGOBELOWDOMAIN;
|
||
sInfo.lpfn = NULL;
|
||
LPITEMIDLIST lpidlBrowse = ::SHBrowseForFolder(&sInfo);
|
||
if (lpidlBrowse != NULL)
|
||
{
|
||
if (::SHGetPathFromIDList(lpidlBrowse, szFolderPath))
|
||
{
|
||
strFolderPath = szFolderPath;
|
||
}
|
||
}
|
||
if (lpidlBrowse != NULL)
|
||
{
|
||
::CoTaskMemFree(lpidlBrowse);
|
||
}
|
||
if (!lpidlBrowse)
|
||
return false;
|
||
|
||
if (_taccess(strFolderPath, 0x0) != 0x0)
|
||
{
|
||
AfxMessageBox(_T("请选择一个有效路径!"));
|
||
return false;
|
||
}
|
||
|
||
strPath = strFolderPath + _T("\\");
|
||
|
||
return true;
|
||
}
|
||
|
||
bool makeDir(CTreeCtrl &tree, HTREEITEM hItem, LPCTSTR pszRootDir)
|
||
{
|
||
if (!pszRootDir) return false;
|
||
|
||
// 根目录不存在
|
||
if (_taccess(pszRootDir, 0x0) != 0x0)
|
||
return false;
|
||
|
||
// hItem 所指目录已经存在, 继续新建子目录,如果不存在,新建
|
||
CString sDir = pszRootDir + tree.GetItemText(hItem) + _T("\\");
|
||
if (!_taccess(sDir, 0x0) == 0x0)
|
||
{
|
||
if (!CreateDirectory(sDir, NULL))
|
||
{
|
||
#ifndef NDEBUG
|
||
AfxMessageBox(getLastErrorMsg());
|
||
#endif
|
||
return false;
|
||
}
|
||
}
|
||
|
||
if (!tree.ItemHasChildren(hItem)) return true;
|
||
|
||
HTREEITEM hChildItem = tree.GetChildItem(hItem);
|
||
while (hChildItem != NULL)
|
||
{
|
||
makeDir(tree, hChildItem, sDir);
|
||
hChildItem = tree.GetNextItem(hChildItem, TVGN_NEXT);
|
||
}
|
||
return true;
|
||
}
|
||
|
||
int getLastInserId(CUIISQLiteServer &db, LPCTSTR pszTable)
|
||
{
|
||
CString sId;
|
||
if (db.GetSelData(CString(_T("select last_insert_rowid() from")) + pszTable, sId))
|
||
return TypeConvert::convert<int, LPCTSTR>(sId);
|
||
return -1;
|
||
}
|
||
|
||
bool putEquFileToDb(CUIISQLiteServer &db
|
||
, LPCTSTR pszFile
|
||
, int idClass
|
||
, const CEquipmentLibraryDlg::EOPER &oper )
|
||
{
|
||
if (!pszFile) return false;
|
||
if (_taccess(pszFile, 0x0) != 0x0) return false;
|
||
|
||
CString sPath(pszFile), sTbl(oper == CEquipmentLibraryDlg::eManaZhSb ? _T("dwg") : _T("aec"));
|
||
|
||
CString sName(_T(""));
|
||
if (oper != CEquipmentLibraryDlg::eManaZhSb)
|
||
{
|
||
sName = CoreTools::getEquipmentName(sPath);
|
||
if (sName.IsEmpty()) return false;
|
||
}
|
||
else
|
||
{
|
||
FilePath f(pszFile);
|
||
sName = f._file_name_without_ext;
|
||
}
|
||
|
||
CString pszSuffix = sPath.Right(sPath.GetLength() - sPath.ReverseFind(_T('.')));
|
||
if (pszSuffix == _T(".r2p"))
|
||
{
|
||
AecDbEwEquipment *pEqu = new AecDbEwEquipment();
|
||
if (pEqu->ReadFromFile(sPath))
|
||
{
|
||
sPath = FilePath::getSystemTemporaryFolder() + _T("\\xxx__xx_dd.equ");
|
||
pEqu->WriteToFile(sPath);
|
||
DELETE_PTR(pEqu);
|
||
}
|
||
}
|
||
else if (pszSuffix == _T(".zhequ"))
|
||
{
|
||
CString sFile(FilePath::getSystemTemporaryFolder() + _T("\\temp&&$$.dwg"));
|
||
if (_taccess(sFile, 0x0) == 0x0)
|
||
::DeleteFile(sFile);
|
||
|
||
if (!::CopyFile(sPath, sFile, false)) return false;
|
||
|
||
std::shared_ptr<AcDbDatabase> pDb(new AcDbDatabase(false));
|
||
if (pDb->readDwgFile(sFile, AcDbDatabase::kForReadAndAllShare) != Acad::eOk)
|
||
return false;
|
||
AcDbBlockTableRecordPointer pRcd(ZH_SB_BLK_NAME, pDb.get(), AcDb::kForRead);
|
||
if (pRcd.openStatus() != Acad::eOk)
|
||
{
|
||
CString sErr(_T(""));
|
||
sErr.Format(_T("文件%s,不是上华组合设备格式!"), sPath);
|
||
AfxMessageBox(sErr);
|
||
return false;
|
||
}
|
||
sPath = sFile;
|
||
}
|
||
|
||
CString sql(_T(""));
|
||
sql.Format(_T("insert into %s_package ([name],[rem],[idclass],[package]) values ('%s', '', '%d', ?)")
|
||
, sTbl
|
||
, sName
|
||
, idClass);
|
||
db.BeginTrans();
|
||
if (db.InsertBlob(sql, sPath))
|
||
{
|
||
int fid = getLastInserId(db, sTbl + _T("_package"));
|
||
SH_BIM_BLOCK bims;
|
||
SH_BIM_BLOCK::const_iterator it;
|
||
if (oper == CEquipmentLibraryDlg::eMana)
|
||
{
|
||
AecDbEwEquipment *pEqu = makeEqu(sPath, bims);
|
||
DELETE_PTR(pEqu);
|
||
for (it = bims.begin(); it != bims.end(); ++it)
|
||
{
|
||
sql.Format(_T("insert into %s_bims (name, value, equid) values ('%s', '%s', '%d')")
|
||
, sTbl
|
||
, it->first
|
||
, it->second
|
||
, fid);
|
||
db.ExecuteSQL(sql);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 不需要处理 组合设备 的 bim,bim属性直接在文件里面
|
||
}
|
||
}
|
||
db.CommitTrans();
|
||
|
||
return true;
|
||
}
|
||
|
||
bool hasEquFilesInDb(CUIISQLiteServer &db, CTreeCtrl &tree, HTREEITEM hItem)
|
||
{
|
||
std::vector<HTREEITEM> items;
|
||
items.push_back(hItem);
|
||
getAllChildrenItem(tree, hItem, items);
|
||
CString sql(_T("")), sTmp(_T(""));
|
||
for (int i(0); i < items.size(); ++i)
|
||
{
|
||
int idFolder = tree.GetItemData(items[i]);
|
||
sql.Format(_T("select count(id) from aec_package where idclass='%d'"), idFolder);
|
||
if (db.GetSelData(sql, sTmp))
|
||
{
|
||
if (TypeConvert::convert<int, LPCTSTR>(sTmp) > 0)
|
||
return true;
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
bool hasEquFilesInFolder(LPCTSTR pszDir)
|
||
{
|
||
std::vector<CString> vs;
|
||
CoreTools::getFilesInFolder(pszDir, _T("*.equ"), vs, false, true);
|
||
CoreTools::getFilesInFolder(pszDir, _T("*.r2p"), vs, false, true);
|
||
return !vs.empty();
|
||
}
|
||
|
||
void importTo(LPCTSTR pszDir
|
||
, CTreeCtrl &tree
|
||
, CUIISQLiteServer &db
|
||
, HTREEITEM hItem
|
||
, const CEquipmentLibraryDlg::EOPER &oper)
|
||
{
|
||
if (!pszDir) return;
|
||
if (!hasEquFilesInFolder(pszDir)) return;
|
||
|
||
CString sql(_T("")), sTbl(_T("aec"));
|
||
if (oper == CEquipmentLibraryDlg::eManaZhSb)
|
||
sTbl = _T("dwg");
|
||
|
||
std::vector<CString> v;
|
||
std::vector<CString>::const_reverse_iterator rit;
|
||
CoreTools::SplitString(pszDir, _T('\\'), v);
|
||
if (v.empty()) return;
|
||
CString sFolder(*v.rbegin()), sClassPath(_T(""));
|
||
if (sFolder.IsEmpty())
|
||
{
|
||
for (rit = v.rbegin(); rit != v.rend(); ++rit)
|
||
{
|
||
if (!rit->IsEmpty())
|
||
{
|
||
sFolder = *rit;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
int idFolder(-1);
|
||
std::vector<CString> files;
|
||
std::vector<CString> dirs;
|
||
if (isRootItem(tree, hItem))
|
||
{ // 如果选择的是根节点,则需要把第一个目录名当做Folder插入到数据库中
|
||
HTREEITEM h = findSubDir(tree, hItem, sFolder);
|
||
if (h)
|
||
{
|
||
idFolder = tree.GetItemData(h);
|
||
}
|
||
else
|
||
{
|
||
sql.Format(_T("insert into %s_folder (folder) values ('%s')"), sTbl, sFolder);
|
||
if (!db.ExecuteSQL(sql))
|
||
{
|
||
AfxMessageBox(_T("新建Folder失败!"));
|
||
return;
|
||
}
|
||
idFolder = getLastInserId(db, _T("aec_folder"));
|
||
h = tree.InsertItem(sFolder, 0, 2, hItem);
|
||
tree.SetItemData(h, idFolder);
|
||
}
|
||
// Folder 目录下面没有文件操作
|
||
dirs.clear();
|
||
CoreTools::getSubFolderByPath(pszDir, dirs, false);
|
||
for (size_t i = 0; i < dirs.size(); ++i)
|
||
{
|
||
importTo(dirs[i], tree, db, h, oper);
|
||
}
|
||
}
|
||
else
|
||
{ // 如果不是根目录,则只需要在hItem下面新建节点,并在 class 库内新建记录
|
||
HTREEITEM h = findSubDir(tree, hItem, sFolder);
|
||
if (!h)
|
||
{
|
||
h = tree.InsertItem(sFolder, 0, 2, hItem);
|
||
HTREEITEM hFolder = getParentFolder(tree, h);
|
||
idFolder = tree.GetItemData(hFolder);
|
||
sClassPath = getClassName(tree, h);
|
||
sql.Format(_T("insert into %s_class (class, idfolder) values('%s', '%d')")
|
||
, sTbl, sClassPath, idFolder);
|
||
if (!db.ExecuteSQL(sql))
|
||
{
|
||
tree.DeleteItem(h);
|
||
AfxMessageBox(_T("向aec_class插入数据失败!"));
|
||
return;
|
||
}
|
||
tree.SetItemData(h, getLastInserId(db, sTbl + _T("_class")));
|
||
}
|
||
|
||
sFolder = tree.GetItemText(getParentFolder(tree, h));
|
||
sClassPath = getClassName(tree, h);
|
||
|
||
int idClass = tree.GetItemData(h);
|
||
files.clear();
|
||
|
||
if (oper == CEquipmentLibraryDlg::eMana)
|
||
{
|
||
CoreTools::getFilesInFolder(pszDir, _T("*.equ"), files, false, false);
|
||
CoreTools::getFilesInFolder(pszDir, _T("*.r2p"), files, false, false);
|
||
}
|
||
else
|
||
{
|
||
CoreTools::getFilesInFolder(pszDir, _T("*.zhequ"), files, false, false);
|
||
}
|
||
|
||
for (size_t f = 0; f < files.size(); ++f)
|
||
{
|
||
CString &sPath(files[f]);
|
||
if (!putEquFileToDb(db, sPath, idClass, oper)) continue;
|
||
}
|
||
|
||
dirs.clear();
|
||
CoreTools::getSubFolderByPath(pszDir, dirs, false);
|
||
for (size_t i = 0; i < dirs.size(); ++i)
|
||
{
|
||
importTo(dirs[i], tree, db, h, oper);
|
||
}
|
||
}
|
||
}
|
||
|
||
void SetViewportDir(const AcGeVector3d &dir
|
||
, const AcGePoint3d &ptMax
|
||
, const AcGePoint3d &ptMin)
|
||
{
|
||
AcGePlane plan(AcGePoint3d::kOrigin, dir);
|
||
|
||
AcGePoint2d pt1 = ptMin.convert2d(plan);
|
||
AcGePoint2d pt2 = ptMax.convert2d(plan);
|
||
AcGePoint2d pt(CoreTools::MidPt(pt1, pt2));
|
||
|
||
|
||
AcDbViewTableRecord VTR;
|
||
VTR.setViewDirection(dir);
|
||
VTR.setCenterPoint(pt);
|
||
VTR.setWidth(abs(pt1.x - pt2.x));
|
||
VTR.setHeight(abs(pt1.y - pt2.y));
|
||
acedSetCurrentView(&VTR, NULL);
|
||
}
|
||
|
||
void SetVistualStyle(LPCTSTR pszVSName)
|
||
{
|
||
if (!pszVSName) return;
|
||
AcDbObjectId idVs(AcDbObjectId::kNull);
|
||
|
||
AcDbDatabase *pDb = acdbHostApplicationServices()->workingDatabase();
|
||
if (!pDb) return;
|
||
|
||
AcDbDictionary *pVsD = NULL;
|
||
if (pDb->getVisualStyleDictionary(pVsD, AcDb::kForRead) != Acad::eOk) return;
|
||
|
||
AcDbVisualStyle *pVs(NULL);
|
||
if (Acad::eOk == pVsD->getAt(pszVSName, (AcDbObject *&)pVs, AcDb::kForRead))
|
||
{
|
||
idVs = pVs->objectId();
|
||
pVs->close();
|
||
}
|
||
pVsD->close();
|
||
|
||
if (idVs.isValid())
|
||
acdbSetViewportVisualStyle(idVs);
|
||
}
|
||
|
||
bool SaveBitmapToFile(CBitmap *bitmap, AcDbBlockTableRecord::PreviewIcon &icon)
|
||
{
|
||
CString sPath(FilePath::getSystemTemporaryFolder() + _T("\\a_b_cc__.bmp"));
|
||
CImage img;
|
||
img.Attach(*bitmap);
|
||
HRESULT hr = img.Save(sPath);
|
||
img.Detach();
|
||
if (!FAILED(hr) && _taccess(sPath, 0x0) == 0x0)
|
||
{
|
||
CFile fi;
|
||
if (fi.Open(sPath, CFile::modeRead))
|
||
{
|
||
icon.setLogicalLength(fi.GetLength());
|
||
fi.Read(icon.asArrayPtr(), fi.GetLength());
|
||
}
|
||
}
|
||
return !icon.isEmpty();
|
||
}
|
||
|
||
HBITMAP PreviewIcon2Bitmap(const AcDbBlockTableRecord::PreviewIcon &icon)
|
||
{
|
||
CString sPath(FilePath::getSystemTemporaryFolder() + _T("\\a_v_v.bmp"));
|
||
CFile file(sPath, CFile::modeReadWrite | CFile::modeCreate);
|
||
if (file.m_hFile)
|
||
{
|
||
file.Write((void*)icon.asArrayPtr(), icon.length());
|
||
file.Close();
|
||
return (HBITMAP)::LoadImage(0, sPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
|
||
}
|
||
return NULL;
|
||
}
|
||
|
||
void ScreenCopy(const AcGePoint3d &wptTL, const AcGePoint3d &wptBR, AcDbBlockTableRecord::PreviewIcon &icon)
|
||
{
|
||
CView *pView = acedGetAcadDwgView();
|
||
if (!pView) return;
|
||
|
||
CDC *pDc = pView->GetDC();
|
||
if (!pDc) return;
|
||
|
||
CRect rect;
|
||
if (wptTL == wptBR)
|
||
pView->GetClientRect(rect);
|
||
else
|
||
rect.SetRect(CKTCadUtility::Wcs2Pixel(wptTL), CKTCadUtility::Wcs2Pixel(wptBR));
|
||
|
||
CBitmap bitmap;
|
||
bitmap.CreateCompatibleBitmap(pDc, rect.Width(), rect.Height());
|
||
|
||
CDC memDc;
|
||
memDc.CreateCompatibleDC(pDc);
|
||
CBitmap *pOldBitmap = memDc.SelectObject(&bitmap);
|
||
|
||
memDc.BitBlt(0
|
||
, 0
|
||
, rect.Width()
|
||
, rect.Height()
|
||
, pDc
|
||
, rect.left
|
||
, rect.top
|
||
, SRCCOPY);
|
||
|
||
CMemFile file;
|
||
SaveBitmapToFile(&bitmap, icon);
|
||
|
||
memDc.SelectObject(pOldBitmap);
|
||
memDc.DeleteDC();
|
||
|
||
::ReleaseDC(pView->GetSafeHwnd(), pDc->GetSafeHdc());
|
||
}
|
||
|
||
bool hasSameFileName(CListBox &list, LPCTSTR name)
|
||
{
|
||
CString s;
|
||
for (int i = 0; i < list.GetCount(); ++i)
|
||
{
|
||
list.GetText(i, s);
|
||
if (s == name)
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
void insertZHSB(CUIISQLiteServer &db, const int &fid)
|
||
{
|
||
ads_point adsPtIns;
|
||
if (acedGetPoint(NULL, _T("\n选择插入点:"), adsPtIns) != RTNORM) return;
|
||
AcGePoint3d ptIns(asPnt3d(adsPtIns));
|
||
CoreTools::UCS2WCS(ptIns, ptIns);
|
||
|
||
CString sBlkName = getZhSbNameFromDb(db, fid);
|
||
if (sBlkName.IsEmpty()) return;
|
||
|
||
AcDbObjectId blkId;
|
||
|
||
AcDbDatabase *pCurDb = acdbHostApplicationServices()->workingDatabase();
|
||
if (!pCurDb) return;
|
||
|
||
std::shared_ptr<AcDbDatabase> pDb = getZhSbFileFromDb(db, fid);
|
||
if (!pDb) return;
|
||
|
||
AcDbBlockTableRecordPointer pCurRcd(sBlkName, pCurDb, AcDb::kForRead);
|
||
if (pCurRcd.openStatus() != Acad::eOk)
|
||
{ // 不存在,插入
|
||
AecDbObjXDataMap xPipeInit;
|
||
// 如果当前图纸没有初始设置
|
||
if (!KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xPipeInit))
|
||
{
|
||
// 从 pDb 中读取,写入当前数据库
|
||
if (KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xPipeInit, pDb.get()))
|
||
KTModelLayoutXData::WriteModelXData(KT_PIPEINIT, xPipeInit);
|
||
}
|
||
|
||
AcDbBlockTableRecordPointer pNewRcd(ZH_SB_BLK_NAME, pDb.get(), AcDb::kForRead);
|
||
if (pNewRcd.openStatus() != Acad::eOk) return;
|
||
|
||
AcDbDatabase *pTempDb(NULL);
|
||
if (pDb->wblock(pTempDb, pNewRcd->id()) == Acad::eOk)
|
||
pCurDb->insert(blkId, sBlkName, pTempDb);
|
||
DELETE_PTR(pTempDb);
|
||
}
|
||
else
|
||
{ // 已经存在
|
||
blkId = pCurRcd->id();
|
||
pCurRcd->close();
|
||
}
|
||
|
||
if (!blkId.isValid()) return;
|
||
|
||
// 做块
|
||
AcDbBlockReference *pRef(new AcDbBlockReference(ptIns, blkId));
|
||
|
||
CString sZHSBName = sBlkName.Right(sBlkName.GetLength() - 1 - sBlkName.ReverseFind(_T('-')));
|
||
|
||
SH_BIM_BLOCK bims;
|
||
getBimsFromZhSbFile(pDb.get(), bims);
|
||
CoreTools::setBimDatas(pRef, bims);
|
||
CoreTools::setBimData(pRef, KEY_NAME, sZHSBName);
|
||
|
||
// 为块打上“组合设备”的标记
|
||
AecDbObjXDataMap map;
|
||
map.SetAt(ZH_SB_FLAG, TRUE);
|
||
map.SetAt(ZH_SB_NAME, sZHSBName);
|
||
map.Write(pRef, ZH_SB_REF_FIELD);
|
||
|
||
CoreTools::AddToModelSpace(pRef);
|
||
}
|
||
}
|
||
|
||
#pragma region CEquipmentLibraryDlg
|
||
#define _VALVE_ _T("阀")
|
||
IMPLEMENT_DYNAMIC(CEquipmentLibraryDlg, CDialog)
|
||
|
||
BEGIN_MESSAGE_MAP(CEquipmentLibraryDlg, CDialog)
|
||
ON_MESSAGE( WM_ACAD_KEEPFOCUS, &CEquipmentLibraryDlg::onAcadKeepFocus)
|
||
ON_BN_CLICKED(IDC_DIR_ADD, &CEquipmentLibraryDlg::OnBnClickedDirAdd)
|
||
ON_BN_CLICKED(IDC_DIR_MODI, &CEquipmentLibraryDlg::OnBnClickedDirRename)
|
||
ON_BN_CLICKED(IDC_DIR_DEL, &CEquipmentLibraryDlg::OnBnClickedDirDel)
|
||
ON_BN_CLICKED(IDC_DIR_OUT, &CEquipmentLibraryDlg::OnBnClickedDirOut)
|
||
ON_BN_CLICKED(IDC_DIR_IN, &CEquipmentLibraryDlg::OnBnClickedDirIn)
|
||
ON_BN_CLICKED(IDC_FILE_NEW, &CEquipmentLibraryDlg::OnBnClickedFileNew)
|
||
ON_BN_CLICKED(IDC_FILE_ADD, &CEquipmentLibraryDlg::OnBnClickedFileAdd)
|
||
ON_BN_CLICKED(IDC_FILE_COPY, &CEquipmentLibraryDlg::OnBnClickedFileCopy)
|
||
ON_BN_CLICKED(IDC_FILE_RENAME, &CEquipmentLibraryDlg::OnBnClickedFileRename)
|
||
ON_BN_CLICKED(IDC_FILE_DEL, &CEquipmentLibraryDlg::OnBnClickedFileDel)
|
||
ON_BN_CLICKED(IDC_FILE_OUT, &CEquipmentLibraryDlg::OnBnClickedFileOut)
|
||
ON_BN_CLICKED(IDC_BIM_ADD, &CEquipmentLibraryDlg::OnBnClickedBimAdd)
|
||
ON_BN_CLICKED(IDC_BIM_MODI, &CEquipmentLibraryDlg::OnBnClickedBimModi)
|
||
ON_BN_CLICKED(IDC_BIM_DEL, &CEquipmentLibraryDlg::OnBnClickedBimDel)
|
||
ON_BN_CLICKED(IDOK, &CEquipmentLibraryDlg::OnBnClickedOk)
|
||
ON_BN_CLICKED(IDC_INSERT, &CEquipmentLibraryDlg::OnBnClickedInsert)
|
||
ON_BN_CLICKED(IDC_CHECKLINEVLV, &CEquipmentLibraryDlg::OnCheckLineVlv)
|
||
ON_BN_CLICKED(IDC_CHECK_FANGLE, &CEquipmentLibraryDlg::OnCheckFlange)
|
||
ON_NOTIFY(TVN_SELCHANGED, IDC_DIR_TREE, &CEquipmentLibraryDlg::OnTvnSelchangedDirTree)
|
||
ON_LBN_SELCHANGE(IDC_FILE_LIST, &CEquipmentLibraryDlg::OnLbnSelchangeFileList)
|
||
ON_NOTIFY(NM_RCLICK, IDC_DIR_TREE, OnTvnRBClickDirTree)
|
||
ON_WM_CONTEXTMENU()
|
||
ON_CBN_SELCHANGE(IDC_COMB_DB_LIBRARY, &CEquipmentLibraryDlg::OnCbnSelchangeLibrary)
|
||
ON_BN_CLICKED(IDC_CHECK_SEARCH, &CEquipmentLibraryDlg::OnCheckSearch)
|
||
ON_EN_CHANGE(IDC_EDIT_SEARCH, &CEquipmentLibraryDlg::OnEnChangeSearch)
|
||
ON_LBN_DBLCLK(IDC_FILE_LIST, &CEquipmentLibraryDlg::OnLbnDblClkFileList)
|
||
END_MESSAGE_MAP()
|
||
|
||
CEquipmentLibraryDlg::CEquipmentLibraryDlg(EOPER oper
|
||
, LPCTSTR pszDir
|
||
, LPCTSTR pszFile
|
||
, bool bUIFangle
|
||
, bool bUI2DCheck
|
||
, CWnd* pParent)
|
||
: CDialog(CEquipmentLibraryDlg::IDD, pParent)
|
||
, m_hBitmap(NULL)
|
||
, m_eOper(oper)
|
||
, m_bSearch(FALSE)
|
||
, m_strDirAnchor(_T(""))
|
||
, m_strFileAnchor(_T(""))
|
||
, m_bUI_Fangle(bUIFangle)
|
||
, m_bUseFangle(false)
|
||
, m_bUI_2DFlag(bUI2DCheck)
|
||
, m_nValveType(0)
|
||
, m_bCheck2DFlag(false)
|
||
, m_iSelectFileID(-1)
|
||
{
|
||
if (pszDir)
|
||
m_strDirAnchor = pszDir;
|
||
if (pszFile)
|
||
m_strFileAnchor = pszFile;
|
||
|
||
if (m_bUI_Fangle)
|
||
m_bUseFangle = 1;
|
||
|
||
if (m_bUI_2DFlag)
|
||
{
|
||
m_bCheck2DFlag = 1;
|
||
}
|
||
}
|
||
|
||
CEquipmentLibraryDlg::~CEquipmentLibraryDlg()
|
||
{
|
||
if (m_hBitmap) ::DeleteObject(m_hBitmap);
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::DoDataExchange(CDataExchange* pDX)
|
||
{
|
||
CDialog::DoDataExchange(pDX);
|
||
DDX_Control(pDX, IDC_DIR_TREE, m_ctrlDirTree);
|
||
DDX_Control(pDX, IDC_FILE_LIST, m_ctrlFileList);
|
||
DDX_Control(pDX, IDC_BIM_LIST, m_ctrlBimList);
|
||
DDX_Control(pDX, IDC_COMB_DB_LIBRARY, m_cmbEquLib);
|
||
DDX_Control(pDX, IDC_EDIT_SEARCH, m_ctrlSearchEdt);
|
||
|
||
DDX_Control(pDX, IDC_STATIC_SEP, m_ctrlStaticSep);
|
||
DDX_Control(pDX, IDC_STATIC_DIR, m_ctrlStaticDir);
|
||
DDX_Control(pDX, IDC_STATIC_FILE, m_ctrlStaticFile);
|
||
|
||
DDX_Check(pDX, IDC_CHECK_FANGLE, m_bUseFangle);
|
||
DDX_Check(pDX, IDC_CHECKLINEVLV, m_bLineVlv);
|
||
DDX_Check(pDX, IDC_CHECK2DFLAG, m_bCheck2DFlag);
|
||
DDX_CBIndex(pDX, IDC_COMB_VALVE_TYPE, m_nValveType);
|
||
DDX_Check(pDX, IDC_CHECK_SEARCH, m_bSearch);
|
||
DDX_Text(pDX, IDC_EDIT_SEARCH, m_sSearch);
|
||
}
|
||
|
||
BOOL CEquipmentLibraryDlg::OnInitDialog()
|
||
{
|
||
CDialog::OnInitDialog();
|
||
|
||
initDbLibraryComb();
|
||
|
||
if (m_EquLibs.size() <= 1)
|
||
{
|
||
m_cmbEquLib.ShowWindow(SW_HIDE);
|
||
SHOWWINDOW(IDC_STATIC_DB_LIBRARY, SW_HIDE)
|
||
}
|
||
|
||
if (m_EquLibs.empty()
|
||
|| !m_sqlDB.InitADOServer(FilePath::GetSysDir() + _T("//") + m_EquLibs[0]))
|
||
{
|
||
AfxMessageBox(_T("打开数据库Aec3DMep.db失败!"));
|
||
EndDialog(-1);
|
||
return TRUE;
|
||
}
|
||
|
||
if (m_eOper == eManaZhSb)
|
||
{
|
||
SetWindowText(_T("组合设备管理 (双击插入)"));
|
||
CWnd *pWnd = GetDlgItem(IDC_INSERT);
|
||
if (pWnd)
|
||
pWnd->SetWindowText(_T("插入"));
|
||
}
|
||
|
||
m_nIdxEquLib = 0;
|
||
|
||
m_ctrlFileList.ResetContent();
|
||
|
||
initDirTree();
|
||
initFileList();
|
||
initBIMList();
|
||
initPreviewCtrl();
|
||
|
||
CWnd *pWnd(NULL);
|
||
// 插入设备模式下,所有按钮隐藏
|
||
if (m_eOper != eMana && m_eOper != eManaZhSb)
|
||
{
|
||
pWnd = GetDlgItem(IDOK);
|
||
if (pWnd) pWnd->SetWindowText(_T("插入"));
|
||
|
||
SHOWWINDOW(IDC_DIR_ADD, SW_HIDE)
|
||
SHOWWINDOW(IDC_DIR_MODI, SW_HIDE);
|
||
SHOWWINDOW(IDC_DIR_DEL, SW_HIDE);
|
||
SHOWWINDOW(IDC_DIR_OUT, SW_HIDE);
|
||
SHOWWINDOW(IDC_DIR_IN, SW_HIDE);
|
||
SHOWWINDOW(IDC_FILE_ADD, SW_HIDE);
|
||
SHOWWINDOW(IDC_FILE_COPY, SW_HIDE);
|
||
SHOWWINDOW(IDC_FILE_RENAME, SW_HIDE);
|
||
SHOWWINDOW(IDC_FILE_NEW, SW_HIDE);
|
||
SHOWWINDOW(IDC_FILE_DEL, SW_HIDE);
|
||
SHOWWINDOW(IDC_FILE_OUT, SW_HIDE);
|
||
SHOWWINDOW(IDC_BIM_ADD, SW_HIDE);
|
||
SHOWWINDOW(IDC_BIM_MODI, SW_HIDE);
|
||
SHOWWINDOW(IDC_BIM_DEL, SW_HIDE);
|
||
}
|
||
else if (m_eOper == eMana)
|
||
SHOWWINDOW(IDC_FILE_NEW, SW_HIDE);
|
||
|
||
if (m_eOper == eManaZhSb)
|
||
{
|
||
SHOWWINDOW(IDC_PREVIEW_PIC, SW_HIDE);
|
||
}
|
||
|
||
|
||
if (m_bUI_Fangle)
|
||
{
|
||
SHOWWINDOW(IDC_CHECK_FANGLE, SW_SHOW);
|
||
m_bUseFangle = 1;
|
||
|
||
SHOWWINDOW(IDC_CHECKLINEVLV, SW_SHOW);
|
||
m_bLineVlv = 0;
|
||
}
|
||
|
||
if (m_bUI_2DFlag)
|
||
{
|
||
SHOWWINDOW(IDC_CHECK2DFLAG, SW_SHOW);
|
||
m_bCheck2DFlag = 1;
|
||
SHOWWINDOW(IDC_COMB_VALVE_TYPE, SW_SHOW);
|
||
m_nValveType = 0;
|
||
}
|
||
|
||
m_ctrlSearchEdt.EnableWindow(m_bSearch);
|
||
|
||
UpdateData(FALSE);
|
||
|
||
if (m_bSearch && !m_sSearch.IsEmpty())
|
||
{ // 开始就进入搜索模式
|
||
OnCheckSearch();
|
||
OnEnChangeSearch();
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL CEquipmentLibraryDlg::DestroyWindow()
|
||
{
|
||
g_result.clear();
|
||
return CDialog::DestroyWindow();
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::initDbLibraryComb()
|
||
{
|
||
SH_BIM_BLOCK content;
|
||
IniTools::getSectionContent(FilePath::GetSysDir() + _T("\\product.ini")
|
||
, _T("EquLib")
|
||
, content);
|
||
|
||
m_EquLibs.clear();
|
||
m_cmbEquLib.Clear();
|
||
SH_BIM_BLOCK::const_iterator it(content.begin());
|
||
for (; it != content.end(); ++it)
|
||
{
|
||
m_cmbEquLib.AddString(it->first);
|
||
m_EquLibs.push_back(it->second);
|
||
}
|
||
|
||
if (m_cmbEquLib.GetCount() <= 0)
|
||
m_cmbEquLib.AddString(_T("默认设备库"));
|
||
|
||
m_cmbEquLib.SetCurSel(0);
|
||
|
||
if (m_EquLibs.empty())
|
||
m_EquLibs.push_back(_T("Aec3DMep.db"));
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::initDirTree()
|
||
{
|
||
// 为树控件初始化图像列表
|
||
{
|
||
CBitmap bmp;
|
||
if (!bmp.LoadBitmap(IDB_BITMAPDIR))
|
||
{
|
||
AfxMessageBox(_T("Can't load bitmap: %x\n"), IDB_BITMAPPRIV);
|
||
ASSERT(FALSE);
|
||
return;
|
||
}
|
||
BITMAP bmpObj;
|
||
bmp.GetBitmap(&bmpObj);
|
||
UINT nFlags = ILC_COLOR24 | ILC_MASK;
|
||
m_imageList.Create(16, bmpObj.bmHeight, nFlags, 0, 0);
|
||
m_imageList.Add(&bmp, RGB(255, 0, 0));
|
||
//m_ctrlDirTree.SetImageList(&m_imageList, TVSIL_NORMAL);
|
||
}
|
||
|
||
initTree(m_ctrlDirTree, m_imageList, m_sqlDB, m_eOper);
|
||
|
||
anchorDir();
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::initFileList()
|
||
{
|
||
// m_imgList.Create(32, 32, ILC_COLOR32 | ILC_MASK, 5, 1);
|
||
// m_ctrlFileList.SetImageList(&m_imageList);
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::initBIMList()
|
||
{
|
||
m_ctrlBimList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_SINGLEROW);
|
||
m_ctrlBimList.InsertColumn(0, _T("名称"), LVCFMT_LEFT, 150);
|
||
m_ctrlBimList.InsertColumn(1, _T("属性"), LVCFMT_LEFT, 150);
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::initPreviewCtrl()
|
||
{
|
||
if (m_eOper != eManaZhSb && m_eOper != eInsZhSb)
|
||
{
|
||
m_wndViewCtrl.SubclassDlgItem(IDC_PREVIEW_PIC, this);
|
||
}
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::refreshFileList(HTREEITEM hItem)
|
||
{
|
||
m_ctrlFileList.ResetContent();
|
||
if (!hItem) return;
|
||
|
||
// 判断点中的是不Class目录
|
||
if (isRootItem(hItem)) return;
|
||
if (isFolderItem(hItem)) return;
|
||
|
||
CString sql(_T(""));
|
||
std::vector<std::vector<CString>> files;
|
||
|
||
|
||
int idFolder = m_ctrlDirTree.GetItemData(hItem);
|
||
if (m_eOper == eSel)
|
||
{
|
||
int iPos(m_strDirAnchor.Find(_T("阀\\")));
|
||
if (iPos != -1) // 插入阀门
|
||
{
|
||
iPos = m_strDirAnchor.Find(_T("\\"));
|
||
CString sValve(m_strDirAnchor.Right(m_strDirAnchor.GetLength() - iPos - 1)),
|
||
sDN(m_strFileAnchor);
|
||
sql.Format(_T("select [id], [name] from [aec_package] where [name] like'%%%s%%' ")
|
||
_T("and [IDClass] in (select [id] from [aec_class] where [class] like '%%%s%%')")
|
||
, sDN, sValve);
|
||
}
|
||
else // 插入其他设备
|
||
{
|
||
sql.Format(_T("select id, name from aec_package where idclass='%d'"), idFolder);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (m_eOper == eMana || m_eOper == eIns)
|
||
sql.Format(_T("select id, name from aec_package where idclass='%d'"), idFolder);
|
||
else if (m_eOper == eManaZhSb || m_eOper == eInsZhSb)
|
||
sql.Format(_T("select id, name from dwg_package where idclass='%d'"), idFolder);
|
||
}
|
||
|
||
m_sqlDB.GetSelDataEx(sql, files);
|
||
int idx(-1);
|
||
bool bAnchorFile(!m_strFileAnchor.IsEmpty());
|
||
for (size_t i = 0; i < files.size(); ++i)
|
||
{
|
||
std::vector<CString> &v(files[i]);
|
||
if (v.size() < 2) continue;
|
||
|
||
if (bAnchorFile)
|
||
{
|
||
if (!checkFileName(v[1], m_strFileAnchor))
|
||
continue;
|
||
}
|
||
|
||
idx = m_ctrlFileList.AddString(v[1]);
|
||
if (idx != -1)
|
||
m_ctrlFileList.SetItemData(idx, TypeConvert::convert<int, LPCTSTR>(v[0]));
|
||
|
||
}
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::refreshBimList(int idx)
|
||
{
|
||
if (idx == -1) return;
|
||
|
||
int fid = m_ctrlFileList.GetItemData(idx);
|
||
m_ctrlBimList.DeleteAllItems();
|
||
int nRow(0);
|
||
if (m_eOper != eManaZhSb)
|
||
{
|
||
std::vector<std::vector<CString>> bims;
|
||
CString Sql(_T(""));
|
||
Sql.Format(_T("select id, name, value from aec_bims where equid=%d"), fid);
|
||
m_sqlDB.GetSelDataEx(Sql, bims);
|
||
for (size_t i = 0; i < bims.size(); ++i)
|
||
{
|
||
std::vector<CString> &v(bims[i]);
|
||
if (v.size() < 3) continue;
|
||
nRow = m_ctrlBimList.InsertItem(nRow, v[1]);
|
||
m_ctrlBimList.SetItemText(nRow, 1, v[2]);
|
||
m_ctrlBimList.SetItemData(nRow, TypeConvert::convert<int, LPCTSTR>(v[0]));
|
||
nRow++;
|
||
}
|
||
}
|
||
else if (m_eOper == eManaZhSb)
|
||
{
|
||
SH_BIM_BLOCK blk;
|
||
getBimsFromZhSbId(m_sqlDB, fid, blk);
|
||
for (size_t i(0); i < blk.size(); ++i)
|
||
{
|
||
SH_BIM_REC &rec(blk[i]);
|
||
nRow = m_ctrlBimList.InsertItem(nRow, rec.first);
|
||
m_ctrlBimList.SetItemText(nRow, 1, rec.second);
|
||
++nRow;
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::getBimDatasByList(std::map<CString, CString> &bims)
|
||
{
|
||
for (int i = 0; i < m_ctrlBimList.GetItemCount(); ++i)
|
||
{
|
||
bims.insert(std::make_pair(m_ctrlBimList.GetItemText(i, 0), m_ctrlBimList.GetItemText(i, 1)));
|
||
}
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::getSelectedFiles(std::vector<int>& files)
|
||
{
|
||
for (int i = 0; i < m_ctrlFileList.GetCount(); ++i)
|
||
{
|
||
if (m_ctrlFileList.GetSel(i) > 0)
|
||
{
|
||
files.push_back(i);
|
||
}
|
||
}
|
||
}
|
||
|
||
bool CEquipmentLibraryDlg::isFolderItem(HTREEITEM hItem)
|
||
{
|
||
return ::isFolderItem(m_ctrlDirTree, hItem);
|
||
}
|
||
|
||
bool CEquipmentLibraryDlg::isRootItem(HTREEITEM hItem)
|
||
{
|
||
return ::isRootItem(m_ctrlDirTree, hItem);
|
||
}
|
||
|
||
bool CEquipmentLibraryDlg::isClassItem(HTREEITEM hItem)
|
||
{
|
||
return ::isClassItem(m_ctrlDirTree, hItem);
|
||
}
|
||
|
||
HTREEITEM CEquipmentLibraryDlg::getParentFolder(const HTREEITEM &hItem)
|
||
{
|
||
return ::getParentFolder(m_ctrlDirTree, hItem);
|
||
}
|
||
|
||
CString CEquipmentLibraryDlg::getClassName(const HTREEITEM & hItem)
|
||
{
|
||
return ::getClassName(m_ctrlDirTree, hItem);
|
||
}
|
||
|
||
CString CEquipmentLibraryDlg::getEquLibraryName()
|
||
{
|
||
int idx = m_cmbEquLib.GetCurSel();
|
||
if (idx <= 0 || idx >= m_EquLibs.size())
|
||
return _T("Aec3DMep.db");
|
||
return m_EquLibs[idx];
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::anchorDir()
|
||
{
|
||
if (m_strDirAnchor.IsEmpty()) return;
|
||
|
||
m_strDirAnchor.TrimLeft(_T('\\'));
|
||
std::vector<CString> dirs;
|
||
CoreTools::SplitString(m_strDirAnchor, _T('\\'), dirs);
|
||
HTREEITEM hRoot = m_ctrlDirTree.GetRootItem();
|
||
for (size_t i = 0; i < dirs.size(); ++i)
|
||
{
|
||
HTREEITEM h = findSubDir(m_ctrlDirTree, hRoot, dirs[i]);
|
||
if (!h) break;
|
||
hRoot = h;
|
||
m_ctrlDirTree.SelectItem(h);
|
||
m_ctrlDirTree.Expand(h, TVE_EXPAND);
|
||
}
|
||
}
|
||
|
||
LONG_PTR CEquipmentLibraryDlg::onAcadKeepFocus(UINT_PTR, LONG_PTR)
|
||
{
|
||
POINT pt;
|
||
::GetCursorPos(&pt);
|
||
CRect rect;
|
||
GetWindowRect(&rect);
|
||
if (!(rect.PtInRect(pt)))
|
||
{
|
||
return FALSE;
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnBnClickedDirAdd()
|
||
{
|
||
HTREEITEM hRoot(m_ctrlDirTree.GetRootItem());
|
||
HTREEITEM hItem = m_ctrlDirTree.GetSelectedItem();
|
||
if (!hItem)
|
||
{
|
||
AfxMessageBox(_T("请选中一个目录!"));
|
||
return;
|
||
}
|
||
|
||
CString sName(_T("")), sTmp(_T(""));
|
||
if (!CoreTools::getNameByDialog(_T("输入目录名称"), _T("目录名称"), sTmp)) return;
|
||
if (sTmp.Find(_T('\\')) != -1)
|
||
{
|
||
AfxMessageBox(_T("目录名称中不能存在字符“\\”!"));
|
||
return;
|
||
}
|
||
|
||
HTREEITEM h = findSubDir(m_ctrlDirTree, hItem, sTmp);
|
||
if (h)
|
||
{
|
||
AfxMessageBox(_T("目录已经存在!"));
|
||
return;
|
||
}
|
||
|
||
|
||
CString sTbl(_T("aec")), sql(_T("")), sId(_T(""));
|
||
if (m_eOper == eManaZhSb)
|
||
sTbl = _T("dwg");
|
||
|
||
HTREEITEM hNew(NULL);
|
||
if (isRootItem(hItem)) // 添加 folder
|
||
{
|
||
|
||
sql.Format(_T("insert into %s_folder (folder) values ('%s')"), sTbl, sTmp);
|
||
if (m_sqlDB.ExecuteSQL(sql))
|
||
{
|
||
hNew = m_ctrlDirTree.InsertItem(sTmp, 0, 2, hItem);
|
||
m_ctrlDirTree.SetItemData(hNew, getLastInserId(m_sqlDB, sTbl + _T("_folder")));
|
||
m_ctrlDirTree.Expand(hItem, TVE_EXPAND);
|
||
}
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
CString sClass = getClassName(hItem);
|
||
if (!sClass.IsEmpty())
|
||
sClass += _T("\\");
|
||
sClass += sTmp;
|
||
|
||
HTREEITEM hParent = getParentFolder(hItem);
|
||
int idFolder = m_ctrlDirTree.GetItemData(hParent);
|
||
|
||
sql.Format(_T("insert into %s_class(class, idfolder) values ('%s', '%d')"), sTbl, sClass, idFolder);
|
||
if (m_sqlDB.ExecuteSQL(sql))
|
||
{
|
||
hNew = m_ctrlDirTree.InsertItem(sTmp, 0, 2, hItem);
|
||
m_ctrlDirTree.SetItemData(hNew, getLastInserId(m_sqlDB, sTbl + _T("_class")));
|
||
m_ctrlDirTree.Expand(hItem, TVE_EXPAND);
|
||
}
|
||
return;
|
||
}
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnBnClickedDirRename()
|
||
{
|
||
HTREEITEM hItem = m_ctrlDirTree.GetSelectedItem();
|
||
if (!hItem)
|
||
{
|
||
AfxMessageBox(_T("请选中一个目录!"));
|
||
return;
|
||
}
|
||
|
||
if (isRootItem(hItem))
|
||
{
|
||
AfxMessageBox(_T("不能修改根目录名称!"));
|
||
return;
|
||
}
|
||
|
||
if (isFolderItem(hItem))
|
||
{
|
||
CString sItem = m_ctrlDirTree.GetItemText(hItem);
|
||
if (sItem == _VALVE_)
|
||
{
|
||
AfxMessageBox(_T("不能修改“阀”目录名称!"));
|
||
return;
|
||
}
|
||
}
|
||
|
||
CString sTmp(m_ctrlDirTree.GetItemText(hItem));
|
||
if (!CoreTools::getNameByDialog(_T("输入目录新名称"), _T("目录新名称"), sTmp)) return;
|
||
|
||
|
||
if (sTmp.Find(_T('\\')) != -1)
|
||
{
|
||
AfxMessageBox(_T("目录名称中不能存在字符“\\”!"));
|
||
return;
|
||
}
|
||
|
||
HTREEITEM hParent = m_ctrlDirTree.GetParentItem(hItem);
|
||
HTREEITEM h = findSubDir(m_ctrlDirTree, hParent, sTmp);
|
||
if (h)
|
||
{
|
||
AfxMessageBox(_T("目录已经存在!"));
|
||
return;
|
||
}
|
||
|
||
int idFolder = m_ctrlDirTree.GetItemData(hItem);
|
||
CString sql(_T("")), str(_T("")), sItemName(m_ctrlDirTree.GetItemText(hItem)), sTbl(_T("aec"));
|
||
if (m_eOper == eManaZhSb)
|
||
sTbl = _T("dwg");
|
||
|
||
if (isFolderItem(hItem))
|
||
{
|
||
sql.Format(_T("update %s_folder set folder='%s' where id='%d'"), sTbl, sTmp, idFolder);
|
||
if (m_sqlDB.ExecuteSQL(sql))
|
||
{
|
||
m_ctrlDirTree.SetItemText(hItem, sTmp);
|
||
m_ctrlDirTree.Invalidate();
|
||
return;
|
||
}
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
// 首先把自己的一行记录修改
|
||
// 先判断一下自己的目录名称在目录串是第几个位置
|
||
sql.Format(_T("select class from %s_class where id='%d'"), sTbl, idFolder);
|
||
if (!m_sqlDB.GetSelData(sql, str)) return;
|
||
|
||
std::vector<CString> v;
|
||
CoreTools::SplitString(str, _T('\\'), v);
|
||
if (v.empty()) return;
|
||
|
||
std::vector<CString>::iterator it = std::find(v.begin(), v.end(), sItemName);
|
||
if (it == v.end()) return;
|
||
int dist = std::distance(v.begin(), it);
|
||
|
||
std::vector<HTREEITEM> items;
|
||
items.push_back(hItem);
|
||
getAllChildrenItem(m_ctrlDirTree, hItem, items);
|
||
|
||
std::vector<CString> vv;
|
||
int idSub(-1);
|
||
BOOL bSuccess(false);
|
||
for (size_t i = 0; i < items.size(); ++i)
|
||
{
|
||
vv.clear();
|
||
idSub = m_ctrlDirTree.GetItemData(items[i]);
|
||
sql.Format(_T("select class from %s_class where id='%d'"), sTbl, idSub);
|
||
if (!m_sqlDB.GetSelData(sql, str)) continue;
|
||
CoreTools::SplitString(str, _T('\\'), vv);
|
||
if (vv.size() <= dist) continue;
|
||
str.Empty();
|
||
vv[dist] = sTmp;
|
||
for (size_t j = 0; j < vv.size(); ++j)
|
||
{
|
||
str += vv[j];
|
||
str += _T("\\");
|
||
}
|
||
str = str.Left(str.GetLength() - 1);
|
||
sql.Format(_T("update %s_class set class = '%s' where id='%d'"), sTbl, str, idSub);
|
||
bSuccess = m_sqlDB.ExecuteSQL(sql);
|
||
}
|
||
if (bSuccess)
|
||
{
|
||
m_ctrlDirTree.SetItemText(hItem, sTmp);
|
||
m_ctrlDirTree.Invalidate();
|
||
}
|
||
|
||
return;
|
||
}
|
||
}
|
||
|
||
bool PermissionDel()
|
||
{
|
||
#ifdef NDEBUG
|
||
//集团版本,需要许可密码
|
||
if (CoreTools::encryptionType() == 1)
|
||
{
|
||
CXKMMDlg dlg;
|
||
if (IDOK == dlg.DoModal())
|
||
{
|
||
return true;
|
||
}
|
||
else
|
||
return false;
|
||
}
|
||
#endif
|
||
return true;
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnBnClickedDirDel()
|
||
{
|
||
|
||
HTREEITEM hItem = m_ctrlDirTree.GetSelectedItem();
|
||
if (!hItem)
|
||
{
|
||
AfxMessageBox(_T("请选中一个目录!"));
|
||
return;
|
||
}
|
||
if (isRootItem(hItem))
|
||
{
|
||
AfxMessageBox(_T("不能删除根目录!"));
|
||
return;
|
||
}
|
||
|
||
if (m_ctrlDirTree.ItemHasChildren(hItem))
|
||
{
|
||
AfxMessageBox(_T("此目录下还有子目录,请先删除子目录!"));
|
||
return;
|
||
}
|
||
|
||
if (isFolderItem(hItem))
|
||
{
|
||
CString sItem = m_ctrlDirTree.GetItemText(hItem);
|
||
if (sItem == _VALVE_)
|
||
{
|
||
AfxMessageBox(_T("不能删除“阀”目录!"));
|
||
return;
|
||
}
|
||
}
|
||
|
||
CString sTbl(_T("aec")), sql(_T(""));
|
||
if (m_eOper == eManaZhSb)
|
||
sTbl = _T("dwg");
|
||
|
||
int idFolder = m_ctrlDirTree.GetItemData(hItem);
|
||
if (isClassItem(hItem))
|
||
{
|
||
|
||
CString sTmp(_T(""));
|
||
sql.Format(_T("select count(id) from %s_package where idclass='%d'"), sTbl, idFolder);
|
||
if (m_sqlDB.GetSelData(sql, sTmp))
|
||
{
|
||
if (TypeConvert::convert<int, LPCTSTR>(sTmp) > 0)
|
||
{
|
||
AfxMessageBox(_T("此目录下还有文件,请先删除子目录下的文件!"));
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
return;
|
||
|
||
if (AfxMessageBox(_T("是否删除?此操作不可逆!"), MB_YESNO) != IDYES)
|
||
return;
|
||
|
||
if (!PermissionDel())
|
||
{
|
||
return;
|
||
}
|
||
|
||
sql.Format(_T("delete from %s_class where id='%d'"), sTbl, idFolder);
|
||
if (m_sqlDB.ExecuteSQL(sql))
|
||
{
|
||
m_ctrlDirTree.DeleteItem(hItem);
|
||
m_ctrlDirTree.Invalidate();
|
||
}
|
||
}
|
||
|
||
if (isFolderItem(hItem))
|
||
{
|
||
// 先删除数据库中内容
|
||
if (AfxMessageBox(_T("是否删除?此操作不可逆!"), MB_YESNO) != IDYES)
|
||
return;
|
||
sql.Format(_T("delete from %s_folder where id='%d'"), sTbl, idFolder);
|
||
if (m_sqlDB.ExecuteSQL(sql))
|
||
{
|
||
m_ctrlDirTree.DeleteItem(hItem);
|
||
m_ctrlDirTree.Invalidate();
|
||
}
|
||
|
||
return;
|
||
}
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnBnClickedDirOut()
|
||
{
|
||
HTREEITEM hRoot = m_ctrlDirTree.GetSelectedItem();
|
||
if (!hRoot)
|
||
{
|
||
AfxMessageBox(_T("请选中一个目录!"));
|
||
return;
|
||
}
|
||
bool bRootItem(isRootItem(hRoot));
|
||
|
||
CString sPath(_T(""));
|
||
if (!selectPath(_T("请选择文件要保存的目录"), sPath))
|
||
return;
|
||
|
||
// 先建好目录
|
||
makeDir(m_ctrlDirTree, hRoot, sPath);
|
||
sPath += m_ctrlDirTree.GetItemText(hRoot);
|
||
|
||
std::vector<HTREEITEM> items;
|
||
items.push_back(hRoot);
|
||
getAllChildrenItem(m_ctrlDirTree, hRoot, items);
|
||
|
||
CString sRoot(_T(""));
|
||
if (isClassItem(hRoot))
|
||
sRoot = getClassName(hRoot);
|
||
|
||
CString sFullPath(_T(""))
|
||
, sql(_T(""))
|
||
, sTmp(_T(""))
|
||
, sClassPath(_T(""))
|
||
, sFolderName(_T(""))
|
||
, sFileSuffix(_T(".equ"))
|
||
, sTbl(_T("aec"));
|
||
|
||
if (m_eOper == eManaZhSb)
|
||
{
|
||
sTbl = _T("dwg");
|
||
sFileSuffix = _T(".zhequ");
|
||
}
|
||
|
||
int classId(-1);
|
||
static int _idx(0);
|
||
std::map<CString, CString> mm;
|
||
std::map<CString, CString>::const_iterator it;
|
||
for (size_t i = 0; i < items.size(); ++i)
|
||
{
|
||
HTREEITEM h(items[i]);
|
||
if (!isClassItem(h)) continue;
|
||
|
||
sClassPath = getClassName(h);
|
||
sClassPath.Replace(sRoot, _T(""));
|
||
|
||
if (bRootItem)
|
||
{
|
||
sFolderName = m_ctrlDirTree.GetItemText(getParentFolder(h));
|
||
sFullPath.Format(_T("%s\\%s\\%s\\"), sPath, sFolderName, sClassPath);
|
||
}
|
||
else
|
||
{
|
||
sFullPath.Format(_T("%s\\%s\\"), sPath, sClassPath);
|
||
}
|
||
|
||
mm.clear();
|
||
classId = m_ctrlDirTree.GetItemData(h);
|
||
sql.Format(_T("select id, name from %s_package where idclass='%d'"), sTbl, classId);
|
||
m_sqlDB.GetSelData(sql, mm);
|
||
if (mm.empty()) continue;
|
||
|
||
CString sName(_T(""));
|
||
for (it = mm.begin(); it != mm.end(); ++it)
|
||
{
|
||
_idx = 0;
|
||
AecDbEwEquipment *pEqu = makeEqu(m_sqlDB, TypeConvert::convert<int, LPCTSTR>(it->first));
|
||
if (pEqu)
|
||
{
|
||
sName = checkFileName(it->second);
|
||
sTmp = sFullPath + sName + sFileSuffix;
|
||
while (_taccess(sTmp, 0x0) == 0x0)
|
||
{
|
||
sTmp.Format(_T("%s%s%d%s"), sFullPath, it->second, ++_idx, sFileSuffix);
|
||
}
|
||
CoreTools::equipment2File(pEqu, sTmp, it->second);
|
||
DELETE_PTR(pEqu);
|
||
}
|
||
}
|
||
}
|
||
AfxMessageBox(_T("导出完毕。"));
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnBnClickedDirIn()
|
||
{
|
||
HTREEITEM hItem = m_ctrlDirTree.GetSelectedItem();
|
||
if (!hItem)
|
||
{
|
||
AfxMessageBox(_T("请选中一个目录!"));
|
||
return;
|
||
}
|
||
|
||
CString sPath(_T(""));
|
||
if (!selectPath(_T("请选择一个要导入的目录"), sPath))
|
||
return;
|
||
|
||
importTo(sPath + _T("\\"), m_ctrlDirTree, m_sqlDB, hItem, m_eOper);
|
||
|
||
AfxMessageBox(_T("导入完毕。"));
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnBnClickedFileAdd()
|
||
{
|
||
HTREEITEM hItem = m_ctrlDirTree.GetSelectedItem();
|
||
if (!hItem)
|
||
{
|
||
AfxMessageBox(_T("请选中一个目录!"));
|
||
return;
|
||
}
|
||
|
||
if (!isClassItem(hItem))
|
||
{
|
||
AfxMessageBox(_T("不能在根目录或一级目录下保存文件,请选择一个二级目录!"));
|
||
return;
|
||
}
|
||
|
||
CString s(_T("上华设备文件(*.equ,*.r2p)|*.equ;*.r2p||"));
|
||
if (m_eOper == eManaZhSb)
|
||
s = _T("上华设备文件(*.zhequ)|*.zhequ||");
|
||
|
||
CFileDialog fileDlg(TRUE
|
||
, NULL
|
||
, NULL
|
||
, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_ALLOWMULTISELECT
|
||
, s);
|
||
|
||
fileDlg.m_ofn.nMaxFile = 4096;
|
||
fileDlg.m_ofn.lpstrFile = new TCHAR[fileDlg.m_ofn.nMaxFile];
|
||
::memset(fileDlg.m_ofn.lpstrFile, 0, sizeof(TCHAR) * fileDlg.m_ofn.nMaxFile);
|
||
|
||
if (fileDlg.DoModal() != IDOK) return;
|
||
|
||
HTREEITEM hFolder = getParentFolder(hItem);
|
||
if (!hFolder || !isFolderItem(hFolder)) return;
|
||
|
||
CString sPath(_T(""));
|
||
int idxClass = m_ctrlDirTree.GetItemData(hItem);
|
||
|
||
POSITION pos = fileDlg.GetStartPosition();
|
||
while (pos != NULL)
|
||
{
|
||
sPath = fileDlg.GetNextPathName(pos);
|
||
putEquFileToDb(m_sqlDB, sPath, idxClass, m_eOper);
|
||
}
|
||
|
||
delete[] fileDlg.m_ofn.lpstrFile;
|
||
|
||
refreshFileList(hItem);
|
||
|
||
AfxMessageBox(_T("导入完毕。"));
|
||
|
||
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnBnClickedFileCopy()
|
||
{
|
||
HTREEITEM hItem = m_ctrlDirTree.GetSelectedItem();
|
||
if (!hItem)
|
||
{
|
||
AfxMessageBox(_T("请选中一个目录!"));
|
||
return;
|
||
}
|
||
|
||
std::vector<int> files;
|
||
getSelectedFiles(files);
|
||
if (files.empty())
|
||
{
|
||
AfxMessageBox(_T("请至少选择一个文件!"));
|
||
return;
|
||
}
|
||
|
||
CEquLibCopyTreeDlg dlg(m_imageList, m_sqlDB, m_eOper, this);
|
||
if (dlg.DoModal() != IDOK) return;
|
||
|
||
int newID;
|
||
int classId = dlg.getClassId();
|
||
CString sql(_T("")), str(_T("")), sTbl(m_eOper == eManaZhSb ? _T("dwg") : _T("aec"));
|
||
std::vector<std::vector<CString>> mm;
|
||
m_sqlDB.BeginTrans();
|
||
for (size_t i = 0; i < files.size(); ++i)
|
||
{
|
||
int fileId = m_ctrlFileList.GetItemData(files[i]);
|
||
|
||
sql.Format(_T("insert into %s_package (name, idclass, rem, package) ")
|
||
_T("select name, idclass, rem, package from %s_package where id = '%d'"), sTbl, sTbl, fileId);
|
||
if (!m_sqlDB.ExecuteSQL(sql)) continue;
|
||
|
||
newID = getLastInserId(m_sqlDB, sTbl + _T("_package"));
|
||
sql.Format(_T("update %s_package set idclass = '%d' where id = '%d'")
|
||
, sTbl
|
||
, classId
|
||
, newID);
|
||
if (!m_sqlDB.ExecuteSQL(sql)) continue;
|
||
|
||
if (m_eOper == eMana)
|
||
{
|
||
mm.clear();
|
||
sql.Format(_T("select Name, Value from aec_Bims where EquID='%d'"), fileId);
|
||
m_sqlDB.GetSelDataEx(sql, mm);
|
||
for (int i(0); i != mm.size(); ++i)
|
||
{
|
||
if (mm[i].size() < 2) continue;
|
||
sql.Format(_T("insert into aec_Bims (Name, Value, EquID, ReadOnly) values ('%s','%s','%d','0')")
|
||
, mm[i][0]
|
||
, mm[i][1]
|
||
, newID);
|
||
m_sqlDB.ExecuteSQL(sql);
|
||
}
|
||
}
|
||
else if (m_eOper == eManaZhSb)
|
||
{
|
||
// 不需要处理bim,直接保存在了dwg文件里面
|
||
}
|
||
}
|
||
m_sqlDB.CommitTrans();
|
||
refreshFileList(hItem);
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnBnClickedFileAnchor()
|
||
{
|
||
std::vector<int> files;
|
||
getSelectedFiles(files);
|
||
if (files.size() != 1) return;
|
||
|
||
CString path;
|
||
m_ctrlFileList.GetText(files[0], path);
|
||
|
||
std::vector<CString> items;
|
||
CoreTools::SplitString(path, _T("\\"), items);
|
||
|
||
if (items.size() < 1) return;
|
||
|
||
HTREEITEM hParent(m_ctrlDirTree.GetRootItem());
|
||
for (size_t i(0); i < items.size() - 1; ++i)
|
||
{
|
||
hParent = FindTreeItem(&m_ctrlDirTree, hParent, items[i]);
|
||
}
|
||
|
||
if (!hParent) return;
|
||
|
||
m_bSearch = FALSE;
|
||
UpdateData(FALSE);
|
||
|
||
OnCheckSearch();
|
||
|
||
m_ctrlDirTree.Select(hParent, TVGN_CARET);
|
||
|
||
int idx = m_ctrlFileList.FindString(0, *items.rbegin());
|
||
if (idx != -1)
|
||
m_ctrlFileList.SetSel(idx);
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnBnClickedFileRename()
|
||
{
|
||
HTREEITEM hRoot = m_ctrlDirTree.GetSelectedItem();
|
||
if (!hRoot)
|
||
{
|
||
AfxMessageBox(_T("请选中一个目录!"));
|
||
return;
|
||
}
|
||
|
||
std::vector<int> files;
|
||
getSelectedFiles(files);
|
||
if (files.size() != 1)
|
||
{
|
||
AfxMessageBox(_T("请选择单个文件!"));
|
||
return;
|
||
}
|
||
|
||
int idx = files[0];
|
||
|
||
CString sTmp(_T("")), sql(_T("")), sTbl(m_eOper == eManaZhSb ? _T("dwg") : _T("aec"));
|
||
m_ctrlFileList.GetText(idx, sTmp);
|
||
int fileId = m_ctrlFileList.GetItemData(idx);
|
||
if (!CoreTools::getNameByDialog(_T("输入文件新名称"), _T("文件新名称"), sTmp)) return;
|
||
|
||
if (hasSameFileName(m_ctrlFileList, sTmp))
|
||
{
|
||
AfxMessageBox(_T("存在相同的文件名称!"));
|
||
return;
|
||
}
|
||
|
||
sql.Format(_T("update %s_package set name='%s' where id='%d'"), sTbl, sTmp, fileId);
|
||
|
||
if (m_sqlDB.ExecuteSQL(sql))
|
||
refreshFileList(hRoot);
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnBnClickedFileDel()
|
||
{
|
||
if (AfxMessageBox(_T("是否删除?此操作不可逆!"), MB_YESNO) != IDYES)
|
||
return;
|
||
|
||
#ifdef NDEBUG
|
||
if (!PermissionDel())
|
||
{
|
||
return;
|
||
}
|
||
#endif // !_NDEBUG
|
||
|
||
HTREEITEM hRoot = m_ctrlDirTree.GetSelectedItem();
|
||
if (!hRoot)
|
||
{
|
||
AfxMessageBox(_T("请选中一个目录!"));
|
||
return;
|
||
}
|
||
|
||
std::vector<int> files;
|
||
getSelectedFiles(files);
|
||
if (files.empty())
|
||
{
|
||
AfxMessageBox(_T("请至少选择一个文件!"));
|
||
return;
|
||
}
|
||
|
||
int idx(-1);
|
||
CString sql(_T("")), sTbl(m_eOper == eManaZhSb ? _T("dwg") : _T("aec"));
|
||
m_sqlDB.BeginTrans();
|
||
for (size_t i = 0; i < files.size(); ++i)
|
||
{
|
||
idx = m_ctrlFileList.GetItemData(files[i]);
|
||
if (m_eOper == eMana)
|
||
{
|
||
sql.Format(_T("delete from aec_bims where equid='%d'"), idx);
|
||
m_sqlDB.ExecuteSQL(sql);
|
||
}
|
||
|
||
sql.Format(_T("delete from %s_package where id='%d'"), sTbl, idx);
|
||
m_sqlDB.ExecuteSQL(sql);
|
||
}
|
||
m_sqlDB.CommitTrans();
|
||
|
||
refreshFileList(hRoot);
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnBnClickedFileOut()
|
||
{
|
||
HTREEITEM hRoot = m_ctrlDirTree.GetSelectedItem();
|
||
if (!hRoot)
|
||
{
|
||
AfxMessageBox(_T("请选中一个目录!"));
|
||
return;
|
||
}
|
||
|
||
std::vector<int> files;
|
||
getSelectedFiles(files);
|
||
if (files.empty())
|
||
{
|
||
AfxMessageBox(_T("请至少选择一个文件!"));
|
||
return;
|
||
}
|
||
|
||
CString sPath(_T(""));
|
||
if (!selectPath(_T("请选择文件要保存的目录"), sPath))
|
||
return;
|
||
|
||
CString sName(_T("")), sFile(_T(""));
|
||
int fileId(-1);
|
||
for (size_t i = 0; i < files.size(); ++i)
|
||
{
|
||
fileId = m_ctrlFileList.GetItemData(files[i]);
|
||
m_ctrlFileList.GetText(files[i], sName);
|
||
|
||
sName = checkFileName(sName);
|
||
sFile = sPath + sName;
|
||
if (m_eOper == eMana)
|
||
{
|
||
AecDbEwEquipment *pEqu = makeEqu(m_sqlDB, fileId);
|
||
if (!pEqu) continue;
|
||
|
||
sFile += _T(".equ");
|
||
if (_taccess(sFile, 0x0) == 0x0)
|
||
{
|
||
if (IDYES != AfxMessageBox(CString(_T("文件:")) + sName + _T("已存在,是否覆盖?"), MB_YESNO))
|
||
{
|
||
DELETE_PTR(pEqu);
|
||
continue;
|
||
}
|
||
else
|
||
{
|
||
if (!::DeleteFile(sFile))
|
||
{
|
||
AfxMessageBox(getLastErrorMsg());
|
||
DELETE_PTR(pEqu);
|
||
continue;
|
||
}
|
||
}
|
||
}
|
||
|
||
CoreTools::equipment2File(pEqu, sFile, sName);
|
||
|
||
DELETE_PTR(pEqu);
|
||
}
|
||
else if (m_eOper == eManaZhSb)
|
||
{
|
||
std::shared_ptr<AcDbDatabase> ptr = getZhSbFileFromDb(m_sqlDB, fileId);
|
||
if (!ptr) return;
|
||
|
||
sFile += _T(".zhequ");
|
||
|
||
int i(1);
|
||
while (i < 100)
|
||
{
|
||
if (_taccess(sFile, 0x0) == 0x0)
|
||
{
|
||
sFile.Format(_T("%s%s(%d).zhequ")
|
||
, sPath
|
||
, sName
|
||
, i++);
|
||
}
|
||
else
|
||
break;
|
||
}
|
||
ptr->saveAs(sFile, false, AcDb::kDHL_CURRENT);
|
||
}
|
||
}
|
||
|
||
AfxMessageBox(_T("文件导出完毕。"));
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnBnClickedBimAdd()
|
||
{
|
||
int idx = m_ctrlFileList.GetCurSel();
|
||
if (idx == -1)
|
||
{
|
||
AfxMessageBox(_T("请选中一个文件!"));
|
||
return;
|
||
}
|
||
|
||
int equId = m_ctrlFileList.GetItemData(idx);
|
||
|
||
CString sKey(_T("")), sValue(_T(""));
|
||
if (!CoreTools::getBimDataByDlg(true, sKey, sValue)) return;
|
||
|
||
LVFINDINFO info;
|
||
info.flags = LVFI_PARTIAL | LVFI_STRING;
|
||
info.psz = sKey;
|
||
int nIndex;
|
||
|
||
nIndex = m_ctrlBimList.FindItem(&info);
|
||
if (nIndex != -1)
|
||
{
|
||
AfxMessageBox(_T("已经存在相同的属性!"));
|
||
return;
|
||
}
|
||
|
||
if (m_eOper == eMana)
|
||
{
|
||
CString sql(_T(""));
|
||
sql.Format(_T("insert into aec_bims (name, value, equid) values ('%s', '%s', '%d')")
|
||
, sKey
|
||
, sValue
|
||
, equId);
|
||
|
||
if (m_sqlDB.ExecuteSQL(sql))
|
||
{
|
||
int id = getLastInserId(m_sqlDB, _T("aec_bims"));
|
||
idx = m_ctrlBimList.InsertItem(m_ctrlBimList.GetItemCount() + 1, sKey);
|
||
m_ctrlBimList.SetItemText(idx, 1, sValue);
|
||
m_ctrlBimList.SetItemData(idx, id);
|
||
m_ctrlBimList.Invalidate();
|
||
}
|
||
}
|
||
else if (m_eOper == eManaZhSb)
|
||
{
|
||
if (addBimRecToZhSbFile(m_sqlDB, equId, std::make_pair(sKey, sValue)))
|
||
{
|
||
idx = m_ctrlBimList.InsertItem(m_ctrlBimList.GetItemCount() + 1, sKey);
|
||
m_ctrlBimList.SetItemText(idx, 1, sValue);
|
||
m_ctrlBimList.Invalidate();
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnBnClickedBimModi()
|
||
{
|
||
int idx = m_ctrlFileList.GetCurSel();
|
||
if (idx == -1)
|
||
{
|
||
AfxMessageBox(_T("请选中一个文件!"));
|
||
return;
|
||
}
|
||
|
||
int equId = m_ctrlFileList.GetItemData(idx);
|
||
|
||
idx = m_ctrlBimList.GetSelectionMark();
|
||
if (idx == -1)
|
||
{
|
||
AfxMessageBox(_T("请选中一行数据!"));
|
||
return;
|
||
}
|
||
|
||
int bimId = m_ctrlBimList.GetItemData(idx);
|
||
|
||
if (AfxMessageBox(_T("是否修改?此操作不可逆!"), MB_YESNO) != IDYES)
|
||
return;
|
||
|
||
CString sKey(m_ctrlBimList.GetItemText(idx, 0)), sValue(m_ctrlBimList.GetItemText(idx, 1));
|
||
if (!CoreTools::getBimDataByDlg(false, sKey, sValue)) return;
|
||
|
||
if (m_eOper == eMana)
|
||
{
|
||
CString sql(_T(""));
|
||
sql.Format(_T("update aec_bims set value='%s' where id='%d'"), sValue, bimId);
|
||
if (m_sqlDB.ExecuteSQL(sql))
|
||
{
|
||
m_ctrlBimList.SetItemText(idx, 1, sValue);
|
||
m_ctrlBimList.Invalidate();
|
||
//refreshBimList(idx);
|
||
}
|
||
}
|
||
else if (m_eOper == eManaZhSb)
|
||
{
|
||
if (addBimRecToZhSbFile(m_sqlDB, equId, std::make_pair(sKey, sValue)))
|
||
{
|
||
m_ctrlBimList.SetItemText(idx, 1, sValue);
|
||
m_ctrlBimList.Invalidate();
|
||
}
|
||
}
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnBnClickedBimDel()
|
||
{
|
||
if (!PermissionDel())
|
||
{
|
||
return;
|
||
}
|
||
|
||
int fileIdx = m_ctrlFileList.GetCurSel();
|
||
if (fileIdx == -1)
|
||
{
|
||
AfxMessageBox(_T("请选中一个文件!"));
|
||
return;
|
||
}
|
||
int equId = m_ctrlFileList.GetItemData(fileIdx);
|
||
|
||
int bimIdx = m_ctrlBimList.GetSelectionMark();
|
||
if (bimIdx == -1)
|
||
{
|
||
AfxMessageBox(_T("请选中一行数据!"));
|
||
return;
|
||
}
|
||
int bimId = m_ctrlBimList.GetItemData(bimIdx);
|
||
|
||
if (AfxMessageBox(_T("是否删除?此操作不可逆!"), MB_YESNO) != IDYES)
|
||
return;
|
||
|
||
if (m_eOper == eMana)
|
||
{
|
||
CString sql(_T(""));
|
||
sql.Format(_T("delete from aec_bims where id='%d'"), bimId);
|
||
if (m_sqlDB.ExecuteSQL(sql))
|
||
{
|
||
m_ctrlBimList.DeleteItem(bimIdx);
|
||
m_ctrlBimList.Invalidate();
|
||
//refreshBimList(fileIdx);
|
||
}
|
||
}
|
||
else if (m_eOper == eManaZhSb)
|
||
{
|
||
if (delBimRecToZhSbFile(m_sqlDB, equId, m_ctrlBimList.GetItemText(bimIdx, 0)))
|
||
{
|
||
m_ctrlBimList.DeleteItem(bimIdx);
|
||
m_ctrlBimList.Invalidate();
|
||
}
|
||
}
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnBnClickedOk()
|
||
{
|
||
UpdateData(TRUE);
|
||
std::vector<int> files;
|
||
getSelectedFiles(files);
|
||
CDialog::OnOK();
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnBnClickedInsert()
|
||
{
|
||
if (m_eOper == eManaZhSb)
|
||
{
|
||
if (m_iSelectFileID != -1)
|
||
{
|
||
SetVistualStyle(_T("2dWireframe"));
|
||
ShowWindow(SW_HIDE);
|
||
insertZHSB(m_sqlDB, m_iSelectFileID);
|
||
ShowWindow(SW_SHOW);
|
||
}
|
||
}
|
||
else
|
||
CDialog::OnCancel();
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnCheckLineVlv()
|
||
{
|
||
UpdateData();
|
||
if (m_bLineVlv)
|
||
{
|
||
m_bUseFangle = FALSE;
|
||
}
|
||
UpdateData(FALSE);
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnCheckFlange()
|
||
{
|
||
UpdateData();
|
||
|
||
//法兰端面
|
||
//垫片信息
|
||
if (m_bUseFangle)
|
||
{
|
||
CFLEndFGsDlg dlg;
|
||
if (IDOK == dlg.DoModal())
|
||
{
|
||
dlg.GetFLngEndFace(m_sEndF1, m_sEndF2);
|
||
dlg.GetGasketInf(m_sGaskets);
|
||
}
|
||
}
|
||
}
|
||
|
||
#include "EquLibDlg.h"
|
||
#include "ZHSBLibDlg.h"
|
||
void CEquipmentLibraryDlg::zhsbgl()
|
||
{
|
||
CZHSBLibDlg::zhsbgl();
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::crzhsb(LPCTSTR pszDir)
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
CEquipmentLibraryDlg dlg(eInsZhSb, pszDir);
|
||
if (dlg.DoModal() != IDOK) return;
|
||
insertZHSB(dlg.getSqliteDB(), dlg.m_iSelectFileID);
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::sbgl()
|
||
{
|
||
CEquLibDlg::sbgl();
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::crsb(LPCTSTR pszDir)
|
||
{
|
||
CEquLibDlg::crsb();
|
||
}
|
||
|
||
int CEquipmentLibraryDlg::selectSingleEquID(LPCTSTR pszDir
|
||
, LPCTSTR pszFile
|
||
, bool bUIFangle
|
||
, bool bUI2DCheck)
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
CEquipmentLibraryDlg dlg(eSel, pszDir, pszFile, bUIFangle, bUI2DCheck);
|
||
if (dlg.DoModal() != IDOK) return -1;
|
||
|
||
return dlg.m_iSelectFileID;
|
||
}
|
||
|
||
AecDbEwEquipment* CEquipmentLibraryDlg::selectSingleEqu(LPCTSTR pszDir
|
||
, LPCTSTR pszFile
|
||
, bool bUIFangle
|
||
, bool bUI2DCheck
|
||
, bool &bUseFangle
|
||
, bool &b2DCheck)
|
||
{
|
||
bUseFangle = bUIFangle;
|
||
b2DCheck = bUI2DCheck;
|
||
return CEquLibDlg::selectEqu(pszFile, bUseFangle, b2DCheck);
|
||
}
|
||
|
||
AecDbEwEquipment * CEquipmentLibraryDlg::selectCustomValve(LPCTSTR pszDir
|
||
, double dDN
|
||
, bool bUIFangle
|
||
, bool bUI2DCheck
|
||
, bool &bUseFangle
|
||
, bool &b2DCheck)
|
||
{
|
||
bUseFangle = bUIFangle;
|
||
b2DCheck = bUI2DCheck;
|
||
return CEquLibDlg::selectCustomValve(pszDir, dDN, bUseFangle, b2DCheck);
|
||
}
|
||
|
||
AecDbEwEquipment * CEquipmentLibraryDlg::getEquipment(LPCTSTR pszPath, double dDN)
|
||
{
|
||
if (!pszPath) return NULL;
|
||
struct resbuf rb;
|
||
acedGetVar(_T("INSUNITS"), &rb);
|
||
double dDn(dDN);
|
||
if (rb.resval.rint == AcDb::kUnitsMeters)
|
||
{
|
||
if (dDn <= 5.0) dDn *= 1000;
|
||
}
|
||
int iDN = (int)(dDn + 0.5);
|
||
CString sFileAnchor = CString(_T("DN")) + TypeConvert::convert<std::wstring, int>(iDN).c_str();
|
||
|
||
return getEquipment(pszPath, sFileAnchor);
|
||
}
|
||
|
||
AecDbEwEquipment * CEquipmentLibraryDlg::getEquipment(LPCTSTR pszPath, LPCTSTR pszFile)
|
||
{
|
||
if (!pszPath || !pszFile) return NULL;
|
||
|
||
CString sPath(pszPath), sFileAnchor(pszFile);
|
||
sPath.TrimLeft(_T('\\'));
|
||
|
||
CString sFolder = sPath.Left(sPath.Find(_T('\\')));
|
||
CString sClass = sPath.Right(sPath.GetLength() - sPath.Find(_T('\\')) - 1);
|
||
|
||
CString sql(_T(""));
|
||
sql.Format(_T("select id, name from aec_package")
|
||
_T(" where idclass=")
|
||
_T(" (")
|
||
_T(" select id from aec_class where class='%s'")
|
||
_T(" )")
|
||
_T(" and name like '%%%s%%'"), sClass, sFileAnchor);
|
||
|
||
std::map<CString, CString> ss;
|
||
std::map<CString, CString>::const_iterator it;
|
||
CUIISQLiteServer db;
|
||
if (!db.InitADOServer(FilePath::GetSysDir() + _T("\\Aec3DMep.db")))
|
||
{
|
||
AfxMessageBox(_T("打开数据库Aec3DMep.db失败!"));
|
||
return NULL;
|
||
}
|
||
db.GetSelData(sql, ss);
|
||
|
||
for (it = ss.begin(); it != ss.end(); ++it)
|
||
{
|
||
if (checkFileName(it->second, sFileAnchor))
|
||
return makeEqu(db, TypeConvert::convert<int, LPCTSTR>(it->first));
|
||
}
|
||
return NULL;
|
||
}
|
||
|
||
bool CEquipmentLibraryDlg::saveEquToDb(AcDbObjectId equID, LPCTSTR pszEquName)
|
||
{
|
||
CAcModuleResourceOverride myResources;
|
||
if (!equID.isValid()) return false;
|
||
if (!pszEquName) return false;
|
||
CImageList imgList;
|
||
CBitmap bmp;
|
||
if (!bmp.LoadBitmap(IDB_BITMAPDIR))
|
||
{
|
||
AfxMessageBox(_T("Can't load bitmap: %x\n"), IDB_BITMAPPRIV);
|
||
ASSERT(FALSE);
|
||
return false;
|
||
}
|
||
BITMAP bmpObj;
|
||
bmp.GetBitmap(&bmpObj);
|
||
UINT nFlags = ILC_COLOR24 | ILC_MASK;
|
||
imgList.Create(16, bmpObj.bmHeight, nFlags, 0, 0);
|
||
imgList.Add(&bmp, RGB(255, 0, 0));
|
||
//m_ctrlDirTree.SetImageList(&m_imageList, TVSIL_NORMAL);
|
||
|
||
CUIISQLiteServer db;
|
||
if (!db.InitADOServer(FilePath::GetSysDir() + _T("\\Aec3DMep.db")))
|
||
{
|
||
AfxMessageBox(_T("打开数据库Aec3DMep.db失败!"));
|
||
return false;
|
||
}
|
||
|
||
CEquLibCopyTreeDlg dlg(imgList, db, CEquipmentLibraryDlg::eMana, NULL);
|
||
if (dlg.DoModal() != IDOK) return false;
|
||
|
||
int idClass = dlg.getClassId();
|
||
|
||
CString sName(pszEquName);
|
||
sName = checkFileName(sName);
|
||
CString sFile = FilePath::getSystemTemporaryFolder() + _T("\\") + sName + _T(".equ");
|
||
if (CoreTools::equipment2File(equID, sFile, pszEquName))
|
||
{
|
||
bool bRel = putEquFileToDb(db, sFile, idClass, eMana);
|
||
::DeleteFile(sFile);
|
||
return bRel;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
bool CEquipmentLibraryDlg::ExtractBomOfZHEqu(AcDbBlockReference *pRef, AecDbEwEquipment &equ)
|
||
{
|
||
if (!pRef) return false;
|
||
AecDbObjXDataMap map;
|
||
// 不是组合设备的块引用
|
||
if (!map.Read(pRef, ZH_SB_REF_FIELD)) return false;
|
||
SH_BIM_BLOCK bims;
|
||
CoreTools::getBimDatas(pRef, bims);
|
||
if (bims.empty()) return false;
|
||
|
||
CoreTools::setBimDatas(&equ, bims);
|
||
|
||
AecDbObjXDataMap *pEquData(equ.GetSpecialtyData(AcDb::kForWrite));
|
||
|
||
CString s;
|
||
if (CoreTools::getBimData(pRef, KEY_NAME, s))
|
||
pEquData->SetAt(KEY_NAME, s);
|
||
|
||
if (CoreTools::getBimData(pRef, KEY_SN, s))
|
||
pEquData->SetAt(KEY_SN, s);
|
||
|
||
if (CoreTools::getBimData(pRef, PIPE_SYS, s))
|
||
pEquData->SetAt(PIPE_SYS, s);
|
||
|
||
if (CoreTools::getBimData(pRef, KEY_BOMNO, s))
|
||
pEquData->GetAt(KEY_BOMNO, s);
|
||
|
||
return true;
|
||
}
|
||
|
||
AecDbEwEquipment* CEquipmentLibraryDlg::getEquipment(int fid)
|
||
{
|
||
return makeEqu(m_sqlDB, fid);
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnTvnSelchangedDirTree(NMHDR *pNMHDR, LRESULT *pResult)
|
||
{
|
||
LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
|
||
if (!pNMTreeView->itemNew.hItem) return;
|
||
|
||
refreshFileList(pNMTreeView->itemNew.hItem);
|
||
|
||
m_iSelectFileID = -1;
|
||
|
||
*pResult = 0;
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnLbnSelchangeFileList()
|
||
{
|
||
std::vector<int> v;
|
||
getSelectedFiles(v);
|
||
if (v.size() > 1)
|
||
return;
|
||
|
||
AcAxDocLock lock;
|
||
|
||
int idx = m_ctrlFileList.GetCurSel();
|
||
refreshBimList(idx);
|
||
m_iSelectFileID = m_ctrlFileList.GetItemData(idx);
|
||
|
||
if (m_eOper != eManaZhSb && m_eOper != eInsZhSb)
|
||
{
|
||
m_wndViewCtrl.clearAll();
|
||
m_wndViewCtrl.init(true);
|
||
m_wndViewCtrl.SetOrbitFlag(OBF_PAN | OBF_ZOOM | OBF_COTE);
|
||
AcDbExtents exts;
|
||
AecDbEwEquipment *pEqu = makeEqu(m_sqlDB, m_iSelectFileID);
|
||
if (!pEqu) return;
|
||
|
||
// 预览
|
||
AcGiViewDraw dc;
|
||
pEqu->Draw3d(dc);
|
||
pEqu->getGeomExtents(exts);
|
||
m_wndViewCtrl.InitFromCurrentView3D(exts, true);
|
||
m_wndViewCtrl.Add(pEqu);
|
||
m_wndViewCtrl.view()->invalidate();
|
||
m_wndViewCtrl.Invalidate();
|
||
m_wndViewCtrl.RedrawWindow();
|
||
}
|
||
else
|
||
{
|
||
CStatic *pPic = (CStatic *)GetDlgItem(IDC_PREVIEW_PIC);
|
||
if (!pPic) return;
|
||
std::shared_ptr<AcDbDatabase> pDb = getZhSbFileFromDb(m_sqlDB, m_iSelectFileID);
|
||
if (!pDb) return;
|
||
|
||
AcDbBlockTableRecordPointer pRcd(ZH_SB_BLK_NAME, pDb.get(), AcDb::kForRead);
|
||
if (pRcd.openStatus() != Acad::eOk) return;
|
||
|
||
AcDbBlockTableRecord::PreviewIcon icon;
|
||
pRcd->getPreviewIcon(icon);
|
||
if (icon.isEmpty()) return;
|
||
|
||
if (m_hBitmap)
|
||
::DeleteObject(m_hBitmap);
|
||
|
||
m_hBitmap = PreviewIcon2Bitmap(icon);
|
||
if (!m_hBitmap) return;
|
||
|
||
CImage img;
|
||
img.Attach(m_hBitmap);
|
||
|
||
CRect rect;
|
||
pPic->GetWindowRect(rect);
|
||
CPoint ptTL(rect.TopLeft());
|
||
ScreenToClient(&ptTL); // 得到绘制区域的左上角点的对话框客户端坐标
|
||
|
||
int controlWidth(rect.Width()), controlHeight(rect.Height());
|
||
int imgWidth(img.GetWidth()), imgHeight(img.GetHeight());
|
||
CDC *pDc = GetDC(); // 绘制在对话框上
|
||
|
||
CDC memDc;
|
||
memDc.CreateCompatibleDC(pDc);
|
||
|
||
CBitmap bmp;
|
||
bmp.CreateCompatibleBitmap(pDc, controlWidth, controlHeight);
|
||
CBitmap *pOldbmp = memDc.SelectObject(&bmp);
|
||
|
||
memDc.FillSolidRect(&rect, pDc->GetBkColor());
|
||
img.Draw(memDc.m_hDC, 0, 0, controlWidth, controlHeight, 0, 0, imgWidth, imgHeight);
|
||
|
||
pDc->BitBlt(ptTL.x, ptTL.y, controlWidth, controlHeight, &memDc, 0, 0, SRCCOPY);
|
||
|
||
memDc.SelectObject(pOldbmp);
|
||
|
||
ReleaseDC(pDc);
|
||
}
|
||
|
||
|
||
return;
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnTvnRBClickDirTree(NMHDR * pNMHDR, LRESULT * pResult)
|
||
{
|
||
if (m_eOper != eMana && m_eOper != eManaZhSb) return;
|
||
|
||
CPoint point;
|
||
GetCursorPos(&point);
|
||
CPoint pointInTree = point;
|
||
m_ctrlDirTree.ScreenToClient(&pointInTree);
|
||
|
||
UINT flag = TVHT_ONITEM;
|
||
HTREEITEM hItem = m_ctrlDirTree.HitTest(pointInTree, &flag);
|
||
if (!hItem) return;
|
||
|
||
m_ctrlDirTree.SelectItem(hItem);
|
||
CString sItem = m_ctrlDirTree.GetItemText(hItem);
|
||
|
||
CMenu menu;
|
||
menu.CreatePopupMenu();
|
||
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_EQU_LIB_DIR_ADD, _T("添加目录(&A)"));
|
||
if (!isRootItem(hItem) && sItem != _VALVE_)
|
||
{
|
||
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_EQU_LIB_DIR_RENAME, _T("修改名称(&M)"));
|
||
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_EQU_LIB_DIR_DEL, _T("删除目录(&D)"));
|
||
}
|
||
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_EQU_LIB_DIR_IN, _T("导入目录(&I)"));
|
||
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_EQU_LIB_DIR_OUT, _T("导出目录(&O)"));
|
||
int nID = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD
|
||
, point.x
|
||
, point.y, &m_ctrlDirTree);
|
||
|
||
switch (nID)
|
||
{
|
||
case ID_EQU_LIB_DIR_ADD:
|
||
OnBnClickedDirAdd();
|
||
break;
|
||
case ID_EQU_LIB_DIR_RENAME:
|
||
OnBnClickedDirRename();
|
||
break;
|
||
case ID_EQU_LIB_DIR_DEL:
|
||
OnBnClickedDirDel();
|
||
break;
|
||
case ID_EQU_LIB_DIR_IN:
|
||
OnBnClickedDirIn();
|
||
break;
|
||
case ID_EQU_LIB_DIR_OUT:
|
||
return OnBnClickedDirOut();
|
||
default:
|
||
break;
|
||
}
|
||
g_result.clear();
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnContextMenu(CWnd *pWnd, CPoint pt)
|
||
{
|
||
if (pWnd->GetSafeHwnd() != m_ctrlFileList.GetSafeHwnd()) return;
|
||
|
||
UpdateData(TRUE);
|
||
|
||
CMenu menu;
|
||
menu.CreatePopupMenu();
|
||
|
||
std::vector<int> v;
|
||
getSelectedFiles(v);
|
||
if (m_eOper != eMana && m_eOper != eManaZhSb)
|
||
{
|
||
if (!m_bSearch) return;
|
||
if (v.size() != 1) return;
|
||
|
||
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_EQU_LIB_FILE_ANCHOR, _T("定位文件(&W)"));
|
||
}
|
||
else
|
||
{
|
||
if (m_bSearch)
|
||
{
|
||
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_EQU_LIB_FILE_ANCHOR, _T("定位文件(&W)"));
|
||
}
|
||
else
|
||
{
|
||
if (m_eOper == eManaZhSb)
|
||
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_EQU_LIB_FILE_NEW, _T("新建设备(&N)"));
|
||
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_EQU_LIB_FILE_IN, _T("导入文件(&I)"));
|
||
if (!v.empty())
|
||
{
|
||
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_EQU_LIB_FILE_OUT, _T("导出文件(&O)"));
|
||
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_EQU_LIB_FILE_COPY, _T("复制文件(&C)"));
|
||
if (v.size() == 1)
|
||
{
|
||
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_EQU_LIB_FILE_RENAME, _T("文件改名(&M)"));
|
||
if (m_eOper == eManaZhSb)
|
||
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_EQU_LIB_FILE_THUMBNAIL, _T("更新预览(&P)"));
|
||
}
|
||
menu.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_EQU_LIB_FILE_DEL, _T("删除文件(&D)"));
|
||
}
|
||
}
|
||
}
|
||
|
||
int nID = menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD
|
||
, pt.x
|
||
, pt.y, &m_ctrlFileList);
|
||
|
||
switch (nID)
|
||
{
|
||
case ID_EQU_LIB_FILE_THUMBNAIL:
|
||
return OnBnClickedFileUpdateThumbnail();
|
||
case ID_EQU_LIB_FILE_NEW:
|
||
OnBnClickedFileNew();
|
||
break;
|
||
case ID_EQU_LIB_FILE_IN:
|
||
OnBnClickedFileAdd();
|
||
break;
|
||
case ID_EQU_LIB_FILE_OUT:
|
||
return OnBnClickedFileOut();
|
||
case ID_EQU_LIB_FILE_DEL:
|
||
OnBnClickedFileDel();
|
||
break;
|
||
case ID_EQU_LIB_FILE_COPY:
|
||
OnBnClickedFileCopy();
|
||
break;
|
||
case ID_EQU_LIB_FILE_RENAME:
|
||
OnBnClickedFileRename();
|
||
break;
|
||
case ID_EQU_LIB_FILE_ANCHOR:
|
||
return OnBnClickedFileAnchor();
|
||
default:
|
||
break;
|
||
}
|
||
g_result.clear();
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnBnClickedFileUpdateThumbnail()
|
||
{
|
||
AcAxDocLock lock;
|
||
|
||
HTREEITEM hRoot = m_ctrlDirTree.GetSelectedItem();
|
||
if (!hRoot)
|
||
{
|
||
AfxMessageBox(_T("请选中一个目录!"));
|
||
return;
|
||
}
|
||
|
||
std::vector<int> files;
|
||
getSelectedFiles(files);
|
||
if (files.size() != 1)
|
||
{
|
||
AfxMessageBox(_T("请选择一个文件!"));
|
||
return;
|
||
}
|
||
|
||
int fileId = m_ctrlFileList.GetItemData(files[0]);
|
||
|
||
std::shared_ptr<AcDbDatabase> pDb = getZhSbFileFromDb(m_sqlDB, fileId);
|
||
if (!pDb) return;
|
||
|
||
AcDbBlockTableRecordPointer pRcd(ZH_SB_BLK_NAME, pDb.get(), AcDb::kForWrite);
|
||
if (pRcd.openStatus() != Acad::eOk) return;
|
||
|
||
do
|
||
{
|
||
ShowWindow(SW_HIDE);
|
||
ads_point _pt1, _pt2;
|
||
if (acedGetPoint(NULL, _T("\n选择预览图的左上角"), _pt1) != RTNORM) break;
|
||
if (acedGetPoint(_pt1, _T("\n选择预览图的右下角"), _pt2) != RTNORM) break;
|
||
|
||
AcGePoint3d pt1(asPnt3d(_pt1)), pt2(asPnt3d(_pt2));
|
||
CoreTools::UCS2WCS(pt1, pt1);
|
||
CoreTools::UCS2WCS(pt2, pt2);
|
||
|
||
AcDbExtents ext;
|
||
ext.addPoint(pt1);
|
||
ext.addPoint(pt2);
|
||
AcGePoint3d ptMax(ext.maxPoint()), ptMin(ext.minPoint());
|
||
pt1.x = ptMin.x;
|
||
pt1.y = ptMax.y;
|
||
pt2.x = ptMax.x;
|
||
pt2.y = ptMin.y;
|
||
|
||
AcDbBlockTableRecord::PreviewIcon icon;
|
||
ScreenCopy(pt1, pt2, icon);
|
||
if (icon.isEmpty()) break;
|
||
|
||
pRcd->setPreviewIcon(icon);
|
||
pRcd->close();
|
||
|
||
pDb->saveAs(pDb->originalFileName(), false, AcDb::kDHL_CURRENT);
|
||
|
||
updateDwgPackage(m_sqlDB, fileId, pDb->originalFileName());
|
||
|
||
} while (false);
|
||
|
||
ShowWindow(SW_SHOW);
|
||
OnLbnSelchangeFileList();
|
||
}
|
||
|
||
|
||
void CEquipmentLibraryDlg::OnBnClickedFileNew()
|
||
{
|
||
if (m_eOper != eManaZhSb) return;
|
||
|
||
AcAxDocLock lock;
|
||
|
||
HTREEITEM hItem = m_ctrlDirTree.GetSelectedItem();
|
||
if (!hItem)
|
||
{
|
||
AfxMessageBox(_T("请选中一个目录!"));
|
||
return;
|
||
}
|
||
|
||
if (!isClassItem(hItem))
|
||
{
|
||
AfxMessageBox(_T("不能在根目录或一级目录下保存文件,请选择一个二级目录!"));
|
||
return;
|
||
}
|
||
|
||
ads_name ssName;
|
||
AcDbObjectId RcdId;
|
||
AcDbObjectIdArray ids;
|
||
AcDbIdMapping idmap;
|
||
Acad::ErrorStatus es;
|
||
|
||
SetVistualStyle(_T("Shaded"));// 提前渲染
|
||
ShowWindow(SW_HIDE);
|
||
|
||
do
|
||
{
|
||
if (acedSSGet(NULL, NULL, NULL, NULL, ssName) != RTNORM) break;
|
||
|
||
AcDbObjectId EntId;
|
||
ads_name EntName;
|
||
Adesk::Int32 nLength = 0;
|
||
acedSSLength(ssName, &nLength);
|
||
AcDbExtents ext, extAll;
|
||
for (int nLen = 0; nLen<nLength; nLen++)
|
||
{
|
||
acedSSName(ssName, nLen, EntName);
|
||
acdbGetObjectId(EntId, EntName);
|
||
ids.append(EntId);
|
||
AcDbEntityPointer ptr(EntId, AcDb::kForRead);
|
||
if (ptr.openStatus() == Acad::eOk)
|
||
{
|
||
if (ptr->getGeomExtents(ext) == Acad::eOk)
|
||
extAll.addExt(ext);
|
||
}
|
||
}
|
||
acedSSFree(ssName);
|
||
if (ids.isEmpty()) break;
|
||
|
||
AcGePoint3d ptBlk = CoreTools::MidPt(extAll.maxPoint(), extAll.minPoint());
|
||
|
||
CString sBlockName(ZH_SB_BLK_NAME), sEquName(_T("组合设备1"));
|
||
if (!CoreTools::getNameByDialog(_T("输入组合设备名称"), _T("组合设备名称"), sEquName)) break;
|
||
if (sEquName.IsEmpty()) break;
|
||
|
||
if (!CoreTools::checkFileName(sEquName))
|
||
{
|
||
AfxMessageBox(_T("请检查设备名称,不能出现“ \\/:*?\"<>| ”。"));
|
||
break;
|
||
}
|
||
|
||
if (hasSameFileName(m_ctrlFileList, sEquName))
|
||
{
|
||
AfxMessageBox(_T("存在相同的文件名称!"));
|
||
break;
|
||
}
|
||
|
||
if (acedGetPoint(asDblArray(ptBlk), _T("\n指定插入点:"), asDblArray(ptBlk)) == RTCAN) break;
|
||
|
||
int idxClass = m_ctrlDirTree.GetItemData(hItem);
|
||
|
||
SetViewportDir(AcGeVector3d(-1., -1., 1), extAll.maxPoint(), extAll.minPoint());
|
||
|
||
AcDbDatabase *_pDb = new AcDbDatabase(Adesk::kTrue, Adesk::kTrue);
|
||
std::shared_ptr<AcDbDatabase> pDb(_pDb);
|
||
|
||
// 得到当前文件中的 设置
|
||
AecDbObjXDataMap xPipeInit;
|
||
if (KTModelLayoutXData::ReadModelXData(KT_PIPEINIT, xPipeInit))
|
||
KTModelLayoutXData::WriteModelXData(KT_PIPEINIT, xPipeInit, pDb.get());
|
||
|
||
AecDbObjXDataMap xDataMap;
|
||
KTModelLayoutXData::WriteModelNameObjXData(ZH_SB_BIM_REC, xDataMap, pDb.get());
|
||
xDataMap.SetAt(_T("maxpt"), extAll.maxPoint());
|
||
xDataMap.SetAt(_T("minpt"), extAll.minPoint());
|
||
KTModelLayoutXData::WriteModelNameObjXData(ZH_SB_BLK_EXT, xDataMap, pDb.get());
|
||
|
||
AcDbBlockTableRecord *pRcd = new AcDbBlockTableRecord;
|
||
pRcd->setOrigin(ptBlk);
|
||
pRcd->setName(sBlockName);
|
||
|
||
AcDbBlockTable *pTbl(NULL);
|
||
pDb->getBlockTable(pTbl, AcDb::kForWrite);
|
||
if (!pTbl)
|
||
{
|
||
DELETE_PTR(pRcd);
|
||
break;
|
||
}
|
||
|
||
pTbl->add(RcdId, pRcd);
|
||
|
||
pTbl->close();
|
||
|
||
AcDbBlockTableRecord::PreviewIcon icon;
|
||
ScreenCopy(AcGePoint3d::kOrigin, AcGePoint3d::kOrigin, icon);
|
||
if (!icon.isEmpty())
|
||
pRcd->setPreviewIcon(icon);
|
||
pRcd->close();
|
||
|
||
es = acdbHostApplicationServices()->workingDatabase()->wblockCloneObjects(ids
|
||
, RcdId
|
||
, idmap
|
||
, AcDb::kDrcReplace);
|
||
|
||
CString sPath(FilePath::getSystemTemporaryFolder() + _T("\\") + sEquName + _T(".dwg"));
|
||
if (_taccess(sPath, 0x0) == 0x0)
|
||
::DeleteFile(sPath);
|
||
|
||
es = pDb->saveAs(sPath, false, AcDb::kDHL_1024);
|
||
if (es!=Acad::eOk) acutPrintf(_T("\n保存失败"));
|
||
|
||
putEquFileToDb(m_sqlDB, sPath, idxClass, eManaZhSb);
|
||
|
||
|
||
refreshFileList(hItem);
|
||
} while (false);
|
||
ShowWindow(SW_SHOW);
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnCbnSelchangeLibrary()
|
||
{
|
||
CString sEquLib = getEquLibraryName();
|
||
|
||
if (m_cmbEquLib.GetCurSel() == m_nIdxEquLib) return;
|
||
|
||
m_ctrlBimList.DeleteAllItems();
|
||
|
||
if (m_EquLibs.empty()
|
||
|| !m_sqlDB.InitADOServer(FilePath::GetSysDir() + _T("//") + sEquLib))
|
||
{
|
||
AfxMessageBox(_T("打开数据库Aec3DMep.db失败!"));
|
||
EndDialog(-1);
|
||
}
|
||
|
||
m_ctrlFileList.ResetContent();
|
||
|
||
m_ctrlDirTree.DeleteAllItems();
|
||
initTree(m_ctrlDirTree, m_imageList, m_sqlDB, m_eOper);
|
||
initFileList();
|
||
initBIMList();
|
||
initPreviewCtrl();
|
||
|
||
m_nIdxEquLib = m_cmbEquLib.GetCurSel();
|
||
}
|
||
|
||
|
||
void CEquipmentLibraryDlg::OnCheckSearch()
|
||
{
|
||
UpdateData(TRUE);
|
||
CRect reSep, reTree, reList;
|
||
m_ctrlStaticSep.GetWindowRect(reSep);
|
||
m_ctrlDirTree.GetWindowRect(reTree);
|
||
|
||
if (m_bSearch)
|
||
{
|
||
m_ctrlFileList.GetWindowRect(reList);
|
||
int delta = reList.left - reSep.left;
|
||
reList.left = reTree.left;
|
||
ScreenToClient(reList);
|
||
m_ctrlFileList.MoveWindow(reList);
|
||
SetWindowText(_T("输入要搜索的文件的特征,多个特征用“空格”分开。"));
|
||
}
|
||
else
|
||
{
|
||
m_ctrlFileList.GetWindowRect(reList);
|
||
reList.left = reSep.left + 6;
|
||
ScreenToClient(reList);
|
||
m_ctrlFileList.MoveWindow(reList);
|
||
if (m_eOper == eMana || m_eOper == eManaZhSb)
|
||
SetWindowText(_T("设备管理"));
|
||
else
|
||
SetWindowText(_T("插入"));
|
||
}
|
||
|
||
m_ctrlStaticDir.SetWindowText(m_bSearch ? _T("搜索结果") : _T("设备文件目录"));
|
||
m_ctrlSearchEdt.EnableWindow(m_bSearch);
|
||
::ShowWindow(m_ctrlStaticSep, m_bSearch ? SW_HIDE : SW_SHOW);
|
||
::ShowWindow(m_ctrlDirTree, m_bSearch ? SW_HIDE : SW_SHOW);
|
||
::ShowWindow(m_ctrlStaticFile, m_bSearch ? SW_HIDE : SW_SHOW);
|
||
|
||
m_ctrlDirTree.SelectItem(m_ctrlDirTree.GetRootItem());
|
||
|
||
|
||
m_ctrlSearchEdt.IsWindowVisible();
|
||
|
||
if (m_eOper == eMana || m_eOper == eManaZhSb)
|
||
{
|
||
SHOWWINDOW(IDC_DIR_ADD, m_bSearch ? SW_HIDE : SW_SHOW)
|
||
SHOWWINDOW(IDC_DIR_MODI, m_bSearch ? SW_HIDE : SW_SHOW);
|
||
SHOWWINDOW(IDC_DIR_DEL, m_bSearch ? SW_HIDE : SW_SHOW);
|
||
SHOWWINDOW(IDC_DIR_OUT, m_bSearch ? SW_HIDE : SW_SHOW);
|
||
SHOWWINDOW(IDC_DIR_IN, m_bSearch ? SW_HIDE : SW_SHOW);
|
||
if (m_eOper == eManaZhSb)
|
||
SHOWWINDOW(IDC_FILE_NEW, m_bSearch ? SW_HIDE : SW_SHOW);
|
||
SHOWWINDOW(IDC_FILE_ADD, m_bSearch ? SW_HIDE : SW_SHOW);
|
||
SHOWWINDOW(IDC_FILE_OUT, m_bSearch ? SW_HIDE : SW_SHOW);
|
||
SHOWWINDOW(IDC_FILE_DEL, m_bSearch ? SW_HIDE : SW_SHOW);
|
||
SHOWWINDOW(IDC_FILE_RENAME, m_bSearch ? SW_HIDE : SW_SHOW);
|
||
SHOWWINDOW(IDC_FILE_ADD, m_bSearch ? SW_HIDE : SW_SHOW);
|
||
SHOWWINDOW(IDC_FILE_COPY, m_bSearch ? SW_HIDE : SW_SHOW);
|
||
}
|
||
|
||
m_ctrlFileList.ResetContent();
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnEnChangeSearch()
|
||
{
|
||
UpdateData(TRUE);
|
||
CString str;
|
||
m_ctrlSearchEdt.GetWindowText(str);
|
||
|
||
if (str.IsEmpty()) return;
|
||
|
||
str.MakeUpper();
|
||
|
||
std::vector<CString> conditions;
|
||
CoreTools::SplitString(str, _T(' '), conditions);
|
||
if (conditions.empty()) return;
|
||
|
||
m_ctrlFileList.ResetContent();
|
||
|
||
int idx;
|
||
std::map<int, CString> result;
|
||
search(m_sqlDB, conditions, result, m_eOper);
|
||
std::map<int, CString>::const_iterator it(result.begin());
|
||
for (; it != result.end(); ++it)
|
||
{
|
||
idx = m_ctrlFileList.AddString(it->second);
|
||
m_ctrlFileList.SetItemData(idx, it->first);
|
||
}
|
||
if (m_ctrlFileList.GetCount() > 0)
|
||
{
|
||
m_ctrlFileList.SetSel(0);
|
||
m_iSelectFileID = m_ctrlFileList.GetItemData(0);
|
||
}
|
||
}
|
||
|
||
void CEquipmentLibraryDlg::OnLbnDblClkFileList()
|
||
{
|
||
UpdateData(TRUE);
|
||
|
||
if (m_bSearch)
|
||
{
|
||
OnBnClickedFileAnchor();
|
||
}
|
||
else
|
||
{
|
||
if (m_eOper == eManaZhSb)
|
||
{
|
||
if (m_iSelectFileID != -1)
|
||
{
|
||
SetVistualStyle(_T("2dWireframe"));
|
||
ShowWindow(SW_HIDE);
|
||
insertZHSB(m_sqlDB, m_iSelectFileID);
|
||
ShowWindow(SW_SHOW);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
#pragma endregion
|
||
|
||
#pragma region CEquLibCopyTreeDlg
|
||
IMPLEMENT_DYNAMIC(CEquLibCopyTreeDlg, CDialog)
|
||
BEGIN_MESSAGE_MAP(CEquLibCopyTreeDlg, CDialog)
|
||
ON_BN_CLICKED(IDOK, &CEquLibCopyTreeDlg::OnBnClickedOk)
|
||
ON_BN_CLICKED(IDCANCEL, &CEquLibCopyTreeDlg::OnBnClickedCancel)
|
||
ON_BN_CLICKED(IDC_BUTTON1,&CEquLibCopyTreeDlg::OnNewFolder)
|
||
END_MESSAGE_MAP()
|
||
|
||
CEquLibCopyTreeDlg::CEquLibCopyTreeDlg(CImageList & img
|
||
, CUIISQLiteServer & db
|
||
, const CEquipmentLibraryDlg::EOPER &oper
|
||
, CWnd * pParent) : CDialog(CEquLibCopyTreeDlg::IDD, pParent)
|
||
, m_eOper(oper)
|
||
, m_imageList(img)
|
||
, m_iClassId(-1)
|
||
, m_sqlDB(db) { }
|
||
|
||
CEquLibCopyTreeDlg::~CEquLibCopyTreeDlg() { }
|
||
|
||
void CEquLibCopyTreeDlg::DoDataExchange(CDataExchange * pDX)
|
||
{
|
||
CDialog::DoDataExchange(pDX);
|
||
DDX_Control(pDX, IDC_TREE1, m_ctrlDirTree);
|
||
}
|
||
|
||
BOOL CEquLibCopyTreeDlg::OnInitDialog()
|
||
{
|
||
CDialog::OnInitDialog();
|
||
initTree(m_ctrlDirTree, m_imageList, m_sqlDB, m_eOper);
|
||
return TRUE;
|
||
}
|
||
|
||
void CEquLibCopyTreeDlg::OnBnClickedOk()
|
||
{
|
||
HTREEITEM hItem = m_ctrlDirTree.GetSelectedItem();
|
||
if (!hItem)
|
||
{
|
||
AfxMessageBox(_T("请选择一个目录!"));
|
||
return;
|
||
}
|
||
if (::isFolderItem(m_ctrlDirTree, hItem) || ::isRootItem(m_ctrlDirTree, hItem))
|
||
{
|
||
AfxMessageBox(_T("不能选择根目录和一级目录!"));
|
||
return;
|
||
}
|
||
|
||
m_iClassId = m_ctrlDirTree.GetItemData(hItem);
|
||
|
||
CDialog::OnOK();
|
||
}
|
||
|
||
void CEquLibCopyTreeDlg::OnBnClickedCancel()
|
||
{
|
||
CDialog::OnCancel();
|
||
}
|
||
|
||
void CEquLibCopyTreeDlg::OnNewFolder()
|
||
{
|
||
HTREEITEM hRoot(m_ctrlDirTree.GetRootItem());
|
||
HTREEITEM hItem = m_ctrlDirTree.GetSelectedItem();
|
||
if (!hItem)
|
||
{
|
||
AfxMessageBox(_T("请选中一个目录!"));
|
||
return;
|
||
}
|
||
|
||
CString sName(_T("")), sTmp(_T(""));
|
||
if (!CoreTools::getNameByDialog(_T("输入目录名称"), _T("目录名称"), sTmp)) return;
|
||
if (sTmp.Find(_T('\\')) != -1)
|
||
{
|
||
AfxMessageBox(_T("目录名称中不能存在字符“\\”!"));
|
||
return;
|
||
}
|
||
|
||
HTREEITEM h = findSubDir(m_ctrlDirTree, hItem, sTmp);
|
||
if (h)
|
||
{
|
||
AfxMessageBox(_T("目录已经存在!"));
|
||
return;
|
||
}
|
||
|
||
CString sql(_T("")), sId(_T(""));
|
||
HTREEITEM hNew(NULL);
|
||
if (isRootItem(m_ctrlDirTree,hItem)) // 添加 folder
|
||
{
|
||
sql.Format(_T("insert into aec_folder (folder) values ('%s')"), sTmp);
|
||
if (m_sqlDB.ExecuteSQL(sql))
|
||
{
|
||
hNew = m_ctrlDirTree.InsertItem(sTmp, 0, 2, hItem);
|
||
m_ctrlDirTree.SetItemData(hNew, getLastInserId(m_sqlDB, _T("aec_folder")));
|
||
m_ctrlDirTree.Expand(hItem, TVE_EXPAND);
|
||
}
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
CString sClass = getClassName(m_ctrlDirTree,hItem);
|
||
if (!sClass.IsEmpty())
|
||
sClass += _T("\\");
|
||
sClass += sTmp;
|
||
|
||
HTREEITEM hParent = getParentFolder(m_ctrlDirTree,hItem);
|
||
int idFolder = m_ctrlDirTree.GetItemData(hParent);
|
||
|
||
sql.Format(_T("insert into aec_class (class, idfolder) values ('%s', '%d')"), sClass, idFolder);
|
||
if (m_sqlDB.ExecuteSQL(sql))
|
||
{
|
||
hNew = m_ctrlDirTree.InsertItem(sTmp, 0, 2, hItem);
|
||
m_ctrlDirTree.SetItemData(hNew, getLastInserId(m_sqlDB, _T("aec_class")));
|
||
m_ctrlDirTree.Expand(hItem, TVE_EXPAND);
|
||
}
|
||
return;
|
||
}
|
||
}
|
||
|
||
#pragma endregion
|