/// <summary> /// Constructs the actual query /// </summary> /// <returns>Full insert AND delete queries</returns> public string Build() { // If we only have rows with comment, do not print any query if (Rows.All(row => row.NoData)) // still true if row count = 0 { return("-- " + SQLUtil.AddBackQuotes(Table) + " has empty data." + Environment.NewLine); } var query = new StringBuilder(); query.Append(Delete); // Can be empty query.Append(InsertHeader); var count = 0; foreach (var row in Rows) { if (count >= MaxRowsPerInsert) { query.ReplaceLast(',', ';'); query.Append(InsertHeader); count = 0; } query.Append(row.Build()); count++; } query.Append(Environment.NewLine); return(query.ReplaceLast(',', ';').ToString()); }
private bool CanAutoImport() { if (Rows.All(_ => _.RntDTO == null)) { return(true); } return(false); }
public bool IsComplete() { bool rtVal = false; rtVal = Rows.All(x => x.IsComplete()); rtVal &= Columns.All(x => x.IsComplete()); return(rtVal); }
protected void ObjectInvariant() { Contract.Invariant(Header.Width > 0); Contract.Invariant(Header.Height > 0); Contract.Invariant(Header.BytesPerPixelComponent > 0); Contract.Invariant(Rows.Count() == Header.Height); Contract.Invariant(Rows.All(row => row.Count() == Header.Width * Header.Components.Count)); Contract.Invariant(Rows.All(row => row.All(IsPixelComponentInRange))); }
/// <summary> /// 获得 表头行是否选中状态 /// </summary> /// <returns></returns> protected CheckboxState HeaderCheckState() { var ret = CheckboxState.UnChecked; if (Rows.Any() && Rows.All(i => SelectedRows.Contains(i))) { ret = CheckboxState.Checked; } else if (Rows.Any(i => SelectedRows.Contains(i))) { ret = CheckboxState.Mixed; } return(ret); }
public Size CalculateAutoScrollSize(Size autoScrollMinSize, Size size, VScrollProperties verticalScroll) { Size autoScrollSize = this.autoScrollMinSize; //Dynamically adjust width if (verticalScroll.Visible) { autoScrollSize.Width = size.Width - SystemInformation.VerticalScrollBarWidth; } else { autoScrollSize.Width = size.Width; } int timeDivisions = (EndHourInDay - StartHourInDay) * (EndDate - StartDate).Days; int pixelsPerDivision = autoScrollSize.Width / timeDivisions; if (pixelsPerDivision < MinTimeIntervalWidth) { if (verticalScroll.Visible) { autoScrollSize.Width = timeDivisions * MinTimeIntervalWidth - SystemInformation.VerticalScrollBarWidth; } else { autoScrollSize.Width = timeDivisions * MinTimeIntervalWidth; } } //Dynamically adjust height if (Rows.Count > 0 && Rows.All(p => p.Rect != null)) { int highestYValue = Rows.Select(p => { return(p.Rect.Bottom); }).Max(); autoScrollSize.Height = highestYValue + 1; } else { autoScrollSize.Height = size.Height; } if (autoScrollMinSize != autoScrollSize) { autoScrollMinSize = autoScrollSize; } return(autoScrollMinSize); }
protected override async Task OnRefreshClickedAsync() { await Rows.Fill(this); if (!Rows.Any()) { this.CloseWindow(); } if (Rows.All(_ => _.AreEqual)) { this.CloseWindow(); } if (CanAutoImport()) { ImportCmd.ExecuteIfItCan(); } }
/// <summary> /// Constructs the actual query /// </summary> /// <returns>Full insert AND delete queries</returns> public string Build() { // If we only have rows with comment, do not print any query if (Rows.All(row => row.NoData)) // still true if row count = 0 { return("-- " + SQLUtil.AddBackQuotes(Table) + " has empty data." + Environment.NewLine); } var query = new StringBuilder(); query.Append(Delete); // Can be empty query.Append(InsertHeader); var count = 0; foreach (var row in Rows) { if (count >= MaxRowsPerInsert && !_deleteDuplicates) { query.ReplaceLast(',', ';'); query.Append(InsertHeader); count = 0; } query.Append(row.Build()); count++; } query.Append(Environment.NewLine); // This is easier to implement that comparing raw objects in each row // and certainly faster. Imagine comparing 1k rows of <string, int, int, emote, YouGotIt> if (_deleteDuplicates) { var str = String.Join("\n", query.ToString().Split('\n').Distinct()); // Do not use Enviroment.NewLine query.Clear(); query.Append(str); } query.ReplaceLast(',', ';'); return(query.ToString()); }
public SourceTable GetSourceTable(HtmlExtractorBase htmlExtractor) { Boolean AddHeaderRow = false; Boolean AddContextColumn = false; Int32 Height = Rows.Count; if (ColumnContextTakes.Cells.items.Any()) { Height++; AddHeaderRow = true; } Int32 Width = 0; if (Rows.Any()) { Width = Rows.Max(x => x.Cells.Count); } if (Rows.All(x => x.RowContextTake != null)) { Width++; AddContextColumn = true; } SourceTable output = new SourceTable(Width, Height); Int32 ri = 0; if (AddHeaderRow) { for (int i = 0; i < ColumnContextTakes.Cells.Count; i++) { //Int32 rx = i; RecordTemplateItemTake take = (RecordTemplateItemTake)ColumnContextTakes.Cells.items[i]; //String takeSubPath = ItemDescriptors.ValueCellSubXPath[i]; //Int32 rx = ItemDescriptors.CellIndex(takeSubPath, AddContextColumn); Int32 rx = ItemDescriptors.CellIndex(take, AddContextColumn); if (rx > -1) { htmlExtractor.SetSourceTableCell(output[rx, ri], take.SelectedNode, null); } //if (AddContextColumn) //{ // rx++; //} } ri++; } foreach (var row in Rows) { if (AddContextColumn) { if (row.RowContextTake != null) { htmlExtractor.SetSourceTableCell(output[0, ri], row.RowContextTake.SelectedNode, null); } } foreach (var take in row.Cells.items) { Int32 rx = ItemDescriptors.CellIndex(take, AddContextColumn); if (rx < output.Width) { htmlExtractor.SetSourceTableCell(output[rx, ri], take.SelectedNode, null); } } ri++; } output = output.GetDistinctRows(); return(output); }
public void Within_50ms() { var rows = Rows.All(); Speed.Runs(() => Blocks.Init(rows, null), 1, TimeSpan.FromMilliseconds(50)); }
public void Columns_have_values_between_7_and_10(int columns, Shape shape, Rotation rotation) { Assert.AreEqual(columns, Rows.All().Columns(shape, rotation)); }
public void MergeCells(ITableCell inputCell1, ITableCell inputCell2) // TODO: Optimize method { SCTableCell cell1 = (SCTableCell)inputCell1; SCTableCell cell2 = (SCTableCell)inputCell2; if (CannotBeMerged(cell1, cell2)) { return; } int minRowIndex = cell1.RowIndex < cell2.RowIndex ? cell1.RowIndex : cell2.RowIndex; int maxRowIndex = cell1.RowIndex > cell2.RowIndex ? cell1.RowIndex : cell2.RowIndex; int minColIndex = cell1.ColumnIndex < cell2.ColumnIndex ? cell1.ColumnIndex : cell2.ColumnIndex; int maxColIndex = cell1.ColumnIndex > cell2.ColumnIndex ? cell1.ColumnIndex : cell2.ColumnIndex; // Horizontal merging List <A.TableRow> aTableRowList = this.ATable.Elements <A.TableRow>().ToList(); if (minColIndex != maxColIndex) { int horizontalMergingCount = maxColIndex - minColIndex + 1; for (int rowIdx = minRowIndex; rowIdx <= maxRowIndex; rowIdx++) { A.TableCell[] rowATblCells = aTableRowList[rowIdx].Elements <A.TableCell>().ToArray(); A.TableCell firstMergingCell = rowATblCells[minColIndex]; firstMergingCell.GridSpan = new Int32Value(horizontalMergingCount); Span <A.TableCell> nextMergingCells = new Span <A.TableCell>(rowATblCells, minColIndex + 1, horizontalMergingCount - 1); foreach (A.TableCell aTblCell in nextMergingCells) { aTblCell.HorizontalMerge = new BooleanValue(true); MergeParagraphs(minRowIndex, minColIndex, aTblCell); } } } // Vertical merging if (minRowIndex != maxRowIndex) { // Set row span value for the first cell in the merged cells int verticalMergingCount = maxRowIndex - minRowIndex + 1; IEnumerable <A.TableCell> rowSpanCells = aTableRowList[minRowIndex].Elements <A.TableCell>() .Skip(minColIndex) .Take(maxColIndex + 1); foreach (A.TableCell aTblCell in rowSpanCells) { aTblCell.RowSpan = new Int32Value(verticalMergingCount); } // Set vertical merging flag foreach (A.TableRow aTblRow in aTableRowList.Skip(minRowIndex + 1).Take(maxRowIndex)) { foreach (A.TableCell aTblCell in aTblRow.Elements <A.TableCell>().Take(maxColIndex + 1)) { aTblCell.VerticalMerge = new BooleanValue(true); MergeParagraphs(minRowIndex, minColIndex, aTblCell); } } } // Delete a:gridCol and a:tc elements if all columns are merged for (int colIdx = 0; colIdx < Columns.Count;) { int?gridSpan = ((SCTableCell)Rows[0].Cells[colIdx]).ATableCell.GridSpan?.Value; if (gridSpan > 1 && Rows.All(row => ((SCTableCell)row.Cells[colIdx]).ATableCell.GridSpan?.Value == gridSpan)) { int deleteColumnCount = gridSpan.Value - 1; // Delete a:gridCol elements foreach (Column column in Columns.Skip(colIdx + 1).Take(deleteColumnCount)) { column.AGridColumn.Remove(); Columns[colIdx].Width += column.Width; // append width of deleting column to merged column } // Delete a:tc elements foreach (A.TableRow aTblRow in aTableRowList) { IEnumerable <A.TableCell> removeCells = aTblRow.Elements <A.TableCell>().Skip(colIdx).Take(deleteColumnCount); foreach (A.TableCell aTblCell in removeCells) { aTblCell.Remove(); } } colIdx += gridSpan.Value; continue; } colIdx++; } // Delete a:tr for (int rowIdx = 0; rowIdx < Rows.Count;) { int?rowSpan = ((SCTableCell)Rows[rowIdx].Cells[0]).ATableCell.RowSpan?.Value; if (rowSpan > 1 && Rows[rowIdx].Cells.All(c => ((SCTableCell)c).ATableCell.RowSpan?.Value == rowSpan)) { int deleteRowsCount = rowSpan.Value - 1; // Delete a:gridCol elements foreach (SCTableRow row in Rows.Skip(rowIdx + 1).Take(deleteRowsCount)) { row.ATableRow.Remove(); Rows[rowIdx].Height += row.Height; } rowIdx += rowSpan.Value; continue; } rowIdx++; } rowCollection.Reset(); }
public override bool IsConstantExpression() { return(Rows.All(i => i.All(j => j.IsConstantExpression()))); }
public void Rows_have_4_bit() { Assert.AreEqual(0, Rows.All().Count(rows => rows.Count() != 4)); }
public void Contains_213_rows() { Assert.AreEqual(213, Rows.All().ToArray().Length); }
public void Are_initialized_within_5ms() { Speed.Runs(() => Rows.All(), 1, TimeSpan.FromMilliseconds(5)); }
private bool IsValidateTable() => Columns.Any() && Rows.Any() && Columns.All(c => c.CategoryType == CategoryType.Column || c.CategoryType == CategoryType.Interchangeable) && Rows.All(r => r.CategoryType == CategoryType.Row || r.CategoryType == CategoryType.Interchangeable) && IntersectionCount >= AllCategoriesIntersectionCount;
public bool IsValid() { return(Rows.All(CellCollectionIsValid) && Columns.All(CellCollectionIsValid) && Groups.All(CellCollectionIsValid)); }