コード例 #1
0
        public override void Run()
        {
            string path = FileService.SaveFile(Res.GetString("TITLE_EXPORT_DATASTORE_XML"), Res.GetString("FILTER_XML_FILES"));

            if (!string.IsNullOrEmpty(path))
            {
                TreeNode             connNode = Workbench.Instance.ObjectExplorer.GetSelectedNode();
                FdoConnectionManager mgr      = ServiceManager.Instance.GetService <FdoConnectionManager>();
                FdoConnection        conn     = mgr.GetConnection(connNode.Name);

                using (new TempCursor(Cursors.WaitCursor))
                {
                    using (var svc = conn.CreateFeatureService())
                    {
                        var scs      = new List <SpatialContextInfo>(svc.GetSpatialContexts()).ToArray();
                        var schemas  = svc.DescribeSchema();
                        var mappings = svc.DescribeSchemaMapping(true);

                        var dstore = new FdoDataStoreConfiguration(schemas, scs, mappings);
                        dstore.Save(path);

                        Log.InfoFormatted("Connection saved to: {0}", path);
                    }
                }
            }
        }
コード例 #2
0
        public static void Initialize()
        {
            FdoConnectionManager manager = ServiceManager.Instance.GetService <FdoConnectionManager>();
            NamingService        namer   = ServiceManager.Instance.GetService <NamingService>();

            manager.ConnectionAdded += delegate(object sender, EventArgs <string> e)
            {
                LoggingService.InfoFormatted("Connection added: {0}", e.Data);
            };
            manager.ConnectionRemoved += delegate(object sender, EventArgs <string> e)
            {
                LoggingService.InfoFormatted("Connection removed: {0}", e.Data);
                if (manager.GetConnectionNames().Count == 0)
                {
                    namer.ResetCounter();
                }
            };
            manager.ConnectionRenamed += delegate(object sender, ConnectionRenameEventArgs e)
            {
                LoggingService.InfoFormatted("Connection {0} renamed to {1}", e.OldName, e.NewName);
            };
            manager.ConnectionRefreshed += delegate(object sender, EventArgs <string> e)
            {
                LoggingService.InfoFormatted("Connection {0} refreshed", e.Data);
            };
        }
コード例 #3
0
        public override void Run()
        {
            string path = FileService.OpenFile(Res.GetString("TITLE_LOAD_CONNECTION"), Res.GetString("FILTER_CONNECTION_FILE"));

            if (FileService.FileExists(path))
            {
                FdoConnection        conn = FdoConnection.LoadFromFile(path);
                FdoConnectionManager mgr  = ServiceManager.Instance.GetService <FdoConnectionManager>();

                string name = string.Empty;
                name = Msg.ShowInputBox(Res.GetString("TITLE_NEW_CONNECTION"), Res.GetString("PROMPT_ENTER_NEW_CONNECTION_NAME"), name);
                if (name == null)
                {
                    return;
                }

                while (name == string.Empty || mgr.NameExists(name))
                {
                    name = Msg.ShowInputBox(Res.GetString("TITLE_NEW_CONNECTION"), Res.GetString("PROMPT_ENTER_NEW_CONNECTION_NAME"), name);
                    if (name == null)
                    {
                        return;
                    }
                }

                using (TempCursor cur = new TempCursor(Cursors.WaitCursor))
                {
                    mgr.AddConnection(name, conn);
                }
            }
        }
