本文整理汇总了C#中FdoToolbox.Core.Feature.FdoConnection.CreateFeatureService方法的典型用法代码示例。如果您正苦于以下问题:C# FdoConnection.CreateFeatureService方法的具体用法?C# FdoConnection.CreateFeatureService怎么用?C# FdoConnection.CreateFeatureService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FdoToolbox.Core.Feature.FdoConnection
的用法示例。
在下文中一共展示了FdoConnection.CreateFeatureService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
/// <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 override void Execute(FdoConnection source, FdoConnection target, bool overwrite, string[] spatialContextNames)
{
if (spatialContextNames.Length == 0)
return;
FdoFeatureService srcService = source.CreateFeatureService();
FdoFeatureService destService = target.CreateFeatureService();
ReadOnlyCollection<SpatialContextInfo> srcContexts = srcService.GetSpatialContexts();
ReadOnlyCollection<SpatialContextInfo> destContexts = destService.GetSpatialContexts();
foreach (SpatialContextInfo ctx in srcContexts)
{
if (SpatialContextInSpecifiedList(ctx, spatialContextNames))
{
try
{
//Find target spatial context of the same name
SpatialContextInfo sci = destService.GetSpatialContext(ctx.Name);
if (sci != null && overwrite)
{
//If found, destroy then create
destService.DestroySpatialContext(ctx.Name);
destService.CreateSpatialContext(ctx, false);
}
else
{
destService.CreateSpatialContext(ctx, false);
}
}
catch (Exception)
{
}
}
}
}
示例2: Execute
/// <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);
}
}
}
示例3: SchemaDesignContext
public SchemaDesignContext(FdoConnection conn)
{
_spatialContexts = new BindingList<SpatialContextInfo>();
if (conn == null)
{
_schemas = new FeatureSchemaCollection(null);
_mappings = new PhysicalSchemaMappingCollection();
}
else
{
using (var svc = conn.CreateFeatureService())
{
_schemas = svc.DescribeSchema();
_mappings = svc.DescribeSchemaMapping(true);
if (_mappings == null)
_mappings = new PhysicalSchemaMappingCollection();
var spatialContexts = svc.GetSpatialContexts();
foreach (var sc in spatialContexts)
{
_spatialContexts.Add(sc);
}
}
}
this.Connection = conn;
EvaluateCapabilities();
}
示例4: FdoStandardQueryPresenter
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);
}
示例5: FdoAggregateQueryPresenter
public FdoAggregateQueryPresenter(IFdoAggregateQueryView view, FdoConnection conn)
{
_view = view;
_conn = conn;
_service = _conn.CreateFeatureService();
_view.OrderingEnabled = false;
_walker = SchemaWalker.GetWalker(conn);
}
示例6: FdoSpatialContextBrowserDlg
public FdoSpatialContextBrowserDlg(FdoConnection conn)
: this()
{
using (FdoFeatureService service = conn.CreateFeatureService())
{
grdSpatialContexts.DataSource = service.GetSpatialContexts();
}
}
示例7: GetWalker
public static SchemaWalker GetWalker(FdoConnection conn)
{
using (var svc = conn.CreateFeatureService())
{
if (svc.SupportsPartialSchemaDiscovery())
return new PartialSchemaWalker(conn);
else
return new FullSchemaWalker(conn);
}
}
示例8: Execute
/// <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 virtual void Execute(ICollection<SpatialContextInfo> spatialContexts, FdoConnection target, bool overwrite)
{
bool supportsMultipleScs = target.Capability.GetBooleanCapability(CapabilityType.FdoCapabilityType_SupportsMultipleSpatialContexts);
bool supportsDestroySc = target.Capability.HasArrayCapability(CapabilityType.FdoCapabilityType_CommandList, (int)OSGeo.FDO.Commands.CommandType.CommandType_DestroySpatialContext);
using (FdoFeatureService service = target.CreateFeatureService())
{
if (supportsMultipleScs)
{
if (overwrite && supportsDestroySc)
{
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, overwrite);
}
}
else
{
List<SpatialContextInfo> contexts = new List<SpatialContextInfo>(spatialContexts);
//Copy either the active spatial context in the list or the first
//spatial context (if no active one is found)
SpatialContextInfo active = null;
if (contexts.Count > 0)
{
foreach (SpatialContextInfo sc in contexts)
{
if (sc.IsActive)
{
active = sc;
break;
}
}
if (active == null)
active = contexts[0];
}
if(active != null)
service.CreateSpatialContext(active, overwrite);
}
}
}
示例9: Execute
/// <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 override void Execute(FdoConnection source, FdoConnection target, bool overwrite, string [] spatialContextNames)
{
if (spatialContextNames.Length == 0)
return;
string srcName = spatialContextNames[0];
FdoFeatureService srcService = source.CreateFeatureService();
FdoFeatureService destService = target.CreateFeatureService();
SpatialContextInfo context = srcService.GetSpatialContext(srcName);
if (context != null)
{
//Make sure that CSName != Spatial Context Name
WKTParser parser = new WKTParser(context.CoordinateSystemWkt);
if (!string.IsNullOrEmpty(parser.CSName))
{
context.CoordinateSystem = parser.CSName;
context.Name = parser.CSName;
destService.CreateSpatialContext(context, overwrite);
}
}
}
示例10: Execute
public override int Execute()
{
CommandStatus retCode;
FdoConnection conn = null;
try
{
conn = new FdoConnection(_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 = conn.CreateFeatureService())
{
try
{
service.CreateDataStore(_dstoreStr);
WriteLine("Data Store Created!");
retCode = CommandStatus.E_OK;
}
catch (OSGeo.FDO.Common.Exception ex)
{
WriteException(ex);
retCode = CommandStatus.E_FAIL_CREATE_DATASTORE;
return (int)retCode;
}
}
if (conn.State != FdoConnectionState.Closed)
conn.Close();
}
return (int)retCode;
}
示例11: FdoOutputOperation
/// <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;
}
示例12: Execute
public override int Execute()
{
CommandStatus retCode;
FdoConnection srcConn = new FdoConnection(_srcProvider, _srcConnStr);
FdoConnection destConn = null;
//Directory given, assume SHP
if (Directory.Exists(_destPath))
{
destConn = new FdoConnection("OSGeo.SHP", "DefaultFileLocation=" + _destPath);
}
else
{
if (ExpressUtility.CreateFlatFileDataSource(_destPath))
destConn = ExpressUtility.CreateFlatFileConnection(_destPath);
else
throw new FdoException("Could not create data source: " + _destPath);
}
try
{
srcConn.Open();
destConn.Open();
string srcName = "SOURCE";
string dstName = "TARGET";
FdoBulkCopyOptions options = new FdoBulkCopyOptions();
options.RegisterConnection(srcName, srcConn);
options.RegisterConnection(dstName, destConn);
using (FdoFeatureService srcService = srcConn.CreateFeatureService())
using (FdoFeatureService destService = destConn.CreateFeatureService())
{
//See if spatial context needs to be copied to target
if (!string.IsNullOrEmpty(_srcSpatialContext))
{
SpatialContextInfo srcCtx = srcService.GetSpatialContext(_srcSpatialContext);
if (srcCtx != null)
{
Console.WriteLine("Copying spatial context: " + srcCtx.Name);
ExpressUtility.CopyAllSpatialContexts(new SpatialContextInfo[] { srcCtx }, destConn, true);
}
}
else
{
//Copy all
ExpressUtility.CopyAllSpatialContexts(srcConn, destConn, true);
}
FeatureSchema srcSchema = null;
//See if partial class list is needed
if (_srcClasses.Count > 0)
{
WriteLine("Checking if partial schema discovery is supported: " + srcService.SupportsPartialSchemaDiscovery());
srcSchema = srcService.PartialDescribeSchema(_srcSchema, _srcClasses);
}
else //Full copy
{
WriteLine("No classes specified, reading full source schema");
srcSchema = srcService.GetSchemaByName(_srcSchema);
}
if (srcSchema == null)
{
WriteError("Could not find source schema: " + _srcSchema);
retCode = CommandStatus.E_FAIL_SCHEMA_NOT_FOUND;
}
else
{
WriteLine("Checking source schema for incompatibilities");
FeatureSchema targetSchema = null;
IncompatibleSchema incSchema;
if (destService.CanApplySchema(srcSchema, out incSchema))
{
int clsCount = srcSchema.Classes.Count;
WriteLine("Applying source schema (containing " + clsCount + " classes) to target");
destService.ApplySchema(srcSchema, null, true);
targetSchema = srcSchema;
}
else
{
WriteWarning("Incompatibilities were detected in source schema. Applying a modified version to target");
FeatureSchema fixedSchema = destService.AlterSchema(srcSchema, incSchema);
int clsCount = fixedSchema.Classes.Count;
WriteLine("Applying modified source schema (containing " + clsCount + " classes) to target");
destService.ApplySchema(fixedSchema, null, true);
targetSchema = fixedSchema;
}
//Now set class copy options
foreach (ClassDefinition cd in srcSchema.Classes)
{
FdoClassCopyOptions copt = new FdoClassCopyOptions(srcName, dstName, srcSchema.Name, cd.Name, targetSchema.Name, cd.Name);
copt.FlattenGeometries = _flatten;
options.AddClassCopyOption(copt);
}
if (_flatten)
{
//.........这里部分代码省略.........
示例13: GetClasses
public static IList<OSGeo.FDO.Schema.ClassDefinition> GetClasses(string title, string message, FdoConnection conn)
{
OSGeo.FDO.Schema.FeatureSchemaCollection schemas = null;
using (FdoFeatureService service = conn.CreateFeatureService())
{
schemas = service.DescribeSchema();
}
if (schemas != null)
{
FdoMultiClassPicker diag = new FdoMultiClassPicker(title, message, schemas);
if (diag.ShowDialog() == DialogResult.OK)
{
return diag.SelectedClasses;
}
}
return null;
}
示例14: Create
public bool Create()
{
bool ok = true;
FdoConnection conn = new FdoConnection(_view.Provider, GetBaseConnectionString());
bool created = false;
bool cleanup = true;
try
{
using (var svc = conn.CreateFeatureService())
{
try
{
CreateDataStore(svc);
created = true;
}
catch (Exception ex)
{
_view.ShowError(ex);
created = false;
ok = false;
}
}
if (created)
{
//Amend the connection string to include the data store
var builder = new DbConnectionStringBuilder();
builder.ConnectionString = conn.ConnectionString;
builder[_view.DataStoreParameter] = _view.DataStoreName;
conn.ConnectionString = builder.ConnectionString;
conn.Open();
using (var svc = conn.CreateFeatureService())
{
CreateDefaultSpatialContext(svc);
}
}
}
finally
{
if (created)
{
if (File.Exists(_view.SchemaFile))
{
ApplySchemas(conn);
}
if (_view.ConnectOnCreate)
{
_connMgr.AddConnection(_view.ConnectionName, conn);
cleanup = false;
}
}
if (cleanup)
{
conn.Close();
conn.Dispose();
}
}
return ok;
}
示例15: FromElement
internal static FdoClassCopyOptions FromElement(FdoCopyTaskElement el, FeatureSchemaCache cache, FdoConnection sourceConn, FdoConnection targetConn, out TargetClassModificationItem mod)
{
mod = null;
if (!cache.HasConnection(el.Source.connection))
throw new TaskLoaderException("The referenced source connection is not defined");
if (!cache.HasConnection(el.Target.connection))
throw new TaskLoaderException("The referenced target connection is not defined");
FdoClassCopyOptions opts = new FdoClassCopyOptions(el.Source.connection, el.Target.connection, el.Source.schema, [email protected], el.Target.schema, [email protected]);
opts.DeleteTarget = el.Options.DeleteTarget;
opts.SourceFilter = el.Options.Filter;
if (!el.Options.FlattenGeometriesSpecified)
opts.FlattenGeometries = false;
else
opts.FlattenGeometries = el.Options.FlattenGeometries;
if (!el.Options.ForceWKBSpecified)
opts.ForceWkb = false;
else
opts.ForceWkb = el.Options.ForceWKB;
if (!string.IsNullOrEmpty(el.Options.BatchSize))
opts.BatchSize = Convert.ToInt32(el.Options.BatchSize);
opts.Name = el.name;
opts.CreateIfNotExists = el.createIfNotExists;
ClassDefinition srcClass = cache.GetClassByName(el.Source.connection, el.Source.schema, [email protected]);
ClassDefinition dstClass = cache.GetClassByName(el.Target.connection, el.Target.schema, [email protected]);
if (!el.createIfNotExists && dstClass == null)
throw new InvalidOperationException("Target class " + [email protected] + " does not exist and the createIfNotExist option is false");
SpatialContextInfo defaultSc = null;
FunctionDefinitionCollection availableFunctions = (FunctionDefinitionCollection)sourceConn.Capability.GetObjectCapability(CapabilityType.FdoCapabilityType_ExpressionFunctions);
using (var svc = targetConn.CreateFeatureService())
{
defaultSc = svc.GetActiveSpatialContext();
}
if (dstClass != null)
{
foreach (FdoPropertyMappingElement propMap in el.PropertyMappings)
{
if (srcClass.Properties.IndexOf(propMap.source) < 0)
throw new TaskLoaderException("The property mapping (" + propMap.source + " -> " + propMap.target + ") in task (" + el.name + ") contains a source property not found in the source class definition (" + [email protected] + ")");
//Add to list of properties to check for
if (propMap.createIfNotExists && dstClass.Properties.IndexOf(propMap.target) < 0)
{
if (mod == null)
mod = new UpdateTargetClass(dstClass.Name);
opts.AddSourcePropertyToCheck(propMap.source);
//Clone copy of source property of same name
var srcProp = srcClass.Properties[srcClass.Properties.IndexOf(propMap.source)];
srcProp = FdoSchemaUtil.CloneProperty(srcProp);
mod.AddProperty(srcProp);
}
else
{
if (dstClass.Properties.IndexOf(propMap.target) < 0)
throw new TaskLoaderException("The property mapping (" + propMap.source + " -> " + propMap.target + ") in task (" + el.name + ") contains a target property not found in the target class definition (" + [email protected] + ")");
PropertyDefinition sp = srcClass.Properties[propMap.source];
PropertyDefinition tp = dstClass.Properties[propMap.target];
if (sp.PropertyType != tp.PropertyType)
throw new TaskLoaderException("The properties in the mapping (" + propMap.source + " -> " + propMap.target + ") are of different types");
//if (sp.PropertyType != PropertyType.PropertyType_DataProperty)
// throw new TaskLoaderException("One or more properties in the mapping (" + propMap.source + " -> " + propMap.target + ") is not a data property");
DataPropertyDefinition sdp = sp as DataPropertyDefinition;
DataPropertyDefinition tdp = tp as DataPropertyDefinition;
opts.AddPropertyMapping(propMap.source, propMap.target);
//Property mapping is between two data properties
if (sdp != null && tdp != null)
{
//Types not equal, so add a conversion rule
if (sdp.DataType != tdp.DataType)
{
FdoDataPropertyConversionRule rule = new FdoDataPropertyConversionRule(
propMap.source,
propMap.target,
sdp.DataType,
tdp.DataType,
propMap.nullOnFailedConversion,
propMap.truncate);
opts.AddDataConversionRule(propMap.source, rule);
}
}
}
}
//
//.........这里部分代码省略.........