修改测试问题

master
mzhifa 8 months ago
parent bd35d87b9c
commit 4403cf07c7

@ -15,6 +15,7 @@ namespace StartServerWPF.Models
public string DataBase { get; set; } public string DataBase { get; set; }
public string TableName { get; set; } public string TableName { get; set; }
public string WebsocketUrl { get; set; } public string WebsocketUrl { get; set; }
public bool DingdingIsEnable { get; set; }
public string Account { get; set; } public string Account { get; set; }
public string Pwd { get; set; } public string Pwd { get; set; }

@ -13,7 +13,7 @@ namespace StartServerWPF.Models
{ {
public class WorkareasModelArray public class WorkareasModelArray
{ {
public int selectIndex { get; set; } public int selectIndex { get; set; }=-1;
public List<Workareas> workarea { get; set; } public List<Workareas> workarea { get; set; }
} }
public class Workareas public class Workareas

@ -148,15 +148,19 @@ namespace StartServerWPF.Modules.Main.ViewModels
StartSelectedDate = DateTime.Now; StartSelectedDate = DateTime.Now;
EndSelectedDate = DateTime.Now; EndSelectedDate = DateTime.Now;
WorkareaNameSource = new ObservableCollection<string>(); WorkareaNameSource = new ObservableCollection<string>();
_workareasModelArray.workarea.Select(n => n.workareaname).ToList().ForEach(a => WorkareaNameSource.Add(a));
WareaSelectedIndex = _workareasModelArray.selectIndex;
if ((_workareasModelArray != null)
&& (_workareasModelArray.workarea.Count > 0))
{
WareaSelectedIndex = _workareasModelArray.selectIndex;
_workareasModelArray.workarea.Select(n => n.workareaname).ToList().ForEach(a => WorkareaNameSource.Add(a));
var model = _workareasModelArray.workarea[WareaSelectedIndex]; var model = _workareasModelArray.workarea[WareaSelectedIndex];
string jsonStr= File.ReadAllText(Path.Combine(model.filepath, "datapro.json")); string jsonStr = File.ReadAllText(Path.Combine(model.filepath, "datapro.json"));
var datas= JsonConvert.DeserializeObject<List<DataProModel>>(jsonStr); var datas = JsonConvert.DeserializeObject<List<DataProModel>>(jsonStr);
NameSource = new ObservableCollection<DataProModel>(); NameSource = new ObservableCollection<DataProModel>();
datas.ForEach(d => { NameSource.Add(d); }); datas.ForEach(d => { NameSource.Add(d); });
DataSelectedIndex = 0; DataSelectedIndex = 0;
}
}); });
public DelegateCommand AddItemCommand => new(() => public DelegateCommand AddItemCommand => new(() =>
@ -287,7 +291,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
IsBusy=true; IsBusy=true;
Application.Current.Dispatcher.InvokeAsync(() => Application.Current.Dispatcher.InvokeAsync(() =>
{ {
AddItems(ProcessSliceSource, new ProcessingInformationModel { ProcessMes = "没有需要处理的文件", MonitorTime = DateTime.Now.ToString() }); AddItems(ProcessSliceSource, new ProcessingInformationModel { ProcessMes = $"没有查询到文件,目录:{DataPath}\\MM\\dd\\hh\\mm", MonitorTime = DateTime.Now.ToString() });
}, DispatcherPriority.ApplicationIdle); }, DispatcherPriority.ApplicationIdle);
} }
}); });

