public IRowTransform GetTransform() { bool ispermute = true; for (int i = 0; i < m_combos.Count; i++) { if (m_checks[i].Checked) { continue; } var c = m_typeCombos[i]; if (c.SelectedIndex > 0) { ispermute = false; } } if (ispermute) { TableStructure target = new TableStructure(); List <int> indexes = new List <int>(); for (int i = 0; i < m_combos.Count; i++) { if (m_checks[i].Checked) { continue; } var combo = m_combos[i]; int idx = combo.Items.IndexOf(combo.Text); if (idx < 0) { throw new RowTransformError("DAE-00183" + Texts.Get("s_cannot_find$column", "column", combo.Text)); } indexes.Add(idx); target._Columns.Add(new ColumnStructure(m_target.Columns[i])); } return(new PermuteTransform(m_source, target, indexes)); } else { TableStructure target = new TableStructure(); List <GenericTransform.ColExpr> cols = new List <GenericTransform.ColExpr>(); for (int i = 0; i < m_typeCombos.Count; i++) { if (m_checks[i].Checked) { continue; } cols.Add(new GenericTransform.ColExpr { Type = (GenericTransform.ColExprType)m_typeCombos[i].SelectedItem, Expression = m_combos[i].Text, Name = m_target.Columns[i].ColumnName }); target._Columns.Add(new ColumnStructure(m_target.Columns[i])); } GenericTransform gt = new GenericTransform(m_source, target, cols); return(gt); } }
public ColumnMapFrame_VarTarget() { InitializeComponent(); m_invoker = new ControlInvoker(this); var col = (DataGridViewComboBoxColumn)lbtarget.Columns[1]; foreach (var type in GenericTransform.GetColExprTypes()) { col.Items.Add(type.ToString()); m_types[type.ToString()] = type; } }
//void GotRowFormat(IAsyncResult async) //{ // lbsource.Enabled = true; // lbtarget.Enabled = true; // DataTable rowformat = m_source.EndGetRowFormat(async); // foreach (DataRow row in rowformat.Rows) // { // lbsource.Items.Add(row["ColumnName"]); // } //} public IRowTransform GetTransform() { bool ispermute = true; bool iscolumn = false; foreach (DataGridViewRow row in lbtarget.Rows) { var type = GetExprType(row); if (type == null) { continue; } if (!(type is GenericTransform.ColumnColExprType)) { ispermute = false; } iscolumn = true; } if (!iscolumn) { throw new InternalError("DAE-00372 no columns"); } if (ispermute) { List <int> colindexes = new List <int>(); foreach (DataGridViewRow row in lbtarget.Rows) { var type = GetExprType(row); if (type == null) { continue; } int index = m_srcformat.Columns.GetIndex(row.Cells[2].Value.ToString()); if (index < 0) { throw new InternalError("DAE-00012 Undefined column:" + row.Cells[2].Value.ToString()); } colindexes.Add(index); } return(new PermuteTransform(m_srcformat, CreateTargetStructure(), colindexes)); } else { List <GenericTransform.ColExpr> cols = new List <GenericTransform.ColExpr>(); foreach (DataGridViewRow row in lbtarget.Rows) { var type = GetExprType(row); if (type == null) { continue; } cols.Add(new GenericTransform.ColExpr { Type = type, Expression = row.Cells[2].Value.SafeToString(), Name = row.Cells[0].Value.ToString() }); } GenericTransform gt = new GenericTransform(m_srcformat, CreateTargetStructure(), cols); return(gt); } }
public void SetBindings(ITabularDataStore source, ITabularDataStore target) { using (WaitContext wc = new WaitContext()) { Async.SafeOpen(source.Connection); Async.SafeOpen(target.Connection); try { IAsyncResult res1 = source.BeginGetRowFormat(null); Async.WaitFor(res1); m_source = source.EndGetRowFormat(res1); } catch (Exception err) { throw new BulkCopyInputError("DAE-00181", err); } if (m_source.Columns.Count == 0) { throw new ExpectedError("DAE-00182 " + Texts.Get("s_no_columns_detected_in_imported_source")); } IAsyncResult res2 = target.BeginGetRowFormat(null); Async.WaitFor(res2); m_target = target.EndGetRowFormat(res2); int acty = labValue.Top + labValue.Height + 10; int colindex = 0; foreach (IColumnStructure col in m_target.Columns) { Label lab = new Label(); Controls.Add(lab); lab.Left = labTarget.Left; lab.Top = acty; lab.Text = col.ColumnName + " :"; CheckBox skip = new CheckBox(); Controls.Add(skip); skip.Top = acty; skip.Width = 30; skip.Left = labSkip.Left; m_checks.Add(skip); skip.Tag = colindex; skip.CheckedChanged += new EventHandler(skip_CheckedChanged); ComboBox type = new ComboBox(); Controls.Add(type); type.Left = labType.Left; type.Top = acty; type.DropDownStyle = ComboBoxStyle.DropDownList; GenericTransform.GetColExprTypes(type.Items); type.SelectedIndex = 0; type.Tag = colindex; m_typeCombos.Add(type); ComboBox sel = new ComboBox(); Controls.Add(sel); sel.Left = labValue.Left; sel.Top = acty; sel.DropDownStyle = ComboBoxStyle.DropDown; sel.DropDownClosed += new EventHandler(sel_DropDownClosed); sel.Tag = colindex; foreach (IColumnStructure srccol in m_source.Columns) { sel.Items.Add(srccol.ColumnName); } sel.SelectedIndex = sel.Items.IndexOf(col.ColumnName); if (sel.SelectedIndex < 0) { if (col.ColumnOrder < sel.Items.Count) { sel.SelectedIndex = col.ColumnOrder; } else { sel.SelectedIndex = 0; } } m_combos.Add(sel); acty += Math.Max(sel.Height, lab.Height) * 5 / 4; colindex++; } } }