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 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> UserProc;<br /> <font color="#008080">Var</font><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 color="#008080">Begin</font><br /> <font color="#008000">// Get current repository<br /> </font> mb := MetabaseClass.Active;<br /> <font color="#008000">// Get the TSDB_FOLDER folder, in which time series<br /> </font> <font color="#008000">// database will be created<br /> </font> parent := mb.ItemById(<font color="#800000">"TSDB_FOLDER"</font>).Bind;<br /> <font color="#008000">// Get MDM repository<br /> </font> rdsDatabase := mb.ItemById(<font color="#800000">"RDS_LOAD"</font>).Bind <font color="#008080">As</font> IRdsDatabase;<br /> <font color="#008000">// Create an object for data loading<br /> </font> loader := <font color="#008080">New</font> CubeLoaderFromSource.Create;<br /> <font color="#008000">// Specify the MDM repository, that is used on loading<br /> </font> loader.RdsDatabase := rdsDatabase.Open(<font color="#008080">Null</font>);<br /> <font color="#008000">// Specify that time series database will be<br /> </font> <font color="#008000">// created for loaded data<br /> </font> loader.Type := CubeLoaderType.Rubricator;<br /> <font color="#008000">// Specify the folder, in which time series database will be created<br /> </font> loader.Parent := parent;<br /> <font color="#008000">// Get bindings of dimensions to data source fields<br /> </font> DimBindings := loader.DimensionBindings;<br /> <font color="#008000">// Add binding for the CITY field<br /> </font> bind := DimBindings.Add(<font color="#800000">"CITY"</font>);<br /> <font color="#008000">// Specify, that the field will have corresponding dimension,<br /> </font> <font color="#008000">// based on the CITY_DICT MDM dictionary<br /> </font> DimModel := mb.ItemById(<font color="#800000">"CITY_DICT"</font>).Bind <font color="#008080">As</font> IDimensionModel;<br /> bind.Dictionary := DimModel;<br /> <font color="#008000">// Specify the index, by which binding is created<br /> </font> bind.Index := DimModel.Indexes.FindById(<font color="#800000">"UINDEX"</font>);<br /> <font color="#008000">// Specify identifier of the attribute, based on which index is built<br /> </font> bind.AttributeId := <font color="#800000">"NAME"</font>;<br /> <font color="#008000">// Add a binding for the INDICATOR field.<br /> </font> <font color="#008000">// Dictionary for creating the dimension, corresponding to this field,<br /> </font> <font color="#008000">// is created automatically in the RDS_LOAD MDM repository<br /> </font> DimBindings.Add(<font color="#800000">"INDICATOR"</font>);<br /> <font color="#008000">// Add a binding for calendar dimension<br /> </font> Calend := DimBindings.AddCalendar(<font color="#800000">"Year"</font>, DimCalendarLevel.Year);<br /> <font color="#008000">// Create a n object for date parsing in data source<br /> </font> DateConv := <font color="#008080">New</font> DateConverter.Create;<br /> <font color="#008000">// Set date format<br /> </font> DateConv.CalendarDateFormat := <font color="#800000">"$YEAR$"</font>;<br /> DateConv.ConvertShortYear := <font color="#008080">True</font>;<br /> <font color="#008000">// Set created object to calendar dimension binding<br /> </font> Calend.Converter := DateConv;<br /> <font color="#008000">// Add a binding for data source values<br /> </font> loader.FactBindings.Add(<font color="#800000">"Value"</font>);<br /> <font color="#008000">// Create an object to work with data source<br /> </font> creator := <font color="#008080">New</font> DtObjectCreator.Create;<br /> <font color="#008000">// Create a text data source from file<br /> </font> prov := creator.CreateDtObjectFromFile(<font color="#800000">"C:\result_exp.txt"</font>) <font color="#008080">As</font> IDtTextProvider;<br /> <font color="#008000">// Specify field delimiter used in source<br /> </font> prov.DelimitedColumnDelimiter := <font color="#800000">";"</font>;<br /> <font color="#008000">// Load data and process loading result<br /> </font> Result := loader.LoadWithResult(prov, <font color="#008080">Null</font>);<br /> <font color="#008000">// Get the object to which data is loaded<br /> </font> Object := Result.Object;<br /> <font color="#008000">// Output information about object to console window<br /> </font> Debug.WriteLine(<font color="#800000">"Name and identifier of created time series database: "</font> +<br /> Object.Name + <font color="#800000">"("</font> + Object.Id + <font color="#800000">")"</font>);<br /> <font color="#008000">// Get empty records and output them to console window<br /> </font> List := Result.NullStrings;<br /> <font color="#008080">If</font> List.Count <> <font color="#008000">0</font> <font color="#008080">Then</font><br /> Debug.WriteLine(<font color="#800000">"Empty records:"</font>);<br /> <font color="#008080">For</font> <font color="#008080">Each</font> Item <font color="#008080">In</font> List <font color="#008080">Do</font><br /> Arr := Item <font color="#008080">As</font> IArrayList;<br /> <font color="#008080">For</font> i := <font color="#008000">0</font> <font color="#008080">To</font> Arr.Count - <font color="#008000">1</font> <font color="#008080">Do</font><br /> Debug.Write(Arr.Item(i));<br /> Debug.Write(<font color="#800000">"; "</font>);<br /> <font color="#008080">End</font> <font color="#008080">For</font>;<br /> Debug.WriteLine(<font color="#800000">""</font>);<br /> <font color="#008080">End</font> <font color="#008080">For</font>;<br /> <font color="#008080">End</font> <font color="#008080">If</font>;<br /> <font color="#008000">// Get duplicate records and output them to console window<br /> </font> List := Result.DuplicatedStrings;<br /> <font color="#008080">If</font> List.Count <> <font color="#008000">0</font> <font color="#008080">Then</font><br /> Debug.WriteLine(<font color="#800000">"Duplicate records:"</font>);<br /> <font color="#008080">For</font> <font color="#008080">Each</font> Item <font color="#008080">In</font> List <font color="#008080">Do</font><br /> Arr := Item <font color="#008080">As</font> IArrayList;<br /> <font color="#008080">For</font> i := <font color="#008000">0</font> <font color="#008080">To</font> Arr.Count - <font color="#008000">1</font> <font color="#008080">Do</font><br /> Debug.Write(Arr.Item(i));<br /> Debug.Write(<font color="#800000">"; "</font>);<br /> <font color="#008080">End</font> <font color="#008080">For</font>;<br /> Debug.WriteLine(<font color="#800000">""</font>);<br /> <font color="#008080">End</font> <font color="#008080">For</font>;<br /> <font color="#008080">End</font> <font color="#008080">If</font>;<br /> <font color="#008080">End</font> <font color="#008080">Sub</font> UserProc;
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.
<font color="#008080">Imports</font> Prognoz.Platform.Interop.Cubes;<br /> <font color="#008080">Imports</font> Prognoz.Platform.Interop.Dimensions;<br /> <font color="#008080">Imports</font> Prognoz.Platform.Interop.Dt;<br /> <font color="#008080">Imports</font> Prognoz.Platform.Interop.ForeCollections;<br /> <font color="#008080">Imports</font> Prognoz.Platform.Interop.Rds;<br /> …<br /> <font color="#008080">Public</font> <font color="#008080">Shared</font> <font color="#008080">Sub</font> Main(Params: StartParams);<br /> <font color="#008080">Var</font><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 color="#008080">Begin</font><br /> <font color="#008000">// Get current repository<br /> </font> mb := Params.Metabase;<br /> <font color="#008000">// Get the TSDB_FOLDER folder, in which time series<br /> </font> <font color="#008000">// database is created<br /> </font> parent := mb.ItemById[<font color="#800000">"TSDB_FOLDER"</font>].Bind();<br /> <font color="#008000">// Get MDM repository<br /> </font> rdsDatabase := mb.ItemById[<font color="#800000">"RDS_LOAD"</font>].Bind() <font color="#008080">As</font> IRdsDatabase;<br /> <font color="#008000">// Create object for data loading<br /> </font> loader := <font color="#008080">New</font> CubeLoaderFromSource.Create();<br /> <font color="#008000">// Specify MDM repository, that is used on loading<br /> </font> loader.RdsDatabase := rdsDatabase.Open(<font color="#008080">Null</font>);<br /> <font color="#008000">// Specify that time series database is created<br /> </font> <font color="#008000">// for loaded data<br /> </font> loader.Type := CubeLoaderType.cltRubricator;<br /> <font color="#008000">// Specify the folder, in which time series database is created<br /> </font> loader.Parent := parent;<br /> <font color="#008000">// Get dimension bindings to data source fields<br /> </font> DimBindings := loader.DimensionBindings;<br /> <font color="#008000">// Add binding for the CITY field<br /> </font> bind := DimBindings.Add(<font color="#800000">"CITY"</font>);<br /> <font color="#008000">// Specify that dimension corresponds to the field,<br /> </font> <font color="#008000">// the dimension is based on MDM dictionary CITY_DICT<br /> </font> DimModel := mb.ItemById[<font color="#800000">"CITY_DICT"</font>].Bind() <font color="#008080">As</font> IDimensionModel;<br /> bind.Dictionary := DimModel;<br /> <font color="#008000">// Specify index, by which binding is created<br /> </font> bind.Index := DimModel.Indexes.FindById(<font color="#800000">"UINDEX"</font>);<br /> <font color="#008000">// Specify identifier of attribute, based on which index is built<br /> </font> bind.AttributeId := <font color="#800000">"NAME"</font>;<br /> <font color="#008000">// Add binding for the INDICATOR field.<br /> </font> <font color="#008000">// Dictionary for cretaing dimension, corresponding to this field,<br /> </font> <font color="#008000">// is automatically created in MDM repository RDS_LOAD<br /> </font> DimBindings.Add(<font color="#800000">"INDICATOR"</font>);<br /> <font color="#008000">// Add binding for calendar dimension<br /> </font> Calend := DimBindings.AddCalendar(<font color="#800000">"Year"</font>, DimCalendarLevel.dclYear);<br /> <font color="#008000">// Create object for parsing dates in data source<br /> </font> DateConv := <font color="#008080">New</font> DateConverter.Create();<br /> <font color="#008000">// Set date format<br /> </font> DateConv.CalendarDateFormat := <font color="#800000">"$YEAR$"</font>;<br /> DateConv.ConvertShortYear := <font color="#008080">True</font>;<br /> <font color="#008000">// Set created object to calendar dimension binding<br /> </font> Calend.Converter := DateConv;<br /> <font color="#008000">// Add binding for data source values<br /> </font> loader.FactBindings.Add(<font color="#800000">"Value"</font>);<br /> <font color="#008000">// Create object for working with data source<br /> </font> creator := <font color="#008080">New</font> DtObjectCreator.Create();<br /> <font color="#008000">// Create text data source from file<br /> </font> prov := creator.CreateDtObjectFromFile(<font color="#800000">"C:\result_exp.txt"</font>) <font color="#008080">As</font> IDtTextProvider;<br /> <font color="#008000">// Specify field delimiter used in source<br /> </font> prov.DelimitedColumnDelimiter := <font color="#800000">";"</font>;<br /> <font color="#008000">// Load data and process loading result<br /> </font> Result := loader.LoadWithResult(prov, <font color="#008080">Null</font>);<br /> <font color="#008000">// Get object, to which data was loaded<br /> </font> Object := Result.Object;<br /> <font color="#008000">// Output information about object to console window<br /> </font> System.Diagnostics.Debug.WriteLine(<font color="#800000">"Name and identifier of created time series database: "</font> +<br /> Object.Name + <font color="#800000">"("</font> + Object.Id + <font color="#800000">")"</font>);<br /> <font color="#008000">// Get empty records and output them to console window<br /> </font> List := Result.NullStrings;<br /> <font color="#008080">If</font> List.Count <> <font color="#008000">0</font> <font color="#008080">Then</font><br /> System.Diagnostics.Debug.WriteLine(<font color="#800000">"Empty records:"</font>);<br /> <font color="#008080">For</font> <font color="#008080">Each</font> Item <font color="#008080">In</font> List <font color="#008080">Do</font><br /> Arr := Item <font color="#008080">As</font> IArrayList;<br /> <font color="#008080">For</font> i := <font color="#008000">0</font> <font color="#008080">To</font> Arr.Count - <font color="#008000">1</font> <font color="#008080">Do</font><br /> System.Diagnostics.Debug.Write(Arr.Item[i]);<br /> System.Diagnostics.Debug.Write(<font color="#800000">"; "</font>);<br /> <font color="#008080">End</font> <font color="#008080">For</font>;<br /> System.Diagnostics.Debug.WriteLine(<font color="#800000">""</font>);<br /> <font color="#008080">End</font> <font color="#008080">For</font>;<br /> <font color="#008080">End</font> <font color="#008080">If</font>;<br /> <font color="#008000">// Get duplicate records and output them to console window<br /> </font> List := Result.DuplicatedStrings;<br /> <font color="#008080">If</font> List.Count <> <font color="#008000">0</font> <font color="#008080">Then</font><br /> System.Diagnostics.Debug.WriteLine(<font color="#800000">"Duplicate records:"</font>);<br /> <font color="#008080">For</font> <font color="#008080">Each</font> Item <font color="#008080">In</font> List <font color="#008080">Do</font><br /> Arr := Item <font color="#008080">As</font> IArrayList;<br /> <font color="#008080">For</font> i := <font color="#008000">0</font> <font color="#008080">To</font> Arr.Count - <font color="#008000">1</font> <font color="#008080">Do</font><br /> System.Diagnostics.Debug.Write(Arr.Item[i]);<br /> System.Diagnostics.Debug.Write(<font color="#800000">"; "</font>);<br /> <font color="#008080">End</font> <font color="#008080">For</font>;<br /> System.Diagnostics.Debug.WriteLine(<font color="#800000">""</font>);<br /> <font color="#008080">End</font> <font color="#008080">For</font>;<br /> <font color="#008080">End</font> <font color="#008080">If</font>;<br /> <font color="#008080">End</font> <font color="#008080">Sub</font>;
See also: