/* ========================================= */ /* SORTING CALLS */ /* ========================================= */ /* Load more results */ public IActionResult loadMore() { HttpContext.Session.SetInt32("load_no", (HttpContext.Session.GetInt32("load_no") ?? 1) + 1); int loadNo = HttpContext.Session.GetInt32("load_no") ?? 1; int loaded = _context.resultsCount(); bool searchFlag, dateFlag; searchFlag = dateFlag = false; string searchFlagTerm, dateFlagStart, dateFlagEnd; searchFlagTerm = dateFlagStart = dateFlagEnd = string.Empty; modelDataResult[] retval; if (!HttpContext.Session.GetString("lastsearch").Equals("none")) { searchFlag = true; searchFlagTerm = HttpContext.Session.GetString("lastsearch"); } if (HttpContext.Session.GetString("datefilter").Split("-")[0].Equals("on")) { dateFlag = true; dateFlagStart = HttpContext.Session.GetString("datefilter").Split("-")[1]; dateFlagEnd = HttpContext.Session.GetString("datefilter").Split("-")[2]; } if (searchFlag && dateFlag) { retval = _context.getFromSearch ( searchFlagTerm, loadNo, _context.returnallabsoluteResultsTimeframe(Convert.ToDateTime(dateFlagStart), Convert.ToDateTime(dateFlagEnd), loadNo) ); } else if (searchFlag) { retval = _context.getFromSearch(searchFlagTerm, loadNo, _context.allResults()); } else if (dateFlag) { retval = _context.returnallabsoluteResultsTimeframe(Convert.ToDateTime(dateFlagStart), Convert.ToDateTime(dateFlagEnd), loadNo); } else { retval = _context.allResultsNewSort(loadNo); } modelPackage pckg = new modelPackage() { dataresults = retval, total = retval.Length, count = loaded }; return(PartialView("_PartialData", pckg)); }
/* Update progress */ public IActionResult updateProgress() { modelPackage pckg = new modelPackage() { progress = HttpContext.Session.GetString("progress") }; return(PartialView("_PartialProgress", pckg)); }
/* Update adminpanel:instruments model */ public IActionResult updateInstruments() { modelPackage pckg = new modelPackage() { instruments = _context.returnAllInstruments() }; return(PartialView("_PartialInstruments", pckg)); }
/* Update adminpanel:users model */ public IActionResult updateUsers() { modelPackage pckg = new modelPackage() { credentials = _context.returnAllAccounts() }; return(PartialView("_PartialAccount", pckg)); }
public modelPackage updatePage(int num) { modelPackage retPckg = new modelPackage() { dataresults = _context.allResultsNewSort(num) }; return(retPckg); }
public IActionResult updatefeed() { modelPackage pckg = new modelPackage() { progress2 = HttpContext.Session.GetInt32("DEV_currentamount") ?? 1, count = HttpContext.Session.GetInt32("DEV_totalamount") ?? 1, elapsed = HttpContext.Session.GetString("DEV_timestarted"), endtime = HttpContext.Session.GetString("DEV_timeended") }; return(PartialView("_PartialDev", pckg)); }
/* Update database management */ public IActionResult updateDatabasePanel() { modelPackage pckg = new modelPackage() { count = _context.resultsCount(), counttrack = _context.returnTableCountTrack(), totalInstruments = _context.returnAllInstruments().Count(), countusers = _context.returnAllAccounts().Count() }; return(PartialView("_PartialDBManage", pckg)); }
/* Add new tag to database */ public IActionResult addNewTag(string name) { var random = new Random(); modelTag newtag = new modelTag(); newtag.name = name; newtag.color = String.Format("#{0:X6}", random.Next(0x1000000)); _context.addEntry(newtag); modelPackage pckg = new modelPackage(); return(PartialView("_PartialTagDrop", pckg)); }
/* ========================================= */ /* MAIN HANDLERS */ /* ========================================= */ /* Main index view*/ public IActionResult Index() { HttpContext.Session.SetInt32("load_no", 1); modelPackage pckg = new modelPackage(); pckg.instruments = _context.returnAllInstruments(); HttpContext.Session.SetInt32("lastAmount", _context.resultsCount()); HttpContext.Session.SetString("progress", "No progress to display"); HttpContext.Session.SetString("datefilter", "off-x-x"); return(View(pckg)); }
/* Update dates */ public IActionResult UpdateDates(string dates) { var splitted = dates.Split(","); var sD = splitted[0].Split(" "); var eD = splitted[1].Split(" "); string startDateFormatted = sD[0] + " " + sD[1] + " " + sD[2] + " " + sD[3] + " " + sD[4]; string endDateFormatted = eD[0] + " " + eD[1] + " " + eD[2] + " " + eD[3] + " " + eD[4]; DateTime startDate = Convert.ToDateTime(startDateFormatted); DateTime endDate = Convert.ToDateTime(endDateFormatted); modelDataResult[] results; int loadNo = HttpContext.Session.GetInt32("load_no") ?? 1; int count; if (!HttpContext.Session.GetString("lastsearch").Equals("none")) { string x = HttpContext.Session.GetString("lastsearch"); results = _context.getFromSearch ( HttpContext.Session.GetString("lastsearch"), loadNo, _context.returnallResultsTimeframeAll(startDate, endDate) ); count = _context.getFromSearch ( HttpContext.Session.GetString("lastsearch"), loadNo, _context.returnallResultsTimeframeAll(startDate, endDate) ).Length; } else { results = _context.returnallResultsTimeframe(startDate, endDate, HttpContext.Session.GetInt32("load_no") ?? 1); count = _context.returnallResultsTimeframeAll(startDate, endDate).Length; } modelPackage pckg = new modelPackage() { dataresults = results, total = count, }; HttpContext.Session.SetString("datefilter", "on-" + startDateFormatted + "-" + endDateFormatted); return(PartialView("_PartialData", pckg)); }
/* Update data model */ public IActionResult updateModel() { HttpContext.Session.SetInt32("load_no", 1); HttpContext.Session.SetString("lastsearch", "none"); HttpContext.Session.SetInt32("lastAmount", _context.resultsCount()); HttpContext.Session.SetString("datefilter", "off-x-x"); modelPackage pckg = new modelPackage() { dataresults = _context.allResultsNewSort(1), total = _context.resultsCount(), count = _context.resultsCount() }; return(PartialView("_PartialData", pckg)); }
/* Update data model on search term enter */ public IActionResult updateFromSearch(string term) { modelDataResult[] retval; int num = HttpContext.Session.GetInt32("load_no") ?? 1; int loaded = _context.resultsCount(); int count = 0; if (term == null) { retval = _context.allResultsNewSort(HttpContext.Session.GetInt32("load_no") ?? 1); } else { if (HttpContext.Session.GetString("datefilter").Split("-")[0].Equals("on")) { DateTime dateStart = Convert.ToDateTime(HttpContext.Session.GetString("datefilter").Split("-")[1]); DateTime dateEnd = Convert.ToDateTime(HttpContext.Session.GetString("datefilter").Split("-")[2]); retval = _context.getFromSearch(term, num, _context.returnallabsoluteResultsTimeframe(dateStart, dateEnd, num)); count = _context.getFromSearchAll(term, _context.returnallResultsTimeframeAll(dateStart, dateEnd)).Length; } else { retval = _context.getFromSearch(term, num, null).ToList().Take(15 * num).ToArray(); count = _context.getFromSearchAll(term, _context.allResults()).Length; } } modelPackage pckg = new modelPackage() { dataresults = retval, total = count, count = loaded }; if (term == null) { HttpContext.Session.SetString("lastsearch", "none"); } else { HttpContext.Session.SetString("lastsearch", term); } return(PartialView("_PartialData", pckg)); }
/* Generate report */ public IActionResult Report(modelDataResult result) { modelTarget[] targets = _context.returnTargets(result.ID); modelWell[] wells = _context.returnWells(result.ID); List <modelStats> statsList = new List <modelStats>(); string cq = ""; string wellno = ""; foreach (modelTarget target in targets) { modelStats model = new modelStats() { species = target.Name, result = Convert.ToInt32(target.Outcome) }; statsList.Add(model); } int idx = 1; foreach (modelWell well in wells) { cq += (well.Cq + ","); wellno += (idx + ","); idx++; } modelPackage pckg = new modelPackage() { singularResult = _context.returnResultFromID(result.ID), graph = generateGraph(result), cqList = cq, wellnoList = wellno, stats = statsList.ToArray() }; return(View(pckg)); }
/* Admin portal view */ public IActionResult adminPortal() { if (HttpContext.Session.GetString("permissions") == "admin") { modelPackage pckg = new modelPackage() { issys = false }; if (HttpContext.Session.GetString("permlevel") == "sysadmin") { pckg.issys = true; } return(View(pckg)); } else { return(RedirectToAction("Index", "Home")); } }