Пример #1
0
        public static BaseTable DataSetToVisualizerBase(DataSet p_objDataSetToVisualize)
        {
            // List of bast type tables
            VisualizerBaseTable[] arrTables = new VisualizerBaseTable[p_objDataSetToVisualize.Tables.Count];

            // for each table in DataSet
            for (int intCurrTable = 0; intCurrTable < p_objDataSetToVisualize.Tables.Count; intCurrTable++)
            {
                #region Convert DataTable to Base Table

                // Get current Table
                DataTable dtSingleTableFromDS = p_objDataSetToVisualize.Tables[intCurrTable];

                // Create Dictionary of columns and types
                Dictionary<string, Type> dicColumns = new Dictionary<string, Type>();
                foreach (DataColumn column in dtSingleTableFromDS.Columns)
                {
                    dicColumns.Add(column.ColumnName, column.DataType);
                }

                // Create array of Primary-key columns
                string[] arrPrimaryKeys = new string[dtSingleTableFromDS.PrimaryKey.Length];
                for (int intCurrPK = 0; intCurrPK < arrPrimaryKeys.Length; intCurrPK++)
                {
                    arrPrimaryKeys[intCurrPK] = dtSingleTableFromDS.PrimaryKey[intCurrPK].ColumnName;
                }

                // Create Base table from current DataTable
                VisualizerBaseTable objSingleTableFromDS = new VisualizerBaseTable(DataTableToMatrix(dtSingleTableFromDS),
                                                          dicColumns,
                                                          arrPrimaryKeys,
                                                          dtSingleTableFromDS.TableName);

                // Ver2: prepare to Hierarchical DataView within Dataset
                // Ver2: objSingleTableFromDS.MyIdField = objHierarchicalDV.MyIDField;
                // Ver2: objSingleTableFromDS.MyParentIdField = objHierarchicalDV.MyParentIDField;

                #endregion

                // Add Base table to array of tables
                arrTables[intCurrTable] = objSingleTableFromDS;
            }

            // Create base object to that can go between debugger and debugee
            BaseTable objVisualizer = new BaseTable(arrTables);

            return objVisualizer;
        }
Пример #2
0
        public static BaseTable DataTableToBaseData(DataTable p_dtDataTableToVisualize)
        {
            #region Preparation

            // Create columns dictionary with types (key - tablename, value - type)
            Dictionary<string, Type> dicColumns = new Dictionary<string, Type>();
            foreach (DataColumn objDataColumn in p_dtDataTableToVisualize.Columns)
            {
                dicColumns.Add(objDataColumn.ColumnName, objDataColumn.DataType);
            }

            // Create array of primary key columns
            string[] arrPrimaryKeys = new string[p_dtDataTableToVisualize.PrimaryKey.Length];

            // for each primary column
            for (int intCurrPK = 0; intCurrPK < p_dtDataTableToVisualize.PrimaryKey.Length; intCurrPK++)
            {
                arrPrimaryKeys[intCurrPK] = p_dtDataTableToVisualize.PrimaryKey[intCurrPK].ColumnName;
            }

            #endregion

            // Create base object to that can go between debugger and debugee
            BaseTable objTableToVisualize =
                new BaseTable(DataTableToMatrix(p_dtDataTableToVisualize),
                                         dicColumns,
                                         arrPrimaryKeys,
                                         p_dtDataTableToVisualize.TableName);

            return objTableToVisualize;
        }