public PathNode(int x, int y, TCell cellObject) { X = x; Y = y; CellObject = cellObject; G = int.MaxValue; }
public void GetHBaseImage(string rowKey = "20150822180801118") { var socket = new TSocket(hbaseThrif, hbaseThrifPort); var transport = new TBufferedTransport(socket); var protocol = new TBinaryProtocol(transport); Hbase.Client hbaseClient = new Hbase.Client(protocol); transport.Open(); //List<byte[]> tableNames = hc.getTableNames(); byte[] table = Encoding.UTF8.GetBytes("FiservImages"); byte[] row = Encoding.UTF8.GetBytes(rowKey); byte[] column = Encoding.UTF8.GetBytes("ImageData:Image"); List<TRowResult> results = hbaseClient.getRow(table, row, null); TCell t = new TCell(); //t. foreach (TRowResult result in results) { //result.Columns[column] //result.Columns; Dictionary<byte[], TCell> konj; konj = result.Columns; //string s = Encoding.UTF8.GetString(result.Columns[column].Value); foreach (KeyValuePair<byte[], TCell> singleRow in konj) { //File.WriteAllBytes(@"c:\test\output.docx", singleRow.Value.Value); OpenFile(singleRow.Value.Value, "output.docx"); } } }
private MapSection Visit(TCell cell) { Stack <TCell> stack = new Stack <TCell>(new List <TCell>()); MapSection mapSection = new MapSection(); stack.Push(cell); while (stack.Count != 0) { cell = stack.Pop(); if (_visited[cell.Y][cell.X] || !cell.IsWalkable) { continue; } mapSection.AddCell(cell); _visited[cell.Y][cell.X] = true; foreach (TCell neighbor in GetNeighbors(cell)) { if (cell.IsWalkable == neighbor.IsWalkable && !_visited[neighbor.Y][neighbor.X]) { stack.Push(neighbor); } } } return(mapSection); }
public int GetHashCode(TEdge obj) { TCell source = obj.Source; int hashCode = source.GetHashCode(); TCell target = obj.Target; return(hashCode ^ target.GetHashCode()); }
public void Set(TCell tCell, string key) { if (_tCell != tCell) { SolveLog.Instance.LogPA(key, _tCell, tCell, _x, _y); _tCell = tCell; } }
public async Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken) { iprot.IncrementRecursionDepth(); try { TField field; await iprot.ReadStructBeginAsync(cancellationToken); while (true) { field = await iprot.ReadFieldBeginAsync(cancellationToken); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 1: if (field.Type == TType.String) { ColumnName = await iprot.ReadBinaryAsync(cancellationToken); } else { await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken); } break; case 2: if (field.Type == TType.Struct) { Cell = new TCell(); await Cell.ReadAsync(iprot, cancellationToken); } else { await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken); } break; default: await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken); break; } await iprot.ReadFieldEndAsync(cancellationToken); } await iprot.ReadStructEndAsync(cancellationToken); } finally { iprot.DecrementRecursionDepth(); } }
public void Read(TProtocol iprot) { TField field; iprot.ReadStructBegin(); while (true) { field = iprot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 1: if (field.Type == TType.String) { Row = iprot.ReadBinary(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 2: if (field.Type == TType.Map) { { Columns = new Dictionary <byte[], TCell>(); TMap _map4 = iprot.ReadMapBegin(); for (int _i5 = 0; _i5 < _map4.Count; ++_i5) { byte[] _key6; TCell _val7; _key6 = iprot.ReadBinary(); _val7 = new TCell(); _val7.Read(iprot); Columns[_key6] = _val7; } iprot.ReadMapEnd(); } } else { TProtocolUtil.Skip(iprot, field.Type); } break; default: TProtocolUtil.Skip(iprot, field.Type); break; } iprot.ReadFieldEnd(); } iprot.ReadStructEnd(); }
public void SetCell(int x, int y, TCell type, string key) { var current = playArea[x, y]; if (current.Value != type) { playArea[x, y].Set(type, key); } }
public void Read(TProtocol iprot) { iprot.IncrementRecursionDepth(); try { TField field; iprot.ReadStructBegin(); while (true) { field = iprot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 1: if (field.Type == TType.String) { ColumnName = iprot.ReadBinary(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 2: if (field.Type == TType.Struct) { Cell = new TCell(); Cell.Read(iprot); } else { TProtocolUtil.Skip(iprot, field.Type); } break; default: TProtocolUtil.Skip(iprot, field.Type); break; } iprot.ReadFieldEnd(); } iprot.ReadStructEnd(); } finally { iprot.DecrementRecursionDepth(); } }
internal void LogPA(string key, TCell @old, TCell @new, int x, int y) { var logItem = new LogItem { key = key, old = @old, @new = @new, x = x, y = y }; logItem.report = $"PA:{key} Cell:{@old} -> {@new}"; log.Add(logItem); WriteToLog(logItem.report); changes++; }
public TGridGame(int rows, int cols) // se unod dei due parametri vale zero, devo fare eseguire un eccezione { _nRow = rows; _nCol = cols; _Cells = new TCell[_nRow, _nCol]; for (int r = 0; r < _nRow; r++) { for (int c = 0; c < _nCol; c++) { _Cells[r, c] = new TCell(); } } }
public TGridGame() { _nRow = _DefaultRow; _nCol = _DefaultCol; _Cells = new TCell[_nRow, _nCol]; for (int r = 0; r < _nRow; r++) { for (int c = 0; c < _nCol; c++) { _Cells[r, c] = new TCell(); } } }
public void WriteXlsxTest() { string file = AppDomain.CurrentDomain.BaseDirectory + "/ExcelTests/t2.xlsx"; IExcel excel = ExcelFactory.CreateDefault(); DataTable dt = excel.Read(file, 0, 2); DataSet ds = new DataSet(); ds.Tables.Add(dt); TTemplate template = new TTemplate(); TRow R1 = new TRow(); TCell A = new TCell("A", "A", 0, 0); A.ColSpan = 2; TCell B = new TCell("", "B", 0, 2); TCell C = new TCell("C", "C", 0, 3); C.RowSpan = 2; TCell D = new TCell("D", "D", 0, 4); D.RowSpan = 2; TCell E = new TCell("", "E", 0, 5); E.ColSpan = 2; R1.Cells.Add(A); R1.Cells.Add(B); R1.Cells.Add(C); R1.Cells.Add(D); R1.Cells.Add(E); TRow R2 = new TRow(); TCell A1 = new TCell("A1", "A1", 1, 0); TCell A2 = new TCell("A2", "A2", 1, 1); TCell B1 = new TCell("B1", "B1", 1, 2); TCell E1 = new TCell("E1", "E1", 1, 5); TCell E2 = new TCell("E2", "E2", 1, 6); R2.Cells.Add(A1); R2.Cells.Add(A2); R2.Cells.Add(B1); R2.Cells.Add(E1); R2.Cells.Add(E2); TSheet tsheet = new TSheet(); tsheet.Name = "Sheet1"; tsheet.Title = "表格O"; tsheet.Head.Rows.Add(R1); tsheet.Head.Rows.Add(R2); template.Sheets.Add(tsheet); string outputFilePath = AppDomain.CurrentDomain.BaseDirectory + "/ExcelTests/out2.xlsx"; bool result = excel.WriteFile(outputFilePath, ds, template); Assert.IsTrue(result); }
private IEnumerable <TCell> GetNeighbors(TCell cell) { List <TCell> neighbors = new List <TCell>(8); foreach (int[] offset in _offsets) { TCell neighbor = GetCell(cell.X + offset[0], cell.Y + offset[1]); if (neighbor == null) { continue; } neighbors.Add(neighbor); } return(neighbors); }
private void UpdateBounds(TCell cell) { if (cell.X > _right) { _right = cell.X; } if (cell.X < _left) { _left = cell.X; } if (cell.Y > _bottom) { _bottom = cell.Y; } if (cell.Y < _top) { _top = cell.Y; } }
public Dictionary <byte[], TCell> GetHBaseImage() { var socket = new TSocket(_hbaseThrif, _hbaseThrifPort); var transport = new TBufferedTransport(socket); var protocol = new TBinaryProtocol(transport); Hbase.Client hbaseClient = new Hbase.Client(protocol); Dictionary <byte[], TCell> hbaseResult = new Dictionary <byte[], TCell>(); transport.Open(); //List<byte[]> tableNames = hc.getTableNames(); byte[] table = Encoding.UTF8.GetBytes("FiservImages"); byte[] row = Encoding.UTF8.GetBytes(_documentId); byte[] column = Encoding.UTF8.GetBytes("ImageData:Image"); List <TRowResult> results = hbaseClient.getRow(table, row, null); TCell t = new TCell(); //t. foreach (TRowResult result in results) { //result.Columns[column] //result.Columns; hbaseResult = result.Columns; //string s = Encoding.UTF8.GetString(result.Columns[column].Value); //foreach (KeyValuePair<byte[], TCell> singleRow in konj) //{ // //File.WriteAllBytes(@"c:\test\output.docx", singleRow.Value.Value); // Main a = new Main(); // a.OpenFile(singleRow.Value.Value, "output.docx"); //} } return(hbaseResult); }
public Dictionary<byte[], TCell> GetHBaseImage() { var socket = new TSocket(_hbaseThrif, _hbaseThrifPort); var transport = new TBufferedTransport(socket); var protocol = new TBinaryProtocol(transport); Hbase.Client hbaseClient = new Hbase.Client(protocol); Dictionary<byte[], TCell> hbaseResult = new Dictionary<byte[], TCell>(); transport.Open(); //List<byte[]> tableNames = hc.getTableNames(); byte[] table = Encoding.UTF8.GetBytes("FiservImages"); byte[] row = Encoding.UTF8.GetBytes(_documentId); byte[] column = Encoding.UTF8.GetBytes("ImageData:Image"); List<TRowResult> results = hbaseClient.getRow(table, row, null); TCell t = new TCell(); //t. foreach (TRowResult result in results) { //result.Columns[column] //result.Columns; hbaseResult = result.Columns; //string s = Encoding.UTF8.GetString(result.Columns[column].Value); //foreach (KeyValuePair<byte[], TCell> singleRow in konj) //{ // //File.WriteAllBytes(@"c:\test\output.docx", singleRow.Value.Value); // Main a = new Main(); // a.OpenFile(singleRow.Value.Value, "output.docx"); //} } return hbaseResult; }
public void GetHBaseImage(string rowKey = "20150822180801118") { var socket = new TSocket(hbaseThrif, hbaseThrifPort); var transport = new TBufferedTransport(socket); var protocol = new TBinaryProtocol(transport); Hbase.Client hbaseClient = new Hbase.Client(protocol); transport.Open(); //List<byte[]> tableNames = hc.getTableNames(); byte[] table = Encoding.UTF8.GetBytes("FiservImages"); byte[] row = Encoding.UTF8.GetBytes(rowKey); byte[] column = Encoding.UTF8.GetBytes("ImageData:Image"); List <TRowResult> results = hbaseClient.getRow(table, row, null); TCell t = new TCell(); //t. foreach (TRowResult result in results) { //result.Columns[column] //result.Columns; Dictionary <byte[], TCell> konj; konj = result.Columns; //string s = Encoding.UTF8.GetString(result.Columns[column].Value); foreach (KeyValuePair <byte[], TCell> singleRow in konj) { //File.WriteAllBytes(@"c:\test\output.docx", singleRow.Value.Value); OpenFile(singleRow.Value.Value, "output.docx"); } } }
public void Read (TProtocol iprot) { TField field; iprot.ReadStructBegin(); while (true) { field = iprot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 1: if (field.Type == TType.String) { ColumnName = iprot.ReadBinary(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 2: if (field.Type == TType.Struct) { Cell = new TCell(); Cell.Read(iprot); } else { TProtocolUtil.Skip(iprot, field.Type); } break; default: TProtocolUtil.Skip(iprot, field.Type); break; } iprot.ReadFieldEnd(); } iprot.ReadStructEnd(); }
public void AddCell(TCell cell) { Cells.Add(cell); UpdateBounds(cell); }
internal void Clear() { _tCell = TCell.No; }
public void Read(TProtocol iprot) { iprot.IncrementRecursionDepth(); try { TField field; iprot.ReadStructBegin(); while (true) { field = iprot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 1: if (field.Type == TType.String) { Row = iprot.ReadBinary(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 2: if (field.Type == TType.Map) { { Columns = new Dictionary <byte[], TCell>(); TMap _map4 = iprot.ReadMapBegin(); for (int _i5 = 0; _i5 < _map4.Count; ++_i5) { byte[] _key6; TCell _val7; _key6 = iprot.ReadBinary(); _val7 = new TCell(); _val7.Read(iprot); Columns[_key6] = _val7; } iprot.ReadMapEnd(); } } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 3: if (field.Type == TType.List) { { SortedColumns = new List <TColumn>(); TList _list8 = iprot.ReadListBegin(); for (int _i9 = 0; _i9 < _list8.Count; ++_i9) { TColumn _elem10; _elem10 = new TColumn(); _elem10.Read(iprot); SortedColumns.Add(_elem10); } iprot.ReadListEnd(); } } else { TProtocolUtil.Skip(iprot, field.Type); } break; default: TProtocolUtil.Skip(iprot, field.Type); break; } iprot.ReadFieldEnd(); } iprot.ReadStructEnd(); } finally { iprot.DecrementRecursionDepth(); } }
public async Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken) { iprot.IncrementRecursionDepth(); try { TField field; await iprot.ReadStructBeginAsync(cancellationToken); while (true) { field = await iprot.ReadFieldBeginAsync(cancellationToken); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 1: if (field.Type == TType.String) { Row = await iprot.ReadBinaryAsync(cancellationToken); } else { await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken); } break; case 2: if (field.Type == TType.Map) { { Columns = new Dictionary <byte[], TCell>(); TMap _map4 = await iprot.ReadMapBeginAsync(cancellationToken); for (int _i5 = 0; _i5 < _map4.Count; ++_i5) { byte[] _key6; TCell _val7; _key6 = await iprot.ReadBinaryAsync(cancellationToken); _val7 = new TCell(); await _val7.ReadAsync(iprot, cancellationToken); Columns[_key6] = _val7; } await iprot.ReadMapEndAsync(cancellationToken); } } else { await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken); } break; case 3: if (field.Type == TType.List) { { SortedColumns = new List <TColumn>(); TList _list8 = await iprot.ReadListBeginAsync(cancellationToken); for (int _i9 = 0; _i9 < _list8.Count; ++_i9) { TColumn _elem10; _elem10 = new TColumn(); await _elem10.ReadAsync(iprot, cancellationToken); SortedColumns.Add(_elem10); } await iprot.ReadListEndAsync(cancellationToken); } } else { await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken); } break; default: await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken); break; } await iprot.ReadFieldEndAsync(cancellationToken); } await iprot.ReadStructEndAsync(cancellationToken); } finally { iprot.DecrementRecursionDepth(); } }
/// <summary> /// Creates a new pair of cells. /// </summary> /// <param name="firstCell">First cell.</param> /// <param name="secondCell">Second cell.</param> public Pair(TCell firstCell, TCell secondCell) { this.FirstCell = firstCell; this.SecondCell = secondCell; }
protected internal CellInfo(int x, int y, TCell data) { X = x; Y = y; Data = data; }
public static Dictionary <TCell, (int Dist, TCell From)> DijkstraFrom <TCell, TMid>(this IDijkstra <TCell, TMid> dijkstra, TCell start, Func <TCell, bool> valid = null) { return(dijkstra.Build().ComputeFrom(start, valid));
public void Read (TProtocol iprot) { TField field; iprot.ReadStructBegin(); while (true) { field = iprot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 0: if (field.Type == TType.List) { { Success = new List<TCell>(); TList _list65 = iprot.ReadListBegin(); for( int _i66 = 0; _i66 < _list65.Count; ++_i66) { TCell _elem67 = new TCell(); _elem67 = new TCell(); _elem67.Read(iprot); Success.Add(_elem67); } iprot.ReadListEnd(); } } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 1: if (field.Type == TType.Struct) { Io = new IOError(); Io.Read(iprot); } else { TProtocolUtil.Skip(iprot, field.Type); } break; default: TProtocolUtil.Skip(iprot, field.Type); break; } iprot.ReadFieldEnd(); } iprot.ReadStructEnd(); }
public void Read(TProtocol iprot) { TField field; iprot.ReadStructBegin(); while (true) { field = iprot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 1: if (field.Type == TType.String) { Row = iprot.ReadBinary(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 2: if (field.Type == TType.Map) { { Columns = new Dictionary<byte[], TCell>(); TMap _map4 = iprot.ReadMapBegin(); for( int _i5 = 0; _i5 < _map4.Count; ++_i5) { byte[] _key6; TCell _val7; _key6 = iprot.ReadBinary(); _val7 = new TCell(); _val7.Read(iprot); Columns[_key6] = _val7; } iprot.ReadMapEnd(); } } else { TProtocolUtil.Skip(iprot, field.Type); } break; default: TProtocolUtil.Skip(iprot, field.Type); break; } iprot.ReadFieldEnd(); } iprot.ReadStructEnd(); }
public ActionResult Export(int payId) { PaymentManager pm = new PaymentManager(); Payment payment = pm.LoadPayment(payId); #region 动态模板 TTemplate template = new TTemplate(); TRow R1 = new TRow(); TRow R2 = new TRow(); int index1 = 3; int index2 = 3; TCell A = new TCell("PersonId", "ID", 0, 0); A.RowSpan = 2; A.Width = 1; TCell B = new TCell("PersonName", "姓名", 0, 1); B.RowSpan = 2; TCell C = new TCell("PersonCode", "身份证", 0, 2); C.RowSpan = 2; R1.Cells.Add(A); R1.Cells.Add(B); R1.Cells.Add(C); foreach (PayItemDO item in payment.Items) { TCell cell = new TCell(); cell.Name = item.ItemName; cell.Caption = item.ItemCaption; if (item.IsLeaf == true) { //cell.Width = 50; } if (item.ParentId == 0) { cell.RowIndex = 0; cell.ColumnIndex = index1; int colspan = 1; foreach (PayItemDO pi in payment.Items) { if (pi.ParentId == item.ItemId) { colspan++; } } if (colspan == 1) { cell.RowSpan = 2; index1++; index2++; } else { cell.ColSpan = colspan - 1; index1 = index1 + cell.ColSpan; } R1.Cells.Add(cell); } else { cell.RowIndex = 1; cell.ColumnIndex = index2; index2 = index2 + 1; R2.Cells.Add(cell); } } TSheet tsheet = new TSheet(); tsheet.Name = "Sheet1"; tsheet.Title = "Sheet1"; tsheet.Head.Rows.Add(R1); tsheet.Head.Rows.Add(R2); template.Sheets.Add(tsheet); #endregion IExcel excel = ExcelFactory.CreateDefault(); DataSet ds = new DataSet(); payment.DataSource.TableName = "Sheet1"; ds.Tables.Add(payment.DataSource); POIStream stream = new POIStream(); stream.AllowClose = false; excel.Write(stream, template, ds, ExcelExtendType.XLSX); stream.AllowClose = true; byte[] buffer = new byte[stream.Length]; stream.Position = 0; stream.Read(buffer, 0, buffer.Length); stream.Close(); HttpResponse context = System.Web.HttpContext.Current.Response; try { context.ContentType = "application/ms-excel"; context.AddHeader("Content-Disposition", string.Format("attachment; filename={0}.xlsx", HttpUtility.UrlEncode(payment.PayTitle, System.Text.Encoding.UTF8))); context.BinaryWrite(buffer); context.Flush(); context.End(); } catch (Exception ex) { context.ContentType = "text/plain"; context.Write(ex.Message); } return(null); }