@ -36,6 +36,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
_systemConfig = systemConfig; _systemConfig = systemConfig;
ApmsIsEnable = _systemConfig.proApms.IsEnable; ApmsIsEnable = _systemConfig.proApms.IsEnable;
ToolsIsEnable= _systemConfig.proTools.IsEnable; ToolsIsEnable= _systemConfig.proTools.IsEnable;
DingdingIsEnable = _systemConfig.remoteDb.DingdingIsEnable;
InitializeParams(); InitializeParams();
StartTime = DateTime.Now; StartTime = DateTime.Now;
Console.WriteLine(System.Environment.CurrentDirectory); Console.WriteLine(System.Environment.CurrentDirectory);
@ -219,7 +220,16 @@ namespace StartServerWPF.Modules.Main.ViewModels
} }
} }
private bool dingdingIsEnable;
public bool DingdingIsEnable
{
get { return dingdingIsEnable; }
set
{
_systemConfig.remoteDb.DingdingIsEnable = value;
SetProperty(ref dingdingIsEnable, value);
}
}
private ObservableCollection<ProcessModel> _processDataSource =new ObservableCollection<ProcessModel>(); private ObservableCollection<ProcessModel> _processDataSource =new ObservableCollection<ProcessModel>();
public ObservableCollection<ProcessModel> ProcessDataSource public ObservableCollection<ProcessModel> ProcessDataSource
@ -439,6 +449,8 @@ namespace StartServerWPF.Modules.Main.ViewModels
public void OneKeyStop() public void OneKeyStop()
{ {
//保存设置数据
JsonParser.WriteSystemConfigFile(JsonParser.systemConfigPath, _systemConfig);
foreach (var item in _systemConfig.GetType().GetProperties()) foreach (var item in _systemConfig.GetType().GetProperties())
{ {
var pro = item.GetValue(_systemConfig) as ProcessInfo; var pro = item.GetValue(_systemConfig) as ProcessInfo;
@ -607,7 +619,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
var ms = new MsEventModel(outLine.Data) { CurrentTime = DateTime.Now }; var ms = new MsEventModel(outLine.Data) { CurrentTime = DateTime.Now };
AddItems(ApmsEventSource, ms); AddItems(ApmsEventSource, ms);
var data = ApmsEventSource.Where(f => f.OriginTime == ms.OriginTime).FirstOrDefault(); var data = ApmsEventSource.Where(f => f.OriginTime == ms.OriginTime).FirstOrDefault();
if (data == null) if (data != null)
{ {
CSDevicePublish cSDevicePublish = new CSDevicePublish() CSDevicePublish cSDevicePublish = new CSDevicePublish()
{ {
@ -615,9 +627,12 @@ namespace StartServerWPF.Modules.Main.ViewModels
message = outLine.Data, message = outLine.Data,
}; };
string jsonStr = JsonSerializer.Serialize(cSDevicePublish); string jsonStr = JsonSerializer.Serialize(cSDevicePublish);
if (_systemConfig.remoteDb.DingdingIsEnable)
{
_websocket.SendMes(jsonStr); _websocket.SendMes(jsonStr);
} }
} }
}
else if (pro.MainModule.ModuleName.Contains(_systemConfig.proTools.ProName)) else if (pro.MainModule.ModuleName.Contains(_systemConfig.proTools.ProName))
{ {
AddItems(ToolsEventSource, new MsEventModel(outLine.Data) { CurrentTime = DateTime.Now }); AddItems(ToolsEventSource, new MsEventModel(outLine.Data) { CurrentTime = DateTime.Now });
@ -767,10 +782,13 @@ namespace StartServerWPF.Modules.Main.ViewModels
//重新编码,解决中文乱码问题 //重新编码,解决中文乱码问题
Encoder = JavaScriptEncoder.Create(UnicodeRanges.All) Encoder = JavaScriptEncoder.Create(UnicodeRanges.All)
}); });
if (_systemConfig.remoteDb.DingdingIsEnable)
{
_websocket.SendMes(jsonStr); _websocket.SendMes(jsonStr);
} }
} }
} }
}
RunTime = DateDiff(DateTime.Now, StartTime); RunTime = DateDiff(DateTime.Now, StartTime);
vpnStatus = vpn.CheckVpnStatus(_systemConfig.vpnInfo.VpnName); vpnStatus = vpn.CheckVpnStatus(_systemConfig.vpnInfo.VpnName);
if (!vpnStatus) if (!vpnStatus)
@ -798,7 +816,10 @@ namespace StartServerWPF.Modules.Main.ViewModels
//重新编码,解决中文乱码问题 //重新编码,解决中文乱码问题
Encoder = JavaScriptEncoder.Create(UnicodeRanges.All) Encoder = JavaScriptEncoder.Create(UnicodeRanges.All)
}); });
if (_systemConfig.remoteDb.DingdingIsEnable)
{
_websocket.SendMes(jsonStr); _websocket.SendMes(jsonStr);
}
} }
} }

