Example #1
0
        public SumAggregator(IXColumn sumOverColumn)
        {
            _sumColumn        = sumOverColumn;
            _sumCurrentGetter = sumOverColumn.CurrentGetter();

            ColumnDetails = new ColumnDetails($"{sumOverColumn.ColumnDetails.Name}.Sum", typeof(long));
        }
Example #2
0
        /// <summary>
        /// Saves or loads a listview column.
        /// </summary>
        internal void OpenColumn(bool save, string listId, Column column)
        {
            string        key = listId + "\\" + column.Id;
            ColumnDetails savedData;

            if (save)
            {
                // Save
                if (!this._columnDisplayStatuses.TryGetValue(key, out savedData))
                {
                    savedData = new ColumnDetails();
                    this._columnDisplayStatuses.Add(key, savedData);
                }

                savedData.DisplayIndex = column.DisplayIndex;
                savedData.Width        = column.Width;
                savedData.Visible      = column.Visible;
                savedData.DisplayName  = column.OverrideDisplayName;
            }
            else
            {
                // Load
                if (this._columnDisplayStatuses.TryGetValue(key, out savedData))
                {
                    column.Visible             = savedData.Visible;
                    column.Width               = savedData.Width;
                    column.DisplayIndex        = savedData.DisplayIndex;
                    column.OverrideDisplayName = savedData.DisplayName;
                }
            }
        }
Example #3
0
        /// <summary>
        ///  Change the type of a column to a new type. Values are copied from the existing
        ///  column to the new one, if value conversion is possible.
        /// </summary>
        /// <param name="details">Details with existing name and new other details</param>
        public void AlterColumn(ColumnDetails details)
        {
            _locker.EnterWriteLock();
            try
            {
                if (this.RunParallel)
                {
                    Parallel.ForEach(_partitions, (p) =>
                    {
                        p.AlterColumn(details);
                    });
                }
                else
                {
                    foreach (Partition p in _partitions)
                    {
                        p.AlterColumn(details);
                    }
                }

                // Reset column alias mappings
                _columnAliasCorrector.SetMappings(this);
            }
            finally
            {
                _locker.ExitWriteLock();
            }
        }
Example #4
0
        private static IList <ColumnDetails> ParseSchemaFile(string schemaFilePath)
        {
            List <ColumnDetails> columns = new List <ColumnDetails>();

            foreach (string line in File.ReadAllLines(schemaFilePath))
            {
                string[]      values = line.Split('\t');
                ColumnDetails d;

                if (values.Length == 1)
                {
                    d = new ColumnDetails(values[0]);
                }
                else if (values.Length == 2)
                {
                    d = new ColumnDetails(values[0], values[1], null);
                }
                else if (values.Length == 3)
                {
                    d = new ColumnDetails(values[0], values[1], null);
                }
                else if (values.Length == 5)
                {
                    d = new ColumnDetails(values[0], values[1], values[2], values[3], bool.Parse(values[4]));
                }
                else
                {
                    throw new InvalidOperationException(String.Format("Schema Files must be tab delimited, and may contain 1, 2, 3, or 5 values:\r\nName\tType?\tDefault?\tAlias?\tIsPrimaryKey\r\n. Line Read: {0}", line));
                }

                columns.Add(d);
            }

            return(columns);
        }
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            ColumnDetails column = (ColumnDetails)value;

            writer.WriteStartObject();
            writer.WritePropertyName("name");
            writer.WriteValue(column.Name);

            if (!String.IsNullOrEmpty(column.Type))
            {
                writer.WritePropertyName("type");
                writer.WriteValue(column.Type);
            }

            if (column.Default != null)
            {
                writer.WritePropertyName("default");
                writer.WriteValue(column.Default);
            }

            if (!String.IsNullOrEmpty(column.Alias))
            {
                writer.WritePropertyName("alias");
                writer.WriteValue(column.Alias);
            }

            if (column.IsPrimaryKey)
            {
                writer.WritePropertyName("isPrimaryKey");
                writer.WriteValue(column.IsPrimaryKey);
            }

            writer.WriteEndObject();
        }
