123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- #include "stdafx.h"
- #include "OTSLicenseInfo.h"
- namespace OTSDATA {
- // license info class
- // used to handle license information
- IMPLEMENT_SERIAL(COTSLicenseInfo, CObject, 1)
- // constructor
- COTSLicenseInfo::COTSLicenseInfo()
- {
- Init();
- }
- // copy constructor
- COTSLicenseInfo::COTSLicenseInfo(const COTSLicenseInfo& a_oSource)
- {
- // can't copy itself
- if (&a_oSource == this)
- {
- return;
- }
- // copy data over
- Duplicate(a_oSource);
- }
- // copy constructor
- COTSLicenseInfo::COTSLicenseInfo(COTSLicenseInfo* a_poSource)
- {
- // input check
- ASSERT(a_poSource);
- if (!a_poSource)
- {
- return;
- }
- // can't copy itself
- if (a_poSource == this)
- {
- return;
- }
- // copy data over
- Duplicate(*a_poSource);
- }
- // =operator
- COTSLicenseInfo& COTSLicenseInfo::operator=(const COTSLicenseInfo& a_oSource)
- {
- // cleanup
- Cleanup();
- // copy the class data over
- Duplicate(a_oSource);
- // return class
- return *this;
- }
- // ==operator
- BOOL COTSLicenseInfo::operator==(const COTSLicenseInfo& a_oSource)
- {
- return m_strMachineId.Compare(a_oSource.m_strMachineId) == 0 &&
- m_nPackId == a_oSource.m_nPackId &&
- m_nLicType == a_oSource.m_nLicType &&
- m_oExpireDate == a_oSource.m_oExpireDate &&
- m_strComputerNickName.Compare(a_oSource.m_strComputerNickName) == 0;
- }
- // detractor
- COTSLicenseInfo::~COTSLicenseInfo()
- {
- // cleanup
- Cleanup();
- }
- // COTSLicenseInfo member functions
- // serialization
- void COTSLicenseInfo::Serialize(CArchive& ar)
- {
- // store?
- if (ar.IsStoring())
- {
- // store
- ar << m_strMachineId;
- ar << (int)m_nPackId;
- ar << (int)m_nLicType;
- ar << m_oExpireDate;
- ar << m_strComputerNickName;
- }
- else
- {
- // load
- ar >> m_strMachineId;
- int nTemp;
- ar >> nTemp;
- m_nPackId = (OTS_SOFT_PACKAGE_ID)nTemp;
- ar >> nTemp;
- m_nLicType = (OTS_LICENSE_TYPE)nTemp;
- ar >> m_oExpireDate;
- ar >> m_strComputerNickName;
- }
- // base object serialization
- CObject::Serialize(ar);
- }
- void COTSLicenseInfo::Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode)
- {
- xmls::xString xstrMachineId;
- xmls::xInt xnPackId;
- xmls::xInt xnLicType;
- xmls::xOleDateTime xoExpireDate;
- xmls::xString xstrComputerNickName;
- this->Register("MachineId", &xstrMachineId);
- this->Register("PackId", &xnPackId);
- this->Register("LicType", &xnLicType);
- this->Register("ExpireDate", &xoExpireDate);
- this->Register("ComputerNickName", &xstrComputerNickName);
- if (isStoring)
- {
- xstrMachineId = m_strMachineId;
- xnPackId = (int)m_nPackId;
- xnLicType = (int)m_nLicType;
- xoExpireDate = m_oExpireDate;
- xstrComputerNickName = m_strComputerNickName;
- Slo::Serialize(true, classDoc, rootNode);
- }
- else
- {
- xmls::Slo::Serialize(false, classDoc, rootNode);
- m_strMachineId = xstrMachineId.value().c_str();
- m_nPackId = (OTS_SOFT_PACKAGE_ID)xnPackId.value();
- m_nLicType = (OTS_LICENSE_TYPE)xnLicType.value();
- m_oExpireDate = xoExpireDate.value();
- m_strComputerNickName = xstrComputerNickName.value().c_str();
- }
- }
- // protected:
- // cleanup
- void COTSLicenseInfo::Cleanup()
- {
- // nothing needs to be done at the moment
- }
- // initialization
- void COTSLicenseInfo::Init()
- {
- m_strMachineId = _T("");
- m_nPackId = OTS_SOFT_PACKAGE_ID::OTSIncA;
- m_nLicType = OTS_LICENSE_TYPE::Offline;
- m_oExpireDate = COleDateTime::GetCurrentTime();
- m_strComputerNickName = _T("");
- }
- // duplication
- void COTSLicenseInfo::Duplicate(const COTSLicenseInfo& a_oSource)
- {
- // initialization
- Init();
- // copy data over
- m_strMachineId = a_oSource.m_strMachineId;
- m_nPackId = a_oSource.m_nPackId;
- m_nLicType = a_oSource.m_nLicType;
- m_oExpireDate = a_oSource.m_oExpireDate;
- m_strComputerNickName = a_oSource.m_strComputerNickName;
- }
- }
|