@ -10,6 +10,7 @@ using StartServerWPF.Modules.Main.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics.Metrics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.Serialization; using System.Runtime.Serialization;
@ -33,8 +34,9 @@ namespace StartServerWPF.Modules.Main.ViewModels
wareaModelSingleton = workareaModel; wareaModelSingleton = workareaModel;
this._workareasModelArray = workareasModelArray; this._workareasModelArray = workareasModelArray;
MainModel = _systemConfig.vpnInfo; MainModel = _systemConfig.vpnInfo;
WorkareaNameSource = new ObservableCollection<string>(); WorkareaNameSource = new ObservableCollection<Workareas>();
_workareasModelArray.workarea.Select(n=>n.workareaname).ToList().ForEach(a=> WorkareaNameSource.Add(a));
_workareasModelArray.workarea.ForEach(a => WorkareaNameSource.Add(a));
} }
private string _title = "应用列表"; private string _title = "应用列表";
public string Title => _title; public string Title => _title;
@ -44,8 +46,8 @@ namespace StartServerWPF.Modules.Main.ViewModels
private readonly IDialogService _dialogService; private readonly IDialogService _dialogService;
private SystemConfigModel _systemConfig; private SystemConfigModel _systemConfig;
private WorkareasModelArray _workareasModelArray; private WorkareasModelArray _workareasModelArray;
private ObservableCollection<string> _workareaNameSource; private ObservableCollection<Workareas> _workareaNameSource;
public ObservableCollection<string> WorkareaNameSource public ObservableCollection<Workareas> WorkareaNameSource
{ {
get => _workareaNameSource; get => _workareaNameSource;
set { SetProperty(ref _workareaNameSource, value); } set { SetProperty(ref _workareaNameSource, value); }
@ -75,8 +77,10 @@ namespace StartServerWPF.Modules.Main.ViewModels
WareaModel.savepath = path; WareaModel.savepath = path;
string file = Path.Combine(path, Path.GetFileName(path) + ".json"); string file = Path.Combine(path, Path.GetFileName(path) + ".json");
WareaModel.workareaname = Path.GetFileName(WareaModel.savepath); WareaModel.workareaname = Path.GetFileName(WareaModel.savepath);
if (File.Exists(file))
{
File.WriteAllText(file, JsonConvert.SerializeObject(WareaModel)); File.WriteAllText(file, JsonConvert.SerializeObject(WareaModel));
}
//MessageBox.Show("当前工区目录配置文件不存在," + ex.Message); //MessageBox.Show("当前工区目录配置文件不存在," + ex.Message);
} }
} }
@ -122,12 +126,12 @@ namespace StartServerWPF.Modules.Main.ViewModels
if (result != null && result.Result == ButtonResult.OK) if (result != null && result.Result == ButtonResult.OK)
{ {
var area = result.Parameters.GetValue<Workareas>("param1"); var area = result.Parameters.GetValue<Workareas>("param1");
var file = _workareasModelArray.workarea.Where(f => f.workareaname == area.workareaname).FirstOrDefault(); var file = WorkareaNameSource.Where(f => f.workareaname == area.workareaname).FirstOrDefault();
if (file == null) if (file == null)
{ {
_workareasModelArray.workarea.Add(area); // _workareasModelArray.workarea.Add(area);
WorkareaNameSource.Add(area.workareaname); WorkareaNameSource.Add(area);
WareaSelectedIndex= WorkareaNameSource.Count()-1; WareaSelectedIndex = WorkareaNameSource.Count()-1;
} }
else else
{ {
@ -149,17 +153,17 @@ namespace StartServerWPF.Modules.Main.ViewModels
try try
{ {
string jsonStr = File.ReadAllText(fbd.FileName); string jsonStr = File.ReadAllText(fbd.FileName);
_workareasModelArray = JsonConvert.DeserializeObject<WorkareasModelArray>(jsonStr); var _workareasArray = JsonConvert.DeserializeObject<WorkareasModelArray>(jsonStr);
WorkareaNameSource = new ObservableCollection<string>(); WorkareaNameSource = new ObservableCollection<Workareas>();
_workareasModelArray.workarea.Select(n => n.workareaname).ToList().ForEach(a => WorkareaNameSource.Add(a)); _workareasArray.workarea.ForEach(a => WorkareaNameSource.Add(a));
WareaSelectedIndex = _workareasModelArray.selectIndex; WareaSelectedIndex = _workareasArray.selectIndex;
var item = _workareasModelArray.workarea[_workareasModelArray.selectIndex];
var item = _workareasArray.workarea[_workareasArray.selectIndex];
string areaPath = Path.Combine(item.filepath, Path.GetFileName(item.filepath) + ".json"); string areaPath = Path.Combine(item.filepath, Path.GetFileName(item.filepath) + ".json");
var currentWorkarea = new WorkareaModel();
if (File.Exists(areaPath)) if (File.Exists(areaPath))
{ {
string workarea = File.ReadAllText(areaPath); string workarea = File.ReadAllText(areaPath);
currentWorkarea = JsonConvert.DeserializeObject<WorkareaModel>(workarea); var currentWorkarea = JsonConvert.DeserializeObject<WorkareaModel>(workarea);
if (currentWorkarea.StationConfig.Stations == null) if (currentWorkarea.StationConfig.Stations == null)
{ {
currentWorkarea.StationConfig.Stations = currentWorkarea.CreateStationFromCSV(Path.Combine(JsonParser.workareaPath, currentWorkarea.apmModel.station), currentWorkarea.StationConfig.Location) currentWorkarea.StationConfig.Stations = currentWorkarea.CreateStationFromCSV(Path.Combine(JsonParser.workareaPath, currentWorkarea.apmModel.station), currentWorkarea.StationConfig.Location)
@ -174,7 +178,6 @@ namespace StartServerWPF.Modules.Main.ViewModels
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show("导入工区失败," + ex); MessageBox.Show("导入工区失败," + ex);
} }
} }
@ -185,14 +188,12 @@ namespace StartServerWPF.Modules.Main.ViewModels
if (MessageBox.Show($"删除{WareaModel.workareaname}工区所有文件?", "提示", MessageBoxButton.OKCancel, if (MessageBox.Show($"删除{WareaModel.workareaname}工区所有文件?", "提示", MessageBoxButton.OKCancel,
MessageBoxImage.Exclamation) == MessageBoxResult.OK) MessageBoxImage.Exclamation) == MessageBoxResult.OK)
{ {
if (Directory.Exists(WareaModel.savepath)) var area= WorkareaNameSource.Where(a => a.workareaname == WareaModel.workareaname).FirstOrDefault();
if (area != null)
{ {
Directory.Delete(WareaModel.savepath, true); WorkareaNameSource.Remove(area);
WareaSelectedIndex = 0;
} }
var area= _workareasModelArray.workarea.Where(a => a.workareaname == WareaModel.workareaname).FirstOrDefault();
WorkareaNameSource.Remove(WareaModel.workareaname);
_workareasModelArray.workarea.Remove(area);
WareaSelectedIndex =0;
} }
}); });
@ -255,6 +256,11 @@ namespace StartServerWPF.Modules.Main.ViewModels
get => new DelegateCommand(() => get => new DelegateCommand(() =>
{ {
// 数据校验关键字段不能为空、年龄做数字区间的校验、做UserName的唯一检查自定义特性检查 // 数据校验关键字段不能为空、年龄做数字区间的校验、做UserName的唯一检查自定义特性检查
//if(WareaSelectedIndex == -1)
//{
// MessageBox.Show("工区名称不能为空", "提示", MessageBoxButton.OK);
// return;
//}
if (string.IsNullOrEmpty(WareaModel.savepath) if (string.IsNullOrEmpty(WareaModel.savepath)
|| string.IsNullOrEmpty(WareaModel.apmModel.station) || string.IsNullOrEmpty(WareaModel.apmModel.station)
|| string.IsNullOrEmpty(WareaModel.apmModel.ttime[0].ttime2d)) || string.IsNullOrEmpty(WareaModel.apmModel.ttime[0].ttime2d))
@ -267,6 +273,33 @@ namespace StartServerWPF.Modules.Main.ViewModels
{ {
//1 Workarea配置更新选择的索引 //1 Workarea配置更新选择的索引
_workareasModelArray.selectIndex = WareaSelectedIndex; _workareasModelArray.selectIndex = WareaSelectedIndex;
int count = _workareasModelArray.workarea.Count;
int wIndex = count-1;
while (wIndex < 0)
{
//清除目录保存文件
var item = _workareasModelArray.workarea[wIndex];
var model = WorkareaNameSource.Where(p => p.workareaname == item.workareaname).FirstOrDefault();
if (model == null)
{
_workareasModelArray.workarea.Remove(item);
if (Directory.Exists(item.filepath))
{
Directory.Delete(item.filepath, true);
}
}
wIndex--;
}
if(_workareasModelArray.workarea.Count<= 0)
{
//没有数据直接删除文件;
WareaModel.savepath = string.Empty;
File.Delete(Path.Combine(JsonParser.workareaPath, "Workareas.json"));
return;
}
_workareasModelArray.workarea[WareaSelectedIndex].filepath = WareaModel.savepath;
JsonParser.WriteSystemConfigFile(Path.Combine(JsonParser.workareaPath, "Workareas.json"), _workareasModelArray); JsonParser.WriteSystemConfigFile(Path.Combine(JsonParser.workareaPath, "Workareas.json"), _workareasModelArray);
_wareaModel.apmModel.channels = new List<StationChannelsModel> _wareaModel.apmModel.channels = new List<StationChannelsModel>
{ {
@ -318,7 +351,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
ApmsModel apms = curWorkarea.apmModel; ApmsModel apms = curWorkarea.apmModel;
apms.station = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.station)).Replace("\\", "/"); apms.station = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.station)).Replace("\\", "/");
apms.ttime[0].ttime2d = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.ttime[0].ttime2d)).Replace("\\", "/"); apms.ttime[0].ttime2d = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.ttime[0].ttime2d)).Replace("\\", "/");
apms.savepath = Path.Combine(curWorkarea.savepath, curWorkarea.apmsavepath); apms.savepath = Path.Combine(curWorkarea.savepath, curWorkarea.apmsavepath).Replace("\\", "/"); ;
apms.push2wx = curWorkarea.apmpush2wx ? "YES" : "NO"; apms.push2wx = curWorkarea.apmpush2wx ? "YES" : "NO";
JsonParser.WriteSystemConfigFile(Path.Combine(_systemConfig.proApms.ProPath, "apms.json"), apms); JsonParser.WriteSystemConfigFile(Path.Combine(_systemConfig.proApms.ProPath, "apms.json"), apms);
} }

