Пример #1
0
 /// <summary>
 /// Creates table.
 /// For internal use only.
 /// </summary>
 public virtual void CreateTable(TableDataSource source)
 {
     if (source.Table == null)
     {
         source.Table = new DataTable(source.TableName);
         DataSet.Tables.Add(source.Table);
     }
 }
Пример #2
0
 /// <inheritdoc/>
 public override void CreateTable(TableDataSource source)
 {
     if (DataSet.Tables.Contains(source.TableName))
     {
         source.Table = DataSet.Tables[source.TableName];
         base.CreateTable(source);
     }
     else
     {
         source.Table = null;
     }
 }
Пример #3
0
 /// <summary>
 /// Deletes table.
 /// For internal use only.
 /// </summary>
 public virtual void DeleteTable(TableDataSource source)
 {
     if (source.Table != null)
     {
         if (dataSet != null)
         {
             dataSet.Tables.Remove(source.Table);
         }
         source.Table.Dispose();
         source.Table = null;
     }
 }
 /// <inheritdoc/>
 public override void CreateTable(TableDataSource source)
 {
     if (DataSet.Tables.Count == 1)
     {
         source.Table = DataSet.Tables[0];
         base.CreateTable(source);
     }
     else
     {
         source.Table = null;
     }
 }
Пример #5
0
        private void PRegisterDataTable(DataTable table, string referenceName, bool enabled)
        {
            dictionary.AddRegisteredItem(table, referenceName);

            TableDataSource source = FindDataComponent(referenceName) as TableDataSource;

            if (source != null)
            {
                source.Reference = table;
                source.InitSchema();
                source.RefreshColumns(true);
                AddBaseWithChiledToDictonary(source);
            }
            else
            {
                // check tables inside connections. Are we trying to replace the connection table
                // with table provided by an application?
                source = FindByAlias(referenceName) as TableDataSource;
                // check "Data.TableName" case
                if (source == null && referenceName.StartsWith("Data."))
                {
                    source = FindByAlias(referenceName.Remove(0, 5)) as TableDataSource;
                }
                if (source != null && (source.Connection != null || source.IgnoreConnection))
                {
                    source.IgnoreConnection = true;
                    source.Reference        = table;
                    source.InitSchema();
                    source.RefreshColumns(true);
                    AddBaseWithChiledToDictonary(source);
                }
                else
                {
                    source = new TableDataSource();
                    source.ReferenceName = referenceName;
                    source.Reference     = table;
                    source.Name          = CreateUniqueName(referenceName.Contains(".") ? table.TableName : referenceName);
                    source.Alias         = CreateUniqueAlias(source.Alias);
                    source.Enabled       = enabled;
                    source.InitSchema();
                    dictionary.DataSources.Add(source);
                    AddBaseWithChiledToDictonary(source);
                }
            }
        }
Пример #6
0
        internal virtual void FillTable(TableDataSource source)
        {
            if (source.Table != null)
            {
                bool parametersChanged = false;
                foreach (CommandParameter par in source.Parameters)
                {
                    object value = par.Value;
                    if (!Object.Equals(value, par.LastValue))
                    {
                        par.LastValue     = value;
                        parametersChanged = true;
                    }
                }

                if (source.ForceLoadData || source.Table.Rows.Count == 0 || parametersChanged)
                {
                    FillTableData(source.Table, source.SelectCommand, source.Parameters);
                }
            }
        }
Пример #7
0
        internal void RegisterDataTable(DataTable table, string referenceName, bool enabled)
        {
            AddRegisteredItem(table, referenceName);

            TableDataSource source = FindDataComponent(referenceName) as TableDataSource;

            if (source != null)
            {
                source.Reference = table;
                source.InitSchema();
                source.RefreshColumns(true);
            }
            else
            {
                // check tables inside connections. Are we trying to replace the connection table
                // with table provided by an application?
                source = FindByAlias(referenceName) as TableDataSource;
                if (source != null && (source.Connection != null || source.IgnoreConnection))
                {
                    source.IgnoreConnection = true;
                    source.Reference        = table;
                    source.InitSchema();
                    source.RefreshColumns(true);
                }
                else
                {
                    source = new TableDataSource();
                    source.ReferenceName = referenceName;
                    source.Reference     = table;
                    source.Name          = CreateUniqueName(referenceName.Contains(".") ? table.TableName : referenceName);
                    source.Alias         = CreateUniqueAlias(source.Alias);
                    source.Enabled       = enabled;
                    source.InitSchema();
                    DataSources.Add(source);
                }
            }
        }
Пример #8
0
 /// <inheritdoc/>
 public override void DeleteTable(TableDataSource source)
 {
     // do nothing
 }
Пример #9
0
        /// <summary>
        /// Fills the <see cref="Tables"/> collection with all tables available in the database.
        /// </summary>
        /// <param name="initSchema">Set to <b>true</b> to initialize each table's schema.</param>
        public virtual void CreateAllTables(bool initSchema)
        {
            List <string> tableNames = new List <string>();

            tableNames.AddRange(GetTableNames());
            FilterTables(tableNames);

            // remove tables with tablename that does not exist in the connection.
            for (int i = 0; i < Tables.Count; i++)
            {
                TableDataSource table = Tables[i];
                bool            found = !String.IsNullOrEmpty(table.SelectCommand);
                // skip tables with non-empty selectcommand
                if (!found)
                {
                    foreach (string tableName in tableNames)
                    {
                        if (String.Compare(table.TableName, tableName, true) == 0)
                        {
                            found = true;
                            break;
                        }
                    }
                }
                // table name not found between actual tablenames. It may happen if we have edited the connection.
                if (!found)
                {
                    table.Dispose();
                    i--;
                }
            }

            // now create tables that are not created yet.
            foreach (string tableName in tableNames)
            {
                bool found = false;
                foreach (TableDataSource table in Tables)
                {
                    if (String.Compare(table.TableName, tableName, true) == 0)
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    TableDataSource table          = new TableDataSource();
                    string          fixedTableName = tableName.Replace(".", "_").Replace("[", "").Replace("]", "").Replace("\"", "");
                    if (Report != null)
                    {
                        table.Name  = Report.Dictionary.CreateUniqueName(fixedTableName);
                        table.Alias = Report.Dictionary.CreateUniqueAlias(table.Alias);
                    }
                    else
                    {
                        table.Name = fixedTableName;
                    }

                    table.TableName  = tableName;
                    table.Connection = this;
                    table.Enabled    = false;

                    Tables.Add(table);
                }
            }

            // init table schema
            if (initSchema)
            {
                foreach (TableDataSource table in Tables)
                {
                    table.InitSchema();
                }
            }
        }
Пример #10
0
 internal override void DeleteTable(TableDataSource source)
 {
     // do nothing
 }