修改测试

master
mzhifa 5 months ago
parent 397447f996
commit ea5b04f32f

@ -1,6 +1,8 @@
using System;
using SqlSugar;
using System;
using System.Linq;
using System.Text;
using Txgy.RBS.DbModel.Models;
namespace Txgy.RBS.DTO
{
@ -19,6 +21,9 @@ namespace Txgy.RBS.DTO
/// </summary>
public int id { get; set; }
public int project_id { get; set; }
/// <summary>
/// Desc:
/// Default:
@ -180,5 +185,8 @@ namespace Txgy.RBS.DTO
/// </summary>
public int push_wx_company_id { get; set; }
public StationFileDTO stationFile { get; set; }
public TimeTabDTO timeTab { get; set; }
}
}

@ -40,14 +40,8 @@ namespace Txgy.RBS.DTO
/// Default:
/// Nullable:True
/// </summary>
public double? e { get; set; }
public double? ylat { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:True
/// </summary>
public double? n { get; set; }
/// <summary>
/// Desc:

@ -1,17 +0,0 @@
using SqlSugar;
namespace Txgy.RBS.DTO
{
///<summary>
///
///</summary>
public partial class ResultJsonDTO
{
public int Id { get; set; }
public int ResultId { get; set; }
public string Json { get; set; }
}
}

@ -7,9 +7,9 @@ namespace Txgy.RBS.DTO
///<summary>
///
///</summary>
public partial class StationsDTO
public class StationDTO
{
public StationsDTO()
public StationDTO()
{
@ -68,7 +68,7 @@ namespace Txgy.RBS.DTO
/// Default:3200000000
/// Nullable:False
/// </summary>
public int sens { get; set; }
public double sens { get; set; }
/// <summary>
/// Desc:

@ -1,19 +1,15 @@
using System;
using System.Linq;
using System.Text;
using Txgy.RBS.DbModel.Models;
namespace Txgy.RBS.DTO
{
///<summary>
///
///</summary>
public partial class StationFileDTO
public class StationFileDTO
{
public StationFileDTO()
{
}
/// <summary>
/// Desc:
/// Default:
@ -35,5 +31,6 @@ namespace Txgy.RBS.DTO
/// </summary>
public string file_name { get; set; }
public List<StationDTO> stations { get; set; }
}
}

@ -7,7 +7,7 @@ namespace Txgy.RBS.DTO
///<summary>
///
///</summary>
public partial class StationNumVpnDTO
public class StationNumVpnDTO
{
public StationNumVpnDTO()
{

@ -8,13 +8,8 @@ namespace Txgy.RBS.DbModel.Models
///<summary>
///
///</summary>
public partial class project_info
public class project_info
{
public project_info()
{
}
/// <summary>
/// Desc:
/// Default:
@ -23,6 +18,8 @@ namespace Txgy.RBS.DbModel.Models
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int id { get; set; }
public int project_id { get; set; }
/// <summary>
/// Desc:
/// Default:
@ -184,5 +181,11 @@ namespace Txgy.RBS.DbModel.Models
/// </summary>
public int push_wx_company_id { get; set; }
[Navigate(NavigateType.OneToOne, nameof(project_id))]
public station_file stationFile { get; set; }
[Navigate(NavigateType.OneToOne, nameof(project_id))]
public time_tab time_tab { get; set; }
}
}

@ -1,4 +1,5 @@
using System;
using SqlSugar;
using System;
using System.Linq;
using System.Text;
@ -19,6 +20,7 @@ namespace Txgy.RBS.DbModel.Models
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int current_project_id { get; set; }

@ -8,7 +8,7 @@ namespace Txgy.RBS.DbModel.Models
///<summary>
///
///</summary>
public partial class result
public class result
{
public result()
{
@ -42,14 +42,14 @@ namespace Txgy.RBS.DbModel.Models
/// Default:
/// Nullable:True
/// </summary>
public double? e { get; set; }
public double? xlon { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:True
/// </summary>
public double? n { get; set; }
public double? ylat { get; set; }
/// <summary>
/// Desc:
@ -107,5 +107,8 @@ namespace Txgy.RBS.DbModel.Models
/// </summary>
public double? seismic_direction { get; set; }
public string json_str { set; get; }
}
}

@ -1,41 +0,0 @@
using SqlSugar;
using System;
using System.Linq;
using System.Text;
namespace Txgy.RBS.DbModel.Models
{
///<summary>
///
///</summary>
public partial class result_json
{
public result_json()
{
}
/// <summary>
/// Desc:
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int id { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:True
/// </summary>
public int? result_id { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:True
/// </summary>
public string json { get; set; }
}
}

@ -8,9 +8,9 @@ namespace Txgy.RBS.DbModel.Models
///<summary>
///
///</summary>
public partial class stations
public partial class station
{
public stations()
public station()
{
@ -70,7 +70,7 @@ namespace Txgy.RBS.DbModel.Models
/// Default:3200000000
/// Nullable:False
/// </summary>
public int sens { get; set; }
public double sens { get; set; }
/// <summary>
/// Desc:

@ -8,19 +8,14 @@ namespace Txgy.RBS.DbModel.Models
///<summary>
///
///</summary>
public partial class station_file
public class station_file
{
public station_file()
{
}
/// <summary>
/// Desc:
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
[SugarColumn(IsPrimaryKey = true,IsIdentity =true)]
public int id { get; set; }
/// <summary>
@ -37,5 +32,9 @@ namespace Txgy.RBS.DbModel.Models
/// </summary>
public string file_name { get; set; }
[Navigate(NavigateType.OneToMany, nameof(station.project_id))]
public List<station> stations { get; set; }
}
}

@ -1,6 +1,8 @@
using System;
using ServiceStack.Text;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
@ -19,7 +21,7 @@ namespace Txgy.RBS.Framework.Api
}
}
public ReponseCodeEnum Code { get; set; }
public HttpStatusCode Code { get; set; }
/// <summary>
/// 特指错误消息

@ -0,0 +1,50 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
namespace Txgy.RBS.Framework
{
public class CommonData
{
public static string BaseProjectPath { get; set; } = "d:\\Project";
public static string ApmsDefaultPath { get; set; } = "program\\apms\\gw.apms.json";
public static string RecvDefaultPath { get; set; } = "program\\recvmqtt\\gw.recvmqtt.json";
/// <summary>//From:www.13le.com
/// 复制文件夹下所有文件
/// </summary>
/// <param name="sourceFolder">原文件路径</param>
/// <param name="destFolder">目标文件路径</param>
public static void CopyFolder(string sourceFolder, string destFolder)
{
//如果目标路径不存在,则创建目标路径
if (!System.IO.Directory.Exists(destFolder))
{
System.IO.Directory.CreateDirectory(destFolder);
}
//得到原文件根目录下的所有文件
string[] files = System.IO.Directory.GetFiles(sourceFolder);
foreach (string file in files)
{
string name = System.IO.Path.GetFileName(file);
string dest = System.IO.Path.Combine(destFolder, name);
System.IO.File.Copy(file, dest);//复制文件
}
//得到原文件根目录下的所有文件夹
string[] folders = System.IO.Directory.GetDirectories(sourceFolder);
foreach (string folder in folders)
{
string name = System.IO.Path.GetFileName(folder);
string dest = System.IO.Path.Combine(destFolder, name);
CopyFolder(folder, dest);//构建目标路径,递归复制文件
}
}
}
}

@ -0,0 +1,124 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Txgy.RBS.Framework.Models
{
public class ApmsModel
{
private string station1;
private List<TTime> ttime1;
private string push2wx1;
private string savepath1;
private float xmin1;
private float xmax1;
private float ymin1;
private float ymax1;
private float zref1;
private float zmin1;
private float zmax1;
private float minstep1;
private List<StationChannelsModel> channels1;
[JsonProperty("station")]
public string station { get => station1; set => station1 = value; }//根据station表生成
[JsonProperty("ttime")]
public List<TTime> ttime { get => ttime1; set => ttime1 = value; }//客户端上传
[JsonProperty("Main.log_level")]
public string log_level { get; set; }
[JsonProperty("Main.slice_seconds")]
public int slice_seconds { get; set; }
[JsonProperty("Main.overlap_seconds")]
public int overlap_seconds { get; set; }
[JsonProperty("Main.is_mag")]
public string is_mag { get; set; }
[JsonProperty("Main.is_write_slice")] //Apms配置存储结果
public string is_write_slice { get; set; }
[JsonProperty("Main.lon")]
public double lon { get; set; }
[JsonProperty("Main.lat")]
public double lat { get; set; }
[JsonProperty("Main.height")]
public double height { get; set; }
[JsonProperty("Main.savepath")] //Apms配置处理结果存储目录由基础路径+工程名称+"result"拼接
public string savepath { get => savepath1; set => savepath1 = value; }
[JsonProperty("Main.push2wx")] //Apms配置微信推送暂时不开放
public string push2wx { get => push2wx1; set => push2wx1 = value; }
[JsonProperty("Main.push_url")]
public string push_url { get; set; }
[JsonProperty("Main.push_mag")] //Apms配置推送阈值
public double push_mag { get; set; }
[JsonProperty("Main.message_id")]
public int message_id { get; set; }
[JsonProperty("Main.company_id")]
public int company_id { get; set; }
[JsonProperty("Main.area_id")]
public int area_id { get; set; }
[JsonProperty("Main.content")]
public string content { get; set; }
[JsonProperty("Main.push_key")]
public string push_key { get; set; }
[JsonProperty("RServer.host")]
public string host { get; set; }
public List<StationChannelsModel> channels { get => channels1; set => channels1 = value; }
[JsonProperty("Locate.log_level")]
public string llog_level { get; set; }
[JsonProperty("Locate.work_path")]
public string work_path { get; set; }
[JsonProperty("Locate.xmin")]
public float xmin { get => xmin1; set => xmin1 = value; }
[JsonProperty("Locate.xmax")]
public float xmax { get => xmax1; set => xmax1 = value; }
[JsonProperty("Locate.ymin")]
public float ymin { get => ymin1; set => ymin1 = value; }
[JsonProperty("Locate.ymax")]
public float ymax { get => ymax1; set => ymax1 = value; }
[JsonProperty("Locate.zref")]
public float zref { get => zref1; set => zref1 = value; }
[JsonProperty("Locate.zmin")]
public float zmin { get => zmin1; set => zmin1 = value; }
[JsonProperty("Locate.zmax")]
public float zmax { get => zmax1; set => zmax1 = value; }
[JsonProperty("Locate.minstep")]
public float minstep { get => minstep1; set => minstep1 = value; }
[JsonProperty("Locate.method")]
public string method { get; set; }
[JsonProperty("Locate.clusted_otime")]
public double clusted_otime { get; set; }
}
public class TTime
{
private string ttime2d1;
[JsonProperty("station")]
public string station { get; set; }
// [JsonProperty("ttime")]
// public string ttime { get; set; }
[JsonProperty("ttime2d")]
public string ttime2d
{
get => ttime2d1;
set => ttime2d1 = value;
}
}
public class StationChannelsModel
{
public string network { get; set; }
public string location { get; set; }
public string channels { get; set; }
public string station { get; set; }
}
}

@ -0,0 +1,40 @@
using System;
using System.Reflection;
namespace Txgy.RBS.Framework.Models
{
public class MsEventModel
{
public int ID { get; set; }
public DateTime CurrentTime { get; set; }
public DateTime OriginTime { get; set; }
public double EastCoordinate { get; set; }
public double NorthCoordinate { get; set; }
public double Depth { get; set; }
public double ML { get; set; }
public double Energy { get; set; }
public int EarthquakeSource { get; set; }
public bool IsSend { get => isSend; set => isSend = value; }
public MsEventModel(string message)
{
eventMessage = message;
string[] evtS = message.Trim(' ').Split(new char[] { ' ' });
CurrentTime = DateTime.Now;
OriginTime = DateTime.Parse(evtS[0]);
EastCoordinate = double.Parse(evtS[2]);
NorthCoordinate = double.Parse(evtS[1]);
Depth = double.Parse(evtS[3]);
ML = evtS.Length == 7 ? -10 : double.Parse(evtS[5]);
}
private string eventMessage;
private bool isSend = false;
public override string ToString()
{
return eventMessage;
}
}
}

@ -0,0 +1,29 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Txgy.RBS.Framework.Models
{
//recv配置波形数据存储目录,由基础路径+工程名称+"wavesdata"拼接
public class RecvMqttModel
{
public string savepath { get; set; }
[JsonProperty("log_level")]
public string log_level { get; set; }
[JsonProperty("send2server")] //recv配置Send2Redis
public string send2server { get; set; }
[JsonProperty("MQTT.Server")] //recv配置MqttServer
public string Server { get; set; }
[JsonProperty("MQTT.Stations")]
public string Stations { get; set; }
[JsonProperty("MQTT.Send81")]
public string Send81 { get; set; }
[JsonProperty("dirstruct")]
public string dirstruct { get; set; }
[JsonProperty("Help")]
public string Help { get; set; }
}
}

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Txgy.RBS.Framework
{
public class ProcessConfig
{
/// <summary>
/// server程序
/// </summary>
public ProcessInfo Server { get; set; }
/// <summary>
/// Recv程序
/// </summary>
public ProcessInfo RecvMqtt { get; set; }
/// <summary>
/// Apms(定位程序)程序
/// </summary>
public ProcessInfo Apms { get; set; }
}
}

@ -1,4 +1,6 @@
using Newtonsoft.Json;

using System.Text.Json.Serialization;
namespace Txgy.RBS.Framework
{
@ -8,7 +10,6 @@ namespace Txgy.RBS.Framework
/// <summary>
/// 程序路径
/// </summary>
[JsonProperty]
public string ProName
{
get { return proName; }
@ -18,7 +19,6 @@ namespace Txgy.RBS.Framework
/// <summary>
/// 程序路径
/// </summary>
[JsonProperty]
public string ProTitle
{
get { return proTitle; }
@ -35,7 +35,6 @@ namespace Txgy.RBS.Framework
/// <summary>
/// 程序路径
/// </summary>
[JsonProperty]
public string ProPath
{
get { return proPath; }
@ -46,7 +45,6 @@ namespace Txgy.RBS.Framework
/// <summary>
/// 启动参数
/// </summary>
[JsonProperty]
public string ProParams
{
get { return proParams; }
@ -56,7 +54,6 @@ namespace Txgy.RBS.Framework
/// <summary>
/// 配置文件路径
/// </summary>
[JsonProperty]
public string JsonPath { get; set; }
private int pid;
@ -74,5 +71,12 @@ namespace Txgy.RBS.Framework
get { return operationStr; }
set { operationStr = value; }
}
[JsonIgnore]
public DateTime StartTime { set; get; }
[JsonIgnore]
public bool State { set; get; }
}
}

@ -7,7 +7,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="ServiceStack.Interfaces" Version="6.10.0" />
<PackageReference Include="ServiceStack.Redis" Version="6.10.0" />
</ItemGroup>

@ -11,10 +11,14 @@ namespace Txgy.RBS.IServices
{
public AutoMapObject()
{
CreateMap<result_json, ResultJsonDTO>().ReverseMap();
CreateMap<project_info, ProjectInfoDTO>().ReverseMap();
CreateMap<result, ResultDTO>().ReverseMap();
CreateMap<project_info, ProjectInfoDTO>()
.ForMember(p => p.timeTab, pd => pd.MapFrom(s => s.time_tab))
.ForMember(p => p.stationFile, pd => pd.MapFrom(s => s.stationFile)).ReverseMap();
CreateMap<project_used,ProjectUsedDTO>().ReverseMap();
CreateMap<stations, StationsDTO>().ReverseMap();
CreateMap<station, StationDTO>().ReverseMap();
CreateMap<station_file, StationFileDTO>().ReverseMap();
CreateMap<station_num_vpn,StationNumVpnDTO>().ReverseMap();
CreateMap<time_tab, TimeTabDTO>().ReverseMap();
CreateMap<global_config,GlobalConfigDTO>().ReverseMap();
}

@ -19,8 +19,5 @@ namespace Txgy.RBS.IServices
GlobalConfigDTO GetGlobalConfig(int id);
List<GlobalConfigDTO> GetAllGlobalConfig();
int StartProcess(ProcessInfo proInfo);
}
}

@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Txgy.RBS.DTO;
using Txgy.RBS.Framework;
using Txgy.RBS.Framework.Api;
using Txgy.RBS.IServices;
@ -23,6 +24,14 @@ namespace Txgy.RBS.IServices
ProjectUsedDTO GetCurrentProjectUsed();
ApiResult StartProject(bool isStart);
ApiResult UpdateCurrentProjectUsed(ProjectUsedDTO projectUsed);
ApiResult StartProject(string projectName, ProcessConfig processConfig);
ApiResult StopProject(string ProjectName);
ApiResult GetState(string projectName,int id);
ApiResult ExportCSV(string fileName, List<StationDTO> stations);
}
}

@ -12,15 +12,15 @@ namespace Txgy.RBS.IServices
{
public interface IResultInfoService : IBaseService
{
ApiResult AddResultInfo(ResultJsonDTO resultJsonDTO);
ApiResult AddResultInfo(ResultDTO resultJsonDTO);
ApiResult DeleteResultInfo(int id);
ApiResult UpdateResultInfo(ResultJsonDTO resultJsonDTO);
ApiResult UpdateResultInfo(ResultDTO resultJsonDTO);
ResultJsonDTO GetResultInfo(int id);
ResultDTO GetResultInfo(int id);
List<ResultJsonDTO> GetAllResultInfo();
List<ResultDTO> GetAllResultInfo();
}
}

@ -11,15 +11,17 @@ namespace Txgy.RBS.IServices
{
public interface IStationsService : IBaseService
{
ApiResult AddStations(StationsDTO stationsDTO);
ApiResult AddStations(StationDTO stationsDTO);
ApiResult DeleteStations(int id);
ApiResult UpdateStations(StationsDTO stationsDTO);
ApiResult UpdateStations(StationDTO stationsDTO);
StationsDTO GetStations(int id);
StationDTO GetStations(int id);
List<StationsDTO> GetAllStations();
List<StationDTO> GetAllStations();
List<StationNumVpnDTO> GetStationNumVpn();
}
}

@ -8,6 +8,8 @@
<ItemGroup>
<PackageReference Include="AutoMapper" Version="13.0.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.0" />
</ItemGroup>
<ItemGroup>

@ -1,6 +1,12 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
using Newtonsoft.Json;
using System.IO;
using System.Security.Policy;
using Txgy.RBS.DTO;
using Txgy.RBS.Framework;
using Txgy.RBS.Framework.Api;
using Txgy.RBS.Framework.Models;
using Txgy.RBS.IServices;
using Txgy.RBS.Services;
@ -13,10 +19,14 @@ namespace Txgy.RBS.Server.WebApi.Controllers
public class ProjectInfoController : ControllerBase
{
private readonly IProjectInfoService _projectInfoService;
private readonly IStationsService _stationsService;
private readonly ProcessConfig _processConfig;
public ProjectInfoController(ILogger<ProjectInfoController> logger, IProjectInfoService projectInfoService)
public ProjectInfoController(ILogger<ProjectInfoController> logger, IProjectInfoService projectInfoService,IStationsService stationsService, IConfiguration configuration)
{
this._projectInfoService = projectInfoService;
this._stationsService = stationsService;
this._processConfig = configuration.GetSection("process").Get<ProcessConfig>();
}
[HttpPost]
@ -55,11 +65,114 @@ namespace Txgy.RBS.Server.WebApi.Controllers
return _projectInfoService.GetCurrentProjectUsed();
}
//[HttpPost]
//public void Post([FromBody] string value)
//{
[HttpPost]
public ApiResult StartProject(ProjectUsedDTO usedDTO)
{
// 更新当前项目配置
var res = _projectInfoService.UpdateCurrentProjectUsed(usedDTO);
var curProject = this.GetProjectInfo(usedDTO.current_project_id);
var staVpn = _stationsService.GetStationNumVpn();
if (res.Success && curProject != null)
{
//}
string path = Path.Combine(CommonData.BaseProjectPath, curProject.project_name);
if (!Directory.Exists(path))
{
var direc = Directory.CreateDirectory(path);
}
string apmApp = Path.Combine(path, _processConfig.Apms.ProPath, _processConfig.Apms.ProName + ".exe");
if (!System.IO.File.Exists(apmApp))
{
string sourceFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "program");
CommonData.CopyFolder(sourceFile, Path.Combine(path, "program"));
}
// 修改配置文件
string str = System.IO.File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + CommonData.ApmsDefaultPath);
ApmsModel apm = JsonConvert.DeserializeObject<ApmsModel>(str);
//station.csv
apm.station = curProject.stationFile.file_name;
_projectInfoService.ExportCSV(Path.Combine(path, "program\\apms", apm.station), curProject.stationFile.stations);
//time_tab
apm.ttime[0].ttime2d = curProject.timeTab.filename;
System.IO.File.WriteAllText(Path.Combine(path, "program\\apms", curProject.timeTab.filename), curProject.timeTab.file_content);
apm.is_write_slice = (curProject.local_save_result == 1) ? "YES" : "NO";
apm.savepath = Path.Combine(CommonData.BaseProjectPath, curProject.project_name, curProject.save_result_path) ;
apm.push_mag = curProject.push_wx_value;
apm.channels = new List<StationChannelsModel>
{
new StationChannelsModel
{
channels = curProject.channels,
location = curProject.location,
network = curProject.network,
station=string.Join(",", curProject.stationFile.stations.Select(p=>p.num)),
}
};
apm.xmin = (float)curProject.xmin;
apm.xmax = (float)curProject.xmax;
apm.ymin = (float)curProject.ymin;
apm.ymax = (float)curProject.ymax;
apm.zmin = (float)curProject.zmin;
apm.zmax = (float)curProject.zmax;
string apmJson = JsonConvert.SerializeObject(apm, Formatting.Indented);
System.IO.File.WriteAllText(Path.Combine(path, CommonData.ApmsDefaultPath), apmJson);
_processConfig.Apms.ProPath = Path.Combine(path, _processConfig.Apms.ProPath);
//修改recvMqtt配置
str = System.IO.File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + CommonData.RecvDefaultPath);
var rec = JsonConvert.DeserializeObject<RecvMqttModel>(str);
if (rec != null)
{
rec.savepath = Path.Combine(CommonData.BaseProjectPath, curProject.project_name, curProject.save_waves_path);
rec.send2server = (curProject.send_redis == 1) ? "YES" : "NO";
rec.Server = curProject.mqtt_server;
List< StationNumVpnDTO> vpnList=new List< StationNumVpnDTO>();
foreach (var item in curProject.stationFile.stations)
{
var v= staVpn.Where(p => p.num == item.num).FirstOrDefault();
if (v != null)
{
vpnList.Add(v);
}
}
rec.Stations = string.Join(",", vpnList.Select(p => p.vpn_name));
rec.dirstruct = curProject.local_save_waves == 1 ? "NMDHM" : "NMDHM0";
string recvJson = JsonConvert.SerializeObject(rec, Formatting.Indented);
System.IO.File.WriteAllText(Path.Combine(path, CommonData.RecvDefaultPath), recvJson);
_processConfig.RecvMqtt.ProPath = Path.Combine(path, _processConfig.RecvMqtt.ProPath);
}
_processConfig.Server.ProPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _processConfig.Server.ProPath);
res= _projectInfoService.StartProject(curProject.project_name, _processConfig);
res.Data = curProject;
}
return res;
}
[HttpPost]
public ApiResult StopProject(ProjectUsedDTO usedDTO)
{
// 更新当前项目配置
var res = _projectInfoService.UpdateCurrentProjectUsed(usedDTO);
var curProject = this.GetProjectInfo(usedDTO.current_project_id);
if (res.Success && curProject != null)
{
res= _projectInfoService.StopProject(curProject.project_name);
res.Data = curProject;
}
return res;
}
[HttpGet]
public ApiResult GetProjectProcessState(string projectName, int id)
{
ApiResult result = new ApiResult();
result = _projectInfoService.GetState(projectName, id);
return result;
}
}
}

@ -19,9 +19,9 @@ namespace Txgy.RBS.Server.WebApi.Controllers
this._resultInfoService = resultInfoService;
}
[HttpPost]
public ApiResult AddProjectInfo(ResultJsonDTO resultJsonDTO)
public ApiResult AddProjectInfo(ResultDTO resultDTO)
{
return _resultInfoService.AddResultInfo(resultJsonDTO);
return _resultInfoService.AddResultInfo(resultDTO);
}
[HttpDelete("{id}")]
@ -31,19 +31,19 @@ namespace Txgy.RBS.Server.WebApi.Controllers
}
[HttpPost]
public ApiResult UpdateResultInfo(ResultJsonDTO resultJsonDTO)
public ApiResult UpdateResultInfo(ResultDTO resultDTO)
{
return _resultInfoService.UpdateResultInfo(resultJsonDTO);
return _resultInfoService.UpdateResultInfo(resultDTO);
}
[HttpGet("{id}")]
public ResultJsonDTO GetProjectInfo(int id)
public ResultDTO GetResultInfo(int id)
{
return _resultInfoService.GetResultInfo(id);
}
[HttpGet]
public List<ResultJsonDTO> GetAllResultInfo()
public List<ResultDTO> GetAllResultInfo()
{
return _resultInfoService.GetAllResultInfo();
}

@ -19,7 +19,7 @@ namespace Txgy.RBS.Server.WebApi.Controllers
}
[HttpPost]
public ApiResult AddStations(StationsDTO stationsDTO)
public ApiResult AddStations(StationDTO stationsDTO)
{
return _stationsService.AddStations(stationsDTO);
}
@ -31,21 +31,27 @@ namespace Txgy.RBS.Server.WebApi.Controllers
}
[HttpPost]
public ApiResult UpdateStations(StationsDTO stationsDTO)
public ApiResult UpdateStations(StationDTO stationsDTO)
{
return _stationsService.UpdateStations(stationsDTO);
}
[HttpGet("{id}")]
public StationsDTO GetStations(int id)
public StationDTO GetStations(int id)
{
return _stationsService.GetStations(id);
}
[HttpGet]
public List<StationsDTO> GetAllStationss()
public List<StationDTO> GetAllStationss()
{
return _stationsService.GetAllStations();
}
[HttpGet]
public List<StationNumVpnDTO> GetStationNumVpn()
{
return _stationsService.GetStationNumVpn();
}
}
}

@ -17,7 +17,8 @@ builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
// 启用本地缓存
builder.Services.AddMemoryCache();
var app = builder.Build();
// Configure the HTTP request pipeline.

@ -1,9 +1,12 @@
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using SqlSugar;
using System.Reflection;
using Txgy.RBS.Framework;
using Txgy.RBS.Framework.RedisHelper.Service;
using Txgy.RBS.Services;
namespace Txgy.RBS.Server.WebApi.Register
{
@ -23,7 +26,8 @@ namespace Txgy.RBS.Server.WebApi.Register
Assembly serviceAssembly = Assembly.Load("Txgy.RBS.IServices");
ConfigurationBinder.RegisterAssemblyTypes(interfaceAssembly, serviceAssembly).AsImplementedInterfaces();
#endregion
var pro= applicationBuilder.Configuration.GetSection("process").Get<ProcessConfig>();
ConfigurationBinder.RegisterType<ProcessManagerService>().SingleInstance();
#region 注册每个控制器和抽象之间的关系
var controllerBaseType = typeof(ControllerBase);
ConfigurationBinder.RegisterAssemblyTypes(typeof(Program).Assembly)

@ -9,6 +9,8 @@
<ItemGroup>
<PackageReference Include="Autofac" Version="7.0.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.0" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.148" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

@ -10,6 +10,8 @@
"ConnectionSqlite": "Data Source=rbs_server_db.db",
"ConnectionType": "0"
},
"process": {
"Server": {
"ProName": "server",
"ProTitle": "服务",
@ -26,7 +28,7 @@
"ProTitle": "数据接收",
"IsEnable": true,
"ProPath": "program\\recvmqtt\\",
"ProParams": "-cfg gw.recvmqtt.all.json >outRecv.txt",
"ProParams": "-cfg gw.recvmqtt.json >outRecv.txt",
"JsonPath": "gw.recvmqtt.json",
"Pid": 0,
"OperationStr": "open",
@ -37,11 +39,12 @@
"ProTitle": "实时处理",
"IsEnable": true,
"ProPath": "program\\apms\\",
"ProParams": "-cfg apms.json >outApms.txt",
"JsonPath": "apms.json",
"ProParams": "-cfg gw.apms.json >outApms.txt",
"JsonPath": "gw.apms.json",
"Pid": 0,
"OperationStr": "open",
"ShowState": 0
}
},
"AllowedHosts": "*"
}

@ -66,162 +66,5 @@ namespace Txgy.RBS.Services
}
return new ApiResult() { Message = "更新失败" };
}
#region 方法
private bool CMDStartProcess(ProcessInfo proInfo)
{
//* Create your Process
Process process = new Process();
process.Exited += Process_Exited;
process.EnableRaisingEvents = true;
process.StartInfo.FileName = Path.GetFullPath(proInfo.ProPath + proInfo.ProName + ".exe");
process.StartInfo.WorkingDirectory = Path.GetFullPath(proInfo.ProPath);
process.StartInfo.Arguments = proInfo.ProParams;
Debug.WriteLine($"*******name:{process.StartInfo.FileName}, arguments:{process.StartInfo.Arguments}*********");
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
//* Set your output and error (asynchronous) handlers
{
process.OutputDataReceived += new DataReceivedEventHandler(OutputHandler);
process.ErrorDataReceived += new DataReceivedEventHandler(OutputHandler);
}
//* Start process and handlers
bool res = process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
// process.WaitForExit();
return res;
}
private void Process_Exited(object? sender, EventArgs e)
{
}
void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
{
Debug.WriteLine("output*************:{0},{1}", sendingProcess.ToString(), outLine.Data);
if (string.IsNullOrEmpty(outLine.Data)) return;
if (outLine.Data.Contains("ProcessSlice:"))
{
var pro = sendingProcess as Process;
if (pro != null)
{
}
}
else if (outLine.Data.Contains("ML "))
{
var pro = sendingProcess as Process;
if (pro != null)
{
}
}
}
public int StartProcess(ProcessInfo proInfo)
{
bool res = CMDStartProcess(proInfo);
int seInd = res ? 0 : 37;
return seInd;
}
/// <summary>
/// 结束进程
/// </summary>
/// <param name="processInfo"></param>
/// <returns>0=成功;1=未找到进程;-1=失败</returns>
private int KillProcess(ProcessInfo processInfo)
{
int ri = 0;
if (processInfo != null)
{
if (processInfo.ProName != null)
{
try
{
Process[] localByName = Process.GetProcessesByName(processInfo.ProName);
if (localByName.Length == 0)
{
ri = 1;
return ri;
}
foreach (var item in localByName)
{
Console.WriteLine(item.Id);
item.Kill();
}
return ri;
}
catch (Exception)
{
return -1;
}
}
else
{
return 0;
}
}
else
{
return 0;
}
}
/// <summary>
/// 查找进程
/// </summary>
/// <param name="processInfo"></param>
/// <returns>0=正在运行;1=未运行;-1=系统错误</returns>
private int FindProcess(ProcessInfo processInfo)
{
int ri = 0;
try
{
Process[] localByName = Process.GetProcessesByName(processInfo.ProName);
if (localByName.Length == 0)
{
ri = 1;
return ri;
}
return ri;
}
catch (Exception)
{
return -1;
}
}
public string ProcessStatus { get; set; }
public void GetState(List< ProcessInfo> processes)
{
foreach (var item in processes)
{
var pro = item;
if (pro != null )
{
int sfp = FindProcess(pro);
if (sfp == 0)
{
ProcessStatus = "正常运行";
}
else
{
ProcessStatus = "重启中";
StartProcess(pro);
Thread.Sleep(20);
}
}
}
}
#endregion
}
}

@ -0,0 +1,396 @@
using System.Diagnostics;
using Txgy.RBS.Framework.Api;
using Txgy.RBS.Framework;
using Microsoft.Extensions.Caching.Memory;
using System.Collections.Concurrent;
using ServiceStack;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Linq;
using System.Data;
using Txgy.RBS.DTO;
using Aspose.Cells;
using Txgy.RBS.Framework.Models;
namespace Txgy.RBS.Services
{
public class ProcessManagerService
{
private readonly IMemoryCache _cache;
public ProcessManagerService( IMemoryCache cache)
{
_cache = cache;
MoniTimer.Interval = 10000;
MoniTimer.Elapsed += MoniTimer_Elapsed;
MoniTimer.Start();
}
private void MoniTimer_Elapsed(object? sender, System.Timers.ElapsedEventArgs e)
{
foreach (var item in ProjectMonitor)
{
foreach (var proValue in item.Value.GetType().GetProperties())
{
var pro = proValue.GetValue(item.Value) as ProcessInfo;
if (pro != null)
{
int sfp = FindProcess(pro);
if (sfp != 0)
{
Console.WriteLine($"{pro.ProName}程序重启中,path:{pro.ProPath}");
StartProcess(pro);
Thread.Sleep(20);
}
}
}
}
}
public ConcurrentDictionary<string, ProcessConfig> ProjectMonitor = new ConcurrentDictionary<string, ProcessConfig>();
public void StartMointor(string projectName, ProcessConfig processInfo)
{
if (!ProjectMonitor.ContainsKey(projectName))
{
ProjectMonitor.TryAdd(projectName, processInfo);
}
}
System.Timers.Timer MoniTimer { get; set; } = new System.Timers.Timer();
public void StopMointor(string projectName)
{
if (ProjectMonitor.ContainsKey(projectName))
{
ProjectMonitor.TryRemove(projectName, out ProcessConfig pro);
}
}
#region 方法
public ApiResult StartProject(string projectName, ProcessConfig processConfig)
{
int res = 0;
if (ProjectMonitor.ContainsKey(projectName)) new ApiResult();
foreach (var item in processConfig.GetType().GetProperties())
{
var pro = item.GetValue(processConfig) as ProcessInfo;
if (pro != null && pro.IsEnable)
{
res = StartProcess(pro);
if (res != 0)
{
break;
}
pro.StartTime = DateTime.Now;
pro.State = true;
_cache.Set(pro.ProPath, pro);
Thread.Sleep(10);
}
}
StartMointor(projectName, processConfig);
if (res == 0)
{
return new ApiResult();
}
return new ApiResult() { Message = "操作失败" };
}
public ApiResult StopProject(string projectName)
{
int res = 0;
ProjectMonitor.TryGetValue(projectName, out ProcessConfig process);
if(process == null) { return new ApiResult(); }
foreach (var item in process.GetType().GetProperties())
{
var pro = item.GetValue(process) as ProcessInfo;
if (pro != null && pro.IsEnable)
{
res = KillProcess(pro);
if (res != 0)
{
break;
}
pro.State = false;
_cache.Set(pro.ProPath, pro);
Thread.Sleep(10);
}
}
StopMointor(projectName);
if (res == 0)
{
return new ApiResult();
}
return new ApiResult() { Message = "操作失败" };
}
private bool CMDStartProcess(ProcessInfo proInfo)
{
//* Create your Process
Process process = new Process();
process.Exited += Process_Exited;
process.EnableRaisingEvents = true;
process.StartInfo.FileName = Path.GetFullPath(Path.Combine(proInfo.ProPath, proInfo.ProName + ".exe"));
process.StartInfo.WorkingDirectory = Path.GetFullPath(proInfo.ProPath);
process.StartInfo.Arguments = proInfo.ProParams;
Debug.WriteLine($"*******ProcessName:{process.StartInfo.FileName}, arguments:{process.StartInfo.Arguments}*********");
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
//* Set your output and error (asynchronous) handlers
{
process.OutputDataReceived += new DataReceivedEventHandler(OutputHandler);
process.ErrorDataReceived += new DataReceivedEventHandler(OutputHandler);
}
//* Start process and handlers
bool res = process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
// process.WaitForExit();
return res;
}
private void Process_Exited(object? sender, EventArgs e)
{
}
void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
{
Debug.WriteLine("output*************:{0},{1}", sendingProcess.ToString(), outLine.Data);
if (string.IsNullOrEmpty(outLine.Data)) return;
if (outLine.Data.Contains("ProcessSlice:"))
{
var pro = sendingProcess as Process;
if (pro != null)
{
}
}
else if (outLine.Data.Contains("ML "))
{
var pro = sendingProcess as Process;
if (pro != null)
{
var msEvent= new MsEventModel(outLine.Data) { CurrentTime = DateTime.Now };
Console.WriteLine($"processName:{pro.ProcessName},message:{outLine.Data}");
}
}
}
public int StartProcess(ProcessInfo proInfo)
{
bool res = CMDStartProcess(proInfo);
int seInd = res ? 0 : 1;
return seInd;
}
/// <summary>
/// 结束进程
/// </summary>
/// <param name="processInfo"></param>
/// <returns>0=成功;1=未找到进程;-1=失败</returns>
private int KillProcess(ProcessInfo processInfo)
{
int ri = 0;
if (processInfo != null)
{
if (processInfo.ProName != null)
{
try
{
Process[] localByName = Process.GetProcessesByName(processInfo.ProName);
if (localByName.Length == 0)
{
ri = 1;
return ri;
}
foreach (var item in localByName)
{
item.Kill();
}
return ri;
}
catch (Exception)
{
return -1;
}
}
else
{
return 0;
}
}
else
{
return 0;
}
}
/// <summary>
/// 查找进程
/// </summary>
/// <param name="processInfo"></param>
/// <returns>0=正在运行;1=未运行;-1=系统错误</returns>
private int FindProcess(ProcessInfo processInfo)
{
int ri = 0;
try
{
Process[] localByName = Process.GetProcessesByName(processInfo.ProName);
if (localByName.Length == 0)
{
ri = 1;
return ri;
}
else
{
var pro= localByName.Where(p => p.MainModule.FileName.Contains(processInfo.ProPath));
if (!pro.Any())
{
ri = 1;
}
return ri;
}
}
catch (Exception)
{
return -1;
}
}
public string ProcessStatus { get; set; }
public ApiResult GetState(string projectName, int id)
{
ProjectMonitor.TryGetValue(projectName, out ProcessConfig process);
if (process == null|| (id<1 || id>3)) { return new ApiResult(); }
ProcessInfo pro = id == 1 ? process.Server : id == 2 ? process.Apms : process.RecvMqtt;
int sfp = FindProcess(pro);
if (sfp != 0)
{
return new ApiResult { Code = System.Net.HttpStatusCode.NotFound };
}
return new ApiResult
{
Code = System.Net.HttpStatusCode.OK, Data = new
{
name=pro.ProName,
state= sfp == 0 ? 1 : 0,
start_time=pro.StartTime,
running_time=(DateTime.Now-pro.StartTime).TotalSeconds,
}
};
}
#endregion
public ApiResult ExportCSV(string fileName, List<StationDTO> stations)
{
DataTable dataTable = new DataTable();
string[] header = new string[] { "project_id", "net", "sta"," x2000", "y2000", "z2000", "sens", "begin", "stop", "sitenum" };
DataColumn da = new DataColumn();
foreach (var item in header)
{
dataTable.Columns.Add(item, typeof(string));
}
foreach (var sta in stations)
{
dataTable.Rows.Add(sta.project_id, sta.network,sta.num,sta.coord_e,sta.coord_n,sta.altitude,sta.sens,sta.begin_time,sta.end_time,sta.site_number);
}
return ExportExcel(fileName,dataTable, header);
}
/// 导出csv表格
/// </summary>
/// <param name="list">数据集合</param>
/// <param name="header">数据表头</param>
/// <param name=" title"> 标题</param>
/// <returns></returns>
private ApiResult ExportExcel(string fileName, DataTable dt, string[] header, string title = null)
{
Workbook wb = new Workbook();
try
{
Worksheet sheet = wb.Worksheets[0];
sheet.Name = "station数据";
if (dt.Rows.Count <= 0)
{
return new ApiResult() { Code= System.Net.HttpStatusCode.NoContent,Message="没有数据"};
}
// 为单元格添加样式
Aspose.Cells.Style style = wb.CreateStyle();
//style.HorizontalAlignment = Aspose.Cells.TextAlignmentType.Center; //设置居中
style.Font.Size = 20;//文字大小
style.Font.IsBold = true;//粗体
style.HorizontalAlignment = TextAlignmentType.Center;//文字居中
// 为合计单元格样式
Aspose.Cells.Style sumstyle = wb.CreateStyle();
sumstyle.Font.Size = 12;//文字大小
sumstyle.Font.IsBold = true;//粗体
sumstyle.Font.Color = System.Drawing.Color.Red; //颜色
//style.HorizontalAlignment = TextAlignmentType.Center;//文字居中
//添加标题
int rowIndex = 0;
sheet.Cells.SetRowHeight(rowIndex, 40); //设置行高
if (title != null)
{
sheet.Cells[rowIndex, 0].PutValue(title);
sheet.Cells[rowIndex, 0].SetStyle(style);
sheet.Cells.Merge(0, 0, 1, header.Length); //合并行 Merge(1, 1,1, 5); 第一行 第一列 到 第一行 第 5列
//Merge切记后两位参数不能是 0
rowIndex++;
}
//添加表头
style.Font.Size = 12;//文字大小
sheet.Cells.SetRowHeight(rowIndex, 20); //设置行高
for (int c = 0; c < header.Length; c++)
{
sheet.Cells[rowIndex, c].PutValue(header[c]);
sheet.Cells[rowIndex, c].SetStyle(style);
sheet.Cells.SetColumnWidth(c, 20);//设置宽度
}
rowIndex++;
//添加内容
for (int r = 0; r < dt.Rows.Count; r++)//遍历DataTable行
{
for (int c = 0; c < header.Length; c++) //列只遍历到和表头数量相等的列,其余的列不导出
{
//自动把数字变量转出后 单元格变为数字类型。
try
{
//把添加变量转字符类型存储
sheet.Cells[r + rowIndex, c].PutValue(dt.Rows[r][c].ToString());
// sheet.Cells[r + rowIndex, c].PutValue(Convert.ToDecimal(dt.Rows[r][c])); //要导出数字列是数字类型,必须把添加变量转数字类型。
}
catch
{
//把添加变量转字符类型存储
sheet.Cells[r + rowIndex, c].PutValue(dt.Rows[r][c].ToString());
}
}
}
//输出到Excel
wb.Save(fileName, new OoxmlSaveOptions(SaveFormat.Csv));
//保存成97或2003写法
//workbook.Save(“output.xls, New XlsSaveOptions(SaveFormat.Excel97To2003))
// 释放Excel对象
sheet.Dispose();
wb.Dispose();
}
catch (Exception e)
{
return new ApiResult() { Code = System.Net.HttpStatusCode.NoContent, Message = $"保存{fileName}文件异常:{e.Message}" };
}
return new ApiResult();
}
}
}

@ -1,12 +1,15 @@
using AutoMapper;
using Microsoft.Extensions.Caching.Memory;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Txgy.RBS.DbModel.Models;
using Txgy.RBS.DTO;
using Txgy.RBS.Framework;
using Txgy.RBS.Framework.Api;
using Txgy.RBS.IServices;
@ -15,19 +18,22 @@ namespace Txgy.RBS.Services
public class ProjectInfoService : BaseService, IProjectInfoService
{
private readonly IMapper _iMapper;
private readonly ProcessManagerService _processManager;
private readonly IMemoryCache _cache;
public ProjectInfoService(ISqlSugarClient client, IMapper iMapper) : base(client)
public ProjectInfoService(ISqlSugarClient client, IMapper iMapper, ProcessManagerService processManager) : base(client)
{
this._iMapper = iMapper;
this._processManager = processManager;
}
public ApiResult AddProjectInfo(ProjectInfoDTO project)
{
int res = 0;
project_info project_Info = _iMapper.Map<project_info>(project);
res = _Client.Insertable(project_Info).ExecuteCommand();
if (res > 0)
var pro = _Client.InsertNav(project_Info).Include(p=>p.stationFile).ThenInclude(t=>t.stations)
.Include(time => time.time_tab).ExecuteCommand();
if (pro)
{
return new ApiResult();
}
@ -36,8 +42,9 @@ namespace Txgy.RBS.Services
public ApiResult DeleteProjectInfo(int id)
{
int res= _Client.Deleteable<project_info>(p=>p.id==id).ExecuteCommand();
if (res > 0)
var res = _Client.DeleteNav<project_info>(p => p.id == id).Include(p => p.stationFile).ThenInclude(t => t.stations)
.Include(time => time.time_tab).ExecuteCommand();
if (res)
{
return new ApiResult();
}
@ -46,8 +53,10 @@ namespace Txgy.RBS.Services
public List<ProjectInfoDTO> GetAllProjectInfo()
{
var projects = _Client.Queryable<project_info>().ToList();
return _iMapper.Map<List<ProjectInfoDTO>>(projects);
var projects = _Client.Queryable<project_info>().Includes(x => x.stationFile, t=>t.stations)
.Includes(ti=>ti.time_tab).ToList();
var projectDTOs= _iMapper.Map<List<ProjectInfoDTO>>(projects);
return projectDTOs;
}
public ProjectUsedDTO GetCurrentProjectUsed()
@ -57,44 +66,69 @@ namespace Txgy.RBS.Services
return projectUse;
}
//public ProjectInfoDTO GetCurrentProjectInfo()
//{
// var curProject = _Client.Queryable<project_used>().First();
// project_info projectInfo = _Client.Queryable<project_info>().First(c => c.id == curProject.current_project_id);
// ProjectInfoDTO projectInfoDTO = _iMapper.Map<project_info, ProjectInfoDTO>(projectInfo);
// return projectInfoDTO;
//}
public ApiResult UpdateProjectInfo(ProjectInfoDTO project)
{
project_info projectInfo = _iMapper.Map<project_info>(project);
var res = _Client.UpdateNav(projectInfo).Include(p => p.stationFile).ThenInclude(t => t.stations)
.Include(time => time.time_tab).ExecuteCommand();
if (res)
{
return new ApiResult();
}
return new ApiResult() { Message = "更新失败" };
}
public ProjectInfoDTO GetProjectInfo(int id)
{
project_info projectInfo = _Client.Queryable<project_info>().First(c => c.id == id);
project_info projectInfo = _Client.Queryable<project_info>().Includes(x => x.stationFile, t => t.stations).Includes(ti => ti.time_tab).Where(p => p.id == id).First();
ProjectInfoDTO projectInfoDTO = _iMapper.Map<project_info, ProjectInfoDTO>(projectInfo);
//test
//if (projectInfoDTO != null)
//{
// projectInfoDTO.id = 6;
// projectInfoDTO.project_id = 9;
// projectInfoDTO.project_name = "tea";
// projectInfoDTO.moni_layer = 1;
// projectInfoDTO.moni_num = 8;
// var a = UpdateProjectInfo(projectInfoDTO);
//}
return projectInfoDTO;
}
public ApiResult StartProject(bool isStart)
{
int res = 0;
if (res == 0)
public ApiResult UpdateCurrentProjectUsed(ProjectUsedDTO projectUsed)
{
var pro=_iMapper.Map<project_used>(projectUsed);
var res= _Client.Updateable<project_used>(pro).ExecuteCommand();
if (res>0)
{
return new ApiResult();
}
return new ApiResult() { Message = "更新失败" };
}
public ApiResult UpdateProjectInfo(ProjectInfoDTO project)
public ApiResult StartProject(string projectName, ProcessConfig processConfig)
{
project_info projectInfo = _iMapper.Map<ProjectInfoDTO, project_info> (project);
int res= _Client.Updateable<project_info>(projectInfo).ExecuteCommand();
if(res > 0)
var res = _processManager.StartProject(projectName, processConfig);
return res;
}
public ApiResult StopProject(string projectName)
{
return new ApiResult();
var res = _processManager.StopProject(projectName);
return res;
}
return new ApiResult() { Message = "更新失败" };
public ApiResult GetState(string projectName, int id)
{
return _processManager.GetState(projectName, id);
}
public ApiResult ExportCSV(string fileName, List<StationDTO> stations)
{
return _processManager.ExportCSV(fileName, stations);
}
}
}

@ -21,10 +21,10 @@ namespace Txgy.RBS.Services
this._iMapper = iMapper;
}
public ApiResult AddResultInfo(ResultJsonDTO resultJsonDTO)
public ApiResult AddResultInfo(ResultDTO resultJsonDTO)
{
int res = 0;
result_json result_Json = _iMapper.Map<result_json>(resultJsonDTO);
result result_Json = _iMapper.Map<result>(resultJsonDTO);
res = _Client.Insertable(result_Json).ExecuteCommand();
if (res > 0)
@ -36,7 +36,7 @@ namespace Txgy.RBS.Services
public ApiResult DeleteResultInfo(int id)
{
int res= _Client.Deleteable<result_json>(p=>p.id==id).ExecuteCommand();
int res= _Client.Deleteable<result>(p=>p.id==id).ExecuteCommand();
if (res > 0)
{
return new ApiResult();
@ -44,24 +44,24 @@ namespace Txgy.RBS.Services
return new ApiResult() { Message = "删除失败" };
}
public List<ResultJsonDTO> GetAllResultInfo()
public List<ResultDTO> GetAllResultInfo()
{
var projects = _Client.Queryable<result_json>().ToList();
return _iMapper.Map<List<ResultJsonDTO>>(projects);
var projects = _Client.Queryable<result>().ToList();
return _iMapper.Map<List<ResultDTO>>(projects);
}
public ResultJsonDTO GetResultInfo(int id)
public ResultDTO GetResultInfo(int id)
{
result_json result_Json = _Client.Queryable<result_json>().First(c => c.id == id);
ResultJsonDTO resultJsonDTO = _iMapper.Map<ResultJsonDTO>(result_Json);
result result_Json = _Client.Queryable<result>().First(c => c.id == id);
ResultDTO resultJsonDTO = _iMapper.Map<ResultDTO>(result_Json);
return resultJsonDTO;
}
public ApiResult UpdateResultInfo(ResultJsonDTO resultJsonDTO)
public ApiResult UpdateResultInfo(ResultDTO resultJsonDTO)
{
result_json result_Json = _iMapper.Map<result_json> (resultJsonDTO);
int res= _Client.Updateable<result_json>(result_Json).ExecuteCommand();
result result_Json = _iMapper.Map<result> (resultJsonDTO);
int res= _Client.Updateable<result>(result_Json).ExecuteCommand();
if(res > 0)
{
return new ApiResult();

@ -21,10 +21,10 @@ namespace Txgy.RBS.Services
this._iMapper = iMapper;
}
public ApiResult AddStations(StationsDTO stationsDTO)
public ApiResult AddStations(StationDTO stationsDTO)
{
int res = 0;
stations station = _iMapper.Map<stations>(stationsDTO);
station station = _iMapper.Map<station>(stationsDTO);
res = _Client.Insertable(station).ExecuteCommand();
if (res > 0)
@ -36,7 +36,7 @@ namespace Txgy.RBS.Services
public ApiResult DeleteStations(int id)
{
int res= _Client.Deleteable<stations>(p=>p.id==id).ExecuteCommand();
int res= _Client.Deleteable<station>(p=>p.id==id).ExecuteCommand();
if (res > 0)
{
return new ApiResult();
@ -44,24 +44,30 @@ namespace Txgy.RBS.Services
return new ApiResult() { Message = "删除失败" };
}
public List<StationsDTO> GetAllStations()
public List<StationDTO> GetAllStations()
{
var projects = _Client.Queryable<stations>().ToList();
return _iMapper.Map<List<StationsDTO>>(projects);
var projects = _Client.Queryable<station>().ToList();
return _iMapper.Map<List<StationDTO>>(projects);
}
public List<StationNumVpnDTO> GetStationNumVpn()
{
var station = _Client.Queryable<station_num_vpn>().ToList();
var stationsDTO = _iMapper.Map<List<StationNumVpnDTO>>(station);
return stationsDTO;
}
public StationsDTO GetStations(int id)
public StationDTO GetStations(int id)
{
stations station = _Client.Queryable<stations>().First(c => c.id == id);
StationsDTO stationsDTO = _iMapper.Map<StationsDTO>(station);
station station = _Client.Queryable<station>().First(c => c.id == id);
StationDTO stationsDTO = _iMapper.Map<StationDTO>(station);
return stationsDTO;
}
public ApiResult UpdateStations(StationsDTO stationsDTO)
public ApiResult UpdateStations(StationDTO stationsDTO)
{
stations station = _iMapper.Map<stations> (stationsDTO);
int res= _Client.Updateable<stations>(station).ExecuteCommand();
station station = _iMapper.Map<station> (stationsDTO);
int res= _Client.Updateable<station>(station).ExecuteCommand();
if(res > 0)
{
return new ApiResult();

@ -7,7 +7,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Aspose.Cells" Version="24.4.0" />
<PackageReference Include="AutoMapper" Version="13.0.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.0" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.148" />
</ItemGroup>

@ -1 +1 @@
start /min gw.apms.exe -cfg gw.apms3.json >out.txt
start /min gw.apms.exe -cfg gw.apms.json >out.txt

@ -60,3 +60,9 @@
[4504] 16 Mar 13:33:12.690 # Server initialized
[4504] 16 Mar 13:33:12.691 * Ready to accept connections
[4504] 19 Mar 15:52:42.085 # Client id=258 addr=116.235.70.136:52939 fd=13 name= age=1945 idle=295 flags=P db=1 sub=33 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=16226 oll=515 omem=10559560 events=rw cmd=subscribe scheduled to be closed ASAP for overcoming of output buffer limits.
[37440] 17 Apr 14:21:54.831 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
[37440] 17 Apr 14:21:54.832 # Redis version=5.0.10, bits=64, commit=1c047b68, modified=0, pid=37440, just started
[37440] 17 Apr 14:21:54.832 # Configuration loaded
[37440] 17 Apr 14:21:54.835 * Running mode=standalone, port=6379.
[37440] 17 Apr 14:21:54.835 # Server initialized
[37440] 17 Apr 14:21:54.836 * Ready to accept connections

Loading…
Cancel
Save