ReadDataStream([Value: IIOStreamSys = Null]): IIOStreamSys;
Value is a stream in which the read data is placed. By default the Null value is passed, and a new stream is also created.
The ReadDataStream method reads the task execution result and places this result into the stream.
The given method can be used for the tasks that calculate the regular report. Calculated regular report or a file in which the report is exported after calculation are the result of the given tasks executions. File format is set in the FormatTag property of the task.
Executing the example requires that the repository contains a scheduled tasks container with the TASK_CONTAINTER identifier. The first task of the container performs the calculation of the regular report. The notification about execution completion is sent by email, the calculated report exported to MHT format is sent as an application.
Sub UserProc;
Var
MB: IMetabase;
CrInfo: IMetabaseObjectCreateInfo;
MObj: IMetabaseObject;
Doc: IDocument;
Cont: IScheduledTasksContainer;
Tasks: IMetabaseObjectDescriptors;
Task: ICalculateReportScheduledTask;
Results: IScheduledTaskResults;
Result: IScheduledTaskResult;
Begin
MB := MetabaseClass.Active;
Cont := MB.ItemById("TASK_CONTAINTER").Bind As IScheduledTasksContainer;
Tasks := Cont.Tasks;
Task := Tasks.Item(0).Bind As ICalculateReportScheduledTask;
Results := Task.GetResults;
Result := Results.Item(Results.Count - 1);
If Result.Succeeded Then
CrInfo := MB.CreateCreateInfo;
CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_DOCUMENT;
CrInfo.Id := "Result_ReportCalc";
CrInfo.Name := "Result_ReportCalc";
CrInfo.Parent := MB.Root;
MObj := MB.CreateObject(CrInfo).Edit;
Doc := MObj As IDocument;
Doc.LoadFromStream(Result.ReadDataStream As IIOStream);
Doc.FileName := "Result_ReportCalc.mht";
MObj.Save;
End If;
End Sub UserProc;
After executing the example the history of execution of the first task in the scheduled tasks container is received. If the last execution was completed successfully, the new document would be created in the repository root. The file that contains the exported report that was received after task execution is loaded to this document.
See also: