SaveToXml(Xml: IXmlDomElement);
SaveToXml(Xml: Prognoz.Platform.Interop.MsXml2.IXmlDomElement);
Xml. XML file that stores calculation statistics.
The SaveToXml method saves statistics tree to XML file.
It is used on comparing calculation statistics using the IMsCalculationStats.Compare method.
To load calculation statistics from XML file, use the IMsCalculationStats.LoadFromXml method.
Executing the example requires that the repository contains a modeling container with the CONT_MODEL identifier that contains a modeling problem with the PROBLEM identifier.
Add links to the Metabase, Ms, Xml (in Fore.NET - the MsXml2 assembly) system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
Problem: IMsProblem;
Settings: IMsProblemCalculationSettings;
Calc: IMsProblemCalculation;
Doc: IXMLDOMDocument3;
Elem: IXmlDomElement;
Begin
Mb := MetabaseClass.Active;
// Get modeling problem
Problem := Mb.ItemByIdNamespace("PROBLEM", Mb.GetObjectKeyById("CONT_MODEL")).EditTemporary As IMsProblem;
Settings := Problem.CreateCalculationSettings;
// Set calculation statistics drill down
Settings.StatsLevel := MsCalculationStatsLevel.Basic;
Calc := Problem.Calculate(Settings);
// Calculate modeling problem and calculation statistics
Calc.Run;
// Save statistic to XML file
Doc := New FreeThreadedDOMDocument60.Create;
Elem := doc.createElement("Stats");
Doc.appendChild(Elem);
Calc.Stats.SaveToXml(Elem);
Doc.Save("D:\Work\Stats.xml");
End Sub UserProc;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.MsXml2;
Public Shared Sub Main(Params: StartParams);
Var
Mb: IMetabase;
Problem: IMsProblem;
Settings: IMsProblemCalculationSettings;
Calc: IMsProblemCalculation;
Doc: IXMLDOMDocument3 = New FreeThreadedDOMDocument60();
Elem: IXmlDomElement;
Begin
Mb := Params.Metabase;
// Get modeling problem
Problem := Mb.ItemByIdNamespace["PROBLEM", Mb.GetObjectKeyById("CONT_MODEL")].EditTemporary() As IMsProblem;
Settings := Problem.CreateCalculationSettings();
// Set calculation statistics drill down
Settings.StatsLevel := MsCalculationStatsLevel.mcslBasic;
Calc := Problem.Calculate(Settings);
// Calculate modeling problem and calculation statistics
Calc.Run();
// Save statistic to XML file
Elem := doc.createElement("Stats");
Doc.appendChild(Elem);
Calc.Stats.SaveToXml(Elem);
Doc.Save("D:\Work\Stats.xml");
End Sub;
After executing the example, the specified modeling problem is calculated. The calculation statistic is saved to the Stats.xml file.
See also: