示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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;
        }