コード例 #1
0
        public void Delete(Dictionary <string, object> dictFieldsVals)
        {
            string commandText = "Delete from " + this.TableName + " Where ";

            SqlParameter[] parameters = new SqlParameter[dictFieldsVals.Count];
            int            index      = 0;

            foreach (string field_name in dictFieldsVals.Keys)
            {
                parameters.SetValue(new SqlParameter(field_name, dictFieldsVals[field_name]), index);
                commandText += field_name + " = @" + parameters[index].ParameterName + " AND ";
                index++;
            }
            commandText = commandText.Substring(0, commandText.Length - 4);
            db.ExecuteDataset(commandText, parameters);
            try
            {
                if (TableName.Equals("act"))
                {
                    //object app_date = this.Columns["approval_date"];
                    //object pvpk = this.Columns["pvFK"];
                }
            }
            catch (Exception ex)
            {
                ;
            }
        }
コード例 #2
0
        private void InsertOneToOnes(List <string> hierarchyList, List <TableJoin> oneToOneList)
        {
            // Insert each child of a one-to-one directly after its parent in the
            // hierarchy list.

            foreach (TableJoin OneToOneJoin in oneToOneList)
            {
                // Index of current element in hierarchyList
                int i = 0;

                // Have we found the 'from' table for the this one to one join?
                bool FromFound = false;

                foreach (string TableName in hierarchyList)
                {
                    if (TableName.Equals(OneToOneJoin.FromTable))
                    {
                        FromFound = true;
                        break;
                    }
                    else
                    {
                        i++;
                    }
                }

                // Insert to table name directly after its from table.
                if (FromFound)
                {
                    hierarchyList.Insert(i + 1, OneToOneJoin.ToTable);
                }
            }
        }
コード例 #3
0
ファイル: LoadAppLogic.cs プロジェクト: hugohenley/E-Science
        /// <summary>
        /// Check if the correct list of files/table names are present in this batch
        /// </summary>
        /// <param name="FileEntries"></param>
        /// <returns></returns>
        public static bool IsMatchCSVFileTables(List <CSVFileEntry> FileEntries)
        {
            // check if the file count and the expected number of tables match
            if (LoadConstants.EXPECTED_TABLES.Count != FileEntries.Count)
            {
                return(false);
            }

            // for each expected table name, check if it is present in the list of file entries
            foreach (string TableName in LoadConstants.EXPECTED_TABLES)
            {
                bool TableExists = false;
                foreach (CSVFileEntry FileEntry in FileEntries)
                {
                    if (!TableName.Equals(FileEntry.TargetTable))
                    {
                        continue;
                    }
                    TableExists = true; // found a match
                    break;
                }
                // if the table name did not exist in list of CSV files, this check fails.
                if (!TableExists)
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #4
0
ファイル: PgTrigger.cs プロジェクト: hryz/apgdiff.net
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }

            if (obj is PgTrigger trigger)
            {
                var equals = Before == trigger.Before &&
                             ForEachRow == trigger.ForEachRow &&
                             Function.Equals(trigger.Function) &&
                             Name.Equals(trigger.Name) &&
                             OnDelete == trigger.OnDelete &&
                             OnInsert == trigger.OnInsert &&
                             OnUpdate == trigger.OnUpdate &&
                             OnTruncate == trigger.OnTruncate &&
                             TableName.Equals(trigger.TableName);

                if (!equals)
                {
                    return(false);
                }

                return((UpdateColumns.Count == 0 && trigger.UpdateColumns.Count == 0) ||
                       UpdateColumns.All(t1 => trigger.UpdateColumns.Any(t1.EqualsIgnoreCase)));
            }

            return(false);
        }
コード例 #5
0
        internal void ConfigurePropertyMappings(
            IList <Tuple <ColumnMappingBuilder, EntityType> > propertyMappings,
            DbProviderManifest providerManifest,
            bool allowOverride = false)
        {
            DebugCheck.NotNull(propertyMappings);
            DebugCheck.NotNull(providerManifest);

            foreach (var configuration in _primitivePropertyConfigurations)
            {
                var propertyPath          = configuration.Key;
                var propertyConfiguration = configuration.Value;

                propertyConfiguration.Configure(
                    propertyMappings.Where(
                        pm =>
                        propertyPath.Equals(
                            new PropertyPath(
                                pm.Item1.PropertyPath
                                .Skip(pm.Item1.PropertyPath.Count - propertyPath.Count)
                                .Select(p => p.GetClrPropertyInfo()))
                            ) &&
                        TableName.Equals(pm.Item2.GetTableName())),
                    providerManifest,
                    allowOverride,
                    fillFromExistingConfiguration: true);
            }
        }
コード例 #6
0
 private void OnCommit(TableCommitInfo commitInfo)
 {
     if (TableName.Equals(commitInfo.TableName))
     {
         addedList.AddRange(commitInfo.AddedRows);
         removedList.AddRange(commitInfo.RemovedRows);
     }
 }
コード例 #7
0
        public bool CanFire(TableEvent tableEvent)
        {
            if (!TableName.Equals(tableEvent.Table.TableInfo.TableName))
            {
                return(false);
            }

            return(MatchesEvent(tableEvent.EventTime, tableEvent.EventType));
        }
コード例 #8
0
ファイル: UserContextTable.cs プロジェクト: meikeric/deveeldb
        protected override IEnumerable <int> ResolveRows(int column, IEnumerable <int> rowSet, ITable ancestor)
        {
            if (!TableName.Equals(ancestor.TableInfo.TableName) &&
                !ancestor.TableInfo.TableName.Equals(Table.TableInfo.TableName))
            {
                throw new Exception("Method routed to incorrect table ancestor.");
            }

            return(rowSet);
        }
コード例 #9
0
 /// <summary>The services system message posted.</summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The e.</param>
 private void ServicesSystemMessagePosted(object sender, SystemMessageEventArgs e)
 {
     if (e.Message == SystemMessage.TableTruncated)
     {
         if (AutoReload && TableName.Equals(e.Data))
         {
             LoadTableData();
         }
     }
 }
コード例 #10
0
 IEnumerable <Dimension> GetTableDimensions()
 {
     if (_xlsx.MultiTableWorkbook)
     {
         return(from d in _xlsx.Dimensions
                where TableName.Equals(d.Sheet, System.StringComparison.OrdinalIgnoreCase)
                select d);
     }
     return(from d in _xlsx.Dimensions
            select d);
 }
コード例 #11
0
ファイル: IDConversion.cs プロジェクト: dhq-boiler/Sunctum
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(this, obj))
            {
                return(true);
            }
            var other = obj as IDConversion;

            return(TableName.Equals(other.TableName) &&
                   DomesticID.Equals(other.DomesticID) &&
                   ForeignID.Equals(other.ForeignID));
        }
コード例 #12
0
        public override string ToString()
        {
            //select
            StringBuilder query = new StringBuilder("SELECT");

            if (top.HasValue)
            {
                query.Append($" TOP {top}");
            }

            if (TableColumns.Count > 0)
            {
                var columnNames = TableColumns.Select(c => c.ToString()).ToList();
                var columns     = string.Join(", ", columnNames.ToArray());
                query.Append($" {columns}");
            }

            //from
            if (TableName != null && !TableName.Equals(string.Empty))
            {
                query.Append($" FROM {TableName}");
            }

            //join
            for (int i = 0; i < joinTables.Count; i++)
            {
                query.Append($" {joinTables[i]}");
                query.Append($" ON {joinConditions[i]}");
            }

            //where
            if (Conditions.Count > 0)
            {
                var conditions = string.Join(" ", Conditions.ToArray());
                query.Append($" {conditions}");
            }

            //group by

            //having

            //order by
            if (orderByColumns.Count > 0)
            {
                var columns = orderByColumns.Select(c => c.ToString()).ToList();
                var orderBy = string.Join(", ", columns);
                query.Append($" ORDER BY {orderBy}");
            }

            return(query.ToString());
        }
コード例 #13
0
ファイル: GlobalCacheManager.cs プロジェクト: e2wugui/zeze
            public override bool Equals(object obj)
            {
                if (this == obj)
                {
                    return(true);
                }

                if (obj is GlobalTableKey another)
                {
                    return(TableName.Equals(another.TableName) && ByteBuffer.Equals(Key, another.Key));
                }

                return(false);
            }
コード例 #14
0
ファイル: IndexSet.cs プロジェクト: VijayMVC/index-comparer
        public bool Equals(IndexSet other)
        {
            if (Object.ReferenceEquals(other, null))
            {
                return(false);
            }
            if (Object.ReferenceEquals(this, other))
            {
                return(true);
            }

            return(SchemaName.Equals(other.SchemaName) && TableName.Equals(other.TableName) &&
                   IndexName.Equals(other.IndexName));
        }
コード例 #15
0
ファイル: Table.cs プロジェクト: IM-SQL/IMSQL
        public int IndexOfColumn(string[] columnName)
        {
            if (columnName.Length > 2)
            {
                throw new NotImplementedException();
            }
            if (columnName.Length == 2)
            {
                if (!TableName.Equals(columnName[0], StringComparison.InvariantCultureIgnoreCase))
                {
                    return(-1);
                }
            }

            return(columns.FindIndex(col => Equals(columnName.Last(), col.ColumnName)));
        }
コード例 #16
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            TableInfo dest = (TableInfo)obj;

            if (this.TableName == null || dest.TableName == null)
            {
                return(this.TableName == null && dest.TableName == null);
            }

            return(TableName.Equals(dest.TableName, StringComparison.CurrentCultureIgnoreCase));
        }
コード例 #17
0
        public override bool Equals(object obj)
        {
            var equals = false;

            if (this == obj)
            {
                equals = true;
            }
            else if (obj is PgIndex index)
            {
                equals = Definition.Equals(index.Definition) &&
                         Name.Equals(index.Name) &&
                         TableName.Equals(index.TableName) &&
                         Unique == index.Unique;
            }

            return(equals);
        }
コード例 #18
0
ファイル: PmsSheetToolBox.cs プロジェクト: trigrass2/myreport
 void TextBoxEx_KeyPress(object sender, KeyPressEventArgs e)
 {
     //用户表密码字段输入不超过12
     if (TableName != null && TableName.Equals("s_UserInfo", StringComparison.CurrentCultureIgnoreCase) &&
         _rField.Equals("Pass", StringComparison.CurrentCultureIgnoreCase))
     {
         if (this.SelectionLength == 0)//没有选择的时候,输入
         {
             if (this.Text.Length >= 12)
             {
                 e.Handled = true;
             }
         }
     }
     if (PmsField.textBoxKeyPress(this.Text, RType, this, e.KeyChar))
     {
         e.Handled = true;
     }
 }
コード例 #19
0
        public override bool EqualsNode(
            ExprNode o,
            bool ignoreStreamPrefix)
        {
            if (this == o) {
                return true;
            }

            if (o == null || GetType() != o.GetType()) {
                return false;
            }

            var that = (ExprTableAccessNode) o;
            if (!TableName.Equals(that.TableName)) {
                return false;
            }

            return EqualsNodeInternal(that);
        }
コード例 #20
0
        public override string ToString()
        {
            StringBuilder query = new StringBuilder(Action);

            //table
            if (TableName != null && !TableName.Equals(string.Empty))
            {
                query.Append($" {TableName}");
            }

            //where
            if (Conditions.Count > 0)
            {
                var conditions = string.Join(" ", Conditions.ToArray());
                query.Append($" {conditions}");
            }

            return(query.ToString());
        }
コード例 #21
0
        /// <summary>
        /// Set the background color of the columns
        /// </summary>
        /// <param name="backColor"></param>
        /// <param name="selectionBackColor"></param>
        /// <param name="tcList"></param>
        public void SetBackColorByColumns(Color backColor, Color selectionBackColor, params TableColumn[] tcList)
        {
            if (tcList == null)
            {
                return;
            }

            // get only the columns for processing
            //string[] columns = new string[tcList.Length];
            List <string> columns = new List <string>();

            for (int i = 0; i < tcList.Length; i++)
            {
                TableColumn tc = tcList[i];

                if (!TableName.Equals(tc.TableName, StringComparison.InvariantCultureIgnoreCase))
                {
                    continue;
                }

                columns.Add(tcList[i].ColumnName.ToUpper());
            }

            columns.Sort();
            string[] colArray = columns.ToArray();
            //Array.Sort(columns);

            foreach (DataGridViewColumn col in dataGridView1.Columns)
            {
                string headerText = col.HeaderText.ToUpper();
                bool   found      = Array.BinarySearch(colArray, headerText) >= 0;
                col.DefaultCellStyle.BackColor          = (found) ? backColor : Color.White;
                col.DefaultCellStyle.SelectionBackColor = (found) ? selectionBackColor : Color.Black;
                col.Tag = found;
            }
        }
コード例 #22
0
        public override string ToString()
        {
            StringBuilder query = new StringBuilder(Action);

            if (TableName != null && !TableName.Equals(string.Empty))
            {
                query.Append($" {TableName}");
            }

            if (TableColumns.Count > 0)
            {
                var columnNames = TableColumns.Select(c => c.ToString()).ToList();
                var columns     = string.Join(", ", columnNames.ToArray());
                query.Append($" ({columns})");
            }

            if (values.Count > 0)
            {
                var values = string.Join(", ", this.values.ToArray());
                query.Append($" VALUES ({values})");
            }

            return(query.ToString());
        }
コード例 #23
0
        private SystemTable InternalGetTable(TableName tableName)
        {
            // Is it in the cache?
            SystemTable table;
            if (!tableNameMap.TryGetValue(tableName, out table)) {
                // Directory table is special case,
                if (tableName.Equals(SystemTableNames.Tables)) {
                    ITable t = state.GetTable(tableName);
                    if (t == null)
                        return null;

                    table = new SystemTable(this, t, -1);
                }
                    // Index tables are special cases
                else if (tableName.Equals(SystemTableNames.Index)) {
                    ITable t = state.GetTable(tableName);
                    if (t == null)
                        return null;

                    table = new SystemTable(this, t, -1);
                }
                    // Not a special case table,
                else {
                    // If the table is in the table id map
                    long tableId;
                    if (tableIdMap.TryGetValue(tableName, out tableId)) {
                        // Simply fetch if it is,
                        table = GetTable(tableId);
                    } else {
                        // Otherwise we need to resolve the table name to an id
                        // Discover the id for this table name from a query on the directory
                        // table.
                        // This is probably going to be a very heavy operation for what is a
                        // simple TableName to id lookup, and I think ultimately this
                        // operation will be backed by a cache.

                        // first check if we have the system TABLES table, that means
                        // we have a full setup
                        if (!TableExists(SystemTableNames.Tables)) {
                            // we have not a full setup: try to get the table
                            // directly from the state
                            ITable t = state.GetTable(tableName);
                            if (t == null)
                                return null;

                            tableId = state.CreateUniqueId(SystemTableNames.Tables);
                            table = new SystemTable(this, t, tableId);
                            tableIdMap[tableName] = tableId;
                        } else {
                            // Query the composite index
                            SystemTable tables = GetTable(SystemTableNames.Tables);
                            // Find the RowIndex that represents the set of all schema/name
                            // items in the table
                            IRowCursor i = GetNames(tables, tableName);
                            // Fail conditions
                            if (i.Count == 0)
                                return null;

                            if (i.Count > 1)
                                throw new ApplicationException("Multiple '" + tableName + "' tables.");

                            if (!i.MoveNext())
                                throw new ArgumentException();

                            // Read the result
                            RowId rowid = i.Current;
                            tableId = tables.GetValue(0, rowid);
                            string tableType = tables.GetValue(3, rowid);

                            // Fetch the table info
                            if (tableType.Equals("TABLE")) {
                                // Handle table_id overflow gracefully
                                if (tableId > Int32.MaxValue)
                                    throw new ApplicationException("table_id overflow (" + tableId + ")");

                                // Put the table id in the map
                                tableIdMap[tableName] = tableId;
                                // Fetch the table,
                                table = GetTable(tableId);
                            }

                                // Sequences
                            else if (tableType.Equals("SEQUENCE")) {
                                // NOTE, this doesn't get put on the table cache!
                                //TODO:
                            }

                                // Table primitives
                            else if (tableType.StartsWith("PRIMITIVE:")) {
                                // The name of the primitive
                                string tableOb = tableType.Substring(10);
                                if (tableOb.Equals("EmptyTable"))
                                    return SystemTable.Empty;
                                if (tableOb.Equals("OneRowTable"))
                                    return SystemTable.OneRow;
                            }

                                // Dynamically created tables created via reflection
                            else if (tableType.StartsWith("DYN:")) {
                                // A dynamic table type
                                //TODO:
                            } else {
                                throw new ApplicationException("Unknown table type: " + tableType);
                            }
                        }
                    }
                }

                tableNameMap[tableName] = table;
            }
            return table;
        }
