793 lines
16 KiB
C++
793 lines
16 KiB
C++
#include "stdafx.h"
|
|
#include "SCWJDlg.h"
|
|
#include "LJCSDlg.h"
|
|
#include "AecDbObjXDataMap.h"
|
|
#include "CoreTools.h"
|
|
#include "uiiado.h"
|
|
#include "TextDlg.h"
|
|
#include "ZHDLDlg.h"
|
|
|
|
|
|
extern DLLIMPEXP CString IDCreate();
|
|
extern BOOL GetLocalIP(CStringArray& arsIP);
|
|
extern Acad::ErrorStatus AddToModelSpace(AcDbEntity* pEnt,AcDbDatabase* pDb = NULL,bool bClose = true);
|
|
|
|
static void FreeBuffer(int n,AcDbVoidPtrArray& arEntPtrs)
|
|
{
|
|
AcDbEntity* pEnt = NULL;
|
|
while(arEntPtrs.length() > n )
|
|
{
|
|
pEnt = (AcDbEntity*)arEntPtrs.last();
|
|
if (pEnt != NULL)
|
|
{
|
|
pEnt->erase();
|
|
pEnt->close();
|
|
arEntPtrs.removeLast();
|
|
DELETE_PTR(pEnt);
|
|
}
|
|
}
|
|
}
|
|
|
|
IMPLEMENT_DYNAMIC(CSCWJDlg, CDialog)
|
|
|
|
CSCWJDlg::CSCWJDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CSCWJDlg::IDD, pParent)
|
|
, m_sProName(_T(""))
|
|
, m_sProNo(_T(""))
|
|
, m_sSubProName(_T(""))
|
|
, m_sPro(_T(""))
|
|
, m_sAuthor(_T("张工"))
|
|
, m_sIP(_T(""))
|
|
, m_sRem(_T(""))
|
|
, m_sKeyword(_T(""))
|
|
{
|
|
|
|
}
|
|
|
|
CSCWJDlg::~CSCWJDlg()
|
|
{
|
|
if (m_pMySQLDb != NULL)
|
|
delete m_pMySQLDb;
|
|
}
|
|
|
|
void CSCWJDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
DDX_Text(pDX, IDC_EDIT1, m_sProName);
|
|
DDX_Text(pDX, IDC_EDIT2, m_sProNo);
|
|
DDX_Text(pDX, IDC_EDIT4, m_sSubProName);
|
|
DDX_CBString(pDX, IDC_COMBO2, m_sPro);
|
|
DDX_Text(pDX, IDC_EDIT6, m_sAuthor);
|
|
DDX_CBString(pDX, IDC_COMBO3, m_sIP);
|
|
DDX_Control(pDX, IDC_LIST2, m_wndListBox);
|
|
DDX_Text(pDX, IDC_EDIT3, m_sRem);
|
|
DDX_Control(pDX, IDC_COMBO3, m_wndIPCombox);
|
|
DDX_Text(pDX, IDC_EDIT7, m_sKeyword);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CSCWJDlg, CDialog)
|
|
ON_BN_CLICKED(IDC_BUTTON1, &CSCWJDlg::OnBnClickedButton1)
|
|
ON_BN_CLICKED(IDC_BUTTON9, &CSCWJDlg::OnBnClickedButton9)
|
|
ON_BN_CLICKED(IDOK, &CSCWJDlg::OnBnClickedOk)
|
|
ON_BN_CLICKED(IDC_BUTTON2, &CSCWJDlg::OnBnClickedButton2)
|
|
ON_BN_CLICKED(IDC_BUTTON7, &CSCWJDlg::OnBnClickedButton7)
|
|
ON_BN_CLICKED(IDC_BUTTON10, &CSCWJDlg::OnBnClickedButton10)
|
|
ON_BN_CLICKED(IDC_BUTTON11, &CSCWJDlg::OnBnClickedButton11)
|
|
ON_BN_CLICKED(IDC_BUTTON5, &CSCWJDlg::OnBnClickedButton5)
|
|
ON_BN_CLICKED(IDC_BUTTON12, &CSCWJDlg::OnBnClickedButton12)
|
|
ON_BN_CLICKED(IDC_BUTTON8, &CSCWJDlg::OnBnClickedButton8)
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
BOOL CSCWJDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
InitMeIPCombox();
|
|
|
|
if ( !InitADOServer() )
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CSCWJDlg::InitMeIPCombox()
|
|
{
|
|
CStringArray arIps;
|
|
GetLocalIP(arIps);
|
|
|
|
for (int i = 0;i < arIps.GetSize();i++)
|
|
{
|
|
m_wndIPCombox.AddString(arIps.GetAt(i));
|
|
}
|
|
if (arIps.GetSize() > 0)
|
|
{
|
|
m_wndIPCombox.SetCurSel(0);
|
|
m_sIP = arIps.GetAt(0);
|
|
}
|
|
}
|
|
|
|
BOOL CSCWJDlg::InitADOServer()
|
|
{
|
|
m_pMySQLDb = CLJCSDlg::GetSHEarthWormConnect();
|
|
return (m_pMySQLDb != NULL) ? TRUE : FALSE;
|
|
}
|
|
|
|
typedef AcArray<AcGeMatrix3d> AcGeMatrix3dArray;
|
|
void RevGetText(AcDbBlockReference* pRef,AcDbVoidPtrArray& arEntPtrs,AcGeMatrix3dArray& arXforms)
|
|
{
|
|
if (pRef != NULL)
|
|
{
|
|
AcGeMatrix3d xform = pRef->blockTransform();
|
|
AcDbObjectId idRec = pRef->blockTableRecord();
|
|
|
|
AcDbBlockTableRecord* pRec = NULL;
|
|
if ( Acad::eOk == acdbOpenObject((AcDbObject*&)pRec,idRec,AcDb::kForRead) )
|
|
{
|
|
AcDbBlockTableRecordIterator* pIt = NULL;
|
|
pRec->newIterator(pIt);
|
|
|
|
AcDbEntity* pSubEnt = NULL;
|
|
AcDbEntity* pSubCln = NULL;
|
|
|
|
for (pIt->start();!pIt->done();pIt->step())
|
|
{
|
|
if ( Acad::eOk == pIt->getEntity(pSubEnt,AcDb::kForRead) )
|
|
{
|
|
AcDbText* pText = AcDbText::cast(pSubEnt);
|
|
if (pText != NULL)
|
|
{
|
|
//acutPrintf(_T("\n%s"),pText->textStringConst());
|
|
|
|
pSubCln = (AcDbEntity*)pSubEnt->clone();
|
|
pSubCln->transformBy(xform);
|
|
|
|
for (int j = 0;j < arXforms.length();j++)
|
|
{
|
|
pSubCln->transformBy(arXforms.at(j));
|
|
}
|
|
arEntPtrs.append(pSubCln);
|
|
}
|
|
|
|
AcDbMText* pMText = AcDbMText::cast(pSubEnt);
|
|
if (pMText != NULL)
|
|
{
|
|
//acutPrintf(_T("\n%s"),pMText->contents());
|
|
|
|
pSubCln = (AcDbEntity*)pSubEnt->clone();
|
|
pSubCln->transformBy(xform);
|
|
|
|
for (int j = 0;j < arXforms.length();j++)
|
|
{
|
|
pSubCln->transformBy(arXforms.at(j));
|
|
}
|
|
arEntPtrs.append(pSubCln);
|
|
}
|
|
|
|
AcDbBlockReference* pSubRef = AcDbBlockReference::cast(pSubEnt);
|
|
if (pSubRef != NULL)
|
|
{
|
|
AcGeMatrix3dArray arXforms2;
|
|
arXforms2.append(xform);
|
|
RevGetText(pSubRef,arEntPtrs,arXforms2);
|
|
}
|
|
pSubEnt->close();
|
|
}
|
|
}
|
|
pRec->close();
|
|
}
|
|
}
|
|
}
|
|
|
|
bool SortEntX(AcDbEntity* pEnt1,AcDbEntity* pEnt2)
|
|
{
|
|
AcGePoint3d ptPos1,ptPos2;
|
|
|
|
AcDbText* pText1 = AcDbText::cast(pEnt1);
|
|
if (pText1 != NULL)
|
|
{
|
|
ptPos1 = pText1->position();
|
|
}
|
|
|
|
AcDbMText* pMText1 = AcDbMText::cast(pEnt1);
|
|
if (pMText1 != NULL)
|
|
{
|
|
ptPos1 = pMText1->location();
|
|
}
|
|
|
|
//2
|
|
AcDbText* pText2 = AcDbText::cast(pEnt2);
|
|
if (pText2 != NULL)
|
|
{
|
|
ptPos2 = pText2->position();
|
|
}
|
|
|
|
AcDbMText* pMText2 = AcDbMText::cast(pEnt2);
|
|
if (pMText2 != NULL)
|
|
{
|
|
ptPos2 = pMText2->location();
|
|
}
|
|
|
|
if (ptPos1.x < ptPos2.x)
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
void SortToRowCol(AcDbVoidPtrArray& arTxtEntPtrs,std::vector<int>& arYs,CString& sText)
|
|
{
|
|
AcDbEntity* pEnt = NULL;
|
|
std::vector<AcDbEntity*> arRowEnt;
|
|
double nY = 0.0;
|
|
AcGePoint3d ptPos;
|
|
double dH = 0.0;
|
|
|
|
for (int i = 0;i < arYs.size();i++)
|
|
{
|
|
nY = arYs.at(i);
|
|
|
|
arRowEnt.clear();
|
|
for (int ii = 0;ii < arTxtEntPtrs.length();ii++)
|
|
{
|
|
pEnt = (AcDbEntity*)arTxtEntPtrs.at(ii);
|
|
|
|
AcDbText* pText = AcDbText::cast(pEnt);
|
|
if (pText != NULL)
|
|
{
|
|
ptPos = pText->position();
|
|
dH = pText->height();
|
|
}
|
|
|
|
AcDbMText* pMText = AcDbMText::cast(pEnt);
|
|
if (pMText != NULL)
|
|
{
|
|
ptPos = pMText->location();
|
|
dH = pMText->textHeight();
|
|
}
|
|
|
|
if ( fabs(ptPos.y - nY) < 0.5 * dH)
|
|
{
|
|
arRowEnt.push_back(pEnt);
|
|
}
|
|
}
|
|
|
|
std::sort(arRowEnt.begin(),arRowEnt.end(),SortEntX);
|
|
|
|
//提取文本
|
|
CString sLine = _T("{");
|
|
for (int j = 0;j < arRowEnt.size();j++)
|
|
{
|
|
pEnt = (AcDbEntity*)arRowEnt.at(j);
|
|
|
|
AcDbText* pText = AcDbText::cast(pEnt);
|
|
if (pText != NULL)
|
|
{
|
|
sLine += pText->textStringConst();
|
|
}
|
|
|
|
AcDbMText* pMText = AcDbMText::cast(pEnt);
|
|
if (pMText != NULL)
|
|
{
|
|
sLine += pMText->contents();
|
|
}
|
|
sLine += _T(";");
|
|
}
|
|
|
|
//避免uiiadosrv内部冲突,改为[]
|
|
sLine.Replace(_T("("),_T("["));
|
|
sLine.Replace(_T(")"),_T("]"));
|
|
|
|
sText += sLine;
|
|
sText += _T("}");
|
|
}
|
|
}
|
|
|
|
void PickTitleBar(CString& sText)
|
|
{
|
|
//扫描提取
|
|
ads_point pt1, pt2;
|
|
AcDbVoidPtrArray arEntPtrs;
|
|
|
|
int nRes = acedGetPoint(NULL, _T("\n请选择图栏左上角点:"), pt1);
|
|
if (nRes == RTNORM)
|
|
{
|
|
nRes = acedGetCorner(pt1, _T("\n请选择图栏右下角点:"), pt2);
|
|
if (nRes == RTNORM)
|
|
{
|
|
ads_name ss,ent;
|
|
acedSSGet(_T("C"),pt1,pt2,NULL,ss);
|
|
|
|
Adesk::Int32 nLen = 0;
|
|
acedSSLength(ss,&nLen);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
AcDbVoidPtrArray arEntPtrs;
|
|
|
|
AcDbObjectId id;
|
|
for(int i = 0;i < nLen;i++)
|
|
{
|
|
acedSSName(ss,i,ent);
|
|
acdbGetObjectId(id,ent);
|
|
|
|
if ( Acad::eOk == acdbOpenAcDbEntity(pEnt,id,AcDb::kForRead))
|
|
{
|
|
AcDbText* pText = AcDbText::cast(pEnt);
|
|
if (pText != NULL)
|
|
{
|
|
//acutPrintf(_T("\n%s"),pText->textStringConst());
|
|
arEntPtrs.append(pEnt->clone());
|
|
}
|
|
|
|
AcDbMText* pMText = AcDbMText::cast(pEnt);
|
|
if (pMText != NULL)
|
|
{
|
|
//acutPrintf(_T("\n%s"),pMText->contents());
|
|
arEntPtrs.append(pEnt->clone());
|
|
}
|
|
|
|
AcDbBlockReference* pRef = AcDbBlockReference::cast(pEnt);
|
|
if (pRef != NULL)
|
|
{
|
|
AcGeMatrix3dArray arXforms;
|
|
RevGetText(pRef,arEntPtrs,arXforms);
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
acedSSFree(ss);
|
|
|
|
//再次过滤,去除不在框选范围的实体文字
|
|
ads_point pt3;
|
|
AcGePoint3d ptPos;
|
|
double dH = 0.0;
|
|
AcDbVoidPtrArray arGetTxtPtrs;
|
|
std::vector<int> arYs;
|
|
|
|
for (int i = 0; i < arEntPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arEntPtrs.at(i);
|
|
|
|
AcDbText* pText = AcDbText::cast(pEnt);
|
|
if (pText != NULL)
|
|
{
|
|
ptPos = pText->position();
|
|
dH = pText->height();
|
|
}
|
|
|
|
AcDbMText* pMText = AcDbMText::cast(pEnt);
|
|
if (pMText != NULL)
|
|
{
|
|
ptPos = pMText->location();
|
|
dH = pMText->textHeight();
|
|
}
|
|
|
|
acdbWcs2Ucs(asDblArray(ptPos),pt3,false);
|
|
|
|
if (pt3[X] < __max(pt1[X],pt2[X]) &&
|
|
pt3[X] > __min(pt1[X],pt2[X]) &&
|
|
pt3[Y] > __min(pt1[Y],pt2[Y]) &&
|
|
pt3[Y] < __max(pt1[Y],pt2[Y]) )
|
|
{
|
|
arGetTxtPtrs.append(pEnt);
|
|
|
|
//误差为半个dH
|
|
BOOL bFind = FALSE;
|
|
for (int j = 0;j < arYs.size();j++)
|
|
{
|
|
if ( fabs(ptPos.y - arYs.at(j)) < 0.5 * dH)
|
|
{
|
|
bFind = TRUE;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!bFind)
|
|
{
|
|
arYs.push_back( (int)(ptPos.y));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
delete pEnt;
|
|
}
|
|
}
|
|
|
|
//排序 X Y ,分行,提取文本
|
|
std::sort(arYs.begin(),arYs.end());
|
|
SortToRowCol(arGetTxtPtrs,arYs,sText);
|
|
|
|
FreeBuffer(0,arGetTxtPtrs);
|
|
}
|
|
}
|
|
}
|
|
|
|
//添加标题栏
|
|
void CSCWJDlg::OnBnClickedButton1()
|
|
{
|
|
EnableWindow(FALSE);
|
|
CWnd* pFrame = acedGetAcadFrame();
|
|
pFrame->EnableWindow(TRUE);
|
|
ShowWindow(SW_HIDE);
|
|
pFrame->SetFocus();
|
|
|
|
CString sText;
|
|
PickTitleBar(sText);
|
|
|
|
if (!sText.IsEmpty())
|
|
{
|
|
m_wndListBox.AddString(sText);
|
|
}
|
|
|
|
pFrame->EnableWindow(FALSE);
|
|
ShowWindow(SW_SHOW);
|
|
EnableWindow(TRUE);
|
|
}
|
|
|
|
//删除标题栏
|
|
void CSCWJDlg::OnBnClickedButton9()
|
|
{
|
|
int nItem = m_wndListBox.GetCurSel();
|
|
if (nItem != -1)
|
|
{
|
|
m_wndListBox.DeleteString(nItem);
|
|
}
|
|
}
|
|
|
|
//修改
|
|
void CSCWJDlg::OnBnClickedButton5()
|
|
{
|
|
int nItem = m_wndListBox.GetCurSel();
|
|
if (nItem != -1)
|
|
{
|
|
CString sText;
|
|
m_wndListBox.GetText(nItem,sText);
|
|
|
|
CTextDlg dlg;
|
|
dlg.m_sText = sText;
|
|
if (IDOK == dlg.DoModal())
|
|
{
|
|
sText = dlg.m_sText;
|
|
m_wndListBox.DeleteString(nItem);
|
|
m_wndListBox.InsertString(nItem,sText);
|
|
}
|
|
}
|
|
}
|
|
|
|
void CSCWJDlg::OnBnClickedOk()
|
|
{
|
|
UpdateData();
|
|
|
|
CString sSQL;
|
|
|
|
//先判断账号是否存在
|
|
sSQL.Format(_T("select * from Aec_Employees where IP like '%s'"),m_sIP);
|
|
if (m_pMySQLDb->IsSelEmpty(sSQL))
|
|
{
|
|
AfxMessageBox(_T("IP对应的账号没有创建,请先创建账号!"));
|
|
return;
|
|
}
|
|
|
|
CString sTxt;
|
|
m_sTitles = _T("");
|
|
for (int i = 0;i < m_wndListBox.GetCount();i++)
|
|
{
|
|
m_wndListBox.GetText(i,sTxt);
|
|
|
|
if (!sTxt.IsEmpty())
|
|
{
|
|
m_sTitles += sTxt;
|
|
m_sTitles += _T("|");
|
|
}
|
|
}
|
|
m_sTitles.TrimRight(_T('|'));
|
|
if (m_sTitles.IsEmpty())
|
|
{
|
|
AfxMessageBox(_T("图签栏不能为空,请选择图纸图签栏!"));
|
|
return;
|
|
}
|
|
|
|
CTime tCur = CTime::GetCurrentTime();
|
|
CString sTime = tCur.Format(_T("%Y-%m-%d:%H-%M-%S"));
|
|
CString sGuid = IDCreate();
|
|
|
|
CString sDwgFile = curDoc()->fileName();
|
|
CString sFileName,sTip,sTmp;
|
|
|
|
struct resbuf rb;
|
|
acedGetVar(_T("acadver"),&rb);
|
|
|
|
CString sAcadver = rb.resval.rstring;
|
|
CString sDwgNewFile = sDwgFile;
|
|
|
|
sDwgNewFile.MakeLower();
|
|
sDwgNewFile.Replace(_T(".dwg"),_T("$.dwg"));
|
|
|
|
if ( ::CopyFile(sDwgFile,sDwgNewFile,FALSE) )
|
|
{
|
|
CString sDwgZipFile = sDwgNewFile;
|
|
sDwgZipFile.Replace(_T("$.dwg"),_T(".zip"));
|
|
|
|
CFileFind find1;
|
|
if (find1.FindFile(sDwgZipFile))
|
|
{
|
|
::DeleteFile(sDwgZipFile);
|
|
}
|
|
|
|
if ( CoreTools::ZipFile(sDwgNewFile,sDwgZipFile) )
|
|
{
|
|
int nPos = sDwgZipFile.ReverseFind(_T('\\'));
|
|
if (nPos != -1)
|
|
{
|
|
sFileName = sDwgZipFile.Mid(nPos + 1);
|
|
}
|
|
|
|
//去除InsertBlob 冲突的关键字
|
|
m_sAuthor.Replace(_T('('),_T('<'));
|
|
m_sAuthor.Replace(_T(')'),_T('>'));
|
|
m_sAuthor.Replace(_T('.'),_T('-'));
|
|
|
|
m_sPro.Replace(_T('('),_T('<'));
|
|
m_sPro.Replace(_T(')'),_T('>'));
|
|
m_sPro.Replace(_T('.'),_T('-'));
|
|
|
|
m_sProName.Replace(_T('('),_T('<'));
|
|
m_sProName.Replace(_T(')'),_T('>'));
|
|
m_sProName.Replace(_T('.'),_T('-'));
|
|
|
|
m_sProNo.Replace(_T('('),_T('<'));
|
|
m_sProNo.Replace(_T(')'),_T('>'));
|
|
m_sProNo.Replace(_T('.'),_T('-'));
|
|
|
|
m_sSubProName.Replace(_T('('),_T('<'));
|
|
m_sSubProName.Replace(_T(')'),_T('>'));
|
|
m_sSubProName.Replace(_T('.'),_T('-'));
|
|
|
|
m_sTitles.Replace(_T('('),_T('<'));
|
|
m_sTitles.Replace(_T(')'),_T('>'));
|
|
m_sTitles.Replace(_T('.'),_T(' '));
|
|
|
|
m_sKeyword.Replace(_T('('),_T('<'));
|
|
m_sKeyword.Replace(_T(')'),_T('>'));
|
|
m_sKeyword.Replace(_T('.'),_T(' '));
|
|
|
|
m_sRem.Replace(_T('('),_T('<'));
|
|
m_sRem.Replace(_T(')'),_T('>'));
|
|
m_sRem.Replace(_T('.'),_T(' '));
|
|
|
|
sAcadver.Replace(_T('('),_T('<'));
|
|
sAcadver.Replace(_T(')'),_T('>'));
|
|
sAcadver.Replace(_T('.'),_T(' '));
|
|
|
|
BOOL bSuccess = FALSE;
|
|
sSQL.Format(_T("insert into AEC_ProDrawing (Designer,ProName,IP,FileName,GUID,ProTitle,ProNo,SubProTitle,Rem,RevTxt,keywords,acadver,Package) values \
|
|
('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s',?)"),m_sAuthor,m_sPro,m_sIP,sFileName,sGuid,
|
|
m_sProName,m_sProNo,m_sSubProName,m_sRem,_T("*"),m_sKeyword,sAcadver);
|
|
|
|
//acutPrintf(_T("\nchlen=%d"),m_sTitles.GetLength());
|
|
|
|
if ( m_pMySQLDb->InsertBlob(sSQL,sDwgZipFile) > 0)
|
|
{
|
|
sSQL.Format(_T("update AEC_ProDrawing set Package=? where GUID='%s'"),sGuid);
|
|
bSuccess = m_pMySQLDb->UpdateBlob(sSQL,sDwgNewFile);
|
|
if (bSuccess == 0)
|
|
{
|
|
sSQL.Format(_T("update AEC_ProDrawing set Titles='%s' where GUID='%s'"),m_sTitles,sGuid);
|
|
bSuccess = m_pMySQLDb->ExecuteSQL(sSQL);
|
|
}
|
|
}
|
|
|
|
//acutPrintf(_T("\n%d:"),m_sTitles.GetLength() * sizeof(TCHAR));
|
|
|
|
if (bSuccess )
|
|
{
|
|
AfxMessageBox(_T("当前图纸上传备档成功!"));
|
|
EndDialog(IDOK);
|
|
}
|
|
else
|
|
{
|
|
sTmp = sSQL;
|
|
sTip.Format(_T("当前图纸上传备档失败!ERROR:%s"),sTmp);
|
|
AfxMessageBox(sTip);
|
|
|
|
CString sErrorFile = sFileName;
|
|
sErrorFile.Replace(_T(".zip"),_T(".txt"));
|
|
|
|
CString sSQLFile = FilePath::GetSysDir();
|
|
sSQLFile += _T("\\");
|
|
sSQLFile += sErrorFile;
|
|
|
|
UINT nMode = CFile::modeCreate|CFile::modeWrite;
|
|
CFileFind find2;
|
|
if (find2.FindFile(sSQLFile))
|
|
{
|
|
nMode = CFile::modeWrite;
|
|
}
|
|
|
|
CStdioFile file;
|
|
if (file.Open(sSQLFile,nMode))
|
|
{
|
|
file.SeekToEnd();
|
|
file.WriteString(sTmp);
|
|
file.WriteString(_T("\n"));
|
|
file.Close();
|
|
}
|
|
}
|
|
|
|
CFileFind find;
|
|
if (find.FindFile(sDwgZipFile))
|
|
{
|
|
//::DeleteFile(sDwgZipFile);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AfxMessageBox(_T("当前图纸压缩失败,备档失败!"));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AfxMessageBox(_T("文件备份复制失败,当前图纸上传备档失败!"));
|
|
}
|
|
|
|
CFileFind find;
|
|
if (find.FindFile(sDwgNewFile))
|
|
{
|
|
::DeleteFile(sDwgNewFile);
|
|
}
|
|
}
|
|
|
|
bool PickText(CString& sTxt)
|
|
{
|
|
ads_name ent;
|
|
ads_point pt;
|
|
ads_matrix xformres;
|
|
int pickflag = 0;
|
|
struct resbuf* pRb = NULL;
|
|
|
|
int nRes = acedNEntSelP(_T("\n请选择图面文字:"),ent,pt,pickflag,xformres,&pRb);
|
|
|
|
if (nRes == RTNORM)
|
|
{
|
|
AcDbObjectId id;
|
|
acdbGetObjectId(id,ent);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
if (Acad::eOk == acdbOpenAcDbEntity(pEnt,id,AcDb::kForRead))
|
|
{
|
|
AcDbText* pText = AcDbText::cast(pEnt);
|
|
if (pText != NULL)
|
|
{
|
|
sTxt = pText->textStringConst();
|
|
}
|
|
|
|
AcDbMText* pMText = AcDbMText::cast(pEnt);
|
|
if (pMText != NULL)
|
|
{
|
|
TCHAR* pTxt = pMText->contents();
|
|
if (pTxt != NULL)
|
|
{
|
|
sTxt = pTxt;
|
|
acutDelString(pTxt);
|
|
}
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
if (pRb != NULL) acutRelRb(pRb);
|
|
|
|
return sTxt.IsEmpty() ? false : true;
|
|
}
|
|
|
|
//项目名称
|
|
void CSCWJDlg::OnBnClickedButton2()
|
|
{
|
|
UpdateData();
|
|
|
|
EnableWindow(FALSE);
|
|
CWnd* pFrame = acedGetAcadFrame();
|
|
pFrame->EnableWindow(TRUE);
|
|
ShowWindow(SW_HIDE);
|
|
pFrame->SetFocus();
|
|
|
|
PickText(m_sProName);
|
|
|
|
pFrame->EnableWindow(FALSE);
|
|
ShowWindow(SW_SHOW);
|
|
EnableWindow(TRUE);
|
|
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
//项目编号
|
|
void CSCWJDlg::OnBnClickedButton7()
|
|
{
|
|
UpdateData();
|
|
|
|
EnableWindow(FALSE);
|
|
CWnd* pFrame = acedGetAcadFrame();
|
|
pFrame->EnableWindow(TRUE);
|
|
ShowWindow(SW_HIDE);
|
|
pFrame->SetFocus();
|
|
|
|
PickText(m_sProNo);
|
|
|
|
pFrame->EnableWindow(FALSE);
|
|
ShowWindow(SW_SHOW);
|
|
EnableWindow(TRUE);
|
|
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
//子项名称
|
|
void CSCWJDlg::OnBnClickedButton10()
|
|
{
|
|
UpdateData();
|
|
|
|
EnableWindow(FALSE);
|
|
CWnd* pFrame = acedGetAcadFrame();
|
|
pFrame->EnableWindow(TRUE);
|
|
ShowWindow(SW_HIDE);
|
|
pFrame->SetFocus();
|
|
|
|
PickText(m_sSubProName);
|
|
|
|
pFrame->EnableWindow(FALSE);
|
|
ShowWindow(SW_SHOW);
|
|
EnableWindow(TRUE);
|
|
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
//设计
|
|
void CSCWJDlg::OnBnClickedButton11()
|
|
{
|
|
UpdateData();
|
|
|
|
EnableWindow(FALSE);
|
|
CWnd* pFrame = acedGetAcadFrame();
|
|
pFrame->EnableWindow(TRUE);
|
|
ShowWindow(SW_HIDE);
|
|
pFrame->SetFocus();
|
|
|
|
PickText(m_sAuthor);
|
|
|
|
pFrame->EnableWindow(FALSE);
|
|
ShowWindow(SW_SHOW);
|
|
EnableWindow(TRUE);
|
|
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CSCWJDlg::OnBnClickedButton12()
|
|
{
|
|
UpdateData();
|
|
|
|
EnableWindow(FALSE);
|
|
CWnd* pFrame = acedGetAcadFrame();
|
|
pFrame->EnableWindow(TRUE);
|
|
ShowWindow(SW_HIDE);
|
|
pFrame->SetFocus();
|
|
|
|
PickText(m_sKeyword);
|
|
|
|
pFrame->EnableWindow(FALSE);
|
|
ShowWindow(SW_SHOW);
|
|
EnableWindow(TRUE);
|
|
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CSCWJDlg::OnBnClickedButton8()
|
|
{
|
|
UpdateData();
|
|
|
|
CZHDLDlg dlg;
|
|
dlg.m_bCreate = TRUE;
|
|
dlg.m_sIP = m_sIP;
|
|
dlg.m_sName = m_sAuthor;
|
|
dlg.m_sProName = m_sPro;
|
|
dlg.DoModal();
|
|
}
|