コード例 #4
0
        public void Decorate(IObjectExplorer explorer)
        {
            _explorer = explorer;
            _connMgr  = ServiceManager.Instance.GetService <FdoConnectionManager>();
            _connMgr.ConnectionAdded     += new ConnectionEventHandler(OnConnectionAdded);
            _connMgr.ConnectionRenamed   += new ConnectionRenamedEventHandler(OnConnectionRenamed);
            _connMgr.ConnectionRemoved   += new ConnectionEventHandler(OnConnectionRemoved);
            _connMgr.ConnectionRefreshed += new ConnectionEventHandler(OnConnectionRefreshed);

            _explorer.RegisterImage(IMG_ASSOC_PROPERTY);
            _explorer.RegisterImage(IMG_FEATURE_CLASS);
            _explorer.RegisterImage(IMG_CLASS);
            _explorer.RegisterImage(IMG_CONNECTION);
            _explorer.RegisterImage(IMG_DATA_PROPERTY);
            _explorer.RegisterImage(IMG_GEOM_PROPERTY);
            _explorer.RegisterImage(IMG_ID_PROPERTY);
            _explorer.RegisterImage(IMG_OBJECT_PROPERTY);
            _explorer.RegisterImage(IMG_RASTER_PROPERTY);
            _explorer.RegisterImage(IMG_SCHEMA);

            _explorer.RegisterImage(IMG_DB_CONNECTION);
            _explorer.RegisterImage(IMG_SERVER_CONNECTION);
            _explorer.RegisterImage(IMG_FILE_CONNECTION);

            _explorer.RegisterRootNode(RootNodeName, "FDO Data Sources", "database_connect", "/ObjectExplorer/ContextMenus/FdoConnections");
            _explorer.RegisterContextMenu(NODE_CONNECTION, PATH_SELECTED_CONNECTION);
            _explorer.RegisterContextMenu(NODE_SCHEMA, PATH_SELECTED_SCHEMA);
            _explorer.RegisterContextMenu(NODE_CLASS, PATH_SELECTED_CLASS);

            _explorer.AfterExpansion += new TreeViewEventHandler(OnAfterNodeExpansion);
            //_explorer.RegisterContextMenu(NODE_PROPERTY, "/ObjectExplorer/ContextMenus/SelectedProperty");
        }
コード例 #5
0
        public override void Run()
        {
            string dir = FileService.GetDirectory(Res.GetString("TITLE_CONNECT_SHP_DIR"));

            if (FileService.DirectoryExists(dir))
            {
                FdoConnection        conn  = new FdoConnection("OSGeo.SHP", "DefaultFileLocation=" + dir);
                FdoConnectionManager mgr   = ServiceManager.Instance.GetService <FdoConnectionManager>();
                NamingService        namer = ServiceManager.Instance.GetService <NamingService>();

                string name = Msg.ShowInputBox(Res.GetString("TITLE_CONNECTION_NAME"), Res.GetString("PROMPT_ENTER_CONNECTION"), namer.GetDefaultConnectionName("OSGeo.SHP"));
                if (name == null)
                {
                    return;
                }

                while (string.IsNullOrEmpty(name) || mgr.NameExists(name))
                {
                    Msg.ShowError(Res.GetString("ERR_CONNECTION_NAME_EMPTY_OR_EXISTS"));
                    name = Msg.ShowInputBox(Res.GetString("TITLE_CONNECTION_NAME"), Res.GetString("PROMPT_ENTER_CONNECTION"), name);

                    if (name == null)
                    {
                        return;
                    }
                }
                mgr.AddConnection(name, conn);
            }
        }
コード例 #6
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Form.Load"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            FdoConnectionManager connMgr = ServiceManager.Instance.GetService <FdoConnectionManager>();

            lstConnections.DataSource = new List <string>(connMgr.GetConnectionNames());
            base.OnLoad(e);
        }
コード例 #7
0
        public override void Run()
        {
            Workbench wb = Workbench.Instance;

            if (wb != null)
            {
                TreeNode node     = wb.ObjectExplorer.GetSelectedNode();
                TreeNode connNode = wb.ObjectExplorer.GetSelectedNode();
                while (connNode.Level > 1)
                {
                    connNode = connNode.Parent;
                }

                FdoConnectionManager mgr  = ServiceManager.Instance.GetService <FdoConnectionManager>();
                FdoConnection        conn = mgr.GetConnection(connNode.Name);
                FdoDataPreviewCtl    ctl  = null;
                if (node.Level > 1) //Class node
                {
                    ctl = new FdoDataPreviewCtl(conn, node.Parent.Name, node.Name);
                }
                else
                {
                    ctl = new FdoDataPreviewCtl(conn);
                }

                wb.ShowContent(ctl, ViewRegion.Document);
            }
        }
コード例 #8
0
        public override void Run()
        {
            string file = FileService.OpenFile(Res.GetString("TITLE_CONNECT_SQLITE"), Res.GetString("FILTER_SQLITE"));

            if (FileService.FileExists(file))
            {
                FdoConnection        conn  = ExpressUtility.CreateFlatFileConnection("OSGeo.SQLite", file);
                FdoConnectionManager mgr   = ServiceManager.Instance.GetService <FdoConnectionManager>();
                NamingService        namer = ServiceManager.Instance.GetService <NamingService>();

                string name = Msg.ShowInputBox(Res.GetString("TITLE_CONNECTION_NAME"), Res.GetString("PROMPT_ENTER_CONNECTION"), namer.GetDefaultConnectionName("OSGeo.SQLite"));
                if (name == null)
                {
                    return;
                }

                while (name == string.Empty || mgr.NameExists(name))
                {
                    Msg.ShowError(Res.GetString("ERR_CONNECTION_NAME_EMPTY_OR_EXISTS"));
                    name = Msg.ShowInputBox(Res.GetString("TITLE_CONNECTION_NAME"), Res.GetString("PROMPT_ENTER_CONNECTION"), name);

                    if (name == null)
                    {
                        return;
                    }
                }
                mgr.AddConnection(name, conn);
            }
        }
コード例 #9
0
        public override void Run()
        {
            TreeNode             connNode = Workbench.Instance.ObjectExplorer.GetSelectedNode();
            FdoConnectionManager mgr      = ServiceManager.Instance.GetService <FdoConnectionManager>();

            mgr.RemoveConnection(connNode.Name);
        }
コード例 #10
0
        public override void Run()
        {
            TreeNode             connNode = Workbench.Instance.ObjectExplorer.GetSelectedNode();
            FdoConnectionManager mgr      = ServiceManager.Instance.GetService <FdoConnectionManager>();

            using (TempCursor cur = new TempCursor(Cursors.WaitCursor))
            {
                mgr.RefreshConnection(connNode.Name);
            }
        }
コード例 #11
0
        public override void Run()
        {
            string path = FileService.SaveFile(Res.GetString("TITLE_SAVE_CONNECTION"), Res.GetString("FILTER_CONNECTION_FILE"));

            if (!string.IsNullOrEmpty(path))
            {
                TreeNode             connNode = Workbench.Instance.ObjectExplorer.GetSelectedNode();
                FdoConnectionManager mgr      = ServiceManager.Instance.GetService <FdoConnectionManager>();
                FdoConnection        conn     = mgr.GetConnection(connNode.Name);
                conn.Save(path);
                Log.InfoFormatted("Connection saved to: {0}", path);
            }
        }
コード例 #12
0
        public override void Run()
        {
            Workbench            wb          = Workbench.Instance;
            TreeNode             classNode   = wb.ObjectExplorer.GetSelectedNode();
            string               srcConnName = classNode.Parent.Parent.Name;
            string               schemaName  = classNode.Parent.Name;
            string               className   = classNode.Name;
            FdoConnectionManager mgr         = ServiceManager.Instance.GetService <FdoConnectionManager>();
            FdoConnection        source      = mgr.GetConnection(srcConnName);
            var ctl = new DumpFeatureClassCtl(source, schemaName, className);

            wb.ShowContent(ctl, ViewRegion.Dialog);
        }
コード例 #13
0
        public override void Run()
        {
            TreeNode node = Workbench.Instance.ObjectExplorer.GetSelectedNode();

            if (node.Level == 2) //Schema
            {
                TreeNode             schemaNode = node;
                TreeNode             connNode   = node.Parent;
                FdoConnectionManager mgr        = ServiceManager.Instance.GetService <FdoConnectionManager>();
                FdoConnection        conn       = mgr.GetConnection(connNode.Name);
                using (FdoFeatureService service = conn.CreateFeatureService())
                {
                    FeatureSchema schema = service.GetSchemaByName(schemaNode.Name);
                    if (schema != null)
                    {
                        PartialSchemaSaveDialog dialog = new PartialSchemaSaveDialog(schema);
                        dialog.ShowDialog();
                    }
                }
            }


            //string path = FileService.SaveFile(Res.GetString("TITLE_SAVE_SCHEMA"), Res.GetString("FILTER_SCHEMA_FILE"));
            //if (!string.IsNullOrEmpty(path))
            //{
            //    TreeNode node = Workbench.Instance.ObjectExplorer.GetSelectedNode();
            //    if (node.Level == 1) //Connection
            //    {
            //        TreeNode connNode = node;
            //        FdoConnectionManager mgr = ServiceManager.Instance.GetService<FdoConnectionManager>();
            //        FdoConnection conn = mgr.GetConnection(connNode.Name);
            //        using (FdoFeatureService service = conn.CreateFeatureService())
            //        {
            //            service.WriteSchemaToXml(path);
            //            Log.InfoFormatted(Res.GetString("LOG_SCHEMA_SAVED"), path);
            //        }
            //    }
            //    else if (node.Level == 2) //Schema
            //    {
            //        TreeNode schemaNode = node;
            //        TreeNode connNode = node.Parent;
            //        FdoConnectionManager mgr = ServiceManager.Instance.GetService<FdoConnectionManager>();
            //        FdoConnection conn = mgr.GetConnection(connNode.Name);
            //        using (FdoFeatureService service = conn.CreateFeatureService())
            //        {
            //            service.WriteSchemaToXml(schemaNode.Name, path);
            //            Log.InfoFormatted(Res.GetString("LOG_SCHEMA_SAVED_2"), connNode.Name, path);
            //        }
            //    }
            //}
        }
コード例 #14
0
        public override void Run()
        {
            Workbench wb   = Workbench.Instance;
            TreeNode  node = wb.ObjectExplorer.GetSelectedNode();

            if (node.Level == 3)
            {
                string name = node.Name;
                FdoConnectionManager mgr  = ServiceManager.Instance.GetService <FdoConnectionManager>();
                FdoConnection        conn = mgr.GetConnection(node.Parent.Parent.Name);
                FdoInsertScaffold    ctl  = new FdoInsertScaffold(conn, name);
                wb.ShowContent(ctl, ViewRegion.Dialog);
            }
        }
コード例 #15
0
        public bool IsValid(object caller, Condition condition)
        {
            IObjectExplorer objectExplorer = caller as IObjectExplorer;

            if (objectExplorer == null)
            {
                return(false);
            }

            TreeNode node = objectExplorer.GetSelectedNode();

            //Might be the one. Check it's root parent
            if (node.Level >= 1)
            {
                TreeNode root = node.Parent;
                while (root.Level > 0)
                {
                    root = root.Parent;
                }

                TreeNode rootCmp = objectExplorer.GetRootNode(FdoObjectExplorerExtender.RootNodeName);
                if (root == rootCmp)
                {
                    TreeNode connNode = node;
                    while (connNode.Level > 1)
                    {
                        connNode = connNode.Parent;
                    }
                    FdoConnectionManager connMgr = ServiceManager.Instance.GetService <FdoConnectionManager>();
                    FdoConnection        conn    = connMgr.GetConnection(connNode.Name);
                    if (conn != null)
                    {
                        try
                        {
                            var applicable                     = (Array.IndexOf <string>(applicableProviders, conn.Provider.ToUpper()) >= 0);
                            var supportsSchemaMappings         = conn.Capability.GetBooleanCapability(CapabilityType.FdoCapabilityType_SupportsSchemaOverrides);
                            var supportsDescribeSchemaMappings = conn.Capability.GetArrayCapability(CapabilityType.FdoCapabilityType_CommandList).Cast <CommandType>().Contains(CommandType.CommandType_DescribeSchemaMapping);

                            return(supportsSchemaMappings && supportsDescribeSchemaMappings);
                        }
                        catch
                        {
                            return(false);
                        }
                    }
                }
            }
            return(false);
        }
