123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using Shaker.Model;
- using ShakerService.ViewModel;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net.Http.Headers;
- using System.Text;
- using System.Threading.Tasks;
- namespace ShakerService
- {
- internal class ServiceConfigModel : BaseModel
- {
- public string Name = "振动台";
- public string SN = "SN123456";
- public int Port = 5555;
- public int AnalogCount = 11;
- public int ValveCount = 4;
- public int AccelerationCount = 2;
- public override object Clone()
- {
- return this.CloneBase();
- }
- }
- internal class ServiceConfigViewModel:BaseServiceViewModel<ServiceConfigModel>
- {
- public string Name => Model.Name;
- public string SN => Model.SN;
- public int Port => Model.Port;
- public int AnalogCount => Model.AnalogCount;
- public int ValveCount => Model.ValveCount;
- public int AccelerationCount => Model.AccelerationCount;
- private ServiceConfigViewModel()
- {
- Communication.Instance.DbConnection.CreateTable<ServiceConfigModel>();
- var config = Communication.Instance.DbConnection.Query<ServiceConfigModel>($"select * from {nameof(ServiceConfigModel)}")?.FirstOrDefault() ?? new ServiceConfigModel();
- UpModel(config);
- Communication.Instance.DbConnection.DeleteAll<ServiceConfigModel>();
- Communication.Instance.DbConnection.Insert(config, nameof(ServiceConfigModel));
- }
- static ServiceConfigViewModel()
- {
- }
- public static ServiceConfigViewModel Instance { get; } = new ServiceConfigViewModel();
- }
- }
|