Browse Source

增加自动升级的功能

master
yibo 4 years ago
parent
commit
8573d95169
5 changed files with 135 additions and 116 deletions
  1. +107
    -103
      ButcherFactory.Login/ButcherFactory.Login.csproj
  2. +5
    -0
      ButcherFactory.Login/Login.xaml
  3. +23
    -13
      ButcherFactory.Login/Login.xaml.cs
  4. BIN
      ButcherFactory.Login/images/setting.png
  5. BIN
      ButcherFactory.Login/images/update.png

+ 107
- 103
ButcherFactory.Login/ButcherFactory.Login.csproj View File

@ -1,110 +1,114 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9374B813-569C-4774-A50D-68777735B900}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ButcherFactory.Login</RootNamespace>
<AssemblyName>ButcherFactory.Login</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject>
</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="WinFormControl, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tsref\Debug\WinFormControl.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="ClientVersion.cs" />
<Compile Include="Login.xaml.cs">
<DependentUpon>Login.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<Page Include="Login.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Resource Include="images\login.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ButcherFactory.BO\ButcherFactory.BO.csproj">
<Project>{b258c523-269c-4ed7-ab71-7196d5d2ef65}</Project>
<Name>ButcherFactory.BO</Name>
</ProjectReference>
<ProjectReference Include="..\ButcherFactory.Form\ButcherFactory.Form.csproj">
<Project>{2485631b-624c-43e0-9287-86fa1c8485fc}</Project>
<Name>ButcherFactory.Form</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9374B813-569C-4774-A50D-68777735B900}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ButcherFactory.Login</RootNamespace>
<AssemblyName>ButcherFactory.Login</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject>
</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="WinFormControl, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tsref\Debug\WinFormControl.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="ClientVersion.cs" />
<Compile Include="Login.xaml.cs">
<DependentUpon>Login.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<Page Include="Login.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Resource Include="images\login.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ButcherFactory.BO\ButcherFactory.BO.csproj">
<Project>{b258c523-269c-4ed7-ab71-7196d5d2ef65}</Project>
<Name>ButcherFactory.BO</Name>
</ProjectReference>
<ProjectReference Include="..\ButcherFactory.Form\ButcherFactory.Form.csproj">
<Project>{2485631b-624c-43e0-9287-86fa1c8485fc}</Project>
<Name>ButcherFactory.Form</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Resource Include="images\setting.png" />
<Resource Include="images\update.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">
</Target> </Target>
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
-->
-->
</Project> </Project>

+ 5
- 0
ButcherFactory.Login/Login.xaml View File

@ -9,6 +9,11 @@
<DropShadowEffect BlurRadius="40" Color="#000000" ShadowDepth="0" Opacity="0.3"/> <DropShadowEffect BlurRadius="40" Color="#000000" ShadowDepth="0" Opacity="0.3"/>
</Window.Effect> </Window.Effect>
<Grid> <Grid>
<TextBlock x:Name="versionLbl" Margin="0,0,20,10" HorizontalAlignment="Right" VerticalAlignment="Bottom" Foreground="Green"/>
<Image x:Name="updateImg" Visibility="Hidden" Source="images\update.png" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,45,0" Width="32" PreviewMouseDown="UpdateBtn_Click"/>
<Image Source="images\setting.png" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,10,0" Width="32" PreviewMouseDown="SetBtn_Click"/>
<Label Content="用户名:" FontFamily="微软雅黑" FontSize="22px" HorizontalAlignment="Left" Margin="140,152,0,0" VerticalAlignment="Top" Width="90"/> <Label Content="用户名:" FontFamily="微软雅黑" FontSize="22px" HorizontalAlignment="Left" Margin="140,152,0,0" VerticalAlignment="Top" Width="90"/>
<TextBox Name="userNameInput" HorizontalAlignment="Left" Height="33" Margin="233,158,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" FontFamily="微软雅黑" FontSize="17" Width="187" VerticalContentAlignment="Center" PreviewMouseLeftButtonDown="UserNameTextBoxClick"/> <TextBox Name="userNameInput" HorizontalAlignment="Left" Height="33" Margin="233,158,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" FontFamily="微软雅黑" FontSize="17" Width="187" VerticalContentAlignment="Center" PreviewMouseLeftButtonDown="UserNameTextBoxClick"/>


+ 23
- 13
ButcherFactory.Login/Login.xaml.cs View File

@ -108,33 +108,43 @@ namespace ButcherFactory.Login
const string serUri = "http://172.28.1.194:7799/AutoUpdate/ClientVersion.xml"; const string serUri = "http://172.28.1.194:7799/AutoUpdate/ClientVersion.xml";
const string puKey = "c756e02cedb42a33f78091a466411bde8447d854"; const string puKey = "c756e02cedb42a33f78091a466411bde8447d854";
private void AutoUpdate()
void Login_Loaded(object sender, RoutedEventArgs e)
{ {
if (!File.Exists("ButcherFactory.AutoUpdate.exe")) if (!File.Exists("ButcherFactory.AutoUpdate.exe"))
return; return;
var versionInfo = new ClientVersion(); var versionInfo = new ClientVersion();
if (File.Exists("ClientVersion.xml"))
versionInfo = XmlUtil.DeserializeFromFile<ClientVersion>("ClientVersion.xml");
if (File.Exists("ClientVersion.xml"))
{
versionInfo = XmlUtil.DeserializeFromFile<ClientVersion>("ClientVersion.xml");
versionLbl.Text = versionInfo.Version;
}
if (string.IsNullOrEmpty(versionInfo.ServerUrl)) if (string.IsNullOrEmpty(versionInfo.ServerUrl))
versionInfo.ServerUrl = serUri; versionInfo.ServerUrl = serUri;
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(versionInfo.ServerUrl); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(versionInfo.ServerUrl);
req.Timeout = 5000;
HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
if (resp.StatusCode != HttpStatusCode.OK) if (resp.StatusCode != HttpStatusCode.OK)
return; return;
var down = new System.Net.WebClient(); var down = new System.Net.WebClient();
var serverVersion = XmlUtil.XmlDeserializeObject<ClientVersion>(down.DownloadString(versionInfo.ServerUrl)); var serverVersion = XmlUtil.XmlDeserializeObject<ClientVersion>(down.DownloadString(versionInfo.ServerUrl));
if (versionInfo.Version == serverVersion.Version)
return;
if (versionInfo.Version != serverVersion.Version)
updateImg.Visibility = Visibility.Visible;
}
private void UpdateBtn_Click(object sender, MouseButtonEventArgs e)
{
System.Diagnostics.Process.Start("ButcherFactory.AutoUpdate.exe", puKey); System.Diagnostics.Process.Start("ButcherFactory.AutoUpdate.exe", puKey);
App.Current.Shutdown();
}
void Login_Loaded(object sender, RoutedEventArgs e)
{
//AutoUpdate();
}
App.Current.Shutdown();
}
private void SetBtn_Click(object sender, MouseButtonEventArgs e)
{
if (!File.Exists("ButcherFactory.Tools.exe"))
return;
System.Diagnostics.Process.Start("ButcherFactory.Tools.exe");
}
} }
} }

BIN
ButcherFactory.Login/images/setting.png View File

Before After
Width: 64  |  Height: 64  |  Size: 1.5 KiB

BIN
ButcherFactory.Login/images/update.png View File

Before After
Width: 200  |  Height: 200  |  Size: 5.2 KiB

Loading…
Cancel
Save