LoadFile Methods

public bool LoadFile( string fileName, DataView dataview, bool readOnly, string customFileName, string logFileName = null, string customLogFileName = null )

 

public bool LoadFile( string fileName, bool readOnly, string customFileName, string viewFileName, string logFileName = null, string customLogFileName = null, string defaultViewFileName = null, string enterpriseFileName = null, string enterpriseLogFileName = null )

 

Description

The LoadFile methods load a base data source file into the DataSource. If the specified file cannot be found, a GeoCalcException will be thrown with an ErrorCode specifying XercesParseError.

The signatures of this method preserve some of the behavior from past releases by defaulting the newer parameters; you are able to add, remove, move, rename, or edit objects in the base datasource, the same as in the past. Any new objects will be added to the base datasource file.

The readOnly parameter indicates whether the base datasource can be edited. It is recommended that the readOnly parameter be set to true to indicate that the user may not add, remove, move, rename or edit objects in the base datasource to ensure that standard object definitions will not be altered.

The GeoCalc library also supports the use of a "custom" datasource which is loaded on top of the base datasource, in order to provide more flexibility to users, and to provide a sandbox for customization so that standard data objects can be preserved from inadvertent changes. To use the custom datasource, set the customFileName parameter to an xml filename of your choice. If this custom file does not already exist, it will be created once the data source is later saved via CommitToFile. Note that the custom data source file does not need to contain fully defined objects. For example, if a user has created a custom point style based on radians, the custom file will contain the new custom point style, but does not need to contain another definition of radians. It will rely on the base datasource to define radians. During the load, any objects in the custom file that were already loaded from the base file will be ignored.

In addition to the standard and custom datasources, the GeoCalc library also uses a "view" file which contains the presentation information for the display of objects in dialogs. This provides the ability to hide and reorganize objects, and to specify display names, without altering the actual datasource file. This also means there could be several different views employed that could then be used as filters so that different users are restricted to different sets of objects. A view file is distinguished by the ".xvw" extension. You can either specify the view file itself during the LoadFile, or they may load (or create) the view independently and then pass it into the LoadFile call. If the specified view does not exist yet, a default will be created and saved during the CommitToFile.

A defaultDataView parameter is provided in the second signature of LoadFile shown above to allow for specifying a default path for the view file, in case the file provided by viewFileName does not exist. This can be useful if you have multiple users of a GeoCalc app with access to a common drive, so that users can start with a default view from the common drive, which is then copied locally to store their personal edits going forward.

If the xml files being loaded are from GeoCalc v6.4 or earlier, they may contain the grouping information that is now split out into the view file. In this case, if you want to use the old grouping information, you can specify a new (non-existant) viewFileName and do not specify a default. The Load process will extract the grouping information from the datasource xml file. When CommitToFile is called, the folder structure will be stored in the specified new xvw file, and will be removed from the datasource xml file.

A single instance of the DataSource class can only be connected to a single base data source file and a single custom data source file. If the IsLoaded property is true when this method is called, the current base data source file (and custom data source file, if it exists) will be unloaded and the specified file(s) will be loaded.

When loading data from the base datasource file and the custom datasource file, if objects are encountered that are not in the specified view, they will be added under the top-level folder for their type. By default, base objects added in this way will be hidden in the view, but custom objects will be visible. If it is desired that base objects be added to the view as visible, use set_RefreshViewHidden(false).

The GeoCalc DataSource also has the ability to log changes to the base and custom datasources. In order to activate logging, the changeLog and/or customChangeLog parameters must be set to the desired log files. If the change logs already exist, they will be loaded first so users may access prior changes if desired. If the change logs do not already exist, they will be created when the datasource(s) are saved. If no change logs are specified, changes will not be logged.

Example

GeoCalc.DataSource data;

String filename("C:\\bmg\\GeoCalcNet\\GeoCalcFM90_N4\\data\\geodata.xml");

String customfilename("C:\\bmg\\GeoCalcNet\\GeoCalcFM90_N4\\data\\custom.xml");

String viewfilename("C:\\bmg\\GeoCalcNet\\GeoCalcFM90_N4\\data\\geodata.xvw");

if (!data.LoadFile(filename, true, customfilename, viewfilename)

{

System.Console.WriteLine("Failed to load " + dataSourcePathName);

}