Thanks for the hints about t_document content! I've implemented the solution by assembling the date of creation and the rest to a single XML output.
The GUID of the baseline (available as attribute in a baseline node within the raw XML) is actually the t_document table's DocID column.
private void GetPackageBaselineInfo(Package pkg)
{
if (cfgHandling.bBaselineInfoSupport)
{
log("Available package baselines are collected for release history...");
Project projInterface = currentRepository.GetProjectInterface();
XmlDocument baselineInfo = new XmlDocument();
// this retrieves only GUID, version, name and notes for the baseline
string sBaselineInfoRaw = projInterface.GetBaselines(pkg.PackageGUID, "");
sBaselineInfoRaw = sBaselineInfoRaw.Replace("><Baseline ", ">\r\n<Baseline ");
baselineInfo.LoadXml(sBaselineInfoRaw);
XmlNode blCollection = baselineInfo.SelectSingleNode("EA.BaseLines");
if ((baselineInfo != null) && (blCollection != null))
{
XmlDocument baselineInfoExt = (XmlDocument)baselineInfo.Clone(); // extended baseline info, to be exported
XmlAttribute cDate = baselineInfoExt.CreateAttribute("creationdate");
if (cDate == null)
{
log("Creation date could not be added as new attribute. No baseline info will be extracted.");
return;
}
if (baselineInfoExt == null)
{
log("Output baseline info XML creation failed.");
return;
}
else
{
log("Count of available baselines: " + blCollection.ChildNodes.Count.ToString());
// take each baseline to get the date of creation too
foreach (XmlNode node in blCollection.ChildNodes)
{
string guid = GetAttributeValue(node, "guid");
if (guid != null)
{
string sQuery = "SELECT `DocDate` FROM `t_document` WHERE `DocID` LIKE \"" + guid + "\"";
string date = currentRepository.SQLQuery(sQuery); // date is still raw XML, as date+time
XmlDocument DateXML = new XmlDocument();
DateXML.LoadXml(date);
DateTime dtDate = DateTime.Parse(DateXML.SelectSingleNode("//DocDate").InnerText);
// insert the date of creation to the baseline XML
XmlNode targetNode = baselineInfoExt.SelectSingleNode("//Baseline[@guid='" + guid + "']");
if (targetNode != null)
{
cDate.Value = dtDate.Date.ToString("yyyy-MM-dd");
targetNode.Attributes.SetNamedItem(cDate);
}
else
{
log("Target node not found by baseline GUID.");
return;
}
}
else
{
log("Package baseline with empty GUID found. This shall be an error. The process ends now.");
return;
}
}
log("Baseline content collected, writing to XML...");
baselineInfoExt.Save(Path.Combine(cfgHandling.sAddInPath, "temp_baselines.xml"));
log("Baseline information saved to XML.");
}
}
else
{
log("Node collection not found.");
}
}
}