示例#1
0
        /// <summary>
        /// Remove a particular pair of path with a type from the table.
        /// </summary>
        /// <param name="source">Source of propagation</param>
        /// <param name="dest">Destination of propagation</param>
        /// <param name="type">Type of table</param>
        /// <returns>The PathPair removed.</returns>
        public PathPair RemovePathPair(string source, string dest, TableType type)
        {
            PathPair returnPair = null;
            List<PathPair> usedTable = null;
            //Use different table based on type.
            switch (type)
            {
                case TableType.Create: usedTable = _createEventPathPair; break;
                case TableType.Update: usedTable = _updateEventPathPair; break;
                case TableType.Rename: usedTable = _renameEventPathPair; break;
                case TableType.Delete: usedTable = _deleteEventPathPair; break;

            }
            if (usedTable == null)
            {
                return null;
            }
            lock (this)
            {
                //Create a Copy of the Pathpair, 
                //Find a same PathPair and return it.
                PathPair pathPair = new PathPair(source, dest);
                foreach (PathPair pair in usedTable)
                {
                    if (pathPair.Equals(pair))
                    {
                        returnPair = pair;
                    }
                }
                usedTable.Remove(returnPair);
            }

            return returnPair;
        }
示例#2
0
        internal static Table BuildTable(int rowCount, 
                                         int columnCount,
                                         Brush borderBrush,
                                         Thickness borderThickness,
                                         double dLineHeight,
                                         TableType tableType)
        {
            Table table = new Table();
            table.Tag = tableType;
            table.CellSpacing = 2;
            table.BorderBrush = borderBrush;
            table.BorderThickness = borderThickness;
            table.MouseEnter += new MouseEventHandler(table_MouseEnter);
            table.MouseLeave += new MouseEventHandler(table_MouseLeave);

            for (int columnIndex = 0; columnIndex < columnCount; columnIndex++)
            {
                TableColumn tableColumn = new TableColumn();
                tableColumn.Width = double.IsNaN(dLineHeight) ? GridLength.Auto : new GridLength(dLineHeight);
                table.Columns.Add(tableColumn);
            }

            TableRowGroup rowGroup = new TableRowGroup();
            for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
            {
                TableRow row = BuildTableRow(columnCount,borderBrush,borderThickness,dLineHeight);
                rowGroup.Rows.Add(row);
            }
            table.RowGroups.Add(rowGroup);
            return table;
        }
示例#3
0
 public static GenTableDALBase CreateInstance(TableType table, string connectionString)
 {
     if (GlobalService.DbType == DatabaseType.SqlServer)
     {
         return new SqlServer.SqlGenTableDAL(table, connectionString);
     }
     return null;
 }
示例#4
0
 public GenBLL(TableType table)
 {
     this.table = table;
     this.ModelName = table.Model.Name.Value;
     this.ParaModelName = this.ModelName.Substring(0,1).ToLower() + this.ModelName.Substring(1);
     this.DALName = "dal" + ModelName;
     this.TableName = table.Name.Value;
 }
 public GameDescriptor(SiteName siteName,
                       GameType gameType,
                       Buyin buyin,
                       TableType tableType,
                       SeatType seatType)
     : this(PokerFormat.SitAndGo, siteName, gameType, buyin, tableType, seatType)
 {
 }
 public GameDescriptor(SiteName siteName,
                       GameType gameType,
                       Limit limit,
                       TableType tableType,
                       SeatType seatType)
     : this(PokerFormat.CashGame, siteName, gameType, limit, tableType, seatType)
 {
 }
示例#7
0
 public static ColumnType GetColumn(TableType table, string column)
 {
     foreach (ColumnType col in table.ColumnSet.MyColumns)
     {
         if (string.Equals(col.Name.Value, column, StringComparison.InvariantCultureIgnoreCase))
             return col;
     }
     return null;
 }
 public static void AddTable(string nameTable, TableType tableType, ArrayList columnList)
 {
     switch (tableType)
     {
         case TableType.Standart:
             tables.Add(nameTable, new DataTableStandart(nameTable));
             foreach (object col in columnList) tables[nameTable].Table.Columns.Add(col.ToString());
             break;
         case TableType.Compare:
             tables.Add(nameTable, new DataTableDifference(nameTable));
             break;
     }
 }
 public GameDescriptor(PokerFormat pokerFormat,
                       SiteName siteName,
                       GameType gameType,
                       Buyin buyin,
                       TableType tableType,
                       SeatType seatType)
 {
     PokerFormat = pokerFormat;
     Site = siteName;
     GameType = gameType;
     Buyin = buyin;
     TableType = tableType;
     SeatType = seatType;
 }
 public GameDescriptor(PokerFormat pokerFormat,
                       SiteName siteName,
                       GameType gameType,
                       Limit limit,
                       TableType tableType,
                       SeatType seatType)
 {
     PokerFormat = pokerFormat;
     Site = siteName;
     GameType = gameType;
     Limit = limit;
     TableType = tableType;
     SeatType = seatType;
 }
示例#11
0
        // Build a table with a given number of rows and columns
        internal static Table UpdateTable(Table table,
                                         int rowCount, 
                                         int columnCount,
                                         Brush borderBrush,
                                         Thickness borderThickness,
                                         double dLineHeight,
                                         TableType tableType)
        {
            table.Tag = tableType;
            table.CellSpacing = 2;
            table.BorderBrush = borderBrush;
            table.BorderThickness = borderThickness;
            table.MouseEnter += new MouseEventHandler(table_MouseEnter);
            table.MouseLeave += new MouseEventHandler(table_MouseLeave);
         
            if (0 >= table.Columns.Count)
            {
                for (int columnIndex = 0; columnIndex < columnCount; columnIndex++)
                {
                    TableColumn tableColumn = new TableColumn();
                    tableColumn.Width = double.IsNaN(dLineHeight) ? GridLength.Auto : new GridLength(dLineHeight);
                    table.Columns.Add(tableColumn);
                }
            }
            else
            {
                foreach (TableColumn tableColumn in table.Columns)
                {
                    tableColumn.Width = double.IsNaN(dLineHeight) ? GridLength.Auto : new GridLength(dLineHeight);
                }
            }

            foreach(TableRowGroup rowGroup in table.RowGroups)
            {
                foreach (TableRow row in rowGroup.Rows)
                {
                    foreach (TableCell cell in row.Cells)
                    {
                        cell.BorderBrush = borderBrush;
                        cell.BorderThickness = borderThickness; 
                    }
                }
            }

            return table;
        }
 public WorksheetType()
 {
     _queryTable = new List<QueryTableType>();
     _worksheetoptions = new worksheetoptions();
     _sorting = new SortingType();
     _conditionalFormatting = new List<ConditionalFormattingType>();
     _autoFilter = new AutoFilter();
     _dataValidation = new List<DataValidationType>();
     _pivotTable = new List<PivotTableType>();
     _pageBreaks = new PageBreaksType();
     _dataTable = new DataTable();
     _watches = new List<WatchesWatch>();
     _worksheetOptions = new WorksheetOptionsType();
     _table = new TableType();
     _names = new List<NamesTypeNamedRange>();
     _protected = TrueFalseType.Item0;
     _rightToLeft = TrueFalseType.Item0;
 }
示例#13
0
        private DataTable GetTableType(int userId, TableType tableType)
        {
            DataTable Table = new DataTable();

            switch (tableType)
            {
                case TableType.Activity:
                    WhereItems.Clear();
                    Table.Columns.Add("# of Activities");
                    Table.Columns.Add("# of Weeks");
                    WhereItems.Add("tblLoginID", userId.ToString());
                    break;

                case TableType.BMI:
                    WhereItems.Clear();
                    Table.Columns.Add("Activity");
                    Table.Columns.Add("Value");
                    WhereItems.Add("activityID", SelectActivityID("BMI").ToString());
                    WhereItems.Add("tblLoginID", userId.ToString());
                    break;

                case TableType.SittingHeartRate:
                    WhereItems.Clear();
                    Table.Columns.Add("Activity");
                    Table.Columns.Add("Value");
                    WhereItems.Add("activityID", SelectActivityID("Sitting Heart Rate").ToString());
                    WhereItems.Add("tblLoginID", userId.ToString());
                    break;

                case TableType.WorkingHeartRate:
                    WhereItems.Clear();
                    Table.Columns.Add("Activity");
                    Table.Columns.Add("Value");
                    WhereItems.Add("activityID", SelectActivityID("Working Heart Rate").ToString());
                    WhereItems.Add("tblLoginID", userId.ToString());
                    break;

            }
            return Table;
        }
示例#14
0
 public ISqlUpdate MakeSelect(TableType.Table_Type type)
 {
     switch (type)
     {
         case TableType.Table_Type.Compnay:
             return new CompanySql();
         case TableType.Table_Type.Menu:
             return new MenuSql();
         case TableType.Table_Type.Notice:
             return new NoticeSql();
         case TableType.Table_Type.Rule:
             return new RuleSql();
         case TableType.Table_Type.Seting:
             return new SetSql();
         case TableType.Table_Type.Service:
             return new ServiceSql();
         case TableType.Table_Type.DownFile:
             return new DownFileSql();
         default:
             return null;
     }
 }
示例#15
0
        public IHttpActionResult Get([FromUri] string sdi, [FromUri] DateTime t1, [FromUri] DateTime t2, [FromUri] IntervalType interval = new IntervalType(), [FromUri] bool rbase = false, [FromUri] TableType table = new TableType(), [FromUri] int mrid = 0, [FromUri] string instantMinutes = "60")
        {
            IDbConnection db = HdbController.Connect(this.Request.Headers);
            var           seriesProcessor = new HdbApi.DataAccessLayer.SeriesRepository();
            var           result          = seriesProcessor.GetSeries(db, sdi, interval.ToString(), t1, t2, table.ToString(), mrid, rbase, instantMinutes);

            try
            {
                db.Close();
                db.Dispose();
            }
            catch
            {
            }

            return(Ok(result));
        }
示例#16
0
 //private TableType Table { get; set; }
 public SearchSqlFrm(TableType table)
 {
     InitializeComponent();
     this.textEditorControl1.Document.HighlightingStrategy =
        HighlightingStrategyFactory.CreateHighlightingStrategy("TSQL");
 }
示例#17
0
 public void EndPlace(Mobile from, TableType type, Point3D loc)
 {
     DaviesLocker table = new DaviesLocker(from, type, loc);
     for (int i = 0; i < m_Entries.Count; ++i)
     {
         //BountyBoardEntry entry = (BountyBoardEntry) BountyBoard.Entries[i];
         DaviesDeedEntry e = (DaviesDeedEntry) Entries[i];
         table.m_Entries.Add(new DaviesLockerEntry(e.type, e.Level, e.Decoder, e.Map, e.Location2d, e.Location3d,
             e.Bounds, e.Mapnumber));
     }
     Delete();
     BaseHouse house = BaseHouse.FindHouseAt(table);
     if (house != null)
         house.Addons.Add(table);
 }
示例#18
0
        public bool ValidatePlacement(Mobile from, Point3D loc, TableType type)
        {
            if (from.AccessLevel >= AccessLevel.GameMaster)
                return true;

            if (!from.InRange(GetWorldLocation(), 1))
            {
                from.SendLocalizedMessage(500446); // That is too far away.
                return false;
            }

            Map map = from.Map;

            if (map == null)
                return false;

            BaseHouse house = BaseHouse.FindHouseAt(loc, map, 20);

            if (house == null || !house.IsFriend(from))
            {
                from.SendLocalizedMessage(500269); // You cannot build that there.
                return false;
            }

            if (type == TableType.East)
            {
                int x = loc.X - 1;
                int y = loc.Y - 1;
                int y2 = loc.Y - 2;
                int z = loc.Z;
                if (!map.CanFit(x, y, z, 20, true, false, false))
                {
                    from.SendLocalizedMessage(500269); // You cannot build that there.
                    return false;
                }
                if (!map.CanFit(x, y2, z, 20, true, false, false))
                {
                    @from.SendLocalizedMessage(500269); // You cannot build that there.
                    return false;
                }
            }
            else
            {
                int x = loc.X - 1;
                int x2 = loc.X - 2;
                int y = loc.Y - 1;
                int z = loc.Z;
                if (!map.CanFit(x, y, z, 20, true, false, false))
                {
                    from.SendLocalizedMessage(500269); // You cannot build that there.
                    return false;
                }
                if (!map.CanFit(x2, y, z, 20, true, false, false))
                {
                    @from.SendLocalizedMessage(500269); // You cannot build that there.
                    return false;
                }
            }

            return true;
        }
示例#19
0
 // FALSE if the row matches, TRUE otherwise !!!
 protected static bool EqualFuncTableType(string key, TableType content)
 {
     TableType parsed;
     if (TableTypes.TryParse (key, out parsed))
         return parsed != content;
     else
         return true;
 }
示例#20
0
 public Token(TableType type, int rid)
 {
     token = (uint)type | (uint)rid;
 }
        public async Task <ResponseViewModel <List <BusinessCustomerViewMdoel> > > Gets(long?id, TableType type)
        {
            var returnResponse = new ResponseViewModel <List <BusinessCustomerViewMdoel> >();

            try
            {
                var url      = String.Format(AppointmentUserService.GET_BUSINESS_CUSTOMERBYIDANDTYPE, id, (int)type);
                var response = await this.appointmentUserService.httpClient.GetAsync(url);

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    returnResponse = await base.GetHttpResponse <List <BusinessCustomerViewMdoel> >(response);
                }
            }
            catch (Exception ex)
            {
                returnResponse.Data    = null;
                returnResponse.Message = "Reason: " + ex.Message.ToString();
                returnResponse.Status  = false;
            }
            return(returnResponse);
        }
示例#22
0
 protected override TableType ParseTableType(string[] handLines)
 {
     return(TableType.FromTableTypeDescriptions(TableTypeDescription.Regular));
 }
示例#23
0
        public void FillTableSchema(Table tbl, TableType tableType)
        {
            TableColumnCollection columns = new TableColumnCollection();
            DataSet dsColumns;

            tbl.ForeignKeys = new ForeignKeyCollection();

            if (tableType == TableType.Function)
            {
                if (dsColumns2.Tables[Name] == null)
                {
                    var cmdColumns = new SqlCommand(ROUTINE_COLUMN_SQL_ALL);
                    var dt         = new DataTable(Name);
                    dt.Load(cmdColumns.GetReader());
                    dsColumns2.Tables.Add(dt);
                }
                dsColumns = dsColumns2;
            }
            else
            {
                if (dsColumns1.Tables[Name] == null)
                {
                    var cmdColumns = new SqlCommand(TABLE_COLUMN_SQL_ALL);
                    var dt         = new DataTable(Name);
                    dt.Load(cmdColumns.GetReader());
                    dsColumns1.Tables.Add(dt);
                }
                dsColumns = dsColumns1;
            }

            DataRow[] drColumns = dsColumns.Tables[Name].Select("TableName ='" + tbl.Name + "'", "OrdinalPosition ASC");

            for (int i = 0; i < drColumns.Length; i++)
            {
                TableColumn column = new TableColumn(tbl);
                column.ColumnName     = drColumns[i][SqlSchemaVariable.COLUMN_NAME].ToString();
                column.NativeDataType = drColumns[i][SqlSchemaVariable.DATA_TYPE].ToString();
                if (column.NativeDataType == "numeric")
                {
                    column.NativeDataType = string.Format("Decimal({0},{1})", drColumns[i]["precision"], drColumns[i]["scale"]);
                }
                column.DataType = GetDbType(column.NativeDataType);
                if (drColumns[i][SqlSchemaVariable.COLUMN_DEFAULT] != DBNull.Value)
                {
                    string defaultSetting = drColumns[i][SqlSchemaVariable.COLUMN_DEFAULT].ToString().Trim();
                    if (defaultSetting.ToLower().IndexOf("newsequentialid()") > -1)
                    {
                        column.DefaultSetting = SqlSchemaVariable.DEFAULT;
                    }
                    else
                    {
                        column.DefaultSetting = defaultSetting;
                    }
                }
                column.AutoIncrement = Convert.ToBoolean(drColumns[i][SqlSchemaVariable.IS_IDENTITY]);
                int maxLength;
                int.TryParse(drColumns[i][SqlSchemaVariable.MAX_LENGTH].ToString(), out maxLength);
                column.MaxLength = maxLength;
                if (maxLength > 0)
                {
                    column.NativeDataType += "(" + maxLength + ")";
                }
                column.IsNullable = drColumns[i][SqlSchemaVariable.IS_NULLABLE].ToString() == "YES";
                bool isComputed = (drColumns[i][SqlSchemaVariable.IS_COMPUTED].ToString() == "1");
                column.IsReadOnly  = (column.NativeDataType == "timestamp" || isComputed);
                column.UpdateCheck = ColumnAttributes.GetConcurrencyUpdateCheckRule(column);
                columns.Add(column);
                tbl.SchemaName = drColumns[i]["Owner"].ToString();
            }
            tbl.Columns = columns;

            if (dsIndex.Tables[Name] == null)
            {
                var       cmdIndex = new SqlCommand(INDEX_SQL_ALL);
                DataTable dt       = new DataTable(Name);
                dt.Load(cmdIndex.GetReader());
                dsIndex.Tables.Add(dt);
            }

            DataRow[] drIndexes = dsIndex.Tables[Name].Select("TableName ='" + tbl.Name + "'");
            for (int i = 0; i < drIndexes.Length; i++)
            {
                string      colName        = drIndexes[i][SqlSchemaVariable.COLUMN_NAME].ToString();
                string      constraintType = drIndexes[i][SqlSchemaVariable.CONSTRAINT_TYPE].ToString();
                TableColumn column         = columns.GetColumn(colName);

                if (Utility.IsMatch(constraintType, SqlSchemaVariable.PRIMARY_KEY))
                {
                    column.IsPrimaryKey = true;
                }
                else if (Utility.IsMatch(constraintType, SqlSchemaVariable.FOREIGN_KEY))
                {
                    column.IsForeignKey = true;
                }
                //HACK: Allow second pass naming adjust based on whether a column is keyed
                column.ColumnName = column.ColumnName;
            }

            if (dtFKR == null)
            {
                var cmdFKR = new SqlCommand(FOREIGN_KEY_RELATIONSHIPS);
                dtFKR = new DataTable();
                dtFKR.Load(cmdFKR.GetReader());

                var cmdFK = new SqlCommand(FOREIGN_KEYS);
                dtFK = new DataTable();
                dtFK.Load(cmdFK.GetReader());
            }

            DataRow[] drfkr;
            drfkr = dtFKR.Select("PkTable ='" + tbl.Name + "'");
            for (int i = 0; i < drfkr.Length; i++)
            {
                Relationship rel = new Relationship();
                rel.Name = drfkr[i]["RelName"].ToString();
                Table fktable = Db.Service.GetSchema(drfkr[i]["FkTable"].ToString());
                rel.ClassNameOne  = tbl.ClassName;
                rel.ClassNameMany = fktable.ClassName;
                string[] a = Regex.Split(rel.Name, "__");
                if (a.Length == 2)
                {
                    rel.PropertyNameMany = a[0]; // name used in primary table to fetch many of this table
                    rel.PropertyNameOne  = a[1]; // named used for foreign key in this table
                }
                else
                {
                    rel.PropertyNameOne  = tbl.ClassName;
                    rel.PropertyNameMany = fktable.ClassNamePlural;
                }

                DataRow[] drfk = dtFK.Select("PkTable = '" + tbl.Name + "' and RelName = '" + rel.Name + "'");
                for (int ii = 0; ii < drfk.Length; ii++)
                {
                    Relationship.KeyPair kp    = new Relationship.KeyPair();
                    TableColumn          fkcol = fktable.Columns.GetColumn(drfk[ii]["FkColumn"].ToString());
                    TableColumn          pkcol = columns.GetColumn(drfk[ii]["PkColumn"].ToString());
                    kp.vartype    = fkcol.VarType;
                    kp.ForeignKey = fkcol.Name;
                    kp.PrimaryKey = pkcol.Name;
                    rel.KeyPairs.Add(kp);
                    if (ii > 0)
                    {
                        rel.ForeignKey += ",";
                        rel.PrimaryKey += ",";
                    }
                    rel.PrimaryKey += kp.PrimaryKey;
                    rel.ForeignKey += kp.ForeignKey;
                }


                tbl.ForeignKeyTables.Add(rel);
            }

            drfkr = dtFKR.Select("FkTable ='" + tbl.Name + "'");
            for (int i = 0; i < drfkr.Length; i++)
            {
                Relationship rel = new Relationship();
                rel.Name = drfkr[i]["RelName"].ToString();
                Table pktable = Db.Service.GetSchema(drfkr[i]["PkTable"].ToString());
                rel.ClassNameOne  = pktable.ClassName;
                rel.ClassNameMany = tbl.ClassName;
                string[] a = Regex.Split(rel.Name, "__");
                if (a.Length == 2)
                {
                    rel.PropertyNameMany = a[0]; // name used in primary table to fetch many of this table
                    rel.PropertyNameOne  = a[1]; // named used for foreign key in this table
                }
                else
                {
                    rel.PropertyNameOne  = pktable.ClassName;
                    rel.PropertyNameMany = tbl.ClassNamePlural;
                }

                DataRow[] drfk = dtFK.Select("FkTable = '" + tbl.Name + "' and RelName = '" + rel.Name + "'");
                for (int ii = 0; ii < drfk.Length; ii++)
                {
                    Relationship.KeyPair kp    = new Relationship.KeyPair();
                    TableColumn          fkcol = columns.GetColumn(drfk[ii]["FkColumn"].ToString());
                    TableColumn          pkcol = pktable.Columns.GetColumn(drfk[ii]["PkColumn"].ToString());
                    kp.vartype    = fkcol.VarType;
                    kp.ForeignKey = fkcol.Name;
                    kp.PrimaryKey = pkcol.Name;
                    rel.KeyPairs.Add(kp);
                    if (ii > 0)
                    {
                        rel.ForeignKey += ",";
                        rel.PrimaryKey += ",";
                    }
                    rel.PrimaryKey       += kp.PrimaryKey;
                    rel.ForeignKey       += kp.ForeignKey;
                    fkcol.PropertyNameOne = rel.PropertyNameOne;
                }

                tbl.ForeignKeys.Add(rel);
            }

            if (dsManyToManyCheck.Tables[Name] == null)
            {
                var cmdM2M = new SqlCommand(MANY_TO_MANY_CHECK_ALL);
                var dt     = new DataTable(Name);
                dt.Load(cmdM2M.GetReader());
                dsManyToManyCheck.Tables.Add(dt);
            }

            DataRow[] drs = dsManyToManyCheck.Tables[Name].Select("PK_Table = '" + tbl.Name + "'");
            if (drs.Length > 0)
            {
                for (int count = 0; count < drs.Length; count++)
                {
                    string mapTable = drs[count]["FK_Table"].ToString();
                    string localKey = drs[count]["FK_Column"].ToString();
                    if (dsManyToManyMap.Tables[Name] == null)
                    {
                        var       cmdM2MMap = new SqlCommand(MANY_TO_MANY_FOREIGN_MAP_ALL);
                        DataTable dt        = new DataTable(Name);
                        dt.Load(cmdM2MMap.GetReader());
                        dsManyToManyMap.Tables.Add(dt);
                    }


                    DataRow[] drMap = dsManyToManyMap.Tables[Name].Select("FK_Table = '" + mapTable + "' AND PK_Table <> '" + tbl.Name + "'");

                    for (int i = 0; i < drMap.Length; i++)
                    {
                        ManyToManyRelationship m = new ManyToManyRelationship(mapTable);
                        m.ForeignTableName              = drMap[i]["PK_Table"].ToString();
                        m.ForeignPrimaryKey             = drMap[i]["PK_Column"].ToString();
                        m.MapTableLocalTableKeyColumn   = localKey;
                        m.MapTableForeignTableKeyColumn = drMap[i]["FK_Column"].ToString();
                        tbl.ManyToManys.Add(m);
                    }
                }
            }
        }
示例#24
0
 /// <summary>
 /// Initializes this reference
 /// </summary>
 /// <param name="type">The element's type</param>
 /// <param name="index">The element's index in its table</param>
 public TableElemRef(TableType type, int index)
 {
     data = (((uint)type) << 30) | (uint)index;
 }
示例#25
0
        public static PlayerStats createStatsFromHandList(List <Hand> handList, string playerName, PokerClient client, TableType tableType)
        {
            var playerStats = new PlayerStats(playerName, client, tableType);

            foreach (var hand in handList)
            {
                playerStats.increment(hand);
            }

            return(playerStats);
        }
示例#26
0
 /// <summary>
 /// Read and decode an index value from the reader.
 /// </summary>
 /// <param name="reader">The reader to read From.</param>
 /// <param name="table">The index type to read.</param>
 /// <returns>The index value.</returns>
 private Token ReadIndexValue(BinaryReader reader, TableType table)
 {
     return new Token(table, GetIndexSize(table) == 2 ? reader.ReadInt16() : reader.ReadInt32());
 }
示例#27
0
        protected void TreeCellDataFuncTableType(TreeViewColumn treeViewColumn, CellRenderer renderer, TreeModel treeModel, TreeIter iter)
        {
            TableType tt = (TableType)treeModel.GetValue(iter, columnsDict[treeViewColumn]);

            cellRendererCombo.Text = tt.ToStr();
        }
示例#28
0
 protected abstract void OnTableTypeChanged(TreeIter iter, TableType newTableType);
示例#29
0
 /// <summary>
 /// Gets the rows.
 /// </summary>
 /// <param name="table">The table.</param>
 /// <returns></returns>
 public int GetRowCount(TableType table)
 {
     return _rowCounts[((int)table >> 24)];
 }
示例#30
0
        public HttpResponseMessage Get([FromUri] string svr, [FromUri] string sdi, [FromUri] string t1, [FromUri] string t2, [FromUri] string tstp = "DY",
                                       [FromUri] TableType table = new TableType(), [FromUri] string mrid = "0", [FromUri] string format = "1")
        {
            var cgiProcessor = new HdbApi.DataAccessLayer.CgiRepository();

            IDbConnection db;

            if (svr.ToLower() == "pnhyd" || svr.ToLower() == "gphyd")
            {
                db = null;
            }
            else //HDB
            {
                // Connect to HDB
                bool            hostFound = false;
                List <string[]> hostList  = cgiProcessor.get_host_list();
                foreach (string[] hostInfo in hostList)
                {
                    if (svr == hostInfo[0].ToString())
                    {
                        hostFound = true;
                        this.Request.Headers.Add("api_hdb", hostInfo[0]);
                        this.Request.Headers.Add("api_user", hostInfo[4]);
                        this.Request.Headers.Add("api_pass", hostInfo[5]);
                    }
                }
                if (!hostFound)
                {
                    throw new Exception("HDB Database not recognized.");
                }
                db = HdbController.Connect(this.Request.Headers);
            }
            // Build CGI query URL
            //      ?svr=lchdb2&sdi=25401&tstp=IN&t1=2018-05-07T05:00&t2=2018-05-07T08:00&table=R&mrid=&format=2
            var tstpString = "";

            switch (tstp.ToString().ToLower())
            {
            case "instant":
            case "in":
                tstpString = "IN";
                break;

            case "hour":
            case "hr":
                tstpString = "HR";
                break;

            case "month":
            case "mn":
                tstpString = "MN";
                break;

            case "year":
            case "yr":
                tstpString = "YR";
                break;

            case "wy":
                tstpString = "WY";
                break;

            default:
                tstpString = "DY";
                break;
            }
            tstp = tstpString;

            int      t1Int, t2Int;
            DateTime t1Input, t2Input;

            if (DateTime.TryParse(t1, out t1Input) && DateTime.TryParse(t2, out t2Input))
            {
                // Snap date-times to the time-step-specific date format
                switch (tstp.ToString().ToLower())
                {
                case "in":
                case "hr":
                    t1Input = t1Input;
                    t2Input = t2Input;
                    break;

                case "dy":
                    t1Input = new DateTime(t1Input.Year, t1Input.Month, t1Input.Day, 0, 0, 0);
                    t2Input = new DateTime(t2Input.Year, t2Input.Month, t2Input.Day, 0, 0, 0);
                    break;

                case "mn":
                    t1Input = new DateTime(t1Input.Year, t1Input.Month, 1, 0, 0, 0);
                    t2Input = new DateTime(t2Input.Year, t2Input.Month, 1, 0, 0, 0);
                    break;

                case "yr":
                case "wy":
                    t1Input = new DateTime(t1Input.Year, 1, 1, 0, 0, 0);
                    t2Input = new DateTime(t2Input.Year, 1, 1, 0, 0, 0);
                    break;

                default:
                    throw new Exception("Error: Invalid Query Time-Step.");
                }
            }
            // Special case for T1 and T2 - If integers, query last X-timestep's worth of data and snap dates
            else if (int.TryParse(t1, out t1Int) && int.TryParse(t2, out t2Int))
            {
                switch (tstp.ToString().ToLower())
                {
                case "in":
                case "hr":
                    t1Input = DateTime.Now.AddHours(t1Int);
                    t1Input = new DateTime(t1Input.Year, t1Input.Month, t1Input.Day, t1Input.Hour, 0, 0);
                    t2Input = DateTime.Now.AddHours(t2Int);
                    t2Input = new DateTime(t2Input.Year, t2Input.Month, t2Input.Day, t2Input.Hour, 0, 0);
                    break;

                case "dy":
                    t1Input = DateTime.Now.AddDays(t1Int);
                    t1Input = new DateTime(t1Input.Year, t1Input.Month, t1Input.Day, 0, 0, 0);
                    t2Input = DateTime.Now.AddDays(t2Int);
                    t2Input = new DateTime(t2Input.Year, t2Input.Month, t2Input.Day, 0, 0, 0);
                    break;

                case "mn":
                    t1Input = DateTime.Now.AddMonths(t1Int);
                    t1Input = new DateTime(t1Input.Year, t1Input.Month, 1, 0, 0, 0);
                    t2Input = DateTime.Now.AddMonths(t2Int);
                    t2Input = new DateTime(t2Input.Year, t2Input.Month, 1, 0, 0, 0);
                    break;

                case "yr":
                case "wy":
                    t1Input = DateTime.Now.AddYears(t1Int);
                    t1Input = new DateTime(t1Input.Year, 1, 1, 0, 0, 0);
                    t2Input = DateTime.Now.AddYears(t2Int);
                    t2Input = new DateTime(t2Input.Year, 1, 1, 0, 0, 0);
                    break;

                default:
                    throw new Exception("Error: Invalid Query Time-Step.");
                }
            }
            else
            {
                throw new Exception("Error: Invalid Query Dates.");
            }

            var urlString = "?svr=" + svr
                            + "&sdi=" + sdi
                            + "&tstp=" + tstpString
                            + "&t1=" + t1Input.ToString("yyyy-MM-ddTHH\\:mm")
                            + "&t2=" + t2Input.ToString("yyyy-MM-ddTHH\\:mm")
                            + "&table=" + table.ToString()
                            + "&mrid=" + mrid
                            + "&format=" + format;
            List <string> result = cgiProcessor.get_cgi_data(db, urlString);

            var output   = String.Join <string>(String.Empty, result);
            var response = new HttpResponseMessage(HttpStatusCode.OK);

            response.Content = new StringContent(output, System.Text.Encoding.UTF8, "text/html");

            try
            {
                db.Close();
                db.Dispose();
            }
            catch
            {
            }

            return(response);
        }
示例#31
0
        /// <summary>
        /// create Put Sample File
        /// </summary>
        /// <param name="type"></param>
        /// <param name="dateTime"></param>
        /// <param name="ver"></param>
        public bool create(TableType type, string dateTime, int ver)
        {
            bool flag = false;

            try
            {
                List <string> data = new List <string>();

                SetFile f = new SetFile(type, dateTime);

                //ex: sampleA53_20170803
                string getFileName = f.getSampleFileName();

                #region File

                data.Add("START-OF-FILE");

                #region Title

                data.Add($"REPLYFILENAME={getFileName}");
                data.Add("PROGRAMNAME=getdata");
                data.Add("PROGRAMFLAG=" + f.getPROGRAMFLAG());
                data.Add("FIRMNAME=" + f.getFIRMNAME()); //確認是否提出來?
                data.Add("SECMASTER=YES");
                data.Add("OUTPUTFORMAT=bulklist");
                data.Add("DELIMITER=,");
                data.Add("FUNDAMENTALS=yes");

                #endregion Title

                //空一行
                data.Add(string.Empty);

                #region START-OF-FIELDS

                data.Add("START-OF-FIELDS");
                object obj      = null;
                bool   findFlag = false;
                if (TableType.A53.ToString().Equals(type.ToString()))
                {
                    obj      = new A53Sample();
                    findFlag = true;
                }
                if (findFlag)
                {
                    obj.GetType()
                    .GetProperties()
                    //.OrderBy(x => x.Name)
                    .ToList()
                    .ForEach(x => data.Add(x.Name));
                }
                data.Add("END-OF-FIELDS");

                #endregion START-OF-FIELDS

                //空一行
                data.Add(string.Empty);

                #region START-OF-DATA

                data.Add("START-OF-DATA");
                int           year  = Int32.Parse(dateTime.Substring(0, 4));
                int           month = Int32.Parse(dateTime.Substring(4, 2));
                int           day   = Int32.Parse(dateTime.Substring(6, 2));
                DateTime      date  = new DateTime(year, month, day);
                IFRS9Entities db    = new IFRS9Entities();
                db.Bond_Account_Info.AsNoTracking()
                .Where(x => x.Report_Date.HasValue &&
                       x.Report_Date.Value == date &&
                       x.Version.HasValue && x.Version == ver)
                .Select(x => x.Bond_Number).Distinct()
                .OrderBy(x => x)
                .ToList().ForEach(x =>
                {
                    if (!x.IsNullOrWhiteSpace())
                    {
                        data.Add(string.Format("{0}|ISIN", x));
                    }
                });
                db.Dispose();
                data.Add("END-OF-DATA");

                #endregion START-OF-DATA

                data.Add("END-OF-FILE");

                #endregion File

                //ex: ../samplePut 資料夾
                //f.putCommpanyFilePath();
                //ex: sampleA53_20170803
                //f.putSampleFileName();
                //建立 scv 檔案
                flag = new CreatePutFile().create(
                    f.putSampleFilePath(),
                    f.putSampleFileName(),
                    data);
            }
            catch
            {
                flag = false;
            }
            return(flag);
        }
示例#32
0
 public static T GetTableDataRow <T>(TableType tableType, string id) where T : new()
 {
     return((T)TableDataManager.Instance.GetTableData(tableType, id));
 }
示例#33
0
 static XElement GetValuesElement(int address, string unit, TableType tableType)
 {
     return(new XElement(X_values, new XAttribute(X_address, HexNum(address)), new XAttribute(X_unit, unit), new XAttribute(X_tableType, tableType.ToStr())));
 }
示例#34
0
 protected override TableType ParseTableType(List <string> header)
 {
     return(TableType.FromTableTypeDescriptions(TableTypeDescription.Regular));
 }
示例#35
0
 public DataTable GetTable(string value, TableType tableType = TableType.Predefined)
 {
     return(dbLayer.GetTable(value, tableType));
 }
示例#36
0
        public TableInfo(Worksheet sheet, string name, TableType type)
        {
            this.sheet = sheet;
            this.name  = name;
            this.type  = type;

            Cells cells = sheet.Cells;

            for (int i = cells.MinColumn; i < cells.MaxColumn; i++)
            {
                string head = cells[0, i].StringValue.Trim().ToLower();
                if (string.IsNullOrEmpty(head) || (!head.Contains("cs") && !head.Contains("cpp") && !head.Contains("lua")))
                {
                    continue;                                                                                                         //三种语言都不需要
                }
                string requireType = cells[1, i].StringValue.Trim().ToLower();
                if (string.IsNullOrEmpty(requireType))
                {
                    ShowError.RequireType("NULL", name, i);
                    continue;
                }
                FieldRequireType fieldRequireType = FieldRequireType.Optional;
                switch (requireType)
                {
                case "key":
                case "required":
                    fieldRequireType = FieldRequireType.Required;
                    break;

                case "optional":
                    fieldRequireType = FieldRequireType.Optional;
                    break;

                case "repeated":
                    fieldRequireType = FieldRequireType.Repeated;
                    break;

                default:
                    ShowError.RequireType(requireType, name, i);
                    continue;
                }
                string fieldType = cells[2, i].StringValue;
                ShowError.FieldType_ErrorMessageFmt = string.Format("{0}  ,在”{1}“的第 {2} 列", "{0}", name, i);
                if (!FieldType.ParseType(ref fieldType, fieldType))
                {
                    continue;
                }
                string fieldName = cells[3, i].StringValue.Trim();
                if (string.IsNullOrEmpty(fieldName))
                {
                    ShowError.FieldName("NULL(不能为空)", name, i);
                    continue;
                }
                string errorMsg = FieldInfo.CheckFieldName(fieldName);
                if (errorMsg != null)
                {
                    ShowError.FieldName(fieldName + errorMsg, name, i);
                    continue;
                }

                FieldInfo add = new FieldInfo
                {
                    col         = i,
                    language    = head,
                    requireType = fieldRequireType,
                    type        = fieldType,
                    name        = fieldName
                };

                fields.Add(add);

                if (requireType == "key")
                {
                    this.key = fieldName;
                }
            }
        }
示例#37
0
        public Table GetSchema(string tableName)
        {
            TableType tableType = TableType.Table;

            return(GetSchema(tableName, tableType));
        }
示例#38
0
        public async Task <ResponseViewModel <List <BusinessHourViewModel> > > Gets(long id, TableType type)
        {
            var returnResponse = new ResponseViewModel <List <BusinessHourViewModel> >();

            try
            {
                var url      = String.Format(AppointmentUserService.GET_BUSINESSHOURSBYTYPE, id, type);
                var response = await this.appointmentUserService.httpClient.GetAsync(url);

                returnResponse = await base.GetHttpResponse <List <BusinessHourViewModel> >(response);
            }
            catch (Exception ex)
            {
                returnResponse.Data    = null;
                returnResponse.Message = "Reason: " + ex.Message.ToString();
                returnResponse.Status  = false;
            }
            return(returnResponse);
        }
示例#39
0
 public void SetSource(TableType value)
 {
     tableType = value;
 }
示例#40
0
 public Token(TableType type)
     : this(type, 0)
 {
 }
示例#41
0
 public Token(TableType type)
     : this(type, 0)
 {
 }
示例#42
0
 public Token(TableType type, int rid)
 {
     token = (uint)type | (uint)rid;
 }
示例#43
0
        public void InitUIControls()
        {
            //### Border width
            for (int i = 0; i < mst_doubleLineWidths.Length; i++)
            {
                this.AddComboBorderWidth(mst_doubleLineWidths[i]);
            }

            //### Border/background collor
            for (int i = 0; i < mst_colorArray.Length; i++)
            {
                this.AddComboCollor(mst_colorArray[i]);
            }

            if (null != this.Table)
            {
                this.Rows    = this.Table.RowGroups[0].Rows.Count;
                this.Columns = this.Table.RowGroups[0].Rows[0].Cells.Count;
                this.m_txBxRows.IsEnabled = this.m_txBxColumns.IsEnabled = false;

                bool bFound = false;

                if (null != this.Table.BorderBrush)
                {
                    for (int i = 0; i < mst_colorArray.Length; i++)
                    {
                        if (null != this.Table.BorderBrush && mst_colorArray[i] == ((SolidColorBrush)this.Table.BorderBrush).Color)
                        {
                            this.m_comboBorderColor.SelectedIndex = i;
                            bFound = true;
                            break;
                        }
                    }

                    if (!bFound)
                    {
                        this.AddComboCollor(((SolidColorBrush)this.Table.BorderBrush).Color);
                    }
                }

                if (null != this.Table.BorderThickness && 0 < this.Table.BorderThickness.Left)
                {
                    bFound = false;
                    for (int i = 0; i < mst_doubleLineWidths.Length; i++)
                    {
                        if (mst_doubleLineWidths[i] == this.Table.BorderThickness.Left)
                        {
                            this.m_comboBorderWidth.SelectedIndex = i;
                            break;
                        }
                    }
                    if (!bFound)
                    {
                        this.AddComboBorderWidth(this.Table.BorderThickness.Left);
                    }
                }

                TableType tableType = (null != this.Table.Tag ? (TableType)this.Table.Tag : TableType.BoxBorder);
                switch (tableType)
                {
                case TableType.BoxBorder:
                    this.IsBoxBorder = true;
                    break;

                case TableType.FullBorder:
                    this.IsFullBorder = true;
                    break;

                case TableType.NoneBorder:
                    this.IsNoBorder = true;
                    break;

                default:
                    Debug.Assert(false, "Unexpected table type!");
                    break;
                }

                bool bIsAuto = false;
                foreach (TableColumn tableColumn in this.Table.Columns)
                {
                    if (GridLength.Auto == tableColumn.Width)
                    {
                        bIsAuto = true;
                        break;
                    }
                }
                if (!bIsAuto && 0 < this.Table.Columns.Count)
                {
                    this.CellWidth            = this.Table.Columns[0].Width.Value;
                    this.IsCellWidthAutomatic = false;
                }
            }
            else
            {
                this.m_comboBorderWidth.SelectedIndex = mst_iDefaultLineWidthIdx;
                this.m_comboBorderColor.SelectedIndex = mst_iDefaultBlackColorIdx;
                this.IsFullBorder = true;
            }
        }
示例#44
0
 public Table(string name, string schema, TableType type)
 {
     _actualName = name;
     _schema     = string.IsNullOrWhiteSpace(schema) ? null : schema;
     _type       = type;
 }
示例#45
0
 protected abstract void OnTableTypeChanged(TreeIter iter, TableType newTableType);
示例#46
0
        public int Import()
        {
            ServerConfiguration serverConfiguration = LoadServerConfiguration();

            if (serverConfiguration == null)
            {
                return(1);
            }
            string databaseFilePath = serverConfiguration.DatabaseFilePath;

            if (String.IsNullOrWhiteSpace(databaseFilePath))
            {
                Console.WriteLine("Database file path is not set in the server configuration file.");
                return(2);
            }
            if (!File.Exists(databaseFilePath))
            {
                Console.WriteLine($"Couldn't find the database file at {databaseFilePath}");
                return(3);
            }
            Console.WriteLine($"Opening database \"{databaseFilePath}\"...");
            LocalDatabase localDatabase = LocalDatabase.OpenDatabase(databaseFilePath);

            using (SqlDumpReader sqlDumpReader = new SqlDumpReader(importFilePath))
            {
                while (true)
                {
                    bool tableFound = false;
                    while (sqlDumpReader.ReadLine())
                    {
                        if (sqlDumpReader.CurrentLineCommand == SqlDumpReader.LineCommand.CREATE_TABLE)
                        {
                            Logger.Debug("CREATE TABLE statement found.");
                            Console.WriteLine("CREATE TABLE statement found.");
                            tableFound = true;
                            break;
                        }
                    }
                    if (!tableFound)
                    {
                        Logger.Debug("CREATE TABLE statement was not found.");
                        Console.WriteLine("CREATE TABLE statement was not found.");
                        return(4);
                    }
                    SqlDumpReader.ParsedTableDefinition parsedTableDefinition = sqlDumpReader.ParseTableDefinition();
                    TableType tableType = DetectImportTableType(parsedTableDefinition);
                    if (tableType == TableType.UNKNOWN)
                    {
                        Console.WriteLine($"Table {parsedTableDefinition.TableName} doesn't match any known supported formats. It will be skipped.");
                        continue;
                    }
                    Logger.Debug($"Table type is {tableType}.");
                    ImportFormat?detectedImportFormat = ConvertTableTypeToImportFormat(tableType);
                    if (!detectedImportFormat.HasValue)
                    {
                        Console.WriteLine("Could not determine the format of the database dump.");
                        return(5);
                    }
                    if (detectedImportFormat.Value == importFormat)
                    {
                        Console.WriteLine($"Found a matching import format: {ImportFormatToString(detectedImportFormat.Value)}.");
                    }
                    else
                    {
                        Console.WriteLine($"Expected the import format {importFormat} but found {ImportFormatToString(detectedImportFormat.Value)}.");
                        return(6);
                    }
                    bool insertFound = false;
                    while (sqlDumpReader.ReadLine())
                    {
                        if (sqlDumpReader.CurrentLineCommand == SqlDumpReader.LineCommand.INSERT)
                        {
                            Logger.Debug("INSERT statement found.");
                            insertFound = true;
                            break;
                        }
                    }
                    if (!insertFound)
                    {
                        Logger.Debug("INSERT statement was not found.");
                        Console.WriteLine("Couldn't find any data to import.");
                        return(7);
                    }
                    Importer importer;
                    BitArray existingLibgenIds = null;
                    int      existingBookCount = 0;
                    switch (tableType)
                    {
                    case TableType.NON_FICTION:
                        existingBookCount = localDatabase.CountNonFictionBooks();
                        if (existingBookCount != 0)
                        {
                            existingLibgenIds = localDatabase.GetNonFictionLibgenIdsBitArray();
                        }
                        importer = new NonFictionImporter(localDatabase, existingLibgenIds);
                        break;

                    case TableType.FICTION:
                        existingBookCount = localDatabase.CountFictionBooks();
                        if (existingBookCount != 0)
                        {
                            existingLibgenIds = localDatabase.GetFictionLibgenIdsBitArray();
                        }
                        importer = new FictionImporter(localDatabase, existingLibgenIds);
                        break;

                    case TableType.SCI_MAG:
                        existingBookCount = localDatabase.CountSciMagArticles();
                        if (existingBookCount != 0)
                        {
                            existingLibgenIds = localDatabase.GetSciMagLibgenIdsBitArray();
                        }
                        importer = new SciMagImporter(localDatabase, existingLibgenIds);
                        break;

                    default:
                        throw new Exception($"Unknown table type: {tableType}.");
                    }
                    bool updateProgressLine = false;
                    Importer.ImportProgressReporter importProgressReporter = (int objectsAdded, int objectsUpdated) =>
                    {
                        if (updateProgressLine)
                        {
                            Console.SetCursorPosition(0, Console.CursorTop - 1);
                        }
                        else
                        {
                            updateProgressLine = true;
                        }
                        if (objectsUpdated > 0)
                        {
                            Console.WriteLine($"Books added: {objectsAdded}, updated: {objectsUpdated}.");
                        }
                        else
                        {
                            Console.WriteLine($"Books added: {objectsAdded}.");
                        }
                    };
                    Logger.Debug("Importing data.");
                    Console.WriteLine("Importing data.");
                    importer.Import(sqlDumpReader, importProgressReporter, IMPORT_PROGRESS_UPDATE_INTERVAL, parsedTableDefinition);
                    DatabaseMetadata databaseMetadata = localDatabase.GetMetadata();
                    switch (tableType)
                    {
                    case TableType.NON_FICTION:
                        databaseMetadata.NonFictionFirstImportComplete = true;
                        break;

                    case TableType.FICTION:
                        databaseMetadata.FictionFirstImportComplete = true;
                        break;

                    case TableType.SCI_MAG:
                        databaseMetadata.SciMagFirstImportComplete = true;
                        break;
                    }
                    localDatabase.UpdateMetadata(databaseMetadata);
                    Logger.Debug("SQL dump import has been completed successfully.");
                    Console.WriteLine("SQL dump import has been completed successfully.");
                    return(0);
                }
            }
        }
示例#47
0
 public void BeginPlace(Mobile from, TableType type)
 {
     from.BeginTarget(-1, true, TargetFlags.None, new TargetStateCallback(Placement_OnTarget), type);
 }
示例#48
0
        /// <summary>
        /// 查询出列名
        /// </summary>
        /// <param name="connectionName">配置文件中的 name</param>
        /// <param name="tableName">表名</param>
        /// <param name="type">1.sql server  2.mysql</param>
        /// <returns></returns>
        public IList <string> GetColumnsName(string connectionName, string tableName, TableType type = TableType.SqlServer)
        {
            OperationResult <IList <string> > columnsNameResult = null;

            if (type == TableType.SqlServer)
            {
                SynPlanSqlServerBLL sqlServerBLL = new SynPlanSqlServerBLL(connectionName);
                columnsNameResult = sqlServerBLL.GetColumnsName(tableName);
            }
            else if (type == TableType.MySql)
            {
                SynPlanMySqlBLL mySqlBLL = new SynPlanMySqlBLL(connectionName);
                columnsNameResult = mySqlBLL.GetColumnsName(tableName);
            }

            if (columnsNameResult != null && columnsNameResult.ResultType == OperationResultType.Success)
            {
                return(columnsNameResult.AppendData);
            }
            else
            {
                Log(string.Format("From:{0} 数据库操作失败!原因:{1}", connectionName, columnsNameResult.Message));
                return(null);
            }
        }
示例#49
0
 public void ChangeTableType(Table2D table2D, TableType newType)
 {
     data.ChangeTableType(table2D, newType);
 }
示例#50
0
        /// <summary>
        /// Internal API constructor intended for Implementation classes, instead use <see cref="DiscoveredDatabase.ExpectTable"/> instead.
        /// </summary>
        /// <param name="database"></param>
        /// <param name="table"></param>
        /// <param name="querySyntaxHelper"></param>
        /// <param name="schema"></param>
        /// <param name="tableType"></param>
        public DiscoveredTable(DiscoveredDatabase database, string table, IQuerySyntaxHelper querySyntaxHelper, string schema = null, TableType tableType = TableType.Table)
        {
            _table    = table;
            Helper    = database.Helper.GetTableHelper();
            Database  = database;
            Schema    = schema;
            TableType = tableType;

            QuerySyntaxHelper = querySyntaxHelper;
        }
示例#51
0
 /**
 * Set as TableType
 */
 public override void SetAsTable(TableType Value)
 {
     objectValue = (Object) Value;
     setDBXType(DBXDataTypes.TableType);
 }
示例#52
0
        /// <summary>
        /// Select 分页查询
        /// </summary>
        /// <param name="page">当前页</param>
        /// <param name="pageNum">每页数量</param>
        /// <param name="pageOrder">row_number order</param>
        /// <param name="rowConds">row_number conditions</param>
        /// <param name="fields">需要查询的字段,可包含关键字和sql函数</param>
        /// <returns>结果集合</returns>
        public override IList <T> Select(int page, int pageNum, OrderBy pageOrder, IList <MYDBCondition> rowConds, params string[] fields)
        {
            StringBuilder sb     = new StringBuilder("select ");
            bool          first  = true;
            bool          isPage = false;

            try
            {
                if (page > 0 && pageOrder != null)
                {
                    isPage = true;
                }

                if (fields != null && fields.Length > 0)
                {
                    foreach (string s in fields)
                    {
                        if (!first)
                        {
                            sb.Append(",");
                        }
                        first = false;
                        if (TableType.GetProperty(s) == null)
                        {
                            sb.Append(s);
                        }
                        else
                        {
                            sb.Append(" [");
                            sb.Append(s);
                            sb.Append("] ");
                        }
                    }
                }
                else
                {
                    sb.Append(" * ");
                }

                if (isPage)
                {
                    StringBuilder sb1 = new StringBuilder();
                    if (rowConds != null)
                    {
                        foreach (MYDBCondition c in rowConds)
                        {
                            sb1.Append(c.ToQueryString());
                        }
                    }
                    sb.Append(string.Format("from (select *,row_number() over({0}) as row from [{1}] where 1 = 1 {2}) as t ", pageOrder.ToQueryString(), TableName, sb1.ToString()));
                }
                else
                {
                    sb.Append(" from [");
                    sb.Append(TableName);
                    sb.Append("] ");
                }

                if (joinQuery != null)
                {
                    sb.Append(joinQuery.ToString());
                    joinQuery.Length = 0;
                }

                sb.Append(" where 1 = 1 ");

                if (isPage)
                {
                    sb.Append(string.Format("and row between {0} and {1} ", (page - 1) * pageNum + 1, page * pageNum));
                }

                if (whereQuery != null)
                {
                    sb.Append(whereQuery.ToString());
                    whereQuery.Length = 0;
                }

                return(sqlDB.dbExe.ExeReaderToList <T>(null, sb.ToString(), selectParams));
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                selectParams = null;
            }
        }
示例#53
0
        public override void ChangeTypeToAndReload(TableType newType, System.IO.Stream stream)
        {
            tableType = newType;
            rangeZ.Size = newType.ValueSize () * this.CountZ;
            valuesZ = ReadValues (stream, rangeZ, tableType);

            this.valuesZasFloats = ValuesAsFloats (this.valuesZ);
            this.valuesZmin = valuesZasFloats.Min ();
            this.valuesZmax = valuesZasFloats.Max ();
            this.valuesZavg = valuesZasFloats.Average ();
        }
        protected override TableType ParseTableType(string[] handLines)
        {
            bool isCap = handLines[0].ToLower().Contains(" cap ");

            return(TableType.FromTableTypeDescriptions(isCap ? TableTypeDescription.Cap : TableTypeDescription.Regular));
        }
示例#55
0
        /// <summary>
        /// Determines the size of an index into the named table.
        /// </summary>
        /// <param name="tokenTypes">The table to determine the index for.</param>
        /// <returns>The index size in bytes.</returns>
        private int GetIndexSize(TableType table)
        {
            int _table = (int)table >> 24;
            if (_table < 0 || _table > TableCount)
                throw new ArgumentException(@"Invalid token type.");

            if (_rowCounts[_table] > 65535)
                return 4;

            return 2;
        }
示例#56
0
        /// <summary>
        /// Brukes til å merge commentar fil i ny versjon med master fra gammel til ny master
        /// </summary>
        public Merger()
        {
            Console.WriteLine(String.Format("Starter med versjon {0} på root {1}", versjon, root));
            Console.WriteLine("Press Enter for å kjøre eller stopp VS.");
            Console.ReadLine();

            myOut = new GrandMaster.GrandMaster();
            string mergeDir = root + @"\PCAxis.Sql\codegenerator2\Merge_Comments_and_oldMaster\";

            string file         = mergeDir + "old_master_" + versjon + ".xml";
            string commentsFile = mergeDir + "CommentsInModel_" + versjon + ".xml";
            string utFil        = mergeDir + "new_master_" + versjon + ".xml";

            System.IO.StreamWriter outFile = new System.IO.StreamWriter(utFil);

            XmlTextReader xmlReader  = new XmlTextReader(file);
            XmlTextReader xmlReader3 = new XmlTextReader(commentsFile);

            XmlSerializer oldMasterSerial = new XmlSerializer(typeof(GrandMaster.GrandMaster));
            XmlSerializer commentsSerial  = new XmlSerializer(typeof(CommentsInModel.CommentsInModel));

            XmlSerializer grandSerial = new XmlSerializer(typeof(GrandMaster.GrandMaster));

            myComments = (CommentsInModel.CommentsInModel)commentsSerial.Deserialize(xmlReader3);
            myMaster   = (GrandMaster.GrandMaster)oldMasterSerial.Deserialize(xmlReader);


            StringCollection lang1Tabs = new StringCollection();

            //codes
            int tmpi = 0;

            //myOut.Codes = myMaster.Codes;

            /*
             * myOut.Codes = new GrandMasterCode[myMaster.Codes.Length];
             * foreach (MasterCode mc in myMaster.Codes)
             * {
             *  GrandMasterCode gg = new GrandMasterCode();
             *  gg.codeName = mc.codeName;
             *  gg.defaultCodeValue = mc.defaultCodeValue;
             *
             *  myOut.Codes[tmpi] = gg;
             *  tmpi++;
             * }
             * //keywords
             * tmpi = 0;
             * myOut.Keywords = new GrandMasterKeyword[myMaster.Keywords.Length];
             * foreach (MasterKeyword mc in myMaster.Keywords)
             * {
             *  GrandMasterKeyword gg = new GrandMasterKeyword();
             *  gg.modelName = mc.modelName;
             *  if (mc.optionalSpecified)
             *  {
             *      gg.optionalSpecified = mc.optionalSpecified;
             *      gg.optional = mc.optional;
             *  }
             *  if(!String.IsNullOrEmpty(mc.defaultLocalName))
             *  {
             *      gg.defaultLocalName = mc.defaultLocalName;
             *  }
             *  myOut.Keywords[tmpi] = gg;
             *  tmpi++;
             * }
             */

            //comments fila bestemmer hvilke tabeller som skal med
            myOut.Tables       = new GrandMasterTables();
            myOut.Tables.Table = new TableType[myComments.Tables.Table.Length];
            tmpi = 0;

            foreach (Table commTable in myComments.Tables.Table)
            {
                TableType tt = new TableType();

                tt.modelName = commTable.name;

                tt.Description = commTable.Description;

                TableType oldMasterTable = getOldMaster(tt.modelName);
                bool      hasOldMaster   = (!(oldMasterTable == null));

                tt.Columns = this.getColumns(commTable.Columns, oldMasterTable);

                if (hasOldMaster)
                {
                    tt.alias   = oldMasterTable.alias;
                    tt.Comment = oldMasterTable.Comment;

                    tt.defaultAlias_lang2 = oldMasterTable.defaultAlias_lang2;

                    #region tt.generate
                    tt.generate = oldMasterTable.generate;

                    #endregion tt.generate

                    //tt.langType fixes this later, together with the new ones
                    //tt.modelName already in place;
                    tt.readBySqlDbConfig = oldMasterTable.readBySqlDbConfig;
                    //tt.tableName fixes this later, together with the new ones
                }

                myOut.Tables.Table[tmpi] = tt;
                tmpi++;
            }

            ///setter tabellenes langType og tableName
            ///
            foreach (TableType tt in myOut.Tables.Table)
            {
                tt.tableName = tt.modelName.ToUpper();

                bool minstEnKolHasSL = false;
                foreach (ColumnType ct in tt.Columns)
                {
                    if (ct.hasSL)
                    {
                        minstEnKolHasSL = true;
                    }
                }
                tt.hasSL = minstEnKolHasSL;
            }

            //outFile.WriteLine("11111sdfsdfsfds");

            grandSerial.Serialize(outFile, myOut);
            //outFile.WriteLine("22222sdfsdfsfds");
            //outFile.Flush();
            Console.Out.WriteLine("Wrote to file: " + utFil);
            Console.Out.WriteLine("OOOOOOOOOOOOOOOBS   KODER og KEYWORDS må legges inn for hånd!!!");
        }
示例#57
0
 /// <summary>
 /// Retrieves the number of rows in a specified table.
 /// </summary>
 /// <param name="token">The metadata token.</param>
 /// <returns>The row count in the table.</returns>
 /// <exception cref="System.ArgumentException">Invalid token type specified for table.</exception>
 public Token GetMaxTokenValue(TableType table)
 {
     return new Token(table, _rowCounts[((int)table >> 24)]);
 }
示例#58
0
        private void FillTables(Database database, string connectionString)
        {
            int         textInRow;
            Boolean     largeValues;
            Boolean     varDecimal;
            int         lastObjectId = 0;
            bool        isTable      = true;
            ISchemaBase item         = null;

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                using (SqlCommand command = new SqlCommand(TableSQLCommand.GetTableDetail(database.Info.Version), conn))
                {
                    conn.Open();
                    command.CommandTimeout = 0;
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            InitTableIndex(database, reader);
                            root.RaiseOnReadingOne(reader[TableNameIndex]);
                            if (lastObjectId != (int)reader[TableIdIndex])
                            {
                                lastObjectId = (int)reader[TableIdIndex];
                                isTable      = reader["ObjectType"].ToString().Trim().Equals("U");
                                if (isTable)
                                {
                                    item       = new Table(database);
                                    item.Id    = (int)reader[TableIdIndex];
                                    item.Name  = (string)reader[TableNameIndex];
                                    item.Owner = (string)reader[TableOwnerIndex];
                                    ((Table)item).HasClusteredIndex = (int)reader[HasClusteredIndexIndex] == 1;
                                    textInRow   = (int)reader[Text_In_Row_limitIndex];
                                    largeValues = (Boolean)reader[large_value_types_out_of_rowIndex];
                                    varDecimal  = ((int)reader[HasVarDecimalIndex]) == 1;
                                    if (database.Options.Ignore.FilterTableFileGroup)
                                    {
                                        ((Table)item).FileGroup     = (string)reader[FileGroupIndex];
                                        ((Table)item).FileGroupText = (string)reader[FileGroupTextIndex];
                                        if (database.Info.Version == DatabaseInfo.VersionTypeEnum.SQLServer2008)
                                        {
                                            if (database.Options.Ignore.FilterTableChangeTracking)
                                            {
                                                ((Table)item).FileGroupStream              = (string)reader[FileGroupStreamIndex];
                                                ((Table)item).HasChangeTracking            = ((int)reader[TableHasChangeTracking]) == 1;
                                                ((Table)item).HasChangeTrackingTrackColumn = ((int)reader[TableHasChangeTrackingTrackColumn]) == 1;
                                            }
                                        }
                                    }
                                    if (database.Options.Ignore.FilterTableOption)
                                    {
                                        if (textInRow > 0)
                                        {
                                            ((Table)item).Options.Add(new TableOption("TextInRow", textInRow.ToString(CultureInfo.InvariantCulture), item));
                                        }
                                        if (largeValues)
                                        {
                                            ((Table)item).Options.Add(new TableOption("LargeValues", "1", item));
                                        }
                                        if (varDecimal)
                                        {
                                            ((Table)item).Options.Add(new TableOption("VarDecimal", "1", item));
                                        }
                                    }
                                    if ((database.Options.Ignore.FilterTableLockEscalation) && (database.Info.Version == DatabaseInfo.VersionTypeEnum.SQLServer2008))
                                    {
                                        ((Table)item).Options.Add(new TableOption("LockEscalation", (string)reader[TableLockEscalation], item));
                                    }
                                    else
                                    {
                                        ((Table)item).Options.Add(new TableOption("LockEscalation", "TABLE", item));
                                    }
                                    database.Tables.Add((Table)item);
                                }
                                else
                                {
                                    item = new TableType(database)
                                    {
                                        Id    = (int)reader[TableIdIndex],
                                        Name  = (string)reader[TableNameIndex],
                                        Owner = (string)reader[TableOwnerIndex]
                                    };
                                    database.TablesTypes.Add((TableType)item);
                                }
                            }
                            if (isTable)
                            {
                                if (database.Options.Ignore.FilterTable)
                                {
                                    FillColumn((ITable <Table>)item, reader);
                                }
                            }
                            else
                            {
                                if (database.Options.Ignore.FilterUserDataType)
                                {
                                    FillColumn((ITable <TableType>)item, reader);
                                }
                            }
                        }
                    }
                }
            }
            //tables.ToSQL();
        }
示例#59
0
        /// <summary>
        /// Determines whether [is call target supported] [the specified target type].
        /// </summary>
        /// <param name="targetType">Type of the target.</param>
        /// <param name="flags">The flags.</param>
        /// <returns>
        /// 	<c>true</c> if [is call target supported] [the specified target type]; otherwise, <c>false</c>.
        /// </returns>
        private static bool IsCallTargetSupported(TableType targetType, InvokeSupportFlags flags)
        {
            bool result = false;

            if (targetType == TableType.MethodDef && InvokeSupportFlags.MethodDef == (flags & InvokeSupportFlags.MethodDef))
                result = true;
            else if (targetType == TableType.MemberRef && InvokeSupportFlags.MemberRef == (flags & InvokeSupportFlags.MemberRef))
                result = true;
            else if (targetType == TableType.MethodSpec && InvokeSupportFlags.MethodSpec == (flags & InvokeSupportFlags.MethodSpec))
                result = true;

            return result;
        }
示例#60
0
 public LayoutType(TableType currentLayout)
 {
     CurrentLayout = currentLayout;
 }