SaveToStream(Stream: IIOStream);
SaveToStream(Stream: System.IO.Stream);
Stream. A stream where a dashboard is saved.
The SaveToStream method saves a dashboard to a stream.
To load the dashboard from the stream, use the IAdhocReport.LoadFromStream method.
Executing the example requires that the repository contains a dashboard with the ADHOC identifier.
Add links to the Adhoc, IO and Metabase system assemblies.
Sub UserProc;
Var
MB: IMetabase;
CrInfo: IMetabaseObjectCreateInfo;
AdhocReport: IAdhocReport;
Stream: IMemoryStream;
Begin
MB := MetabaseClass.Active;
AdhocReport := MB.ItemById("ADHOC").Bind As IAdhocReport;
// Save report in stream
Stream := New MemoryStream.Create;
AdhocReport.SaveToStream(Stream);
// Create a dashboard
CrInfo := MB.CreateCreateInfo;
CrInfo.ClassID := MetabaseObjectClass.KE_ADHOC_REPORT;
CrInfo.Id := "NEW_ADHOC";
CrInfo.Name := "New dashboard";
CrInfo.Parent := MB.Root;
AdhocReport := MB.CreateObject(CrInfo).Edit As IAdhocReport;
// Load report from the stream to dashboard
AdhocReport.LoadFromStream(Stream);
(AdhocReport As IMetabaseObject).Save;
Dispose Stream;
End Sub UserProc;
After executing the example the report with the ADHOC identifier is saved to the stream. A new dashboard with the NEW_ADHOC identifier was created where the report was loaded from the stream.
The requirements and result of the Fore.NET example match with those in the Fore example.
Imports Prognoz.Platform.Interop.AdHoc;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.ForeIO;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
CrInfo: IMetabaseObjectCreateInfo;
AdhocReport: IAdhocReport;
Stream: MemoryStream;
Begin
MB := Params.Metabase;
AdhocReport := MB.ItemById["ADHOC"].Bind() As IAdhocReport;
// Save report to the stream
Stream := New MemoryStream.Create();
AdhocReport.SaveToStream(Stream);
// Create a dashboard
CrInfo := MB.CreateCreateInfo();
CrInfo.ClassID := MetabaseObjectClass.KE_ADHOC_REPORT As Int32;
CrInfo.Id := "NEW_ADHOC";
CrInfo.Name := "New dashboard";
CrInfo.Parent := MB.Root;
AdhocReport := MB.CreateObject(CrInfo).Edit() As IAdhocReport;
// Load report from the stream to dashboard
AdhocReport.LoadFromStream(Stream);
(AdhocReport As IMetabaseObject).Save();
Dispose Stream;
End Sub;
See also: