コード例 #1
0
        public questStatus GetViewInfo(DatabaseId databaseId, TablesetView tablesetView, out View view)
        {
            // Initialize
            questStatus status = null;

            view = null;


            // Get view
            DbViewsMgr dbViewsMgr = new DbViewsMgr(this._userSession);

            status = dbViewsMgr.Read(databaseId, tablesetView.Schema, tablesetView.Name, out view);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            tablesetView.View = view;


            // Get view columns
            ViewId        viewId       = new ViewId(view.Id);
            List <Column> columnList   = null;
            DbColumnsMgr  dbColumnsMgr = new DbColumnsMgr(this._userSession);

            status = dbColumnsMgr.Read(viewId, out columnList);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            view.ColumnList = columnList;

            return(new questStatus(Severity.Success));
        }
コード例 #2
0
        public questStatus ReadTablesetConfiguration(TablesetId tablesetId, out TablesetConfiguration tablesetConfiguration)
        {
            // Initialize
            questStatus status = null;

            tablesetConfiguration = null;


            // Read tableset
            Tableset       tableset       = null;
            DbTablesetsMgr dbTablesetsMgr = new DbTablesetsMgr(this._userSession);

            status = dbTablesetsMgr.Read(tablesetId, out tableset);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }


            // Read database
            DatabaseId databaseId = new DatabaseId(tableset.DatabaseId);

            Quest.Functional.MasterPricing.Database database = null;
            DbDatabasesMgr dbDatabasesMgr = new DbDatabasesMgr(this._userSession);

            status = dbDatabasesMgr.Read(databaseId, out database);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }



            /*
             * Load tableset entities.
             */
            DbTablesetColumnsMgr dbTablesetColumnsMgr = new DbTablesetColumnsMgr(this._userSession);


            // Read tables in tableset
            List <Quest.Functional.MasterPricing.TablesetTable> tablesetTableList = null;
            DbTablesetTablesMgr dbTablesetTablesMgr = new DbTablesetTablesMgr(this._userSession);

            status = dbTablesetTablesMgr.Read(tablesetId, out tablesetTableList);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }

            // Read table info.
            EntityType entityType = new EntityType();

            entityType.Id = EntityType.Table;
            DbTablesMgr  dbTablesMgr  = new DbTablesMgr(this._userSession);
            DbColumnsMgr dbColumnsMgr = new DbColumnsMgr(this._userSession);

            foreach (TablesetTable tablesetTable in tablesetTableList)
            {
                TablesetId tableSetId = new TablesetId(tablesetTable.Id);
                List <Quest.Functional.MasterPricing.TablesetColumn> tablesetColumnList = null;

                TableSetEntityId tableSetEntityId = new TableSetEntityId(tablesetTable.Id);
                status = dbTablesetColumnsMgr.Read(entityType, tableSetEntityId, out tablesetColumnList);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                tablesetTable.TablesetColumnList = tablesetColumnList;

                Table table = null;
                status = dbTablesMgr.Read(databaseId, tablesetTable.Schema, tablesetTable.Name, out table);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                tablesetTable.Table = table;


                // Get column metadata
                EntityTypeId entityTypeId = new EntityTypeId(EntityType.Table);
                EntityId     entityId     = new EntityId(table.Id);
                foreach (TablesetColumn tablesetColumn in tablesetColumnList)
                {
                    Column column = null;
                    status = dbColumnsMgr.Read(entityTypeId, entityId, tablesetColumn.Name, out column);
                    if (!questStatusDef.IsSuccess(status))
                    {
                        return(status);
                    }
                    tablesetColumn.Column = column;
                }
            }

            // Read views in tableset
            List <Quest.Functional.MasterPricing.TablesetView> tablesetViewList = null;
            DbTablesetViewsMgr dbTablesetViewsMgr = new DbTablesetViewsMgr(this._userSession);

            status = dbTablesetViewsMgr.Read(tablesetId, out tablesetViewList);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            // Read views columns in tableset
            entityType.Id = EntityType.View;
            DbViewsMgr dbViewsMgr = new DbViewsMgr(this._userSession);

            foreach (TablesetView tablesetView in tablesetViewList)
            {
                TablesetViewId tablesetViewId = new TablesetViewId(tablesetView.Id);
                List <Quest.Functional.MasterPricing.TablesetColumn> tablesetColumnList = null;

                TableSetEntityId tableSetEntityId = new TableSetEntityId(tablesetView.Id);
                status = dbTablesetColumnsMgr.Read(entityType, tableSetEntityId, out tablesetColumnList);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                tablesetView.TablesetColumnList = tablesetColumnList;

                View view = null;
                status = dbViewsMgr.Read(databaseId, tablesetView.Schema, tablesetView.Name, out view);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                tablesetView.View = view;


                // Get column metadata
                EntityTypeId entityTypeId = new EntityTypeId(EntityType.View);
                EntityId     entityId     = new EntityId(view.Id);
                foreach (TablesetColumn tablesetColumn in tablesetColumnList)
                {
                    Column column = null;
                    status = dbColumnsMgr.Read(entityTypeId, entityId, tablesetColumn.Name, out column);
                    if (!questStatusDef.IsSuccess(status))
                    {
                        return(status);
                    }
                    tablesetColumn.Column = column;
                }
            }

            // Build tableset configuration
            tablesetConfiguration                = new TablesetConfiguration();
            tablesetConfiguration.Tableset       = tableset;
            tablesetConfiguration.Database       = database;
            tablesetConfiguration.TablesetTables = tablesetTableList;
            tablesetConfiguration.TablesetViews  = tablesetViewList;


            return(new questStatus(Severity.Success));
        }