Example #6
0
 private SimpleMultiArgumentFunction(string name, IEnumerable <IXColumn> columns, Func <IList <XArray>, XArray> function)
 {
     _name              = name;
     _columns           = columns;
     _function          = function;
     this.ColumnDetails = new ColumnDetails(name, typeof(T));
 }
        public SingleValueColumn(IXTable source, string columnName, Type type)
        {
            _source = source;

            Allocator.AllocateToSize(ref _array, 1, type);
            ColumnDetails = new ColumnDetails(columnName, type);
        }
        private TableRow GenerateHeaderFromSheet(ViewModel viewModel, ConsoleSheet currentSheet)
        {
            var row = new TableRow();
            List <TableCell> headers = new List <TableCell>();

            for (int i = currentSheet.IndexStart; i < currentSheet.IndexEnd; i++)
            {
                ColumnDetails column = currentSheet.Columns.ElementAt(i - currentSheet.IndexStart);

                var content = new List <ICellContent>();
                content.Add(
                    new BasicCellContent
                {
                    Value = column.columnName
                });
                if (_settings.displayTypes)
                {
                    content.Add(new BreakingRuleContentArea());
                    content.Add(new BasicCellContent {
                        ForegroundColor = ConsoleColor.Blue, Value = column.type.ToString()
                    });
                }
                headers.Add(new BasicTableCell
                {
                    ContentAreas = content.ToArray()
                });
            }
            row.Cells = headers.ToArray();
            return(row);
        }
Example #9
0
        /// <summary>
        ///  Change the type of a column to a new type. Values are copied from the existing
        ///  column to the new one, if value conversion is possible.
        /// </summary>
        /// <param name="details">Details with existing name and new other details</param>
        public void AlterColumn(ColumnDetails details)
        {
            if (details == null)
            {
                throw new ArgumentNullException("details");
            }

            if (!this.Columns.ContainsKey(details.Name))
            {
                throw new ArribaException(StringExtensions.Format("Column '{0}' does not exist; it can't be altered.", details.Name));
            }

            // Get the old column and build the new one
            IUntypedColumn currentcolumn     = this.Columns[details.Name];
            IUntypedColumn replacementColumn = ColumnFactory.Build(details, currentcolumn.Count);

            // Size the new column and copy each value to it
            ushort count = this.Count;

            replacementColumn.SetSize(count);
            for (ushort i = 0; i < count; ++i)
            {
                replacementColumn[i] = currentcolumn[i];
            }

            // Store the new column
            this.Columns[details.Name]         = replacementColumn;
            this.DetailsByColumn[details.Name] = details;
        }
Example #10
0
        /// <summary>
        ///  Add a new column with the given details. Columns must be added before values can be set on them.
        /// </summary>
        /// <param name="details">Details of the column to add</param>
        /// <param name="initialCapacity">suggested initial capacity of the column</param>
        public void AddColumn(ColumnDetails details, ushort initialCapacity)
        {
            if (details == null)
            {
                throw new ArgumentNullException("details");
            }

            if (this.Columns.ContainsKey(details.Name))
            {
                if (!this.DetailsByColumn[details.Name].Type.Equals(details.Type))
                {
                    AlterColumn(details);
                    return;
                }

                // If the column exists and type matches, we can only update side details (alias)
                this.DetailsByColumn[details.Name] = details;
            }
            else
            {
                if (details.IsPrimaryKey)
                {
                    ColumnDetails idColumnDetails = this.IDColumn;
                    if (idColumnDetails != null)
                    {
                        throw new ArribaException(StringExtensions.Format("Column '{0}' to be added is marked as the primary key but cannot be added because column '{1}' is already the primary key column.", details.Name, idColumnDetails.Name));
                    }
                }

                IUntypedColumn newColumn = ColumnFactory.Build(details, initialCapacity);
                this.Columns[details.Name]         = newColumn;
                this.DetailsByColumn[details.Name] = details;
                newColumn.SetSize(_itemCount);
            }
        }
        void ReleaseDesignerOutlets()
        {
            if (ButtonCapture != null)
            {
                ButtonCapture.Dispose();
                ButtonCapture = null;
            }

            if (ButtonClearEvents != null)
            {
                ButtonClearEvents.Dispose();
                ButtonClearEvents = null;
            }

            if (ColumnDetails != null)
            {
                ColumnDetails.Dispose();
                ColumnDetails = null;
            }

            if (ColumnEventType != null)
            {
                ColumnEventType.Dispose();
                ColumnEventType = null;
            }

            if (TableEvents != null)
            {
                TableEvents.Dispose();
                TableEvents = null;
            }
        }
