123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- using System;
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Http;
- using Edge.WebHost.Models.TankMonitor;
- using Edge.WebHost.Models.VeederRoot_ATG_Console_Handler_Models;
- using Edge.Core.IndustryStandardInterface.ATG;
- using Edge.WebHost.Models.SmartFuel;
- namespace Edge.WebHost.Controllers
- {
- public class TankDetailsController : Controller
- {
- CurrentTank currenttank = new CurrentTank();
- public IActionResult Index()
- {
- var smartFuelInfo = new SmartFuelViewInfo();
- smartFuelInfo.queryString = Request.Query["q"].ToString();
- return View("../WebConsole/TankDetails/Index", smartFuelInfo);
- }
- public IActionResult TankOverviewFnav()
- {
- return PartialView("/Views/WebConsole/TankDetails/TankOverviewFnav.cshtml");
- }
- public IActionResult TankDevicesOverview()
- {
- return PartialView("/Views/WebConsole/TankDetails/TankDevicesOverview.cshtml");
- }
- public IActionResult TankDetailFnav()
- {
- return PartialView("/Views/WebConsole/TankDetails/TankDetailFnav.cshtml");
- }
- public IActionResult TankDeviceDetails(int index)
- {
- ViewBag.tankIndex = index;
- return PartialView("/Views/WebConsole/TankDetails/TankDeviceDetails.cshtml");
- }
- public IActionResult AlarmHistoryFnav()
- {
- return PartialView("/Views/WebConsole/TankDetails/AlarmHistoryFnav.cshtml");
- }
- public IActionResult AlarmHistory()
- {
- return PartialView("/Views/WebConsole/TankDetails/AlarmHistory.cshtml");
- }
- public IActionResult FuelInventoryFnav()
- {
- return PartialView("/Views/WebConsole/TankDetails/FuelInventoryFnav.cshtml");
- }
- public IActionResult FuelInventoryList()
- {
- return PartialView("/Views/WebConsole/TankDetails/FuelInventoryList.cshtml");
- }
- public IActionResult ActiveAlarm()
- {
- return View("/Views/WebConsole/TankDetails/ActiveAlarm");
- }
- public IActionResult InStockFuelReport()
- {
- return View("/Views/WebConsole/TankDetails/InStockFuelReport");
- }
- public IActionResult NewInStockFuel()
- {
- return View("/Views/WebConsole/TankDetails/NewInStockFuel");
- }
- public IActionResult NewFuelInventory()
- {
- return View("/Views/WebConsole/TankDetails/NewFuelInventory");
- }
- public IActionResult Test(int index)
- {
- ViewBag.tankIndex = index;
- return View("../WebConsole/TankDetails/Index");
- }
- //public IActionResult TankDeviceDetails()
- ////public IActionResult TankDeviceDetails(string tankID, string fuelID, string fuelKind)
- //{
- // if (currenttank.currentTankID == null)
- // {
- // currenttank.currentTankID = "1";
- // currenttank.currentFuelID = "92";//"#92";
- // currenttank.currentFuelKind = "汽油";//"GasOil";
- // }
- // ViewBag.CurrentTankID = currenttank.currentTankID.ToString();
- // ViewBag.CurrentFuelID = currenttank.currentFuelID.ToString();
- // ViewBag.CurrentFuelKind = currenttank.currentFuelKind.ToString();
- // return View("TankDeviceDetails");
- //}
- private static MockAutoTankGaugeController mockAtgController;
- // GET: /<controller>/
- //public IActionResult Index()
- static TankDetailsController()
- {
- //return "This is my default action...";
- //return View();
- var tank1 = new Tank()
- {
- TankNumber = 1,
- Diameter = 1800,
- Product = new Product()
- {
- ProductCode = "02",
- ProductLabel = "92#"
- },
- Limit = new TankLimit() { },
- Probe = new Probe()
- {
- ProbeLength = 1800,
- State = "",
- }
- };
- var tank2 = new Tank()
- {
- TankNumber = 2,
- Diameter = 1800,
- Product = new Product()
- {
- ProductCode = "05",
- ProductLabel = "95#"
- },
- Limit = new TankLimit()
- {
- },
- Probe = new Probe()
- {
- ProbeLength = 2800,
- State = "",
- }
- };
- var tank3 = new Tank()
- {
- TankNumber = 3,
- Diameter = 1800,
- Product = new Product()
- {
- ProductCode = "08",
- ProductLabel = "98#"
- },
- Limit = new TankLimit()
- {
- },
- Probe = new Probe()
- {
- ProbeLength = 1800,
- State = "",
- }
- };
- var tank4 = new Tank()
- {
- TankNumber = 4,
- Diameter = 1800,
- Product = new Product()
- {
- ProductCode = "09",
- ProductLabel = "0#"
- },
- Limit = new TankLimit()
- {
- },
- Probe = new Probe()
- {
- ProbeLength = 1800,
- State = "",
- }
- };
- var tank5 = new Tank()
- {
- TankNumber = 5,
- Diameter = 1800,
- Product = new Product()
- {
- ProductCode = "11",
- ProductLabel = "-35#"
- },
- Limit = new TankLimit()
- {
- },
- Probe = new Probe()
- {
- ProbeLength = 1800,
- State = "",
- }
- };
- mockAtgController =
- new MockAutoTankGaugeController(
- new List<Tank>()
- {
- tank1,tank2,tank3,tank4,tank5
- }, SystemUnit.Metric);
- }
- //
- // GET: /HelloWorld/Welcome/
- // GET: VeederRoot_ATG_Console_Handler_/Create
- public ActionResult Create()
- {
- return View();
- }
- // GET: VeederRoot_ATG_Console_Handler_/Details/5
- public async Task<ActionResult> Details(int? tankNumber)
- {
- if (tankNumber.HasValue)
- {
- var reading = await mockAtgController.GetTankReadingAsync(tankNumber.Value);
- if (reading == null) return NotFound();
- return Ok(new[]
- {
- new TankReadingDto(){
- tankNumber= tankNumber.Value,
- Height= reading.Height,
- Water= reading.Water,
- Temperature= reading.Temperature,
- Volume= reading.Volume,
- WaterVolume= reading.WaterVolume,
- TimeStamp = DateTime.Now.ToString("HH:mm:ss"),
- }
- });
- }
- else
- {
- List<TankReadingDto> tankReadings = new List<TankReadingDto>();
- foreach (var t in mockAtgController.Tanks)
- {
- var reading = await mockAtgController.GetTankReadingAsync(t.TankNumber);
- if (reading == null) continue;
- var dto = new TankReadingDto()
- {
- tankNumber = t.TankNumber,
- Height = reading.Height,
- Water = reading.Water,
- Temperature = reading.Temperature,
- Volume = reading.Volume,
- WaterVolume = reading.WaterVolume,
- TimeStamp = DateTime.Now.ToString("HH:mm:ss"),
- };
- tankReadings.Add(dto);
- }
- return Ok(tankReadings);
- }
- }
- // POST: VeederRoot_ATG_Console_Handler_/Create
- [HttpPost]
- [ValidateAntiForgeryToken]
- public ActionResult Create(IFormCollection collection)
- {
- try
- {
- // TODO: Add insert logic here
- return RedirectToAction(nameof(Index));
- }
- catch
- {
- return View();
- }
- }
- }
- }
|