コード例 #16
0
ファイル: TaskLoader.cs プロジェクト: beritec/fdotoolbox
        /// <summary>
        /// Prepares the specified bulk copy definition (freshly deserialized) before the loading process begins
        /// </summary>
        /// <param name="def">The bulk copy definition.</param>
        protected override NameValueCollection Prepare(FdoToolbox.Core.Configuration.FdoBulkCopyTaskDefinition def)
        {
            /* There is subtle precondition that would've resulted in all connection references being named to a
             * single reference, thus invalidating the whole task when loaded.
             *
             * If the task definition has any connection names to an *already* loaded connection, a rename operation
             * could overwrite a previous rename operation. Consider:
             *
             * Connection A) SDF_Desktop
             * Connection B) SDFConnection0
             *
             * Loaded Connections:
             * - SDFConnection0
             * - SDFConnection1
             *
             * If during loading, SDF_Desktop matches to SDFConnection0, and SDFConnection0 matches to SDFConnection1 the rename operations
             * would then be:
             *
             * 1) Rename SDF_Desktop to SDFConnection0
             * 2) Rename SDF_Connection0 to SDFConnection1
             *
             * As a result, all referenced connections will eventually be renamed to SDFConnection1, which is not what we want.
             *
             * The solution bere is to "fix" the definition by renaming the named connections to something we know is not already a loaded
             * connection. This is done regardless to ensure consistent behaviour. Thsi method performs this solution.
             */

            string prefix  = "Connection";
            int    counter = 0;
            FdoConnectionManager connMgr = ServiceManager.Instance.GetService <FdoConnectionManager>();

            NameValueCollection nameMappings = new NameValueCollection();

            foreach (FdoConnectionEntryElement el in def.Connections)
            {
                string newName = prefix + counter;
                while (connMgr.GetConnection(newName) != null)
                {
                    counter++;
                    newName = prefix + counter;
                }
                string oldName = el.name;
                def.UpdateConnectionReferences(oldName, newName);
                nameMappings.Add(newName, oldName);
                counter++;
            }

            return(nameMappings);
        }
コード例 #17
0
        public override void Run()
        {
            TreeNode             connNode = Workbench.Instance.ObjectExplorer.GetSelectedNode();
            FdoConnectionManager mgr      = ServiceManager.Instance.GetService <FdoConnectionManager>();
            FdoConnection        conn     = mgr.GetConnection(connNode.Name);

            if (!conn.Capability.GetBooleanCapability(CapabilityType.FdoCapabilityType_SupportsSQL))
            {
                MessageService.ShowError(Res.GetString("ERR_UNSUPPORTED_SQL"));
            }
            else
            {
                var dlg = new FdoSqlCommandDialog(conn);
                dlg.ShowDialog();
            }
        }
コード例 #18
0
ファイル: NewTaskDialog.cs プロジェクト: beritec/fdotoolbox
        protected override void OnLoad(EventArgs e)
        {
            _connMgr = ServiceManager.Instance.GetService <FdoConnectionManager>();
            List <string> srcNames = new List <string>(_availNames);
            List <string> dstNames = new List <string>(_availNames);

            cmbSrcConnection.DataSource = srcNames;
            cmbDstConnection.DataSource = dstNames;

            cmbSrcConnection.SelectedIndex = 0;
            cmbDstConnection.SelectedIndex = 0;

            cmbSrcConnection_SelectionChangeCommitted(this, EventArgs.Empty);
            cmbDstConnection_SelectionChangeCommitted(this, EventArgs.Empty);

            base.OnLoad(e);
        }
コード例 #19
0
        public override void Run()
        {
            Workbench wb   = Workbench.Instance;
            TreeNode  node = wb.ObjectExplorer.GetSelectedNode();

            if (node.Level == 3)
            {
                if (MessageService.AskQuestion("This is a dangerous operation. One false filter could cause irreversible data changes. Do you want to continue?"))
                {
                    string name = node.Name;
                    FdoConnectionManager mgr  = ServiceManager.Instance.GetService <FdoConnectionManager>();
                    FdoConnection        conn = mgr.GetConnection(node.Parent.Parent.Name);

                    FdoBulkUpdateCtl ctl = new FdoBulkUpdateCtl(conn, node.Name);
                    wb.ShowContent(ctl, ViewRegion.Dialog);
                }
            }
        }