@ -49,11 +49,11 @@
<UniformGrid Columns="1"> <UniformGrid Columns="1">
<TextBlock Text="实时处理配置" Background="Black" Foreground="White" VerticalAlignment="Center" Height="30" FontSize="18"/> <TextBlock Text="实时处理配置" Background="Black" Foreground="White" VerticalAlignment="Center" Height="30" FontSize="18"/>
<DockPanel VerticalAlignment="Center"> <DockPanel VerticalAlignment="Center">
<TextBlock Text="工程文件:" Width="65" VerticalAlignment="Center"/> <TextBlock Text="工区名称:" Width="65" VerticalAlignment="Center"/>
<Button Content="..." DockPanel.Dock="Right" Visibility="Hidden" /> <Button Content="..." DockPanel.Dock="Right" Visibility="Hidden" />
<ComboBox DockPanel.Dock="Left" ItemsSource="{Binding WorkareaNameSource}" SelectedIndex="{Binding WareaSelectedIndex}"/> <ComboBox x:Name="cBoxWorkarea" DockPanel.Dock="Left" ItemsSource="{Binding WorkareaNameSource}" SelectedIndex="{Binding WareaSelectedIndex}"/>
</DockPanel> </DockPanel>
<DockPanel VerticalAlignment="Center"> <DockPanel VerticalAlignment="Center" IsEnabled="{Binding ElementName=cBoxWorkarea,Converter={StaticResource Object2BooleanReConverter}}">
<TextBlock Text="配置名称:" Width="65" VerticalAlignment="Center"/> <TextBlock Text="配置名称:" Width="65" VerticalAlignment="Center"/>
<Button Content="删除" Background="#FFA6783E" Foreground="White" DockPanel.Dock="Right" Command="{Binding DeleteCommand}"/> <Button Content="删除" Background="#FFA6783E" Foreground="White" DockPanel.Dock="Right" Command="{Binding DeleteCommand}"/>
<Button Content="添加" Background="#FF0ABEFF" Foreground="White" DockPanel.Dock="Right" Command="{Binding AddItemCommand}"/> <Button Content="添加" Background="#FF0ABEFF" Foreground="White" DockPanel.Dock="Right" Command="{Binding AddItemCommand}"/>
@ -66,7 +66,7 @@
Text="{Binding DataPath}" Text="{Binding DataPath}"
IsReadOnly="True" /> IsReadOnly="True" />
</DockPanel> </DockPanel>
<TextBlock Text="选择工程目录G:\n2107\" <TextBlock Text="选择工程目录:[\MM\dd\hh\mm]G:\n2107\"
Margin="65,0,0,5" Margin="65,0,0,5"
Foreground="LightGray" Foreground="LightGray"
VerticalAlignment="Center" VerticalAlignment="Center"
@ -109,8 +109,8 @@
</ListBox.ItemTemplate> </ListBox.ItemTemplate>
</ListBox> </ListBox>
</Border> </Border>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center"> <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" >
<Button Content="保存" Background="#FF0ABEFF" Foreground="White" Command="{Binding SaveCommand}" VerticalAlignment="Bottom" Margin="0,0,30,0"/> <Button Content="保存" Background="#FF0ABEFF" Foreground="White" Command="{Binding SaveCommand}" IsEnabled="{Binding ElementName=cBoxWorkarea,Converter={StaticResource Object2BooleanReConverter}}" VerticalAlignment="Bottom" Margin="0,0,30,0"/>
<Button Content="开始" Background="#FF0ABEFF" Foreground="White" Command="{Binding StartCommand}" VerticalAlignment="Bottom" IsEnabled="{Binding IsBusy}"/> <Button Content="开始" Background="#FF0ABEFF" Foreground="White" Command="{Binding StartCommand}" VerticalAlignment="Bottom" IsEnabled="{Binding IsBusy}"/>
<hc:LoadingCircle Height="30" Visibility="{Binding IsBusy, Converter={StaticResource Boolean2VisibilityReConverter}}"/> <hc:LoadingCircle Height="30" Visibility="{Binding IsBusy, Converter={StaticResource Boolean2VisibilityReConverter}}"/>
</StackPanel> </StackPanel>

@ -120,6 +120,7 @@
<UniformGrid Rows="1" IsEnabled="{Binding ElementName=cBoxService, Path=IsChecked, Converter={StaticResource Boolean2BooleanReConverter}}"> <UniformGrid Rows="1" IsEnabled="{Binding ElementName=cBoxService, Path=IsChecked, Converter={StaticResource Boolean2BooleanReConverter}}">
<CheckBox Content="数据处理" IsChecked="{Binding ApmsIsEnable}" Style="{StaticResource ToggleButtonSwitch}" Width="100"/> <CheckBox Content="数据处理" IsChecked="{Binding ApmsIsEnable}" Style="{StaticResource ToggleButtonSwitch}" Width="100"/>
<CheckBox Content="后处理" IsChecked="{Binding ToolsIsEnable}" Style="{StaticResource ToggleButtonSwitch}" Width="100"/> <CheckBox Content="后处理" IsChecked="{Binding ToolsIsEnable}" Style="{StaticResource ToggleButtonSwitch}" Width="100"/>
<CheckBox Content="发送钉钉" IsChecked="{Binding DingdingIsEnable}" Style="{StaticResource ToggleButtonSwitch}" Width="100"/>
</UniformGrid> </UniformGrid>
</StackPanel> </StackPanel>
</Border> </Border>

@ -51,8 +51,8 @@
<TextBlock Text="实时处理配置" Background="Black" Foreground="White" VerticalAlignment="Top" Height="30" FontSize="18"/> <TextBlock Text="实时处理配置" Background="Black" Foreground="White" VerticalAlignment="Top" Height="30" FontSize="18"/>
<DockPanel VerticalAlignment="Center"> <DockPanel VerticalAlignment="Center">
<TextBlock Text="工区名称:" Width="65" VerticalAlignment="Center"/> <TextBlock Text="工区名称:" Width="65" VerticalAlignment="Center"/>
<Button Content="删除" Background="#FFA6783E" Foreground="White" Command="{Binding DeleteItemCommand}" DockPanel.Dock="Right"/> <Button Content="删除" Background="#FFA6783E" Foreground="White" IsEnabled="{Binding ElementName=cBoxWorkarea,Path=SelectedValue, Converter={StaticResource Object2BooleanConverter}}" Command="{Binding DeleteItemCommand}" DockPanel.Dock="Right"/>
<ComboBox ItemsSource="{Binding WorkareaNameSource}" SelectedIndex="{Binding WareaSelectedIndex}" DockPanel.Dock="Right"/> <ComboBox x:Name="cBoxWorkarea" ItemsSource="{Binding WorkareaNameSource}" DisplayMemberPath="workareaname" SelectedIndex="{Binding WareaSelectedIndex}" DockPanel.Dock="Right"/>
</DockPanel> </DockPanel>
<DockPanel VerticalAlignment="Center"> <DockPanel VerticalAlignment="Center">
<TextBlock Text="工区路径:" Width="65" VerticalAlignment="Center"/> <TextBlock Text="工区路径:" Width="65" VerticalAlignment="Center"/>
@ -79,7 +79,6 @@
<TextBlock Text="实时微信通知:" Width="90" VerticalAlignment="Center"/> <TextBlock Text="实时微信通知:" Width="90" VerticalAlignment="Center"/>
<CheckBox IsChecked="{Binding WareaModel.apmpush2wx}"/> <CheckBox IsChecked="{Binding WareaModel.apmpush2wx}"/>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"> <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="后处理路径:" Width="65" VerticalAlignment="Center"/> <TextBlock Text="后处理路径:" Width="65" VerticalAlignment="Center"/>
<TextBox DockPanel.Dock="Left" Width="100" Text="{Binding WareaModel.toolsavepath}"/> <TextBox DockPanel.Dock="Left" Width="100" Text="{Binding WareaModel.toolsavepath}"/>
@ -203,7 +202,7 @@
<StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Center" Grid.Row="3" Grid.Column="2" Margin="0,0,0,30"> <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Center" Grid.Row="3" Grid.Column="2" Margin="0,0,0,30">
<Button Content="添加工区" Width="80" Height="30" Background="#FF0ABEFF" Foreground="White" Command="{Binding AddItemCommand}"/> <Button Content="添加工区" Width="80" Height="30" Background="#FF0ABEFF" Foreground="White" Command="{Binding AddItemCommand}"/>
<Button Content="导入工区" Width="80" Height="30" Background="#FF0ABEFF" Foreground="White" Command="{Binding ImportCommand}" Margin="20,0,20,0"/> <Button Content="导入工区" Width="80" Height="30" Background="#FF0ABEFF" Foreground="White" Command="{Binding ImportCommand}" Margin="20,0,20,0"/>
<Button Content="保存" Width="80" Height="30" Background="#FF0ABEFF" Foreground="White" Command="{Binding ConfirmCommand}"/> <Button Content="保存" Width="80" Height="30" Background="#FF0ABEFF" Foreground="White" Command="{Binding ConfirmCommand}" IsEnabled="{Binding ElementName=cBoxWorkarea,Path=SelectedValue, Converter={StaticResource Object2BooleanConverter}}"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</Border> </Border>

@ -64,8 +64,15 @@ namespace StartServerWPF.Modules.Main
webSocket4Net.Send("{\"type\":\"heartbeat\",\"utype\":\"device\"}"); webSocket4Net.Send("{\"type\":\"heartbeat\",\"utype\":\"device\"}");
} }
else if (webSocket4Net.State == WebSocketState.Closed) else if (webSocket4Net.State == WebSocketState.Closed)
{
try
{ {
webSocket4Net.Open(); webSocket4Net.Open();
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
Thread.Sleep(TimeSpan.FromSeconds(10)); Thread.Sleep(TimeSpan.FromSeconds(10));
} }
Thread.Sleep(TimeSpan.FromSeconds(5)); Thread.Sleep(TimeSpan.FromSeconds(5));

@ -45,6 +45,7 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
GC.KeepAlive(loopCallback); GC.KeepAlive(loopCallback);
workarea= workareaModel; workarea= workareaModel;
_wavesModel = new WavesModel(); _wavesModel = new WavesModel();
CreateChart();
if (workarea.StationConfig.Stations != null) if (workarea.StationConfig.Stations != null)
{ {
List<string> devicesNums = new List<string>(); List<string> devicesNums = new List<string>();
@ -58,7 +59,6 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
devicesNums.Sort(); devicesNums.Sort();
smList = _wavesModel.ReadWavesFromJson(devicesNums.ToArray()); smList = _wavesModel.ReadWavesFromJson(devicesNums.ToArray());
subNameList = new Dictionary<string, ASCiiData>(); subNameList = new Dictionary<string, ASCiiData>();
CreateChart();
StartChart(); StartChart();
Sure(); Sure();
} }
@ -310,8 +310,10 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
private void StationSelect() private void StationSelect()
{ {
DialogParameters param = new DialogParameters(); DialogParameters param = new DialogParameters
param.Add("station", workarea.StationConfig.Stations);// 编辑 {
{ "station", workarea.StationConfig.Stations }
};
_dialogService.ShowDialog("ChartStationDialog" _dialogService.ShowDialog("ChartStationDialog"
, param, ((result)=> , param, ((result)=>
{ {
@ -514,6 +516,7 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
} }
private void RealTimeData(object isCheck) private void RealTimeData(object isCheck)
{ {
if (smList.Count <=0) return;
_channelCount = smList.Count * 3; _channelCount = smList.Count * 3;
CurrentTime = smList.First().BeginTime.ToShortDateString(); CurrentTime = smList.First().BeginTime.ToShortDateString();
StationsName = smList.Select(a => new StationAxis { Name = a.Name, IsChecked = true, SelectCommand = new DelegateCommand<object>(StationsNameVisible) }).ToList(); StationsName = smList.Select(a => new StationAxis { Name = a.Name, IsChecked = true, SelectCommand = new DelegateCommand<object>(StationsNameVisible) }).ToList();

@ -365,6 +365,10 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
} }
Stopwatch st = new Stopwatch(); Stopwatch st = new Stopwatch();
st.Start(); st.Start();
//清除容器数据
while (smList.TryDequeue(out StationModel stationModel))
{
}
//读取.json文件 //读取.json文件
CurrentEventTime = _wavesModel.ReadChartJsonFile(JsonPath); CurrentEventTime = _wavesModel.ReadChartJsonFile(JsonPath);
//读取.mseed文件 //读取.mseed文件
@ -739,9 +743,12 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
LChartALL.BeginUpdate(); LChartALL.BeginUpdate();
for (int channelIndex = 0; channelIndex < _channelCount; channelIndex++) for (int channelIndex = 0; channelIndex < _channelCount; channelIndex++)
{ {
//对齐起始时间x轴
var d = _lChartAll.ViewXY.XAxes[0].DateTimeToAxisValue(smList.ElementAt(channelIndex/3).BeginTime);
_lChartAll.ViewXY.SampleDataSeries[channelIndex].FirstSampleTimeStamp = d;
double[] thisSeriesData = _data[channelIndex]; double[] thisSeriesData = _data[channelIndex];
_lChartAll.ViewXY.YAxes[channelIndex].SetRange(thisSeriesData.Min() - 1, thisSeriesData.Max() + 1); _lChartAll.ViewXY.YAxes[channelIndex].SetRange(thisSeriesData.Min() - 1, thisSeriesData.Max() + 1);
LChartALL.ViewXY.SampleDataSeries[channelIndex].AddSamples(_data[channelIndex], true); LChartALL.ViewXY.SampleDataSeries[channelIndex].AddSamples(_data[channelIndex], true);
} }
LChartALL.EndUpdate(); LChartALL.EndUpdate();

@ -49,8 +49,11 @@ namespace StartServerWPF.Modules.MseedChart.ViewModels
// _title = "编辑" + _title; // _title = "编辑" + _title;
var stations = parameters.GetValue<List<StationState>>("station"); var stations = parameters.GetValue<List<StationState>>("station");
StationsSource = new ObservableCollection<StationState>(); StationsSource = new ObservableCollection<StationState>();
if (stations != null)
{
stations.ForEach(s => { StationsSource.Add(s); }); stations.ForEach(s => { StationsSource.Add(s); });
} }
}
private VpnInfo _mainModel = new VpnInfo(); private VpnInfo _mainModel = new VpnInfo();
public VpnInfo MainModel public VpnInfo MainModel

@ -29,7 +29,7 @@ namespace StartServerWPF
{ {
System.AppDomain.CurrentDomain.UnhandledException += new System.UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); System.AppDomain.CurrentDomain.UnhandledException += new System.UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
AddSecurity(@"C:\ProgramData\Microsoft\Network\Connections"); // AddSecurity(@"C:\ProgramData\Microsoft\Network\Connections");
} }
/// <summary> /// <summary>
@ -66,28 +66,24 @@ namespace StartServerWPF
SystemConfigModel sc = JsonConvert.DeserializeObject<SystemConfigModel>(str); SystemConfigModel sc = JsonConvert.DeserializeObject<SystemConfigModel>(str);
containerRegistry.RegisterSingleton<SystemConfigModel>(() => sc); containerRegistry.RegisterSingleton<SystemConfigModel>(() => sc);
string st = File.ReadAllText(Path.Combine(JsonParser.workareaPath, "Workareas.json")); WorkareasModelArray wm = new WorkareasModelArray();
var wm = JsonConvert.DeserializeObject<WorkareasModelArray>(st); wm.workarea = new List<Workareas>();
var item = wm.workarea[wm.selectIndex]; string wreasPath = Path.Combine(JsonParser.workareaPath, "Workareas.json");
string areaPath = Path.Combine(item.filepath, Path.GetFileName(item.filepath)+".json"); string areaPath = Path.Combine(JsonParser.workareaPath, "Workarea.json");
var currentWorkarea =new WorkareaModel(); if (File.Exists(wreasPath))
if (File.Exists(areaPath))
{ {
string st = File.ReadAllText(wreasPath);
wm = JsonConvert.DeserializeObject<WorkareasModelArray>(st);
var item = wm.workarea[wm.selectIndex];
areaPath = Path.Combine(item.filepath, item.workareaname + ".json");
}
string workarea = File.ReadAllText(areaPath); string workarea = File.ReadAllText(areaPath);
currentWorkarea = JsonConvert.DeserializeObject<WorkareaModel>(workarea); var currentWorkarea = JsonConvert.DeserializeObject<WorkareaModel>(workarea);
if (currentWorkarea.StationConfig.Stations == null) if (currentWorkarea.StationConfig.Stations == null)
{ {
currentWorkarea.StationConfig.Stations = currentWorkarea.CreateStationFromCSV(Path.Combine(JsonParser.workareaPath, currentWorkarea.apmModel.station), currentWorkarea.StationConfig.Location) currentWorkarea.StationConfig.Stations = currentWorkarea.CreateStationFromCSV(Path.Combine(JsonParser.workareaPath, currentWorkarea.apmModel.station), currentWorkarea.StationConfig.Location)
?.Select(a => new StationState { IsEnable = a.Enable, Name = a.Num }).ToList(); ?.Select(a => new StationState { IsEnable = a.Enable, Name = a.Num }).ToList();
} }
}
else
{
//加载默认配置数据
string workarea = File.ReadAllText(Path.Combine(JsonParser.workareaPath, "Workarea.json"));
currentWorkarea = JsonConvert.DeserializeObject<WorkareaModel>(workarea);
}
containerRegistry.RegisterSingleton<WorkareasModelArray>(() => wm); containerRegistry.RegisterSingleton<WorkareasModelArray>(() => wm);
containerRegistry.RegisterSingleton<WorkareaModel>(() => currentWorkarea); containerRegistry.RegisterSingleton<WorkareaModel>(() => currentWorkarea);
} }

@ -7,6 +7,7 @@
"DataBase": "txgymeisdb", "DataBase": "txgymeisdb",
"TableName": "event", "TableName": "event",
"WebsocketUrl": "ws://43.138.12.228/ws", "WebsocketUrl": "ws://43.138.12.228/ws",
"DingdingIsEnable": true,
"Account": "upclient", "Account": "upclient",
"Pwd": "zgbj0010" "Pwd": "zgbj0010"
}, },

