LoadFromXml(Element: IXmlDomElement);
SaveToXml(Element: Prognoz.Platform.Interop.MsXml2.IXmlDomElement);
Element. The element, from which the parameters of the mobile application objects are loaded.
The LoadFromXml method loads parameters of mobile application objects from XML file.
To load publisher parameters to XML file, use the IMobileApplicationPublicator.SaveToXml method.
The example is a procedure with the following input parameters:
Publicator. Mobile application publisher.
File. The full name of the XML file that contains parameters of the mobile application objects.
MbObj. The object from the mobile application.
Add links to the Metabase, Mobile, Xml system assemblies.
Sub LoadParams(Publicator: IMobileApplicationPublicator; File: String; MbObj: IMetabaseObject);
Var
MaPubObjs: IMobileApplicationPublishObjects;
XmlDoc: IXmlDomDocument3;
el: IXmlDomElement;
MaPubObj: IMobileApplicationPublishObject;
PublishObject: IMobilePublishObject;
res: MobilePublishObjectResult;
s: String;
Begin
MaPubObjs := Publicator.Items;
// Load parameters of mobile application objects
XmlDoc := New DOMDocument60.Create;
XmlDoc.load(File);
el := XmlDoc.selectSingleNode("Root") As IXmlDomElement;
MaPubObjs.LoadFromXml(el);
// Check if the specified object is included in mobile application
MaPubObj := MaPubObjs.ItemByKey(MbObj.Key);
If MaPubObj <> Null Then
If MaPubObj.IsValid Then // The object is included and available for publishing
PublishObject := MaPubObj.PublishObject;
// Specify path for saving object
PublishObject.ExportPath := "C:\" + MbObj.Id + ".zip";
// Specify object version
PublishObject.Version := "1.0";
// Publish object
res := PublishObject.Publish(Null);
// Save publishing parameters
XmlDoc := New DOMDocument60.Create;
el := XmlDoc.createElement("Root");
XmlDoc.appendChild(el);
PublishObject.SaveToXml(el);
XmlDoc.save("C:\PublishObject.xml");
// Display publishing results in the console window
s := MbObj.Name + " (" + MbObj.Id + ")";
If res = MobilePublishObjectResult.OK Then
Debug.WriteLine("Object publishing '" + s + "' is finished");
Else
Debug.WriteLine("Error publishing the '" + s + "' object")
End If;
End If;
// Save parameters of mobile application object
XmlDoc := New DOMDocument60.Create;
el := XmlDoc.createElement("Root");
XmlDoc.appendChild(el);
MaPubObj.SaveToXml(el);
XmlDoc.save("C:\" + MbObj.Id + ".xml");
End If;
End Sub LoadParams;
Procedure execution result: parameters of the mobile application object are loaded from the File file. If the MbObj object is included in the mobile application and available for publishing, it will be published. Publishing results are displayed in the console window. The parameters of the mobile application object and the object publishing parameters are saved in the XML format.
The example is a procedure with the following input parameters:
Publicator. Mobile application publisher.
File. The full name of the XML file that contains parameters of mobile application objects.
MbObj. The object from the mobile application.
Imports Prognoz.Platform.Interop.Mobile;
Imports Prognoz.Platform.Interop.MsXml2;
…
Public Shared Sub LoadParams(Publicator: IMobileApplicationPublicator; File: String; MbObj: IMetabaseObject);
Var
MaPubObjs: IMobileApplicationPublishObjects;
XmlDoc: IXmlDomDocument3;
el: IXmlDomElement;
MaPubObj: IMobileApplicationPublishObject;
PublishObject: IMobilePublishObject;
res: MobilePublishObjectResult;
s: String;
Begin
MaPubObjs := Publicator.Items;
// Load parameters of mobile application objects
XmlDoc := New DOMDocument60.Create();
XmlDoc.load(File);
el := XmlDoc.selectSingleNode("Root") As IXmlDomElement;
MaPubObjs.LoadFromXml(el);
// Check if the specified object is included in mobile application
MaPubObj := MaPubObjs.ItemByKey[MbObj.Key];
If MaPubObj <> Null Then
If MaPubObj.IsValid Then // The object is included and available for publishing
PublishObject := MaPubObj.PublishObject;
// Specify the path for saving object
PublishObject.ExportPath := "C:\" + MbObj.Id + ".zip";
// Specify object version
PublishObject.Version := "1.0";
// Publish object
res := PublishObject.Publish(Null);
// Save publishing parameters
XmlDoc := New DOMDocument60.Create();
el := XmlDoc.createElement("Root");
XmlDoc.appendChild(el);
PublishObject.SaveToXml(el);
XmlDoc.save("C:\PublishObject.xml");
// Display publishing results in the console window
s := MbObj.Name + " (" + MbObj.Id + ")";
If res = MobilePublishObjectResult.mporOK Then
System.Diagnostics.Debug.WriteLine("Object publishing '" + s + "' is finished").
Else
System.Diagnostics.Debug.WriteLine("Erro occurred on '" + s + "' publishing the object").
End If;
End If;
// Save parameters of mobile application object
XmlDoc := New DOMDocument60.Create();
el := XmlDoc.createElement("Root");
XmlDoc.appendChild(el);
MaPubObj.SaveToXml(el);
XmlDoc.save("C:\" + MbObj.Id + ".xml");
End If;
End Sub LoadParams;
Procedure execution result: parameters of mobile application objects are loaded from the File file. If the MbObj object is included in the mobile application and available for publishing, it will be published. Publishing results are displayed in the console window. Parameters of the mobile application object and the object publishing parameters are saved in the XML format.
See also: