Exemple #1
0
        async private Task BuildList()
        {
            lstDatasets.Items.Clear();
            AccessFDB fdb = null;

            switch (_providerId)
            {
            case "mssql":
                fdb = new SqlFDB();
                break;

            case "postgres":
                fdb = new pgFDB();
                break;

            case "sqlite":
                fdb = new SQLiteFDB();
                break;
            }

            if (fdb == null)
            {
                return;
            }

            if (!await fdb.Open(this.ConnectionString))
            {
                MessageBox.Show(fdb.LastErrorMessage, "Error");
                return;
            }

            string[] dsnames = await fdb.DatasetNames();

            if (dsnames != null)
            {
                foreach (string dsname in dsnames)
                {
                    var isImageDatasetResult = await fdb.IsImageDataset(dsname);

                    ListViewItem item = new ListViewItem(
                        dsname, isImageDatasetResult.isImageDataset ? 1 : 0);

                    lstDatasets.Items.Add(item);

                    if (item.Text == _dsname)
                    {
                        lstDatasets.SelectedIndices.Add(lstDatasets.Items.Count - 1);
                    }
                }
            }
        }
Exemple #2
0
        async private Task <string[]> DatasetNames()
        {
            try
            {
                SQLiteFDB fdb = new SQLiteFDB();
                if (!await fdb.Open(_filename))
                {
                    _errMsg = fdb.LastErrorMessage;
                    return(null);
                }
                string[] ds = await fdb.DatasetNames();

                string[] dsMod = new string[ds.Length];

                int i = 0;
                foreach (string dsname in ds)
                {
                    var isImageDatasetResult = await fdb.IsImageDataset(dsname);

                    string imageSpace = isImageDatasetResult.imageSpace;
                    if (isImageDatasetResult.isImageDataset)
                    {
                        dsMod[i++] = "#" + dsname;
                    }
                    else
                    {
                        dsMod[i++] = dsname;
                    }
                }
                if (ds == null)
                {
                    _errMsg = fdb.LastErrorMessage;
                }

                fdb.Dispose();

                return(dsMod);
            }
            catch (Exception ex)
            {
                _errMsg = ex.Message;
                return(null);
            }
        }