Exemplo n.º 1
0
        private void CreatTablesButt_Click(object sender, EventArgs e)
        {
            string ConnectionString = _cs;

            Npgsql.NpgsqlConnection _conn = new Npgsql.NpgsqlConnection(ConnectionString);
            _conn.Open();
            FolderBrowserDialog dlg = new FolderBrowserDialog();

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            Dictionary <string, string> xsdFiles = GetTablesNames.GetTables(dlg.SelectedPath);

            foreach (KeyValuePair <string, string> _filePath in xsdFiles)
            {
                ProccessXSD     proc = new ProccessXSD();
                TableDefinition def  = proc.XSDToTableDefinition(_filePath.Key, TargetSchema);
                Console.WriteLine(def.SQLtable());
                Npgsql.NpgsqlCommand _cmd = new Npgsql.NpgsqlCommand(def.SQLtable(), _conn);
                _cmd.ExecuteNonQuery();

                ///Запись sql в файл для каждой таблицы
#if Debug
                string file = System.IO.Path.Combine(System.IO.Directory.GetParent(_filePath.Key).FullName, _filePath.Value + ".sql");
                System.IO.StreamWriter wrt = new System.IO.StreamWriter(file);
                wrt.WriteLine(def.SQLtable());
                wrt.Flush();
                wrt.Close();
#endif
            }
            _conn.Close();
        }
Exemplo n.º 2
0
        /// <summary>
        /// TODO: переименовать во что-то более осмысленное
        /// </summary>
        /// <param name="Folder"></param>
        /// <returns></returns>
        private async System.Threading.Tasks.Task BurnDaHausAsync(string Folder)
        {
            string _folder      = Folder;
            string xmlPath      = _folder;
            string xsdPath      = _folder;
            string originalText = Text;
            Dictionary <string, string> tables = GetTablesNames.GetTables(xsdPath);

            foreach (KeyValuePair <string, string> table in tables.AsEnumerable())
            {
                ResetProgressBar();
                Text = table.Value;
                Action <int> progress = new Action <int>(ProgressChanged);
                string[]     files    = GetXMLSBySchema(table.Value, xmlPath, true);



                ProccessXSD     proc = new ProccessXSD();
                TableDefinition def  = proc.XSDToTableDefinition(table.Key, TargetSchema);
                if (def.tableName == "as_param")
                {
                    ResetProgressBar();
                    Action <int> localProgress = new Action <int>(ProgressChanged);
                    string[]     paramXmls     = System.IO.Directory.GetFiles(xmlPath, "AS_*_PARAMS_*.xml", System.IO.SearchOption.AllDirectories);
                    foreach (string paramXml in paramXmls)
                    {
                        textBox1.Text = paramXml;
                        WriteData paramWrt = new WriteData(def, paramXml, _cs, 100);
                        await paramWrt.ReadXmlAsync(localProgress);
                    }
                    continue;
                }

                if (files.Count() < 1)
                {
                    continue;
                }

                foreach (string xmlfile in files)
                {
                    textBox1.Text = xmlfile;
                    WriteData wrt = new WriteData(def, xmlfile, _cs);
                    await wrt.ReadXmlAsync(progress);
                }
            }
            Text = originalText;
            ResetProgressBar();
        }