修改数据处理问题

master
mzhifa 1 year ago
parent 6d6e518909
commit d90ff5b8bd

@ -0,0 +1,34 @@
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StartServerWPF.Models
{
public class DataProModelArray
{
public int selectIndex { get; set; }
public List<DataProModel> dataProModels { get; set; }
}
public class DataProModel: BindableBase
{
private string name;
private string dataPath;
private string resultPath;
private string startTime;
private string endTime;
public string Name { get => name; set => SetProperty(ref name, value); }
public string DataPath { get => dataPath; set => SetProperty(ref dataPath, value); }
public string ResultPath { get => resultPath; set => SetProperty(ref resultPath, value); }
public string StartTime { get => startTime; set => SetProperty(ref startTime, value); }
public string EndTime { get => endTime; set => SetProperty(ref endTime, value); }
}
}

@ -55,6 +55,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="ApmsModel.cs" /> <Compile Include="ApmsModel.cs" />
<Compile Include="DataProModelArray.cs" />
<Compile Include="JsonParser.cs" /> <Compile Include="JsonParser.cs" />
<Compile Include="ProcessInfo.cs" /> <Compile Include="ProcessInfo.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />

@ -91,7 +91,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
workareaModel.savepath = WorkAreaPath; workareaModel.savepath = WorkAreaPath;
workareaModel.workareaname = WorkAreaName; workareaModel.workareaname = WorkAreaName;
//生成工区默认配置文件 //生成工区默认配置文件
File.WriteAllText(Path.Combine(WorkAreaPath, Path.GetFileName(WorkAreaPath) + ".json"), JsonConvert.SerializeObject(workareaModel)); File.WriteAllText(Path.Combine(WorkAreaPath, Path.GetFileName(WorkAreaPath) + ".json"), JsonConvert.SerializeObject(workareaModel, Formatting.Indented));
dialog.Parameters.Add("param1", workareas); dialog.Parameters.Add("param1", workareas);
RequestClose?.Invoke( dialog); RequestClose?.Invoke( dialog);
} }

@ -9,6 +9,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing.Drawing2D;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -114,6 +115,33 @@ namespace StartServerWPF.Modules.Main.ViewModels
WareaSelectedIndex = _workareasModelArray.selectIndex; WareaSelectedIndex = _workareasModelArray.selectIndex;
}); });
public DelegateCommand SaveCommand => new(() =>
{
DataProModelArray dataProModelArray = new DataProModelArray();
dataProModelArray.selectIndex = 0;
dataProModelArray.dataProModels = new List<DataProModel>();
dataProModelArray.dataProModels.Add(new DataProModel
{
Name = DateTime.Now.ToString("d"),
DataPath = DataPath,
ResultPath = SavePath,
StartTime = DateTime.Now.ToString("G"),
EndTime = DateTime.Now.ToString("G")
});
string jsonStr = JsonConvert.SerializeObject(dataProModelArray, Formatting.Indented);
var model = _workareasModelArray.workarea[WareaSelectedIndex];
File.WriteAllText(Path.Combine( model.filepath, "datapro.json"), jsonStr);
});
public DelegateCommand DeleteCommand => new(() =>
{
});
public DelegateCommand<object> SelectFileCommand => new((obj) => public DelegateCommand<object> SelectFileCommand => new((obj) =>
{ {

@ -42,7 +42,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
string apmttime2dFile = string.Empty; string apmttime2dFile = string.Empty;
private readonly IDialogService _dialogService; private readonly IDialogService _dialogService;
private SystemConfigModel _systemConfig; private SystemConfigModel _systemConfig;
private readonly WorkareasModelArray _workareasModelArray; private WorkareasModelArray _workareasModelArray;
private ObservableCollection<string> _workareaNameSource; private ObservableCollection<string> _workareaNameSource;
public ObservableCollection<string> WorkareaNameSource public ObservableCollection<string> WorkareaNameSource
{ {
@ -60,13 +60,23 @@ namespace StartServerWPF.Modules.Main.ViewModels
try try
{ {
var area = _workareasModelArray.workarea[value]; var area = _workareasModelArray.workarea[value];
WareaModel.savepath = area.filepath;
string file = Path.Combine(area.filepath, Path.GetFileName(area.filepath) + ".json"); string file = Path.Combine(area.filepath, Path.GetFileName(area.filepath) + ".json");
string json = File.ReadAllText(file); string json = File.ReadAllText(file);
WareaModel = JsonConvert.DeserializeObject<WorkareaModel>(json); WareaModel = JsonConvert.DeserializeObject<WorkareaModel>(json);
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show("当前工区目录配置文件不存在," + ex.Message); //生成工区默认配置文件
string str = File.ReadAllText(Path.Combine(JsonParser.workareaPath, "Workarea.json"));
string path = WareaModel.savepath;
WareaModel = JsonConvert.DeserializeObject<WorkareaModel>(str);
WareaModel.savepath = path;
string file = Path.Combine(path, Path.GetFileName(path) + ".json");
WareaModel.workareaname = Path.GetFileName(WareaModel.savepath);
File.WriteAllText(file, JsonConvert.SerializeObject(WareaModel));
//MessageBox.Show("当前工区目录配置文件不存在," + ex.Message);
} }
_workareasModelArray.selectIndex = value; _workareasModelArray.selectIndex = value;
} }
@ -97,12 +107,10 @@ namespace StartServerWPF.Modules.Main.ViewModels
{ {
apmStationFile = string.Empty; apmStationFile = string.Empty;
apmttime2dFile = string.Empty; apmttime2dFile = string.Empty;
// WareaModel.apmModel = ;
}); });
public DelegateCommand AddItemCommand => new(() => public DelegateCommand AddItemCommand => new(() =>
{ {
DialogParameters param = new DialogParameters(); DialogParameters param = new DialogParameters();
// param.Add("type", 1);// 编辑 // param.Add("type", 1);// 编辑
_dialogService.ShowDialog("AddWorkAreaDialog", _dialogService.ShowDialog("AddWorkAreaDialog",
@ -129,6 +137,47 @@ namespace StartServerWPF.Modules.Main.ViewModels
})); }));
}); });
public DelegateCommand ImportCommand => new(() =>
{
System.Windows.Forms.OpenFileDialog fbd = new System.Windows.Forms.OpenFileDialog();
fbd.Multiselect = false;
fbd.Filter = ".json|*.json|.txt|*.txt";
if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
try
{
string jsonStr = File.ReadAllText(fbd.FileName);
_workareasModelArray = JsonConvert.DeserializeObject<WorkareasModelArray>(jsonStr);
WorkareaNameSource = new ObservableCollection<string>();
_workareasModelArray.workarea.Select(n => n.workareaname).ToList().ForEach(a => WorkareaNameSource.Add(a));
WareaSelectedIndex = _workareasModelArray.selectIndex;
var item = _workareasModelArray.workarea[_workareasModelArray.selectIndex];
string areaPath = Path.Combine(item.filepath, Path.GetFileName(item.filepath) + ".json");
var currentWorkarea = new WorkareaModel();
if (File.Exists(areaPath))
{
string workarea = File.ReadAllText(areaPath);
currentWorkarea = JsonConvert.DeserializeObject<WorkareaModel>(workarea);
if (currentWorkarea.StationConfig.Stations == null)
{
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();
}
WareaModel = currentWorkarea;
}
else
{
MessageBox.Show("工区配置文件不存在!");
}
}
catch (Exception ex)
{
MessageBox.Show("导入工区失败," + ex);
}
}
});
public DelegateCommand DeleteItemCommand => new(() => public DelegateCommand DeleteItemCommand => new(() =>
{ {
if (MessageBox.Show($"删除{WareaModel.workareaname}工区所有文件?", "提示", MessageBoxButton.OKCancel, if (MessageBox.Show($"删除{WareaModel.workareaname}工区所有文件?", "提示", MessageBoxButton.OKCancel,
@ -144,6 +193,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
WareaSelectedIndex =0; WareaSelectedIndex =0;
} }
}); });
public DelegateCommand<object> SelectFileCommand => new((obj) => public DelegateCommand<object> SelectFileCommand => new((obj) =>
{ {
string para = obj.ToString(); string para = obj.ToString();
@ -222,7 +272,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
station = string.Join(",", _wareaModel.StationConfig.Stations.Where(p => p.IsEnable).Select(n => n.Name)) station = string.Join(",", _wareaModel.StationConfig.Stations.Where(p => p.IsEnable).Select(n => n.Name))
} }
}; };
JsonParser.WriteSystemConfigFile(Path.Combine(_wareaModel.savepath, "Workarea.json"), _wareaModel); JsonParser.WriteSystemConfigFile(Path.Combine(_wareaModel.savepath, Path.GetFileName(_wareaModel.savepath) + ".json"), _wareaModel);
var curWorkarea = JsonParser.DeepCopy<WorkareaModel>(_wareaModel); var curWorkarea = JsonParser.DeepCopy<WorkareaModel>(_wareaModel);
if (!string.IsNullOrEmpty(apmStationFile)) if (!string.IsNullOrEmpty(apmStationFile))
@ -234,7 +284,7 @@ namespace StartServerWPF.Modules.Main.ViewModels
} }
apmStationFile = null; apmStationFile = null;
} }
if(!string.IsNullOrEmpty(apmttime2dFile)) if (!string.IsNullOrEmpty(apmttime2dFile))
{ {
string destFileName = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.ttime[0].ttime2d)); string destFileName = Path.GetFullPath(Path.Combine(curWorkarea.savepath, curWorkarea.apmModel.ttime[0].ttime2d));
if (destFileName != apmttime2dFile) if (destFileName != apmttime2dFile)

