コード例 #1
0
        public override bool Exexute()
        {
            IWorkspace workspace = GisDataHelper.OpenWorkspace(dataSourceId);

            if (workspace.HasFeatureClass(layerName) && deleteOld)
            {
                workspace.DeleteFeatureClass(layerName);
            }
            IFeatureClass targetFeatureClass = workspace.TryOpenFeatureClass(layerName);

            if (targetFeatureClass == null)
            {
                if (shpPaths.Length > 0)
                {
                    IFeatureClass shpFeatureClass = XWorkspace.OpenShapeFile(shpPaths[0]);
                    targetFeatureClass = workspace.CreateFeatureClass(layerName, shpFeatureClass.Fields);
                }
            }
            else
            {
                if (clearRecord)
                {
                    targetFeatureClass.Delete();
                }
            }
            for (int i = 0; i < shpPaths.Length; i++)
            {
                IFeatureClass shpFeatureClass = XWorkspace.OpenShapeFile(shpPaths[i]);
                shpFeatureClass.CopyTo(targetFeatureClass);
            }
            Output = targetFeatureClass;
            return(Output != null);
        }