private void SetTitleBorders(ISheet sheet, CellRangeAddress range) { RegionUtil.SetBorderBottom((short)BorderStyle.Thin, range, sheet, wb); RegionUtil.SetBorderTop((short)BorderStyle.Thin, range, sheet, wb); RegionUtil.SetBorderLeft((short)BorderStyle.Thin, range, sheet, wb); RegionUtil.SetBorderRight((short)BorderStyle.Double, range, sheet, wb); }
public static void SetRegionBorder(int border, CellRangeAddress region, ISheet sheet, IWorkbook workbook) { RegionUtil.SetBorderLeft(border, region, sheet, workbook); RegionUtil.SetBorderRight(border, region, sheet, workbook); RegionUtil.SetBorderTop(border, region, sheet, workbook); RegionUtil.SetBorderBottom(border, region, sheet, workbook); }
//设置合并单元格边框 public static void setBorderForMergeCell(int border, CellRangeAddress region, ISheet sheet, IWorkbook workBook) { sheet.AddMergedRegion(region); RegionUtil.SetBorderBottom(1, region, sheet, workBook); RegionUtil.SetBorderLeft(1, region, sheet, workBook); RegionUtil.SetBorderRight(1, region, sheet, workBook); RegionUtil.SetBorderTop(1, region, sheet, workBook); }
public void setBordersToMergedCells() { for (int i = 0; i < sheet.NumMergedRegions; i++) { CellRangeAddress mergedRegions = sheet.GetMergedRegion(i); RegionUtil.SetBorderLeft((int)BorderStyle.Thin, mergedRegions, sheet, hssfwb); RegionUtil.SetBorderRight((int)BorderStyle.Thin, mergedRegions, sheet, hssfwb); RegionUtil.SetBorderTop((int)BorderStyle.Thin, mergedRegions, sheet, hssfwb); RegionUtil.SetBorderBottom((int)BorderStyle.Thin, mergedRegions, sheet, hssfwb); } }
public static void MergeCellsAndAddBorder(ISheet sheet, int firstRow, int lastRow, int firstCol, int lastCol) { var cra = new CellRangeAddress(firstRow, lastRow, firstCol, lastCol); sheet.AddMergedRegion(cra); RegionUtil.SetBorderBottom(1, cra, sheet, sheet.Workbook); RegionUtil.SetBorderTop(1, cra, sheet, sheet.Workbook); RegionUtil.SetBorderLeft(1, cra, sheet, sheet.Workbook); RegionUtil.SetBorderRight(1, cra, sheet, sheet.Workbook); }
private static Vector3?GetEstimatedPath(AbstractActor actor, out List <Vector3> path) { PathNode closestNode = null; var closestNodeDist = float.MaxValue; var destRadius = GetMinWeaponRange(actor); path = null; var enemies = actor.Combat.GetAllEnemiesOf(actor); if (enemies.Count == 0) { Main.HBSLog?.LogWarning("FilterToAdjacentSlowestMoveNode: no enemies"); } foreach (var enemy in enemies) { if (enemy.IsDead) { continue; } var clippedEnemyPos = RegionUtil.MaybeClipMovementDestinationToStayInsideRegion(actor, enemy.CurrentPosition); var curPath = DynamicLongRangePathfinder.GetPathToDestination(clippedEnemyPos, actor.MovementCaps.MaxWalkDistance, actor, false, destRadius); if (curPath == null || curPath.Count == 0) { Main.HBSLog?.LogWarning("FilterToAdjacentSlowestMoveNode: didn't get a path to unit"); continue; } var nodeOnCurPath = AIUtil.GetPrunedClosestValidPathNode(actor, actor.Pathing.CurrentGrid, actor.Combat, actor.MovementCaps.MaxWalkDistance, curPath); if (nodeOnCurPath == null) { Main.HBSLog?.LogWarning("FilterToAdjacentSlowestMoveNode: didn't get a node on the current path"); continue; } var distanceFromEnemy = Vector3.Distance(nodeOnCurPath.Position, clippedEnemyPos); if (distanceFromEnemy >= closestNodeDist) { continue; } path = curPath; closestNode = nodeOnCurPath; closestNodeDist = distanceFromEnemy; } return(closestNode?.Position); }
public static void drawBorders(ISheet sheet, int firstDataRow, int lastDataRow, int lastDataColumn) { CellRangeAddress firstDataEntryAddress = new CellRangeAddress(firstDataRow, firstDataRow, 0, lastDataColumn); RegionUtil.SetBorderTop(BORDER_THICKNESS, firstDataEntryAddress, sheet, sheet.Workbook); CellRangeAddress lastDataEntryAddress = new CellRangeAddress(lastDataRow, lastDataRow, 0, lastDataColumn); RegionUtil.SetBorderBottom(BORDER_THICKNESS, lastDataEntryAddress, sheet, sheet.Workbook); CellRangeAddress lastColumnAddress = new CellRangeAddress(firstDataRow - 1, lastDataRow, lastDataColumn, lastDataColumn); RegionUtil.SetBorderRight(BORDER_THICKNESS, lastColumnAddress, sheet, sheet.Workbook); }
public string GenerateDownloadPackage(DateTime from, DateTime to, string region, int north, int south, int west, int east, string product, string format) { int result = 0; string dateFormatString = @"yyyy-MM-dd"; string dateTimeFormatString = @"yyyy-MM-dd hh:mm:ss"; int queryProductId = ConvertProductStringToId(product); if (queryProductId == 1 || queryProductId == 6) // For viirs { Region regionValue = RegionUtil.GetRegionFromDisplayName(region); if (north == -1000 || south == -1000 || west == -1000 || east == -1000) { RegionBoundary boundary = GetRegionBoundary(regionValue); north = boundary.North; south = boundary.South; west = boundary.West; east = boundary.East; } } else { north = 90; south = -90; west = -180; east = 180; } string downloadTaskName = DateTime.UtcNow.ToString("yyyy_MM_dd") + "_" + DateTime.UtcNow.Ticks.ToString(); using (MySqlConnection connection = new MySqlConnection(DatabaseConnectionstring)) { string queryCommandTextFormat = "INSERT INTO jpssflood.downloadtasks_v2 (CreatedTime, Name, StartTime, EndTime, Step, Product, Region, North, South, West, East, ProcessStartTime, ProcessEndTime, ImageFormat, Status) "; queryCommandTextFormat += "VALUES('{0}', '{1}', '{2}', '{3}', {4}, {5}, {6}, {7}, {8}, {9}, {10}, '{11}', '{12}', '{13}', {14})"; connection.Open(); MySqlCommand command = new MySqlCommand(); command.Connection = connection; command.CommandText = string.Format(queryCommandTextFormat, DateTime.UtcNow.ToString(dateTimeFormatString) /*CreatedTime*/, downloadTaskName /*Name*/, from.ToString(dateFormatString) /*StartTime*/, to.ToString(dateFormatString) /*EndTime*/, 1, queryProductId, 1, north, south, west, east, DateTime.MinValue.ToString(dateTimeFormatString) /*ProcessStartTime*/, DateTime.MinValue.ToString(dateTimeFormatString) /*ProcessEndTime*/, format /*ImageFormat*/, 1 /*Status*/); result = command.ExecuteNonQuery(); } return(result == 1 ? downloadTaskName : string.Empty); }
private void ApplyPopulateState(PopulateAction action, RegionFile region, Bitmap populateOverlay) { for (int chunkX = 0; chunkX < 32; chunkX++) { for (int chunkZ = 0; chunkZ < 32; chunkZ++) { Chunk c = region.Chunks[chunkX, chunkZ]; if (c == null || c.Root == null) { continue; } ((TAG_Byte)c.Root["Level"]["TerrainPopulated"]).Payload = action.PopulatedFlags[chunkX, chunkZ]; } } RegionUtil.RenderRegionChunkstobePopulated(region, populateOverlay); }
private void TagUnitsInRegion() { Main.LogDebug($"[SetUnitsInRegionToBeTaggedObjectiveTargetsResult] Tagging '{NumberOfUnits}' '{Type}' in region '{RegionGuid}'"); RegionGameLogic regionGameLogic = UnityGameInstance.BattleTechGame.Combat.ItemRegistry.GetItemByGUID <RegionGameLogic>(RegionGuid); if (regionGameLogic == null) { Main.Logger.LogError($"[SetUnitsInRegionToBeTaggedObjectiveTargetsResult] Region Not Found for Guid '{RegionGuid}'"); return; } if (Type == "Building") { List <BuildingRepresentation> buildingsInMap = GameObjextExtensions.GetBuildingsInMap(); Main.LogDebug($"[SetUnitsInRegionToBeTaggedObjectiveTargetsResult] Collected '{buildingsInMap.Count}' buildings to check."); if (NumberOfUnits > 0) { buildingsInMap.Shuffle(); } foreach (BuildingRepresentation building in buildingsInMap) { bool isBuildingInRegion = RegionUtil.PointInRegion(UnityGameInstance.BattleTechGame.Combat, building.transform.position, RegionGuid); if (isBuildingInRegion) { Main.LogDebug($"[SetUnitsInRegionToBeTaggedObjectiveTargetsResult] Found building '{building.gameObject.name}' in region!"); building.ParentBuilding.EncounterTags.UnionWith(Tags); SetTeam(building.ParentBuilding); SetIsTargetObjective(building.ParentBuilding); if (HasReachedUnitLimit()) { break; } } } } else { Main.LogDebug($"[SetUnitsInRegionToBeTaggedObjectiveTargetsResult] Tagging '{Type}' Not Yet Supported. Use 'TagUnitsInRegion'"); } }
private void ApplyBiomeState(BiomeAction action, RegionFile region, Bitmap terrainOverlay, Bitmap biomeOverlay, ref String[,] tooltips, UpdateStatus updateStatus) { foreach (ChunkState state in action.Chunks) { Chunk c = region.Chunks[state.Coords.X, state.Coords.Z]; if (c == null || c.Root == null) { continue; } ((TAG_Byte_Array)c.Root["Level"]["Biomes"]).Payload = (byte[])state.Biomes.Clone(); } tooltips = new String[biomeOverlay.Width, biomeOverlay.Height]; if (terrainOverlay != null) { updateStatus("Generating terrain map"); RegionUtil.RenderRegionTerrain(region, terrainOverlay); } updateStatus("Generating biome map"); RegionUtil.RenderRegionBiomes(region, biomeOverlay, tooltips); updateStatus(""); }
protected void AddHeaderCell(IRow row, int col, String text, int width = -1, bool underlined = true, int colSpan = 1, bool borderRight = false) { var cell = row.CreateCell(col); cell.SetCellValue(text); cell.CellStyle = underlined ? columnHeaderStyleUnderlined : columnHeaderStyle; if (width != -1) { row.Sheet.SetColumnWidth(col, width); } var range = new CellRangeAddress(row.RowNum, row.RowNum, col, col + colSpan - 1); if (colSpan > 1) { row.Sheet.AddMergedRegion(range); } if (borderRight) { RegionUtil.SetBorderRight((int)BorderStyle.Medium, range, row.Sheet, row.Sheet.Workbook); } }
static void Main(string[] args) { IWorkbook workbook = new XSSFWorkbook(); ISheet sheet = workbook.CreateSheet(); var cell = sheet.CreateRow(1).CreateCell(1); cell.SetCellValue(new XSSFRichTextString("test1")); var style1 = workbook.CreateCellStyle(); style1.Alignment = HorizontalAlignment.Center; style1.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Yellow.Index2; style1.FillPattern = FillPattern.SolidForeground; cell.CellStyle = style1; sheet.AddMergedRegion(new CellRangeAddress(1, 1, 1, 2)); var cell2 = sheet.CreateRow(2).CreateCell(1); cell2.SetCellValue("test2"); cell2.CellStyle = style1; sheet.AddMergedRegion(new CellRangeAddress(2, 2, 1, 2)); var cra = new CellRangeAddress(2, 3, 4, 5); RegionUtil.SetBorderTop((int)BorderStyle.DashDot, cra, sheet); RegionUtil.SetBorderLeft((int)BorderStyle.DashDot, cra, sheet); RegionUtil.SetBorderRight((int)BorderStyle.DashDot, cra, sheet); RegionUtil.SetBorderBottom((int)BorderStyle.DashDot, cra, sheet); sheet.AddMergedRegion(cra); using (FileStream sw = File.Create("test.xlsx")) { workbook.Write(sw); } }
public void AddRange(string data, int colLen, int rowLen, XSSFCellStyle cellStyle = null) { row = sheet.GetRow(rowIndex) ?? sheet.CreateRow(rowIndex); ICell cell = row.CreateCell(colIndex); cell.CellStyle = cellStyle ?? defaultCellStyle; cell.SetCellValue(creationHelper.CreateRichTextString(data)); //Да не прави Range на една клетка, че има проблем с Wrap трябва да измислим и как да оправим Autofit-a на Merge cells/rows if (colLen != 1 || rowLen != 1) { CellRangeAddress cra = new CellRangeAddress(rowIndex, rowIndex + rowLen - 1, colIndex, colIndex + colLen - 1); sheet.AddMergedRegion(cra); if (cellStyle != null) { RegionUtil.SetBorderTop((int)cellStyle.BorderTop, cra, sheet, workBook); RegionUtil.SetBorderBottom((int)cellStyle.BorderBottom, cra, sheet, workBook); RegionUtil.SetBorderLeft((int)cellStyle.BorderLeft, cra, sheet, workBook); RegionUtil.SetBorderRight((int)cellStyle.BorderRight, cra, sheet, workBook); } } //if (cellStyle != null && cellStyle.Alignment == HorizontalAlignment.Center) // CellUtil.SetAlignment(cell, workBook, (int)HorizontalAlignment.Center); }
public void GenerateDetailedReport(DateTime settle_day) { FileStream fs = new FileStream(String.Format("产品运行数据日报(报风委会表单)-{0}.xls", settle_day.ToString("yyyyMMdd")), FileMode.OpenOrCreate, FileAccess.ReadWrite); HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("Sheet1"); HSSFFont font1 = (HSSFFont)workbook.CreateFont(); font1.FontName = "楷体"; font1.FontHeightInPoints = 11; int left_border = 1; HSSFCellStyle style1 = (HSSFCellStyle)workbook.CreateCellStyle(); style1.BorderLeft = NPOI.SS.UserModel.BorderStyle.Medium; style1.BorderRight = NPOI.SS.UserModel.BorderStyle.Medium; style1.BorderTop = NPOI.SS.UserModel.BorderStyle.Medium; style1.BorderBottom = NPOI.SS.UserModel.BorderStyle.Medium; style1.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; style1.SetFont(font1); style1.WrapText = true; int nrow = 1; //表一:总账户信息 //表一第一行 var region = new CellRangeAddress(1, 1, left_border, 6); var row = sheet.CreateRow(nrow++); var cell = row.CreateCell(1); sheet.AddMergedRegion(region); RegionUtil.SetBorderTop(2, region, sheet, workbook); RegionUtil.SetBorderBottom(2, region, sheet, workbook); RegionUtil.SetBorderLeft(2, region, sheet, workbook); RegionUtil.SetBorderRight(2, region, sheet, workbook); cell.SetCellValue("总账户"); cell.CellStyle = style1; //表一第二行 region = new CellRangeAddress(2, 2, left_border, 2); row = sheet.CreateRow(nrow++); cell = row.CreateCell(1); sheet.AddMergedRegion(region); RegionUtil.SetBorderTop(2, region, sheet, workbook); RegionUtil.SetBorderBottom(2, region, sheet, workbook); RegionUtil.SetBorderLeft(2, region, sheet, workbook); RegionUtil.SetBorderRight(2, region, sheet, workbook); cell.SetCellValue("额度(元)"); cell.CellStyle = style1; region = new CellRangeAddress(2, 2, left_border + 2, 4); cell = row.CreateCell(3); sheet.AddMergedRegion(region); RegionUtil.SetBorderTop(2, region, sheet, workbook); RegionUtil.SetBorderBottom(2, region, sheet, workbook); RegionUtil.SetBorderLeft(2, region, sheet, workbook); RegionUtil.SetBorderRight(2, region, sheet, workbook); cell.SetCellValue("权益(元)"); cell.CellStyle = style1; region = new CellRangeAddress(2, 2, left_border + 4, 6); cell = row.CreateCell(5); sheet.AddMergedRegion(region); RegionUtil.SetBorderTop(2, region, sheet, workbook); RegionUtil.SetBorderBottom(2, region, sheet, workbook); RegionUtil.SetBorderLeft(2, region, sheet, workbook); RegionUtil.SetBorderRight(2, region, sheet, workbook); cell.SetCellValue("风险水平"); cell.CellStyle = style1; //读取数据库表 var granted_table = this.dataset.display_ds.Tables["business_overview"]; var pnl_table = this.dataset.display_ds.Tables["business_state_view"]; var last_year_settle_rec = (from s in pnl_table.AsEnumerable() where s.Field <DateTime>("结算日").Year < settle_day.Year orderby s.Field <DateTime>("结算日") descending select new { settle_day = s.Field <DateTime>("结算日"), accum_gross_pnl = s.Field <decimal>("累计总盈亏") }).First(); //表一第三行 string[] row_data = new string[] { "总授权额度", granted_table.Rows[0].Field <decimal>(0).ToString(), "年初总账户权益", (last_year_settle_rec.accum_gross_pnl + granted_table.Rows[0].Field <decimal>(0)).ToString(), "总delta", "0" }; int ncol = left_border; row = sheet.CreateRow(nrow++); foreach (var data in row_data) { cell = row.CreateCell(ncol++); cell.CellStyle = style1; cell.SetCellValue(data); } //表一第四行 var last_settle_rec = (from s in pnl_table.AsEnumerable() where s.Field <DateTime>("结算日") < settle_day orderby s.Field <DateTime>("结算日") descending select new { settle_day = s.Field <DateTime>("结算日"), accum_gross_pnl = s.Field <decimal>("累计总盈亏") }).First(); row_data = new string[] { "已使用额度", granted_table.Rows[0].Field <decimal>(1).ToString(), "期初总账户权益", (last_settle_rec.accum_gross_pnl + granted_table.Rows[0].Field <decimal>(0)).ToString(), "", "" }; ncol = left_border; row = sheet.CreateRow(nrow++); foreach (var data in row_data) { cell = row.CreateCell(ncol++); cell.CellStyle = style1; cell.SetCellValue(data); } //表一第五行 var cur_settle_rec = (from s in pnl_table.AsEnumerable() where s.Field <DateTime>("结算日") == settle_day orderby s.Field <DateTime>("结算日") descending select new { settle_day = s.Field <DateTime>("结算日"), gross_pnl = s.Field <decimal>("结算日总盈亏"), accum_gross_pnl = s.Field <decimal>("累计总盈亏") }).First(); row_data = new string[] { "授权亏损度", granted_table.Rows[0].Field <decimal>(2).ToString(), "当前总账户权益", (cur_settle_rec.accum_gross_pnl + granted_table.Rows[0].Field <decimal>(0)).ToString(), "", "" }; ncol = left_border; row = sheet.CreateRow(nrow++); foreach (var data in row_data) { cell = row.CreateCell(ncol++); cell.CellStyle = style1; cell.SetCellValue(data); } //表一第六行 row_data = new string[] { "", "", "当日盈亏数", cur_settle_rec.gross_pnl.ToString(), "", "" }; ncol = left_border; row = sheet.CreateRow(nrow++); foreach (var data in row_data) { cell = row.CreateCell(ncol++); cell.CellStyle = style1; cell.SetCellValue(data); } //表一第七行 row_data = new string[] { "", "", "本年亏损度", (cur_settle_rec.accum_gross_pnl - last_year_settle_rec.accum_gross_pnl < 0?cur_settle_rec.accum_gross_pnl - last_year_settle_rec.accum_gross_pnl:0).ToString(), "", "" }; ncol = left_border; row = sheet.CreateRow(nrow++); foreach (var data in row_data) { cell = row.CreateCell(ncol++); cell.CellStyle = style1; cell.SetCellValue(data); } //调整表格大小 sheet.SetColumnWidth(1, 4096); sheet.SetColumnWidth(2, 4096); sheet.SetColumnWidth(3, 4096); sheet.SetColumnWidth(4, 4096); sheet.SetColumnWidth(5, 3072); sheet.SetColumnWidth(6, 3072); //表二:期权信息 nrow++; region = new CellRangeAddress(nrow, nrow, 1, 11); sheet.AddMergedRegion(region); row = sheet.CreateRow(nrow++); cell = row.CreateCell(1); cell.CellStyle = style1; cell.SetCellValue("期权账户"); RegionUtil.SetBorderTop(2, region, sheet, workbook); RegionUtil.SetBorderBottom(2, region, sheet, workbook); RegionUtil.SetBorderLeft(2, region, sheet, workbook); RegionUtil.SetBorderRight(2, region, sheet, workbook); row_data = new string[] { "", "当日权利仓开仓量(手)", "当日权利仓平仓量(手)", "当日义务仓开仓量(手)", "当日义务仓平仓量(手)", "权利仓持仓量(手)", "义务仓持仓量(手)", "当日期权持仓损益(元)", "当日期权平仓损益(元)", "当日期权总损益(元)", "本年期权累计损益(元)" }; ncol = left_border; row = sheet.CreateRow(nrow++); row.Height = 1024; foreach (var data in row_data) { cell = row.CreateCell(ncol++); cell.CellStyle = style1; cell.SetCellValue(data); } workbook.Write(fs); fs.Close(); }
public CellRangeAddress ApplyBorderToRange(ISheet worksheet, CellRangeAddress range) { var defaultCellStyle = worksheet.Workbook.GetCellStyleAt(0); if (this.Border != CellBorder.None) { if (this.Border.HasFlag(CellBorder.Top)) { RegionUtil.SetBorderTop((int)this.BorderStyle, range, worksheet, worksheet.Workbook); if (this.BorderColor == null) { RegionUtil.SetTopBorderColor(defaultCellStyle.TopBorderColor, range, worksheet, worksheet.Workbook); } else { throw new Exception("RegionUtil.SetTopBorderColor(this.BorderColor.Indexed, range, worksheet, worksheet.Workbook)"); //RegionUtil.SetTopBorderColor(this.BorderColor.Indexed, range, worksheet, worksheet.Workbook); } } if (this.Border.HasFlag(CellBorder.Bottom)) { RegionUtil.SetBorderBottom((int)this.BorderStyle, range, worksheet, worksheet.Workbook); if (this.BorderColor == null) { RegionUtil.SetBottomBorderColor(defaultCellStyle.BottomBorderColor, range, worksheet, worksheet.Workbook); } else { throw new Exception("RegionUtil.SetBottomBorderColor(this.BorderColor.Indexed, range, worksheet, worksheet.Workbook)"); //RegionUtil.SetBottomBorderColor(this.BorderColor.Indexed, range, worksheet, worksheet.Workbook); } } if (this.Border.HasFlag(CellBorder.Right)) { RegionUtil.SetBorderRight((int)this.BorderStyle, range, worksheet, worksheet.Workbook); if (this.BorderColor == null) { RegionUtil.SetRightBorderColor(defaultCellStyle.RightBorderColor, range, worksheet, worksheet.Workbook); } else { throw new Exception("RegionUtil.SetRightBorderColor(this.BorderColor.Indexed, range, worksheet, worksheet.Workbook)"); //RegionUtil.SetRightBorderColor(this.BorderColor.Indexed, range, worksheet, worksheet.Workbook); } } if (this.Border.HasFlag(CellBorder.Left)) { RegionUtil.SetBorderLeft((int)this.BorderStyle, range, worksheet, worksheet.Workbook); if (this.BorderColor == null) { RegionUtil.SetLeftBorderColor(defaultCellStyle.LeftBorderColor, range, worksheet, worksheet.Workbook); } else { throw new Exception("egionUtil.SetLeftBorderColor(this.BorderColor.Indexed, range, worksheet, worksheet.Workbook)"); //RegionUtil.SetLeftBorderColor(this.BorderColor.Indexed, range, worksheet, worksheet.Workbook); } } } return(range); }
public override void OnRenderMain(FlatProject project, ParsedLog log) { int rowPos = LG_ROW_POS_CONTENT_START; foreach (ParsedLogLine line in log.LogLineList) { int colPos = LG_COL_POS_CONTENT_START; if (project.ShowFileName) { ICell fileCell = GetLogContentStringCell(colPos, rowPos); fileCell.SetCellValue(line.File.Name); SetCellWidthToDictionary(LG_COL_NAME_FILE, line.File.Name); colPos++; } ICell lineNumCell = GetLogContentCenterCell(colPos, rowPos); lineNumCell.SetCellValue(line.LineNumber); SetCellWidthToDictionary(LG_COL_NAME_LINE, line.LineNumber.ToString()); colPos++; if (line.HasError) { ICell notParsedCell = GetLogContentStringCell(colPos, rowPos); notParsedCell.SetCellValue(line.NotParsedLog); if (line.ColumnList.Count > 1) { int cellRange = colPos; foreach (ParsedLogColumn col in line.ColumnList) { if (col.ColumnDefinition.Visble) { cellRange++; } } CellRangeAddress region = new CellRangeAddress(rowPos, rowPos, colPos, cellRange - 1); logSheet.AddMergedRegion(region); RegionUtil.SetBorderTop(BORDER_THIN, region, logSheet, workbook); RegionUtil.SetBorderBottom(BORDER_THIN, region, logSheet, workbook); RegionUtil.SetBorderRight(BORDER_THIN, region, logSheet, workbook); RegionUtil.SetBorderLeft(BORDER_THIN, region, logSheet, workbook); } } else { foreach (ParsedLogColumn col in line.ColumnList) { if (!col.ColumnDefinition.Visble) { continue; } ICell cell = null; if (col.ColumnDefinition.IsDateTimeField) { DateTime time = new DateTime(long.Parse(col.Value)); cell = GetLogContentDateCell(colPos, rowPos); cell.SetCellValue(time); SetCellWidthToDictionary(col.ColumnDefinition.ColumnName, time.ToString(FORMAT_STR_DATE)); } else { cell = GetLogContentStringCell(colPos, rowPos); cell.SetCellValue(col.Value); SetCellWidthToDictionary(col.ColumnDefinition.ColumnName, col.Value); } colPos++; } } rowPos++; } ResizeLogColumns(project, project.PatternDefinition.ColumnDefinitionList); }
internal byte[] GenerateReportDataToExcel(ReportData reportData, string templateName, int rowStart, int columnStart) { var config = NiisAmbientContext.Current.Configuration.GetSection("ReportOptions"); var tempFolderName = config["TempFolder"]; var reportTemplatesFolder = config["ReportTemplatesFolder"]; var emptyTempplateFolderName = config["EmptyReportTemplateName"]; var tempFileFullPath = string.Format("{0}\\{1}", Path.GetFullPath(tempFolderName), Guid.NewGuid() + "Report.xlsx"); var reportTemplateFolderFullPath = string.Format("{0}\\{1}", Path.GetFullPath(reportTemplatesFolder), string.IsNullOrEmpty("templateName") ? emptyTempplateFolderName : templateName); GeneratedExcelFilePath = tempFileFullPath; if (!File.Exists(tempFileFullPath)) { FileStream templateFile = new FileStream(reportTemplateFolderFullPath, FileMode.Open, FileAccess.ReadWrite); var book = new XSSFWorkbook(templateFile); var sheet = (XSSFSheet)book.GetSheet("Отчет"); var rows = reportData.Rows; #region Cell border styling var boldFont = book.CreateFont(); boldFont.Boldweight = (short)FontBoldWeight.Bold; ICellStyle headerStyle = book.CreateCellStyle(); headerStyle.SetFont(boldFont); headerStyle.FillForegroundColor = IndexedColors.SeaGreen.Index; headerStyle.FillPattern = FillPattern.SolidForeground; headerStyle.VerticalAlignment = VerticalAlignment.Center; headerStyle.Alignment = HorizontalAlignment.Center; headerStyle.WrapText = true; addThinBorder(headerStyle); ICellStyle simpleBorderedStyle = book.CreateCellStyle(); addThinBorder(simpleBorderedStyle); ICellStyle simpleBorderedCenterAlignmentStyle = book.CreateCellStyle(); addThinBorder(simpleBorderedStyle); simpleBorderedCenterAlignmentStyle.VerticalAlignment = VerticalAlignment.Center; simpleBorderedCenterAlignmentStyle.Alignment = HorizontalAlignment.Center; simpleBorderedCenterAlignmentStyle.WrapText = true; ICellStyle simpleBorderedBoldStyle = book.CreateCellStyle(); simpleBorderedBoldStyle.SetFont(boldFont); addThinBorder(simpleBorderedBoldStyle); void addThinBorder(ICellStyle cellStyle) { cellStyle.BorderLeft = BorderStyle.Thin; cellStyle.BorderTop = BorderStyle.Thin; cellStyle.BorderRight = BorderStyle.Thin; cellStyle.BorderBottom = BorderStyle.Thin; } #endregion var rowNumber = rowStart; foreach (var row in reportData.Rows) { var createdRow = sheet.CreateRow(rowNumber); var cellNumer = columnStart; #region Создание ячеек if (row.Cells != null) { foreach (var cell in row.Cells) { var createdCell = createdRow.CreateCell(cellNumer); if (cell.Value != null) { createdCell.SetCellValue(cell.Value); } //усановим стайлинг для шапки/остальных строк if (row.IsHeader) { createdCell.CellStyle = headerStyle; sheet.AutoSizeColumn(cellNumer, true); } else { createdCell.CellStyle = simpleBorderedStyle; if (cell.IsBold) { createdCell.CellStyle = simpleBorderedBoldStyle; } else if (cell.IsTextAlignCenter) { createdCell.CellStyle = simpleBorderedCenterAlignmentStyle; } } //объединение ячеек if (cell.CollSpan > 0 || cell.RowSpan > 0) { var lastRowIndex = cell.RowSpan > 0 ? rowNumber + cell.RowSpan - 1 : 0; var lastColumnIndex = cell.CollSpan > 0 ? cellNumer + cell.CollSpan - 1 : 0; if (lastRowIndex < rowNumber) { lastRowIndex = rowNumber; } if (lastColumnIndex < cellNumer) { lastColumnIndex = cellNumer; } var cellRangeAddress = new CellRangeAddress(rowNumber, lastRowIndex, cellNumer, lastColumnIndex); sheet.AddMergedRegion(cellRangeAddress); RegionUtil.SetBorderBottom((int)BorderStyle.Thin, cellRangeAddress, sheet, book); RegionUtil.SetBorderTop((int)BorderStyle.Thin, cellRangeAddress, sheet, book); } if (cell.CollSpan > 0) { cellNumer = cellNumer + cell.CollSpan; } else { cellNumer++; } } } #endregion rowNumber++; } using (var fileStreem = new FileStream(tempFileFullPath, FileMode.Create, FileAccess.Write)) { book.Write(fileStreem); } } return(File.ReadAllBytes(tempFileFullPath)); }
protected override BehaviorTreeResults Tick() { if (unit.HasMovedThisRound) { return(new BehaviorTreeResults(BehaviorNodeState.Failure)); } BehaviorVariableValue targetLanceGuidValue = this.tree.GetCustomBehaviorVariableValue(FOLLOW_LANCE_TARGET_GUID_KEY); if (targetLanceGuidValue == null) { return(new BehaviorTreeResults(BehaviorNodeState.Failure)); } string targetLanceGuid = targetLanceGuidValue.StringVal; Lance targetLance = DestinationUtil.FindLanceByGUID(this.tree, targetLanceGuid); if (targetLance == null) { return(new BehaviorTreeResults(BehaviorNodeState.Failure)); } AbstractActor closestEnemy = null; if (Main.Settings.AiSettings.FollowAiSettings.StopWhen == "OnEnemyVisible") { Main.LogDebug($"[MoveToFollowLanceNode] Looking for closest visible enemy."); closestEnemy = AiUtils.GetClosestVisibleEnemy(this.unit, targetLance); } else // OnEnemyDetected { Main.LogDebug($"[MoveToFollowLanceNode] Looking for closest detected enemy."); closestEnemy = AiUtils.GetClosestDetectedEnemy(this.unit, targetLance); } if (closestEnemy != null) { if (Main.Settings.AiSettings.FollowAiSettings.StopWhen != "WhenNotNeeded") { Main.LogDebug($"[MoveToFollowLanceNode] Detected enemy. No longer following player mech."); return(new BehaviorTreeResults(BehaviorNodeState.Failure)); } else { Main.LogDebug($"[MoveToFollowLanceNode] Enemies detected but keeping tight formation still. Following player mech."); } } else { Main.LogDebug($"[MoveToFollowLanceNode] No enemies detected. Following player mech."); } List <AbstractActor> lanceMembers = AIUtil.GetLanceUnits(this.unit.Combat, this.unit.LanceId); float travelDistance = Mathf.Max(this.unit.MaxSprintDistance, this.unit.MaxWalkDistance); if (this.waitForLance) { for (int i = 0; i < lanceMembers.Count; i++) { AbstractActor abstractActor = lanceMembers[i] as AbstractActor; if (abstractActor != null) { float lanceMemberTravelDistance = Mathf.Max(abstractActor.MaxWalkDistance, abstractActor.MaxSprintDistance); travelDistance = Mathf.Min(travelDistance, lanceMemberTravelDistance); } } } AbstractActor targetActor = GetMechToFollow(targetLance); if (targetActor == null) { Main.Logger.LogError("[MoveToFollowLanceNode] Target Actor is null"); return(new BehaviorTreeResults(BehaviorNodeState.Failure)); } Main.LogDebug($"[MoveToFollowLanceNode] Target to follow is '{targetActor.DisplayName} {targetActor.VariantName}'"); bool shouldSprint = this.tree.GetCustomBehaviorVariableValue(FOLLOW_LANCE_SHOULD_SPRINT_KEY).BoolVal; Main.LogDebug($"[MoveToFollowLanceNode] Should sprint by behaviour value being set? '{shouldSprint}'"); shouldSprint = (!this.unit.HasAnyContactWithEnemy); Main.LogDebug($"[MoveToFollowLanceNode] Should sprint by contact with enemy? '{shouldSprint}'"); shouldSprint = (this.unit.CurrentPosition - targetActor.CurrentPosition).magnitude > Main.Settings.AiSettings.FollowAiSettings.MaxDistanceFromTargetBeforeSprinting; // sprint if the unit is over 200 metres away Main.LogDebug($"[MoveToFollowLanceNode] Is the follow target further than 200m? Should sprint? '{shouldSprint}'"); Vector3 lookDirection = (closestEnemy == null) ? targetActor.CurrentPosition : closestEnemy.CurrentPosition; MoveType moveType = (shouldSprint) ? MoveType.Sprinting : MoveType.Walking; this.unit.Pathing.UpdateAIPath(targetActor.CurrentPosition, lookDirection, moveType); Vector3 vectorToTarget = this.unit.Pathing.ResultDestination - this.unit.CurrentPosition; float distanceToTarget = vectorToTarget.magnitude; if (distanceToTarget > travelDistance) { Main.LogDebug($"[MoveToFollowLanceNode] Can't reach follow target in one go so will go as far as I can"); // If the target is out of range, head in the direction of that unit to the maximum possible travel distance for this turn vectorToTarget = vectorToTarget.normalized * travelDistance; } // Ensure the units aren't crowded Vector3 targetDestination = RoutingUtil.Decrowd(this.unit.CurrentPosition + vectorToTarget, this.unit); targetDestination = RegionUtil.MaybeClipMovementDestinationToStayInsideRegion(this.unit, targetDestination); float followLanceZoneRadius = this.unit.BehaviorTree.GetCustomBehaviorVariableValue(FOLLOW_LANCE_ZONE_RADIUS_KEY).FloatVal; Main.LogDebug($"[MoveToFollowLanceNode] My follow zone radius is '{followLanceZoneRadius}'"); if (RoutingUtils.IsUnitInsideRadiusOfPoint(this.unit, targetActor.CurrentPosition, followLanceZoneRadius)) { Main.LogDebug($"[MoveToFollowLanceNode] ...and I am inside that zone."); return(new BehaviorTreeResults(BehaviorNodeState.Failure)); } else { Main.LogDebug($"[MoveToFollowLanceNode] ...and I am NOT inside that zone."); } this.unit.Pathing.UpdateAIPath(targetDestination, lookDirection, moveType); targetDestination = this.unit.Pathing.ResultDestination; float maxCost = this.unit.Pathing.MaxCost; PathNodeGrid currentGrid = this.unit.Pathing.CurrentGrid; Vector3 targetActorPosition = targetActor.CurrentPosition; // This method seems to get called all the time - this is meant to be a last resort method I think. I wonder why the other AI pathfinding methods don't work? if ((currentGrid.GetValidPathNodeAt(targetDestination, maxCost) == null || (targetDestination - targetActor.CurrentPosition).magnitude > 1f) && this.unit.Combat.EncounterLayerData.inclineMeshData != null) { float maxSlope = Mathf.Tan(0.0174532924f * AIUtil.GetMaxSteepnessForAllLance(this.unit)); List <AbstractActor> lanceUnits = AIUtil.GetLanceUnits(this.unit.Combat, this.unit.LanceId); targetDestination = this.unit.Combat.EncounterLayerData.inclineMeshData.GetDestination(this.unit.CurrentPosition, targetDestination, maxCost, maxSlope, this.unit, shouldSprint, lanceUnits, this.unit.Pathing.CurrentGrid, out targetActorPosition); } Vector3 currentPosition = this.unit.CurrentPosition; AIUtil.LogAI(string.Format("issuing order from [{0} {1} {2}] to [{3} {4} {5}] looking at [{6} {7} {8}]", new object[] { currentPosition.x, currentPosition.y, currentPosition.z, targetDestination.x, targetDestination.y, targetDestination.z, targetActorPosition.x, targetActorPosition.y, targetActorPosition.z }), "AI.DecisionMaking"); // TODO: Factor in jump mechs return(new BehaviorTreeResults(BehaviorNodeState.Success) { orderInfo = new MovementOrderInfo(targetDestination, targetActorPosition) { IsSprinting = shouldSprint }, debugOrderString = string.Format("{0} moving toward destination: {1} dest: {2}", this.name, targetDestination, targetActor.CurrentPosition) }); }