コード例 #20
0
        public override void Run()
        {
            Workbench wb = Workbench.Instance;

            if (wb != null)
            {
                TreeNode node = wb.ObjectExplorer.GetSelectedNode();
                if (node.Level == 1)
                {
                    FdoConnectionManager mgr  = ServiceManager.Instance.GetService <FdoConnectionManager>();
                    FdoConnection        conn = mgr.GetConnection(node.Name);

                    FdoDataStoreMgrCtl ctl = new FdoDataStoreMgrCtl(conn);

                    wb.ShowContent(ctl, ViewRegion.Document);
                }
            }
        }
コード例 #21
0
        public void Decorate(IObjectExplorer explorer)
        {
            _explorer = explorer;
            _connMgr  = ServiceManager.Instance.GetService <FdoConnectionManager>();
            _connMgr.BeforeConnectionRemove += new ConnectionBeforeRemoveHandler(OnBeforeConnectionRemove);
            _connMgr.ConnectionRenamed      += new ConnectionRenamedEventHandler(OnConnectionRenamed);
            _taskMgr              = ServiceManager.Instance.GetService <TaskManager>();
            _taskMgr.TaskAdded   += new TaskEventHandler(OnTaskAdded);
            _taskMgr.TaskRemoved += new TaskEventHandler(OnTaskRemoved);
            _taskMgr.TaskRenamed += new TaskRenameEventHandler(OnTaskRenamed);

            _explorer.RegisterImage(IMG_TASK);
            _explorer.RegisterImage(IMG_JOIN);
            _explorer.RegisterImage(IMG_SEQPROC);

            _explorer.RegisterRootNode(RootNodeName, "Tasks", IMG_TASK, PATH_TASKS);
            _explorer.RegisterContextMenu(NODE_TASK, PATH_SELECTED_TASK);
        }
コード例 #22
0
        internal CopyTaskNodeDecorator(TreeNode root, string srcConnName, string srcSchema, string srcClass, string dstConnName, string dstSchema, string dstClass, string taskName, bool createIfNotExists)
        {
            _node = new TreeNode();
            root.Nodes.Add(_node);

            _node.Nodes.Add(new TreeNode("Description"));
            _node.Nodes.Add(new TreeNode("Options"));
            _node.Nodes.Add(new TreeNode("Property Mappings"));
            _node.Nodes.Add(new TreeNode("Expression Mappings (Right click to add)"));

            this.Name        = taskName;
            this.Description = "Copies features from " + srcClass + " to " + dstClass;

            InitDescription(srcConnName, srcSchema, srcClass, dstConnName, dstSchema, dstClass, createIfNotExists);

            _connMgr = ServiceManager.Instance.GetService <FdoConnectionManager>();

            _srcConnName           = srcConnName;
            _dstConnName           = dstConnName;
            this.CreateIfNotExists = createIfNotExists;

            using (FdoFeatureService srcSvc = GetSourceConnection().CreateFeatureService())
                using (FdoFeatureService dstSvc = GetTargetConnection().CreateFeatureService())
                {
                    ClassDefinition sourceClass = srcSvc.GetClassByName(srcSchema, srcClass);
                    Debug.Assert(sourceClass != null);

                    ClassDefinition targetClass = dstSvc.GetClassByName(dstSchema, dstClass);
                    if (targetClass == null && !this.CreateIfNotExists)
                    {
                        throw new InvalidOperationException("Target class " + dstClass + " does not exist. If you want this class created make sure you checked \"Create class of the name name\" when creating a new copy task");
                    }

                    _srcClass = sourceClass;
                    _dstClass = targetClass;
                }

            _options      = new OptionsNodeDecorator(this, _node.Nodes[1]);
            _propMappings = new PropertyMappingsNodeDecorator(this, _node.Nodes[2]);
            _exprMappings = new ExpressionMappingsNodeDecorator(this, _node.Nodes[3]);

            _node.ExpandAll();
        }
コード例 #23
0
        public override void Run()
        {
            Workbench wb   = Workbench.Instance;
            TreeNode  node = wb.ObjectExplorer.GetSelectedNode();

            if (node.Level == 1)
            {
                string name = node.Name;
                FdoConnectionManager mgr  = ServiceManager.Instance.GetService <FdoConnectionManager>();
                FdoConnection        conn = mgr.GetConnection(name);

                if (conn != null)
                {
                    var ctl = new FdoDataStoreCtrl(conn);
                    ctl.DataStoreChanged += delegate
                    {
                        mgr.RefreshConnection(name);
                    };
                    wb.ShowContent(ctl, ViewRegion.Document);
                }
            }
        }
コード例 #24
0
        public void Init()
        {
            FdoConnectionManager connMgr = ServiceManager.Instance.GetService <FdoConnectionManager>();
            FdoConnection        conn    = connMgr.GetConnection(_connName);

            ICapability cap = conn.Capability;

            CapabilityType[]       capTypes = (CapabilityType[])Enum.GetValues(typeof(CapabilityType));
            List <CapabilityEntry> ents     = new List <CapabilityEntry>();

            foreach (CapabilityType ct in capTypes)
            {
                Type t = cap.GetCapabilityValueType(ct);
                if (t != null)
                {
                    CapabilityEntry ent = new CapabilityEntry();
                    ent.Name = ct.ToString();
                    ent.Type = t.ToString();

                    object value = cap.GetObjectCapability(ct);
                    if (t == typeof(Array))
                    {
                        ent.Value = GetArrayValues((Array)value);
                    }
                    else if (t == typeof(FunctionDefinitionCollection))
                    {
                        ent.Value = GetFunctions((FunctionDefinitionCollection)value);
                    }
                    else
                    {
                        ent.Value = value.ToString();
                    }
                    ents.Add(ent);
                }
            }

            _view.Capabilities = ents.ToArray();
        }
コード例 #25
0
        public override void Run()
        {
            TreeNode             connNode = Workbench.Instance.ObjectExplorer.GetSelectedNode();
            FdoConnectionManager mgr      = ServiceManager.Instance.GetService <FdoConnectionManager>();

            string name = Msg.ShowInputBox(Res.GetString("TITLE_RENAME_CONNECTION"), Res.GetString("PROMPT_ENTER_NEW_CONNECTION_NAME"), connNode.Name);

            if (name == null)
            {
                return;
            }

            while (name == string.Empty || mgr.NameExists(name))
            {
                name = Msg.ShowInputBox(Res.GetString("TITLE_RENAME_CONNECTION"), Res.GetString("PROMPT_ENTER_NEW_CONNECTION_NAME"), connNode.Name);
                if (name == null)
                {
                    return;
                }
            }

            mgr.RenameConnection(connNode.Name, name);
        }
コード例 #26
0
        public override void Run()
        {
            TreeNode schemaNode = Workbench.Instance.ObjectExplorer.GetSelectedNode();

            if (schemaNode.Level == 2 && MessageService.AskQuestion("Are you sure you want to delete this schema?"))
            {
                FdoConnectionManager mgr  = ServiceManager.Instance.GetService <FdoConnectionManager>();
                FdoConnection        conn = mgr.GetConnection(schemaNode.Parent.Name);
                using (FdoFeatureService service = conn.CreateFeatureService())
                {
                    try
                    {
                        service.DestroySchema(schemaNode.Name);
                        Msg.ShowMessage(Res.GetString("MSG_SCHEMA_DELETED"), Res.GetString("TITLE_DELETE_SCHEMA"));
                        Log.InfoFormatted(Res.GetString("LOG_SCHEMA_DELETED"), schemaNode.Name, schemaNode.Parent.Name);
                        mgr.RefreshConnection(schemaNode.Parent.Name);
                    }
                    catch (OSGeo.FDO.Common.Exception ex)
                    {
                        Msg.ShowError(ex);
                    }
                }
            }
        }
