private void buildView(object sender, EventArgs e) { var avt = new ArrayVerify(); var newView = new TabloidConfigView(); BuildFromBase.GetTable(_own, ParentTableResult.TableName, Program.AppSet.Schema, ref newView, ref avt, new BuildFromBase.BaseImporterConfig { RemoveTableName = true, ToUpperCase = true, ReplaceUnderscrore = true, ConnectionString = Program.AppSet.ConnectionString }); TabloidConfig.Config.Views.Add(newView); }
private void btn_Click(object sender, EventArgs e) { var error = false; progressBar1.Maximum = 100; progressBar1.Value = 0; var schema = txtSchema.Text == "" ? "public" : txtSchema.Text; object[] param = { txtHote.Text, txtUtil.Text, txtMdp.Text, txtBase.Text, schema }; var connectionString = cmbType.SelectedIndex == 0 ? string.Format("Datasource={0};Database={3};uid={1};pwd={2};", param) : string.Format("User ID={1};Password={2};Host={0};Port=5432;Database={3};SearchPath={4},public;", param); Program.AppSet = new AppSetting { ConnectionString = connectionString, ProviderType = cmbType.SelectedIndex == 0 ? Provider.MySql : Provider.Postgres, Titre = txtBase.Text, identParam = cmbType.SelectedIndex == 0 ? "?" : "@", sqlDebug = "oui" }; Tools.SetDefaultProviderFromAppSet(); lblState.Text = Resources.NewFromBaseForm_btn_Click_Récupération_des_Tables; lblState.Refresh(); SqlCommands.Provider = cmbType.SelectedIndex == 0 ? Provider.MySql : Provider.Postgres; Program.AppSet.Schema = schema; string lastError; var dt = DataTools.Data(SqlCommands.SqlGetTable(), connectionString, out lastError); if (dt == null) { MetroMessageBox.Show(this, Resources.NewFromBaseForm_btn_Click_ + lastError, Resources.Erreur, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!string.IsNullOrEmpty(lastError)) { lblState.Text = lastError; error = true; } else { TabloidConfig.Config = new TabloidConfig(); TabloidConfig.Config.TabloidConfigApp.UseLockDatabaseField = chkLockInDB.Checked; var avt = new ArrayVerify(); var config = new BuildFromBase.BaseImporterConfig { RemoveTableName = chkSuppNomTable.Checked, ToUpperCase = chkCasse.Checked, ReplaceUnderscrore = chkUnderscrore.Checked, ConnectionString = connectionString }; if (dt.Rows.Count > 0) { TabloidFields.TabloidFieldsArray = null; //Program.AppSet.pageDefaut = "/tabloid/BSliste.aspx?table=" + AppSetting.setDefaultPage(dt.Rows[0][0].ToString()); var delta = 100 / dt.Rows.Count; //read Tables foreach (DataRow dtr in dt.Rows) { progressBar1.Value += delta; progressBar1.Refresh(); var dtName = dtr[0].ToString(); var tableConfig = new TabloidConfigView(); try { BuildFromBase.GetTable(this, dtName, schema, ref tableConfig, ref avt, config); TabloidConfig.Config.Views.Add(tableConfig); } catch (Exception ex) { lblState.Text = ex.ToString(); } } if (error) { return; } } //verify tabloid table existance if (!avt.IsThereAll(TabloidTables.TabloidTablesArray.Count())) { var l = avt.NotInIndex(TabloidTables.TabloidTablesArray.Count()); //list unaviable tables var r = DialogResult.Yes; if (!chkAutoTable.Checked) { //Show message var strCh = string.Join("\n\t- ", TabloidTables.TabloidTablesArray .Where((f, index) => l.Any(i => i == index)) .Select((x, index) => x.Name).ToArray()); r = MetroMessageBox.Show(this, string.Format( Resources.NewFromBaseForm_tables_inutiles, strCh), Resources.Information, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); } if (r == DialogResult.Yes) { var toCreate = TabloidTables.TabloidTablesArray .Where((f, index) => l.Any(i => i == index)) .ToList(); TabloidTables.CreateTable( toCreate, connectionString, this); foreach (var t in toCreate)// table to config { var tableConfig = new TabloidConfigView(); try { BuildFromBase.GetTable(this, t.Name, schema, ref tableConfig, ref avt, config); TabloidConfig.Config.Views.Add(tableConfig); } catch (Exception ex) { lblState.Text = ex.ToString(); } } } } OlStyleCollection.olStyles = new List <OlStyle>(); DialogResult = DialogResult.OK; Close(); } }