| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using GSG.NET.ObjectBase;
- using Newtonsoft.Json.Linq;
- using OHV.Common.Model;
- using OHV.Common.Shareds;
- using OHV.SqliteDAL;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace VehicleControlSystem.Managers
- {
- public class RouteManager : SingletonBase<RouteManager>, IDisposable
- {
- SqliteManager sql = null;
- public List<segment> Segments = new List<segment>();
- public List<point> Points = new List<point>();
- public List<equipment> Equipments = new List<equipment>();
- public List<obstacles> Obstacles = new List<obstacles>();
- private RouteManager( )
- {
- }
-
- public void Init( SqliteManager sql )
- {
- this.sql = sql;
- this.LoadJson();
- }
- void LoadJson()
- {
- var path = sql.ConfigDal.GetK( ConstString.RouteFilePath ).Value;
- if ( !System.IO.File.Exists( path ) )
- return;
- using ( StreamReader r = new StreamReader( path ) )
- {
- string json = r.ReadToEnd();
- var o = JObject.Parse( json );
- this.Points = o["points"].ToObject<List<point>>();
- this.Segments = o["segments"].ToObject<List<segment>>();
- this.Obstacles = o["obstacles"].ToObject<List<obstacles>>();
- this.Equipments = o["equipments"].ToObject<List<equipment>>();
- }
- this.WriteToDB();
- }
- /// <summary>
- /// File 에서 읽어 와서 DB로 넣엇 사용하자 View 에서 같이 사용하기 위해
- /// </summary>
- void WriteToDB()
- {
- this.sql.RouteDal.Clean();
- this.Points.ForEach( p =>
- {
- Route route = new Route()
- {
- ScaleValue = p.barcode,
- Name = p.ID.ToString(),
- };
- sql.RouteDal.Add( route );
- } );
- }
- public void Dispose()
- {
- }
- }
- }
|