コード例 #27
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var schema = _schema;

            //Remove elements that have been unchecked.
            foreach (TreeNode clsNode in treeSchema.Nodes)
            {
                string className = clsNode.Name;
                int    index     = schema.Classes.IndexOf(className);
                if (!clsNode.Checked)
                {
                    if (index >= 0)
                    {
                        schema.Classes.RemoveAt(index);
                    }
                }
                else
                {
                    if (index >= 0)
                    {
                        ClassDefinition clsDef = schema.Classes[index];
                        foreach (TreeNode propNode in clsNode.Nodes)
                        {
                            if (!propNode.Checked)
                            {
                                string propName = propNode.Text;
                                int    pidx     = clsDef.Properties.IndexOf(propName);
                                if (pidx >= 0)
                                {
                                    clsDef.Properties.RemoveAt(pidx);
                                    if (clsDef.IdentityProperties.Contains(propName))
                                    {
                                        int idpdx = clsDef.IdentityProperties.IndexOf(propName);
                                        clsDef.IdentityProperties.RemoveAt(idpdx);
                                    }
                                    if (clsDef.ClassType == ClassType.ClassType_FeatureClass)
                                    {
                                        FeatureClass fc = (FeatureClass)clsDef;
                                        if (fc.GeometryProperty.Name == propName)
                                        {
                                            fc.GeometryProperty = null;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (rdXml.Checked)
            {
                using (var ios = new IoFileStream(txtXml.Text, "w"))
                {
                    using (var writer = new XmlWriter(ios, false, XmlWriter.LineFormat.LineFormat_Indent))
                    {
                        schema.WriteXml(writer);
                        writer.Close();
                    }
                    ios.Close();
                }

                MessageService.ShowMessage("Schema saved to: " + txtXml.Text);
                this.DialogResult = DialogResult.OK;
            }
            else if (rdFile.Checked)
            {
                string fileName = txtFile.Text;
                if (ExpressUtility.CreateFlatFileDataSource(fileName))
                {
                    FdoConnection conn        = ExpressUtility.CreateFlatFileConnection(fileName);
                    bool          disposeConn = true;
                    using (FdoFeatureService svc = conn.CreateFeatureService())
                    {
                        svc.ApplySchema(schema);
                        if (MessageService.AskQuestion("Schema saved to: " + txtFile.Text + " connect to it?", "Saved"))
                        {
                            FdoConnectionManager mgr = ServiceManager.Instance.GetService <FdoConnectionManager>();
                            string name = MessageService.ShowInputBox(ResourceService.GetString("TITLE_CONNECTION_NAME"), ResourceService.GetString("PROMPT_ENTER_CONNECTION"), "");
                            if (name == null)
                            {
                                return;
                            }

                            while (name == string.Empty || mgr.NameExists(name))
                            {
                                MessageService.ShowError(ResourceService.GetString("ERR_CONNECTION_NAME_EMPTY_OR_EXISTS"));
                                name = MessageService.ShowInputBox(ResourceService.GetString("TITLE_CONNECTION_NAME"), ResourceService.GetString("PROMPT_ENTER_CONNECTION"), name);

                                if (name == null)
                                {
                                    return;
                                }
                            }
                            disposeConn = false;
                            mgr.AddConnection(name, conn);
                        }
                    }
                    if (disposeConn)
                    {
                        conn.Close();
                        conn.Dispose();
                    }
                    this.DialogResult = DialogResult.OK;
                }
            }
        }
コード例 #28
0
 public CreateSdfPresenter(ICreateSdfView view)
 {
     _view    = view;
     _connMgr = ServiceManager.Instance.GetService <FdoConnectionManager>();
     CheckConnect();
 }
コード例 #29
0
 public FdoBulkCopyCtl()
 {
     InitializeComponent();
     _connMgr = ServiceManager.Instance.GetService <FdoConnectionManager>();
 }
コード例 #30
0
        public override void Run()
        {
            FdoConnectionManager mgr = ServiceManager.Instance.GetService <FdoConnectionManager>();

            mgr.Clear();
        }