class TJJXMLDocument
{
public:
__fastcall TJJXMLDocument(TXMLDocument* XMLDoc,
String Software,
String Method,
int DocumentVersion);
__fastcall ~TJJXMLDocument();
protected:
bool m_Connected;
TXMLDocument* m_XMLDoc;
String m_Software; // 软件名称
String m_Method; // 最高祖先节点
int m_DocumentVersion;
private:
virtual bool __fastcall Encode()=0;
virtual bool __fastcall Decode()=0;
public:
bool __fastcall SaveToFile(TFileName FileName); // 保存
bool __fastcall LoadFromFile(TFileName FileName); // 读取
};
//---------------------------------------------------------------------------
__fastcall TJJXMLDocument::TJJXMLDocument(TXMLDocument* XMLDoc,
String Software,
String Method,
int DocumentVersion)
: m_XMLDoc(XMLDoc),
m_Software(Software),
m_Method(Method),
m_DocumentVersion(DocumentVersion)
{
}
//---------------------------------------------------------------------------
__fastcall TJJXMLDocument::~TJJXMLDocument()
{
m_XMLDoc = NULL;
}
//---------------------------------------------------------------------------
bool __fastcall TJJXMLDocument::SaveToFile(TFileName FileName) // 保存
{
bool Result = false;
try {
if ( Encode() )
{
m_XMLDoc->SaveToFile(FileName);
Result = true;
}
}catch(...){
}
return Result;
}
//---------------------------------------------------------------------------
bool __fastcall TJJXMLDocument::LoadFromFile(TFileName FileName) // 读取
{
bool Result = false;
try {
m_XMLDoc->LoadFromFile(FileName);
Result = Decode();
}catch(...){
}
return Result;
}
// ========================================================================================================
// ========================================================================================================
// ========================================================================================================
// ========================================================================================================
class TXMLOnlineUpdate : public TJJXMLDocument
{
public:
__fastcall TXMLOnlineUpdate(TXMLDocument* XMLDoc, String Software);
__fastcall ~TXMLOnlineUpdate();
public: // 信息清单
void __fastcall Init(); // 被成员变量进行初始化,同时在读信息失败时的原始化恢复
// === (淘汰的发布版本) ==============================================================================
// WashOut
int wso_WashOutVersion; // 已被淘汰的版本号 - WashOutVersion
// === (正式的发布版本) ==============================================================================
// Release
String rls_VersionString; // 完整版本号字符串 - VersionString
int rls_ExecuteFileVersion; // 可执行文件版本号 - ExecuteFileVersion
int rls_DatabaseFileVersion; // 数据库文件版本号 - DatabaseFileVersion
String rls_ExecuteFileURL; // 文件下载 URL - ExecuteFileURL
String rls_EXEFileName; // 可执行文件名
String rls_DatabaseFileURL; // 文件下载 URL - DatabaseFileURL
String rls_DBFFileName; // 数据库文件名
String rls_PackageDownloadURL; // 完整软件包下载 URL - PackageDownloadURL
// === (最新的测试版本) ==============================================================================
// Debug
String dbg_VersionString; // 完整版本号字符串 - VersionString
int dbg_ExecuteFileVersion; // 可执行文件版本号 - ExecuteFileVersion
int dbg_DatabaseFileVersion; // 数据库文件版本号 - DatabaseFileVersion
String dbg_ExecuteFileURL; // 文件下载 URL - ExecuteFileURL
String dbg_EXEFileName; // 可执行文件名
String dbg_DatabaseFileURL; // 文件下载 URL - DatabaseFileURL
String dbg_DBFFileName; // 数据库文件名
String dbg_PackageDownloadURL; // 完整软件包下载 URL - PackageDownloadURL
private:
virtual bool __fastcall Decode(); // 从 XML 中解码
virtual bool __fastcall Encode(); // 编码写入 XML
public:
bool __fastcall JudgeEXEVersion(int CurrentEXEVersion); // 确定是否需要升级
bool __fastcall JudgeDBFVersion(int CurrentDBFVersion); // 确定是否需要升级
bool __fastcall JudgeAlphaStageProducts_EXE(int CurrentEXEVersion); // 确定是否存在更新的测试版
bool __fastcall JudgeAlphaStageProducts_DBF(int CurrentDBFVersion); // 确定是否存在更新的测试版
};
__fastcall TXMLOnlineUpdate::TXMLOnlineUpdate(TXMLDocument* XMLDoc, String Software)
: TJJXMLDocument(XMLDoc, Software, "OnlineUpdate", 1)
{
Init();
}
//---------------------------------------------------------------------------
__fastcall TXMLOnlineUpdate::~TXMLOnlineUpdate()
{
}
//---------------------------------------------------------------------------
void __fastcall TXMLOnlineUpdate::Init() // 被成员变量进行初始化,同时在读信息失败时的原始化恢复
{
// === (淘汰的发布版本) ==============================================================================
// WashOut
wso_WashOutVersion = 0; // 已被淘汰的版本号 - WashOutVersion
// === (正式的发布版本) ==============================================================================
// Release
rls_VersionString = "0.0.0.0"; // 完整版本号字符串 - VersionString
rls_ExecuteFileVersion = 0; // 可执行文件版本号 - ExecuteFileVersion
rls_DatabaseFileVersion = 0; // 数据库文件版本号 - DatabaseFileVersion
rls_ExecuteFileURL = ""; // 文件下载 URL - ExecuteFileURL
rls_EXEFileName = "";
rls_DatabaseFileURL = ""; // 文件下载 URL - DatabaseFileURL
rls_DBFFileName = "";
rls_PackageDownloadURL = ""; // 完整软件包下载 URL - PackageDownloadURL
// === (最新的测试版本) ==============================================================================
// Debug
dbg_VersionString = "0.0.0.0"; // 完整版本号字符串 - VersionString
dbg_ExecuteFileVersion = 0; // 可执行文件版本号 - ExecuteFileVersion
dbg_DatabaseFileVersion = 0; // 数据库文件版本号 - DatabaseFileVersion
dbg_ExecuteFileURL = ""; // 文件下载 URL - ExecuteFileURL
dbg_EXEFileName = "";
dbg_DatabaseFileURL = ""; // 文件下载 URL - DatabaseFileURL
dbg_DBFFileName = "";
dbg_PackageDownloadURL = ""; // 完整软件包下载 URL - PackageDownloadURL
}
//---------------------------------------------------------------------------
bool __fastcall TXMLOnlineUpdate:
ecode()
{
if ( ! m_XMLDoc->Active )
{
try {
m_XMLDoc->Active = true;
}catch(...){
return false;
}
}
Init();
_di_IXMLNode NodeSoftware;
_di_IXMLNode NodeWashOut;
_di_IXMLNode NodeVersion;
_di_IXMLNode NodeDebug;
_di_IXMLNode Node;
NodeSoftware = m_XMLDoc->ChildNodes->FindNode(m_Software);
if ( NodeSoftware )
{
String s;
s = NodeSoftware->GetAttribute("Method");
if ( s == "OnlineUpdate" )
{
m_Method = s;
s = NodeWashOut->GetAttribute("Version");
if ( m_DocumentVersion >= s.ToIntDef(0) );
{
m_DocumentVersion = s.ToIntDef(0);
NodeWashOut = NodeSoftware->ChildNodes->FindNode("WashOut");
if ( NodeWashOut )
{
s = NodeWashOut->GetAttribute("Version");
wso_WashOutVersion = s.ToIntDef(0);
}
NodeVersion = NodeSoftware->ChildNodes->FindNode("Release");
if ( NodeVersion )
{
rls_VersionString = NodeVersion->GetAttribute("Version");
Node = NodeVersion->ChildNodes->FindNode("ExecuteFile");
if ( Node )
{
rls_ExecuteFileVersion = Node->GetAttribute("Version" );
rls_ExecuteFileURL = Node->GetAttribute("URL" );
rls_EXEFileName = Node->GetAttribute("FileName");
}
Node = NodeVersion->ChildNodes->FindNode("DatabaseFile");
if ( Node )
{
rls_DatabaseFileVersion = Node->GetAttribute("Version" );
rls_DatabaseFileURL = Node->GetAttribute("URL" );
rls_DBFFileName = Node->GetAttribute("FileName");
}
}
NodeVersion = NodeSoftware->ChildNodes->FindNode("Debug");
if ( NodeVersion )
{
dbg_VersionString = NodeVersion->GetAttribute("Version");
Node = NodeVersion->ChildNodes->FindNode("ExecuteFile");
if ( Node )
{
dbg_ExecuteFileVersion = Node->GetAttribute("Version" );
dbg_ExecuteFileURL = Node->GetAttribute("URL" );
dbg_EXEFileName = Node->GetAttribute("FileName");
}
Node = NodeVersion->ChildNodes->FindNode("DatabaseFile");
if ( Node )
{
dbg_DatabaseFileVersion = Node->GetAttribute("Version" );
dbg_DatabaseFileURL = Node->GetAttribute("URL" );
dbg_DBFFileName = Node->GetAttribute("FileName");
}
}
}
}
m_XMLDoc->Active = false;
return true;
}
//---------------------------------------------------------------------------
bool __fastcall TXMLOnlineUpdate::Encode()
{
m_XMLDoc->LoadFromXML(WideString(""));
m_XMLDoc->Active = true;
m_XMLDoc->ChildNodes->Clear();
m_XMLDoc->StandAlone = "yes";
_di_IXMLNode NodeSoftware;
_di_IXMLNode NodeWashOut;
_di_IXMLNode NodeRelease;
_di_IXMLNode NodeDebug;
_di_IXMLNode Node;
// ===================================================================================================
// NodeAncestor = m_XMLDoc->CreateNode(m_Ancestor, ntElement, "FriendSafe");
NodeSoftware = m_XMLDoc->CreateNode(m_Software);
NodeSoftware->SetAttribute("Method", m_Method);
NodeSoftware->SetAttribute("Version", m_DocumentVersion);
m_XMLDoc->ChildNodes->Add(NodeSoftware);
// ===================================================================================================
NodeWashOut = NodeSoftware->AddChild("WashOut");
NodeWashOut->SetAttribute("Version", wso_WashOutVersion);
// ===================================================================================================
NodeRelease = NodeSoftware->AddChild("Release");
NodeRelease->SetAttribute("Version", rls_VersionString);
// NodeRelease->SetText(rls_ExecuteFileURL);
Node = NodeRelease->AddChild("ExecuteFile");
Node->SetAttribute("Version", rls_ExecuteFileVersion);
Node->SetAttribute("URL", rls_ExecuteFileURL);
Node->SetAttribute("FileName", rls_EXEFileName);
Node = NodeRelease->AddChild("DatabaseFile");
Node->SetAttribute("Version", rls_DatabaseFileVersion);
Node->SetAttribute("URL", rls_DatabaseFileURL);
Node->SetAttribute("FileName", rls_DBFFileName);
// ===================================================================================================
NodeDebug = NodeSoftware->AddChild("Debug");
NodeDebug ->SetAttribute("Version", dbg_VersionString);
// NodeDebug ->SetText(dbg_DatabaseFileURL);
Node = NodeDebug->AddChild("ExecuteFile");
Node->SetAttribute("Version", dbg_ExecuteFileVersion);
Node->SetAttribute("URL", dbg_ExecuteFileURL);
Node->SetAttribute("FileName", dbg_EXEFileName);
Node = NodeDebug->AddChild("DatabaseFile");
Node->SetAttribute("Version", dbg_DatabaseFileVersion);
Node->SetAttribute("URL", dbg_DatabaseFileURL);
Node->SetAttribute("FileName", dbg_DBFFileName);
return true;
}
//---------------------------------------------------------------------------
bool __fastcall TXMLOnlineUpdate::JudgeEXEVersion(int CurrentEXEVersion) // 确定是否需要升级
{
return false;
}
//---------------------------------------------------------------------------
bool __fastcall TXMLOnlineUpdate::JudgeDBFVersion(int CurrentDBFVersion) // 确定是否需要升级
{
return false;
}