コード例 #24
0
        internal void RebuildIndexes(TableName tableName)
        {
            if (tableName.Equals(SystemTableNames.Index) ||
                tableName.Equals(SystemTableNames.Tables)) {
                throw new ApplicationException("Cannot rebuild index on " + tableName);
            }

            // All indexes on the table,
            IIndexSetDataSource[] idxs = GetTableIndexes(tableName);
            // Rebuild each index
            foreach (IIndexSetDataSource idx in idxs) {
                RebuildIndex(tableName, idx);
            }
        }
コード例 #25
0
        internal long GetIndexId(TableName onTable, string indexName)
        {
            // Handle fetching the index definition entry specially,
            if (onTable.Equals(SystemTableNames.Index) &&
                indexName.Equals("index_composite_idx")) {
                // The index table,
                ITable indexTable = GetTable(SystemTableNames.Index);
                // Iterate until we find it (it should be found after only a few
                // iterations).
                IRowCursor cursor = indexTable.GetRowCursor();
                bool found = false;
                SqlObject indexId = null;
                while (cursor.MoveNext()) {
                    RowId rowId = cursor.Current;
                    indexId = indexTable.GetValue(0, rowId);
                    SqlObject schem = indexTable.GetValue(1, rowId);
                    SqlObject table = indexTable.GetValue(2, rowId);
                    SqlObject iname = indexTable.GetValue(3, rowId);

                    if (schem.ToString().Equals(onTable.Schema) &&
                        table.ToString().Equals(onTable.Name) &&
                        iname.ToString().Equals(indexName)) {
                        found = true;
                        break;
                    }
                }
                // If found
                return found ? indexId.ToInt64() : -1;
            } else {
                // No, so fetch it
                IIndexSetDataSource index = GetIndex(SystemTableNames.Index, "index_composite_idx");
                SqlObject val = SqlObject.CompositeString(new string[] { onTable.Schema, onTable.Name, indexName });

                // Query the index
                IRowCursor cursor = index.Select(SelectableRange.Is(val));

                // Should only be 1 value or none,
                if (cursor.Count > 1)
                    throw new ApplicationException("System index definition table invalid");

                // If no data in iterator, return null
                if (cursor.Count == 0)
                    return -1;

                // The index table,
                SystemTable indexTable = GetTable(SystemTableNames.Index);
                if (!cursor.MoveNext())
                    throw new ApplicationException();

                return indexTable.GetValue(0, cursor.Current);
            }
        }
コード例 #26
0
        internal void AddIndex(long indexId, TableName onTable, string indexName, string type, IndexCollation collation)
        {
            IMutableTable indexTable = GetTable(SystemTableNames.Index);
            TableRow row = indexTable.NewRow();
            row.SetValue(0, indexId);
            row.SetValue(1, onTable.Schema);
            row.SetValue(2, onTable.Name);
            row.SetValue(3, indexName);
            row.SetValue(4, type);
            row.SetValue(5, collation.Function);
            row.SetValue(6, collation.Type.ToString());
            row.SetValue(7, user.Name);
            indexTable.Insert(row);
            indexTable.Commit();

            RowId insertRowId = row.Id;

            IMutableTable indexColumnTable = GetTable(SystemTableNames.ColumnSet);
            for (int i = 0; i < collation.Columns.Length; i++) {
                CollationColumn column = collation.Columns[i];

                row = indexColumnTable.NewRow();
                row.SetValue(0, indexId);
                row.SetValue(1, onTable.Schema);
                row.SetValue(2, onTable.Name);
                row.SetValue(3, indexName);
                row.SetValue(4, i);
                row.SetValue(5, column.ColumnName);
                row.SetValue(6, column.Ascending);
                indexColumnTable.Insert(row);
            }

            indexColumnTable.Commit();

            // If this isn't an index on the INDEXES or TABLES tables,););););
            if (!onTable.Equals(SystemTableNames.Tables) &&
                !onTable.Equals(SystemTableNames.Index)) {
                // Update the indexes
                IIndexSetDataSource[] idxs = GetTableIndexes(SystemTableNames.Index);
                foreach (IIndexSetDataSource i in idxs) {
                    i.Insert(insertRowId);
                }
            }
        }