Class ResourceMigrator
A helper class that copies/moves resources from one connection to another
Inheritance
Inherited Members
Namespace: OSGeo.MapGuide.MaestroAPI.CrossConnection
Assembly: OSGeo.MapGuide.MaestroAPI.dll
Syntax
public class ResourceMigrator
Examples
This example shows how to copy resources from one connection to another using the ResourceMigrator class
IServerConnection sourceConn;
IServerConnection targetConn;
...
ResourceMigrator migrator = new ResourceMigrator(sourceConn, targetConn);
//These are the source resource ids to copy
string [] sourceIds = new string[] {
"Library://Samples/Sheboyan/Data/Parcels.FeatureSource",
"Library://Samples/Sheboyan/Data/Rail.FeatureSource",
"Library://Samples/Sheboyan/Data/Islands.FeatureSource",
"Library://Samples/Sheboyan/Data/Buildings.FeatureSource"
};
//These the the target ids we are copying to. The number of source and
//target ids must be the same
string [] targetIds = new string[] {
"Library://Production/Data/Parcels.FeatureSource",
"Library://Production/Data/Rail.FeatureSource",
"Library://Production/Data/Islands.FeatureSource",
"Library://Production/Data/Buildings.FeatureSource"
};
//Set up the re-base options. This is generally the common parent of the source and target ids.
//This is to ensure that any resource ids references are updated as they are copied across
RebaseOptions options = new RebaseOptions("Library://Samples/Sheboygan/", "Library://Production/");
bool bOverwrite = true;
//Execute the migration
string [] copied = migrator.CopyResources(sourceIds, targetIds, bOverwrite, options, null);
Constructors
| Improve this Doc View SourceResourceMigrator(IServerConnection, IServerConnection)
Initializes a new instance of the ResourceMigrator class.
Declaration
public ResourceMigrator(IServerConnection source, IServerConnection target)
Parameters
Type | Name | Description |
---|---|---|
IServerConnection | source | The source. |
IServerConnection | target | The target. |
Properties
| Improve this Doc View SourceSource
Gets the source connection
Declaration
public IServerConnection Source { get; }
Property Value
Type | Description |
---|---|
IServerConnection |
Target
Gets the target connection
Declaration
public IServerConnection Target { get; }
Property Value
Type | Description |
---|---|
IServerConnection |
Methods
| Improve this Doc View SourceCopyResources(String[], String, Boolean, LengthyOperationProgressCallBack)
Copies resources from the source connection to another connection. The resources in question will be copied to the specified folder. Folder structure of the source is discarded
Declaration
public int CopyResources(string[] resourceIds, string folderId, bool overwrite, LengthyOperationProgressCallBack callback)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | resourceIds | |
System.String | folderId | |
System.Boolean | overwrite | |
LengthyOperationProgressCallBack | callback |
Returns
Type | Description |
---|---|
System.Int32 |
CopyResources(String[], String[], Boolean, RebaseOptions, LengthyOperationProgressCallBack)
Copies resource from the source connection to another connection.
Declaration
public string[] CopyResources(string[] sourceResourceIds, string[] targetResourceIds, bool overwrite, RebaseOptions options, LengthyOperationProgressCallBack callback)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | sourceResourceIds | The array of source resource ids |
System.String[] | targetResourceIds | The array of target resource ids to copy to. Each resource id in the source array will be copied to the corresponding resource id in the target array |
System.Boolean | overwrite | Indicates whether to overwrite |
RebaseOptions | options | Re-base options |
LengthyOperationProgressCallBack | callback |
Returns
Type | Description |
---|---|
System.String[] |
MigrateResource(String, Boolean, LengthyOperationProgressCallBack)
Shortcut API to migrate a specific resource to the target connection. Dependent resources are automatically migrated as well. This copies all dependent resources of the specified resource.
Declaration
public string[] MigrateResource(string resourceId, bool overwrite, LengthyOperationProgressCallBack callback)
Parameters
Type | Name | Description |
---|---|---|
System.String | resourceId | The id of the resource to migrate |
System.Boolean | overwrite | If true, all dependent resources that already exist in the target connection are overwritten, otherwise these are not copied over |
LengthyOperationProgressCallBack | callback | A callback method to indicate progress |
Returns
Type | Description |
---|---|
System.String[] | An array of resource ids that were succesfully migrated |
MigrateResource(String, String[], Boolean, LengthyOperationProgressCallBack)
Migrates a specific resource (and its dependent resources) to the target connection
Declaration
public string[] MigrateResource(string resourceId, string[] dependentResourceIds, bool overwrite, LengthyOperationProgressCallBack callback)
Parameters
Type | Name | Description |
---|---|---|
System.String | resourceId | The id of the resource to migrate |
System.String[] | dependentResourceIds | The array of dependent resource ids |
System.Boolean | overwrite | If true, all dependent resources that already exist in the target connection are overwritten, otherwise these are not copied over |
LengthyOperationProgressCallBack | callback | A callback method to indicate progress |
Returns
Type | Description |
---|---|
System.String[] | An array of resource ids that were succesfully migrated |
MoveResources(String[], String, Boolean, LengthyOperationProgressCallBack)
Moves resources from the source connection to the specified folder on the target connection. Folder structure of the source is discarded
Declaration
public int MoveResources(string[] resourceIds, string folderId, bool overwrite, LengthyOperationProgressCallBack callback)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | resourceIds | |
System.String | folderId | |
System.Boolean | overwrite | |
LengthyOperationProgressCallBack | callback |
Returns
Type | Description |
---|---|
System.Int32 |