@ -50,17 +50,23 @@
<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 DockPanel.Dock="Left" ItemsSource="{Binding WorkareaNameSource}" SelectedIndex="{Binding WareaSelectedIndex}"/>
</DockPanel> </DockPanel>
<DockPanel VerticalAlignment="Center">
<TextBlock Text="配置名称:" Width="65" VerticalAlignment="Center"/>
<Button Content="删除" Background="#FFA6783E" Foreground="White" DockPanel.Dock="Right" Command="{Binding DeleteCommand}"/>
<Button Content="保存" Background="#FF0ABEFF" Foreground="White" DockPanel.Dock="Right" Command="{Binding SaveCommand}"/>
<ComboBox DockPanel.Dock="Left" />
</DockPanel>
<DockPanel VerticalAlignment="Center"> <DockPanel VerticalAlignment="Center">
<TextBlock Text="数据目录:" Width="65" VerticalAlignment="Center"/> <TextBlock Text="数据目录:" Width="65" VerticalAlignment="Center"/>
<Button Content="..." DockPanel.Dock="Right" Command="{Binding SelectFileCommand}" CommandParameter="DataPath" Background="#FF0ABEFF"/> <Button Content="..." Foreground="White" DockPanel.Dock="Right" Command="{Binding SelectFileCommand}" CommandParameter="DataPath" Background="#FF0ABEFF"/>
<TextBox DockPanel.Dock="Left" Text="{Binding DataPath}"/> <TextBox DockPanel.Dock="Left" Text="{Binding DataPath}"/>
</DockPanel> </DockPanel>
<DockPanel VerticalAlignment="Center"> <DockPanel VerticalAlignment="Center">
<TextBlock Text="结果目录:" Width="65" VerticalAlignment="Center"/> <TextBlock Text="结果目录:" Width="65" VerticalAlignment="Center"/>
<Button Content="..." DockPanel.Dock="Right" Command="{Binding SelectFileCommand}" CommandParameter="SavePath" Background="#FF0ABEFF"/> <Button Content="..." Foreground="White" DockPanel.Dock="Right" Command="{Binding SelectFileCommand}" CommandParameter="SavePath" Background="#FF0ABEFF"/>
<TextBox DockPanel.Dock="Left" Text="{Binding SavePath}"/> <TextBox DockPanel.Dock="Left" Text="{Binding SavePath}"/>
</DockPanel> </DockPanel>
<DockPanel VerticalAlignment="Center"> <DockPanel VerticalAlignment="Center">
@ -75,24 +81,28 @@
</Border> </Border>
<Grid Grid.Row="1"> <Grid Grid.Row="1">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition/> <RowDefinition/>
<RowDefinition Height="50"/> <RowDefinition Height="30"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<ListBox ItemsSource="{Binding ProcessSliceSource}" BorderThickness="0"> <TextBlock Text="处理进程"/>
<ListBox.ItemTemplate> <Border Grid.Row="1" BorderBrush="Gray" BorderThickness="1">
<DataTemplate> <ListBox ItemsSource="{Binding ProcessSliceSource}" Margin="5,0,1,1" BorderThickness="0">
<Grid> <ListBox.ItemTemplate>
<Grid.ColumnDefinitions> <DataTemplate>
<ColumnDefinition Width="150"/> <Grid>
<ColumnDefinition/> <Grid.ColumnDefinitions>
</Grid.ColumnDefinitions> <ColumnDefinition Width="150"/>
<TextBlock Text="{Binding MonitorTime}" /> <ColumnDefinition/>
<TextBlock Grid.Column="1" Text="{Binding ProcessMes}" TextWrapping="Wrap" HorizontalAlignment="Center"/> </Grid.ColumnDefinitions>
</Grid> <TextBlock Text="{Binding MonitorTime}" />
</DataTemplate> <TextBlock Grid.Column="1" Text="{Binding ProcessMes}" TextWrapping="Wrap" HorizontalAlignment="Center"/>
</ListBox.ItemTemplate> </Grid>
</ListBox> </DataTemplate>
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center"> </ListBox.ItemTemplate>
</ListBox>
</Border>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button Content="开始" Command="{Binding StartCommand}" VerticalAlignment="Bottom" IsEnabled="{Binding IsBusy}"/> <Button Content="开始" 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>

@ -41,8 +41,8 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition/> <ColumnDefinition/>
<ColumnDefinition Width="auto"/> <ColumnDefinition Width="10"/>
<ColumnDefinition/> <ColumnDefinition />
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Border Grid.Row="0"> <Border Grid.Row="0">
@ -50,7 +50,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"/>
<ComboBox ItemsSource="{Binding WorkareaNameSource}" SelectedIndex="{Binding WareaSelectedIndex}" Margin="0,0,60,0"/> <Button Content="删除" Background="#FFA6783E" Foreground="White" Command="{Binding DeleteItemCommand}" DockPanel.Dock="Right"/>
<ComboBox ItemsSource="{Binding WorkareaNameSource}" 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"/>
@ -72,16 +73,16 @@
<TextBox Width="100" Text="{Binding WareaModel.chartsavepath}"/> <TextBox Width="100" Text="{Binding WareaModel.chartsavepath}"/>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"> <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="实处理路径:" VerticalAlignment="Center"/> <TextBlock Text="实时路径: " VerticalAlignment="Center"/>
<TextBox Width="100" Text="{Binding WareaModel.apmsavepath}"/> <TextBox Width="100" Text="{Binding WareaModel.apmsavepath}"/>
<TextBlock Text="实时微信通知:" 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}"/>
<TextBlock Text="实时微信通知:" VerticalAlignment="Center"/> <TextBlock Text="后得理微信通知:" Width="90" VerticalAlignment="Center"/>
<CheckBox IsChecked="{Binding WareaModel.toolpush2wx}"/> <CheckBox IsChecked="{Binding WareaModel.toolpush2wx}"/>
</StackPanel> </StackPanel>
@ -157,7 +158,7 @@
</GroupBox> </GroupBox>
<Border Grid.Row="0" Grid.Column="2" Margin="20,0,10,0"> <Border Grid.Row="0" Grid.Column="2" Margin="20,0,10,0">
<Grid > <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="1*"/> <RowDefinition Height="1*"/>
<RowDefinition Height="1*"/> <RowDefinition Height="1*"/>
@ -199,9 +200,9 @@
</Popup>--> </Popup>-->
</StackPanel> </StackPanel>
<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="100" 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="100" Height="30" Background="#FF0ABEFF" Foreground="White" Command="{Binding DeleteItemCommand}"/> <Button Content="导入工区" Width="80" Height="30" Background="#FF0ABEFF" Foreground="White" Command="{Binding ImportCommand}" Margin="20,0,20,0"/>
<Button Content="应用" Margin="30,0,0,0" Width="100" Height="30" Background="#FF0ABEFF" Foreground="White" Command="{Binding ConfirmCommand}"/> <Button Content="应用" Width="80" Height="30" Background="#FF0ABEFF" Foreground="White" Command="{Binding ConfirmCommand}"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</Border> </Border>

@ -1,7 +1,7 @@
{ {
"workareaname": "n3103", "workareaname": "n2000",
"savepath": "", "savepath": "",
"chartsavepath": "chartsavepath", "chartsavepath": "WavesData",
"apmsavepath": "Realtime", "apmsavepath": "Realtime",
"toolsavepath": "Post", "toolsavepath": "Post",
"apmpush2wx": false, "apmpush2wx": false,

Loading…
Cancel
Save