Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hemei
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
潘栩锋
hemei
Commits
8348a92a
Commit
8348a92a
authored
May 14, 2020
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化 安装完新程序后,只需要到每个程序的服务器,选择对应的plcgroup, 连客户端界面配置也有列表选择。 不需要再手动复制配置文件
parent
f429e795
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
447 additions
and
24 deletions
+447
-24
FLY.FeedbackRenZiJia.UI.Server.csproj
...kRenZiJia.UI.Server/FLY.FeedbackRenZiJia.UI.Server.csproj
+7
-0
MainWindow.xaml
...ckRenZiJia/FLY.FeedbackRenZiJia.UI.Server/MainWindow.xaml
+6
-2
MainWindow.xaml.cs
...enZiJia/FLY.FeedbackRenZiJia.UI.Server/MainWindow.xaml.cs
+8
-0
WdSetup.xaml
...dbackRenZiJia/FLY.FeedbackRenZiJia.UI.Server/WdSetup.xaml
+18
-0
WdSetup.xaml.cs
...ckRenZiJia/FLY.FeedbackRenZiJia.UI.Server/WdSetup.xaml.cs
+97
-0
FLY.Weight.UI.Server.csproj
...Y.Weight/FLY.Weight.UI.Server/FLY.Weight.UI.Server.csproj
+7
-0
MainWindow.xaml
Project.FLY.Weight/FLY.Weight.UI.Server/MainWindow.xaml
+2
-20
MainWindow.xaml.cs
Project.FLY.Weight/FLY.Weight.UI.Server/MainWindow.xaml.cs
+7
-0
WdSetup.xaml
Project.FLY.Weight/FLY.Weight.UI.Server/WdSetup.xaml
+24
-0
WdSetup.xaml.cs
Project.FLY.Weight/FLY.Weight.UI.Server/WdSetup.xaml.cs
+117
-0
FLY.Winder.UI.Server.csproj
...20190413/FLY.Winder.UI.Server/FLY.Winder.UI.Server.csproj
+7
-0
MainWindow.xaml
....FLY.Winder_20190413/FLY.Winder.UI.Server/MainWindow.xaml
+2
-1
MainWindow.xaml.cs
...Y.Winder_20190413/FLY.Winder.UI.Server/MainWindow.xaml.cs
+7
-0
WdSetup.xaml
...ect.FLY.Winder_20190413/FLY.Winder.UI.Server/WdSetup.xaml
+23
-0
WdSetup.xaml.cs
....FLY.Winder_20190413/FLY.Winder.UI.Server/WdSetup.xaml.cs
+114
-0
thick_public
thick_public
+1
-1
No files found.
Project.FLY.FeedbackRenZiJia/FLY.FeedbackRenZiJia.UI.Server/FLY.FeedbackRenZiJia.UI.Server.csproj
View file @
8348a92a
...
@@ -65,6 +65,9 @@
...
@@ -65,6 +65,9 @@
<Generator>
MSBuild:Compile
</Generator>
<Generator>
MSBuild:Compile
</Generator>
<SubType>
Designer
</SubType>
<SubType>
Designer
</SubType>
</ApplicationDefinition>
</ApplicationDefinition>
<Compile
Include=
"WdSetup.xaml.cs"
>
<DependentUpon>
WdSetup.xaml
</DependentUpon>
</Compile>
<Page
Include=
"MainWindow.xaml"
>
<Page
Include=
"MainWindow.xaml"
>
<Generator>
MSBuild:Compile
</Generator>
<Generator>
MSBuild:Compile
</Generator>
<SubType>
Designer
</SubType>
<SubType>
Designer
</SubType>
...
@@ -77,6 +80,10 @@
...
@@ -77,6 +80,10 @@
<DependentUpon>
MainWindow.xaml
</DependentUpon>
<DependentUpon>
MainWindow.xaml
</DependentUpon>
<SubType>
Code
</SubType>
<SubType>
Code
</SubType>
</Compile>
</Compile>
<Page
Include=
"WdSetup.xaml"
>
<Generator>
MSBuild:Compile
</Generator>
<SubType>
Designer
</SubType>
</Page>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile
Include=
"Properties\AssemblyInfo.cs"
>
<Compile
Include=
"Properties\AssemblyInfo.cs"
>
...
...
Project.FLY.FeedbackRenZiJia/FLY.FeedbackRenZiJia.UI.Server/MainWindow.xaml
View file @
8348a92a
...
@@ -4,7 +4,11 @@
...
@@ -4,7 +4,11 @@
ResizeMode="CanMinimize"
ResizeMode="CanMinimize"
Title="MainWindow" Height="184" Width="268">
Title="MainWindow" Height="184" Width="268">
<Grid>
<Grid>
<TextBlock Height="23" HorizontalAlignment="Left" Margin="80,81,0,0" Name="textBlock1" Text="{Binding CurrRows}" VerticalAlignment="Top" />
<StackPanel>
<Button Content="加载数据" Height="23" HorizontalAlignment="Left" Margin="80,35,0,0" x:Name="button2" VerticalAlignment="Top" Width="118" Click="button2_Click" />
<TextBlock Height="23" HorizontalAlignment="Left" Margin="5" Text="{Binding CurrRows}" VerticalAlignment="Top" />
<Button Content="加载数据" HorizontalAlignment="Left" Padding="20,5" Margin="5" Click="button2_Click" />
<Button Content="配置" Padding="20,5" Margin="5" HorizontalAlignment="Left" Click="btnSetupClick"></Button>
</StackPanel>
</Grid>
</Grid>
</Window>
</Window>
Project.FLY.FeedbackRenZiJia/FLY.FeedbackRenZiJia.UI.Server/MainWindow.xaml.cs
View file @
8348a92a
...
@@ -53,5 +53,13 @@ namespace FLY.FeedbackRenZiJia.UI.Server
...
@@ -53,5 +53,13 @@ namespace FLY.FeedbackRenZiJia.UI.Server
//mGage.mfeedback.mHeatBuf.LoadData(path);
//mGage.mfeedback.mHeatBuf.LoadData(path);
}
}
}
}
private
void
btnSetupClick
(
object
sender
,
RoutedEventArgs
e
)
{
WdSetup
w
=
new
WdSetup
();
w
.
Owner
=
this
;
w
.
Init
(
mGage
.
mfeedback
);
w
.
ShowDialog
();
}
}
}
}
}
Project.FLY.FeedbackRenZiJia/FLY.FeedbackRenZiJia.UI.Server/WdSetup.xaml
0 → 100644
View file @
8348a92a
<Window x:Class="FLY.FeedbackRenZiJia.UI.Server.WdSetup"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="配置" SizeToContent="WidthAndHeight" >
<Grid>
<StackPanel Orientation="Horizontal">
<StackPanel Margin="5">
<TextBlock Text="PLC适配版本" Margin="2"/>
<ComboBox MinWidth="100" Margin="2" x:Name="comboBox" />
</StackPanel>
<Button Content="确定" Padding="20,5" Margin="5" Click="btnOkClick"/>
</StackPanel>
</Grid>
</Window>
Project.FLY.FeedbackRenZiJia/FLY.FeedbackRenZiJia.UI.Server/WdSetup.xaml.cs
0 → 100644
View file @
8348a92a
using
FLY.FeedbackRenZiJia.Server
;
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.IO
;
using
System.Linq
;
using
System.Runtime.CompilerServices
;
using
System.Security.Cryptography
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows
;
using
System.Windows.Controls
;
using
System.Windows.Data
;
using
System.Windows.Documents
;
using
System.Windows.Input
;
using
System.Windows.Media
;
using
System.Windows.Media.Imaging
;
using
System.Windows.Shapes
;
namespace
FLY.FeedbackRenZiJia.UI.Server
{
/// <summary>
/// WdSetup.xaml 的交互逻辑
/// </summary>
public
partial
class
WdSetup
:
Window
{
FeedbackHeat
feedback
;
public
WdSetup
()
{
InitializeComponent
();
}
public
void
Init
(
FeedbackHeat
feedback
)
{
this
.
feedback
=
feedback
;
string
address
=
feedback
.
PLCep
.
ToString
();
Misc
.
StringConverter
.
ToIPEndPoint
(
"192.168.50.60:502"
);
this
.
comboBox
.
ItemsSource
=
new
int
[]
{
1
,
2
,
3
};
int
version
=
3
;
if
(
this
.
feedback
.
IsClient
==
false
)
{
version
=
1
;
}
else
if
(
address
.
CompareTo
(
"192.168.251.20:8000"
)
==
0
)
{
version
=
2
;
}
else
// if (address.CompareTo("192.168.50.60:502") == 0)
{
version
=
3
;
}
this
.
comboBox
.
SelectedItem
=
version
;
}
private
void
btnOkClick
(
object
sender
,
RoutedEventArgs
e
)
{
if
(
MessageBox
.
Show
(
"需要重启,才能生效"
,
"提示"
,
MessageBoxButton
.
OKCancel
)
==
MessageBoxResult
.
OK
)
{
int
version
=
(
int
)
this
.
comboBox
.
SelectedItem
;
switch
(
version
)
{
case
1
:
{
feedback
.
IsClient
=
false
;
feedback
.
Apply
();
}
break
;
case
2
:
{
feedback
.
IsClient
=
true
;
feedback
.
PLCep
=
Misc
.
StringConverter
.
ToIPEndPoint
(
"192.168.251.20:8000"
);
feedback
.
Apply
();
}
break
;
default
:
{
feedback
.
IsClient
=
false
;
feedback
.
PLCep
=
Misc
.
StringConverter
.
ToIPEndPoint
(
"192.168.50.60:502"
);
feedback
.
Apply
();
}
break
;
}
Application
.
Current
.
Shutdown
();
}
}
}
}
Project.FLY.Weight/FLY.Weight.UI.Server/FLY.Weight.UI.Server.csproj
View file @
8348a92a
...
@@ -65,6 +65,9 @@
...
@@ -65,6 +65,9 @@
<Generator>
MSBuild:Compile
</Generator>
<Generator>
MSBuild:Compile
</Generator>
<SubType>
Designer
</SubType>
<SubType>
Designer
</SubType>
</ApplicationDefinition>
</ApplicationDefinition>
<Compile
Include=
"WdSetup.xaml.cs"
>
<DependentUpon>
WdSetup.xaml
</DependentUpon>
</Compile>
<Page
Include=
"MainWindow.xaml"
>
<Page
Include=
"MainWindow.xaml"
>
<Generator>
MSBuild:Compile
</Generator>
<Generator>
MSBuild:Compile
</Generator>
<SubType>
Designer
</SubType>
<SubType>
Designer
</SubType>
...
@@ -77,6 +80,10 @@
...
@@ -77,6 +80,10 @@
<DependentUpon>
MainWindow.xaml
</DependentUpon>
<DependentUpon>
MainWindow.xaml
</DependentUpon>
<SubType>
Code
</SubType>
<SubType>
Code
</SubType>
</Compile>
</Compile>
<Page
Include=
"WdSetup.xaml"
>
<SubType>
Designer
</SubType>
<Generator>
MSBuild:Compile
</Generator>
</Page>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile
Include=
"Properties\AssemblyInfo.cs"
>
<Compile
Include=
"Properties\AssemblyInfo.cs"
>
...
...
Project.FLY.Weight/FLY.Weight.UI.Server/MainWindow.xaml
View file @
8348a92a
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<Grid x:Name="grid_plc"/>
<Grid x:Name="grid_plc"/>
<Grid x:Name="grid_plcos"/>
<Grid x:Name="grid_plcos"/>
<Grid x:Name="grid_WeightSystem"/>
<Grid x:Name="grid_WeightSystem"/>
<StackPanel
Orientation="Vertical"
Margin="5">
<StackPanel Margin="5">
<ItemsControl x:Name="itemcontrol">
<ItemsControl x:Name="itemcontrol">
<ItemsControl.ItemTemplate>
<ItemsControl.ItemTemplate>
<DataTemplate>
<DataTemplate>
...
@@ -40,25 +40,7 @@
...
@@ -40,25 +40,7 @@
</DataTemplate>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ItemsControl>
<!--<StackPanel Orientation="Horizontal" >
<Button Content="配置" Padding="20,5" Margin="5" HorizontalAlignment="Left" Click="btnSetupClick"></Button>
<StackPanel Orientation="Vertical" Margin="4" DataContext="{Binding DataContext,ElementName=grid_plc}">
<TextBlock Text="更新速度" />
<TextBlock Text="{Binding ActUpdateInterval}" FontSize="20"/>
</StackPanel>
<StackPanel Orientation="Vertical" Margin="4" DataContext="{Binding DataContext,ElementName=grid_plcos}">
<TextBlock Text="PLC连接状态" />
<TextBlock Text="{Binding IsRunning}" FontSize="20"/>
</StackPanel>
<StackPanel Orientation="Vertical" Margin="4" DataContext="{Binding DataContext,ElementName=grid_plc}">
<TextBlock Text="寄存器更新数" />
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding DRNeedUpdateCnt}" FontSize="20"/>
<TextBlock Text="/"/>
<TextBlock Text="{Binding DRCnt}" FontSize="20"/>
</StackPanel>
</StackPanel>
</StackPanel>-->
</StackPanel>
</StackPanel>
</Grid>
</Grid>
...
...
Project.FLY.Weight/FLY.Weight.UI.Server/MainWindow.xaml.cs
View file @
8348a92a
...
@@ -49,5 +49,12 @@ namespace FLY.Weight.UI.Server
...
@@ -49,5 +49,12 @@ namespace FLY.Weight.UI.Server
//grid_WeightSystem.DataContext = mTDGage.mData;
//grid_WeightSystem.DataContext = mTDGage.mData;
this
.
itemcontrol
.
ItemsSource
=
plsos
.
PLCs
;
this
.
itemcontrol
.
ItemsSource
=
plsos
.
PLCs
;
}
}
private
void
btnSetupClick
(
object
sender
,
RoutedEventArgs
e
)
{
WdSetup
w
=
new
WdSetup
();
w
.
Owner
=
this
;
w
.
ShowDialog
();
}
}
}
}
}
Project.FLY.Weight/FLY.Weight.UI.Server/WdSetup.xaml
0 → 100644
View file @
8348a92a
<Window x:Class="FLY.Weight.UI.Server.WdSetup"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:FLY.Weight.UI.Server"
mc:Ignorable="d"
Title="WdSetup" SizeToContent="WidthAndHeight" >
<Grid>
<StackPanel Orientation="Horizontal">
<StackPanel Margin="5">
<TextBlock Text="plcgroup配置文件" Margin="2"/>
<ComboBox MinWidth="200" Margin="2" x:Name="comboBox" >
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</StackPanel>
<Button Content="确定" Padding="20,5" Margin="5" Click="btnOkClick"/>
</StackPanel>
</Grid>
</Window>
Project.FLY.Weight/FLY.Weight.UI.Server/WdSetup.xaml.cs
0 → 100644
View file @
8348a92a
using
FLY.OBJComponents.Common
;
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.IO
;
using
System.Linq
;
using
System.Security.Cryptography
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows
;
using
System.Windows.Controls
;
using
System.Windows.Data
;
using
System.Windows.Documents
;
using
System.Windows.Input
;
using
System.Windows.Media
;
using
System.Windows.Media.Imaging
;
using
System.Windows.Shapes
;
namespace
FLY.Weight.UI.Server
{
/// <summary>
/// WdSetup.xaml 的交互逻辑
/// </summary>
public
partial
class
WdSetup
:
Window
{
public
event
PropertyChangedEventHandler
PropertyChanged
;
public
WdSetup
()
{
InitializeComponent
();
Init
();
}
private
void
Init
()
{
var
items
=
new
List
<
PlcGroupItem
>();
//查找 脚本/称重 下的全部 设备连接变量表_xxx 的文件夹
DirectoryInfo
directoryInfo
=
new
DirectoryInfo
(
@"plcgroups"
);
if
(!
directoryInfo
.
Exists
)
{
//异常
return
;
}
var
dirs
=
directoryInfo
.
GetDirectories
();
foreach
(
var
dir
in
dirs
)
{
if
(
dir
.
Name
.
StartsWith
(
"设备连接变量表_"
))
{
PlcGroupItem
item
=
new
PlcGroupItem
();
item
.
Name
=
dir
.
Name
.
Substring
(
"设备连接变量表_"
.
Length
);
item
.
Path
=
System
.
IO
.
Path
.
Combine
(
dir
.
FullName
,
"Generated"
,
"plcgroup.json"
);
items
.
Add
(
item
);
}
}
comboBox
.
ItemsSource
=
items
;
foreach
(
var
item
in
items
)
{
if
(
IsSameContent
(
item
.
Path
,
"plcgroup.json"
))
{
//找到了
comboBox
.
SelectedItem
=
item
;
break
;
}
}
}
public
static
bool
IsSameContent
(
string
filePath1
,
string
filePath2
)
{
//创建一个哈希算法对象
using
(
HashAlgorithm
hash
=
HashAlgorithm
.
Create
())
{
using
(
FileStream
file1
=
new
FileStream
(
filePath1
,
FileMode
.
Open
),
file2
=
new
FileStream
(
filePath2
,
FileMode
.
Open
))
{
byte
[]
hashByte1
=
hash
.
ComputeHash
(
file1
);
//哈希算法根据文本得到哈希码的字节数组
byte
[]
hashByte2
=
hash
.
ComputeHash
(
file2
);
return
Enumerable
.
SequenceEqual
(
hashByte1
,
hashByte2
);
//string str1 = BitConverter.ToString(hashByte1);//将字节数组装换为字符串
//string str2 = BitConverter.ToString(hashByte2);
//return (str1 == str2);//比较哈希码
}
}
}
private
void
btnOkClick
(
object
sender
,
RoutedEventArgs
e
)
{
var
item
=
comboBox
.
SelectedItem
as
PlcGroupItem
;
if
(
item
==
null
)
{
MessageBox
.
Show
(
"请选择型号!!!"
);
return
;
}
if
(
MessageBox
.
Show
(
"需要重启,才能生效"
,
"提示"
,
MessageBoxButton
.
OKCancel
)
==
MessageBoxResult
.
OK
)
{
File
.
Copy
(
item
.
Path
,
"plcgroup.json"
,
true
);
//System.Windows.Forms.Application.Restart();
Application
.
Current
.
Shutdown
();
}
}
}
public
class
PlcGroupItem
{
/// <summary>
/// 名称
/// </summary>
public
string
Name
{
get
;
set
;
}
/// <summary>
/// 路径
/// </summary>
public
string
Path
{
get
;
set
;
}
}
}
Project.FLY.Winder_20190413/FLY.Winder.UI.Server/FLY.Winder.UI.Server.csproj
View file @
8348a92a
...
@@ -61,6 +61,9 @@
...
@@ -61,6 +61,9 @@
<Generator>
MSBuild:Compile
</Generator>
<Generator>
MSBuild:Compile
</Generator>
<SubType>
Designer
</SubType>
<SubType>
Designer
</SubType>
</ApplicationDefinition>
</ApplicationDefinition>
<Compile
Include=
"WdSetup.xaml.cs"
>
<DependentUpon>
WdSetup.xaml
</DependentUpon>
</Compile>
<Page
Include=
"MainWindow.xaml"
>
<Page
Include=
"MainWindow.xaml"
>
<Generator>
MSBuild:Compile
</Generator>
<Generator>
MSBuild:Compile
</Generator>
<SubType>
Designer
</SubType>
<SubType>
Designer
</SubType>
...
@@ -73,6 +76,10 @@
...
@@ -73,6 +76,10 @@
<DependentUpon>
MainWindow.xaml
</DependentUpon>
<DependentUpon>
MainWindow.xaml
</DependentUpon>
<SubType>
Code
</SubType>
<SubType>
Code
</SubType>
</Compile>
</Compile>
<Page
Include=
"WdSetup.xaml"
>
<Generator>
MSBuild:Compile
</Generator>
<SubType>
Designer
</SubType>
</Page>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile
Include=
"Properties\AssemblyInfo.cs"
>
<Compile
Include=
"Properties\AssemblyInfo.cs"
>
...
...
Project.FLY.Winder_20190413/FLY.Winder.UI.Server/MainWindow.xaml
View file @
8348a92a
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
<Grid>
<Grid>
<Grid x:Name="grid_plc"/>
<Grid x:Name="grid_plc"/>
<Grid x:Name="grid_plcos"/>
<Grid x:Name="grid_plcos"/>
<StackPanel
Orientation="Vertical"
>
<StackPanel >
<StackPanel Orientation="Horizontal" >
<StackPanel Orientation="Horizontal" >
<StackPanel Orientation="Vertical" Margin="4" DataContext="{Binding DataContext,ElementName=grid_plc}">
<StackPanel Orientation="Vertical" Margin="4" DataContext="{Binding DataContext,ElementName=grid_plc}">
<TextBlock Text="更新速度" />
<TextBlock Text="更新速度" />
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
<Button Content="配置" Padding="20,5" Margin="5" HorizontalAlignment="Left" Click="btnSetupClick"></Button>
</StackPanel>
</StackPanel>
</Grid>
</Grid>
</Window>
</Window>
Project.FLY.Winder_20190413/FLY.Winder.UI.Server/MainWindow.xaml.cs
View file @
8348a92a
...
@@ -42,5 +42,12 @@ namespace FLY.Winder.UI.Server
...
@@ -42,5 +42,12 @@ namespace FLY.Winder.UI.Server
grid_plc
.
DataContext
=
plsos
.
PLCs
[
0
];
grid_plc
.
DataContext
=
plsos
.
PLCs
[
0
];
}
}
private
void
btnSetupClick
(
object
sender
,
RoutedEventArgs
e
)
{
WdSetup
w
=
new
WdSetup
();
w
.
Owner
=
this
;
w
.
ShowDialog
();
}
}
}
}
}
Project.FLY.Winder_20190413/FLY.Winder.UI.Server/WdSetup.xaml
0 → 100644
View file @
8348a92a
<Window x:Class="FLY.Winder.UI.Server.WdSetup"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="配置" SizeToContent="WidthAndHeight" >
<Grid>
<StackPanel Orientation="Horizontal">
<StackPanel Margin="5">
<TextBlock Text="plcgroup配置文件" Margin="2"/>
<ComboBox MinWidth="200" Margin="2" x:Name="comboBox" >
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</StackPanel>
<Button Content="确定" Padding="20,5" Margin="5" Click="btnOkClick"/>
</StackPanel>
</Grid>
</Window>
Project.FLY.Winder_20190413/FLY.Winder.UI.Server/WdSetup.xaml.cs
0 → 100644
View file @
8348a92a
using
FLY.OBJComponents.Common
;
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.IO
;
using
System.Linq
;
using
System.Security.Cryptography
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows
;
using
System.Windows.Controls
;
using
System.Windows.Data
;
using
System.Windows.Documents
;
using
System.Windows.Input
;
using
System.Windows.Media
;
using
System.Windows.Media.Imaging
;
using
System.Windows.Shapes
;
namespace
FLY.Winder.UI.Server
{
/// <summary>
/// WdSetup.xaml 的交互逻辑
/// </summary>
public
partial
class
WdSetup
:
Window
{
public
WdSetup
()
{
InitializeComponent
();
Init
();
}
private
void
Init
()
{
var
items
=
new
List
<
PlcGroupItem
>();
//查找 脚本/称重 下的全部 设备连接变量表_xxx 的文件夹
DirectoryInfo
directoryInfo
=
new
DirectoryInfo
(
@"plcgroups"
);
if
(!
directoryInfo
.
Exists
)
{
//异常
return
;
}
var
dirs
=
directoryInfo
.
GetDirectories
();
foreach
(
var
dir
in
dirs
)
{
if
(
dir
.
Name
.
StartsWith
(
"设备连接变量表_"
))
{
PlcGroupItem
item
=
new
PlcGroupItem
();
item
.
Name
=
dir
.
Name
.
Substring
(
"设备连接变量表_"
.
Length
);
item
.
Path
=
System
.
IO
.
Path
.
Combine
(
dir
.
FullName
,
"Generated"
,
"plcgroup.json"
);
items
.
Add
(
item
);
}
}
comboBox
.
ItemsSource
=
items
;
foreach
(
var
item
in
items
)
{
if
(
IsSameContent
(
item
.
Path
,
"plcgroup.json"
))
{
//找到了
comboBox
.
SelectedItem
=
item
;
break
;
}
}
}
public
static
bool
IsSameContent
(
string
filePath1
,
string
filePath2
)
{
//创建一个哈希算法对象
using
(
HashAlgorithm
hash
=
HashAlgorithm
.
Create
())
{
using
(
FileStream
file1
=
new
FileStream
(
filePath1
,
FileMode
.
Open
),
file2
=
new
FileStream
(
filePath2
,
FileMode
.
Open
))
{
byte
[]
hashByte1
=
hash
.
ComputeHash
(
file1
);
//哈希算法根据文本得到哈希码的字节数组
byte
[]
hashByte2
=
hash
.
ComputeHash
(
file2
);
return
Enumerable
.
SequenceEqual
(
hashByte1
,
hashByte2
);
//string str1 = BitConverter.ToString(hashByte1);//将字节数组装换为字符串
//string str2 = BitConverter.ToString(hashByte2);
//return (str1 == str2);//比较哈希码
}
}
}
private
void
btnOkClick
(
object
sender
,
RoutedEventArgs
e
)
{
var
item
=
comboBox
.
SelectedItem
as
PlcGroupItem
;
if
(
item
==
null
)
{
MessageBox
.
Show
(
"请选择型号!!!"
);
return
;
}
if
(
MessageBox
.
Show
(
"需要重启,才能生效"
,
"提示"
,
MessageBoxButton
.
OKCancel
)
==
MessageBoxResult
.
OK
)
{
File
.
Copy
(
item
.
Path
,
"plcgroup.json"
,
true
);
//System.Windows.Forms.Application.Restart();
Application
.
Current
.
Shutdown
();
}
}
}
public
class
PlcGroupItem
{
/// <summary>
/// 名称
/// </summary>
public
string
Name
{
get
;
set
;
}
/// <summary>
/// 路径
/// </summary>
public
string
Path
{
get
;
set
;
}
}
}
thick_public
@
5e49ed99
Subproject commit
112766300e4989d39fd3107cf10530d9afa256d8
Subproject commit
5e49ed992e2210e9ec5c5a1397777f248d7182eb
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment