public void DrawHorizontalLine2D(GridContext bgc, int x1, int x2, int y, int z) { for (int x = x1; x <= x2; x++) { DrawPen(bgc, x, y, z); } }
public JsonResult GetGridData(GridContext ctx) { IQueryable <Department> query = this.departmentsRepo; var totalCount = query.Count(); if (ctx.HasFilters) { query = ctx.ApplyFilters(query); totalCount = query.Count(); } if (ctx.HasSorting) { switch (ctx.SortOrder) { case SortOrder.Asc: query = this.departmentsRepo.SortByAsc(ctx.SortColumn); break; case SortOrder.Desc: query = this.departmentsRepo.SortByDesc(ctx.SortColumn); break; } } var departments = query.OrderBy(x => x.Id).Skip(ctx.Skip).Take(ctx.Take).Select(Mapper.Map <DepartmentModel>); return(Json(new { Departments = departments, TotalCount = totalCount }, JsonRequestBehavior.AllowGet)); }
//Greyscale all pixels in Grid public void Grayscale(GridContext bgc) { if (bgc == null) { return; } Grid grid = bgc.Grid; for (int z = 0; z < grid.SizeZ; z++) { for (int y = 0; y < grid.SizeY; y++) { for (int x = 0; x < grid.SizeX; x++) { ulong u = grid.GetRgba(x, y, z); byte r, g, b, a; Converter.Ulong2Rgba(u, out r, out g, out b, out a); var lum = (byte)((r + g + b) / 3); r = g = b = lum; u = Converter.Rgba2Ulong(r, g, b, a); grid.Plot(x, y, z, u); } } } }
//Draw Polygon to Grid public void DrawPolygon(GridContext bgc, PenTwist twistType, int x, int y, int z, int radius, int sides) { double angleSize = 360.0 / sides; for (int i = 0; i < sides; i++) { double vx1 = radius; double vy1 = 0; var angle1 = (int)(i * angleSize); MathTrigonometry.RotateZ(-angle1, ref vx1, ref vy1); double vx2 = radius; double vy2 = 0; var angle2 = (int)((i + 1) * angleSize); MathTrigonometry.RotateZ(-angle2, ref vx2, ref vy2); if (i == sides - 1) //connect last segment { vx2 = radius; vy2 = 0; } DrawAxisLine2D(bgc, twistType, x + (int)vx1, y + (int)vy1, x + (int)vx2, y + (int)vy2, z); } }
//Flip Grid along depth public void FlipZ(GridContext bgc) { if (bgc == null) { return; } Grid grid = bgc.Grid; //Inhibit because it would affect ALL pixels grid.InhibitCodeTracking(); for (int by = 0; by < grid.SizeY; by++) { for (int bx = 0; bx < grid.SizeX; bx++) { for (int bz = 0; bz < grid.SizeZ / 2; bz++) { ulong b1 = grid.GetRgba(bx, by, bz); ulong b2 = grid.GetRgba(bx, by, grid.SizeY - bz - 1); grid.Plot(bx, by, grid.SizeY - bz - 1, b1); grid.Plot(bx, by, bz, b2); } } } grid.AllowCodeTracking(); }
public JsonResult GetGridData(GridContext ctx) { IQueryable<Job> query = this.jobsRepo; var totalCount = query.Count(); if (ctx.HasFilters) { query = ctx.ApplyFilters(query); totalCount = query.Count(); } if (ctx.HasSorting) { switch (ctx.SortOrder) { case SortOrder.Asc: query = this.jobsRepo.SortByAsc(ctx.SortColumn, query); break; case SortOrder.Desc: query = this.jobsRepo.SortByDesc(ctx.SortColumn, query); break; } } var jobs = query.OrderBy(x=>x.Id).Skip(ctx.Skip).Take(ctx.Take).ToList().Select(Mapper.Map<JobModel>); return Json(new { Jobs = jobs, TotalCount = totalCount }, JsonRequestBehavior.AllowGet); }
//Draw supports under suspended corner points public void DrawCorners(GridContext bgc, int x1, int y1, int z1, int x2, int y2, int z2) { if (bgc == null) { return; } //Ensure x2 >= x1, y2 >= y1, z2 >= z1 MinMax(ref x1, ref x2); MinMax(ref y1, ref y2); MinMax(ref z1, ref z2); Grid grid = bgc.Grid; ulong val; for (int y = y2; y >= y1; y--) { for (int x = x1; x < x2; x++) { for (int z = z1; z < z2; z++) { if (MatchRule3D(grid, x, y, z, out val)) { grid.Plot(x, y, z, val); } } } } }
//Rotate Grid on Z public void RotateZ(GridContext bgc) { if (bgc == null) { return; } //Unit size check if (bgc.Grid.SizeX != bgc.Grid.SizeY) { return; } var grid2 = new Grid(bgc.Grid.SizeX, bgc.Grid.SizeY, bgc.Grid.SizeZ, bgc.Grid.Bpp); //grid2.CopyFrom(bgc.Grid); for (int z = 0; z < bgc.Grid.SizeZ; z++) { for (int y = 0; y < bgc.Grid.SizeY; y++) { for (int x = 0; x < bgc.Grid.SizeX; x++) { ulong u = bgc.Grid.GetRgba(x, y, z); grid2.Plot(y, x, z, u); } } } bgc.Grid.CopyFrom(grid2); }
//Add rgba blocks above edge neighbors public void UpV(GridContext bgc, int reps, byte ri, byte gi, byte bi, byte ai) { if (bgc == null) { return; } Grid grid = bgc.Grid; grid.InhibitCodeTracking(); for (int z = 0; z < grid.SizeZ; z++) { for (int y = grid.SizeY - 1; y >= 0; y--) { for (int x = 0; x < grid.SizeX; x++) { ulong u = grid.GetRgba(x, y, z); ulong rgba = Converter.Rgba2Ulong(ri, gi, bi, ai); if (rgba == u) { for (int i = 0; i < reps; i++) { if (grid.GetRgba(x, y + i, z) == 0) { grid.Plot(x, y + i, z, u); } } } } } } grid.AllowCodeTracking(); }
public static IMVCGridRenderingEngine GetRenderingEngine(GridContext gridContext) { IMVCGridRenderingEngine renderingEngine = null; if (!String.IsNullOrWhiteSpace(gridContext.QueryOptions.RenderingEngineName)) { foreach (ProviderSettings configuredEngine in gridContext.GridDefinition.RenderingEngines) { if (String.Compare(gridContext.QueryOptions.RenderingEngineName, configuredEngine.Name, true) == 0) { string engineName = gridContext.QueryOptions.RenderingEngineName; string typeString = gridContext.GridDefinition.RenderingEngines[engineName].Type; Type engineType = Type.GetType(typeString, true); renderingEngine = (IMVCGridRenderingEngine)Activator.CreateInstance(engineType, true); } } } if (renderingEngine == null) { renderingEngine = GetRenderingEngineInternal(gridContext.GridDefinition); } return(renderingEngine); }
public GridController(ILogger <GridController> logger, GridContext context, IWebHostEnvironment webHostEnvironment) { _logger = logger; _context = context; _webHostEnvironment = webHostEnvironment; _gridRepository = new GridRepository(_logger, _context, webHostEnvironment); }
// GET: Fallback public ActionResult Index() { var context = MvcRenderingContext.GetFromViewContext(this.ControllerContext.ParentActionViewContext); var gridContext = GridContext.GetFromRenderingContext(context); return(View(ViewName, null)); }
//Draw set points to Grid private static void Fastcpoints(GridContext bgc, int x, int y, int xc, int yc, int zc) { Dualplot(bgc, -x + xc, y + yc, x + xc, zc); Dualplot(bgc, -y + xc, x + yc, y + xc, zc); Dualplot(bgc, -x + xc, -y + yc, x + xc, zc); Dualplot(bgc, -y + xc, -x + yc, y + xc, zc); }
public virtual JsonResult GetGridData(GridContext ctx) { var curUser = this.usersRepo.FindOne(new UserByLoginSpecify(User.Identity.Name)); IQueryable <Test> query = curUser.AssignedTests.AsQueryable(); var totalCount = query.Count(); if (ctx.HasFilters) { query = ctx.ApplyFilters(query); totalCount = query.Count(); } if (ctx.HasSorting) { switch (ctx.SortOrder) { case SortOrder.Asc: query = this.testsRepo.SortByAsc(ctx.SortColumn, query); break; case SortOrder.Desc: query = this.testsRepo.SortByDesc(ctx.SortColumn, query); break; } } Mapper.CreateMap <AssignedTestModel, Test>().ReverseMap(); var data = query.OrderBy(x => x.Id).Skip(ctx.Skip).Take(ctx.Take).ToList().Select(Mapper.Map <AssignedTestModel>); return(Json(new { Data = data, TotalCount = totalCount }, JsonRequestBehavior.AllowGet)); }
public override void WriteSearchableText(GridContext context, TextWriter writer) { if (Value != null) { writer.WriteLine(Regex.Replace(Value, "<.*?>", " ")); } }
//Render a grid into another grid with oblique perspective and iconic cells public static void RenderObliqueCellsSetRects(RectList rects, Grid gridDst) { GridContext bgc = new GridContext(gridDst); const int cellSize = 7; const int tinSize = 4; foreach (Rect rect in rects) { ulong u = rect.Properties.Rgba; bgc.Pen.SetColor(u); if (u != 0) { var x1 = (int)rect.Pt1[0]; var y1 = (int)rect.Pt1[1]; var z1 = (int)rect.Pt1[2]; int sx1 = x1 * cellSize + z1 * tinSize; int sy1 = gridDst.SizeY - (z1 + 1) * 4 - cellSize - 1 - y1 * cellSize; var x2 = (int)rect.Pt2[0]; var y2 = (int)rect.Pt2[1]; var z2 = (int)rect.Pt2[2]; int sx2 = x2 * cellSize + z2 * tinSize; int sy2 = gridDst.SizeY - (z2 + 1) * 4 - cellSize - 1 - y2 * cellSize; bgc.Pen.SetColor(u); RenderCell(bgc, sx1, sy1); bgc.Pen.SetColor(u); RenderCell(bgc, sx2, sy2); } } }
//Draw filled circle in two dimensions public void DrawFillCircle2D(GridContext bgc, PenTwist ptt, int x1, int y1, int z, int radius) { int sx = radius, sy = 0; int radiusError = 1 - sx; while (sx >= sy) { DrawHorizontalLine(bgc, ptt, sx + x1, -sx + x1, sy + y1, z); DrawHorizontalLine(bgc, ptt, sy + x1, -sy + x1, sx + y1, z); DrawHorizontalLine(bgc, ptt, sx + x1, -sx + x1, -sy + y1, z); DrawHorizontalLine(bgc, ptt, sy + x1, -sy + x1, -sx + y1, z); sy++; if (radiusError < 0) { radiusError += 2 * sy + 1; } else { sx--; radiusError += 2 * (sy - sx + 1); } } }
private static string GenerateClientJsonVisibility(GridContext gridContext) { var gridColumns = gridContext.GridDefinition.GetColumns(); StringBuilder sb = new StringBuilder(); foreach (var cv in gridContext.QueryOptions.ColumnVisibility) { var gridColumn = gridColumns.SingleOrDefault(p => p.ColumnName == cv.ColumnName); if (sb.Length > 0) { sb.Append(","); } sb.AppendFormat("\"{0}\": {{", cv.ColumnName); sb.AppendFormat("\"{0}\": \"{1}\"", "headerText", HttpUtility.JavaScriptStringEncode(gridColumn.HeaderText)); sb.Append(","); sb.AppendFormat("\"{0}\": {1}", "visible", cv.Visible.ToString().ToLower()); sb.Append(","); sb.AppendFormat("\"{0}\": {1}", "allow", gridColumn.AllowChangeVisibility.ToString().ToLower()); sb.Append("}"); } return(sb.ToString()); }
public virtual JsonResult GetGridData(GridContext ctx) { var curUser = this.usersRepo.FindOne(new UserByLoginSpecify(User.Identity.Name)); IQueryable<Test> query = curUser.AssignedTests.AsQueryable(); var totalCount = query.Count(); if (ctx.HasFilters) { query = ctx.ApplyFilters(query); totalCount = query.Count(); } if (ctx.HasSorting) { switch (ctx.SortOrder) { case SortOrder.Asc: query = this.testsRepo.SortByAsc(ctx.SortColumn, query); break; case SortOrder.Desc: query = this.testsRepo.SortByDesc(ctx.SortColumn, query); break; } } Mapper.CreateMap<AssignedTestModel, Test>().ReverseMap(); var data = query.OrderBy(x => x.Id).Skip(ctx.Skip).Take(ctx.Take).ToList().Select(Mapper.Map<AssignedTestModel>); return Json(new { Data = data, TotalCount = totalCount }, JsonRequestBehavior.AllowGet); }
//Render triangles dRectly to a grid by drawing the triangles public void RenderTrianglesToGrid(Triangles triangles, Grid grid) { if (triangles == null || grid == null) { return; } IPainter painter = new CPainter(); GridContext bgc = new GridContext(grid); float sx = grid.SizeX - 1; float sy = grid.SizeY - 1; float sz = grid.SizeZ - 1; bgc.Pen.Rgba = RasterLib.RasterApi.Rgba2Ulong(255, 255, 255, 255); foreach (Triangle triangle in triangles.GetTriangleArray()) { var x1 = (int)((triangle.Vertex1[0] + 0.5f) * sx); var y1 = (int)((triangle.Vertex1[1] + 0.5f) * sy); var z1 = (int)((triangle.Vertex1[2] + 0.5f) * sz); var x2 = (int)((triangle.Vertex2[0] + 0.5f) * sx); var y2 = (int)((triangle.Vertex2[1] + 0.5f) * sy); var z2 = (int)((triangle.Vertex2[2] + 0.5f) * sz); var x3 = (int)((triangle.Vertex3[0] + 0.5f) * sx); var y3 = (int)((triangle.Vertex3[1] + 0.5f) * sy); var z3 = (int)((triangle.Vertex3[2] + 0.5f) * sz); //This requires a filled triangle3d function painter.DrawFillTriangle3D(bgc, x1, y1, z1, x2, y2, z2, x3, y3, z3); } }
//Draw a circle on any 3d axis public void DrawCircle2DAnyAxis(GridContext bgc, PenTwist ptt, int x0, int y0, int z, int radius) { int sx = radius, sy = 0; int radiusError = 1 - sx; while (sx >= sy) { DrawAxisPen(bgc, ptt, sx + x0, sy + y0, z); DrawAxisPen(bgc, ptt, sy + x0, sx + y0, z); DrawAxisPen(bgc, ptt, -sx + x0, sy + y0, z); DrawAxisPen(bgc, ptt, -sy + x0, sx + y0, z); DrawAxisPen(bgc, ptt, -sx + x0, -sy + y0, z); DrawAxisPen(bgc, ptt, -sy + x0, -sx + y0, z); DrawAxisPen(bgc, ptt, sx + x0, -sy + y0, z); DrawAxisPen(bgc, ptt, sy + x0, -sx + y0, z); sy++; if (radiusError < 0) { radiusError += 2 * sy + 1; } else { sx--; radiusError += 2 * (sy - sx + 1); } } }
public void DrawVerticalLine2D(GridContext bgc, int x, int y1, int y2, int z) { for (int y = y1; y <= y2; y++) { DrawPen(bgc, x, y, z); } }
public void WriteSearchableText(GridContext context, TextWriter writer) { foreach (GridSection section in Sections) { section.WriteSearchableText(context, writer); } }
//Draw an arbitrary shape at XYZ public void DrawShape(GridContext bgc, PenTwist twistType, int type, int x, int y, int z, int scale) { switch (type) { case 0: DrawPen(bgc, x, y, z); break; case 1: DrawLine2D(bgc, x - scale, y - scale, x + scale, y + scale, z); break; case 2: DrawFillRect(bgc, x - scale, y - scale, z - scale, x + scale, y + scale, z + scale); break; case 3: DrawPolygon(bgc, twistType, x, y, z, scale, 3); break; case 4: DrawPolygon(bgc, twistType, x, y, z, scale, 4); break; case 5: DrawPolygon(bgc, twistType, x, y, z, scale, 5); break; case 6: DrawPolygon(bgc, twistType, x, y, z, scale, 6); break; case 7: DrawPolygon(bgc, twistType, x, y, z, scale, 7); break; case 8: DrawPolygon(bgc, twistType, x, y, z, scale, 8); break; case 9: DrawCircle2DAnyAxis(bgc, twistType, x, y, z, scale); break; } }
//Render a grid into another grid with Isometric perspective and iconic cells private static void RenderIsometricCellsSetScaled(Grid gridSrc, Grid gridDst, int tileW, int tileH, string title) { GridContext bgc = new GridContext(gridDst); int cellSizeX = tileW; int cellSizeY = tileH; for (int z = gridSrc.SizeZ - 1; z >= 0; z--) { //Console.Write("\r" +(int)(100 - (float)z/gridSrc.SizeZ * 100)+"%"); DrawProgressBar(title, (int)(100 - (float)z / gridSrc.SizeZ * 100)); for (int y = 0; y < gridDst.SizeY; y++) { for (int x = gridSrc.SizeX - 1; x >= 0; x--) { ulong u = gridSrc.GetRgba(x, y, z); if (u != 0) { bgc.Pen.SetColor(u); int sx = (x - z) * tileW; //int sy = y * (tileH - 1) + (x + z) * tileH / 2; int sy = y * (tileH) + (x + z) * tileH / 2 + tileH * 4; RenderIsometricCellScaled(bgc, sx + gridDst.SizeX / 2 - tileW, gridDst.SizeY - sy + tileH, cellSizeX, cellSizeY); } } } } DrawProgressBar(title, 100); Console.WriteLine(); }
//Render Isometricly and return public Grid RenderIsometricCellsScaled(Grid grid, byte bgR, byte bgG, byte bgB, byte bgA, int cellWidth, int cellHeight, string title = "") { if (grid == null) { return(null); } int cellSizeX = cellWidth; int cellSizeY = cellHeight; int maxSize = (grid.SizeX > grid.SizeZ) ? grid.SizeX : grid.SizeZ; int ix = (int)(maxSize * cellSizeX * 2.2); //int iy = (int)(maxSize * cellSizeY * 1.2);//1.6); int iy = (int)(maxSize * cellSizeY * 2.2); Grid grid2 = new Grid(ix, iy, 1, grid.Bpp); GridContext bgc = new GridContext(grid2) { Pen = { Rgba = RasterLib.RasterApi.Rgba2Ulong(bgR, bgG, bgB, bgA) } }; IPainter painter = new CPainter(); painter.DrawFastFillRect(bgc, 0, 0, 0, grid2.SizeX, grid2.SizeY, 1); RenderIsometricCellsSetScaled(grid, grid2, cellSizeX, cellSizeY, title); return(grid2); }
//Draw a facemask-mitigated hollow rect public void DrawMaskHollowRect(GridContext bgc, int x1, int y1, int z1, int x2, int y2, int z2, byte bitmask) { if ((bitmask & (int)CubeFaceMask.Left) != 0) { DrawHollowRect(bgc, x1, y1, z1, x1, y2, z2); } if ((bitmask & (int)CubeFaceMask.Right) != 0) { DrawHollowRect(bgc, x2, y1, z1, x2, y2, z2); } if ((bitmask & (int)CubeFaceMask.Back) != 0) { DrawHollowRect(bgc, x1, y1, z1, x2, y2, z1); } if ((bitmask & (int)CubeFaceMask.Front) != 0) { DrawHollowRect(bgc, x1, y1, z2, x2, y2, z2); } if ((bitmask & (int)CubeFaceMask.Top) != 0) { DrawHollowRect(bgc, x1, y2, z1, x2, y2, z2); } if ((bitmask & (int)CubeFaceMask.Bottom) != 0) { DrawHollowRect(bgc, x1, y1, z1, x2, y1, z2); } }
public virtual void WriteSearchableText(GridContext context, TextWriter writer) { if (Value != null) { writer.WriteLine(Value); } }
//Render a grid into another grid with oblique perspective and iconic cells public static void RenderObliqueCellsSet(Grid gridSrc, Grid gridDst) { GridContext bgc = new GridContext(gridDst); const int cellSize = 7; const int tinSize = 4; string title = "Rendering Oblique"; for (int y = 0; y < gridSrc.SizeY; y++) { DrawProgressBar(title, (int)((float)y / gridSrc.SizeY * 100)); for (int z = gridSrc.SizeZ; z >= 0; z--) { for (int x = 0; x < gridSrc.SizeX; x++) { ulong u = gridSrc.GetRgba(x, y, z); if (u != 0) { // ulong val = gridSrc.GetRgba(x, y, z); bgc.Pen.SetColor(u); int sx = x * cellSize + z * tinSize; int sy = gridDst.SizeY - (z + 1) * 4 - cellSize - 1 - y * cellSize; RenderCell(bgc, sx, sy); } } } } DrawProgressBar(title, 100); Console.WriteLine(); }
//Draw an arbitrary 2d line to Grid public void DrawLine2D(GridContext bgc, int x1, int y1, int x2, int y2, int z) { if (x1 == x2) { DrawVerticalLine2D(bgc, x1, y1, y2, z); } if (y1 == y2) { DrawHorizontalLine2D(bgc, x1, x2, y1, z); } int dx = Math.Abs(x2 - x1), sx = x1 < x2 ? 1 : -1; int dy = Math.Abs(y2 - y1), sy = y1 < y2 ? 1 : -1; int err = (dx > dy ? dx : -dy) / 2; for (; ;) { DrawPen(bgc, x1, y1, z); if (x1 == x2 && y1 == y2) { break; } int e2 = err; if (e2 > -dx) { err -= dy; x1 += sx; } if (e2 < dy) { err += dx; y1 += sy; } } }
//Colorize all pixels in Grid public void Colorize(GridContext bgc, double hue, double saturation) { if (bgc == null) { return; } Grid grid = bgc.Grid; grid.InhibitCodeTracking(); for (int z = 0; z < grid.SizeZ; z++) { for (int y = 0; y < grid.SizeY; y++) { for (int x = 0; x < grid.SizeX; x++) { ulong u = grid.GetRgba(x, y, z); byte r, g, b, a; Converter.Ulong2Rgba(u, out r, out g, out b, out a); double lum = (byte)((r + g + b) / 3); lum = lum / 5f; u = Converter.Hsl2Rgb(hue, saturation, lum); u = Converter.SetAlpha(u, a); grid.Plot(x, y, z, u); } } } grid.AllowCodeTracking(); }
public JsonResult DeleteWatchList(int id, [FromJson] GridContext gridContext) { // Delete and return new grid model as JSON result if the delete was successful. this.DeleteWatchListItem(id); return(Json(this.CreateWatchListGridModel(gridContext))); }
public JsonResult GetGridData(GridContext ctx) { var curUser = this.usersRepo.FindOne(new UserByLoginSpecify(User.Identity.Name)); Mapper.CreateMap<SkillCategory, MySkillCategoryModel>(); var mySkillsCats = curUser.UsersSkills.Select(x => x.SkillCategory).Distinct().Select(Mapper.Map<MySkillCategoryModel>); return this.Json(new {MySkillsCats = mySkillsCats, TotalCount = mySkillsCats.Count()}, JsonRequestBehavior.AllowGet); }
public JsonResult GetAssignedTests(GridContext ctx) { var userId = ctx.Filters.Select(x => x.Filter1).Single(x => x.Field.Equals("UserId")).Value; var user = this.usersRepo.FindOne(new ByIdSpecify<User>(long.Parse(userId))); var data = user.AssignedTests.Select(Mapper.Map<Test, AssignedTestModel>); return Json(new {Data = data, TotalCount = data.Count()}, JsonRequestBehavior.AllowGet); }
public JsonResult GetDetailedRowGridData(GridContext ctx) { var curUser = this.usersRepo.FindOne(new UserByLoginSpecify(User.Identity.Name)); var mySkills = curUser.UsersSkills.AsQueryable(); if (ctx.HasFilters) { mySkills = ctx.ApplyFilters(mySkills); } return Json(new {Skills = mySkills.Select(Mapper.Map<MySkillModel>), TotalCount = mySkills.Count()}, JsonRequestBehavior.AllowGet); }
public JsonResult GetDetailedRowGridData(GridContext ctx) { var curUser = this.jobsRepo.FindOne(new ByIdSpecify<Job>(this.CurrentJobId)); var mySkills = curUser.JobSkills.AsQueryable(); if (ctx.HasFilters) { mySkills = ctx.ApplyFilters(mySkills); } return Json(new { Skills = mySkills.Select(Mapper.Map<JobSkillModel>), TotalCount = mySkills.Count() }, JsonRequestBehavior.AllowGet); }
public JsonResult GetGridData(GridContext ctx) { IQueryable<JobApplication> query = this.jobAppRepo.OrderBy(x => x.Id); //if (ctx.Filters.Any(f => f.Filter1.Field.Equals("ReqNotLow"))) //{ // var jobId = ctx.Filters.Select(x => x.Filter1).Single(x => x.Field.Equals("JobId")).Value; // query = this.SelectHasAllRequiredSkillsAndNotLower(long.Parse(jobId)); // var filter = ctx.Filters.Single(f => f.Filter1.Field.Equals("ReqNotLow")); // ctx.Filters.Remove(filter); //} //else if (ctx.Filters.Any(f => f.Filter1.Field.Equals("Req"))) //{ // var jobId = ctx.Filters.Select(x => x.Filter1).Single(x => x.Field.Equals("JobId")).Value; // query = this.SelectHasAllRequiredSkills(long.Parse(jobId)); // var filter = ctx.Filters.Single(f => f.Filter1.Field.Equals("Req")); // ctx.Filters.Remove(filter); //} //else //{ // query = this.jobAppRepo.OrderBy(x => x.Id); //} var totalCount = query.Count(); if (ctx.HasFilters) { query = ctx.ApplyFilters(query); totalCount = query.Count(); } if (ctx.HasSorting) { switch (ctx.SortOrder) { case SortOrder.Asc: query = this.jobAppRepo.SortByAsc(ctx.SortColumn, query); break; case SortOrder.Desc: query = this.jobAppRepo.SortByDesc(ctx.SortColumn, query); break; } } var jobApplications = query.Skip(ctx.Skip).Take(ctx.Take).ToList().Select(Mapper.Map<JobApplicationModel>); return Json(new { JobApplications = jobApplications, TotalCount = totalCount }, JsonRequestBehavior.AllowGet); }
public JsonResult GetGridData(GridContext ctx) { IQueryable<Job> query; if (ctx.Filters.Any(x => x.Filter1.Field.Equals("ProjectFormalizeNameId"))) { var projectFormalizeNameId = long.Parse(ctx.Filters.Select(x => x.Filter1).Single(c => c.Field.Equals("ProjectFormalizeNameId")).Value); query = this.jobsRepo.Where(x => x.Project.ProjectFormalizeNameId == projectFormalizeNameId); var filter = ctx.Filters.Single(f => f.Filter1.Field.Equals("ProjectFormalizeNameId")); ctx.Filters.Remove(filter); } else { query = this.jobsRepo; } var totalCount = query.Count(); if (ctx.HasFilters) { query = ctx.ApplyFilters(query); totalCount = query.Count(); } if (ctx.HasSorting) { switch (ctx.SortOrder) { case SortOrder.Asc: query = this.jobsRepo.SortByAsc(ctx.SortColumn, query); break; case SortOrder.Desc: query = this.jobsRepo.SortByDesc(ctx.SortColumn, query); break; } } var jobs = query.OrderBy(x => x.Id).Skip(ctx.Skip).Take(ctx.Take).ToList().Select(Mapper.Map<SearchJobModel>); return Json(new { Jobs = jobs, TotalCount = totalCount }, JsonRequestBehavior.AllowGet); }
public JsonResult GetGridData(GridContext ctx) { IQueryable<User> query = this.usersRepo.Where(x => x.JobApplications.Any(a=>a.Job.ProjectId == this.CurrentProjectId)); var totalCount = query.Count(); if (ctx.HasFilters) { query = ctx.ApplyFilters(query); totalCount = query.Count(); } if (ctx.HasSorting) { switch (ctx.SortOrder) { case SortOrder.Asc: query = this.usersRepo.SortByAsc(ctx.SortColumn, query); break; case SortOrder.Desc: query = this.usersRepo.SortByDesc(ctx.SortColumn, query); break; } } var users = query.OrderBy(x => x.Id).Skip(ctx.Skip).Take(ctx.Take).ToList(); var data = new List<CandidateModel>(); foreach (var user in users) { var candidate = Mapper.Map<CandidateModel>(user); // HasSelected if (user.Jobs.Any(x => x.ProjectId == this.CurrentProjectId)) { candidate.HasSelected = true; } else // Not Selected { candidate.HasSelected = false; } // Has Tested if (user.TestResults.Any(x=>user.AssignedTests.Any(a=>a.Id == x.TestId))) { candidate.HasTested = true; } else //Not Tested { candidate.HasTested = false; } // Interview INFO var jobApp = user.JobApplications.First(x => x.Job.ProjectId == this.CurrentProjectId); candidate.HasInterviewed = jobApp.HasInterviewed; candidate.InterviewResult = jobApp.InterviewResult; candidate.InterviewComment = jobApp.InterviewComment; // Calculate PERCENT MATCH JOB PROFILE SKILLS var job = jobApp.Job; candidate.JobId = job.Id; var jobSkills = job.JobSkills; var userSkills = user.UsersSkills; int usersSkillSum = 0; var jobSkillSum = 0; foreach (var jobSkill in jobSkills) { int userEsitmate = 0; if (userSkills.Any(x => x.SkillId == jobSkill.SkillId)) { userEsitmate = userSkills.Single(x => x.SkillId == jobSkill.SkillId).Estimate; } candidate.PercentMatchJobProfile += ((double)userEsitmate / 10 - (double)jobSkill.Estimate / 10) * (double)jobSkill.Estimate / 10; //candidate.Variance += Math.Pow((double)userEsitmate / 10, 2) - Math.Pow((double)jobSkill.Estimate / 10, 2); candidate.Variance += Math.Pow((double)userEsitmate / 10 - (double)jobSkill.Estimate / 10, 2); usersSkillSum += userEsitmate; jobSkillSum += jobSkill.Estimate; } candidate.PercentMatchJobProfile = 1 + candidate.PercentMatchJobProfile; candidate.Variance = Math.Round(candidate.Variance / (jobSkillSum), 2); //var totalJobSkillEst = jobSkills.Sum(x => x.Estimate); //var candPercentage = candidate.PercentMatchJobProfile * 100 / totalJobSkillEst; //candidate.PercentMatchJobProfile = (candPercentage<0) ? 100 - Math.Abs(candPercentage) : candPercentage; // Calculate TESTS RESULTS var assignedTests = user.AssignedTests; var testCompleted = assignedTests.Count(assignedTest => user.TestResults.Any(x => x.TestId == assignedTest.Id)); candidate.TestsCompleted = string.Format("{0} of {1}", testCompleted, assignedTests.Count); data.Add(candidate); } return Json(new { Data = data.OrderByDescending(x=>x.PercentMatchJobProfile), TotalCount = totalCount }, JsonRequestBehavior.AllowGet); }
public JsonResult GetGridData(GridContext ctx) { var curJob = this.jobsRepo.FindOne(new ByIdSpecify<Job>(this.CurrentJobId)); Mapper.CreateMap<SkillCategory, JobSkillCategoryModel>(); var jobSkillCats = curJob.JobSkills.Select(x => x.SkillCategory).Distinct().Select(Mapper.Map<JobSkillCategoryModel>); return this.Json(new { JobSkillCats = jobSkillCats, TotalCount = jobSkillCats.Count() }, JsonRequestBehavior.AllowGet); }
public JsonResult GetGridData(GridContext ctx) { IQueryable<User> query = this.usersRepo.Where(x => this.CurrentSelectedCandidatesIds.Contains(x.Id)); var totalCount = query.Count(); if (ctx.HasFilters) { query = ctx.ApplyFilters(query); totalCount = query.Count(); } if (ctx.HasSorting) { switch (ctx.SortOrder) { case SortOrder.Asc: query = this.usersRepo.SortByAsc(ctx.SortColumn, query); break; case SortOrder.Desc: query = this.usersRepo.SortByDesc(ctx.SortColumn, query); break; } } var data = query.OrderBy(x => x.Id).Skip(ctx.Skip).Take(ctx.Take).ToList().Select(Mapper.Map<User, SelectedCandidateModel>); return Json(new { Data = data, TotalCount = totalCount }, JsonRequestBehavior.AllowGet); }
public JsonResult GetCandidatesGridData(GridContext ctx) { IQueryable<JobApplication> query; if (ctx.Filters.Any(f => f.Filter1.Field.Equals("ReqNotLow"))) { var jobId = ctx.Filters.Select(x => x.Filter1).Single(x => x.Field.Equals("JobId")).Value; query = this.SelectHasAllRequiredSkillsAndNotLower(long.Parse(jobId)); var filter = ctx.Filters.Single(f => f.Filter1.Field.Equals("ReqNotLow")); ctx.Filters.Remove(filter); } else if (ctx.Filters.Any(f => f.Filter1.Field.Equals("Req"))) { var jobId = ctx.Filters.Select(x => x.Filter1).Single(x => x.Field.Equals("JobId")).Value; query = this.SelectHasAllRequiredSkills(long.Parse(jobId)); var filter = ctx.Filters.Single(f => f.Filter1.Field.Equals("Req")); ctx.Filters.Remove(filter); } else { query = this.jobAppRepo.OrderBy(x => x.Id); } var totalCount = query.Count(); if (ctx.HasFilters) { query = ctx.ApplyFilters(query); totalCount = query.Count(); } if (ctx.HasSorting) { switch (ctx.SortOrder) { case SortOrder.Asc: query = this.jobAppRepo.SortByAsc(ctx.SortColumn, query); break; case SortOrder.Desc: query = this.jobAppRepo.SortByDesc(ctx.SortColumn, query); break; } } var jobApplications = query.Skip(ctx.Skip).Take(ctx.Take).ToList().Select(Mapper.Map<CandidateModel>).ToList(); foreach (var jobApp in jobApplications) { // Calculate PERCENT MATCH JOB PROFILE SKILLS var job = this.jobsRepo.FindOne(new ByIdSpecify<Job>(this.CurrentJobId)); var jobSkills = job.JobSkills; var userSkills = this.usersRepo.FindOne(new ByIdSpecify<User>(jobApp.UserId)).UsersSkills; int usersSkillSum = 0; var jobSkillSum = 0; foreach (var jobSkill in jobSkills) { int userEsitmate = 0; if (userSkills.Any(x => x.SkillId == jobSkill.SkillId)) { userEsitmate = userSkills.Single(x => x.SkillId == jobSkill.SkillId).Estimate; } jobApp.PercentMatchJobProfile += ((double)userEsitmate / 10 - (double)jobSkill.Estimate / 10) * (double)jobSkill.Estimate / 10; //jobApp.Variance += Math.Pow((double)userEsitmate / 10, 2) - Math.Pow((double)jobSkill.Estimate / 10, 2); jobApp.Variance += Math.Pow((double)userEsitmate / 10 - (double)jobSkill.Estimate / 10, 2); usersSkillSum += userEsitmate; jobSkillSum += jobSkill.Estimate; } jobApp.PercentMatchJobProfile = 1 + jobApp.PercentMatchJobProfile; jobApp.Variance = Math.Round(jobApp.Variance / (jobSkillSum), 2); //var totalJobSkillEst = jobSkills.Sum(x => x.Estimate); //var candPercentage = jobApp.PercentMatchJobProfile * 100 / totalJobSkillEst; //jobApp.PercentMatchJobProfile = (candPercentage < 0) ? 100 - Math.Abs(candPercentage) : candPercentage; } return Json(new { JobApplications = jobApplications.OrderByDescending(x=>x.PercentMatchJobProfile), TotalCount = totalCount }, JsonRequestBehavior.AllowGet); }
/// <summary> /// Binds the model to a value by using the specified controller context and binding context. /// </summary> /// <returns> /// The bound value. /// </returns> /// <param name="controllerContext">The controller context.</param><param name="bindingContext">The binding context.</param> public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { var model = new GridContext { Take = int.Parse(controllerContext.HttpContext.Request["take"]), Skip = int.Parse(controllerContext.HttpContext.Request["skip"]), Page = int.Parse(controllerContext.HttpContext.Request["page"]), PageSize = int.Parse(controllerContext.HttpContext.Request["pageSize"]), SortOrder = controllerContext.HttpContext.Request["sort[0][dir]"] == "asc" ? SortOrder.Asc : SortOrder.Desc, SortColumn = controllerContext.HttpContext.Request["sort[0][field]"], FilterLogic = controllerContext.HttpContext.Request["filter[logic]"] == "or" ? FilterLogic.Or : FilterLogic.And }; //build filter objects var filters = new List<FilterSet>(); int x = 0; while (x < 20) { var logic = controllerContext.HttpContext.Request["filter[filters][" + x + "][logic]"]; FilterSet filterSet = null; if (logic == null) { var field = controllerContext.HttpContext.Request["filter[filters][" + x + "][field]"]; if (field == null) { break; } var val = controllerContext.HttpContext.Request["filter[filters][" + x + "][value]"] ?? string.Empty; var strop = controllerContext.HttpContext.Request["filter[filters][" + x + "][operator]"]; filterSet = new FilterSet { Filter1 = new FilterInfo { Operator = FilterInfo.ParseOperator(strop), Field = field, Value = val } }; } else { var field1 = controllerContext.HttpContext.Request["filter[filters][" + x + "][filters][0][field]"]; var oper1 = controllerContext.HttpContext.Request["filter[filters][" + x + "][filters][0][operator]"]; var val1 = controllerContext.HttpContext.Request["filter[filters][" + x + "][filters][0][value]"]; var field2 = controllerContext.HttpContext.Request["filter[filters][" + x + "][filters][1][field]"]; var oper2 = controllerContext.HttpContext.Request["filter[filters][" + x + "][filters][1][operator]"]; var val2 = controllerContext.HttpContext.Request["filter[filters][" + x + "][filters][1][value]"]; filterSet = new FilterSet { Filter1 = new FilterInfo { Field = field1, Operator = FilterInfo.ParseOperator(oper1), Value = val1 }, Filter2 = new FilterInfo { Field = field2, Operator = FilterInfo.ParseOperator(oper2), Value = val2 }, Logic = FilterSet.ParseLogic(logic) }; } filters.Add(filterSet); x++; } model.Filters = filters; return model; }