public void FinishSuccess(RouteContext routeContext, SchemaMetaData schemaMetaData)
 {
     foreach (var routingHook in routingHooks)
     {
         routingHook.FinishSuccess(routeContext, schemaMetaData);
     }
 }
Пример #2
0
        /// <summary>
        /// Retrieves names of all contact custom fields from the Act! Database
        /// </summary>
        /// <returns>Array list with names of the custom fields</returns>
        /// <remarks>
        /// Getting custom contact fields
        /// This sample retrieves names of the custom contact fields and puts them into an Array list.
        /// The sample shows the following tasks:
        /// - Using the SDK to get Contact field descriptors.
        /// - Getting the table of each contact field descriptor using the TableByName property of SchemaMetadata.
        /// - If column in the table is custom (IsCustom = true), adding the field name to the Array list.
        /// </remarks>
        public /*override*/ ArrayList GetContactCustomFields()
        {
            ActFramework ACTFM = new ActFramework();

            ACTFM.LogOn("C:\\Documents and Settings\\Administrator\\My Documents\\ACT\\Act for Win 8\\Databases\\Act8Demo.pad", "Chris Huffman", "");
            SchemaMetaData    smd              = ACTFM.SchemaMetaData;
            ReadOnlyHashtable tblByName        = smd.TableByName;
            ArrayList         customFieldArray = new ArrayList();

            ContactFieldDescriptor[] cfdList = ACTFM.Contacts.GetContactFieldDescriptors();
            ContactFieldDescriptor   cfd;
            Table  tContact;
            Column col;

            for (int i = 0; i < cfdList.Length; i++)
            {
                cfd      = cfdList[i];
                tContact = (Act.Framework.MetaData.Table)tblByName[cfd.TableName];
                col      = (Column)tContact.ColumnByDisplayName[cfd.DisplayName];
                if (col != null)
                {
                    if (col.IsCustom)
                    {
                        customFieldArray.Add(col.Name);
                    }
                }
            }
            return(customFieldArray);
        }
        /**
         * Load schema Meta data.
         *
         * @param databaseType database type
         * @return schema Meta data
         * @throws SQLException SQL exception
         */
        public SchemaMetaData Load(IDatabaseType databaseType)
        {
            SchemaMetaData result = LoadShardingSchemaMetaData(databaseType);

            result.Merge(LoadDefaultSchemaMetaData(databaseType));
            return(result);
        }
Пример #4
0
 public InsertCommandContext(SchemaMetaData schemaMetaData, ParameterContext parameterContext, InsertCommand insertCommand) : base(insertCommand)
 {
     _tablesContext       = new TablesContext(insertCommand.Table);
     _columnNames         = insertCommand.UseDefaultColumns() ? schemaMetaData.GetAllColumnNames(insertCommand.Table.GetTableName().GetIdentifier().GetValue()) : insertCommand.GetColumnNames();
     _insertValueContexts = GetInsertValueContexts(parameterContext);
     _generatedKeyContext = new GeneratedKeyContextEngine(schemaMetaData).CreateGenerateKeyContext(parameterContext, insertCommand);
 }
        protected override List <MemoryQueryResultRow> Init(ShardingRule rule, SchemaMetaData schemaMetaData, ISqlCommandContext <ISqlCommand> sqlCommandContext,
                                                            List <IStreamDataReader> streamDataReaders)
        {
            ICollection <MemoryQueryResultRow> result = new LinkedList <MemoryQueryResultRow>();
            var tableNames = new HashSet <string>();

            foreach (var streamDataReader in streamDataReaders)
            {
                while (streamDataReader.Read())
                {
                    MemoryQueryResultRow memoryResultSetRow = new MemoryQueryResultRow(streamDataReader);
                    var actualTableName = memoryResultSetRow.GetCell(0).ToString();
                    var tableRule       = rule.FindTableRuleByActualTable(actualTableName);
                    if (tableRule == null)
                    {
                        if (rule.TableRules.IsEmpty() || schemaMetaData.ContainsTable(actualTableName) && tableNames.Add(actualTableName))
                        {
                            result.Add(memoryResultSetRow);
                        }
                    }
                    else if (tableNames.Add(tableRule.LogicTable))
                    {
                        memoryResultSetRow.SetCell(1, tableRule.LogicTable);
                        SetCellValue(memoryResultSetRow, tableRule.LogicTable, actualTableName);
                        result.Add(memoryResultSetRow);
                    }
                }
            }
            return(result.ToList());
        }
Пример #6
0
 public SelectCommandContext(SchemaMetaData schemaMetaData, string sql, ParameterContext parameterContext, SelectCommand sqlCommand) : base(sqlCommand)
 {
     _tablesContext      = new TablesContext(sqlCommand.GetSimpleTableSegments());
     _groupByContext     = new GroupByContextEngine().CreateGroupByContext(sqlCommand);
     _orderByContext     = new OrderByContextEngine().CreateOrderBy(sqlCommand, _groupByContext);
     _projectionsContext = new ProjectionsContextEngine(schemaMetaData).CreateProjectionsContext(sql, sqlCommand, _groupByContext, _orderByContext);
     _paginationContext  = new PaginationContextEngine().CreatePaginationContext(sqlCommand, _projectionsContext, parameterContext);
     _containsSubQuery   = ContainsSubQuery();
 }
Пример #7
0
        public static SchemaMetaData Decorate <T>(SchemaMetaData schemaMetaData, T rule, ITableMetaDataDecorator <T> tableMetaDataDecorator) where T : IBaseRule
        {
            IDictionary <string, TableMetaData> result = new Dictionary <string, TableMetaData>(schemaMetaData.GetAllTableNames().Count);

            foreach (var tableName in schemaMetaData.GetAllTableNames())
            {
                var tableMetaData = tableMetaDataDecorator.Decorate(schemaMetaData.Get(tableName), tableName, rule);
                result.Add(tableName, tableMetaData);
            }
            return(new SchemaMetaData(result));
        }
        protected MemoryMergedDataReader(T rule, SchemaMetaData schemaMetaData,
                                         ISqlCommandContext <ISqlCommand> sqlCommandContext, List <IStreamDataReader> streamDataReaders)
        {
            // ReSharper disable once VirtualMemberCallInConstructor
            var memoryQueryResultRowList = Init(rule, schemaMetaData, sqlCommandContext, streamDataReaders);

            _memoryResultSetRows = memoryQueryResultRowList.GetEnumerator();
            if (memoryQueryResultRowList.Any())
            {
                _currentSetResultRow = memoryQueryResultRowList.First();
            }
        }
Пример #9
0
        /// <summary>
        /// 通过元信息获取表名
        /// </summary>
        /// <param name="columnName"></param>
        /// <param name="schemaMetaData"></param>
        /// <returns></returns>
        private string FindTableNameFromMetaData(string columnName, SchemaMetaData schemaMetaData)
        {
            foreach (var table in _tables)
            {
                if (schemaMetaData.ContainsColumn(table.GetTableName().GetIdentifier().GetValue(), columnName))
                {
                    return(table.GetTableName().GetIdentifier().GetValue());
                }
            }

            return(null);
        }
        /// <summary>
        /// 创建数据库元数据信息
        /// </summary>
        /// <param name="dataSourceMap"></param>
        /// <param name="databaseType"></param>
        /// <returns></returns>
        private ShardingConnectorMetaData CreateMetaData(IDictionary <string, IDataSource> dataSourceMap,
                                                         IDatabaseType databaseType)
        {
            long            start           = UtcTime.CurrentTimeMillis();
            DataSourceMetas dataSourceMetas =
                new DataSourceMetas(databaseType, GetDatabaseAccessConfigurationMap(dataSourceMap));
            SchemaMetaData            schemaMetaData = LoadSchemaMetaData(dataSourceMap);
            ShardingConnectorMetaData result         = new ShardingConnectorMetaData(dataSourceMetas, schemaMetaData);
            var costMillis = UtcTime.CurrentTimeMillis() - start;

            _logger.LogInformation($"Meta data load finished, cost {costMillis} milliseconds.");
            return(result);
        }
Пример #11
0
        protected override SchemaMetaData[] GetSchemaMetaData()
        {
            SchemaMetaData data = new SchemaMetaData()
            {
                SchemaTable     = "Tables",
                SchemaColumn    = "TABLE_SCHEMA",
                NameColumn      = "TABLE_NAME",
                TableTypeColumn = "TABLE_TYPE",
                ValidTableTypes = new string[] { "VIEW", "BASE TABLE" },
                InvalidSchemas  = null
            };

            return(new SchemaMetaData[] { data });
        }
Пример #12
0
        public string FindTableName(ColumnSegment column, SchemaMetaData schemaMetaData)
        {
            if (1 == _tables.Count)
            {
                return(_tables.First().GetTableName().GetIdentifier().GetValue());
            }

            if (null != column.GetOwner())
            {
                return(FindTableNameFromSQL(column.GetOwner().GetIdentifier().GetValue()));
            }

            return(FindTableNameFromMetaData(column.GetIdentifier().GetValue(), schemaMetaData));
        }
Пример #13
0
        protected virtual SchemaMetaData[] GetSchemaMetaData()
        {
            // A bare minimum set of things that should vaguely work for all databases
            SchemaMetaData data = new SchemaMetaData()
            {
                SchemaTable     = "Tables",
                SchemaColumn    = null,
                NameColumn      = "TABLE_NAME",
                TableTypeColumn = null,
                ValidTableTypes = null,
                InvalidSchemas  = null
            };

            return(new SchemaMetaData[] { data });
        }
 public SqlRewriteContext(SchemaMetaData schemaMetaData, ISqlCommandContext <ISqlCommand> sqlCommandContext, string sql, ParameterContext parameterContext)
 {
     this._schemaMetaData    = schemaMetaData;
     this._sqlCommandContext = sqlCommandContext;
     this._sql = sql;
     this._parameterContext = parameterContext;
     AddSqlTokenGenerators(new DefaultTokenGeneratorBuilder().GetSqlTokenGenerators());
     if (sqlCommandContext is InsertCommandContext insertCommandContext)
     {
         _parameterBuilder = new GroupedParameterBuilder(insertCommandContext.GetGroupedParameters());
     }
     else
     {
         _parameterBuilder = new StandardParameterBuilder(parameterContext);
     }
 }
Пример #15
0
        protected override SchemaMetaData[] GetSchemaMetaData()
        {
            // Note, in older iterations of the code there seemed to be
            // cases when we also need to look in the "views" table
            // but I do not see that in my test cases
            SchemaMetaData data = new SchemaMetaData()
            {
                SchemaTable     = "Tables",
                SchemaColumn    = "TABLE_SCHEMA",
                NameColumn      = "TABLE_NAME",
                TableTypeColumn = "TABLE_TYPE",
                ValidTableTypes = new string[] { "VIEW", "TABLE" },
                InvalidSchemas  = null
            };

            return(new SchemaMetaData[] { data });
        }
        private bool GetValueCaseSensitiveFromTables(IStreamDataReader streamDataReader, SelectCommandContext selectCommandContext,
                                                     SchemaMetaData schemaMetaData, int columnIndex)
        {
            foreach (var simpleTableSegment in selectCommandContext.GetAllTables())
            {
                String        tableName     = simpleTableSegment.GetTableName().GetIdentifier().GetValue();
                TableMetaData tableMetaData = schemaMetaData.Get(tableName);
                IDictionary <String, ColumnMetaData> columns = tableMetaData.GetColumns();
                String columnName = streamDataReader.GetColumnName(columnIndex);
                if (columns.ContainsKey(columnName))
                {
                    return(columns[columnName].CaseSensitive);
                }
            }

            return(false);
        }
        protected override List <MemoryQueryResultRow> Init(ShardingRule rule, SchemaMetaData schemaMetaData, ISqlCommandContext <ISqlCommand> sqlCommandContext, List <IStreamDataReader> streamDataReaders)
        {
            var selectCommandContext = (SelectCommandContext)sqlCommandContext;
            IDictionary <GroupByValue, MemoryQueryResultRow> dataMap = new Dictionary <GroupByValue, MemoryQueryResultRow>(1024);
            IDictionary <GroupByValue, IDictionary <AggregationProjection, IAggregationUnit> > aggregationMap = new Dictionary <GroupByValue, IDictionary <AggregationProjection, IAggregationUnit> >(1024);


            foreach (var streamDataReader in streamDataReaders)
            {
                while (streamDataReader.Read())
                {
                    GroupByValue groupByValue = new GroupByValue(streamDataReader, selectCommandContext.GetGroupByContext().GetItems());
                    InitForFirstGroupByValue(selectCommandContext, streamDataReader, groupByValue, dataMap, aggregationMap);
                    Aggregate(selectCommandContext, streamDataReader, groupByValue, aggregationMap);
                }
            }
            SetAggregationValueToMemoryRow(selectCommandContext, dataMap, aggregationMap);
            List <bool> valueCaseSensitive = streamDataReaders.IsEmpty() ? new List <bool>(0) : GetValueCaseSensitive(streamDataReaders.First(), selectCommandContext, schemaMetaData);

            return(GetMemoryResultSetRows(selectCommandContext, dataMap, valueCaseSensitive));
        }
