|
|
@ -20,24 +20,29 @@ namespace Txgy.RBS.Server.WebApi.Controllers
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private readonly IProjectInfoService _projectInfoService;
|
|
|
|
private readonly IProjectInfoService _projectInfoService;
|
|
|
|
private readonly IStationsService _stationsService;
|
|
|
|
private readonly IStationsService _stationsService;
|
|
|
|
|
|
|
|
private readonly IGlobalConfigService _globalConfigService;
|
|
|
|
private readonly ProcessConfig _processConfig;
|
|
|
|
private readonly ProcessConfig _processConfig;
|
|
|
|
|
|
|
|
|
|
|
|
public ProjectInfoController(ILogger<ProjectInfoController> logger, IProjectInfoService projectInfoService,IStationsService stationsService, IConfiguration configuration)
|
|
|
|
public ProjectInfoController(ILogger<ProjectInfoController> logger, IProjectInfoService projectInfoService,
|
|
|
|
|
|
|
|
IStationsService stationsService,
|
|
|
|
|
|
|
|
IGlobalConfigService globalConfigService,
|
|
|
|
|
|
|
|
IConfiguration configuration)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this._projectInfoService = projectInfoService;
|
|
|
|
this._projectInfoService = projectInfoService;
|
|
|
|
this._stationsService = stationsService;
|
|
|
|
this._stationsService = stationsService;
|
|
|
|
|
|
|
|
this._globalConfigService = globalConfigService;
|
|
|
|
this._processConfig = configuration.GetSection("process").Get<ProcessConfig>();
|
|
|
|
this._processConfig = configuration.GetSection("process").Get<ProcessConfig>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
[HttpPost]
|
|
|
|
public ApiResult AddProjectInfo(ProjectInfoDTO project)
|
|
|
|
public ApiResult AddProjectInfo(ProjectInfoDTO project)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//var pro= _projectInfoService.GetProjectInfo(1);
|
|
|
|
//var pro= _projectInfoService.GetProjectInfo(1);
|
|
|
|
// pro.id=project.id;
|
|
|
|
// pro.id=project.id;
|
|
|
|
// pro.project_id = project.project_id;
|
|
|
|
// pro.project_id = project.project_id;
|
|
|
|
// pro.project_name = project.project_name;
|
|
|
|
// pro.project_name = project.project_name;
|
|
|
|
// pro.moni_layer = project.moni_layer;
|
|
|
|
// pro.moni_layer = project.moni_layer;
|
|
|
|
// pro.moni_num = project.moni_num;
|
|
|
|
// pro.moni_num = project.moni_num;
|
|
|
|
return _projectInfoService.AddProjectInfo(project);
|
|
|
|
return _projectInfoService.AddProjectInfo(project);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -65,12 +70,17 @@ namespace Txgy.RBS.Server.WebApi.Controllers
|
|
|
|
return _projectInfoService.GetAllProjectInfo();
|
|
|
|
return _projectInfoService.GetAllProjectInfo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
[HttpGet("{clientId}")]
|
|
|
|
public ProjectUsedDTO GetCurrentProjectUsed()
|
|
|
|
public ProjectUsedDTO GetCurrentProjectUsed(string clientId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return _projectInfoService.GetCurrentProjectUsed();
|
|
|
|
return _projectInfoService.GetCurrentProjectUsed(clientId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
|
|
|
public ProjectUsedDTO GetCurrentProjectUsed(int projectId)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return _projectInfoService.GetCurrentProjectUsed(projectId);
|
|
|
|
|
|
|
|
}
|
|
|
|
[HttpPost]
|
|
|
|
[HttpPost]
|
|
|
|
public ApiResult StartProject(ProjectUsedDTO usedDTO)
|
|
|
|
public ApiResult StartProject(ProjectUsedDTO usedDTO)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -79,11 +89,11 @@ namespace Txgy.RBS.Server.WebApi.Controllers
|
|
|
|
|
|
|
|
|
|
|
|
var curProject = this.GetProjectInfo(usedDTO.current_project_id);
|
|
|
|
var curProject = this.GetProjectInfo(usedDTO.current_project_id);
|
|
|
|
var staVpn = _stationsService.GetStationNumVpn();
|
|
|
|
var staVpn = _stationsService.GetStationNumVpn();
|
|
|
|
|
|
|
|
var globalConfig = _globalConfigService.GetGlobalConfig();
|
|
|
|
if (res.Success && curProject != null)
|
|
|
|
if (res.Success && curProject != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
string path = Path.Combine(CommonData.BaseProjectPath, curProject.project_name);
|
|
|
|
string path = Path.Combine(globalConfig.base_path, curProject.project_name);
|
|
|
|
if (!Directory.Exists(path))
|
|
|
|
if (!Directory.Exists(path))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var direc = Directory.CreateDirectory(path);
|
|
|
|
var direc = Directory.CreateDirectory(path);
|
|
|
@ -105,8 +115,14 @@ namespace Txgy.RBS.Server.WebApi.Controllers
|
|
|
|
System.IO.File.WriteAllText(Path.Combine(path, "program\\apms", curProject.timeTab.filename), curProject.timeTab.file_content);
|
|
|
|
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.is_write_slice = (curProject.local_save_result == 1) ? "YES" : "NO";
|
|
|
|
apm.savepath = Path.Combine(CommonData.BaseProjectPath, curProject.project_name, curProject.save_result_path) ;
|
|
|
|
apm.savepath = Path.Combine(globalConfig.base_path, curProject.project_name, curProject.save_result_path) ;
|
|
|
|
|
|
|
|
apm.push2wx= (curProject.push_wx==1)? "YES" : "NO";
|
|
|
|
apm.push_mag = curProject.push_wx_value;
|
|
|
|
apm.push_mag = curProject.push_wx_value;
|
|
|
|
|
|
|
|
apm.push_url = globalConfig.push_wx_url;
|
|
|
|
|
|
|
|
apm.company_id = globalConfig.push_wx_company_id;
|
|
|
|
|
|
|
|
apm.message_id = globalConfig.push_wx_message_id;
|
|
|
|
|
|
|
|
apm.content = globalConfig.push_wx_content;
|
|
|
|
|
|
|
|
apm.push_key = globalConfig.push_wx_key;
|
|
|
|
apm.channels = new List<StationChannelsModel>
|
|
|
|
apm.channels = new List<StationChannelsModel>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
new StationChannelsModel
|
|
|
|
new StationChannelsModel
|
|
|
@ -132,7 +148,7 @@ namespace Txgy.RBS.Server.WebApi.Controllers
|
|
|
|
var rec = JsonConvert.DeserializeObject<RecvMqttModel>(str);
|
|
|
|
var rec = JsonConvert.DeserializeObject<RecvMqttModel>(str);
|
|
|
|
if (rec != null)
|
|
|
|
if (rec != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
rec.savepath = Path.Combine(CommonData.BaseProjectPath, curProject.project_name, curProject.save_waves_path);
|
|
|
|
rec.savepath = Path.Combine(globalConfig.base_path, curProject.project_name, curProject.save_waves_path);
|
|
|
|
rec.send2server = (curProject.send_redis == 1) ? "YES" : "NO";
|
|
|
|
rec.send2server = (curProject.send_redis == 1) ? "YES" : "NO";
|
|
|
|
rec.Server = curProject.mqtt_server;
|
|
|
|
rec.Server = curProject.mqtt_server;
|
|
|
|
List< StationNumVpnDTO> vpnList=new List< StationNumVpnDTO>();
|
|
|
|
List< StationNumVpnDTO> vpnList=new List< StationNumVpnDTO>();
|
|
|
@ -152,24 +168,33 @@ namespace Txgy.RBS.Server.WebApi.Controllers
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_processConfig.FilesWatcherService = new Framework.FileWatcherHelper.FilesWatcherService(curProject.project_id,curProject.project_name,apm.savepath);
|
|
|
|
_processConfig.FilesWatcherService = new Framework.FileWatcherHelper.FilesWatcherService(curProject.project_id,curProject.project_name,apm.savepath);
|
|
|
|
res= _projectInfoService.StartProject(curProject.project_name, _processConfig);
|
|
|
|
res= _projectInfoService.StartProject(curProject.project_name, _processConfig);
|
|
|
|
res.Data = curProject;
|
|
|
|
if(res.Success)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
res = _projectInfoService.UpdateCurrentProjectUsed(usedDTO);
|
|
|
|
|
|
|
|
res.Data = curProject;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
res.Message = "没有查询到当前工程名称!";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
[HttpPost]
|
|
|
|
public ApiResult StopProject(ProjectUsedDTO usedDTO)
|
|
|
|
public ApiResult StopProject(ProjectUsedDTO usedDTO)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// 更新当前项目配置
|
|
|
|
// 更新当前项目配置
|
|
|
|
var res = _projectInfoService.UpdateCurrentProjectUsed(usedDTO);
|
|
|
|
var res = _projectInfoService.DeleteCurrentProjectUsed(usedDTO.current_project_id);
|
|
|
|
var curProject = this.GetProjectInfo(usedDTO.current_project_id);
|
|
|
|
var curProject = this.GetProjectInfo(usedDTO.current_project_id);
|
|
|
|
if (res.Success && curProject != null)
|
|
|
|
if (res.Success && curProject != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
res= _projectInfoService.StopProject(curProject.project_name);
|
|
|
|
res= _projectInfoService.StopProject(curProject.project_name);
|
|
|
|
res.Data = curProject;
|
|
|
|
res.Data = curProject;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
[HttpGet]
|
|
|
|
public ApiResult GetProjectProcessState(string projectName, int id)
|
|
|
|
public ApiResult GetProjectProcessState(string projectName, int id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|