@ -20,13 +20,11 @@ namespace StartServerWPF.ViewModels
get { return _title; } get { return _title; }
set { SetProperty(ref _title, value); } set { SetProperty(ref _title, value); }
} }
public DelegateCommand ExitCommand => new(() => public DelegateCommand ExitCommand => new DelegateCommand(() =>
{ {
if (MessageBox.Show("是否退出程序?", "警告", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) this.Title = "close";
{ //关闭主窗口;
Application.Current.MainWindow.Close();
Exit();
}
}); });
public void Exit() public void Exit()
{ {
@ -41,7 +39,7 @@ namespace StartServerWPF.ViewModels
LogHelper.WriteSerLog(_containerProvider.Resolve<SystemConfigModel>().vpnInfo.SystemLogPath, log.ToString()); LogHelper.WriteSerLog(_containerProvider.Resolve<SystemConfigModel>().vpnInfo.SystemLogPath, log.ToString());
main.OneKeyStop(); main.OneKeyStop();
Application.Current.Shutdown(); Environment.Exit(0);
} }
@ -49,8 +47,5 @@ namespace StartServerWPF.ViewModels
{ {
this._containerProvider = containerProvider; this._containerProvider = containerProvider;
} }
} }
} }

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

@ -1,5 +1,5 @@
{ {
"workareaname": "n2000", "workareaname": "default",
"savepath": "", "savepath": "",
"chartsavepath": "WavesData", "chartsavepath": "WavesData",
"apmsavepath": "Realtime", "apmsavepath": "Realtime",

Loading…
Cancel
Save