public void Test_DqlConnection_States()
        {
            string cnstr = "User=dmadmin;Password=@vmware99;Repository=ls_repos";

            using (DqlConnection cn = new DqlConnection(cnstr))
            {
                Assert.IsTrue(cn.State == ConnectionState.Closed, "State is Closed");
                cn.Open();
                Assert.IsTrue(cn.State == ConnectionState.Open, "State is Open");
            }
        }
        /// <summary>
        /// Gets the schema model.
        /// </summary>
        /// <param name="tableName">Name of the table.</param>
        /// <returns>TableSchemaModel.</returns>
        public override TableSchemaModel GetSchemaModel(string tableName)
        {
            TableSchemaModel table = new TableSchemaModel();

            using (DqlConnection cn = new DqlConnection(ConnectionString))
            {
                cn.Open();
                var schema = cn.GetSchema(tableName).AsEnumerable().GroupBy(g => g.Field <string>("name"));

                foreach (var item in schema)
                {
                    FillSchemaModel(table, item);
                }
            }
            return(table);
        }
        public void Test_DqlFill_Schema()
        {
            string  select  = "Select * from dm_cabinet enable(return_top 1)";
            string  cnstr   = "User=dmadmin;Password=@vmware99;Repository=ls_repos";
            DataSet dataset = new DataSet();

            using (var cn = new DqlConnection(cnstr))
            {
                cn.Open();
                using (var cmd = new DqlCommand(select, cn))
                {
                    using (var adapter = new DqlDataAdapter(cmd))
                    {
                        adapter.FillSchema(dataset);
                    }
                }
            }
        }
        /// <summary>
        /// Executes the query.
        /// </summary>
        /// <param name="select">The select.</param>
        /// <returns>DataSet.</returns>
        public override DataSet ExecuteQuery(string select)
        {
            DataSet dataSet = null;

            using (var cn = new DqlConnection(ConnectionString))
            {
                cn.Open();
                using (DqlCommand cmd = new DqlCommand(select, cn))
                {
                    using (DqlDataAdapter adapter = new DqlDataAdapter(cmd))
                    {
                        dataSet = new DataSet();
                        adapter.Fill(dataSet);
                    }
                }
            }
            return(dataSet);
        }
示例#5
0
        /// <summary>
        /// Texts the documentum.
        /// </summary>
        private void TestDocumentum()
        {
            DqlConnectionStringBuilder builder = new DqlConnectionStringBuilder(txtUserId.Text, txtPassword.Text, btnDataSource.Text);

            builder["Extended Properties"] = txtExt.Text;

            DqlDataSource ds = new DqlDataSource(builder.ConnectionString);

            if (ds.UseExternalQueryEngine())
            {
                ds.TestConnection();
                return;
            }

            using (DqlConnection cn = new DqlConnection(builder.ConnectionString))
            {
                cn.Open();
            }
        }
        public void Test_DqlFill_RepeatingValues()
        {
            string  select  = "select r_object_id, object_name, keywords, authors from dm_cabinet where not object_name like 'dm%' and object_name = 'ls_repos'";
            DataSet dataset = new DataSet();
            string  cnstr   = "User=dmadmin;Password=@vmware99;Repository=ls_repos";

            using (DqlConnection cn = new DqlConnection(cnstr))
            {
                cn.Open();
                using (DqlCommand cmd = new DqlCommand(select, cn))
                {
                    using (DqlDataAdapter adapter = new DqlDataAdapter(cmd))
                    {
                        var schemas = adapter.FillSchema(dataset, SchemaType.Source);
                        Assert.AreEqual(dataset.Tables[0].Rows[0]["keywords"].ToString(), "test2|test3|test1");
                        Assert.AreEqual(dataset.Tables[0].Rows[0]["authors"].ToString(), "author2|author3|author1");
                    }
                }
            }
        }
        public void Test_DqlFill()
        {
            string  select  = "Select r_object_id, keywords from dm_cabinet enable(return_top 1); select * from dm_document enable(return_top 1)";
            DataSet dataset = new DataSet();
            string  cnstr   = "User=dmadmin;Password=@vmware99;Repository=ls_repos";

            using (DqlConnection cn = new DqlConnection(cnstr))
            {
                cn.Open();
                using (DqlCommand cmd = new DqlCommand(select, cn))
                {
                    using (DqlDataAdapter adapter = new DqlDataAdapter(cmd))
                    {
                        var schemas = adapter.Fill(dataset);
                        Assert.AreEqual(dataset.Tables.Count, 2);
                        Assert.AreEqual(dataset.Tables[0].Rows.Count, 1);
                        Assert.AreEqual(dataset.Tables[1].Rows.Count, 1);
                    }
                }
            }
        }
示例#8
0
        /// <summary>
        /// Handles the ButtonClick event of the btnDataSource control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DevExpress.XtraEditors.Controls.ButtonPressedEventArgs" /> instance containing the event data.</param>
        private void btnDataSource_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            if (cbProviders.Text == "Microsoft Excel")
            {
                OpenFileDialog dlg = new OpenFileDialog()
                {
                    Filter = "Microsoft Excel (*.xlsx;*.xls)|*.xlsx;*.xls"
                };
                if (dlg.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }
                btnDataSource.Text = dlg.FileName;
            }
            if (cbProviders.Text == "Microsoft Access")
            {
                OpenFileDialog dlg = new OpenFileDialog()
                {
                    Filter = "Microsoft Access (*.mdb;*.accdb)|*.mdb;*.accdb"
                };
                if (dlg.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }
                btnDataSource.Text = dlg.FileName;
            }
            if (cbProviders.Text == "OpenText Documentum")
            {
                if (btnDataSource.Properties.Items.Count != 0)
                {
                    return;
                }

                var           builder = new DqlConnectionStringBuilder(txtUserId.Text, txtPassword.Text, btnDataSource.Text);
                DqlConnection cn      = new DqlConnection(builder.ConnectionString);
                btnDataSource.Properties.Items.AddRange(cn.Catalogs);
                btnDataSource.Text = cn.Catalogs.First();
            }
        }
        public void Test_DqlMultiQuery()
        {
            DataSet dataset = new DataSet("MulitQueryTest");
            string  cnstr   = "User=dmadmin;Password=@vmware99;Repository=ls_repos";

            using (DqlConnection cn = new DqlConnection(cnstr))
            {
                cn.Open();
                using (DqlCommand cmd = new DqlCommand(File.ReadAllText(".\\DqlMultiQueryTest.txt"), cn))
                {
                    using (DqlDataAdapter adapter = new DqlDataAdapter(cmd))
                    {
                        var schemas = adapter.Fill(dataset);
                        var table   = dataset.MergeAll();
                        Assert.AreEqual(dataset.Tables.Count, 21);
                        Assert.AreEqual(table.Rows.Count, 10000);
                        //Assert.AreEqual(dataset.Tables[0].Rows.Count, 1);
                        //Assert.AreEqual(dataset.Tables[1].Rows.Count, 1);
                    }
                }
            }
        }
        /// <summary>
        /// Executes the query.
        /// </summary>
        /// <param name="select">The select.</param>
        /// <param name="token">The token.</param>
        /// <returns>DataSet.</returns>
        public override DataSet ExecuteQuery(string select, CancellationToken token)
        {
            if (UseExternalQueryEngine())
            {
                return(ExecuteQueryExternal(select));
            }

            DataSet dataSet = null;

            using (var cn = new DqlConnection(ConnectionString))
            {
                cn.Open();
                using (DqlCommand cmd = new DqlCommand(select, cn))
                {
                    using (DqlDataAdapter adapter = new DqlDataAdapter(cmd))
                    {
                        dataSet = new DataSet();
                        adapter.Fill(dataSet, token);
                    }
                }
            }
            return(dataSet);
        }
        /// <summary>
        /// Gets the schema model.
        /// </summary>
        /// <returns>List&lt;TableSchemaModel&gt;.</returns>
        public override List <TableSchemaModel> GetSchemaModel()
        {
            if (UseExternalQueryEngine())
            {
                return(GetSchemaModelExternal());
            }

            DqlDataTypeMap          map = new DqlDataTypeMap();
            List <TableSchemaModel> tableSchemaModel = new List <TableSchemaModel>();

            using (DqlConnection cn = new DqlConnection(ConnectionString))
            {
                cn.Open();
                var schema = cn.GetSchema().AsEnumerable().GroupBy(g => g.Field <string>("name"));

                foreach (var item in schema)
                {
                    TableSchemaModel table = new TableSchemaModel();
                    tableSchemaModel.Add(table);
                    FillSchemaModel(table, item);
                }
            }
            return(tableSchemaModel);
        }