markus / MarkusAutoUpdate / src / NetSparkle.Samples.NetFramework.WPF / App.xaml.cs @ 66bd3240
이력 | 보기 | 이력해설 | 다운로드 (3.46 KB)
1 | d8f5045e | taeseongkim | using log4net; |
---|---|---|---|
2 | 8de0cf00 | taeseongkim | using NetSparkle.TestAppWPF.Common; |
3 | 77cdac33 | taeseongkim | using NetSparkle.TestAppWPF.ViewModel; |
4 | d8f5045e | taeseongkim | using Salaros.Configuration; |
5 | using System; |
||
6 | using System.Collections.Generic; |
||
7 | using System.Configuration; |
||
8 | using System.Data; |
||
9 | using System.Globalization; |
||
10 | using System.Linq; |
||
11 | using System.Windows; |
||
12 | |||
13 | namespace NetSparkleUpdater.Samples.NetFramework.WPF |
||
14 | { |
||
15 | /// <summary> |
||
16 | /// Interaction logic for App.xaml |
||
17 | /// </summary> |
||
18 | public partial class App : Application |
||
19 | { |
||
20 | public static string KcomParam = null; |
||
21 | public static string AppCastUri = null; |
||
22 | 8de0cf00 | taeseongkim | public static bool IsExternal = false; |
23 | public static string ExternalAddress = null; |
||
24 | 77cdac33 | taeseongkim | public static ExtractParam extractParam = null; |
25 | |||
26 | public static bool IsExtract = false; |
||
27 | d8f5045e | taeseongkim | |
28 | public static ILog logger = LogManager.GetLogger(typeof(App)); |
||
29 | |||
30 | public App() |
||
31 | { |
||
32 | |||
33 | } |
||
34 | |||
35 | protected override void OnStartup(StartupEventArgs e) |
||
36 | { |
||
37 | try |
||
38 | { |
||
39 | var startDir = AppDomain.CurrentDomain.BaseDirectory; |
||
40 | var configFilePath = $"{System.IO.Path.Combine(startDir, "Markus.AppUpdate.ini")}"; |
||
41 | |||
42 | var config = new ConfigParser(configFilePath, |
||
43 | new ConfigParserSettings |
||
44 | { |
||
45 | MultiLineValues = MultiLineValues.Simple | MultiLineValues.AllowValuelessKeys | MultiLineValues.QuoteDelimitedValues, |
||
46 | Culture = new CultureInfo("en-US") |
||
47 | }); |
||
48 | |||
49 | AppCastUri = config.GetValue("APP_CAST", "URI"); |
||
50 | |||
51 | 8de0cf00 | taeseongkim | var hostDomain = config.GetValue("HOST_DOMAIN", "DOMAIN"); |
52 | |||
53 | if(hostDomain != null) |
||
54 | { |
||
55 | var hostEntry = DnsHelper.GetHostEntryTask(); |
||
56 | |||
57 | if(hostEntry == null) |
||
58 | { |
||
59 | IsExternal = true; |
||
60 | } |
||
61 | else if(!string.IsNullOrWhiteSpace(hostDomain) && !hostEntry.HostName.ToUpper().EndsWith(hostDomain.ToUpper())) |
||
62 | { |
||
63 | IsExternal = true; |
||
64 | } |
||
65 | } |
||
66 | |||
67 | if (IsExternal) |
||
68 | { |
||
69 | ExternalAddress = config.GetValue("APP_CAST", "EXTERNAL_URI"); |
||
70 | |||
71 | var uri = UriHelper.ChangeAddress(new Uri(AppCastUri), ExternalAddress); |
||
72 | |||
73 | AppCastUri = uri.ToString(); |
||
74 | } |
||
75 | |||
76 | |||
77 | d8f5045e | taeseongkim | App.logger.Info($"App Cast Uri : {AppCastUri}"); |
78 | |||
79 | 77cdac33 | taeseongkim | if (e.Args.Count() > 0) |
80 | { |
||
81 | if (e.Args[0] == "EXT" && e.Args.Count() == 2) |
||
82 | { |
||
83 | App.extractParam = ObjectToBytesStringConvert.BytesStringToObject<ExtractParam>(e.Args[1]); |
||
84 | App.IsExtract = true; |
||
85 | } |
||
86 | else if (e.Args[0] == "ADMIN" && e.Args.Count() == 2) |
||
87 | { |
||
88 | App.extractParam = ObjectToBytesStringConvert.BytesStringToObject<ExtractParam>(e.Args[1]); |
||
89 | App.KcomParam = App.extractParam.AppRunParam; |
||
90 | } |
||
91 | else |
||
92 | { |
||
93 | KcomParam = e.Args[0]; |
||
94 | } |
||
95 | } |
||
96 | |||
97 | d8f5045e | taeseongkim | base.OnStartup(e); |
98 | } |
||
99 | catch (Exception ex) |
||
100 | { |
||
101 | logger.Error("Startup Error ", ex); |
||
102 | } |
||
103 | } |
||
104 | } |
||
105 | } |