Пример #18
0
        //Inherited from RelationalDatabase
        //public string DatabaseType { get; set; } //MySQL, SQLite, MS SQL Server, Act!, etc...
        //public string LoginPath { get; set; }

        //Must-implements for Act_DatabaseInterface
        //NOTE: *******************loginpath and image path MUST be compatible with each other ***************************************
        //public void CreateConnection(string login, string password) //todo: add argument for database 
        public void CreateConnection(string login, string password, string database)
        {
            DatabaseType = ("Act!");
            //LoginPath = "C:\\Users\\Scott\\Documents\\ACT\\ACT Data\\Databases\\ScottyPPv16Web3.pad";
            //LoginPath = "C:\\Users\\Scott\\Documents\\ACT\\ACT Data\\Databases\\OptomiLADellv2.pad"; //Dell laptop remote DB
            //LoginPath = "C:\\Users\\zenkutsu64\\My Documents\\ACT\\ACT Data\\Databases\\PivotPointWebv16.pad"; //jamporium.com (Rackspace)
            //LoginPath = "C:\\Users\\zenkutsu64\\Documents\\ACT\\ACT Data\\Databases\\OptomiLA.pad"; //bizexpedite.com (Azure)
           
            if (database == "PPSearch")
                LoginPath = "C:\\Users\\Scott\\Documents\\ACT\\ACT Data\\Databases\\ScottPivotPoint2point0.pad"; //todo: conditional to select login path
            else if (database == "PPTalent")
                LoginPath = "C:\\Users\\Scott\\Documents\\ACT\\ACT Data\\Databases\\ScottPivotPointTalent.pad";
            else if (database == "GladPixGarden")
                LoginPath = "C:\\Users\\Scott\\Documents\\ACT\\ACT Data\\Databases\\ScottGladPixGarden.pad"; //todo: conditional to select login path
           
            //LoginPath = "C:\\Users\\zenkutsu64\\Documents\\ACT\\ACT Data\\Databases\\PivotPoint2point0.pad"; //bizexpedite.com (Azure)
            theFramework = new ActFramework();
            try { 
                theFramework.LogOn(LoginPath, login, password);
                //Test block here to investigate details of the db
                SchemaMetaData smd = theFramework.SchemaMetaData;
                ReadOnlyHashtable tblByName = smd.TableByName;
                ArrayList customFieldArray = new ArrayList();
                ContactFieldDescriptor[] cfdList = theFramework.Contacts.GetContactFieldDescriptors(); //inspect cfdList in the debugger to get info
            }
            catch (InvalidLogonException e){
                Console.WriteLine(e.Message);
            }
            catch (TargetInvocationException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (PADObjectException e)
            {
                Console.WriteLine(e.Message);
            }


        }
Пример #19
0
        protected override SchemaMetaData[] GetSchemaMetaData()
        {
            // The following may fail for Oracle ODBC, need to test that...
            SchemaMetaData data1 = new SchemaMetaData()
            {
                SchemaTable     = "Tables",
                SchemaColumn    = "TABLE_SCHEM",
                NameColumn      = "TABLE_NAME",
                TableTypeColumn = "TABLE_TYPE",
                ValidTableTypes = new string[] { "TABLE", "SYSTEM TABLE" },
                InvalidSchemas  = null
            };
            SchemaMetaData data2 = new SchemaMetaData()
            {
                SchemaTable     = "Views",
                SchemaColumn    = "TABLE_SCHEM",
                NameColumn      = "TABLE_NAME",
                TableTypeColumn = "TABLE_TYPE",
                ValidTableTypes = new string[] { "VIEW" },
                InvalidSchemas  = new string[] { "sys", "INFORMATION_SCHEMA" }
            };

            return(new SchemaMetaData[] { data1, data2 });
        }
Пример #20
0
        private bool GetOrderValuesCaseSensitiveFromTables(SelectCommandContext selectCommandContext, SchemaMetaData schemaMetaData, OrderByItem eachOrderByItem)
        {
            foreach (var simpleTableSegment in selectCommandContext.GetAllTables())
            {
                var tableName     = simpleTableSegment.GetTableName().GetIdentifier().GetValue();
                var tableMetaData = schemaMetaData.Get(tableName);
                IDictionary <String, ColumnMetaData> columns = tableMetaData.GetColumns();
                var orderByItemSegment = eachOrderByItem.GetSegment();
                if (orderByItemSegment is ColumnOrderByItemSegment columnOrderByItemSegment)
                {
                    String columnName = columnOrderByItemSegment.GetColumn().GetIdentifier().GetValue();
                    if (columns.ContainsKey(columnName))
                    {
                        return(columns[columnName].CaseSensitive);
                    }
                }
                else if (orderByItemSegment is IndexOrderByItemSegment indexOrderByItemSegment)
                {
                    int    columnIndex = indexOrderByItemSegment.GetColumnIndex();
                    String columnName  = _streamDataReader.GetColumnName(columnIndex);
                    if (columns.ContainsKey(columnName))
                    {
                        return(columns[columnName].CaseSensitive);
                    }
                }
                else
                {
                    return(false);
                }
            }

            return(false);
        }
Пример #21
0
        private void CopySchema(IEnumerable <SchemaData> sourceSchemaDataList, TaxonomyInfo newTaxonomy, bool isAppend = false)
        {
            foreach (var srcSchemaData in sourceSchemaDataList)
            {
                var newSchemaInfo =
                    newTaxonomy.SchemaInfos.SingleOrDefault(p => p.AttributeID == srcSchemaData.SchemaInfo.AttributeID)
                    ?? new SchemaInfo
                {
                    AttributeID = srcSchemaData.SchemaInfo.AttributeID, TaxonomyID = newTaxonomy.ID
                };

                //copy LOVs
                srcSchemaData.SchemaInfo.ActiveListOfValues.ForEach(aLov =>
                                                                    newSchemaInfo.ListOfValues.Add(new ListOfValue {
                    Active = true, Value = aLov, SchemaID = newSchemaInfo.ID
                }));

                //copy active schema data
                var newSchemaData = new SchemaData
                {
                    SchemaID     = newSchemaInfo.ID,
                    InSchema     = srcSchemaData.InSchema,
                    DisplayOrder = isAppend ?
                                   (
                        newTaxonomy.SchemaInfos.Where(si => si.SchemaData != null).Any(si => si.SchemaData.DisplayOrder >= 500) ?
                        newTaxonomy.SchemaInfos.Where(si => si.SchemaData != null).Max(si => si.SchemaData.DisplayOrder) + 1 :
                        500
                                   )
                                                                    : srcSchemaData.DisplayOrder,
                    NavigationOrder = isAppend ? 0 : srcSchemaData.NavigationOrder,
                    DataType        = srcSchemaData.DataType,
                    Active          = true
                };


                //copy schema meta info
                foreach (var srcSchemaMetaInfo in srcSchemaData.SchemaInfo.SchemaMetaInfos)
                {
                    var newSchemaMetaInfo = new SchemaMetaInfo
                    {
                        SchemaID        = newSchemaInfo.ID,
                        MetaAttributeID = srcSchemaMetaInfo.MetaAttributeID
                    };

                    //copy active schema meta data if it exists
                    if (srcSchemaMetaInfo.SchemaMetaData != null)
                    {
                        var newSchemaMetaData = new SchemaMetaData
                        {
                            Active = true,
                            MetaID = newSchemaMetaInfo.ID,
                            Value  = srcSchemaMetaInfo.SchemaMetaData.Value
                        };
                        newSchemaMetaInfo.SchemaMetaDatas.Add(newSchemaMetaData);
                    }

                    newSchemaInfo.SchemaMetaInfos.Add(newSchemaMetaInfo);
                }

                newSchemaInfo.SchemaDatas.Add(newSchemaData);

                newTaxonomy.SchemaInfos.Add(newSchemaInfo);
            }
        }
 public LogicTablesMergedDataReader(ShardingRule rule, SchemaMetaData schemaMetaData, ISqlCommandContext <ISqlCommand> sqlCommandContext, List <IStreamDataReader> streamDataReaders) : base(rule, schemaMetaData, sqlCommandContext, streamDataReaders)
 {
 }
 public WhereClauseShardingConditionEngine(ShardingRule shardingRule, SchemaMetaData schemaMetaData)
 {
     this.shardingRule   = shardingRule;
     this.schemaMetaData = schemaMetaData;
 }
Пример #24
0
 public OrderByValue(IStreamDataReader streamDataReader, ICollection <OrderByItem> orderByItems, SelectCommandContext selectCommandContext, SchemaMetaData schemaMetaData)
 {
     this._streamDataReader        = streamDataReader;
     this.orderByItems             = orderByItems;
     this.orderValuesCaseSensitive = GetOrderValuesCaseSensitive(selectCommandContext, schemaMetaData);
 }
Пример #25
0
 public ShardingTableBroadcastRoutingEngine(SchemaMetaData schemaMetaData, ISqlCommandContext <ISqlCommand> sqlCommandContext)
 {
     this.schemaMetaData    = schemaMetaData;
     this.sqlCommandContext = sqlCommandContext;
 }
        private void OrderResultSetsToQueue(List <IStreamDataReader> streamDataReaders, SelectCommandContext selectCommandContext, SchemaMetaData schemaMetaData)
        {
            foreach (var queryResult in streamDataReaders)
            {
                OrderByValue orderByValue = new OrderByValue(queryResult, OrderByItems, selectCommandContext, schemaMetaData);
                if (orderByValue.MoveNext())
                {
                    OrderByValuesQueue.Offer(orderByValue);
                }
            }

            SetCurrentStreamDataReader(OrderByValuesQueue.IsEmpty() ? streamDataReaders[0] : OrderByValuesQueue.Peek().GetStreamDataReader());
        }
 public OrderByStreamMergedDataReader(List <IStreamDataReader> streamDataReaders, SelectCommandContext selectCommandContext, SchemaMetaData schemaMetaData)
 {
     this.OrderByItems       = selectCommandContext.GetOrderByContext().GetItems();
     this.OrderByValuesQueue = new PriorityQueue <OrderByValue>(streamDataReaders.Count);
     OrderResultSetsToQueue(streamDataReaders, selectCommandContext, schemaMetaData);
     IsFirstNext = true;
 }
Пример #28
0
        private List <bool> GetOrderValuesCaseSensitive(SelectCommandContext selectCommandContext, SchemaMetaData schemaMetaData)
        {
            List <bool> result = new List <bool>(orderByItems.Count);

            foreach (var orderByItem in orderByItems)
            {
                result.Add(GetOrderValuesCaseSensitiveFromTables(selectCommandContext, schemaMetaData, orderByItem));
            }

            return(result);
        }
Пример #29
0
 public IStreamDataReader Merge(List <IStreamDataReader> streamDataReaders, ISqlCommandContext <ISqlCommand> sqlCommandContext, SchemaMetaData schemaMetaData)
 {
     return(new TransparentMergedDataReader(streamDataReaders[0]));
 }
Пример #30
0
 public MergeEngine(ICollection <IBaseRule> rules, ConfigurationProperties properties, IDatabaseType databaseType, SchemaMetaData metaData)
 {
     this.rules = rules;
     merger     = new MergeEntry(databaseType, metaData, properties);
 }