상속: System.Windows.Forms.Form
예제 #1
0
        public static DBFilesClient SelectCatalog(string path)
        {
            using (var selector = new DefinitionCatalog())
            {
                var defpath = Path.Combine(path, "definitions");

                if (!Directory.Exists(defpath))
                    Directory.CreateDirectory(defpath);

                var files = Directory.GetFiles(defpath, "*.xml");

                if (files.Length == 0)
                {
                    selector.DialogResult = DialogResult.OK;
                    selector.Close();
                    return new DBFilesClient() { File = Path.Combine(defpath, "default.xml"), Tables = new List<Table>() };
                }

                foreach (var file in files)
                    selector.listBox1.Items.Add(Path.GetFileName(file));

                selector.ShowDialog();

                if (selector.DefinitionIndex != -1)
                    return DBFilesClient.Load(files[selector.DefinitionIndex]);

                return null;
            }
        }
예제 #2
0
        public static DBFilesClient SelectCatalog(string path)
        {
            using (var selector = new DefinitionCatalog())
            {
                var files = Directory.GetFiles(Path.Combine(path, "definitions"), "*.xml");

                foreach (var file in files)
                    selector.listBox1.Items.Add(Path.GetFileName(file));

                selector.ShowDialog();

                if (selector.DefinitionIndex != -1)
                    return DBFilesClient.Load(files[selector.DefinitionIndex]);

                return null;
            }
        }
예제 #3
0
        public static DBFilesClient SelectCatalog(string path)
        {
            using (var selector = new DefinitionCatalog())
            {
                var defpath = Path.Combine(path, "definitions");

                if (!Directory.Exists(defpath))
                {
                    Directory.CreateDirectory(defpath);
                }

                var files = Directory.GetFiles(defpath, "*.xml");

                if (files.Length == 0)
                {
                    selector.DialogResult = DialogResult.OK;
                    selector.Close();
                    return(new DBFilesClient()
                    {
                        File = Path.Combine(defpath, "default.xml"), Tables = new List <Table>()
                    });
                }

                foreach (var file in files)
                {
                    selector.listBox1.Items.Add(Path.GetFileName(file));
                }

                selector.ShowDialog();

                if (selector.DefinitionIndex != -1)
                {
                    return(DBFilesClient.Load(files[selector.DefinitionIndex]));
                }

                return(null);
            }
        }
예제 #4
0
        private void LoadDefinitions()
        {
            string oldDefsPath = Path.Combine(m_workingFolder, "dbclayout.xml");

            // convert...
            if (File.Exists(oldDefsPath))
            {
                XmlDocument oldDefs = new XmlDocument();
                //var path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                oldDefs.Load(oldDefsPath);

                if (oldDefs["DBFilesClient"].GetElementsByTagName("Table").Count == 0)
                {
                    DBFilesClient db = new DBFilesClient();

                    db.Tables = new List <Table>();

                    foreach (XmlElement def in oldDefs["DBFilesClient"])
                    {
                        string name = def.Name;

                        var fields   = def.GetElementsByTagName("field");
                        var index    = def.GetElementsByTagName("index");
                        var hasIndex = index.Count > 0;
                        var build    = Convert.ToInt32(def.Attributes["build"].Value);

                        Table table = new Table();

                        table.Name   = name;
                        table.Build  = build;
                        table.Fields = new List <Field>();

                        for (int i = 0; i < fields.Count; i++)
                        {
                            var oldField = fields[i];

                            Field field = new Field();

                            field.Name      = oldField.Attributes["name"].Value;
                            field.ArraySize = Convert.ToInt32(oldField.Attributes["arraysize"]?.Value ?? "1");
                            field.Format    = oldField.Attributes["format"]?.Value ?? "";
                            field.Type      = oldField.Attributes["type"]?.Value ?? "int";
                            field.Index     = i;
                            field.Visible   = true;
                            field.Width     = 0;
                            field.IsIndex   = hasIndex ? index[0]["primary"].InnerText == field.Name : i == 0;

                            table.Fields.Add(field);
                        }

                        db.Tables.Add(table);
                    }

                    db.File = Path.Combine(m_workingFolder, "definitions", "dblayout_old.xml");
                    DBFilesClient.Save(db);

                    File.Move(oldDefsPath, Path.Combine(m_workingFolder, "dbclayout.xml.bak"));
                }
            }

            m_definitions = DefinitionCatalog.SelectCatalog(m_workingFolder);
        }