Blame view

WebApp/Apps/monitor/LocationMonitorApp.cs 2.49 KB
霍尔 authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using Infrastructure;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using WebRepository;

namespace WebApp
{
    /// <summary>
	/// 在线用户记录
	/// </summary>

    public partial class LocationMonitorApp
    {
        private IUnitWork _unitWork;

        public LocationMonitorApp(IUnitWork unitWork)
        {
            _unitWork = unitWork;
        }

        public TableData GetRoadWays()
        {
            var result = new TableData();
            try
            {
                var data = _unitWork.Find<Location>(u => u.Code.Contains("-01-01-01")).Select(u => u.Roadway);

                result.data = data;
                result.count = data.Count();
            }
            catch (Exception ex)
            {
                result.msg = ex.Message;
            }

            return result;
        }

        public TableData GetRoadWayConfig(int roadway)
        {
            var result = new TableData();
            try
            {
                var maxRow = _unitWork.Find<Location>(u => u.Roadway == roadway).OrderByDescending(u => u.Row).First().Row;
                var maxLine =_unitWork.Find<Location>(u => u.Roadway == roadway).OrderByDescending(u=>u.Line).First().Line;
                var maxLayer = _unitWork.Find<Location>(u => u.Roadway == roadway).OrderByDescending(u => u.Layer).First().Layer;
                var type = _unitWork.Find<Location>(u => u.Roadway == roadway).OrderBy(u => u.Id).First().Type;

                JObject jObject = new JObject();
                jObject.Add("MaxRow", maxRow);
                jObject.Add("MaxLine", maxLine);
                jObject.Add("MaxLayer", maxLayer);
                jObject.Add("Type", type);

                result.data = jObject;
                result.count = 1;
            }
            catch (Exception ex)
            {
                result.msg = ex.Message;
            }

            return result;
        }

        public TableData GetLocations(int roadway)
        {
            var result = new TableData();
            try
            {
                var data = _unitWork.Find<Location>(u => u.Roadway == roadway).ToList();
                result.data = data;
                result.count = data.Count;
            }
            catch (Exception ex)
            {
                result.msg = ex.Message;
            }

            return result;
        }
    }
}