LoadWithResult(Source: Object; CreateInfo: IMetabaseObjectCreateInfo): ICubeLoaderResult;
LoadWithResult(Source: Object; CreateInfo: Prognoz.Platform.Interop.Metabase.IMetabaseObjectCreateInfo): Prognoz.Platform.Interop.Cubes.ICubeLoaderResult;
Source. The data source described by the IDtProvider interface.
CreateInfo. Information about the created object. If information is missing or loading to the current object is executed, the Null value must be passed as a parameter.
The LoadWithResult method loads data and returns loading result.
The type of created object determines value of the ICubeLoaderFromSource.Type property.
Executing the example requires the following in the repository:
Folder with the TSDB_FOLDER identifier.
MDM repository with the RDS_LOAD identifier.
Table MDM dictionary with the CITY_DICT identifier. This dictionary must be outside the MDM repository. The dictionary must also contain a unique index with the UINDEX identifier. This index must include only one attribute with the NAME identifier. The attribute contains names of dictionary elements. The dictionary must contain the following elements:
Anchorage.
Mexico.
Chicago.
The file system must contain the C:\result_exp.txt file with data.
Add links to the Collections, Cubes, Dimensions, Dt, Metabase, Rds system assemblies.
Contents of the C:\result_exp.txt file
<font color="#008080">Sub</font><font color="#000000"> UserProc;<br /> </font><font color="#008080">Var</font><font color="#000000"><br /> mb: IMetabase;<br /> parent: IMetabaseObject;<br /> rdsDatabase: IRdsDatabase;<br /> loader: ICubeLoaderFromSource;<br /> DimBindings: ICubeLoaderDimensionBindings;<br /> bind: ICubeLoaderDimensionBinding;<br /> DimModel: IDimensionModel;<br /> Calend: ICubeLoaderDimensionBinding;<br /> DateConv: IDateConverter;<br /> creator: IDtObjectCreator;<br /> prov: IDtTextProvider;<br /> Result: ICubeLoaderResult;<br /> Object: IMetabaseObject;<br /> List, Arr: IArrayList;<br /> Item: Variant;<br /> i: Integer;<br /> </font><font color="#008080">Begin</font><font color="#000000"><br /> </font><font color="#008000">// Get current repository<br /> </font><font color="#000000"> mb := MetabaseClass.Active;<br /> </font><font color="#008000">// Get the TSDB_FOLDER where time series database<br /> </font><font color="#000000"> </font><font color="#008000">// will be created<br /> </font><font color="#000000"> parent := mb.ItemById(</font><font color="#800000">"TSDB_FOLDER"</font><font color="#000000">).Bind;<br /> </font><font color="#008000">// Get MDM repository<br /> </font><font color="#000000"> rdsDatabase := mb.ItemById(</font><font color="#800000">"RDS_LOAD"</font><font color="#000000">).Bind </font><font color="#008080">As</font><font color="#000000"> IRdsDatabase;<br /> </font><font color="#008000">// Create object to load data<br /> </font><font color="#000000"> loader := </font><font color="#008080">New</font><font color="#000000"> CubeLoaderFromSource.Create;<br /> </font><font color="#008000">// Specify an MDM repository which will be used on loading<br /> </font><font color="#000000"> loader.RdsDatabase := rdsDatabase.Open(</font><font color="#008080">Null</font><font color="#000000">);<br /> </font><font color="#008000">// Specify that time series database will be created<br /> </font><font color="#000000"> </font><font color="#008000">// for loaded data<br /> </font><font color="#000000"> loader.Type := CubeLoaderType.Rubricator;<br /> </font><font color="#008000">// Specify folder where time series database will be created<br /> </font><font color="#000000"> loader.Parent := parent;<br /> </font><font color="#008000">// Get dimension bindings to data source fields<br /> </font><font color="#000000"> DimBindings := loader.DimensionBindings;<br /> </font><font color="#008000">// Add binding for the CITY field<br /> </font><font color="#000000"> bind := DimBindings.Add(</font><font color="#800000">"CITY"</font><font color="#000000">);<br /> </font><font color="#008000">// Specify that the field will correspond to dimension<br /> </font><font color="#000000"> </font><font color="#008000">// based on the CITY_DICT MDM dictionary<br /> </font><font color="#000000"> DimModel := mb.ItemById(</font><font color="#800000">"CITY_DICT"</font><font color="#000000">).Bind </font><font color="#008080">As</font><font color="#000000"> IDimensionModel;<br /> bind.Dictionary := DimModel;<br /> </font><font color="#008000">// Specify index by which binding is created<br /> </font><font color="#000000"> bind.Index := DimModel.Indexes.FindById(</font><font color="#800000">"UINDEX"</font><font color="#000000">);<br /> </font><font color="#008000">// Specify attribute identifier which is used to build index<br /> </font><font color="#000000"> bind.AttributeId := </font><font color="#800000">"NAME"</font><font color="#000000">;<br /> </font><font color="#008000">// Add binding for the INDICATOR field.<br /> </font><font color="#000000"> </font><font color="#008000">// Dictionary to create a dimension corresponding to the field<br /> </font><font color="#000000"> </font><font color="#008000">// will be created automatically in the MDM repository «RDS_LOAD»<br /> </font><font color="#000000"> DimBindings.Add(</font><font color="#800000">"INDICATOR"</font><font color="#000000">);<br /> </font><font color="#008000">// Add binding for calendar dimension<br /> </font><font color="#000000"> Calend := DimBindings.AddCalendar(</font><font color="#800000">"Year"</font><font color="#000000">, DimCalendarLevel.Year);<br /> </font><font color="#008000">// Create object to parse dates in data source<br /> </font><font color="#000000"> DateConv := </font><font color="#008080">New</font><font color="#000000"> DateConverter.Create;<br /> </font><font color="#008000">// Set data format<br /> </font><font color="#000000"> DateConv.CalendarDateFormat := </font><font color="#800000">"$YEAR$"</font><font color="#000000">;<br /> DateConv.ConvertShortYear := </font><font color="#008080">True</font><font color="#000000">;<br /> </font><font color="#008000">// Set created object to calendar dimension binding<br /> </font><font color="#000000"> Calend.Converter := DateConv;<br /> </font><font color="#008000">// Add binding for data source values<br /> </font><font color="#000000"> loader.FactBindings.Add(</font><font color="#800000">"Value"</font><font color="#000000">);<br /> </font><font color="#008000">// Create an object to work with data source<br /> </font><font color="#000000"> creator := </font><font color="#008080">New</font><font color="#000000"> DtObjectCreator.Create;<br /> </font><font color="#008000">// Create a text data source from file<br /> </font><font color="#000000"> prov := creator.CreateDtObjectFromFile(</font><font color="#800000">"C:\result_exp.txt"</font><font color="#000000">) </font><font color="#008080">As</font><font color="#000000"> IDtTextProvider;<br /> </font><font color="#008000">// Specify field delimiter used in source<br /> </font><font color="#000000"> prov.DelimitedColumnDelimiter := </font><font color="#800000">";"</font><font color="#000000">;<br /> </font><font color="#008000">// Load data and process loading result<br /> </font><font color="#000000"> Result := loader.LoadWithResult(prov, </font><font color="#008080">Null</font><font color="#000000">);<br /> </font><font color="#008000">// Get object to which data was loaded<br /> </font><font color="#000000"> Object := Result.Object;<br /> </font><font color="#008000">// Display object information in console window<br /> </font><font color="#000000"> Debug.WriteLine(</font><font color="#800000">"Name and identifier of created time series database: "</font><font color="#000000"> +<br /> Object.Name + </font><font color="#800000">"("</font><font color="#000000"> + Object.Id + </font><font color="#800000">")"</font><font color="#000000">);<br /> </font><font color="#008000">// Get empty records and display them to the console window<br /> </font><font color="#000000"> List := Result.NullStrings;<br /> </font><font color="#008080">If</font><font color="#000000"> List.Count <> </font><font color="#008000">0</font><font color="#000000"> </font><font color="#008080">Then</font><font color="#000000"><br /> Debug.WriteLine(</font><font color="#800000">"Empty records:"</font><font color="#000000">);<br /> </font><font color="#008080">For</font><font color="#000000"> </font><font color="#008080">Each</font><font color="#000000"> Item </font><font color="#008080">In</font><font color="#000000"> List </font><font color="#008080">Do</font><font color="#000000"><br /> Arr := Item </font><font color="#008080">As</font><font color="#000000"> IArrayList;<br /> </font><font color="#008080">For</font><font color="#000000"> i := </font><font color="#008000">0</font><font color="#000000"> </font><font color="#008080">To</font><font color="#000000"> Arr.Count - </font><font color="#008000">1</font><font color="#000000"> </font><font color="#008080">Do</font><font color="#000000"><br /> Debug.Write(Arr.Item(i));<br /> Debug.Write(</font><font color="#800000">"; "</font><font color="#000000">);<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">For</font><font color="#000000">;<br /> Debug.WriteLine(</font><font color="#800000">""</font><font color="#000000">);<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">For</font><font color="#000000">;<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">If</font><font color="#000000">;<br /> </font><font color="#008000">// Get duplicated records and display them intp console window<br /> </font><font color="#000000"> List := Result.DuplicatedStrings;<br /> </font><font color="#008080">If</font><font color="#000000"> List.Count <> </font><font color="#008000">0</font><font color="#000000"> </font><font color="#008080">Then</font><font color="#000000"><br /> Debug.WriteLine(</font><font color="#800000">"Duplicated records:"</font><font color="#000000">);<br /> </font><font color="#008080">For</font><font color="#000000"> </font><font color="#008080">Each</font><font color="#000000"> Item </font><font color="#008080">In</font><font color="#000000"> List </font><font color="#008080">Do</font><font color="#000000"><br /> Arr := Item </font><font color="#008080">As</font><font color="#000000"> IArrayList;<br /> </font><font color="#008080">For</font><font color="#000000"> i := </font><font color="#008000">0</font><font color="#000000"> </font><font color="#008080">To</font><font color="#000000"> Arr.Count - </font><font color="#008000">1</font><font color="#000000"> </font><font color="#008080">Do</font><font color="#000000"><br /> Debug.Write(Arr.Item(i));<br /> Debug.Write(</font><font color="#800000">"; "</font><font color="#000000">);<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">For</font><font color="#000000">;<br /> Debug.WriteLine(</font><font color="#800000">""</font><font color="#000000">);<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">For</font><font color="#000000">;<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">If</font><font color="#000000">;<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">Sub</font><font color="#000000"> UserProc;</font>
After executing the example data from the C:\result_exp.txt file is loaded to the time series database created for this purpose. Import results and identifier and name of the created time series database are output to the console window.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Dt;
Imports Prognoz.Platform.Interop.ForeCollections;
Imports Prognoz.Platform.Interop.Rds;
<font color="#008080">Public</font><font color="#000000"> </font><font color="#008080">Shared</font><font color="#000000"> </font><font color="#008080">Sub</font><font color="#000000"> Main(Params: StartParams);<br /> </font><font color="#008080">Var</font><font color="#000000"><br /> mb: IMetabase;<br /> parent: IMetabaseObject;<br /> rdsDatabase: IRdsDatabase;<br /> loader: ICubeLoaderFromSource;<br /> DimBindings: ICubeLoaderDimensionBindings;<br /> bind: ICubeLoaderDimensionBinding;<br /> DimModel: IDimensionModel;<br /> Calend: ICubeLoaderDimensionBinding;<br /> DateConv: IDateConverter;<br /> creator: IDtObjectCreator;<br /> prov: IDtTextProvider;<br /> Result: ICubeLoaderResult;<br /> Object: IMetabaseObject;<br /> List, Arr: IArrayList;<br /> Item: object;<br /> i: Integer;<br /> </font><font color="#008080">Begin</font><font color="#000000"><br /> </font><font color="#008000">// Get current repository<br /> </font><font color="#000000"> mb := Params.Metabase;<br /> </font><font color="#008000">// Get the TSDB_FOLDER folder where time series database<br /> </font><font color="#000000"> </font><font color="#008000">// will be created<br /> </font><font color="#000000"> parent := mb.ItemById[</font><font color="#800000">"TSDB_FOLDER"</font><font color="#000000">].Bind();<br /> </font><font color="#008000">// Get MDM repository<br /> </font><font color="#000000"> rdsDatabase := mb.ItemById[</font><font color="#800000">"RDS_LOAD"</font><font color="#000000">].Bind() </font><font color="#008080">As</font><font color="#000000"> IRdsDatabase;<br /> </font><font color="#008000">// Create an object to load data<br /> </font><font color="#000000"> loader := </font><font color="#008080">New</font><font color="#000000"> CubeLoaderFromSource.Create();<br /> </font><font color="#008000">// Display MDM repository that will be used on loading<br /> </font><font color="#000000"> loader.RdsDatabase := rdsDatabase.Open(</font><font color="#008080">Null</font><font color="#000000">);<br /> </font><font color="#008000">// Specify that for loaded data time series<br /> </font><font color="#000000"> </font><font color="#008000">// database will be created<br /> </font><font color="#000000"> loader.Type := CubeLoaderType.cltRubricator;<br /> </font><font color="#008000">// Specify folder where time series database will be created<br /> </font><font color="#000000"> loader.Parent := parent;<br /> </font><font color="#008000">// Get dimension bindings to data source fields<br /> </font><font color="#000000"> DimBindings := loader.DimensionBindings;<br /> </font><font color="#008000">// Add binding for the CITY field<br /> </font><font color="#000000"> bind := DimBindings.Add(</font><font color="#800000">"CITY"</font><font color="#000000">);<br /> </font><font color="#008000">// Specify that the filed will correspond to dimension<br /> </font><font color="#000000"> </font><font color="#008000">// based on the CITY_DICT MDM dictionary<br /> </font><font color="#000000"> DimModel := mb.ItemById[</font><font color="#800000">"CITY_DICT"</font><font color="#000000">].Bind() </font><font color="#008080">As</font><font color="#000000"> IDimensionModel;<br /> bind.Dictionary := DimModel;<br /> </font><font color="#008000">// Specify index by which binding will be created<br /> </font><font color="#000000"> bind.Index := DimModel.Indexes.FindById(</font><font color="#800000">"UINDEX"</font><font color="#000000">);<br /> </font><font color="#008000">// Specify attribute identifier on which index is built<br /> </font><font color="#000000"> bind.AttributeId := </font><font color="#800000">"NAME"</font><font color="#000000">;<br /> </font><font color="#008000">// Add a binding for the INDICATOR field.<br /> </font><font color="#000000"> </font><font color="#008000">// Dictionary to create a dimension corresponding to this field<br /> </font><font color="#000000"> </font><font color="#008000">// will be created automatically in MDM repository RDS_LOAD<br /> </font><font color="#000000"> DimBindings.Add(</font><font color="#800000">"INDICATOR"</font><font color="#000000">);<br /> </font><font color="#008000">// Add a binding for calendar dimension<br /> </font><font color="#000000"> Calend := DimBindings.AddCalendar(</font><font color="#800000">"Year"</font><font color="#000000">, DimCalendarLevel.dclYear);<br /> </font><font color="#008000">// Create an object to parse dates in data source<br /> </font><font color="#000000"> DateConv := </font><font color="#008080">New</font><font color="#000000"> DateConverter.Create();<br /> </font><font color="#008000">// Set date format<br /> </font><font color="#000000"> DateConv.CalendarDateFormat := </font><font color="#800000">"$YEAR$"</font><font color="#000000">;<br /> DateConv.ConvertShortYear := </font><font color="#008080">True</font><font color="#000000">;<br /> </font><font color="#008000">// Set created object to binding of calendar dimension<br /> </font><font color="#000000"> Calend.Converter := DateConv;<br /> </font><font color="#008000">// Add a binding for data source values<br /> </font><font color="#000000"> loader.FactBindings.Add(</font><font color="#800000">"Value"</font><font color="#000000">);<br /> </font><font color="#008000">// Create an object to work with data source<br /> </font><font color="#000000"> creator := </font><font color="#008080">New</font><font color="#000000"> DtObjectCreator.Create();<br /> </font><font color="#008000">// Create a text data source from file<br /> </font><font color="#000000"> prov := creator.CreateDtObjectFromFile(</font><font color="#800000">"C:\result_exp.txt"</font><font color="#000000">) </font><font color="#008080">As</font><font color="#000000"> IDtTextProvider;<br /> </font><font color="#008000">// Specify field delimiter that is used in source<br /> </font><font color="#000000"> prov.DelimitedColumnDelimiter := </font><font color="#800000">";"</font><font color="#000000">;<br /> </font><font color="#008000">// Load data and process a loading result<br /> </font><font color="#000000"> Result := loader.LoadWithResult(prov, </font><font color="#008080">Null</font><font color="#000000">);<br /> </font><font color="#008000">// Get object to which data was loaded<br /> </font><font color="#000000"> Object := Result.Object;<br /> </font><font color="#008000">// Display information about object in console window<br /> </font><font color="#000000"> System.Diagnostics.Debug.WriteLine(</font><font color="#800000">"Name and identifier of created time series database: "</font><font color="#000000"> +<br /> Object.Name + </font><font color="#800000">"("</font><font color="#000000"> + Object.Id + </font><font color="#800000">")"</font><font color="#000000">);<br /> </font><font color="#008000">// Get empty records and display them to console window<br /> </font><font color="#000000"> List := Result.NullStrings;<br /> </font><font color="#008080">If</font><font color="#000000"> List.Count <> </font><font color="#008000">0</font><font color="#000000"> </font><font color="#008080">Then</font><font color="#000000"><br /> System.Diagnostics.Debug.WriteLine(</font><font color="#800000">"Empty records:"</font><font color="#000000">);<br /> </font><font color="#008080">For</font><font color="#000000"> </font><font color="#008080">Each</font><font color="#000000"> Item </font><font color="#008080">In</font><font color="#000000"> List </font><font color="#008080">Do</font><font color="#000000"><br /> Arr := Item </font><font color="#008080">As</font><font color="#000000"> IArrayList;<br /> </font><font color="#008080">For</font><font color="#000000"> i := </font><font color="#008000">0</font><font color="#000000"> </font><font color="#008080">To</font><font color="#000000"> Arr.Count - </font><font color="#008000">1</font><font color="#000000"> </font><font color="#008080">Do</font><font color="#000000"><br /> System.Diagnostics.Debug.Write(Arr.Item[i]);<br /> System.Diagnostics.Debug.Write(</font><font color="#800000">"; "</font><font color="#000000">);<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">For</font><font color="#000000">;<br /> System.Diagnostics.Debug.WriteLine(</font><font color="#800000">""</font><font color="#000000">);<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">For</font><font color="#000000">;<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">If</font><font color="#000000">;<br /> </font><font color="#008000">// Get duplicated records and display them to console window<br /> </font><font color="#000000"> List := Result.DuplicatedStrings;<br /> </font><font color="#008080">If</font><font color="#000000"> List.Count <> </font><font color="#008000">0</font><font color="#000000"> </font><font color="#008080">Then</font><font color="#000000"><br /> System.Diagnostics.Debug.WriteLine(</font><font color="#800000">"Duplicated records:"</font><font color="#000000">);<br /> </font><font color="#008080">For</font><font color="#000000"> </font><font color="#008080">Each</font><font color="#000000"> Item </font><font color="#008080">In</font><font color="#000000"> List </font><font color="#008080">Do</font><font color="#000000"><br /> Arr := Item </font><font color="#008080">As</font><font color="#000000"> IArrayList;<br /> </font><font color="#008080">For</font><font color="#000000"> i := </font><font color="#008000">0</font><font color="#000000"> </font><font color="#008080">To</font><font color="#000000"> Arr.Count - </font><font color="#008000">1</font><font color="#000000"> </font><font color="#008080">Do</font><font color="#000000"><br /> System.Diagnostics.Debug.Write(Arr.Item[i]);<br /> System.Diagnostics.Debug.Write(</font><font color="#800000">"; "</font><font color="#000000">);<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">For</font><font color="#000000">;<br /> System.Diagnostics.Debug.WriteLine(</font><font color="#800000">""</font><font color="#000000">);<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">For</font><font color="#000000">;<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">If</font><font color="#000000">;<br /> </font><font color="#008080">End</font><font color="#000000"> </font><font color="#008080">Sub</font><font color="#000000">;</font>
See also: