Skip to content

Commit e57cc8a

Browse files
committed
初始化提交仓库
0 parents  commit e57cc8a

38 files changed

+2396
-0
lines changed

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.vs/
2+
*.suo
3+
*.user
4+
.ionide/
5+
6+
# Build results
7+
[Dd]ebug/
8+
[Dd]ebugPublic/
9+
10+
[Rr]elease/
11+
[Rr]eleases/
12+
13+
[Bb]in/
14+
[Oo]bj/
15+
[Oo]ut/
16+
[Ll]og/
17+
[Ll]ogs/
18+
19+
paket-files/
20+
nuget-package-caches/
21+
.paket/

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# AutoUpdata
2+
3+
这是一个可通过远程服务器自动更新APP程序的软件
4+
5+
## 这个程序是做什么?
6+
7+
- 微软的ClickOnce停止更新了
8+
- 其他自动更新的程序要么收费,要么不适配我的需求
9+
- 当涉及到在局域网内,使用同一个程序时,需要人手动复制、黏贴、解压,作为受过高等教育的新时代青年,这种繁琐且重复的工作,就应该自动。
10+
11+
## 这个程序怎么用?
12+
13+
- 首先你需要一个IIS的服务端
14+
- 将你的程序打包成zip,并放置在IIS中
15+
- 点击生成按钮,选择你的程序压缩包,然后他就会在你的压缩包的同级目录下生成一个服务端配置文件(程序更新时,是需要读取这个文件,比对MD5信息)
16+
- ![alt text](image-1.png)
17+
- 至此,服务端的配置结束
18+
19+
- 其次,在需要程序运行的局域网电脑中,配置更新参数
20+
- ![alt text](image-2.png)
21+
- 配置完记得保存刷新(它会在程序运行的目录下生成一个配置文件)
22+
- 点击【更新】将会从远程服务端下载程序文件
23+
- 点击【启动】将会直接从安装目录寻找程序启动
24+
- ![alt text](image-3.png)
25+
- 如果你勾选了【自动运行】,它会在程序启动的时候自动执行一遍更新操作
26+
27+
## 下载链接
28+
29+
- 自己去Releases下载,别啥都问我

image-1.png

40.5 KB
Loading

image-2.png

30.9 KB
Loading

image-3.png

40.4 KB
Loading

image.png

39.5 KB
Loading

src/Extraordinary.App/App.xaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Application
2+
x:Class="Extraordinary.App.App"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:local="clr-namespace:Extraordinary.App"
6+
xmlns:sys="clr-namespace:System;assembly=mscorlib"
7+
ShutdownMode="OnExplicitShutdown"
8+
Startup="Application_Startup">
9+
<Application.Resources>
10+
<ResourceDictionary>
11+
<ResourceDictionary.MergedDictionaries>
12+
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml" />
13+
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml" />
14+
15+
<ResourceDictionary>
16+
<sys:String x:Key="AppName">Extraordinary</sys:String>
17+
</ResourceDictionary>
18+
19+
</ResourceDictionary.MergedDictionaries>
20+
</ResourceDictionary>
21+
</Application.Resources>
22+
</Application>

src/Extraordinary.App/App.xaml.cs

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
using Extraordinary.App.ViewModels;
2+
using Microsoft.Extensions.Configuration;
3+
using Microsoft.Extensions.DependencyInjection;
4+
using Microsoft.Extensions.Hosting;
5+
using System.Text;
6+
using System.Windows;
7+
using System.Windows.Media;
8+
9+
namespace Extraordinary.App
10+
{
11+
/// <summary>
12+
/// Interaction logic for App.xaml
13+
/// </summary>
14+
public partial class App : Application
15+
{
16+
private readonly Mutex _singletonMutex;
17+
18+
public App()
19+
{
20+
var appname = typeof(App).AssemblyQualifiedName;
21+
this._singletonMutex = new Mutex(true, appname, out var createdNew);
22+
//if (!createdNew)
23+
//{
24+
// MessageBox.Show($"软件已经启动!不可重复启动!");
25+
// Environment.Exit(0);
26+
// return;
27+
//}
28+
29+
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
30+
31+
InitHost();
32+
}
33+
34+
private void InitHost()
35+
{
36+
this._host = Host.CreateDefaultBuilder()
37+
.ConfigureAppConfiguration((context, builder) =>
38+
{
39+
builder
40+
.SetBasePath(context.HostingEnvironment.ContentRootPath)
41+
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
42+
.AddJsonFile("appsettings.Development.json", optional: true, reloadOnChange: true);
43+
builder.AddEnvironmentVariables();
44+
})
45+
.ConfigureServices(HostStartup.ConfigureServices)
46+
.Build();
47+
this.RootServiceProvider = this._host.Services;
48+
}
49+
public IHost _host { get; private set; }
50+
public IServiceProvider RootServiceProvider { get; internal set; }
51+
private CancellationTokenSource cts = new CancellationTokenSource();
52+
53+
private void SigninOperator(IServiceProvider sp)
54+
{
55+
var appvm = sp.GetRequiredService<AppViewModel>();
56+
var mainWin = sp.GetRequiredService<MainWindow>();
57+
mainWin.Show();
58+
appvm.NavigateTo(UrlDefines.URL_Realtime);
59+
}
60+
61+
private void Application_Startup(object sender, StartupEventArgs e)
62+
{
63+
RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly;
64+
try
65+
{
66+
SigninOperator(this.RootServiceProvider);
67+
68+
var thread = new Thread(async () =>
69+
{
70+
try
71+
{
72+
// do sth before running
73+
await _host.RunAsync(cts.Token);
74+
}
75+
catch (Exception ex)
76+
{
77+
MessageBox.Show(ex.Message);
78+
this.Shutdown();
79+
}
80+
});
81+
thread.Start();
82+
}
83+
catch (Exception ex)
84+
{
85+
MessageBox.Show(ex.Message);
86+
this.Shutdown();
87+
}
88+
}
89+
90+
protected override void OnExit(ExitEventArgs e)
91+
{
92+
try
93+
{
94+
this._singletonMutex.ReleaseMutex();
95+
}
96+
finally
97+
{
98+
using (_host)
99+
{
100+
var lieftime = _host.Services.GetRequiredService<IHostApplicationLifetime>();
101+
lieftime.StopApplication();
102+
}
103+
//base.OnExit(e);
104+
Environment.Exit(0);
105+
}
106+
}
107+
}
108+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Windows;
2+
3+
[assembly: ThemeInfo(
4+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5+
//(used if a resource is not found in the page,
6+
// or application resource dictionaries)
7+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8+
//(used if a resource is not found in the page,
9+
// app, or any theme specific resource dictionaries)
10+
)]
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
namespace Extraordinary.App.Config
2+
{
3+
public class UpdateConfig
4+
{
5+
/// <summary>
6+
/// 服务端地址
7+
/// </summary>
8+
public string ServerUrl { get; set; } = "http://127.0.0.1:5000";
9+
/// <summary>
10+
/// 下载位置
11+
/// </summary>
12+
public string DownloadPath { get; set; } = "";
13+
/// <summary>
14+
/// 程序名称
15+
/// </summary>
16+
public string AppName { get; set; } = "";
17+
/// <summary>
18+
/// 当前程序的MD5版本信息
19+
/// </summary>
20+
public string CurrentMD5Version { get; set; } = "";
21+
/// <summary>
22+
/// 程序安装位置
23+
/// </summary>
24+
public string InstallationPath { get; set; } = "";
25+
26+
/// <summary>
27+
/// 自启动
28+
/// </summary>
29+
public bool Self_Starting { get; set; } = true;
30+
}
31+
}

0 commit comments

Comments
 (0)