Issue when creating a Checkout Replica in ArcObjects (from an ArcSDE geodatabse to a

المشرف العام

Administrator
طاقم الإدارة
I'm trying to create a checkout replica of some feature classes from an ArcSDE geodatabase to a file geodatabase using ArcObjects.

I'm trying to follow this: How to create a replica in a connected environment, but I'm getting an ArgumentException when calling CreateReplica with the following message: "The workspace is not connected".

Also, I can access the workspaces I'm using without any problems in other parts of the code.

I haven't been able to find the cause of the problem yet, could anyone help me with this?

Here are the relevant parts in my code:

//PS: _workspace is a private attributeprivate void replicateData(string path, string name, IGeometry area) { IWorkspace localWorkspace = CreateFileGDB(path, name); if (localWorkspace == null) return; IGeoDataServer parentGds = InitGeoDataServer(_workspace), childGds = InitGeoDataServer(localWorkspace); string replicaName = "replica_" + (DateTime.UtcNow - DateTime.MinValue).ToString().Replace(",",""); CreateFeatureDatasetReplica(parentGds, childGds, replicaName, esriReplicaAccessType.esriReplicaAccessNone, _workspace, area, false, false); }//Creates a file GDB, opens its workspace and returns itpublic IWorkspace CreateFileGDB(string path, string name) { if (Directory.Exists(path + name)) Directory.Delete(path + name, true); var workspaceFactory = new FileGDBWorkspaceFactoryClass() as WorkspaceFactory; IWorkspaceName workspaceName = workspaceFactory.Create(path, name, null, 0); return (IWorkspace)(workspaceName as IName).Open();//Opens a GeoDataServer from a workspace public static IGeoDataServer IniciaGeoDataServer(IWorkspace workspace) { IGeoDataServer geoDataServer = new GeoDataServerClass(); IGeoDataServerInit geoDataServerInit = (IGeoDataServerInit)geoDataServer; geoDataServerInit.InitWithWorkspace(workspace); return geoDataServer; }//Function to create the replica, based on the example linked abovepublic void CreateFeatureDatasetReplica(IGeoDataServer parentGDS, IGeoDataServer childGDS, String replicaName, esriReplicaAccessType accessType, IWorkspace parentWorkspace, IGeometry geometry, Boolean registerOnly, Boolean useArchiving) { IEnumDataset datasets = parentWorkspace.get_Datasets(esriDatasetType.esriDTFeatureClass); IGPReplicaDatasets gpReplicaDatasets = new GPReplicaDatasetsClass(); IDataset dataset; while ((dataset = datasets.Next()) != null) { //temporary workaround to not include a view that is on the feature classes :^) if (dataset.Name.Contains("VW_")) continue; IGPReplicaDataset gpReplicaDataset = new GPReplicaDatasetClass(); gpReplicaDataset.DatasetType = dataset.Type; gpReplicaDataset.Name = dataset.Name; gpReplicaDatasets.Add(gpReplicaDataset); } IGPReplicaDatasets gpReplicaDatasetsExpand = parentGDS.ExpandReplicaDatasets(gpReplicaDatasets); IGPReplicaDescription gpReplicaDesc = new GPReplicaDescriptionClass(); gpReplicaDesc.ReplicaDatasets = gpReplicaDatasetsExpand; gpReplicaDesc.ModelType = esriReplicaModelType.esriModelTypeFullGeodatabase; gpReplicaDesc.SingleGeneration = (accessType == esriReplicaAccessType.esriReplicaAccessNone); gpReplicaDesc.QueryGeometry = geometry; gpReplicaDesc.SpatialRelation = esriSpatialRelEnum.esriSpatialRelIndexIntersects; IGPReplicaOptions2 replicaOptions = new GPReplicaOptionsClass(); replicaOptions.AccessType = accessType; replicaOptions.ChildReconcilePolicy = esriReplicaReconcilePolicyType.esriReplicaResolveConflictsNone; replicaOptions.ParentReconcilePolicy = esriReplicaReconcilePolicyType.esriReplicaResolveConflictsNone; replicaOptions.IsChildFirstSender = true; replicaOptions.RegisterReplicaOnly = registerOnly; replicaOptions.UseArchiving = useArchiving; IReplicationAgent replicationAgent = new ReplicationAgentClass(); replicationAgent.CreateReplica("", parentGDS, childGDS, null, gpReplicaDesc, replicaOptions); }(How to initialize a GeoDataServer for reference on opening the GeoDataServer function)

Any help or hint is appreciated!



أكثر...
 
أعلى