1修改显示CMD输出内容;

2增加websocket发送钉钉协议;
master
mzhifa 1 year ago
parent 1d750488ff
commit 23003d90ad

@ -16,6 +16,7 @@ namespace StartServerWPF.Modules.Main
public void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.RegisterSingleton<MainViewModel>();
containerRegistry.RegisterDialog<SetParamDialog>();
}
}

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StartServerWPF.Modules.Main.Model
{
class CSMessage
{
public const string heartbeat = "heartbeat";
public const string sigin = "sigin";
public const string offer = "offer";
public const string subscribe = "subscribe";
public const string unsubscribe = "unsubscribe";
public const string publish = "publish";
public const string close = "close";
public const string kickoff = "kickoff";
public const string webhook = "webhook";
}
}

@ -34,6 +34,10 @@ namespace StartServerWPF.Modules.Main.Model
/// </summary>
public ProcessInfo proMonitor { get; set; }
/// <summary>
/// 波形tools
/// </summary>
public ProcessInfo proTools { get; set; }
/// <summary>
/// 波形显示程序
/// </summary>
public ProcessInfo proPlot { get; set; }

@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace StartServerWPF.Modules.Main.Model
{
public class CSUserSigin
{
public string type { get; set; }
public string utype { get; set; }
/// <summary>
/// 用户id
/// </summary>
public int uid { get; set; }
/// <summary>
/// 用户的key
/// </summary>
public string key { get; set; }
public string account { get; set; }
public string password { get; set; }
}
public class SCUserSigin
{
public string type { get; set; }
public string message { get; set; }
public int uid { get; set; }
public int code { get; set; }
}
public class CSUserSubscribeMessage
{
public string type { get; set; }
public string message { get; set; }
public int uid { get; set; }
}
public class SCUserSubscribeMessage
{
public string type { get; set; }
public int code { get; set; }
public int uid { get; set; }
}
public class CSDevicePublish
{
public string type { get; set; }
public string message { get; set; }
public int serialNumber { get; set; }
}
public class SCDevicePublish
{
public string type { get; set; }
public int code { get; set; }
public string message { get; set; }
public int serialNumber { get; set; }
}
public class CSDeviceWebhook
{
public string type { get; set; }
public string message { get; set; }
public int serialNumber { get; set; }
}
}

@ -14,5 +14,6 @@ namespace StartServerWPF.Modules.Main
public string Password { get; set; }
public string DataBase { get; set; }
public string TableName { get; set; }
public string WebsocketUrl { get; set; }
}
}

@ -18,6 +18,12 @@ using StartServerWPF.Modules.Main.Model;
using System.Windows.Media;
using System.Timers;
using System.Windows.Threading;
using Org.BouncyCastle.Crypto.Modes.Gcm;
using System.Net.Http.Json;
using System.Text.Json.Serialization;
using System.Text.Json;
using System.Text.Encodings.Web;
using System.Text.Unicode;
namespace StartServerWPF.Modules.Main.ViewModels
{
@ -46,7 +52,8 @@ namespace StartServerWPF.Modules.Main.ViewModels
+ "\t" + sc.remoteDb.UserName + "\t" + sc.remoteDb.Password);
this._dialogService = dialogService;
this._websocket = websocket;
_websocket.WebSocketInit();
_websocket.WebSocketInit(sc.remoteDb.WebsocketUrl);
CurrentItemsList = ApmsProcessSliceList;
}
@ -134,8 +141,57 @@ namespace StartServerWPF.Modules.Main.ViewModels
set => SetProperty(ref proMonInterval, value);
}
#endregion
private ObservableCollection<string> _OutPutItemsSource = new ObservableCollection<string>();
public ObservableCollection<string> OutPutItemsSource
{
get => _OutPutItemsSource;
set => SetProperty(ref _OutPutItemsSource, value);
}
private List<string> _apmsProcessSliceList= new List<string>();
public List<string> ApmsProcessSliceList
{
get => _apmsProcessSliceList;
set=> SetProperty(ref _apmsProcessSliceList, value);
}
private List<string> _apmsEventList = new List<string>();
public List<string> ApmsEventList
{
get => _apmsEventList;
set => SetProperty(ref _apmsEventList, value);
}
private List<string> _toolsProcessSliceList = new List<string>();
public List<string> ToolsProcessSliceList
{
get => _toolsProcessSliceList;
set => SetProperty(ref _toolsProcessSliceList, value);
}
private List<string> _toolsEventList = new List<string>();
public List<string> ToolsEventList
{
get => _toolsEventList;
set => SetProperty(ref _toolsEventList, value);
}
public static void AddItems<T>(List<T> list, T t1)
{
if (list == null)
{
return;
}
list.Add(t1);
if (list.Count > 10)
{
T item = list[0];
list.RemoveAt(0);
}
}
#endregion
private List<string> CurrentItemsList;
#region 事件
public DelegateCommand LoadedCommand => new(Loaded);
public DelegateCommand UnloadedCommand => new(Unloaded);
@ -150,51 +206,55 @@ namespace StartServerWPF.Modules.Main.ViewModels
public DelegateCommand DisplayRealWavesCommand => new(DisplayRealWaves);
public DelegateCommand QueryDataCommand => new(QueryData);
public DelegateCommand InsertDataCommand => new(InsertData);
public DelegateCommand<object> OutputItemsCommand => new((obj)=>
{
switch (obj.ToString())
{
case "apmsProcessSlice":
CurrentItemsList = ApmsProcessSliceList;
break;
case "apmsEvent":
CurrentItemsList = ApmsEventList;
OutPutItemsSource.Clear();
break;
case "toolsProcessSlice":
CurrentItemsList = ToolsProcessSliceList;
break;
case "toolsEvent":
CurrentItemsList = ToolsEventList;
break;
default:
break;
}
OutPutItemsSource.Clear();
CurrentItemsList.ForEach((item) =>
{
OutPutItemsSource.Add(item);
});
});
private void Loaded()
{
IntilVPN();
SetControlstatus();
}
private void Unloaded()
public void Unloaded()
{
KillProcess(sc.proServer);
KillProcess(sc.proRecv);
KillProcess(sc.proApms);
KillProcess(sc.proMonitor);
string logStr = DateTime.Now.ToString("s") + "\t程序关闭";
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
//switch (kserindex)
//{
// case -1:
// Console.WriteLine(serProcInfo.ProName + "结束失败");
// break;
// case 0:
// Console.WriteLine(serProcInfo.ProName + "结束成功");
// break;
// case 1:
// Console.WriteLine(serProcInfo.ProName + "程序未启动");
// break;
//}
//int krecindex = KillProcess(recvProcInfo);
//switch (krecindex)
//{
// case -1:
// Console.WriteLine(recvProcInfo.ProName + "结束失败");
// break;
// case 0:
// Console.WriteLine(recvProcInfo.ProName + "结束成功");
// break;
// case 1:
// Console.WriteLine(recvProcInfo.ProName + "程序未启动");
// break;
//}
//KillProcess(sc.proServer);
//KillProcess(sc.proRecv);
//KillProcess(sc.proApms);
//KillProcess(sc.proMonitor);
//KillProcess(sc.proTools);
//string logStr = DateTime.Now.ToString("s") + "\t程序关闭";
//WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
OneKeyStop();
}
private void ConnectVPN()
{
vpn.CreateOrUpdateVPN(sc.vpnInfo.VpnName, sc.vpnInfo.VpnIP);
vpn.ConnectVPN(sc.vpnInfo.VpnName, sc.vpnInfo.VpnUserName, sc.vpnInfo.VpnPsw);
Thread.Sleep(1000);
@ -230,10 +290,6 @@ namespace StartServerWPF.Modules.Main.ViewModels
private void SetVPNPara()
{
//FormSetParam fvi = new FormSetParam();
//fvi.fm = this;
//fvi.ShowDialog();
DialogParameters param = new DialogParameters();
param.Add("type", 1);// 编辑
param.Add("model", sc);
@ -258,33 +314,20 @@ namespace StartServerWPF.Modules.Main.ViewModels
private void OneKeyStart()
{
StartTime = DateTime.Now;
sc.proServer.Pid = StartProcess(sc.proServer);
StartTime = DateTime.Now;
if (sc.proServer.Pid < 32)
{
ReciveDataSource.Add("服务器程序启动失败:" + StartTime.ToString());
}
Thread.Sleep(10);
sc.proRecv.Pid = StartProcess(sc.proRecv);
if (sc.proRecv.Pid < 32)
{
ReciveDataSource.Add("接收数据程序启动失败:" + StartTime.ToString());
}
Thread.Sleep(10);
sc.proApms.Pid = StartProcess(sc.proApms);
if (sc.proApms.Pid < 32)
foreach (var item in sc.GetType().GetProperties())
{
ReciveDataSource.Add("自动识别程序启动失败:" + StartTime.ToString());
}
Thread.Sleep(10);
sc.proMonitor.Pid = StartProcess(sc.proMonitor);
Console.WriteLine(sc.proMonitor.Pid);
if (sc.proMonitor.Pid < 32)
{
ReciveDataSource.Add("网页服务程序启动失败:" + StartTime.ToString());
var pro = item.GetValue(sc) as ProcessInfo;
if (pro != null)
{
StartTime = DateTime.Now;
pro.Pid= StartProcess(pro);
if (sc.proServer.Pid < 32)
{
ReciveDataSource.Add( pro.ProName+"服务器程序启动失败:" + StartTime.ToString());
}
Thread.Sleep(10);
}
}
Thread.Sleep(10);
// labelStartTime.Text = "启动时间:" + StartTime.ToString();
RunTime = DateDiff(DateTime.Now, StartTime);
string logStr = StartTime.ToString("s") + "\t服务器程序启动";
@ -299,42 +342,23 @@ namespace StartServerWPF.Modules.Main.ViewModels
private void OneKeyStop()
{
int kserindex = KillProcess(sc.proServer);
if (kserindex > -1)
{
ReciveDataSource.Add(sc.proServer.ProName + "结束成功");
}
else
{
ReciveDataSource.Add(sc.proServer.ProName + "结束失败");
}
int krecindex = KillProcess(sc.proRecv);
if (kserindex > -1)
{
ReciveDataSource.Add(sc.proRecv.ProName + "结束成功");
}
else
{
ReciveDataSource.Add(sc.proRecv.ProName + "结束失败");
}
int kampsindex = KillProcess(sc.proApms);
if (kampsindex > -1)
{
ReciveDataSource.Add(sc.proApms.ProName + "结束成功");
}
else
{
ReciveDataSource.Add(sc.proApms.ProName + "结束失败");
}
int kmonitorindex = KillProcess(sc.proMonitor);
if (kmonitorindex > -1)
{
ReciveDataSource.Add(sc.proMonitor.ProName + "结束成功");
}
else
foreach (var item in sc.GetType().GetProperties())
{
ReciveDataSource.Add(sc.proMonitor.ProName + "结束失败");
var pro = item.GetValue(sc) as ProcessInfo;
if (pro != null)
{
int indexPro = KillProcess(pro);
if (indexPro > -1)
{
ReciveDataSource.Add(pro.ProName + "结束成功");
}
else
{
ReciveDataSource.Add(pro.ProName + "结束失败");
}
}
}
ReciveDataSource.Add("服务停止于:" + DateTime.Now.ToString());
timer1.Stop();
IsIndeterminate = false;
@ -372,37 +396,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
{
Console.WriteLine("已有该记录");
}
// dataGridView1.DataSource = remDb.MySqlSelect("select ETime,X,Y,Z,ML,LocSta,MLSta,Rms from " + sc.remoteDb.TableName).Tables[sc.remoteDb.TableName];
}
//private void button1_Click(object sender, EventArgs e)
//{
// vpn.ConnectVPN(sc.vpnInfo.VpnName, sc.vpnInfo.VpnUserName, sc.vpnInfo.VpnPsw);
// Thread.Sleep(1000);
// string logStr = DateTime.Now.ToString("s") + "\tVPN手动连接";
// WriteSerLog(sc.SystemLogPath + systemLogFileName, logStr);
// SetControlstatus();
//}
//private void button1_Click_1(object sender, EventArgs e)
//{
// JsonParser.WriteSystemConfigFile("SystemConfig.json", sc);
//}
//private void button2_Click(object sender, EventArgs e)
//{
// ProcessStartInfo processStartInfo = new ProcessStartInfo(@"F:\Project\2021\河南理工\余吾预警项目\郑老师程序\v20210415\All\server.exe", "service.conf");
// processStartInfo.WindowStyle = ProcessWindowStyle.Normal;
// Process proc = Process.Start(processStartInfo);
// ProcessStartInfo processStartInfoRec = new ProcessStartInfo(@"F:\Project\2021\河南理工\余吾预警项目\郑老师程序\v20210415\All\gw.recvftp.exe", "-cfg gw.recvftp.json >outRecv.txt");
// processStartInfoRec.WindowStyle = ProcessWindowStyle.Normal;
// Process procRec = Process.Start(processStartInfoRec);
//}
#endregion
private void ConnectVpn()
{
@ -473,6 +467,83 @@ namespace StartServerWPF.Modules.Main.ViewModels
//CheckIp();
}
#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;
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();
return res;
// process.WaitForExit();
}
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)
{
if (pro.MainModule.ModuleName.Contains(sc.proApms.ProName))
{
AddItems(ApmsProcessSliceList, outLine.Data);
}
else if (pro.MainModule.ModuleName.Contains(sc.proTools.ProName))
{
AddItems(ToolsProcessSliceList, outLine.Data);
}
}
}
else if (outLine.Data.Contains("ML "))
{
var pro = sendingProcess as Process;
if (pro != null)
{
if (pro.MainModule.ModuleName.Contains(sc.proApms.ProName))
{
AddItems(ApmsEventList, outLine.Data);
}
else if (pro.MainModule.ModuleName.Contains(sc.proTools.ProName))
{
AddItems(ToolsEventList, outLine.Data);
}
}
}
Application.Current.Dispatcher.BeginInvoke(() =>
{
OutPutItemsSource.Clear();
CurrentItemsList.ForEach((item) =>
{
OutPutItemsSource.Add(item);
});
});
}
/// <summary>
/// 启动进程
/// </summary>
@ -480,19 +551,12 @@ namespace StartServerWPF.Modules.Main.ViewModels
/// <returns>进程启动返回值</returns>
private int StartProcess(ProcessInfo proInfo)
{
//using (Process compiler = new Process())
//{
// compiler.StartInfo.FileName = proInfo.ProName;
// compiler.StartInfo.Arguments = proInfo.ProPath + " -o " + proInfo.ProParams;
// compiler.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
// compiler.Start();
// compiler.WaitForExit();
//}
int seInd = ShellExecute(IntPtr.Zero, new StringBuilder("open"), new StringBuilder(proInfo.ProName + ".exe")
, new StringBuilder(proInfo.ProParams), new StringBuilder(proInfo.ProPath), proInfo.ShowState);
bool res= CMDStartProcess(proInfo);
int seInd = res ? 37 : 1;
//int seInd = ShellExecute(IntPtr.Zero, new StringBuilder("open"), new StringBuilder(proInfo.ProName + ".exe")
// , new StringBuilder(proInfo.ProParams), new StringBuilder(proInfo.ProPath), proInfo.ShowState);
return seInd;
}
/// <summary>
/// 结束进程
@ -589,66 +653,105 @@ namespace StartServerWPF.Modules.Main.ViewModels
{
ReciveDataSource.Clear();
ReciveDataSource.Add(DateTime.Now.ToString());
int sfp = FindProcess(sc.proServer);
if (sfp == 0)
{
ReciveDataSource.Add("服务器程序运行正常");
}
else
{
ReciveDataSource.Add("服务器程序未运行");
Thread.Sleep(2);
StartProcess(sc.proServer);
Thread.Sleep(20);
ReciveDataSource.Add("服务器程序重启成功");
string logStr = DateTime.Now.ToString("s") + "\t服务器程序" + sc.proServer.ProName + "重启";
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
}
sfp = FindProcess(sc.proRecv);
if (sfp == 0)
{
ReciveDataSource.Add("接收数据程序运行正常");
}
else
{
ReciveDataSource.Add("接收数据程序未运行");
Thread.Sleep(2);
StartProcess(sc.proRecv);
Thread.Sleep(20);
ReciveDataSource.Add("接收数据程序重启成功");
string logStr = DateTime.Now.ToString("s") + "\t接收数据程序" + sc.proRecv.ProName + "重启";
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
}
sfp = FindProcess(sc.proApms);
if (sfp == 0)
{
ReciveDataSource.Add("自动识别程序运行正常");
}
else
{
ReciveDataSource.Add("自动识别程序未运行");
Thread.Sleep(2);
StartProcess(sc.proApms);
Thread.Sleep(20);
ReciveDataSource.Add("自动识别程序重启成功");
string logStr = DateTime.Now.ToString("s") + "\t自动识别程序" + sc.proApms.ProName + "重启";
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
}
sfp = FindProcess(sc.proMonitor);
if (sfp == 0)
{
ReciveDataSource.Add("网页服务程序运行正常");
}
else
foreach (var item in sc.GetType().GetProperties())
{
ReciveDataSource.Add("网页服务程序未运行");
Thread.Sleep(2);
StartProcess(sc.proMonitor);
Thread.Sleep(20);
ReciveDataSource.Add("网页服务程序重启成功");
string logStr = DateTime.Now.ToString("s") + "\t网页服务程序" + sc.proMonitor.ProName + "重启";
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
var pro = item.GetValue(sc) as ProcessInfo;
if (pro != null)
{
int sfp = FindProcess(pro);
if (sfp == 0)
{
ReciveDataSource.Add(pro.ProName+"服务器程序运行正常");
}
else
{
ReciveDataSource.Add(pro.ProName + "服务器程序未运行");
Thread.Sleep(2);
StartProcess(pro);
Thread.Sleep(20);
ReciveDataSource.Add(pro.ProName + "服务器程序重启成功");
string logStr = DateTime.Now.ToString("s") + "\t服务器程序" + pro.ProName + "重启";
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
string jsonStr= JsonSerializer.Serialize<CSDeviceWebhook>(new CSDeviceWebhook
{
type= CSMessage.webhook,
message=logStr,
}, new JsonSerializerOptions
{
// 整齐打印
WriteIndented = true,
//重新编码,解决中文乱码问题
Encoder = JavaScriptEncoder.Create(UnicodeRanges.All)
});
_websocket.SendMes(jsonStr);
}
}
}
#region 注释
//int sfp = FindProcess(sc.proServer);
//if (sfp == 0)
//{
// ReciveDataSource.Add("服务器程序运行正常");
//}
//else
//{
// ReciveDataSource.Add("服务器程序未运行");
// Thread.Sleep(2);
// StartProcess(sc.proServer);
// Thread.Sleep(20);
// ReciveDataSource.Add("服务器程序重启成功");
// string logStr = DateTime.Now.ToString("s") + "\t服务器程序" + sc.proServer.ProName + "重启";
// WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
//}
//sfp = FindProcess(sc.proRecv);
//if (sfp == 0)
//{
// ReciveDataSource.Add("接收数据程序运行正常");
//}
//else
//{
// ReciveDataSource.Add("接收数据程序未运行");
// Thread.Sleep(2);
// StartProcess(sc.proRecv);
// Thread.Sleep(20);
// ReciveDataSource.Add("接收数据程序重启成功");
// string logStr = DateTime.Now.ToString("s") + "\t接收数据程序" + sc.proRecv.ProName + "重启";
// WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
//}
//sfp = FindProcess(sc.proApms);
//if (sfp == 0)
//{
// ReciveDataSource.Add("自动识别程序运行正常");
//}
//else
//{
// ReciveDataSource.Add("自动识别程序未运行");
// Thread.Sleep(2);
// StartProcess(sc.proApms);
// Thread.Sleep(20);
// ReciveDataSource.Add("自动识别程序重启成功");
// string logStr = DateTime.Now.ToString("s") + "\t自动识别程序" + sc.proApms.ProName + "重启";
// WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
//}
//sfp = FindProcess(sc.proMonitor);
//if (sfp == 0)
//{
// ReciveDataSource.Add("网页服务程序运行正常");
//}
//else
//{
// ReciveDataSource.Add("网页服务程序未运行");
// Thread.Sleep(2);
// StartProcess(sc.proMonitor);
// Thread.Sleep(20);
// ReciveDataSource.Add("网页服务程序重启成功");
// string logStr = DateTime.Now.ToString("s") + "\t网页服务程序" + sc.proMonitor.ProName + "重启";
// WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
//}
#endregion
RunTime = DateDiff(DateTime.Now, StartTime);
vpnStatus = vpn.CheckVpnStatus(sc.vpnInfo.VpnName);
if (!vpnStatus)
@ -657,6 +760,21 @@ namespace StartServerWPF.Modules.Main.ViewModels
Thread.Sleep(1000);
string logStr = DateTime.Now.ToString("s") + "\tVPN断开重连";
WriteSerLog(sc.vpnInfo.SystemLogPath + JsonParser.systemLogFileName, logStr);
string jsonStr = JsonSerializer.Serialize<CSDeviceWebhook>(new CSDeviceWebhook
{
type = CSMessage.webhook,
message = logStr,
}, new JsonSerializerOptions
{
// 整齐打印
WriteIndented = true,
//重新编码,解决中文乱码问题
Encoder = JavaScriptEncoder.Create(UnicodeRanges.All)
});
_websocket.SendMes(jsonStr);
}
}
public void GetLocalIp()
@ -683,11 +801,6 @@ namespace StartServerWPF.Modules.Main.ViewModels
vpnStatus = vpn.CheckVpnStatus(sc.vpnInfo.VpnName);
if (vpnStatus)
{
//gbServerControl.Enabled = true;
// buttonConnectVPN.Enabled = false;
// buttonDisconnectVPN.Enabled = true;
// labelVPNstatus.ForeColor = Color.Blue;
VPNIsConnect = true;
VPNStatusForeColor = "#FF008000";
@ -696,11 +809,6 @@ namespace StartServerWPF.Modules.Main.ViewModels
}
else
{
// gbServerControl.Enabled = false;
// buttonConnectVPN.Enabled = true;
// buttonDisconnectVPN.Enabled = false;
// labelVPNstatus.ForeColor = Color.Red;
VPNIsConnect = false;
VPNStatusForeColor = "#FFFF0000";
VPNStatus = "VPN断开连接";

@ -110,12 +110,29 @@
<ProgressBar Grid.Row="4" Grid.ColumnSpan="3" VerticalAlignment="Bottom" IsIndeterminate="{Binding IsIndeterminate}" Foreground="Green" Value="0"/>
</Grid>
</GroupBox>
<DataGrid Grid.Column="1" Grid.RowSpan="2" ItemsSource="{Binding DataGridSource}">
</DataGrid>
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Bottom" IsEnabled="False">
<Grid Grid.Column="1" Grid.RowSpan="3" >
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="10*"/>
</Grid.RowDefinitions>
<UniformGrid Grid.Row="0" >
<RadioButton GroupName="A" Command="{Binding OutputItemsCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self},Path=Content}" Content="apmsProcessSlice" IsChecked="True"/>
<RadioButton GroupName="A" Command="{Binding OutputItemsCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self},Path=Content}" Content="apmsEvent"/>
<RadioButton GroupName="A" Command="{Binding OutputItemsCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self},Path=Content}" Content="toolsProcessSlice"/>
<RadioButton GroupName="A" Command="{Binding OutputItemsCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self},Path=Content}" Content="toolsEvent"/>
</UniformGrid>
<ListBox Grid.Row="1" Background="LightGray" ItemsSource="{Binding OutPutItemsSource}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding }" TextWrapping="Wrap"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
<!--<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Bottom" IsEnabled="False">
<Button Content="查询" Command="{Binding QueryDataCommand}"/>
<Button Content="新增" Command="{Binding InsertDataCommand}"/>
</StackPanel>
</StackPanel>-->
<!--<TextBlock Grid.Row="2" Text="Version 2023.05.17" Margin="10,0,0,0"/>-->
</Grid>
</UserControl>

@ -13,22 +13,30 @@ namespace StartServerWPF.Modules.Main
public class WebsocketClient
{
public WebSocket webSocket4Net = null;
public void WebSocketInit()
public void WebSocketInit(string url)
{
Console.WriteLine("客户端");
webSocket4Net = new WebSocket("ws://localhost:5000/ws");
webSocket4Net = new WebSocket(url);
webSocket4Net.Opened += WebSocket4Net_Opened;
webSocket4Net.Error += new EventHandler<ErrorEventArgs>(WebSocket_Error);
webSocket4Net.MessageReceived += WebSocket4Net_MessageReceived;
webSocket4Net.Open();
Console.WriteLine("客户端连接成功!");
Thread thread = new Thread(ClientSendMsgToServer);
Thread thread = new Thread(ClientSendHeartbeat);
thread.IsBackground = true;
thread.Start();
// webSocket4Net.Dispose();
}
public void SendMes(string str)
{
if (webSocket4Net.State == WebSocketState.Open)
{
webSocket4Net.Send(str);
}
}
public void ClientSendMsgToServer()
private void ClientSendHeartbeat()
{
int i = 88;
while (true)

@ -1,19 +1,20 @@
{
"remoteDb":{
"ServerAddress": "txgydatabase.mysql.rds.aliyuncs.com",
"ServerPort": "3306",
"UserName": "tayrds_db",
"Password": "txgy1929",
"DataBase": "txgymeisdb",
"TableName": "event"
},
"remoteDb": {
"ServerAddress": "txgydatabase.mysql.rds.aliyuncs.com",
"ServerPort": "3306",
"UserName": "tayrds_db",
"Password": "txgy1929",
"DataBase": "txgymeisdb",
"TableName": "event",
"WebsocketUrl": "ws://43.138.12.228/ws"
},
"vpnInfo": {
"VpnName": "YUWU-VPN-BySM",
"VpnIP": "49.232.209.49",
"VpnUserName": "lzvpn",
"VpnPsw": "Lz123456789",
"SystemLogPath": "Systemlog\\",
"DataSavePath": "G:\\DATA\\"
"DataSavePath": "I:\\DATA\\"
},
"proServer": {
"ProName": "server",
@ -51,13 +52,22 @@
"OperationStr": "open",
"ShowState": 0
},
"proPlot": {
"ProName": "gw.plot",
"ProPath": "serverprogram\\plot\\",
"ProParams": null,
"proTools": {
"ProName": "gw.tools",
"ProPath": "serverprogram\\tools\\",
"ProParams": "-cfg apms.json -savepath e:\\yuwuN3102mseed -delay 600",
"JsonPath": null,
"Pid": 0,
"OperationStr": "open",
"ShowState": 0
}
//"proPlot": {
// "ProName": "gw.plot",
// "ProPath": "serverprogram\\plot\\",
// "ProParams": null,
// "JsonPath": null,
// "Pid": 0,
// "OperationStr": "open",
// "ShowState": 0
//}
}

@ -4,7 +4,7 @@ namespace StartServerWPF.ViewModels
{
public class MainWindowViewModel : BindableBase
{
private string _title = "Prism Application";
private string _title = "StartServerWPF";
public string Title
{
get { return _title; }

@ -2,8 +2,8 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:prism="http://prismlibrary.com/" ResizeMode="NoResize"
prism:ViewModelLocator.AutoWireViewModel="True"
Title="{Binding Title}" Height="500" Width="800" >
prism:ViewModelLocator.AutoWireViewModel="True" Closing="Window_Closing"
Title="{Binding Title}" Height="500" Width="900" >
<Grid>
<ContentControl prism:RegionManager.RegionName="MainContentRegion" />
</Grid>

@ -1,4 +1,7 @@
using System.Windows;
using Prism.Ioc;
using Prism.Regions;
using StartServerWPF.Modules.Main.ViewModels;
using System.Windows;
namespace StartServerWPF.Views
{
@ -7,9 +10,27 @@ namespace StartServerWPF.Views
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
private readonly IContainerProvider containerProvider;
public MainWindow(IContainerProvider containerProvider)
{
InitializeComponent();
this.containerProvider = containerProvider;
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (MessageBox.Show("是否退出程序?", "warning", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
{
var main= containerProvider.Resolve<MainViewModel>();
main.Unloaded();
}
else
{
e.Cancel = true;
}
}
}
}

@ -1,70 +0,0 @@
{
"station" :"n1105_station_xyz.csv",
"Main.log_level":"DEBUG",
"Main.slice_seconds": 30 ,
"Main.overlap_seconds": 10 ,
"Main.is_mag":"YES",
"Main.is_write_slice":"NO",
"Main.lon":112.8745329,
"Main.lat":36.40473082,
"Main.savepath":"E://Data//ftp",
"RServer.host":"127.0.0.1",
"channels":[
{"network":"HA","station":"N02,N03,N04,N05,N06,N07,N08,N09,N10,N11,N12,N13,N14,N15,N16,N17,N18,N19,N20,N21,N22,N23,N24,N25,N26","location":"06","channels":"SHZ:SHN:SHE"}
],
"Picker.log_level": "DEBUG",
"Picker.use_sma":"YES",
"Picker.minsp": 0.4,
"Picker.mind" :0.6,
"Picker.minss": 0.1,
"Picker.phaed":0.5,
"Picker.channels": [
{
"id": "default",
"lowpass": 10,
"highpass": 50,
"sta": 1,
"lta": 5,
"on": 2.5,
"max": 3,
"off": 1
}
],
"Picker.ismp": "",
"Picker.ttime":[
{"station":"ttime","ttime1y":"2.0,1.18"}
],
"Main.group":"V2",
"Group.log_level": "DEBUG",
"Group.mindelta" :3,
"Group.min_sta_num":3,
"Group.z0" : 0.6,
"Group.et" : 0.1,
"Group.ttime":[
{"station":"ttime","ttime1y":"2.0,1.18"}
],
"Locate.log_level" : "DEBUG",
"Locate.work_path" :".",
"Locate.ttime":[
{"station":"ttime","ttime1y":"2.0,1.18"}
],
"Locate.xmin":-0.3,
"Locate.xmax":0.3,
"Locate.ymin":-0.8,
"Locate.ymax":0.8,
"Locate.zmin":0.4,
"Locate.zmax":0.6,
"Locate.minstep":0.005,
"Locate.method":"",
"Locate.clusted_otime":0.5
}

@ -1,37 +1,41 @@
{
"station": "n1105_station_xyz.csv",
"ttime": [
{
"station": "ttime",
"ttime2d": "ttime_gw20210427.tab"
}
"station" :"N3102_staion_20230403.csv",
"ttime":[{"station":"ttime","ttime2d":"ttime_gw20210427.tab"}],
"Main.log_level":"DEBUG",
"Main.slice_seconds": 20 ,
"Main.overlap_seconds": 5 ,
"Main.is_mag":"YES",
"Main.is_write_slice":"NO",
"Main.lon":38398463.49,
"Main.lat":4031112.103,
"Main.height":1102.63,
"Main.savepath":"I://YuwuN3102Mseed//",
"Main.push2wx":"NO",
"Main.push_url":"https://www.txgy.xyz/api/index/push",
"Main.push_mag":-1.0,
"Main.message_id":1,
"Main.company_id":1,
"Main.area_id":8,
"Main.content":"通知事件",
"Main.push_key":"Y3qYFBQPMbfTt6m",
"RServer.host":"127.0.0.1",
"channels":[
{"network":"HA","station":"N02,N03,N04,N05,N06,N07,N08,N09,N10,N11,N12,N13,N14,N15,N16,N17,N18,N19,N20,N21,N22,N23,N24,N25,N26,N27","location":"06","channels":"SHZ:SHN:SHE"}
],
"Main.log_level": "DEBUG",
"Main.slice_seconds": 30,
"Main.overlap_seconds": 10,
"Main.is_mag": "YES",
"Main.is_write_slice": "NO",
"Main.lon": 112.8745329,
"Main.lat": 36.40473082,
"Main.savepath":"G:\\DATA\\",
"RServer.host": "127.0.0.1",
"channels": [
{
"network": "HA",
"station": "N02,N03,N04,N05,N06,N07,N08,N09,N10,N11,N12,N13,N14,N15,N16,N17,N18,N19,N20,N21,N22,N23,N26,N27",
"location": "06",
"channels": "SHZ:SHN:SHE"
}
],
"Locate.log_level": "DEBUG",
"Locate.work_path": ".",
"Locate.xmin": -0.6,
"Locate.xmax": 0.6,
"Locate.ymin": -1.6,
"Locate.ymax": 1.6,
"Locate.zmin": 0.20,
"Locate.zmax": 0.80,
"Locate.minstep": 0.01,
"Locate.method": "",
"Locate.clusted_otime": 0.5
"Locate.log_level" : "DEBUG",
"Locate.work_path" :".",
"Locate.xmin":38396517,
"Locate.xmax":38398317,
"Locate.ymin":4029418,
"Locate.ymax":4031218,
"Locate.zref":1039,
"Locate.zmin":300,
"Locate.zmax":800,
"Locate.minstep":10,
"Locate.method":"",
"Locate.clusted_otime":0.5
}

@ -1,9 +0,0 @@
[
{
"phases": [
],
"amps": [
]
}
]

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

@ -1,25 +0,0 @@
net,sta,x,y,z,sens
HA,N02,0.094794,0.991668,-0.051,1.00E+08
HA,N03,0.175642,0.672622,-0.002,1.00E+08
HA,N04,-0.29545,0.467104,0.016,1.00E+08
HA,N05,0.034167,0.459918,0.022,1.00E+08
HA,N06,0.341656,0.448421,-0.012,1.00E+08
HA,N07,-0.726609,0.270205,0.037,1.00E+08
HA,N08,-0.543752,0.196426,0.046,1.00E+08
HA,N09,0.329631,0.239064,-0.023,1.00E+08
HA,N10,0.976849,0.155226,-0.022,1.00E+08
HA,N11,0,0,0,1.00E+08
HA,N12,-0.630379,-0.075218,0.005,1.00E+08
HA,N13,-0.374383,-0.158581,0.043,1.00E+08
HA,N14,0.499988,-0.177746,-0.009,1.00E+08
HA,N15,0.825767,-0.132231,-0.01,1.00E+08
HA,N16,-0.026463,-0.415384,0.035,1.00E+08
HA,N17,-0.705466,-0.387117,0.006,1.00E+08
HA,N18,-0.365723,-0.437903,0.042,1.00E+08
HA,N19,0.512986,-0.478628,0.018,1.00E+08
HA,N20,0.669862,-0.403406,0.021,1.00E+08
HA,N21,-0.321459,-0.750294,-0.033,1.00E+08
HA,N22,-0.007697,-0.632427,0.03,1.00E+08
HA,N23,0.437924,-0.637218,0.02,1.00E+08
HA,N26,0.166509,-1.010947,-0.014,1.00E+08
HA,N27,-0.237729,-1.016697,0.007,1.00E+08
1 net sta x y z sens
2 HA N02 0.094794 0.991668 -0.051 1.00E+08
3 HA N03 0.175642 0.672622 -0.002 1.00E+08
4 HA N04 -0.29545 0.467104 0.016 1.00E+08
5 HA N05 0.034167 0.459918 0.022 1.00E+08
6 HA N06 0.341656 0.448421 -0.012 1.00E+08
7 HA N07 -0.726609 0.270205 0.037 1.00E+08
8 HA N08 -0.543752 0.196426 0.046 1.00E+08
9 HA N09 0.329631 0.239064 -0.023 1.00E+08
10 HA N10 0.976849 0.155226 -0.022 1.00E+08
11 HA N11 0 0 0 1.00E+08
12 HA N12 -0.630379 -0.075218 0.005 1.00E+08
13 HA N13 -0.374383 -0.158581 0.043 1.00E+08
14 HA N14 0.499988 -0.177746 -0.009 1.00E+08
15 HA N15 0.825767 -0.132231 -0.01 1.00E+08
16 HA N16 -0.026463 -0.415384 0.035 1.00E+08
17 HA N17 -0.705466 -0.387117 0.006 1.00E+08
18 HA N18 -0.365723 -0.437903 0.042 1.00E+08
19 HA N19 0.512986 -0.478628 0.018 1.00E+08
20 HA N20 0.669862 -0.403406 0.021 1.00E+08
21 HA N21 -0.321459 -0.750294 -0.033 1.00E+08
22 HA N22 -0.007697 -0.632427 0.03 1.00E+08
23 HA N23 0.437924 -0.637218 0.02 1.00E+08
24 HA N26 0.166509 -1.010947 -0.014 1.00E+08
25 HA N27 -0.237729 -1.016697 0.007 1.00E+08

@ -0,0 +1,8 @@
@echo off
set rootdir=%~dp0
cd /d %rootdir%
sc delete gw.apms
nssm install gw.apms %rootdir%\gw.apms.exe confirm
nssm set gw.apms AppDirectory %rootdir%
nssm set gw.apms AppParameters -cfg apms.json
nssm start gw.apms

@ -0,0 +1,3 @@
@echo off
nssm.exe stop gw.apms
nssm.exe remove gw.apms confirm

@ -1,7 +1,8 @@
{
"savepath":"G:\\DATA\\",
"log_level": "DEBUG",
"send2server": "YES",
"stations": "2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,26,27",
"savepath" : "I:\\yuwuN3102mseed\\",
"log_level":"DEBUG",
"send2server":"YES",
"pack_time":12,
"stamseed":"5,10",
"dirstruct": "NDHH"
}

@ -0,0 +1 @@
gw.recvftp.exe -cfg gw.recvftp.json

File diff suppressed because it is too large Load Diff

@ -0,0 +1,39 @@
{
"station" :"N3102_staion_20230403.csv",
"ttime":[{"station":"ttime","ttime2d":"ttime_gw20210427.tab"}],
"Main.log_level":"DEBUG",
"Main.slice_seconds": 30 ,
"Main.overlap_seconds": 10 ,
"Main.is_mag":"YES",
"Main.is_write_slice":"NO",
"Main.lon":38398463.49,
"Main.lat":4031112.103,
"Main.height":1102.63,
"Main.savepath":"I://yuwuN3102mseed//post",
"Main.push2wx":"NO",
"Main.push_url":"http://www.txgy.cloud/api/index/push",
"Main.push_mag":-1.0,
"Main.message_id":1,
"Main.company_id":1,
"Main.area_id":8,
"Main.content":"通知事件",
"Main.push_key":"Y3qYFBQPMbfTt6m",
"RServer.host":"127.0.0.1",
"channels":[
{"network":"HA","station":"N02,N03,N04,N05,N06,N07,N08,N09,N10,N11,N12,N13,N14,N15,N16,N17,N18,N19,N20,N21,N22,N23,N24,N25,N26,N27","location":"06","channels":"SHZ:SHN:SHE"}
],
"Locate.log_level" : "DEBUG",
"Locate.work_path" :".",
"Locate.xmin":38396517,
"Locate.xmax":38398317,
"Locate.ymin":4029418,
"Locate.ymax":4031218,
"Locate.zref":1039,
"Locate.zmin":300,
"Locate.zmax":800,
"Locate.minstep":10,
"Locate.method":"",
"Locate.clusted_otime":0.5
}

@ -0,0 +1 @@
gw.tools.exe -cfg apms.json -savepath e:\yuwuN3102mseed -delay 600
Loading…
Cancel
Save