Example #12
0
        private void BuildWriters()
        {
            // Delete the previous table (if any) only once we've successfully gotten some rows to write
            _xDatabaseContext.StreamProvider.Delete(_tableRootPath);

            int columnCount = _source.Columns.Count;

            _writers = new IColumnWriter[columnCount];

            for (int i = 0; i < columnCount; ++i)
            {
                ColumnDetails column     = _source.Columns[i].ColumnDetails;
                string        columnPath = Path.Combine(_tableRootPath, column.Name);

                // Build a writer for each column
                _writers[i] = TypeProviderFactory.TryGetColumnWriter(_xDatabaseContext.StreamProvider, column.Type, columnPath);
                if (_writers[i] == null)
                {
                    throw new ArgumentException($"No writer or String8 converter for {column.Type.Name} was available. Could not build column writer.");
                }

                // If the column was converted to String8, write String8 in the schema
                if (column.Type != typeof(String8) && _writers[i].WritingAsType == typeof(String8))
                {
                    column = column.ChangeType(typeof(String8));
                }

                _metadata.Schema.Add(column);
            }
        }
Example #13
0
 protected MappingGenerator(ApplicationPreferences applicationPreferences, ColumnDetails columnDetails)
     : base(applicationPreferences.FolderPath, applicationPreferences.TableName, applicationPreferences.NameSpace, applicationPreferences.AssemblyName, applicationPreferences.Sequence, columnDetails)
 {
     this.applicationPreferences = applicationPreferences;
     IsAssigned = applicationPreferences.PrimaryKeyType == PrimaryKeyType.Assigned;
     this._tableReferences = applicationPreferences.TableReferences;
 }
