개정판 97cde7e3
issue #660: SmartUpdate 수정
Change-Id: Ie4469cf5493423fe0bd367623860cd96e92b9574
KCOM/MainWindow.xaml.cs | ||
---|---|---|
402 | 402 |
{ |
403 | 403 |
string url = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.BaseClient.GetVersionData(Environment.Is64BitProcess, Assembly.GetExecutingAssembly().GetName().Version.ToString()); |
404 | 404 |
if (!string.IsNullOrEmpty(url)) |
405 |
{ |
|
406 |
var box = new TextBlock(); |
|
407 |
box.MinWidth = 400; |
|
408 |
box.FontSize = 11; |
|
409 |
box.Text = "새로운 버전이 있습니다. \n업데이트 하시겠습니까?"; |
|
410 |
box.TextWrapping = System.Windows.TextWrapping.Wrap; |
|
405 |
{ |
|
411 | 406 |
DialogParameters parameters = new DialogParameters() |
412 | 407 |
{ |
413 | 408 |
Owner = Application.Current.MainWindow, |
414 |
Content = box, |
|
409 |
Content = new TextBlock() |
|
410 |
{ |
|
411 |
MinWidth = 400, |
|
412 |
FontSize = 11, |
|
413 |
Text = "새로운 버전이 있습니다. \n업데이트 하시겠습니까?", |
|
414 |
TextWrapping = System.Windows.TextWrapping.Wrap |
|
415 |
}, |
|
415 | 416 |
Header = "Confirm", |
416 | 417 |
Theme = new VisualStudio2013Theme(), |
417 | 418 |
ModalBackground = new SolidColorBrush { Color = Colors.Black, Opacity = 0.6 }, |
... | ... | |
419 | 420 |
{ |
420 | 421 |
if (e.DialogResult == true) |
421 | 422 |
{ |
423 |
ProcessStartInfo proInfo = new ProcessStartInfo(); |
|
424 |
var FileName = AppDomain.CurrentDomain.BaseDirectory + "SmartUpdate.exe"; |
|
425 |
Process.Start(FileName, url); |
|
426 |
this.Close(); |
|
427 |
|
|
428 |
/* |
|
422 | 429 |
Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate |
423 | 430 |
{ |
424 | 431 |
destfilepath = System.IO.Path.Combine(TempFile.TempFolder, System.IO.Path.GetFileName(url)); |
... | ... | |
431 | 438 |
client.DownloadFileCompleted += new AsyncCompletedEventHandler(Client_DownloadFileCompleted); |
432 | 439 |
client.DownloadFileAsync(new Uri(url), destfilepath); |
433 | 440 |
})); |
434 |
|
|
435 |
}else |
|
441 |
*/ |
|
442 |
} |
|
443 |
else |
|
436 | 444 |
{ |
437 | 445 |
isUpdateCheck = true; |
438 | 446 |
} |
439 | 447 |
} |
440 | 448 |
}; |
441 |
RadWindow.Confirm(parameters); |
|
449 |
RadWindow.Confirm(parameters); |
|
450 |
|
|
442 | 451 |
} |
443 | 452 |
else |
444 | 453 |
{ |
SmartUpdate/MainWindow.xaml | ||
---|---|---|
1 | 1 |
<Window x:Class="SmartUpdate.MainWindow" |
2 |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|
3 |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|
4 |
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
|
5 |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
|
6 |
xmlns:local="clr-namespace:SmartUpdate" |
|
7 |
mc:Ignorable="d" |
|
8 |
Height="60" Width="300" Background="#FF007acc"> |
|
9 |
<Grid> |
|
10 |
<ProgressBar HorizontalAlignment="Left" VerticalAlignment="Bottom" Height="18" x:Name="progressBar" Width="300" Background="Transparent" BorderThickness="0" |
|
11 |
Foreground="LightSlateGray" Opacity="0.5"/> |
|
12 |
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Bottom" TextAlignment="Center" x:Name="splashText" Foreground="AntiqueWhite" FontWeight="ExtraBold" xml:space="preserve" Height="17.5"> Loading...</TextBlock> |
|
13 |
</Grid> |
|
14 |
</Window> |
|
15 |
|
|
16 |
<!--<Window x:Class="SmartUpdate.MainWindow" |
|
2 | 17 |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
3 | 18 |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
4 | 19 |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
... | ... | |
23 | 38 |
</Border> |
24 | 39 |
<Grid Margin="0,0,0,0" Background="WhiteSmoke"> |
25 | 40 |
|
26 |
<!--<ProgressBar Name="TotalDownloadProgressBar" HorizontalAlignment="Center" Height="30" VerticalAlignment="Top" Width="500" Margin="46,330,46,0" />--> |
|
27 | 41 |
<ProgressBar Name="PartialDownloadProgressBar" HorizontalAlignment="Center" Height="30" VerticalAlignment="Top" Width="500" Margin="46,362,46,0"/> |
28 | 42 |
<TextBlock Text="{Binding ElementName=PartialDownloadProgressBar, Path=Value, StringFormat={}{0:0}%}" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,369,0,0"/> |
29 | 43 |
<ListView HorizontalAlignment="Left" Height="236" Margin="46,103,0,0" VerticalAlignment="Top" Width="500" Name="downloadlist"> |
30 | 44 |
|
31 | 45 |
<ListView.View> |
32 | 46 |
<GridView> |
33 |
<!--<GridViewColumn Header="Num" Width="40" DisplayMemberBinding="{Binding Num}" />--> |
|
34 | 47 |
|
35 | 48 |
<GridViewColumn Width="310" Header="FileName" > |
36 | 49 |
<GridViewColumn.CellTemplate> |
37 | 50 |
<DataTemplate> |
38 | 51 |
<StackPanel Orientation="Horizontal"> |
39 | 52 |
<Image Source="{Binding SIcon}" Width="24" Height="24"></Image> |
40 |
<!--<Image Source="{Binding SIcon}" Width="24" Height="24"></Image>--> |
|
41 | 53 |
<TextBlock Text="{Binding FileName}"/> |
42 | 54 |
</StackPanel> |
43 | 55 |
</DataTemplate> |
... | ... | |
46 | 58 |
|
47 | 59 |
</GridViewColumn> |
48 | 60 |
|
49 |
<!-- <GridViewColumn Header="FileName" Width="260" DisplayMemberBinding="{Binding FileName}" /> --> |
|
50 |
|
|
51 | 61 |
<GridViewColumn Header="Version" Width="179" DisplayMemberBinding="{Binding Version}" /> |
52 |
<!--<GridViewColumn Header="Date" Width="100" DisplayMemberBinding="{Binding Date}" />--> |
|
53 | 62 |
</GridView> |
54 | 63 |
|
55 | 64 |
</ListView.View> |
... | ... | |
61 | 70 |
<Run FontStyle="Italic" FontSize="12" Text=" 업데이트 중입니다. 잠시만 기다려주세요... " /> |
62 | 71 |
</TextBlock> |
63 | 72 |
<Image HorizontalAlignment="Left" Height="64" Margin="525,4,0,0" VerticalAlignment="Top" Width="70" Source="Resources/UpdateImg.png"/> |
64 |
|
|
65 |
<!--<Separator Margin="0,0,0,0"/>--> |
|
66 |
<!-- <TextBox FontSize="18" Text ="MARKUS SmartUpdate" Margin="200,67,200,0" HorizontalAlignment="Center" VerticalAlignment="Top"/>--> |
|
67 | 73 |
</Grid> |
68 | 74 |
</DockPanel> |
69 | 75 |
</Border> |
70 | 76 |
|
71 | 77 |
|
72 |
</Window> |
|
78 |
</Window>-->
|
SmartUpdate/MainWindow.xaml.cs | ||
---|---|---|
35 | 35 |
private string msgFileName = SmartUpdate.Properties.Settings.Default.msgFileName; //메시지창에 띄워줄 프로그램명 |
36 | 36 |
private string FileName = SmartUpdate.Properties.Settings.Default.FileName; //실행파일명 |
37 | 37 |
|
38 |
private string[] url; // msi 파일 url |
|
39 |
string destfilepath = string.Empty; |
|
40 |
public static string TempFolder |
|
41 |
{ |
|
42 |
get |
|
43 |
{ |
|
44 |
return Path.Combine(Path.GetTempPath(), "MARKUS"); |
|
45 |
} |
|
46 |
} |
|
47 |
|
|
38 | 48 |
public MainWindow() |
39 | 49 |
{ |
40 | 50 |
InitializeComponent(); |
... | ... | |
46 | 56 |
|
47 | 57 |
void MainWindow_Loaded(object sender, RoutedEventArgs e) |
48 | 58 |
{ |
49 |
m_bLoop = true; |
|
50 |
lastIndex = index = 0; |
|
51 |
theProgBarThread = new Thread(new ThreadStart(Step)); |
|
52 |
theProgBarThread.Start(); |
|
53 |
Thread.Sleep(100); |
|
54 |
PartialDownloadProgressBar.Maximum = 100; |
|
55 |
strArg = Environment.GetCommandLineArgs(); //KCOM 접속 파라미터 값 받기 위해 |
|
56 |
ConnectUpgradeServer(); //여기서부터 XML 파싱 및 파일 다운로드 |
|
59 |
//m_bLoop = true; |
|
60 |
//lastIndex = index = 0; |
|
61 |
//theProgBarThread = new Thread(new ThreadStart(Step)); |
|
62 |
//theProgBarThread.Start(); |
|
63 |
//Thread.Sleep(100); |
|
64 |
//PartialDownloadProgressBar.Maximum = 100; |
|
65 |
url = Environment.GetCommandLineArgs(); //file url |
|
66 |
destfilepath = System.IO.Path.Combine(TempFolder, System.IO.Path.GetFileName(url[1])); |
|
67 |
splashText.Text = "Update Download Start..."; |
|
68 |
WebClient client = new WebClient(); |
|
69 |
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged); |
|
70 |
client.DownloadFileCompleted += new AsyncCompletedEventHandler(Client_DownloadFileCompleted); |
|
71 |
client.DownloadFileAsync(new Uri(url[1]), destfilepath); |
|
72 |
//ConnectUpgradeServer(); //여기서부터 XML 파싱 및 파일 다운로드 |
|
73 |
} |
|
74 |
|
|
75 |
private void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) |
|
76 |
{ |
|
77 |
Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate |
|
78 |
{ |
|
79 |
double bytesIn = double.Parse(e.BytesReceived.ToString()); |
|
80 |
double totalBytes = double.Parse(e.TotalBytesToReceive.ToString()); |
|
81 |
double percentage = bytesIn / totalBytes * 100; |
|
82 |
splashText.Text = "Download : " + Math.Truncate(percentage).ToString() + " %"; |
|
83 |
progressBar.Value = int.Parse(Math.Truncate(percentage).ToString()); |
|
84 |
})); |
|
85 |
} |
|
86 |
|
|
87 |
|
|
88 |
private void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) |
|
89 |
{ |
|
90 |
try |
|
91 |
{ |
|
92 |
Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate |
|
93 |
{ |
|
94 |
splashText.Text = "Download Completed"; |
|
95 |
})); |
|
96 |
|
|
97 |
if (File.Exists(destfilepath)) |
|
98 |
{ |
|
99 |
ProcessStartInfo update_msi = new ProcessStartInfo(); |
|
100 |
update_msi.FileName = destfilepath; |
|
101 |
Process.Start(update_msi); |
|
102 |
} |
|
103 |
this.Close(); |
|
104 |
} |
|
105 |
catch (Exception) |
|
106 |
{ |
|
107 |
throw; |
|
108 |
} |
|
109 |
|
|
57 | 110 |
} |
58 | 111 |
|
112 |
/* |
|
113 |
|
|
59 | 114 |
public class ItemInfo |
60 | 115 |
{ |
61 | 116 |
public string FileName { get; set; } |
... | ... | |
135 | 190 |
SmartUpdateExit("File Loading Error SmartUpdate를 종료합니다."); //스마트 업데이트 종료 |
136 | 191 |
} |
137 | 192 |
} |
138 |
|
|
193 |
string destfilepath = string.Empty; |
|
194 |
public static string TempFolder |
|
195 |
{ |
|
196 |
get |
|
197 |
{ |
|
198 |
return Path.Combine(Path.GetTempPath(), "MARKUS"); |
|
199 |
} |
|
200 |
} |
|
139 | 201 |
private void SetDown() |
140 | 202 |
{ |
141 | 203 |
try |
142 |
{
|
|
204 |
{ |
|
143 | 205 |
for (int i = 0; i < itemInfoList.Count; i++) |
144 | 206 |
{ |
145 | 207 |
WebClient theDownloadThread = new WebClient(); |
... | ... | |
355 | 417 |
ErrorLogFileWrite("업데이트 파일 작성에 실패했습니다. \r\n 상세로그 : " + strError); |
356 | 418 |
} |
357 | 419 |
} |
420 |
*/ |
|
358 | 421 |
|
359 | 422 |
private void WinState(object sender, MouseButtonEventArgs e) |
360 | 423 |
{ |
SmartUpdate/SmartUpdate.csproj | ||
---|---|---|
36 | 36 |
<DebugSymbols>true</DebugSymbols> |
37 | 37 |
<DebugType>full</DebugType> |
38 | 38 |
<Optimize>false</Optimize> |
39 |
<OutputPath>..\KCOM\bin\x64\Debug\</OutputPath>
|
|
39 |
<OutputPath>..\KCOM\bin\Debug\</OutputPath> |
|
40 | 40 |
<DefineConstants>DEBUG;TRACE</DefineConstants> |
41 | 41 |
<ErrorReport>prompt</ErrorReport> |
42 | 42 |
<WarningLevel>4</WarningLevel> |
내보내기 Unified diff