/// <summary> /// Executes the specified load procedure. /// </summary> /// <param name="resourceID">The resource ID of the load procedure.</param> /// <param name="callback">The callback.</param> /// <returns></returns> public string[] Execute(string resourceID, OSGeo.MapGuide.MaestroAPI.LengthyOperationProgressCallBack callback) { if (!ResourceIdentifier.Validate(this.ResourceID)) { throw new ArgumentException("Invalid resource id: " + this.ResourceID); } if (ResourceIdentifier.GetResourceTypeAsString(this.ResourceID) != ResourceTypes.LoadProcedure.ToString()) { throw new ArgumentException("Not a load procedure resource id: " + this.ResourceID); } ILoadProcedure proc = (ILoadProcedure)this.Parent.ResourceService.GetResource(resourceID); return(Execute(proc, callback)); }
public override void Bind(IEditorService service) { service.RegisterCustomNotifier(this); _service = service; _loadProc = _service.GetEditedResource() as ILoadProcedure; _fProc = _loadProc.SubType; TextBoxBinder.BindText(txtTargetRoot, _fProc, "RootPath"); CheckBoxBinder.BindChecked(chkCreateFeatureSources, _fProc, "GenerateSpatialDataSources"); CheckBoxBinder.BindChecked(chkCreateLayers, _fProc, "GenerateLayers"); TextBoxBinder.BindText(txtFeatureSourceRoot, _fProc, "SpatialDataSourcesPath"); TextBoxBinder.BindText(txtFeatureFolderName, _fProc, "SpatialDataSourcesFolder"); TextBoxBinder.BindText(txtLayerRoot, _fProc, "LayersPath"); TextBoxBinder.BindText(txtLayerFolderName, _fProc, "LayersFolder"); _fProc.PropertyChanged += WeakEventHandler.Wrap <PropertyChangedEventHandler>(OnLoadProcedurePropertyChanged, (eh) => _fProc.PropertyChanged -= eh); }
public override void Bind(IEditorService service) { service.RegisterCustomNotifier(this); _service = service; _loadProc = _service.GetEditedResource() as ILoadProcedure; _fProc = _loadProc.SubType; TextBoxBinder.BindText(txtTargetRoot, _fProc, "RootPath"); CheckBoxBinder.BindChecked(chkCreateFeatureSources, _fProc, "GenerateSpatialDataSources"); CheckBoxBinder.BindChecked(chkCreateLayers, _fProc, "GenerateLayers"); TextBoxBinder.BindText(txtFeatureSourceRoot, _fProc, "SpatialDataSourcesPath"); TextBoxBinder.BindText(txtFeatureFolderName, _fProc, "SpatialDataSourcesFolder"); TextBoxBinder.BindText(txtLayerRoot, _fProc, "LayersPath"); TextBoxBinder.BindText(txtLayerFolderName, _fProc, "LayersFolder"); _fProc.PropertyChanged += OnLoadProcedurePropertyChanged; }
/// <summary> /// Executes the specified load procedure. Only SDF and SHP load procedures are supported. /// Also note that the following load procedure features are ignored during execution: /// - Generalization of data /// - Conversion from SHP to SDF /// - SDF2 to SDF3 conversion /// - SDF3 duplicate key handling /// </summary> /// <param name="proc">The proc.</param> /// <param name="callback">The callback.</param> /// <returns> /// A list of resource IDs that were created from the execution of this load procedure /// </returns> public string[] Execute(ILoadProcedure proc, LengthyOperationProgressCallBack callback) { //TODO: Localize callback messages //TODO: Localize exception messages //TODO: This would currently overwrite everything. In reality, the load procedure has //a list of resource ids which are overwritable, anything not on the list is untouchable. //I presume if this list is empty, then everything is overwritten and the resource list //list is then assigned to the load procedure, which is then updated so that on subsequent runs, //only resources in the list are overwritten instead of everything. string[] resourcesCreatedOrUpdated = null; LengthyOperationProgressCallBack cb = callback; //Assign dummy callback if none specified if (cb == null) cb = delegate { }; //bool loadProcedureUpdated = false; //bool updateGeneratedResourceIds = false; //TODO: SDF and SHP load procedures share lots of common logic. Merge the two //once everything's all good. var type = proc.SubType.Type; if (type == LoadType.Dwg || type == LoadType.Raster) throw new NotSupportedException(Strings.UnsupportedLoadProcedureType); var sproc = (IBaseLoadProcedure)proc.SubType; bool firstExecute = true; if (type == LoadType.Shp) { var shpl = (IShpLoadProcedure)sproc; if (!this.IgnoreUnsupportedFeatures) { //Anything less than 100% implies use of generalization if (shpl.Generalization < 100.0) { throw new NotSupportedException(Strings.LPROC_GeneralizationNotSupported); } //Can't do this because we don't have a portable .net FDO/MG Feature Service if (shpl.ConvertToSdf) { throw new NotSupportedException(Strings.LPROC_ConvertToSdf3NotSupported); } } resourcesCreatedOrUpdated = ExecuteShpLoadProcedure(cb, shpl, ref firstExecute); } else { if (!this.IgnoreUnsupportedFeatures) { CheckUnsupportedFeatures(sproc); } resourcesCreatedOrUpdated = ExecuteBaseProcedure(cb, sproc, ref firstExecute); } //Update the generated resources list if this is the first execution if (firstExecute) { sproc.ResourceId.Clear(); foreach (var it in resourcesCreatedOrUpdated) { sproc.ResourceId.Add(it); } //Before we'd save here, but instead let's mark the resource as dirty from the user side } return resourcesCreatedOrUpdated; }
/// <summary> /// Executes the specified load procedure. Only SDF and SHP load procedures are supported. /// Also note that the following load procedure features are ignored during execution: /// - Generalization of data /// - Conversion from SHP to SDF /// - SDF2 to SDF3 conversion /// - SDF3 duplicate key handling /// </summary> /// <param name="proc">The proc.</param> /// <param name="callback">The callback.</param> /// <returns> /// A list of resource IDs that were created from the execution of this load procedure /// </returns> public string[] Execute(ILoadProcedure proc, LengthyOperationProgressCallBack callback) { //TODO: Localize callback messages //TODO: Localize exception messages //TODO: This would currently overwrite everything. In reality, the load procedure has //a list of resource ids which are overwritable, anything not on the list is untouchable. //I presume if this list is empty, then everything is overwritten and the resource list //list is then assigned to the load procedure, which is then updated so that on subsequent runs, //only resources in the list are overwritten instead of everything. string[] resourcesCreatedOrUpdated = null; LengthyOperationProgressCallBack cb = callback; //Assign dummy callback if none specified if (cb == null) { cb = delegate { } } ; //bool loadProcedureUpdated = false; //bool updateGeneratedResourceIds = false; //TODO: SDF and SHP load procedures share lots of common logic. Merge the two //once everything's all good. var type = proc.SubType.Type; if (type == LoadType.Dwg || type == LoadType.Raster) { throw new NotSupportedException(Strings.UnsupportedLoadProcedureType); } var sproc = (IBaseLoadProcedure)proc.SubType; bool firstExecute = true; if (type == LoadType.Shp) { var shpl = (IShpLoadProcedure)sproc; if (!this.IgnoreUnsupportedFeatures) { //Anything less than 100% implies use of generalization if (shpl.Generalization < 100.0) { throw new NotSupportedException(Strings.LPROC_GeneralizationNotSupported); } //Can't do this because we don't have a portable .net FDO/MG Feature Service if (shpl.ConvertToSdf) { throw new NotSupportedException(Strings.LPROC_ConvertToSdf3NotSupported); } } resourcesCreatedOrUpdated = ExecuteShpLoadProcedure(cb, shpl, ref firstExecute); } else { if (!this.IgnoreUnsupportedFeatures) { CheckUnsupportedFeatures(sproc); } resourcesCreatedOrUpdated = ExecuteBaseProcedure(cb, sproc, ref firstExecute); } //Update the generated resources list if this is the first execution if (firstExecute) { sproc.ResourceId.Clear(); foreach (var it in resourcesCreatedOrUpdated) { sproc.ResourceId.Add(it); } //Before we'd save here, but instead let's mark the resource as dirty from the user side } return(resourcesCreatedOrUpdated); }