public override int Execute() { CommandStatus retCode = CommandStatus.E_OK; bool create = ExpressUtility.CreateFlatFileDataSource(_file); if (!create) { WriteLine("Failed to create file {0}", _file); retCode = CommandStatus.E_FAIL_CREATE_DATASTORE; return((int)retCode); } WriteLine("File {0} created", _file); if (_schema != null) { try { FdoConnection conn = ExpressUtility.CreateFlatFileConnection(_file); conn.Open(); using (FdoFeatureService service = conn.CreateFeatureService()) { service.LoadSchemasFromXml(_schema); WriteLine("Schema applied to {0}", _file); } retCode = CommandStatus.E_OK; } catch (Exception ex) { WriteException(ex); retCode = CommandStatus.E_FAIL_APPLY_SCHEMA; } } return((int)retCode); }
public bool CreateSqlite() { if (_view.CreateConnection && string.IsNullOrEmpty(_view.ConnectionName)) { _view.ShowError("Specify a connection name"); return(false); } if (ExpressUtility.CreateFlatFileDataSource("OSGeo.SQLite", _view.SQLiteFile)) { FdoConnection conn = ExpressUtility.CreateFlatFileConnection("OSGeo.SQLite", _view.SQLiteFile); if (FileService.FileExists(_view.FeatureSchemaDefinition)) { conn.Open(); using (FdoFeatureService service = conn.CreateFeatureService()) { service.LoadSchemasFromXml(_view.FeatureSchemaDefinition, _view.FixIncompatibilities); } } if (_view.CreateConnection) { _connMgr.AddConnection(_view.ConnectionName, conn); } else { conn.Dispose(); } } return(true); }
internal void SchemaChanged(JoinSourceType type) { if (type == JoinSourceType.Target) { return; } _view.ClearJoins(); FdoConnection conn = GetConnection(type); if (conn != null) { using (FdoFeatureService service = conn.CreateFeatureService()) { switch (type) { case JoinSourceType.Left: _view.LeftClasses = service.GetClassNames(_view.SelectedLeftSchema); ClassChanged(type); break; case JoinSourceType.Right: _view.RightClasses = service.GetClassNames(_view.SelectedRightSchema); ClassChanged(type); break; } } } }
public override void ExecuteAction() { using (FdoFeatureService svc = _conn.CreateFeatureService()) { using (IDelete del = svc.CreateCommand <IDelete>(OSGeo.FDO.Commands.CommandType.CommandType_Delete)) { try { del.SetFeatureClassName(_className); if (!string.IsNullOrEmpty(_filter)) { del.SetFilter(_filter); Info("Deleting everything from class " + _className + " with filter: " + _filter); } else { Info("Deleting everything from class: " + _className); } int result = del.Execute(); Info(result + " features deleted from class: " + _className); } catch (OSGeo.FDO.Common.Exception ex) { Error(ex, "Error occured executing delete"); } } } }
public override int Execute() { IConnection conn = null; try { conn = CreateConnection(_provider, _connstr); conn.Open(); } catch (OSGeo.FDO.Common.Exception ex) { WriteException(ex); return (int)CommandStatus.E_FAIL_CONNECT; } if (Array.IndexOf<int>(conn.CommandCapabilities.Commands, (int)CommandType.CommandType_ListDataStores) < 0) return (int)CommandStatus.E_FAIL_UNSUPPORTED_CAPABILITY; using (FdoFeatureService service = new FdoFeatureService(conn)) { ReadOnlyCollection<DataStoreInfo> datastores = service.ListDataStores(_FdoOnly); Console.WriteLine("Listing datastores:\n"); foreach (DataStoreInfo dstore in datastores) { Console.WriteLine("\n\tName:{0}\n\tDescription:{1}", dstore.Name, dstore.Description); } } conn.Close(); return (int)CommandStatus.E_OK; }
public override int Execute() { IConnection conn = null; try { conn = CreateConnection(_provider, _connstr); conn.Open(); } catch (OSGeo.FDO.Common.Exception ex) { WriteException(ex); return (int)CommandStatus.E_FAIL_CONNECT; } using (FdoFeatureService service = new FdoFeatureService(conn)) { ReadOnlyCollection<SpatialContextInfo> contexts = service.GetSpatialContexts(); Console.WriteLine("\nSpatial Contexts in connection: {0}", contexts.Count); foreach (SpatialContextInfo ctx in contexts) { Console.WriteLine("\nName: {0}\n", ctx.Name); Console.WriteLine("\tDescriptionn: {0}", ctx.Description); Console.WriteLine("\tXY Tolerance: {0}\n\tZ Tolerance: {1}", ctx.XYTolerance, ctx.ZTolerance); Console.WriteLine("\tCoordinate System: {0}\n\tCoordinate System WKT:\n\t\t{1}", ctx.CoordinateSystem, ctx.CoordinateSystemWkt); Console.WriteLine("\tExtent Type: {0}", ctx.ExtentType); if (ctx.ExtentType == OSGeo.FDO.Commands.SpatialContext.SpatialContextExtentType.SpatialContextExtentType_Static) Console.WriteLine("\tExtent:\n\t\t{0}", ctx.ExtentGeometryText); } } conn.Close(); return (int)CommandStatus.E_OK; }
public override int Execute() { IConnection conn = null; try { conn = CreateConnection(_provider, _connstr); conn.Open(); } catch (OSGeo.FDO.Common.Exception ex) { WriteException(ex); return((int)CommandStatus.E_FAIL_CONNECT); } using (FdoFeatureService service = new FdoFeatureService(conn)) { ReadOnlyCollection <SpatialContextInfo> contexts = service.GetSpatialContexts(); Console.WriteLine("\nSpatial Contexts in connection: {0}", contexts.Count); foreach (SpatialContextInfo ctx in contexts) { Console.WriteLine("\nName: {0}\n", ctx.Name); Console.WriteLine("\tDescriptionn: {0}", ctx.Description); Console.WriteLine("\tXY Tolerance: {0}\n\tZ Tolerance: {1}", ctx.XYTolerance, ctx.ZTolerance); Console.WriteLine("\tCoordinate System: {0}\n\tCoordinate System WKT:\n\t\t{1}", ctx.CoordinateSystem, ctx.CoordinateSystemWkt); Console.WriteLine("\tExtent Type: {0}", ctx.ExtentType); if (ctx.ExtentType == OSGeo.FDO.Commands.SpatialContext.SpatialContextExtentType.SpatialContextExtentType_Static) { Console.WriteLine("\tExtent:\n\t\t{0}", ctx.ExtentGeometryText); } } } conn.Close(); return((int)CommandStatus.E_OK); }
public FdoDataPreviewPresenter(IFdoDataPreviewView view, FdoConnection conn) { _timer = new Timer(); _view = view; _connection = conn; _service = conn.CreateFeatureService(); _queryViews = new Dictionary <QueryMode, IQuerySubView>(); _queryWorker = new BackgroundWorker(); _queryWorker.WorkerReportsProgress = true; _queryWorker.WorkerSupportsCancellation = true; _queryWorker.DoWork += new DoWorkEventHandler(DoWork); //_queryWorker.ProgressChanged += new ProgressChangedEventHandler(ProgressChanged); _queryWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(RunWorkerCompleted); _view.ElapsedMessage = string.Empty; _view.CancelEnabled = false; _view.ExecuteEnabled = true; insertSupported = (Array.IndexOf(conn.Capability.GetArrayCapability(CapabilityType.FdoCapabilityType_CommandList), OSGeo.FDO.Commands.CommandType.CommandType_Insert) >= 0); updateSupported = (Array.IndexOf(conn.Capability.GetArrayCapability(CapabilityType.FdoCapabilityType_CommandList), OSGeo.FDO.Commands.CommandType.CommandType_Update) >= 0); deleteSupported = (Array.IndexOf(conn.Capability.GetArrayCapability(CapabilityType.FdoCapabilityType_CommandList), OSGeo.FDO.Commands.CommandType.CommandType_Delete) >= 0); _view.DeleteEnabled = deleteSupported; _view.UpdateEnabled = updateSupported; _timer.Interval = 1000; _timer.Elapsed += new ElapsedEventHandler(OnTimerElapsed); }
private void CreateDefaultSpatialContext(FdoFeatureService svc) { var sc = _view.CreateDefaultSpatialContext(); //You would've thought ICreateSpatialContext with updateExisting = true //would do the job, but noooo we have to actually destroy the existing //one first. Annoying! bool destroy = false; var spcs = svc.GetSpatialContexts(); foreach (var spc in spcs) { if (spc.Name == sc.Name) { destroy = true; break; } } if (destroy) { svc.DestroySpatialContext(sc.Name); } svc.CreateSpatialContext(sc, false); }
public void TestInt16Promotion() { DataType[] dtypes = new DataType[] { DataType.DataType_String }; //int16 -> string DataType dt = FdoFeatureService.GetPromotedDataType(DataType.DataType_Int16, dtypes); Assert.AreEqual(DataType.DataType_String, dt); dtypes = new DataType[] { DataType.DataType_String, DataType.DataType_Int64 }; //int16 -> int64 dt = FdoFeatureService.GetPromotedDataType(DataType.DataType_Int16, dtypes); Assert.AreEqual(DataType.DataType_Int64, dt); dtypes = (DataType[])Enum.GetValues(typeof(DataType)); //int16 -> int32 dt = FdoFeatureService.GetPromotedDataType(DataType.DataType_Int16, dtypes); Assert.AreEqual(DataType.DataType_Int32, dt); //No suitable data type dtypes = new DataType[] { DataType.DataType_CLOB, DataType.DataType_BLOB }; try { dt = FdoFeatureService.GetPromotedDataType(DataType.DataType_Int16, dtypes); Assert.Fail("Should have failed to find suitable data type"); } catch (FeatureServiceException) { } }
/// <summary> /// Validates this instance. /// </summary> public void Validate() { foreach (FdoClassCopyOptions copt in this.ClassCopyOptions) { FdoConnection src = GetConnection(copt.SourceConnectionName); FdoConnection dst = GetConnection(copt.TargetConnectionName); if (src == null) { throw new TaskValidationException("The specified source connection name does not exist"); } if (dst == null) { throw new TaskValidationException("The specified target connection name does not exist"); } using (FdoFeatureService srcSvc = src.CreateFeatureService()) using (FdoFeatureService dstSvc = dst.CreateFeatureService()) { ClassDefinition srcCls = srcSvc.GetClassByName(copt.SourceSchema, copt.SourceClassName); ClassDefinition dstCls = dstSvc.GetClassByName(copt.TargetSchema, copt.TargetClassName); if (srcCls == null) { throw new TaskValidationException("The specified source feature class does not exist"); } if (dstCls == null) { throw new TaskValidationException("The specified target feature class does not exist"); } } } }
public override int Execute() { IConnection conn = null; try { conn = CreateConnection(_provider, _connstr); conn.Open(); } catch (OSGeo.FDO.Common.Exception ex) { WriteException(ex); return((int)CommandStatus.E_FAIL_CONNECT); } using (FdoFeatureService service = new FdoFeatureService(conn)) { using (FeatureSchemaCollection schemas = service.DescribeSchema()) { Console.WriteLine("\nSchemas in this connection: {0}", schemas.Count); foreach (FeatureSchema fs in schemas) { Console.WriteLine("\nName: {0}\n", fs.Name); Console.WriteLine("\tQualified Name: {0}", fs.QualifiedName); Console.WriteLine("\tAttributes:"); WriteAttributes(fs.Attributes); } } } conn.Close(); return((int)CommandStatus.E_OK); }
/// <summary> /// Copies all spatial contexts /// </summary> /// <param name="spatialContexts">The spatial contexts.</param> /// <param name="target">The target.</param> /// <param name="overwrite">if set to <c>true</c> [overwrite].</param> public override void Execute(ICollection <SpatialContextInfo> spatialContexts, FdoConnection target, bool overwrite) { //MySQL supports multiple spatial contexts and IDestorySpatialContext //so in this case if overwrite == true, we want to destroy any ones that //already exist in the target before creating new ones in its place. This does not //prevent creating a series of spatial contexts if overwrite == false and one of //the spatial contexts being copied already exists. This is an unfortunate leaky //abstraction in the FDO API. using (FdoFeatureService service = target.CreateFeatureService()) { if (overwrite) { ReadOnlyCollection <SpatialContextInfo> targetContexts = service.GetSpatialContexts(); foreach (SpatialContextInfo sc in spatialContexts) { //Only destroy spatial context if it exists in target connection if (SpatialContextExists(targetContexts, sc)) { service.DestroySpatialContext(sc); } } } foreach (SpatialContextInfo sc in spatialContexts) { service.CreateSpatialContext(sc, false); } } }
public void CopySpatialContexts() { List <SpatialContextInfo> contexts = new List <SpatialContextInfo>(); FdoConnection srcConn = _connMgr.GetConnection(_view.SourceConnectionName); FdoConnection targetConn = _connMgr.GetConnection(_view.SelectedTargetConnectionName); using (FdoFeatureService service = srcConn.CreateFeatureService()) { foreach (string ctxName in _view.SpatialContexts) { SpatialContextInfo sc = service.GetSpatialContext(ctxName); if (sc != null) { contexts.Add(sc); } } } if (contexts.Count == 0) { _view.ShowMessage(null, ResourceService.GetString("MSG_NO_SPATIAL_CONTEXTS_COPIED")); return; } ExpressUtility.CopyAllSpatialContexts(contexts, targetConn, _view.Overwrite); _view.ShowMessage(null, ResourceService.GetString("MSG_SPATIAL_CONTEXTS_COPIED")); _view.Close(); }
public override int Execute() { IConnection conn = null; try { conn = CreateConnection(_provider, _connstr); conn.Open(); } catch (OSGeo.FDO.Common.Exception ex) { WriteException(ex); return (int)CommandStatus.E_FAIL_CONNECT; } using (FdoFeatureService service = new FdoFeatureService(conn)) { using (FeatureSchemaCollection schemas = service.DescribeSchema()) { Console.WriteLine("\nSchemas in this connection: {0}", schemas.Count); foreach (FeatureSchema fs in schemas) { Console.WriteLine("\nName: {0}\n", fs.Name); Console.WriteLine("\tQualified Name: {0}", fs.QualifiedName); Console.WriteLine("\tAttributes:"); WriteAttributes(fs.Attributes); } } } conn.Close(); return (int)CommandStatus.E_OK; }
internal OptionsNodeDecorator(CopyTaskNodeDecorator parent, TreeNode optionsNode) { Parent = parent; _node = optionsNode; InitContextMenus(); //Options - Delete Target TreeNode delTargetNode = new TreeNode("Delete Target"); delTargetNode.ToolTipText = "Delete all features on the feature class before copying (true: enabled, false: disabled)"; delTargetNode.Name = OPT_DEL_TARGET; delTargetNode.ContextMenuStrip = ctxDeleteTarget; //Options - Source Class Filter TreeNode srcFilterNode = new TreeNode("Source Class Filter"); srcFilterNode.ToolTipText = "The filter to apply to the source query where the features will be copied from"; srcFilterNode.Name = OPT_CLS_FILTER; srcFilterNode.ContextMenuStrip = ctxSourceFilter; //Options - Flatten Geometries TreeNode flattenNode = new TreeNode("Flatten Geometries"); flattenNode.ToolTipText = "If true, will strip all Z and M coordinates from geometries being copied"; flattenNode.Name = OPT_FLATTEN; flattenNode.ContextMenuStrip = ctxFlatten; //Options - Force WKB TreeNode forceWkbNode = new TreeNode("Force WKB Geometry"); forceWkbNode.ToolTipText = "If true, will force the input geometry to be WKB compliant"; forceWkbNode.Name = OPT_FORCEWKB; forceWkbNode.ContextMenuStrip = ctxForceWkb; _node.Nodes.Add(delTargetNode); _node.Nodes.Add(srcFilterNode); _node.Nodes.Add(flattenNode); _node.Nodes.Add(forceWkbNode); //Set default values to avoid any nasty surprises this.Delete = false; this.SourceFilter = string.Empty; this.Flatten = false; this.ForceWkb = false; //Test for batch support using (FdoFeatureService svc = Parent.GetTargetConnection().CreateFeatureService()) { if (svc.SupportsBatchInsertion()) { TreeNode batchNode = new TreeNode("Insert Batch Size"); batchNode.ToolTipText = "The batch size to use for batch insert. If set to 0, normal insert will be used"; batchNode.ContextMenuStrip = ctxBatchSize; _node.Nodes.Add(batchNode); //Set default values to avoid any nasty surprises this.BatchSize = 0; } } }
public void Init() { _view.InitializeGrid(); _view.UseTransactionEnabled = (_conn.Capability.GetBooleanCapability(CapabilityType.FdoCapabilityType_SupportsTransactions)); using (FdoFeatureService service = _conn.CreateFeatureService()) { ClassDefinition cd = service.GetClassByName(_className); if (cd != null) { _view.ClassName = cd.Name; foreach (PropertyDefinition pd in cd.Properties) { switch (pd.PropertyType) { case PropertyType.PropertyType_DataProperty: _view.AddDataProperty((DataPropertyDefinition)pd); break; case PropertyType.PropertyType_GeometricProperty: _view.AddGeometricProperty((GeometricPropertyDefinition)pd); break; } } } } }
private static void SetConnectionToolTip(TreeNode connNode, FdoConnection conn) { using (FdoFeatureService service = conn.CreateFeatureService()) { List <string> ctxStrings = new List <string>(); try { ICollection <SpatialContextInfo> contexts = service.GetSpatialContexts(); foreach (SpatialContextInfo sci in contexts) { if (sci.IsActive) { ctxStrings.Add("- " + sci.Name + " (Active)"); } else { ctxStrings.Add("- " + sci.Name); } } } catch { ctxStrings.Add("Could not retrieve spatial contexts"); } string configStatus = conn.HasConfiguration ? "(This connection has custom configuration applied)" : string.Empty; connNode.ToolTipText = string.Format( "Provider: {0}{4}Type: {1}{4}Connection String: {2}{4}Spatial Contexts:{4}{3}{4}{5}", conn.Provider, conn.DataStoreType, conn.SafeConnectionString, ctxStrings.Count > 0 ? string.Join("\n", ctxStrings.ToArray()) : "none", Environment.NewLine, configStatus); } }
/// <summary> /// Initializes this instance. /// </summary> protected override void Initialize() { SendMessage("Creating target data source"); if (!ExpressUtility.CreateFlatFileDataSource(_outputFile)) { throw new FdoETLException(ResourceUtil.GetStringFormatted("ERR_CANNOT_CREATE_DATA_FILE", _outputFile)); } _outConn = ExpressUtility.CreateFlatFileConnection(_outputFile); _outConn.Open(); ClassDefinition cd = _table.CreateClassDefinition(true); using (FdoFeatureService service = _outConn.CreateFeatureService()) { SendMessage("Applying schema to target"); FeatureSchema schema = new FeatureSchema("Schema1", "Default schema"); schema.Classes.Add(cd); service.ApplySchema(schema); } SendMessage("Copying any attached spatial contexts"); ExpressUtility.CopyAllSpatialContexts(_table.SpatialContexts, _outConn, true); Register(new FdoFeatureTableInputOperation(_table)); Register(new FdoOutputOperation(_outConn, cd.Name)); }
/// <summary> /// Gets all class names from the specified flat-file data source /// </summary> /// <param name="sourceFile"></param> /// <returns></returns> public static string[] GetClassNames(string sourceFile) { List <string> classnames = new List <string>(); FdoConnection source = null; try { source = CreateFlatFileConnection(sourceFile); source.Open(); using (FdoFeatureService svc = source.CreateFeatureService()) { using (FeatureSchemaCollection schemas = svc.DescribeSchema()) { foreach (FeatureSchema sch in schemas) { foreach (ClassDefinition cd in sch.Classes) { classnames.Add(cd.Name); } } } } } catch (Exception ex) { } finally { if (source != null) { source.Dispose(); } } return(classnames.ToArray()); }
public override int Execute() { IConnection conn = null; try { conn = CreateConnection(_provider, _connstr); conn.Open(); } catch (OSGeo.FDO.Common.Exception ex) { WriteException(ex); return((int)CommandStatus.E_FAIL_CONNECT); } if (Array.IndexOf <int>(conn.CommandCapabilities.Commands, (int)CommandType.CommandType_ListDataStores) < 0) { return((int)CommandStatus.E_FAIL_UNSUPPORTED_CAPABILITY); } using (FdoFeatureService service = new FdoFeatureService(conn)) { ReadOnlyCollection <DataStoreInfo> datastores = service.ListDataStores(_FdoOnly); Console.WriteLine("Listing datastores:\n"); foreach (DataStoreInfo dstore in datastores) { Console.WriteLine("\n\tName:{0}\n\tDescription:{1}", dstore.Name, dstore.Description); } } conn.Close(); return((int)CommandStatus.E_OK); }
internal void ConnectionChanged(JoinSourceType type) { if (type != JoinSourceType.Target) { _view.ClearJoins(); } FdoConnection conn = GetConnection(type); if (conn != null) { using (FdoFeatureService service = conn.CreateFeatureService()) { switch (type) { case JoinSourceType.Left: _view.LeftSchemas = service.GetSchemaNames(); SchemaChanged(type); break; case JoinSourceType.Right: _view.RightSchemas = service.GetSchemaNames(); SchemaChanged(type); break; case JoinSourceType.Target: _view.TargetSchemas = service.GetSchemaNames(); SchemaChanged(type); break; } } } }
public FdoAggregateQueryPresenter(IFdoAggregateQueryView view, FdoConnection conn) { _view = view; _conn = conn; _service = _conn.CreateFeatureService(); _view.OrderingEnabled = false; _walker = SchemaWalker.GetWalker(conn); }
public FdoSpatialContextBrowserDlg(FdoConnection conn) : this() { using (FdoFeatureService service = conn.CreateFeatureService()) { grdSpatialContexts.DataSource = service.GetSpatialContexts(); } }
public FdoStandardQueryPresenter(IFdoStandardQueryView view, FdoConnection conn) { _view = view; _conn = conn; _service = _conn.CreateFeatureService(); _view.OrderingEnabled = conn.Capability.GetBooleanCapability(CapabilityType.FdoCapabilityType_SupportsSelectOrdering); _walker = SchemaWalker.GetWalker(conn); }
internal void TestUpdate() { using (FdoFeatureService service = _conn.CreateFeatureService()) { long count = service.GetFeatureCount(_className, _view.Filter, true); _view.ShowMessage(null, count + " feature(s) would be updated"); } }
public bool Unregister() { foreach (string prov in _view.SelectedProviders) { FdoFeatureService.UnregisterProvider(prov); } return(true); }
internal void ClassChanged(JoinSourceType type) { if (type == JoinSourceType.Target) { return; } _view.ClearJoins(); FdoConnection conn = GetConnection(type); if (conn != null) { using (FdoFeatureService service = conn.CreateFeatureService()) { switch (type) { case JoinSourceType.Left: { string schema = _view.SelectedLeftSchema; string className = _view.SelectedLeftClass; ClassDefinition cd = service.GetClassByName(schema, className); if (cd != null) { List <string> properties = new List <string>(); foreach (PropertyDefinition pd in cd.Properties) { properties.Add(pd.Name); } _view.LeftProperties = properties; } } break; case JoinSourceType.Right: { string schema = _view.SelectedRightSchema; string className = _view.SelectedRightClass; ClassDefinition cd = service.GetClassByName(schema, className); if (cd != null) { List <string> properties = new List <string>(); foreach (PropertyDefinition pd in cd.Properties) { properties.Add(pd.Name); } _view.RightProperties = properties; } } break; } } } SetTargetGeometries(); }
public void TestUnopenedConnection() { MockRepository mocks = new MockRepository(); IConnection conn = mocks.StrictMock<IConnection>(); Expect.Call(conn.ConnectionState).Return(ConnectionState.ConnectionState_Closed); mocks.ReplayAll(); FdoFeatureService service = new FdoFeatureService(conn); }
public override int Execute() { IConnection conn = null; try { conn = CreateConnection(_provider, _connstr); conn.Open(); } catch (OSGeo.FDO.Common.Exception ex) { WriteException(ex); return (int)CommandStatus.E_FAIL_CONNECT; } using (FdoFeatureService service = new FdoFeatureService(conn)) { ClassDefinition cd = service.GetClassByName(_schema, _class); if (cd == null) { Console.Error.WriteLine("Class {0} not found in schema {1}", _class, _schema); return (int)CommandStatus.E_FAIL_CLASS_NOT_FOUND; } else { using (cd) { foreach (PropertyDefinition propDef in cd.Properties) { bool isIdentity = (propDef.PropertyType == PropertyType.PropertyType_DataProperty && cd.IdentityProperties.Contains((DataPropertyDefinition)propDef)); Console.WriteLine("\nName: {0} ({1}) {2}\n", propDef.Name, propDef.PropertyType, isIdentity ? "(IDENTITY)" : ""); Console.WriteLine("\tQualified Name: {0}\n\tIs System: {1}", propDef.QualifiedName, propDef.IsSystem); switch (propDef.PropertyType) { case PropertyType.PropertyType_DataProperty: WriteDataProperty(propDef as DataPropertyDefinition); break; case PropertyType.PropertyType_GeometricProperty: WriteGeometricProperty(propDef as GeometricPropertyDefinition); break; case PropertyType.PropertyType_AssociationProperty: WriteAssociationProperty(propDef as AssociationPropertyDefinition); break; case PropertyType.PropertyType_ObjectProperty: WriteObjectProperty(propDef as ObjectPropertyDefinition); break; case PropertyType.PropertyType_RasterProperty: WriteRasterProperty(propDef as RasterPropertyDefinition); break; } } } } } conn.Close(); return (int)CommandStatus.E_OK; }
private void GetDataStores() { using (FdoFeatureService service = _conn.CreateFeatureService()) { ReadOnlyCollection <DataStoreInfo> dstores = service.ListDataStores(true); _view.DataStores = dstores; _view.DestroyEnabled = (dstores.Count > 0) && canDestroy; } }
private void UpdateSourceSchemas() { using (FdoFeatureService svc = CreateSourceService()) { cmbSrcSchema.DataSource = svc.GetSchemaNames(); cmbSrcSchema.SelectedIndex = 0; UpdateSourceClasses(); } }
internal void Insert() { using (FdoFeatureService service = _conn.CreateFeatureService()) { service.InsertFeature(_className, _view.GetValues(), _view.UseTransaction); } _view.ShowMessage(null, "Feature Inserted into: " + _className); _view.Close(); }
/// <summary> /// Executes the operation /// </summary> /// <param name="rows"></param> /// <returns></returns> public override IEnumerable <FdoRow> Execute(IEnumerable <FdoRow> rows) { using (FdoFeatureService service = _conn.CreateFeatureService()) { using (FdoFeatureReader reader = service.SelectFeatures(this.Query)) { ClassDefinition cd = reader.GetClassDefinition(); foreach (PropertyDefinition pd in cd.Properties) { if (pd.PropertyType == PropertyType.PropertyType_RasterProperty) { ignoreProperties.Add(pd.Name); } else if (pd.PropertyType == PropertyType.PropertyType_DataProperty) { DataPropertyDefinition dp = pd as DataPropertyDefinition; if (dp.IsAutoGenerated || dp.ReadOnly) { ignoreProperties.Add(pd.Name); } } else if (pd.PropertyType == PropertyType.PropertyType_GeometricProperty) { GeometricPropertyDefinition gp = pd as GeometricPropertyDefinition; if (gp.ReadOnly) { ignoreProperties.Add(gp.Name); } } } while (reader.ReadNext()) { FdoRow row = null; try { row = CreateRowFromReader(reader); } catch (Exception ex) { if (row != null) { RaiseFailedFeatureProcessed(row, ex); } else { RaiseFailedReadFeature(ex.Message, ex); } } if (row != null) { yield return(row); } } } } }
/// <summary> /// Copies the spatial contexts given in the list /// </summary> /// <param name="source">The source connection</param> /// <param name="target">The target connection</param> /// <param name="overwrite">If true will overwrite any existing spatial contexts</param> /// <param name="spatialContextNames">The list of spatial contexts to copy</param> public virtual void Execute(FdoConnection source, FdoConnection target, bool overwrite, string[] spatialContextNames) { if (spatialContextNames.Length == 0) { return; } using (FdoFeatureService sService = source.CreateFeatureService()) using (FdoFeatureService tService = target.CreateFeatureService()) { bool supportsMultipleScs = target.Capability.GetBooleanCapability(CapabilityType.FdoCapabilityType_SupportsMultipleSpatialContexts); bool supportsDestroySc = target.Capability.HasArrayCapability(CapabilityType.FdoCapabilityType_CommandList, (int)OSGeo.FDO.Commands.CommandType.CommandType_DestroySpatialContext); if (supportsMultipleScs) { //Get all contexts in target ReadOnlyCollection <SpatialContextInfo> contexts = tService.GetSpatialContexts(); List <string> updated = new List <string>(); //Destroy any clashing ones if (overwrite && supportsDestroySc) { foreach (SpatialContextInfo c in contexts) { if (SpatialContextInSpecifiedList(c, spatialContextNames)) { tService.DestroySpatialContext(c); } } } //Then overwrite them foreach (SpatialContextInfo c in contexts) { if (SpatialContextInSpecifiedList(c, spatialContextNames)) { tService.CreateSpatialContext(c, overwrite); updated.Add(c.Name); } } //Now create the rest var sourceScs = sService.GetSpatialContexts(); foreach (var sc in sourceScs) { if (!updated.Contains(sc.Name)) { tService.CreateSpatialContext(sc, overwrite); } } } else { tService.CreateSpatialContext(sService.GetActiveSpatialContext(), true); } } }
public override int Execute() { IConnection conn = null; try { conn = CreateConnection(_provider, _connstr); conn.Open(); } catch (OSGeo.FDO.Common.Exception ex) { WriteException(ex); return (int)CommandStatus.E_FAIL_CONNECT; } using (FdoFeatureService service = new FdoFeatureService(conn)) { FeatureSchema fs = service.GetSchemaByName(_schema); if (fs != null) { using (fs) { Console.WriteLine("\nClasses in schema {0}: {1}\n", fs.Name, fs.Classes.Count); foreach (ClassDefinition cd in fs.Classes) { Console.WriteLine("Name: {0} ({1})\n\n\tQualified Name: {2}", cd.Name, cd.ClassType, cd.QualifiedName); Console.WriteLine("\tDescription: {0}", cd.Description); Console.WriteLine("\tIs Abstract: {0}\n\tIs Computed: {1}", cd.IsAbstract, cd.IsComputed); if (cd.BaseClass != null) Console.WriteLine("\tBase Class: {0}", cd.BaseClass.Name); Console.WriteLine("\tAttributes:"); WriteAttributes(cd.Attributes); Console.WriteLine(""); } } } else { Console.Error.WriteLine("Could not find schema: {0}", _schema); return (int)CommandStatus.E_FAIL_SCHEMA_NOT_FOUND; } } conn.Close(); return (int)CommandStatus.E_OK; }
public override int Execute() { CommandStatus retCode; IConnection conn = null; try { conn = CreateConnection(); if (!string.IsNullOrEmpty(_connStr)) { conn.ConnectionString = _connStr; conn.Open(); } } catch (OSGeo.FDO.Common.Exception ex) { WriteException(ex); retCode = CommandStatus.E_FAIL_CONNECT; return (int)retCode; } using (conn) { using (FdoFeatureService service = new FdoFeatureService(conn)) { try { service.DestroyDataStore(_dstoreStr); WriteLine("Data Store destroyed!"); retCode = CommandStatus.E_OK; } catch (OSGeo.FDO.Common.Exception ex) { WriteException(ex); retCode = CommandStatus.E_FAIL_DESTROY_DATASTORE; return (int)retCode; } } if(conn.ConnectionState != ConnectionState.ConnectionState_Closed) conn.Close(); } return (int)retCode; }
public override int Execute() { CommandStatus retCode; IConnection conn = null; try { conn = CreateConnection(_provider, _connstr); conn.Open(); } catch (OSGeo.FDO.Common.Exception ex) { WriteException(ex); retCode = CommandStatus.E_FAIL_CONNECT; return (int)retCode; } using (conn) { using (FdoFeatureService service = new FdoFeatureService(conn)) { try { if (string.IsNullOrEmpty(_schemaName)) service.WriteSchemaToXml(_schemaFile); else service.WriteSchemaToXml(_schemaName, _schemaFile); WriteLine("Schema(s) written to {0}", _schemaFile); retCode = CommandStatus.E_OK; } catch (OSGeo.FDO.Common.Exception ex) { WriteException(ex); retCode = CommandStatus.E_FAIL_SERIALIZE_SCHEMA_XML; } } conn.Close(); } return (int)retCode; }
public override int Execute() { CommandStatus retCode; IConnection conn = null; try { conn = CreateConnection(_provider, _connstr); conn.Open(); } catch (OSGeo.FDO.Common.Exception ex) { WriteException(ex); retCode = CommandStatus.E_FAIL_CONNECT; return (int)retCode; } using (conn) { FdoFeatureService service = new FdoFeatureService(conn); using (service) { try { service.LoadSchemasFromXml(_schemaFile); WriteLine("Schema(s) applied"); retCode = CommandStatus.E_OK; } catch (OSGeo.FDO.Common.Exception ex) { WriteException(ex); retCode = CommandStatus.E_FAIL_APPLY_SCHEMA; return (int)retCode; } } } return (int)retCode; }
/// <summary> /// Constructor /// </summary> /// <param name="conn"></param> /// <param name="className"></param> public FdoOutputOperation(FdoConnection conn, string className) { _conn = conn; _service = conn.CreateFeatureService(); this.ClassName = className; }
public FdoDataPreviewPresenter(IFdoDataPreviewView view, FdoConnection conn) { _timer = new Timer(); _view = view; _connection = conn; _service = conn.CreateFeatureService(); _queryViews = new Dictionary<QueryMode, IQuerySubView>(); _queryWorker = new BackgroundWorker(); _queryWorker.WorkerReportsProgress = true; _queryWorker.WorkerSupportsCancellation = true; _queryWorker.DoWork += new DoWorkEventHandler(DoWork); //_queryWorker.ProgressChanged += new ProgressChangedEventHandler(ProgressChanged); _queryWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(RunWorkerCompleted); _view.ElapsedMessage = string.Empty; _view.CancelEnabled = false; _view.ExecuteEnabled = true; insertSupported = (Array.IndexOf(conn.Capability.GetArrayCapability(CapabilityType.FdoCapabilityType_CommandList), OSGeo.FDO.Commands.CommandType.CommandType_Insert) >= 0); updateSupported = (Array.IndexOf(conn.Capability.GetArrayCapability(CapabilityType.FdoCapabilityType_CommandList), OSGeo.FDO.Commands.CommandType.CommandType_Update) >= 0); deleteSupported = (Array.IndexOf(conn.Capability.GetArrayCapability(CapabilityType.FdoCapabilityType_CommandList), OSGeo.FDO.Commands.CommandType.CommandType_Delete) >= 0); _view.DeleteEnabled = deleteSupported; _view.UpdateEnabled = updateSupported; _timer.Interval = 1000; _timer.Elapsed += new ElapsedEventHandler(OnTimerElapsed); }
private void CreateDataStore(FdoFeatureService svc) { using (var cmd = svc.CreateCommand<ICreateDataStore>(OSGeo.FDO.Commands.CommandType.CommandType_CreateDataStore)) { var props = cmd.DataStoreProperties; props.SetProperty(_view.DataStoreParameter, _view.DataStoreName); if (_view.IsFdoMetadataOptional) props.SetProperty(_view.FdoEnabledParameter, _view.UseFdoMetadata.ToString().ToLower()); cmd.Execute(); } }
private void CreateDefaultSpatialContext(FdoFeatureService svc) { var sc = _view.CreateDefaultSpatialContext(); //You would've thought ICreateSpatialContext with updateExisting = true //would do the job, but noooo we have to actually destroy the existing //one first. Annoying! bool destroy = false; var spcs = svc.GetSpatialContexts(); foreach (var spc in spcs) { if (spc.Name == sc.Name) { destroy = true; break; } } if (destroy) svc.DestroySpatialContext(sc.Name); svc.CreateSpatialContext(sc, false); }
public FdoStandardQueryPresenter(IFdoStandardQueryView view, FdoConnection conn) { _view = view; _conn = conn; _service = _conn.CreateFeatureService(); _view.UseExtendedSelectForOrdering = false; bool bExtended = Array.IndexOf(conn.Capability.GetArrayCapability(CapabilityType.FdoCapabilityType_CommandList), CommandType.CommandType_ExtendedSelect) >= 0; _view.OrderingEnabled = conn.Capability.GetBooleanCapability(CapabilityType.FdoCapabilityType_SupportsSelectOrdering) || bExtended; _view.UseExtendedSelectForOrdering = bExtended; _walker = SchemaWalker.GetWalker(conn); }