Example #14
0
        public JsonResult GetTableExplanations(double tableID)
        {
            IGumruk _iGumruk = new BSGumruk();

            int tblID = (int)(tableID / 0.123123);

            List <d_b_table_explanation> listExps = _iGumruk.GetTableExplanationsByTableID(tblID);

            List <ColumnDetails> response = new List <ColumnDetails>();

            foreach (var item in listExps)
            {
                ColumnDetails clmDetails = new ColumnDetails()
                {
                    Date        = item.created_at.ToString(),
                    explanation = item.details,
                    User        = item.users.name,
                    ExpID       = item.id
                };

                response.Add(clmDetails);
            }

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
 private SimpleTransformFunction(string name, IXColumn column, Func <T, U> function, Action beforeBatch = null)
 {
     _name              = name;
     _column            = column;
     _function          = function;
     _beforeBatch       = beforeBatch;
     this.ColumnDetails = column.ColumnDetails.ChangeType(typeof(U));
 }
Example #16
0
        public ConcatenatingColumn(IXTable table, ColumnDetails columnDetails)
        {
            _table   = table;
            _sources = new List <IXColumn>();

            ColumnDetails = columnDetails;
            Allocator.AllocateToSize(ref _nullArray, 1, columnDetails.Type);
        }
Example #17
0
 public CodeGenerator(ApplicationPreferences applicationPreferences, ColumnDetails columnDetails)
     : base(applicationPreferences.FolderPath, applicationPreferences.TableName, applicationPreferences.NameSpace,
         applicationPreferences.AssemblyName, applicationPreferences.Sequence, columnDetails)
 {
     this.applicationPreferences = applicationPreferences;
     language = applicationPreferences.Language;
     this.tableReferences = applicationPreferences.TableReferences;
 }
Example #18
0
        public void Partition_RoundTrip()
        {
            Partition p = new Partition(PartitionMask.All);

            AddSampleData(p);

            // Round-Trip and re-verify
            Partition p2 = new Partition(PartitionMask.All);

            using (SerializationContext context = new SerializationContext(new MemoryStream()))
            {
                p.WriteBinary(context);
                context.Stream.Seek(0, SeekOrigin.Begin);
                p2.ReadBinary(context);
            }

            // Verify all columns came back
            Assert.AreEqual(String.Join(", ", p.ColumnNames), String.Join(", ", p2.ColumnNames));

            // Select top 3 bugs with Priority = 3 and [ID] <= 12000, order by [ID]
            SelectQuery query = new SelectQuery();

            query.Columns = new string[] { "ID", "Priority" };
            query.Count   = 3;
            query.Where   = SelectQuery.ParseWhere("Priority = 3 AND [ID] <= 12000");
            SelectResult result = p2.Query(query);

            Assert.AreEqual(2, (int)result.Total);
            Assert.AreEqual("11999", result.Values[0, 0].ToString());
            Assert.AreEqual("11643", result.Values[1, 0].ToString());

            // Verify column details are consistent
            foreach (ColumnDetails cd in p.ColumnDetails)
            {
                ColumnDetails cd2 = p2.DetailsByColumn[cd.Name];
                Assert.AreEqual(cd2.Name, cd.Name);
                Assert.AreEqual(cd2.Type, cd.Type);
                Assert.AreEqual(cd2.Alias, cd.Alias);
                Assert.AreEqual(cd2.IsPrimaryKey, cd.IsPrimaryKey);

                // Verify default values - defaults are serialized as string and null/empty aren't distinguishable, so we have to compare that way as well
                Assert.AreEqual((cd2.Default ?? String.Empty).ToString(), (cd.Default ?? String.Empty).ToString());
            }

            // Verify columns themselves and raw data are consistent
            foreach (IUntypedColumn c in p.Columns.Values)
            {
                IUntypedColumn c2 = p2.Columns[c.Name];
                Assert.AreEqual(c2.Name, c.Name);
                Assert.AreEqual(c2.Count, c.Count);
                Assert.AreEqual(c2.DefaultValue, c.DefaultValue);

                for (ushort i = 0; i < c.Count; ++i)
                {
                    Assert.AreEqual(c2[i], c[i]);
                }
            }
        }
Example #19
0
 protected AbstractGenerator(string filePath, string tableName, string nameSpace, string assemblyName, string sequenceName, ColumnDetails columnDetails)
 {
     this.filePath = filePath;
     this.tableName = tableName;
     this.nameSpace = nameSpace;
     this.assemblyName = assemblyName;
     this.sequenceName = sequenceName;
     this.columnDetails = columnDetails;
 }
 private BlockTwoArgumentFunction(string name, Type returnType, IXColumn column1, IXColumn column2, Func <XArray, XArray, XArray> function, Action beforeBatch = null)
 {
     _name              = name;
     _column1           = column1;
     _column2           = column2;
     _function          = function;
     _beforeBatch       = beforeBatch;
     this.ColumnDetails = new ColumnDetails(name, returnType);
 }
 private SimpleTwoArgumentFunction(string name, IXColumn column1, IXColumn column2, Func <T, U, V> function, Action beforeBatch = null)
 {
     _name              = name;
     _column1           = column1;
     _column2           = column2;
     _function          = function;
     _beforeBatch       = beforeBatch;
     this.ColumnDetails = new ColumnDetails(name, typeof(V));
 }
        public IdxToEdtConversionService(StandardMapping standardMapping)
        {
            _standardMapping = standardMapping;

            if (!_standardMapping.IsEmailField())
            {
                _edtColumnDetails = GetEdtColumnDetailsFromDisplayName(standardMapping.EdtName);
            }
        }
    public List <ColumnDetails> ColumnDetails(string TableName, string Schema = "dbo", bool CheckDuplicates = false)
    {
        if (TableName.Contains("."))
        {
            Schema    = TableName.Split('.')[0];
            TableName = TableName.Split('.')[1];
        }

        List <ColumnDetails> details = new List <ColumnDetails>();

        foreach (DataRow r in GetDataTable("select K.ORDINAL_POSITION as [Key], COLUMNPROPERTY(object_id(C.TABLE_SCHEMA + '.' + C.TABLE_NAME), C.COLUMN_NAME, 'IsIdentity') as [IDENTITY], C.COLUMN_NAME, C.DATA_TYPE, C.IS_NULLABLE, OBJECTPROPERTY(OBJECT_ID(CONSTRAINT_SCHEMA + '.' + CONSTRAINT_NAME), 'IsPrimaryKey') as [IS_PK] " +
                                           " from INFORMATION_SCHEMA.COLUMNS C " +
                                           " left join information_schema.key_column_usage K on K.Table_name = C.Table_Name and K.Table_Schema = C.Table_Schema and K.Column_Name = C.Column_Name " +
                                           " where C.TABLE_NAME = @tableName and C.TABLE_SCHEMA = @schema ",
                                           new SortedDictionary <string, object>()
        {
            { "@tableName", TableName },
            { "@schema", Schema }
        }
                                           ).Rows)
        {
            var column = new ColumnDetails()
            {
                Key           = (r["KEY"] != DBNull.Value && (int)r["key"] > 0),
                DataType      = r["DATA_TYPE"].ToString(),
                Name          = r["COLUMN_NAME"].ToString(),
                isNullable    = r["IS_NULLABLE"].ToString() == "YES",
                autoincrement = (r["IDENTITY"] != DBNull.Value && r["IDENTITY"].ToString() == "1"),
                hasDuplicates = false,
                IsPk          = Convert.ToBoolean(r["IS_PK"] == DBNull.Value ? false : r["IS_PK"])
            };

            if (CheckDuplicates)
            {
                // case sensitive grouping for text fields
                object dups;
                if (column.DataType.ToLower().Contains("char") || column.DataType.ToLower().Contains("text"))
                {
                    dups = ExecuteScalar("select top 1 [" + column.Name +
                                         "] COLLATE SQL_Latin1_General_CP1_CS_AS from [" + Schema + "].[" + TableName + "]  group by [" + column.Name +
                                         "] COLLATE SQL_Latin1_General_CP1_CS_AS having count([" + column.Name + "]) > 1");
                }
                else
                {
                    dups = ExecuteScalar("select top 1 [" + column.Name +
                                         "] from [" + Schema + "].[" + TableName + "]  group by [" + column.Name +
                                         "] having count([" + column.Name + "]) > 1");
                }
                column.hasDuplicates = dups != null && dups != DBNull.Value;
            }

            details.Add(column);
        }

        return(details);
    }
Example #24
0
        private CastedColumn(IXColumn column, Type targetType, ValueKinds errorOnKinds = ValueKindsDefaults.ErrorOn, object defaultValue = null, ValueKinds changeToDefaultKinds = ValueKindsDefaults.ChangeToDefault)
        {
            _column       = column;
            ColumnDetails = column.ColumnDetails.ChangeType(targetType);
            _converter    = TypeConverterFactory.GetConverter(column.ColumnDetails.Type, targetType, errorOnKinds, defaultValue, changeToDefaultKinds);

            _targetType           = targetType;
            _errorOnKinds         = errorOnKinds;
            _defaultValue         = defaultValue;
            _changeToDefaultKinds = changeToDefaultKinds;
        }
Example #25
0
        public ConstantColumn(IXTable source, object value, Type type, bool wasUnwrappedLiteral = false)
        {
            Source = source;

            Allocator.AllocateToSize(ref _array, 1, type);
            _array.SetValue(value, 0);

            IsNull  = (value == null || value.Equals("null"));
            _xArray = (IsNull ? XArray.Null(_array, 1) : XArray.Single(_array, 1));

            WasUnwrappedLiteral = wasUnwrappedLiteral;
            ColumnDetails       = new ColumnDetails(string.Empty, type);
        }
Example #26
0
        private void DrawLine(DisplayTable displayTable, ViewPort viewPort, bool drawRefs = false)
        {
            consoleOutputter.Write(cellDivider);
            for (int c = 0; c < displayTable.Header.Cells.Length; c++)
            {
                TableCell     column  = displayTable.Header.Cells[c];
                ColumnDetails details = displayTable.ColumnDetails[c];

                int columnNameLength = c.ToString().Length;
                if (IsOverlyLargeColumn(details, viewPort))
                {
                    for (int i = 0; i < ((viewPort.Width - (verticalSeparator.Length * 2) - Environment.NewLine.Length) / 2) - (columnNameLength / 2); i++)
                    {
                        consoleOutputter.Write(horizontalSeparator);
                    }
                    if (drawRefs)
                    {
                        consoleOutputter.Write(c.ToString());
                    }
                    else
                    {
                        consoleOutputter.Write(horizontalSeparator);
                    }
                    for (int i = 0; i < ((viewPort.Width - (verticalSeparator.Length * 2) - Environment.NewLine.Length) / 2) - (columnNameLength / 2) - ((columnNameLength + 1) % 2); i++)
                    {
                        consoleOutputter.Write(horizontalSeparator);
                    }
                }
                else
                {
                    for (int i = 0; i < (details.columnWidth / 2) - (c.ToString().Length / 2); i++)
                    {
                        consoleOutputter.Write(horizontalSeparator);
                    }
                    if (drawRefs)
                    {
                        consoleOutputter.Write(c.ToString());
                    }
                    else
                    {
                        consoleOutputter.Write(horizontalSeparator);
                    }
                    for (int i = 0; i < (details.columnWidth / 2) - (c.ToString().Length / 2) - ((details.columnWidth + 1) % 2); i++)
                    {
                        consoleOutputter.Write(horizontalSeparator);
                    }
                }
                consoleOutputter.Write(cellDivider);
            }
            consoleOutputter.Write(Environment.NewLine);
        }
        public ApplicationController(NMG.Core.ApplicationPreferences applicationPreferences, ColumnDetails columnDetails)
        {
            applicationPreferences.FolderPath = AddSlashToFolderPath(applicationPreferences.FolderPath);
            codeGenerator = new CodeGenerator(applicationPreferences, columnDetails);

            if (applicationPreferences.ServerType == ServerType.Oracle)
            {
                mappingGenerator = new OracleMappingGenerator(applicationPreferences, columnDetails);
            }
            else
            {
                mappingGenerator = new SqlMappingGenerator(applicationPreferences, columnDetails);
            }
        }
Example #28
0
        /// <summary>
        ///  Construct a column given a TypeDescriptor. The column contains the base type
        ///  and may be wrapped in other columns which add additional functionality
        ///  (sorting, indexing, deduping).
        ///
        ///  Descriptor Syntax: (WrapperType ('[' WrapperDescriptor ']')? ':')* BaseType
        ///    "int"
        ///    "Indexed:Sorted:string"
        ///    "Indexed[HtmlSplitter]:Sorted:string"
        ///
        ///  Use "bare:type" to request only the base column. Ex: "bare:string"
        /// </summary>
        /// <param name="details">Name of column to create</param>
        /// <param name="initialCapacity">Initial storage capacity of the column; use to avoid resizes if the item count is known</param>
        /// <returns>IColumn of requested type</returns>
        internal static IUntypedColumn Build(ColumnDetails details, ushort initialCapacity)
        {
            string[] columnComponents = details.Type.ToLowerInvariant().Split(':');
            string   coreType         = columnComponents[columnComponents.Length - 1];

            COLUMN_CREATOR creatorFunc = null;

            if (s_columnCreators.TryGetValue(coreType, out creatorFunc) == false)
            {
                throw new ArribaException(StringExtensions.Format("Column Type '{0}' is not currently supported.", coreType));
            }

            return(creatorFunc(details, columnComponents, initialCapacity));
        }
Example #29
0
        public CoalesceTransformFunction(IXTable source, XDatabaseContext context)
        {
            while (context.Parser.HasAnotherArgument)
            {
                IXColumn column = context.Parser.NextColumn(source, context);
                _columns.Add(column);
            }

            ValidateAllTypesMatch(_columns);
            IXColumn firstColumn = _columns[0];

            IndicesType   = firstColumn.IndicesType;
            ColumnDetails = new ColumnDetails(nameof(Coalesce), firstColumn.ColumnDetails.Type);
            _coalescer    = (ICoalescer)Allocator.ConstructGenericOf(typeof(Coalescer <>), firstColumn.ColumnDetails.Type);
        }
Example #30
0
        private void WriteValues(ViewModel viewModel, bool displayNulls)
        {
            for (int i = 0; i < viewModel.Rows.Count; i++)
            {
                object[] row = viewModel.Rows.ElementAt(i);
                Console.Write(verticalSeparator);
                for (int j = 0; j < viewModel.Columns.Count(); j++)
                {
                    ColumnDetails header = viewModel.Columns.ElementAt(j);

                    Console.Write(header.GetFormattedValue(row[j], new ViewPort(), displayNulls, verticalSeparator));
                    Console.Write(verticalSeparator);
                }
                Console.WriteLine();
            }
        }
Example #31
0
        private void ColumnsDataTable_ColumnChanged(object sender, DataColumnChangeEventArgs e)
        {
            var currentRowData = new ColumnDetails()
            {
                id              = e.Row.Field <int>("Id"),
                TableId         = e.Row.Field <int>("TableId"),
                Name            = e.Row.Field <string>("ColumnName"),
                Title           = e.Row.Field <string>("ColumnHeaderText"),
                Visible         = e.Row.Field <bool>("Visible"),
                OrdinalPosition = e.Row.Field <int>("OrdinalPosition")
            };

            if (!_columnOperations.UpdateColumn(currentRowData))
            {
                MessageBox.Show($"Update failed{Environment.NewLine}{_columnOperations.LastExceptionMessage}");
            }
        }
Example #32
0
        /// <summary>
        ///  Construct a DataBlock with a given set of column names and
        ///  the pre-built arrays for each row. [NOT EFFICIENT]
        /// </summary>
        /// <param name="columnNames">Names of columns in block</param>
        /// <param name="rowCount">Number of rows in block</param>
        public DataBlock(IEnumerable <string> columnNames, Array rows) :
            this(ColumnDetails.FromNames(columnNames), (rows == null ? 0 : rows.GetLength(0)))
        {
            if (rows == null)
            {
                throw new ArgumentNullException("rows");
            }

            for (int i = 0; i < this.RowCount; ++i)
            {
                Array rowArray = (Array)rows.GetValue(i);
                if (rowArray == null)
                {
                    throw new ArgumentNullException(String.Format("rows[{0}]", i));
                }
                this.SetRow(i, rowArray);
            }
        }
Example #33
0
        /// <summary>
        ///  Add a new column with the given type descriptor and default.
        ///  Columns must be added before values can be set on them.
        /// </summary>
        /// <param name="details">Details of the column to add</param>
        public void AddColumn(ColumnDetails details, ushort initialCapacity)
        {
            _locker.EnterWriteLock();
            try
            {
                foreach (Partition p in _partitions)
                {
                    p.AddColumn(details, initialCapacity);
                }

                // Reset column alias mappings
                _columnAliasCorrector.SetMappings(this);
            }
            finally
            {
                _locker.ExitWriteLock();
            }
        }
Example #34
0
        public RepeatingArrayTable WithColumn(ColumnDetails details, XArray fullColumn)
        {
            if (fullColumn.Count != _arrayRowCount)
            {
                throw new ArgumentException($"All columns passed to ArrayReader must have the configured row count. The configured row count is {_rowCount:n0}; this column has {fullColumn.Count:n0} rows.");
            }

            for (int i = 0; i < _columns.Count; ++i)
            {
                if (_columns[i].ColumnDetails.Name.Equals(details.Name, StringComparison.OrdinalIgnoreCase))
                {
                    throw new ArgumentException($"Can't add duplicate column. ArrayReader already has a column {details.Name}.");
                }
            }

            _columns.Add(new ArrayColumn(fullColumn, details));
            return(this);
        }
Example #35
0
 public SqlMappingGenerator(ApplicationPreferences applicationPreferences, ColumnDetails columnDetails)
     : base(applicationPreferences, columnDetails)
 {
 }
Example #36
0
 private void Generate(string tableName, ColumnDetails columnDetails)
 {
     var applicationPreferences = GetApplicationPreferences(tableName);
     var applicationController = new ApplicationController(applicationPreferences, columnDetails);
     applicationController.Generate();
 }
Example #37
0
        public ColumnDetails GetTableDetails(string selectedTableName)
        {
            var columnDetails = new ColumnDetails();
            var conn = new OracleConnection(connectionStr);
            conn.Open();
            using (conn)
            {
                using (var tableCommand = conn.CreateCommand())
                {
                    tableCommand.CommandText = "select column_name, data_type, data_length, data_precision, data_scale, nullable from user_tab_cols where table_name = '" + selectedTableName + "'";
                    using (var oracleDataReader = tableCommand.ExecuteReader(CommandBehavior.Default))
                    {
                        while (oracleDataReader.Read())
                        {
                            var columnName = oracleDataReader.GetString(0);
                            var dataType = oracleDataReader.GetString(1);
                            int dataLength = 0;
                            int dataPrecision = 0;
                            int dataScale = 0;
                            string isNullableStr = "N";
                            try
                            {
                                dataLength = oracleDataReader.GetInt32(2);
                                dataPrecision = oracleDataReader.GetInt32(3);
                                dataScale = oracleDataReader.GetInt32(4);
                                isNullableStr = oracleDataReader.GetString(5);
                            }
                            catch (InvalidOperationException)
                            {

                            }
                            bool isNullable = false;
                            if (isNullableStr.Equals("Y", StringComparison.CurrentCultureIgnoreCase))
                            {
                                isNullable = true;
                            }
                            columnDetails.Add(new ColumnDetail(columnName, dataType, dataLength, dataPrecision, dataScale, isNullable));
                        }
                    }
                }
                using(var constraintCommand = conn.CreateCommand())
                {
                    constraintCommand.CommandText = "select constraint_name from user_constraints where table_name = '" + selectedTableName + "' and constraint_type = 'P'";
                    var value = constraintCommand.ExecuteOracleScalar();
                    if (value != null)
                    {
                        var constraintName = (OracleString) value;
                        using(var pkColumnCommand = conn.CreateCommand())
                        {
                            pkColumnCommand.CommandText = "select column_name from user_cons_columns where table_name = '" + selectedTableName+ "' and constraint_name = '"+ constraintName.Value +"'";
                            var colNames = pkColumnCommand.ExecuteReader();
                            //var colName = pkColumnCommand.ExecuteOracleScalar();

                            if (colNames.HasRows)
                            {

                                while (colNames.Read())
                                {
                                    var pkColumnName = (OracleString)colNames.GetOracleValue(0);
                                    var columnDetail = columnDetails.Find(detail => detail.ColumnName.Equals(pkColumnName.Value));
                                    columnDetail.IsPrimaryKey = true;
                                }
                            }
                        }
                    }
                }
            }
            columnDetails.Sort((x, y) => x.ColumnName.CompareTo(y.ColumnName));
            return columnDetails;
        }
        public ColumnDetails GetTableDetails(string selectedTableName)
        {
            var columnDetails = new ColumnDetails();
            var conn = new SqlConnection(connectionStr);
            conn.Open();
            using (conn)
            {
                using (var tableDetailsCommand = conn.CreateCommand())
                {
                    tableDetailsCommand.CommandText = "select column_name, data_type, character_maximum_length, NUMERIC_PRECISION, NUMERIC_PRECISION_RADIX, NUMERIC_SCALE, IS_NULLABLE from information_schema.columns where table_name = '" + selectedTableName + "'";
                    using (var sqlDataReader = tableDetailsCommand.ExecuteReader(CommandBehavior.Default))
                    {
                        if (sqlDataReader != null)
                        {
                            while (sqlDataReader.Read())
                            {
                                var columnName = sqlDataReader.GetString(0);
                                var dataType = sqlDataReader.GetString(1);
                                int dataLength = 0;
                                int dataPrecision = 0;
                                int dataScale = 0;
                                bool isNullable = false;
                                try
                                {
                                    dataLength = sqlDataReader.GetInt32(2);
                                    dataPrecision = sqlDataReader.GetInt32(3);
                                    dataScale = sqlDataReader.GetInt32(4);
                                    isNullable = sqlDataReader.GetBoolean(5);
                                }catch (Exception)
                                {

                                }

                                columnDetails.Add(new ColumnDetail(columnName, dataType, dataLength, dataPrecision, dataScale, isNullable));
                            }
                        }
                    }
                }

                using (var constraintCommand = conn.CreateCommand())
                {
                    constraintCommand.CommandText = "select constraint_name from information_schema.TABLE_CONSTRAINTS where table_name = '" + selectedTableName + "' and constraint_type = 'PRIMARY KEY'";
                    var value = constraintCommand.ExecuteScalar();
                    if (value != null)
                    {
                        var constraintName = (string)value;
                        using (var pkColumnCommand = conn.CreateCommand())
                        {
                            pkColumnCommand.CommandText = "select column_name from information_schema.CONSTRAINT_COLUMN_USAGE where table_name = '" + selectedTableName + "' and constraint_name = '" + constraintName + "'";
                            var colName = pkColumnCommand.ExecuteScalar();
                            if (colName != null)
                            {
                                var pkColumnName = (string)colName;
                                var columnDetail = columnDetails.Find(detail => detail.ColumnName.Equals(pkColumnName));
                                columnDetail.IsPrimaryKey = true;
                            }
                        }
                    }
                }
            }
            columnDetails.Sort((x, y) => x.ColumnName.CompareTo(y.ColumnName));
            return columnDetails;
        }