66using GeneralUpdate . Common . Internal ;
77using GeneralUpdate . Common . Internal . Bootstrap ;
88using GeneralUpdate . Common . Shared . Object ;
9+ using GeneralUpdate . Common . Shared . Object . Enum ;
910
1011namespace GeneralUpdate . Client
1112{
@@ -23,51 +24,57 @@ private static void Main(string[] args)
2324 await DifferentialCore.Instance?.Dirty(source, patch);
2425 });*/
2526
26- /* Task.Run(() =>
27+ Task . Run ( async ( ) =>
2728 {
28- //Console.WriteLine("主程序启动辣!!!!");
29- //await Task.Delay(3000);
30-
31- var configinfo = new Configinfo();
32- //configinfo.UpdateLogUrl = "https://www.baidu.com";
33- configinfo.ReportUrl = "http://127.0.0.1:5008/Upgrade/Report";
34- configinfo.UpdateUrl = "http://127.0.0.1:5008/Upgrade/Verification";
35-
36- configinfo.AppName = "GeneralUpdate.Upgrad.exe";
37- configinfo.MainAppName = "GeneralUpdate.Client.exe";
38- configinfo.InstallPath = Thread.GetDomain().BaseDirectory;
39- configinfo.Bowl = "Generalupdate.CatBowl.exe";
40-
41- //当前客户端的版本号
42- configinfo.ClientVersion = "1.0.0.0";
43- //当前升级端的版本号
44- configinfo.UpgradeClientVersion = "1.0.0.0";
45-
46- //平台
47- configinfo.Platform = 1;
48- //产品id
49- configinfo.ProductId = "a77c9df5-45f8-4ee9-b3ad-b9431ce0b51c";
50- //应用密钥
51- configinfo.AppSecretKey = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
52-
53- _ = new GeneralClientBootstrap()//单个或多个更新包下载通知事件
54- .AddListenerMultiDownloadProgress(OnMultiDownloadProgressChanged)
55- //单个或多个更新包下载速度、剩余下载事件、当前下载版本信息通知事件
56- .AddListenerMultiDownloadStatistics(OnMultiDownloadStatistics)
57- //单个或多个更新包下载完成
58- .AddListenerMultiDownloadCompleted(OnMultiDownloadCompleted)
59- //完成所有的下载任务通知
60- .AddListenerMultiAllDownloadCompleted(OnMultiAllDownloadCompleted)
61- //下载过程出现的异常通知
62- .AddListenerMultiDownloadError(OnMultiDownloadError)
63- //整个更新过程出现的任何问题都会通过这个事件通知
64- .AddListenerException(OnException)
65- .SetConfig(configinfo)
66- .Option(UpdateOption.DownloadTimeOut, 60)
67- .Option(UpdateOption.Encoding, Encoding.UTF8)
68- .Option(UpdateOption.Format, Format.ZIP)
69- .LaunchAsync();
70- });*/
29+ try
30+ {
31+ Console . WriteLine ( "主程序启动辣!!!!" ) ;
32+ await Task . Delay ( 3000 ) ;
33+
34+ var configinfo = new Configinfo
35+ {
36+ //configinfo.UpdateLogUrl = "https://www.baidu.com";
37+ ReportUrl = "http://127.0.0.1:5000/Upgrade/Report" ,
38+ UpdateUrl = "http://127.0.0.1:5000/Upgrade/Verification" ,
39+ AppName = "GeneralUpdate.Upgrad.exe" ,
40+ MainAppName = "GeneralUpdate.Client.exe" ,
41+ InstallPath = @"D:\迅雷下载\Client" , //Thread.GetDomain().BaseDirectory,
42+ //configinfo.Bowl = "Generalupdate.CatBowl.exe";
43+ //当前客户端的版本号
44+ ClientVersion = "1.0.0.0" ,
45+ //当前升级端的版本号
46+ UpgradeClientVersion = "1.0.0.0" ,
47+ //平台
48+ Platform = PlatformType . Windwos ,
49+ //产品id
50+ ProductId = "a77c9df5-45f8-4ee9-b3ad-b9431ce0b51c" ,
51+ //应用密钥
52+ AppSecretKey = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
53+ } ;
54+
55+ _ = new GeneralClientBootstrap ( ) //单个或多个更新包下载通知事件
56+ . AddListenerMultiDownloadProgress ( OnMultiDownloadProgressChanged )
57+ //单个或多个更新包下载速度、剩余下载事件、当前下载版本信息通知事件
58+ . AddListenerMultiDownloadStatistics ( OnMultiDownloadStatistics )
59+ //单个或多个更新包下载完成
60+ . AddListenerMultiDownloadCompleted ( OnMultiDownloadCompleted )
61+ //完成所有的下载任务通知
62+ . AddListenerMultiAllDownloadCompleted ( OnMultiAllDownloadCompleted )
63+ //下载过程出现的异常通知
64+ . AddListenerMultiDownloadError ( OnMultiDownloadError )
65+ //整个更新过程出现的任何问题都会通过这个事件通知
66+ . AddListenerException ( OnException )
67+ . SetConfig ( configinfo )
68+ . Option ( UpdateOption . DownloadTimeOut , 60 )
69+ . Option ( UpdateOption . Encoding , Encoding . UTF8 )
70+ . Option ( UpdateOption . Format , Format . ZIP )
71+ . LaunchAsync ( ) ;
72+ }
73+ catch ( Exception e )
74+ {
75+ Console . WriteLine ( e . Message + "\n " + e . StackTrace ) ;
76+ }
77+ } ) ;
7178
7279 /*var paramsOSS = new GlobalConfigInfoOSS();
7380 paramsOSS.Url = "http://192.168.50.203/versions.json";
@@ -82,43 +89,45 @@ private static void Main(string[] args)
8289 hub.AddListenerReceive(Receive);
8390 hub.StartAsync().Wait();*/
8491
85- Console . Read ( ) ;
86- }
87-
88- private static void Receive ( string arg1 , string arg2 )
89- {
90- throw new NotImplementedException ( ) ;
92+ while ( true )
93+ {
94+ var input = Console . ReadLine ( ) ;
95+ if ( input == "exit" )
96+ {
97+ break ;
98+ }
99+ }
91100 }
92101
93-
94102 private static void OnMultiDownloadError ( object arg1 , MultiDownloadErrorEventArgs arg2 )
95103 {
96- Debug . WriteLine ( arg2 . Exception ) ;
104+ var version = arg2 . Version as VersionInfo ;
105+ Console . WriteLine ( $ "{ version . Version } { arg2 . Exception } ") ;
97106 }
98107
99108 private static void OnMultiAllDownloadCompleted ( object arg1 , MultiAllDownloadCompletedEventArgs arg2 )
100109 {
101- Debug . WriteLine ( arg2 . IsAllDownloadCompleted ) ;
110+ Console . WriteLine ( arg2 . IsAllDownloadCompleted ) ;
102111 }
103112
104113 private static void OnMultiDownloadCompleted ( object arg1 , MultiDownloadCompletedEventArgs arg2 )
105114 {
106- var v = arg2 . Version ;
115+ Console . WriteLine ( arg2 . Error . ToString ( ) ) ;
107116 }
108117
109118 private static void OnMultiDownloadStatistics ( object arg1 , MultiDownloadStatisticsEventArgs arg2 )
110119 {
111- Debug . WriteLine ( arg2 . Speed ) ;
120+ Console . WriteLine ( $ " { arg2 . Speed } , { arg2 . Remaining } " ) ;
112121 }
113122
114123 private static void OnMultiDownloadProgressChanged ( object arg1 , MultiDownloadProgressChangedEventArgs arg2 )
115124 {
116- Debug . WriteLine ( arg2 . ProgressValue ) ;
125+ Console . WriteLine ( $ " { arg2 . TotalBytesToReceive } , { arg2 . ProgressValue } " ) ;
117126 }
118127
119128 private static void OnException ( object arg1 , ExceptionEventArgs arg2 )
120129 {
121- Debug . WriteLine ( arg2 . Exception ) ;
130+ Console . WriteLine ( $ " { arg2 . Exception } " ) ;
122131 }
123132 }
124133}
0 commit comments