184 lines
3.4 KiB
C++
184 lines
3.4 KiB
C++
#include "..\stdafx.h"
|
|
#include "THVacCfgOperation.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
THVacCfgOperation::THVacCfgOperation()
|
|
{
|
|
|
|
}
|
|
|
|
THVacCfgOperation::~THVacCfgOperation()
|
|
{
|
|
|
|
}
|
|
|
|
// 转化lst 为Array
|
|
BOOL THVacCfgOperation::TransFormLstToArray(const CStringList &lstStr, CStringArray &arStr)
|
|
{
|
|
if (lstStr.IsEmpty())
|
|
return FALSE;
|
|
|
|
arStr.RemoveAll();
|
|
|
|
CString strText = lstStr.GetHead();
|
|
arStr.Add(strText);
|
|
|
|
for (POSITION pt = lstStr.GetHeadPosition(); pt != NULL;)
|
|
{
|
|
strText = lstStr.GetNext(pt);
|
|
arStr.Add(strText);
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
// 判断是否为表格的模板行(判断依据:所属系统为空,图层代号不为空)
|
|
BOOL THVacCfgOperation::IsGridModel(const CStringArray &arRow)
|
|
{
|
|
BOOL bIsModel = FALSE;
|
|
if (0 == arRow.GetAt(3).CompareNoCase(_T(""))
|
|
&& 0 != arRow.GetAt(0).CompareNoCase(_T("")))
|
|
bIsModel = TRUE;
|
|
|
|
return bIsModel;
|
|
}
|
|
|
|
// 判断是否为有效的表格行
|
|
BOOL THVacCfgOperation::IsGridValueRow(const CStringArray &arRow)
|
|
{
|
|
BOOL bValRow = FALSE;
|
|
if (0 != arRow.GetAt(0).CompareNoCase(_T(""))
|
|
&& 0 != arRow.GetAt(3).CompareNoCase(_T("")))
|
|
bValRow = TRUE;
|
|
|
|
return bValRow;
|
|
}
|
|
|
|
// 字符集中是否包含指定字符
|
|
BOOL THVacCfgOperation::IsArrayHas(const CStringArray &arStr, LPCTSTR pszValue)
|
|
{
|
|
if (NULL == pszValue)
|
|
return FALSE;
|
|
|
|
CString strTempt;
|
|
BOOL bHas = FALSE;
|
|
for (int i = 0; i < arStr.GetSize(); i ++)
|
|
{
|
|
strTempt = arStr.GetAt(i);
|
|
if ( 0 == strTempt.CompareNoCase(pszValue))
|
|
bHas |= TRUE;
|
|
}
|
|
|
|
return bHas;
|
|
}
|
|
|
|
// 关键字映射
|
|
BOOL THVacCfgOperation::MapDBKeyToGrid(const Ttable& arOldField, Ttable& arNewField)
|
|
{
|
|
if (arOldField.GetSize() < 0)
|
|
return FALSE;
|
|
|
|
CString strFieldName, strGridKey;
|
|
CUIITableField fieldTempt;
|
|
for (int i = 0; i < arOldField.GetSize(); i++)
|
|
{
|
|
fieldTempt = arOldField.GetAt(i);
|
|
strFieldName = fieldTempt.m_sFieldName;
|
|
|
|
if (MapDBKeyToGrid(strFieldName, strGridKey))
|
|
{
|
|
fieldTempt.m_sFieldName = strGridKey;
|
|
arNewField.Add(fieldTempt);
|
|
}
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL THVacCfgOperation::MapDBKeyToGrid(const CStringArray &arTableName, CStringArray &arMapKey)
|
|
{
|
|
if (arTableName.GetSize() < 1)
|
|
return FALSE;
|
|
|
|
CString strTableName, strKeyName;
|
|
for (int i = 0; i < arTableName.GetSize(); i++)
|
|
{
|
|
strTableName = arTableName.GetAt(i);
|
|
|
|
if (MapDBKeyToGrid(strTableName, strKeyName))
|
|
{
|
|
arMapKey.Add(strKeyName);
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL THVacCfgOperation::MapDBKeyToGrid(LPCTSTR pszDBKey, CString &strGridKey)
|
|
{
|
|
if (NULL == pszDBKey)
|
|
return FALSE;
|
|
|
|
CString strTableName = pszDBKey;
|
|
if (0 == strTableName.CompareNoCase(_T("LAYKEY")))
|
|
{
|
|
strGridKey = _T("图层代号");
|
|
return TRUE;
|
|
}
|
|
|
|
if (0 == strTableName.CompareNoCase(_T("LAYNAME")))
|
|
{
|
|
strGridKey = _T("图层名称");
|
|
return TRUE;
|
|
}
|
|
|
|
if (0 == strTableName.CompareNoCase(_T("PIPESYS")))
|
|
{
|
|
strGridKey = _T("管线系统");
|
|
return TRUE;
|
|
}
|
|
|
|
if (0 == strTableName.CompareNoCase(_T("SYSTEM")))
|
|
{
|
|
strGridKey = _T("所属系统");
|
|
return TRUE;
|
|
}
|
|
|
|
if (0 == strTableName.CompareNoCase(_T("COLOR")))
|
|
{
|
|
strGridKey = _T("颜色");
|
|
return TRUE;
|
|
}
|
|
|
|
if (0 == strTableName.CompareNoCase(_T("LINETYPE")))
|
|
{
|
|
strGridKey = _T("线型");
|
|
return TRUE;
|
|
}
|
|
|
|
if (0 == strTableName.CompareNoCase(_T("LINEWIDTH")))
|
|
{
|
|
strGridKey = _T("线宽");
|
|
return TRUE;
|
|
}
|
|
|
|
if (0 == strTableName.CompareNoCase(_T("DIMKEY")))
|
|
{
|
|
strGridKey = _T("标注代号");
|
|
return TRUE;
|
|
}
|
|
|
|
if (0 == strTableName.CompareNoCase(_T("MATERIAL")))
|
|
{
|
|
strGridKey = _T("默认材料");
|
|
return TRUE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|