// It is called when preparing this dialog for editing/adding a table or when context changes (not during the process) // Essentially, we do it when data context is set. private void initViewModel() { DcSpace space = mainVM.Space; if (IsNew) { TableName = "New Table"; TableFormula = ""; FilePath = ""; HasHeaderRecord = true; Delimiter = ","; Decimal = "."; TableColumns.Clear(); } else { TableName = Table.Name; TableFormula = Table.GetData().WhereFormula; FilePath = ((TableCsv)Table).FilePath; HasHeaderRecord = ((TableCsv)Table).HasHeaderRecord; Delimiter = ((TableCsv)Table).Delimiter; Decimal = ((TableCsv)Table).CultureInfo.NumberFormat.NumberDecimalSeparator; UpdateColumnList(); } FirePropertyNotifyChanged(""); }
private void OnDataCollected(FdrManagerEventArgs e) { Ordinats.Clear(); cb_Abscissa.Items.Clear(); TableColumns.Clear(); foreach (var title in m_DataProcessingHelper.GetCollectedMeasuresNames()) { CheckedListItem <string> item = new CheckedListItem <string>() { Item = title }; item.PropertyChanged += onOrdinateChecked; Ordinats.Add(item); cb_Abscissa.Items.Add(title); item = new CheckedListItem <string>() { Item = title }; item.PropertyChanged += onTabColumnChecked; TableColumns.Add(item); } StatusLabelMain.Content = Properties.Resources.state_success; Started = false; }
private void MakeColumnsAsLocalSubSelect() { TableColumns.Clear(); List <ColumnClause> lst = GetAllColumns().ToList(); HashSet <string> str = new HashSet <string>(); foreach (var c in lst) { string alias = c.ExtractAlias(); if (alias == null) { alias = ""; } var tp = c.ColumnExpression.GetResultType(); if (tp == SimpleTypes.Geometry) { CoordinateSystem = c.ColumnExpression.GetCoordinateSystem(); } TableColumns.Add(new ColumnSubSelect() { ColumnClause = c, Name = alias, SimpleType = tp }); } }
public override DataTable GetTableInfo(string tableName) { try { String[] columnRestrictions = new String[4]; if (tableName == null) { columnRestrictions[2] = SelectedTable; } else { columnRestrictions[2] = tableName; } DataTable departmentIDSchemaTable = connection.GetSchema("Columns", columnRestrictions); TableColumns.Clear(); DataView dv = departmentIDSchemaTable.DefaultView; departmentIDSchemaTable.DefaultView.Sort = "ORDINAL_POSITION Asc"; var SortedView = dv.ToTable(); foreach (DataRow row in SortedView.Rows) { TableColumns.Add(new Column(row, DbType)); } return(departmentIDSchemaTable); } catch (Exception ex) { return(null); } }
public override void Prepare() { base.Prepare(); for (int i = 0; i < ReturningColumns.Count; i++) { ReturningColumns[i].Prepare(); } TableColumns.Clear(); List <ColumnClause> lst = ReturningColumns.ToList(); HashSet <string> str = new HashSet <string>(); foreach (var c in lst) { string alias = c.ExtractAlias(); if (alias == null) { alias = ""; } var tp = c.ColumnExpression.GetResultType(); if (tp == SimpleTypes.Geometry) { CoordinateSystem = c.ColumnExpression.GetCoordinateSystem(); } TableColumns.Add(new ColumnSubSelect() { ColumnClause = c, Name = alias, SimpleType = tp }); } }
void OnStartNewDataCollecting(FdrManagerEventArgs e) { Ordinats.Clear(); cb_Abscissa.Items.Clear(); TableColumns.Clear(); StatusLabelSecond.Content = ""; StatusLabelMain.Content = Properties.Resources.state_collecting; }
public override DataTable GetTableInfo(string tableName = null) { try { String[] columnRestrictions = new String[4]; if (tableName == null) { columnRestrictions[2] = SelectedTable; } else { columnRestrictions[2] = tableName; } DataTable departmentIDSchemaTable = connection.GetSchema("Columns", columnRestrictions); TableColumns.Clear(); DataView dv = departmentIDSchemaTable.DefaultView; departmentIDSchemaTable.DefaultView.Sort = "ORDINAL_POSITION Asc"; var SortedView = dv.ToTable(); foreach (DataRow row in SortedView.Rows) { TableColumns.Add(new Column(row, DbType)); } ///////// string _table = (tableName == null) ? SelectedTable : tableName; SqlDataAdapter adapter = new SqlDataAdapter("SELECT TOP 1 * FROM " + _table, (connection as SqlConnection)); adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey; DataTable table = new DataTable(); adapter.Fill(table); using (DataTableReader reader = new DataTableReader(table)) { int ordinal = 0; DataTable schemaTable = reader.GetSchemaTable(); for (int i = 0; i < schemaTable.Rows.Count; i++) { if ((bool)schemaTable.Rows[i].ItemArray[12]) { TableColumns[i].ISKey = true; } } } /////////////// return(departmentIDSchemaTable); } catch (Exception ex) { return(null); } }
private void OnFailure(FdrManagerEventArgs e) { TableColumns.Clear(); Ordinats.Clear(); cb_Abscissa.Items.Clear(); Action onFailureAction = delegate() { StatusLabelMain.Content = Properties.Resources.state_failed; Started = false; }; if (!Started) { return; } Dispatcher.Invoke(onFailureAction); MessageBox.Show(e.Message); }
private void btn_Graph_Open_Click(object sender, RoutedEventArgs e) { var opened = Load(); if (opened == null) { return; } cb_Abscissa.Items.Clear(); Ordinats.Clear(); TableColumns.Clear(); m_DataProcessingHelper.loadState(opened.Data); foreach (var title in m_DataProcessingHelper.GetCollectedMeasuresNames()) { CheckedListItem <string> item = new CheckedListItem <string>() { Item = title }; Ordinats.Add(item); cb_Abscissa.Items.Add(title); item = new CheckedListItem <string>() { Item = title }; item.PropertyChanged += onTabColumnChecked; TableColumns.Add(item); } cb_Abscissa.SelectionChanged -= cb_Abscissa_SelectionChanged; cb_Abscissa.SelectedItem = m_DataProcessingHelper.Graphs.First().XAxis; m_DataProcessingHelper.Graphs.Select(g => g.YAxis).ToList().ForEach(y => Ordinats.Where(o => o.Item.Equals(y)).First().IsChecked = true); opened.CheckedTables.ForEach(c => TableColumns.Where(t => t.Item.Equals(c)).First().IsChecked = true); cb_Abscissa.SelectionChanged += cb_Abscissa_SelectionChanged; Ordinats.ToList().ForEach(o => o.PropertyChanged += onOrdinateChecked); }
public override void Prepare() { base.Prepare(); TableColumns.Clear(); PrepareTables(); PrepareColumns(); MakeColumnsAsLocalSubSelect(); PrepareInner(); if (ExtSelects != null && ExtSelects.Count > 0) { foreach (var e in ExtSelects) { e.Prepare(); } } var lst = GetAllColumns(); if (lst.Count == 1) { var tp = lst[0].ColumnExpression.GetResultType(); SetResultType(tp); } }