KmgReader.cpp
上传用户:hell82222
上传日期:2013-12-19
资源大小:1872k
文件大小:3k
- // KmgReader.cpp: implementation of the CKmgReader class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "FileSwitch.h"
- #include "KmgReader.h"
- #include "Database.h"
- #include "Reader.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- extern CStdioFile g_CensorialFile; //监察转换进度的文件
- extern int g_mode;
- CKmgReader::CKmgReader(CProgressInfo* pProgress,CCommandInfo* pCommand,CDwgConverter* pConverter)
- {
- m_pProgress = pProgress;
- m_pCommand = pCommand;
- m_pConverter = pConverter;
- }
- CKmgReader::~CKmgReader()
- {
- }
- BOOL CKmgReader::BeginConvert() //转换开始的初始化.
- {
- _WRITE(str="ttKMG图形文件转换为DWG图形文件转换信息记录n");
- _WRITE(str="成功启动转换服务,等待接受任务中...");
- return TRUE;
- }
- BOOL CKmgReader::Parse() //分析文件的主函数.
- {
- _WRITE(str="n接收到新任务...");
- _WRITE(str.Format("KMG文件路径:%s",m_pCommand->m_strSourceName));
- _WRITE(str.Format("DWG文件路径:%s",m_pCommand->m_strAimName));
- m_pProgress->SetProgressInfoAbsolute(0.01,"初始化...");
- TCHAR szFileName[MAX_PATH];
- ::GetModuleFileName(GetModuleHandle("fileswitch.dll"),szFileName,MAX_PATH);
- (*_tcsrchr(szFileName,'\'))=' ';
- _tcscat(szFileName,_T("\support\init.dat"));
- //short adInitAd2 _((const char * initfilepath, short *initerror));
- if(!adInitAd2(szFileName,&sReturnValue))
- {
- _WRITE(str="初始化失败,无法启动转换服务");
- _ERROR;
- return FALSE;
- }
- m_pProgress->SetProgressInfoAbsolute(0.02,"初始化...");
- if(!m_pConverter->BeginConverter())
- {
- _WRITE(str="转换服务启动失败");
- //void adCloseAd2();
- adCloseAd2();
- return FALSE;
- }
- CKmDataManager* pData=new CKmDataManager;
- ::SetActiveDataManager(pData);
- pData->Init();
- ::SetActiveDataManager(pData);
- BOOL bAllowReadOld=TRUE;
- if(!pData->LoadFile(m_pCommand->m_strSourceName,bAllowReadOld))
- {
- _WRITE(str="无法读取源文件");
- if(!m_pConverter->EndConverter())
- {
- _WRITE(str="转换服务关闭失败");
- delete pData;
- //void adCloseAd2();
- adCloseAd2();
- return FALSE;
- }
- delete pData;
- //void adCloseAd2();
- adCloseAd2();
- return FALSE;
- }
- BOOL bProcessed=TRUE;
- if(!(bProcessed=processfile(pData)))
- {
- _WRITE(str="转换失败");
- if(!m_pConverter->EndConverter())
- {
- _WRITE(str="转换服务关闭失败");
- delete pData;
- //void adCloseAd2();
- adCloseAd2();
- return FALSE;
- }
- delete pData;
- //void adCloseAd2();
- adCloseAd2();
- return FALSE;
- }
- if(!m_pConverter->EndConverter())
- {
- _WRITE(str="转换服务关闭失败");
- delete pData;
- //void adCloseAd2();
- adCloseAd2();
- return FALSE;
- }
- delete pData;
-
- m_aColor.RemoveAll();
- m_altype.ReInit();
- m_alayer.ReInit();
- m_ablock.ReInit();
- m_ashape.ReInit();
- m_adimstyle.ReInit();
- m_awordstyle.ReInit();
-
- //void adCloseAd2();
- adCloseAd2();
- return TRUE;
- }
- BOOL CKmgReader::EndConvert() //结束转换.
- {
- _WRITE(str="转换服务被关闭");
- return TRUE;
- }