// GET: Garis public async Task <IActionResult> Index() { QCekGaris qGrs = new QCekGaris(_context, 3); qGrs.UpdateDariGambar(); var rabContext = _context.TblGaris.Include(g => g.KoordAkhir).Include(g => g.KoordAwal); return(View(await rabContext.ToListAsync())); }
public IActionResult KompGaris(int? polaId, int? garisId, int? koorId, int? skl, bool inzet = false) { var sesPola = SPola.GetSesi(this); int _polaId = 0; if (polaId == null || polaId == 0) { _polaId = sesPola.PolaId; } else { _polaId = (int)polaId; } if(garisId != null) { // simpan ke sessi sesPola.SetGarisId(garisId); } else { garisId = sesPola.GarisId; } if (skl != null) { // simpan ke sessi sesPola.SetSkala(skl); } else { skl = sesPola.Skala; } //tidak ada pilihan pola decimal skala = (decimal)skl; var polaNama = ""; //int polId = ; var mvKompGaris = new MVGambarKompGaris(); var mvGambarGarisParsial = new MVGambarGarisParsial() { Skala = skala / 100, PolaId = _polaId }; var mvGambarGarisValid = new MVGambarGarisValid() { Skala = skala / 100, PolaId = _polaId }; if (_polaId != 0) { #region garis valid polaNama = _context.TblPola.Find(_polaId).Nama; var qGaris = new List<Garis>().AsQueryable(); var qGrsKoor = new List<OKetGarisKoordinat>().AsQueryable(); var qTtkKoor = new List<Koordinat>().AsQueryable(); try { QCekGaris qcGaris = new QCekGaris(_context, _polaId); qcGaris.UpdateDariGambar(); qGaris = qcGaris.QryTblIniPosUpToDate.OrderBy(g => g.Arah); // memperbaharui tabel garis di pola terpilih QCekGaris qGrs = new QCekGaris(_context, _polaId); qGrs.UpdateDariGambar(); QCekKoordinat qKoor = new QCekKoordinat(_context, _polaId); qGrsKoor = qKoor.GarisKoordinat; qTtkKoor = qKoor.QryTblIniPosUpToDate; // filter titik koordinat yang ada garis saja-------------------- var lstKoorAwalGrs = qGaris.Select(g => g.KoordAwal.KoordId).ToList(); var lstKoorAkhirGrs = qGaris.Select(g => g.KoordAkhir.KoordId).ToList(); qTtkKoor = qTtkKoor.Where(t => lstKoorAwalGrs.Contains(t.KoordId) || lstKoorAkhirGrs.Contains(t.KoordId)); //--------------------------------------------------------------------------------------------------------- mvGambarGarisValid.TinggiMax = qGrsKoor.Where(g => g.Garis.Arah == ESumbu.Y) .Select(s => s.Garis.Akhir.TitikY.PosAbs).Max() + 300; mvGambarGarisValid.LebarMax = qGrsKoor.Where(g => g.Garis.Arah == ESumbu.X) .Select(s => s.Garis.Akhir.TitikX.PosAbs).Max() + 300; //buat garis koordinat } catch (Exception) { } mvGambarGarisValid.LstGarisReal = qGaris.ToList(); mvGambarGarisValid.LstGrsKoord = qGrsKoor.ToList(); mvGambarGarisValid.LstKoord = qTtkKoor.ToList(); #endregion #region garis parsial var garis = new Garis(); try { // for test //garisId = 1; QCekGaris qcGaris = new QCekGaris(_context, _polaId); garis = qcGaris.QryTblIniPosUpToDate.Single(g => g.GarisId == (int)garisId); //OrderBy(g => g.Arah); QCekKoordinat qKoor = new QCekKoordinat(_context, _polaId); qGrsKoor = qKoor.GarisKoordinat4Z; qTtkKoor = qKoor.QryTblIni4ZPosUpToDate; mvGambarGarisParsial.TinggiMax = qGrsKoor.Where(g => g.Garis.Arah == ESumbu.Y) .Select(s => s.Garis.Akhir.TitikY.PosRel).Max(); } catch (Exception) { } if (garisId != 0) { QCekKompGaris qcKGaris = new QCekKompGaris(_context, _polaId, (int) garisId); mvGambarGarisParsial.GarisReal = garis; mvGambarGarisParsial.LstGarisKomp = qcKGaris.GarisKomponen.ToList(); } mvGambarGarisParsial.LstGrsKoord = qGrsKoor.ToList(); mvGambarGarisParsial.LstKoord = qTtkKoor.ToList(); #endregion mvKompGaris.GarisValid = mvGambarGarisValid; mvKompGaris.GarisParsial = mvGambarGarisParsial; // menambang tabel komponen garis var tblKompGaris = _context.TblKomponenGaris .Include(k => k.Garis) .Include(g => g.Garis.KoordAwal) .Include(g => g.Garis.KoordAkhir) .Include(g => g.Garis.KoordAwal.TitikX) .Include(g => g.Garis.KoordAwal.TitikY) .Include(g => g.Garis.KoordAkhir.TitikX) .Include(g => g.Garis.KoordAkhir.TitikY) .Include(k => k.PolaKomponen).ThenInclude(p => p.Komponen) .Include(k => k.TitikZ) .Where(k => k.Garis.GarisId == garisId) ; mvKompGaris.GarisParsial.TblKompGaris = tblKompGaris; } ViewBag.Skala = skala / 50; ViewBag.GarisTerpilih = garisId; ViewBag.KoordTerpilih = koorId; bool isAjax = HttpContext.Request.Headers["X-Requested-With"] == "XMLHttpRequest"; if (isAjax) { if (inzet) { return PartialView("RAB/_ViewGambarKompGaris", mvGambarGarisValid); } else { return PartialView("RAB/_ViewGambarGarisParsial", mvGambarGarisParsial); } } //ViewBag.PolaNama = polaNama; ViewBag.ListSkala = new SelectList(LstSkala, "Nilai", "Nama", skala); return View(mvKompGaris); }