⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 step11.cpp

📁 mcgs的数据导出源代码
💻 CPP
字号:
// Step11.cpp : implementation file
//

#include "stdafx.h"
#include "Data_Trans.h"
#include "Data_TransDlg.h"
#include "Step11.h"
#include "VirtualInfoFile.h"
#include "FileDialogST.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CStep11 dialog


CStep11::CStep11(CWnd* pParent /*=NULL*/)
	: CDialog(CStep11::IDD, pParent)
{
	//{{AFX_DATA_INIT(CStep11)
	m_FileName = _T("");
	//}}AFX_DATA_INIT
	m_Dlg = (CData_TransDlg*)pParent;
	m_bTure = false;
}


void CStep11::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CStep11)
	DDX_Text(pDX, IDC_EDIT1, m_FileName);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CStep11, CDialog)
	//{{AFX_MSG_MAP(CStep11)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_TEST, OnTest)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CStep11 message handlers
#include "zlib.h"
void CStep11::OnButton1() 
{
	// TODO: Add your control notification handler code here
	// TODO: Add your control notification handler code here
	CFileDialogST	dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_ALLOWMULTISELECT, _T("All files\0*.*\0"), this);
	CString			sPathName;
	int				nRetValue;

	nRetValue = dlg.DoModal();
	if (nRetValue == IDOK)
	{
		POSITION	Pos;

		Pos = dlg.GetStartPosition();
		while (Pos != NULL)
		{
			sPathName = dlg.GetNextPathName(Pos);
		} // while
	} // if
	else
	{
		return ;
	}
	m_FileName = sPathName;
	CData_TransApp* pApp = (CData_TransApp*)AfxGetApp();
	m_FilePath = pApp->McgsGetPath(m_FileName);
	m_FilePath += "\\database";
	UpdateData(FALSE);
	// TODO: Add your control notification handler code here
	//默认的名称
	//对文件进行操作
	CFile file;
	try
	{
		CString strFileName;
		int iPos1 = m_FileName.ReverseFind(_T('\\'));
		strFileName = m_FileName.Mid( iPos1+1 );
		//if (strFileName.CompareNoCase( "BECCA_DATA.ini") != 0)
		if (strFileName.CompareNoCase("Urtedata.usi") != 0)
		{
			AfxMessageBox("please choose file name is Urtedata.usi");
			m_Dlg->SetWizButton(4);
			return ;
		}
		if( !file.Open( m_FileName , CFile::modeRead ) )
		{
			m_Dlg->SetWizButton(4);
			return;
		}
		//清楚原来的索引信息
		for (int i=0;i<m_Dlg->m_arrayInfoFile.GetSize();++i)
		{
			delete m_Dlg->m_arrayInfoFile[i];
		}
		m_Dlg->m_arrayInfoFile.RemoveAll();
		CByteArray Buff;
		Buff.SetSize(file.GetLength());
		file.Read(Buff.GetData(),file.GetLength());
		COwnerArchive ar(COwnerArchive::storing);
		ar.SvrWrite (Buff);
		ar.SvrSeekToBegin ();
		ar.SvrChangeMode (COwnerArchive::load);
		
		int Size ;
		ar >> Size;	//对象数目
		m_Dlg->m_arrayInfoFile.SetSize(Size);		
		m_Dlg->m_strArray.SetSize(Size);
		if(Size != 1)
		{
			AfxMessageBox(_T("该版本为临时版本,只能导出只有一个组对象的工程数据!"));
			return;
		}
		for (i=0; i<Size; ++i)
		{
			CString DataName;
			ar >> DataName;	//对象名
			m_Dlg->m_arrayInfoFile[i] = new CVirtualInfoFile(DataName);
			int idsize;		
			ar >> idsize;	//对象的成员数
			m_Dlg->m_arrayInfoFile[i]->m_GrpObjInfo.SetSize(idsize+2);
			{	//添加毫秒和秒
	
				//m_Dlg->m_arrayInfoFile[i]->m_GrpObjInfo[0].m_name = "MCGS_Time";
				m_Dlg->m_arrayInfoFile[i]->m_GrpObjInfo[0].m_name = "Becca_Time";
				m_Dlg->m_arrayInfoFile[i]->m_GrpObjInfo[0].m_type = 10;	
				m_Dlg->m_arrayInfoFile[i]->m_GrpObjInfo[1].m_name = "Becca_TimeMS";
				m_Dlg->m_arrayInfoFile[i]->m_GrpObjInfo[1].m_type = 1;		
			}
			CString strName;
			for (int j=0;j<idsize;++j)
			{
				int iType;
				ar >> iType;
				ar >> strName;	
				m_Dlg->m_arrayInfoFile[i]->m_GrpObjInfo[j+2].m_name = strName;
				m_Dlg->m_arrayInfoFile[i]->m_GrpObjInfo[j+2].m_type = iType;
				m_Dlg->m_strArray[i].Add(strName);
			}
			CByteArray BuffTemp;
			//处理读到的buff,看看是不是压缩过的
			DWORD szdata = ar.SvrGetRealBufferSize() - ar.SvrGetBufferSize();
			CByteArray dataBuff;
			dataBuff.SetSize(szdata);
			ar.SvrRead(dataBuff);
			if(dataBuff.GetSize() > 2 * sizeof(long))
			{
				long lHead = 123456;
				memcpy(&lHead,dataBuff.GetData(),sizeof(long));
				if(lHead == 0)
				{
					//这是一份压缩后的数据,需要先做解压缩处理
					//取出解压缩后的长度信息
					unsigned long iOriginSize = 0;
					memcpy(&iOriginSize,dataBuff.GetData() + sizeof(long),sizeof(long));
					BuffTemp.SetSize(iOriginSize);
					uncompress(BuffTemp.GetData(),&iOriginSize,dataBuff.GetData() + 2 * sizeof(long),
						dataBuff.GetSize() - 2 * sizeof(long) );
				}	
				else
				{
					BuffTemp.SetSize(dataBuff.GetSize());
					memcpy(BuffTemp.GetData(),dataBuff.GetData(),dataBuff.GetSize());
				}
			}
			else
			{
				BuffTemp.SetSize(dataBuff.GetSize());
				memcpy(BuffTemp.GetData(),dataBuff.GetData(),dataBuff.GetSize());
			}
			COwnerArchive arTemp(COwnerArchive::storing);
			arTemp.SvrWrite (BuffTemp);
			arTemp.SvrSeekToBegin ();
			arTemp.SvrChangeMode (COwnerArchive::load);
			int FileNum;
			arTemp >> m_Dlg->m_arrayInfoFile[i]->m_timeEnd;
			arTemp >> m_Dlg->m_arrayInfoFile[i]->m_timeStart;
			arTemp >> FileNum;
			for (j=0; j<FileNum;++j)
			{
				CVirtualSaveStruct c;
				c.m_strGroupObjName = DataName;
				c.m_strDataSavePath = m_FilePath;
				c.Serialize (arTemp);
				m_Dlg->m_arrayInfoFile[i]->m_arraySaveInfo.Add(c);
			}
		}
	}
	catch(CException* e)
	{
		e->Delete();
		file.Close();
		return ;
	}
	m_bTure = true;
	m_Dlg->SetWizButton(0);

}

void CStep11::OnTest() 
{

	
}

void CStep11::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	if (m_bTure)
	{
		m_Dlg->SetWizButton(0);
	}
	m_Dlg->m_Type = 1;
	// Do not call CDialog::OnPaint() for painting messages
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -