123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Threading.Tasks;
- using DllEapEntity;
- using Microsoft.AspNetCore.Mvc;
- using WebMainHsms.Models;
- using Cksoft.Unity;
- using DllEapDal;
- using DllLotServer;
- namespace WebMainHsms.Controllers
- {
- public class HomeController : Controller
- {
- public ILotServer CurrSec { get; set; }
- //自动注入服务
- public HomeController(ILotServer psecs)
- {
- CurrSec = psecs;
- }
- public IActionResult Index()
- {
- //CurrSec.StartAll();
- //List<MacOrder> lists = CurrSec.GetMacOrder();
- return View();
- }
- public IActionResult About()
- {
- ViewData["Message"] = "Your application description page.";
- return View();
- }
- public IActionResult Contact()
- {
- ViewData["Message"] = "Your contact page.";
- return View();
- }
- public IActionResult Privacy()
- {
- return View();
- }
- [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
- public IActionResult Error()
- {
- return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
- }
- public ActionResult GetStatus()
- {
- try
- {
- string temperrorinfo = "";
- int result = CurrSec.GetStatus(ref temperrorinfo);
- return Content(new { resultcode = result, errorinfo = temperrorinfo }.ToJson());
- }
- catch (Exception ex)
- {
- return Content(new { resultcode = -1, errorinfo = ex.Message.ToString() }.ToJson());
- }
- }
- public ActionResult Start()
- {
- try
- {
- string temperrorinfo = "";
- int result = CurrSec.Start(ref temperrorinfo);
- return Content(new { resultcode = result, errorinfo = temperrorinfo }.ToJson());
- }
- catch (Exception ex)
- {
- return Content(new { resultcode = -1, errorinfo = ex.Message.ToString() }.ToJson());
- }
- }
- public ActionResult GetInfo()
- {
- try
- {
- List<ServerInfo> info = CurrSec.GetInfo();
- return Content(info.ToJson());
- //Newtonsoft.Json.JsonSerializerSettings jsonformat = new Newtonsoft.Json.JsonSerializerSettings();
- //jsonformat.DateFormatString = "yyyy-MM-dd hh:mm:ss";
- //return Json(info, jsonformat);
- //return Json(info);
- }
- catch (Exception ex)
- {
- return Content(new { resultcode = -1, errorinfo = ex.Message.ToString() }.ToJson());
- }
- }
- [HttpPost]
- public ActionResult GetCount()
- {
- try
- {
- long result = CurrSec.GetAccount();
- return Content(new { resultcode = 1, errorinfo = result }.ToJson());
- }
- catch (Exception ex)
- {
- return Content(new { resultcode = -1, errorinfo = ex.Message.ToString() }.ToJson());
- }
- }
- public ActionResult Stop()
- {
- try
- {
- string temperrorinfo = "";
- int result = CurrSec.Stop(ref temperrorinfo);
- return Content(new { resultcode = result, errorinfo = temperrorinfo }.ToJson());
- }
- catch (Exception ex)
- {
- return Content(new { resultcode = -1, errorinfo = ex.Message.ToString() }.ToJson());
- }
- }
- public ActionResult ClearInfo()
- {
- try
- {
- string temperrorinfo = "";
- int result = CurrSec.ClearInfo(ref temperrorinfo);
- return Content(new { resultcode = result, errorinfo = temperrorinfo }.ToJson());
- }
- catch (Exception ex)
- {
- return Content(new { resultcode = -1, errorinfo = ex.Message.ToString() }.ToJson());
- }
- }
- }
- }
|