Commit 3c203046 authored by 黄树航's avatar 黄树航

未完成

parent 1ec84764
......@@ -10,7 +10,7 @@
<ResourceDictionary.MergedDictionaries>
<!--<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/>-->
<ResourceDictionary Source="pack://application:,,,/Setup;component/Style/ControlStyle.xaml"></ResourceDictionary>
<ResourceDictionary Source="pack://application:,,,/电趣百宝箱Setup;component/Style/ControlStyle.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
......
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace Setup.Common
{
internal class ApiHelper
{
private const string _url = "http://crm.yilongex.cn/api/client/product/list?name=BaibaoTest";
private static readonly HttpClient _httpClient = new HttpClient();
public static async Task<string> CheckAsync()
{
var ret = await _httpClient.GetAsync(_url);
ret.EnsureSuccessStatusCode();
var response = await ret.Content.ReadAsStringAsync();
var lastFile = GetValue(response, "lastFile");
return lastFile;
}
private static string GetValue(string input, string key)
{
var pattern = "(?:\"" + key + "\"):\"(?<val>[^\"]*?)\"";
var match = Regex.Match(input, pattern);
if (match.Groups.Count > 0)
{
return match.Groups[0].Value;
}
else
{
return null;
}
}
}
}
......@@ -34,7 +34,6 @@ namespace Dqkj.Setup.Common
}
}
public static void DeleteTemp(List<string> lisDelete)
{
foreach (var ss in lisDelete)
......
......@@ -44,6 +44,7 @@ namespace Dqkj.Setup
}
return "";
}
public static string CurrentPath
{
get
......
......@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33122.133
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Setup", "Setup.csproj", "{743C17E3-641B-429C-A271-2ED6BEAA6B63}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dqkj.Setup", "Dqkj.Setup.csproj", "{743C17E3-641B-429C-A271-2ED6BEAA6B63}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......
......@@ -7,7 +7,7 @@
<ProjectGuid>{743C17E3-641B-429C-A271-2ED6BEAA6B63}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Setup</RootNamespace>
<AssemblyName>Setup</AssemblyName>
<AssemblyName>电趣百宝箱Setup</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
......@@ -49,6 +49,7 @@
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Numerics" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
......@@ -88,6 +89,7 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Common\ApiHelper.cs" />
<Compile Include="Common\DirectoryHelper.cs" />
<Compile Include="Common\DownloadWebClient.cs">
<SubType>Component</SubType>
......
......@@ -24,7 +24,7 @@
<StackPanel Grid.Row="0" Orientation="Horizontal" Style="{StaticResource stackPanel_setup}">
<Image x:Name="imageLogo" Source="/Img/Subtract.png" Width="40" Height="40" />
<TextBlock x:Name="txtBlockTitle" Text="电趣采集助手" FontSize="25" Foreground="White" VerticalAlignment="Center" Margin="10 0" ></TextBlock>
<TextBlock x:Name="txtBlockTitle" Text="电趣百宝箱" FontSize="25" Foreground="White" VerticalAlignment="Center" Margin="10 0" ></TextBlock>
</StackPanel>
<Image Source="/Img/Rectangle 310-1.png" HorizontalAlignment="Left" IsHitTestVisible="False" />
......
......@@ -8,7 +8,6 @@ namespace Dqkj.Setup
public string Content { get; set; }
public string Md5 { get; set; }
public string UpdateUrl { get; set; }
......
......@@ -8,12 +8,6 @@ namespace Dqkj.Setup
public string Url { get; set; }
public Version Ver
{
get
{
return System.Version.Parse(this.Version);
}
}
public Version Ver => System.Version.Parse(this.Version);
}
}
......@@ -8,11 +8,11 @@ using System.Windows;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Dqkj.Setup")]
[assembly: AssemblyTitle("电趣百宝箱 - 安装程序")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Organization")]
[assembly: AssemblyProduct("Dqkj.Setup")]
[assembly: AssemblyProduct("电趣百宝箱 - 安装程序")]
[assembly: AssemblyCopyright("Copyright © Organization 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
......
......@@ -17,7 +17,7 @@
<TextBlock Text="安装路径:" Style="{StaticResource textBlock_setup}" Margin="10,0" ></TextBlock>
<Border Style="{StaticResource border_setup}">
<TextBox x:Name="txtPath" Text="C:\Dqkj\" Width="300" Height="25" BorderThickness="0" HorizontalContentAlignment="Left" VerticalContentAlignment="Center"></TextBox>
<TextBox x:Name="txtPath" Width="300" Height="25" BorderThickness="0" HorizontalContentAlignment="Left" VerticalContentAlignment="Center"></TextBox>
</Border>
<Border Margin="5,0" Style="{StaticResource border_setup}" >
......
......@@ -6,9 +6,6 @@ using System.Windows.Controls;
namespace Dqkj.Setup
{
/// <summary>
/// InstallView.xaml 的交互逻辑
/// </summary>
public partial class InstallView : UserControl
{
private MainWindow _mainWindow { get; set; }
......@@ -34,7 +31,7 @@ namespace Dqkj.Setup
MessageBox.Show("请选择安装路径!", "温馨提示");
return;
}
if (!System.IO.Path.GetInvalidFileNameChars().Any(c => txtPath.Text.Contains(c)))
if (!Path.GetInvalidFileNameChars().Any(c => txtPath.Text.Contains(c)))
{
MessageBox.Show("非法路径,请重新填写或者选择路径!", "温馨提示");
return;
......@@ -58,7 +55,16 @@ namespace Dqkj.Setup
private void Install_Loaded(object sender, RoutedEventArgs e)
{
var defaultName = "Dqukj";
string[] drives = Environment.GetLogicalDrives();
if (drives.Length > 1)
{
this.txtPath.Text = $@"{drives[1]}{defaultName}\";
}
else
{
this.txtPath.Text = $@"{drives[0]}{defaultName}\";
}
}
}
}
#define 天猫助手
using AutoDownload.Common;
using AutoDownload.Common;
using Dqkj.Setup.Common;
using Dqkj.Setup.View;
using Setup.Common;
using System;
using System.Collections.Generic;
using System.IO;
......@@ -22,38 +21,40 @@ namespace Dqkj.Setup
public partial class ProgressView : System.Windows.Controls.UserControl
{
private MainWindow _mainWindow { get; set; }
string defaultUpdateXmlUrl { get; set; }
static string executeName { get; set; }
string formTitle { get; set; }
static string zip_temp { get; set; }
static string _installPath { get; set; }
private string defaultUpdateXmlUrl { get; set; }
private static string executeName { get; set; }
private string formTitle { get; set; }
private static string zip_temp { get; set; }
private static string _installPath { get; set; }
public ProgressView(string installPath, MainWindow mainWindow)
{
InitializeComponent();
Initialize(installPath);
_installPath = installPath;
_mainWindow = mainWindow;
}
public void Initialize(string installPath)
public async Task Initialize(string installPath)
{
_installPath = installPath;
zip_temp = Path.Combine(installPath, "data_temp.zip");
#if 天猫助手
defaultUpdateXmlUrl = "http://112.74.55.104/AutomaticUpdates/全平台采集/Update.xml";
executeName = "电趣采集助手.exe";
formTitle = $"电趣采集助手-自动更新";
#endif
//#if 天猫助手
// defaultUpdateXmlUrl = "http://112.74.55.104/AutomaticUpdates/全平台采集/Update.xml";
// executeName = "电趣采集助手.exe";
// formTitle = $"电趣采集助手-自动更新";
//#endif
defaultUpdateXmlUrl = await ApiHelper.CheckAsync();
executeName = "电趣百宝箱.exe";
formTitle = $"电趣百宝箱-自动更新";
}
private void installProgress_Loaded(object sender, RoutedEventArgs e)
private async void installProgress_Loaded(object sender, RoutedEventArgs e)
{
try
{
await Initialize(_installPath);
Download();
}
catch (Exception ex)
......@@ -84,11 +85,13 @@ namespace Dqkj.Setup
client.DownloadFileAsync(new Uri(serverVersion.Url), zip_temp, serverVersion);
//Application.Run(frm);
}
private void Client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
progress.Value = e.ProgressPercentage;
txtBlockHint.Text = $"正在安装,请稍后({progress.Value}%)";
}
/// <summary>
/// 当文件下载完成时
/// </summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment