/// <summary> /// Initializes a new instance of the <see cref="RawTable{TKey, TValue}"/> class. /// </summary> /// <param name="other">The table to copy from.</param> RawTable(RawTable <TKey, TValue> other) { var bufferSize = GetCollectionSize(); _buffer = new TValue[bufferSize]; other._buffer.CopyTo(_buffer, 0); }
public void ReadTable() { if (mTableData == null) { mTableData = new RawTable(); } mTableData.readBinary(GetPath()); }
/// <summary> /// 通过聚合SQL加载整个聚合对象列表。 /// </summary> /// <param name="list">The list.</param> /// <param name="sql">The SQL.</param> internal void Query(EntityList list, string sql) { IDataTable dataTable = null; var repo = this._aggregateInfo.Items.First.Value.OwnerRepository; using (var db = RdbDataProvider.Get(repo).CreateDbAccesser()) { var table = db.RawAccesser.QueryDataTable(sql, CommandType.Text); dataTable = new RawTable(table); } //使用dataTable中的数据 和 AggregateDescriptor 中的描述信息,读取整个聚合列表。 this.ReadFromTable(list, dataTable, this._aggregateInfo.Items.First); }
public void ParseData() { _ParseData(); CheckHash(); mTableData = null; }
private void Populate() { Font boldFont = new Font(Font, FontStyle.Bold); Font boldUnderlineFont = new Font(Font, FontStyle.Bold | FontStyle.Underline); RawShape centreShape = new RawEntity(shapeCanvas1, Entity.Name, boldFont, Entity); List <RawShape> level1Shapes = new List <RawShape>(); List <RawShape> level3Shapes = new List <RawShape>(); List <RawShape> rightAlignedShapes = new List <RawShape>(); if (Entity.Parent == null) { RawShape emptyParent = new RawShape(shapeCanvas1, "Add parent...", boldUnderlineFont) { BackColor1 = Color.White, BackColor2 = Color.White, BorderColor = Color.Gray, ForeColor = Color.Gray, FocusForeColor = Color.Blue, FocusBackColor1 = Color.WhiteSmoke, FocusBackColor2 = Color.White, FocusBorderColor = Color.DarkGray, Cursor = Cursors.Hand, OriginatingLineStyle = null, //new LinkLine(boldFont, DashStyle.Dot, "", "", "", LineCaps.None, LineCaps.SolidArrow), Tag = null }; emptyParent.MouseClick += new MouseEventHandler(emptyParent_MouseClick); level1Shapes.Add(emptyParent); } else { RawEntity parentShape = new RawEntity(shapeCanvas1, Entity.Parent.Name, boldFont, Entity.Parent); parentShape.OriginatingLineStyle = new LinkLine(boldFont, DashStyle.Dot, "", "", "", LineCaps.None, LineCaps.SolidArrow); parentShape.MouseClick += new MouseEventHandler(parentShape_MouseClick); level1Shapes.Add(parentShape); foreach (var table in Entity.Parent.MappedTables()) { RawTable tableShape = new RawTable(shapeCanvas1, table.Name, boldFont, table); tableShape.OriginatingLineStyle = new LinkLine(boldFont, DashStyle.Dot, "", "", "", LineCaps.None, LineCaps.SolidArrow); tableShape.MouseClick += new MouseEventHandler(tableShape_MouseClick); rightAlignedShapes.Add(tableShape); } } foreach (var table in Entity.MappedTables()) { RawTable tableShape = new RawTable(shapeCanvas1, table.Name, boldFont, table); tableShape.OriginatingLineStyle = new LinkLine(boldFont, DashStyle.Dot, "", "", "", LineCaps.None, LineCaps.SolidArrow); tableShape.MouseClick += new MouseEventHandler(tableShape_MouseClick); rightAlignedShapes.Add(tableShape); } foreach (Entity child in Entity.Children) { RawEntity childShape = new RawEntity(shapeCanvas1, child.Name, boldFont, child); childShape.OriginatingLineStyle = new LinkLine(boldFont, DashStyle.Dot, "", "", "", LineCaps.None, LineCaps.SolidArrow); childShape.MouseClick += new MouseEventHandler(childShape_MouseClick); level3Shapes.Add(childShape); foreach (var table in child.MappedTables()) { RawTable tableShape = new RawTable(shapeCanvas1, table.Name, boldFont, table); tableShape.OriginatingLineStyle = new LinkLine(boldFont, DashStyle.Dot, "", "", "", LineCaps.None, LineCaps.SolidArrow); tableShape.MouseClick += new MouseEventHandler(tableShape_MouseClick); rightAlignedShapes.Add(tableShape); } } #region Add empty child RawShape emptyChild = new RawShape(shapeCanvas1, "Add child...", boldUnderlineFont) { BackColor1 = Color.White, BackColor2 = Color.White, BorderColor = Color.Gray, ForeColor = Color.Gray, FocusForeColor = Color.Blue, FocusBackColor1 = Color.WhiteSmoke, FocusBackColor2 = Color.White, FocusBorderColor = Color.DarkGray, Cursor = Cursors.Hand, Tag = null, OriginatingLineStyle = null //new LinkLine(boldFont, DashStyle.Dot, "", "", "", LineCaps.None, LineCaps.SolidArrow) }; emptyChild.MouseClick += new MouseEventHandler(emptyChild_MouseClick); //emptyChild.OriginatingLineStyle.MouseClick += new MouseEventHandler(OriginatingLineStyle_MouseClick); level3Shapes.Add(emptyChild); #endregion shapeCanvas1.BackColor = this.BackColor; shapeCanvas1.SwimLane1 = new ShapeCanvas.SwimLaneStyle(Color.FromArgb(100, 100, 100), Color.Black, Color.White, 90F, "Parent", ShapeCanvas.SwimLaneStyle.Styles.Line); shapeCanvas1.SwimLane2 = new ShapeCanvas.SwimLaneStyle(Color.FromArgb(100, 100, 100), Color.Black, Color.White, 90F, "Entity", ShapeCanvas.SwimLaneStyle.Styles.Line); shapeCanvas1.SwimLane3 = new ShapeCanvas.SwimLaneStyle(Color.FromArgb(100, 100, 100), Color.Black, Color.White, 90F, "Children", ShapeCanvas.SwimLaneStyle.Styles.Line); shapeCanvas1.SwimLane4 = new ShapeCanvas.SwimLaneStyle(Color.FromArgb(100, 100, 100), Color.Black, Color.White, 90F, "Mapped Tables", ShapeCanvas.SwimLaneStyle.Styles.Line); shapeCanvas1.BackColor = this.BackColor; shapeCanvas1.DrawVerticalSwimLanes(centreShape, level1Shapes, level3Shapes, rightAlignedShapes, "Parent", "Entity", "Children", "Mapped Tables"); }
public void ParseData() { _ParseData(); // CheckHash(); //暂时关闭hash检查 mTableData = null; }
private void Populate() { if (Table == null || BusyPopulating) { return; } try { BusyPopulating = true; Slyce.Common.Utility.SuspendPainting(this); bool hasMultiSchemas = Table.Database.GetSchemas().Count() > 1; //HideAllFloatingToolstrips(); Cursor = Cursors.WaitCursor; Font boldFont = new Font(Font, FontStyle.Bold); Font subTextFont = new Font(Font.FontFamily, Font.Size - 0.6F, FontStyle.Regular); MainShape = new RawTable(shapeCanvas1, Table.Name, boldFont, CategoryFont, PropertyFont, Table); if (hasMultiSchemas) { MainShape.SubText = string.Format(" ({0}) ", Table.Schema); } MainShape.FontSubText = subTextFont; MainShape.Icon = Table.IsView ? ViewImage : TableImage; //MainShape.Enter += new EventHandler(centreShape_Enter); //MainShape.Leave += new EventHandler(centreShape_Leave); MainShape.MouseClick += new MouseEventHandler(centreShape_MouseClick); CategoryColumns.Parent = MainShape; CategoryColumns.Properties.Clear(); MainShape.Categories.Add(CategoryColumns); if (Table.Columns.Count > 0) { foreach (var column in Table.Columns) { RawProperty prop = new RawProperty(column.Name, column); if (column.InPrimaryKey) { prop.ImageColor = Color.OrangeRed; prop.ImageType = RawProperty.ImageTypes.Key; } prop.Click += new MouseEventHandler(Column_Click); prop.DoubleClick += new MouseEventHandler(Column_DoubleClick); CategoryColumns.Properties.Add(prop); } } List <RawShape> bottomLevelShapes = new List <RawShape>(); List <RawShape> rightAlignedShapes = new List <RawShape>(); Font boldUnderlineFont = new Font(Font, FontStyle.Bold | FontStyle.Underline); //TheEntity.Discriminator.RootGrouping. #region Mapped Entities if (ShowMappedEntities) { foreach (EntityImpl entity in MappedEntities.OrderBy(e => e.Name)) { RawEntity entityShape = new RawEntity(shapeCanvas1, entity.Name, boldFont, entity); CustomLineCap startCap = LineCaps.None; //.SolidArrow; CustomLineCap endCap = LineCaps.None; entityShape.OriginatingLineStyle.LineStyle = DashStyle.Solid; entityShape.Cursor = Cursors.Hand; //entityShape.OriginatingLineStyle.MiddleText = GetDiscriminatorText(entityShape); entityShape.OriginatingLineStyle.StartCap = startCap; entityShape.OriginatingLineStyle.EndCap = endCap; //entityShape.BackColor1 = Color.Blue; //entityShape.BackColor2 = Color.DarkBlue; //entityShape.RoundedCorners = false; entityShape.Tag = entity; entityShape.Icon = EntityImage; string discriminatorText = GetDiscriminatorText(entity); entityShape.OriginatingLineStyle.MiddleText = discriminatorText; if (string.IsNullOrEmpty(discriminatorText)) { entityShape.OriginatingLineStyle.MiddleImage = FilterImageDisabled; entityShape.OriginatingLineStyle.MiddleImageFocused = FilterImageDisabled; } else { entityShape.OriginatingLineStyle.MiddleImage = FilterImage; entityShape.OriginatingLineStyle.MiddleImageFocused = FilterImageFocused; } entityShape.OriginatingLineStyle.MouseClick += new MouseEventHandler(OriginatingLineStyle_MouseClick); entityShape.MouseClick += new MouseEventHandler(entityShape_MouseClick); entityShape.OriginatingLineStyle.MiddleImageClick += new MouseEventHandler(MapLine_MiddleImageClick); entityShape.OriginatingLineStyle.ForeColor = Color.White; entityShape.OriginatingLineStyle.DataObject = entity; entityShape.OriginatingLineStyle.ShowMiddleTextOnlyWhenFocused = true; //entityShape.Enter += new EventHandler(entityShape_Enter); //entityShape.Leave += new EventHandler(entityShape_Leave); entityShape.MouseDoubleClick += new MouseEventHandler(entityShape_MouseDoubleClick); //#region Setup discriminator //if (Table.Discriminator != null && Table.Discriminator.RootGrouping != null) //{ // ArchAngel.Providers.EntityModel.Model.DatabaseLayer.Discrimination.Condition firstCondition = Table.Discriminator.RootGrouping.Conditions.ElementAtOrDefault(0); // if (firstCondition != null) // { // IColumn column = firstCondition.Column; // ArchAngel.Providers.EntityModel.Model.DatabaseLayer.Discrimination.Operator op = firstCondition.Operator; // string exprText = firstCondition.ExpressionValue.Value; // } //} //#endregion //tableShape.OriginatingLineStyle.MiddleImageMouseOver += new EventHandler(OriginatingLineStyle_MiddleImageMouseOver); rightAlignedShapes.Add(entityShape); } #region Add empty entity Slyce.Common.Controls.Diagramming.Shapes.RawShape emptyEntity = new Slyce.Common.Controls.Diagramming.Shapes.RawShape(shapeCanvas1, "Map entity...", boldUnderlineFont) { BackColor1 = Color.White, BackColor2 = Color.White, BorderColor = Color.Gray, ForeColor = Color.Gray, FocusForeColor = Color.Blue, FocusBackColor1 = Color.WhiteSmoke, FocusBackColor2 = Color.White, FocusBorderColor = Color.DarkGray, Cursor = Cursors.Hand, Tag = null, RoundedCorners = false, OriginatingLineStyle = null //new LinkLine(boldFont, DashStyle.Dot, "", "", "", LineCaps.None, LineCaps.SolidArrow) }; emptyEntity.MouseClick += new MouseEventHandler(emptyEntity_MouseClick); //emptyTable.OriginatingLineStyle.MouseClick += new MouseEventHandler(OriginatingLineStyle_MouseClick); rightAlignedShapes.Add(emptyEntity); #endregion } #endregion #region Relationships if (ShowRelatedtables) { foreach (Relationship relationship in Table.Relationships.OrderBy(r => r.PrimaryTable == Table ? r.ForeignTable.Name : r.PrimaryTable.Name)) { RawShape relatedTableShape; CustomLineCap startCap; CustomLineCap endCap; if (relationship.PrimaryTable == Table) { relatedTableShape = new RawTable(shapeCanvas1, relationship.ForeignTable.Name, boldFont, relationship.ForeignTable); if (hasMultiSchemas) { relatedTableShape.SubText = string.Format(" ({0}) ", relationship.ForeignTable.Schema); } string end1 = relationship.PrimaryKey.IsUnique ? "1" : "m"; endCap = relationship.ForeignKey.IsUnique ? LineCaps.One : LineCaps.Many; startCap = relationship.PrimaryKey.IsUnique ? LineCaps.One : LineCaps.Many; relatedTableShape.OriginatingLineStyle.MiddleImageClick += new MouseEventHandler(OriginatingLineStyle_MiddleImageClick2); relatedTableShape.Icon = relationship.ForeignTable.IsView ? ViewImage : TableImage; } else if (relationship.ForeignTable == Table) { relatedTableShape = new RawTable(shapeCanvas1, relationship.PrimaryTable.Name, boldFont, relationship.PrimaryTable); if (hasMultiSchemas) { relatedTableShape.SubText = string.Format(" ({0}) ", relationship.PrimaryTable.Schema); } string end1 = relationship.ForeignKey.IsUnique ? "1" : "m"; endCap = relationship.PrimaryKey.IsUnique ? LineCaps.One : LineCaps.Many; startCap = relationship.ForeignKey.IsUnique ? LineCaps.One : LineCaps.Many; relatedTableShape.OriginatingLineStyle.MiddleImageClick += new MouseEventHandler(OriginatingLineStyle_MiddleImageClick2); relatedTableShape.Icon = relationship.PrimaryTable.IsView ? ViewImage : TableImage; } else { throw new Exception("What the...??!"); } relatedTableShape.FontSubText = subTextFont; if (relationship.IsUserDefined) { relatedTableShape.OriginatingLineStyle.LineStyle = DashStyle.Dash; relatedTableShape.OriginatingLineStyle.LineColor = Color.Yellow; } else { relatedTableShape.OriginatingLineStyle.LineStyle = DashStyle.Solid; } relatedTableShape.Cursor = Cursors.Hand; relatedTableShape.OriginatingLineStyle.StartCap = startCap; relatedTableShape.OriginatingLineStyle.EndCap = endCap; relatedTableShape.OriginatingLineStyle.DataObject = relationship; relatedTableShape.OriginatingLineStyle.ForeColor = Color.White; relatedTableShape.OriginatingLineStyle.MiddleImage = InfoImage; relatedTableShape.MouseClick += new MouseEventHandler(referencedEntityShape_MouseClick); relatedTableShape.MouseDoubleClick += new MouseEventHandler(referencedEntityShape_MouseDoubleClick); bottomLevelShapes.Add(relatedTableShape); } // Add empty relationship RawShape emptyTable = new RawShape(shapeCanvas1, "Add relationship...", boldUnderlineFont) { BackColor1 = Color.White, BackColor2 = Color.White, BorderColor = Color.Gray, ForeColor = Color.Gray, FocusForeColor = Color.Blue, FocusBackColor1 = Color.WhiteSmoke, FocusBackColor2 = Color.White, FocusBorderColor = Color.DarkGray, Cursor = Cursors.Hand, OriginatingLineStyle = null, Tag = null }; emptyTable.MouseClick += new MouseEventHandler(emptyTable_MouseClick); bottomLevelShapes.Add(emptyTable); } #endregion shapeCanvas1.SwimLane1 = new ShapeCanvas.SwimLaneStyle(Color.FromArgb(79, 124, 205), Color.Black, Color.White, 0F, "Related Tables", ShapeCanvas.SwimLaneStyle.Styles.Fill); shapeCanvas1.SwimLane3 = new ShapeCanvas.SwimLaneStyle(Color.FromArgb(79, 124, 205), Color.Black, Color.White, 180F, "Mapped Entities", ShapeCanvas.SwimLaneStyle.Styles.Fill); shapeCanvas1.SwimLane4 = new ShapeCanvas.SwimLaneStyle(Color.FromArgb(79, 124, 205), Color.Black, Color.White, 90F, "Mapped Entities", ShapeCanvas.SwimLaneStyle.Styles.Fill); shapeCanvas1.BackColor = this.BackColor; //shapeCanvas1.DrawStar(centreShape, outerShapes); //shapeCanvas1.DrawThreeLayerHorizontal(centreShape, null, outerShapes, false); shapeCanvas1.Height = this.Height; //shapeCanvas1.DrawThreeLayerVertical(centreShape, null, bottomLevelShapes, rightAlignedShapes); shapeCanvas1.KeepMainShapeCentered = true; shapeCanvas1.DrawThreeLayerHorizontal(MainShape, bottomLevelShapes, rightAlignedShapes, KeepMainShapeFull); //shapeCanvas1.Focus(); } finally { this.AutoScrollPosition = ScrollPosition; Slyce.Common.Utility.ResumePainting(this); Cursor = Cursors.Default; BusyPopulating = false; this.Focus(); shapeCanvas1.Focus(); } }
private static void FormatTable(ExcelWorksheet sectionSheet, int xOffset, int yOffset, RawTable table) { for (var columnIndex = 0; columnIndex < table.Columns.Count; columnIndex++) { sectionSheet.Cells[yOffset, xOffset + columnIndex].Value = table.Columns[columnIndex]; } yOffset++; for (var rowIndex = 0; rowIndex < table.Rows.Count; rowIndex++) { for (var columnIndex = 0; columnIndex < table.Columns.Count; columnIndex++) { if (!table.Rows[rowIndex].Fields.TryGetValue(table.Columns[columnIndex], out var fieldValue)) { Console.WriteLine($"Warning: missing field {table.Columns[columnIndex]} at row {table.Rows[rowIndex].StartRow}"); fieldValue = null; } sectionSheet.Cells[yOffset + rowIndex, xOffset + columnIndex].Value = fieldValue; } } }
private static int WriteParentTable(ExcelWorksheet sectionSheet, int xOffset, int yOffset, RawTable table) { var hasRows = table.Rows.Any(); var hasTables = table.ChildTables.Any(); if (hasRows && hasTables) { throw new NotImplementedException($"Formatting tables with both rows and subtables is not supported"); } FormatTable(sectionSheet, xOffset, yOffset, table); if (hasTables) { foreach (var subtable in table.ChildTables) { FormatTable(sectionSheet, xOffset, yOffset + 1, subtable); xOffset += subtable.Columns.Count + 2; } } if (!hasTables) { xOffset += table.Columns.Count + 2; } return(xOffset); }
private void DrawThreeLayers() { if (Table == null) { return; } Cursor = Cursors.WaitCursor; Font boldFont = new Font(Font, FontStyle.Bold); Font boldUnderlineFont = new Font(Font, FontStyle.Bold | FontStyle.Underline); RawTable centreShape = new RawTable(Table.Name, boldFont, Table); centreShape.Icon = TableImage; centreShape.MouseClick += new MouseEventHandler(centreShape_MouseClick); List <RawShape> topLevelShapes = new List <RawShape>(); List <RawShape> bottomLevelShapes = new List <RawShape>(); foreach (Relationship relationship in Table.Relationships) { RawShape referencedEntityShape; CustomLineCap startCap; CustomLineCap endCap; if (relationship.PrimaryTable == Table) { referencedEntityShape = new RawTable(relationship.ForeignTable.Name, boldFont, relationship.ForeignTable); string end1 = relationship.PrimaryKey.IsUnique ? "1" : "m"; startCap = relationship.ForeignKey.IsUnique ? LineCaps.One : LineCaps.Many; endCap = relationship.PrimaryKey.IsUnique ? LineCaps.One : LineCaps.Many; } else if (relationship.ForeignTable == Table) { referencedEntityShape = new RawTable(relationship.PrimaryTable.Name, boldFont, relationship.PrimaryTable); string end1 = relationship.ForeignKey.IsUnique ? "1" : "m"; startCap = relationship.PrimaryKey.IsUnique ? LineCaps.One : LineCaps.Many; endCap = relationship.ForeignKey.IsUnique ? LineCaps.One : LineCaps.Many; } else { throw new Exception("What the...??!"); } referencedEntityShape.Icon = TableImage; referencedEntityShape.OriginatingLineStyle.LineStyle = DashStyle.Solid; referencedEntityShape.OriginatingLineStyle.StartCap = startCap; referencedEntityShape.OriginatingLineStyle.EndCap = endCap; referencedEntityShape.OriginatingLineStyle.DataObject = relationship; referencedEntityShape.OriginatingLineStyle.ForeColor = Color.White; referencedEntityShape.OriginatingLineStyle.MiddleImage = InfoImage; referencedEntityShape.OriginatingLineStyle.MiddleImageClick += new MouseEventHandler(OriginatingLineStyle_MiddleImageClick); bottomLevelShapes.Add(referencedEntityShape); } //// Add empty reference //RawShape emptyReference = new RawShape("Add relationship...", boldUnderlineFont) //{ // BackColor1 = Color.White, // BackColor2 = Color.White, // BorderColor = Color.Gray, // ForeColor = Color.Gray, // FocusForeColor = Color.Blue, // FocusBackColor1 = Color.WhiteSmoke, // FocusBackColor2 = Color.White, // FocusBorderColor = Color.DarkGray, // Cursor = Cursors.Hand, // OriginatingLineStyle = null,// new LinkLine(boldFont, DashStyle.Dot, "", "", "", LineCaps.None, LineCaps.SolidArrow), // Tag = null //}; //emptyReference.MouseClick += new MouseEventHandler(emptyReference_MouseClick); //bottomLevelShapes.Add(emptyReference); //if (vertical) // canvas1.DrawThreeLayerVertical(centreShape, topLevelShapes, bottomLevelShapes); //else shapeCanvas1.BackColor = this.BackColor; //shapeCanvas1.DrawThreeLayerHorizontal(centreShape, topLevelShapes, bottomLevelShapes, true); shapeCanvas1.Height = this.Height; //shapeCanvas1.DrawStar(centreShape, bottomLevelShapes); shapeCanvas1.KeepMainShapeFull = KeepMainShapeFull; shapeCanvas1.DrawThreeLayerVertical(centreShape, null, bottomLevelShapes); Cursor = Cursors.Default; }