개정판 c4a4d59c
issue #660 SmartUpdate 구현
KCOM/App.xaml.cs | ||
---|---|---|
1 | 1 |
|
2 |
using KCOM.ServiceDeepView; |
|
2 | 3 |
using System; |
3 | 4 |
using System.Collections.Generic; |
4 | 5 |
using System.ComponentModel; |
5 | 6 |
using System.Configuration; |
6 | 7 |
using System.Data; |
8 |
using System.Diagnostics; |
|
9 |
using System.IO; |
|
7 | 10 |
using System.Linq; |
11 |
using System.Net; |
|
12 |
using System.Reflection; |
|
8 | 13 |
using System.Runtime.CompilerServices; |
9 | 14 |
using System.ServiceModel; |
10 | 15 |
using System.Windows; |
16 |
using System.Xml; |
|
11 | 17 |
|
12 | 18 |
namespace KCOM |
13 | 19 |
{ |
... | ... | |
56 | 62 |
return Newtonsoft.Json.JsonConvert.DeserializeObject<OpenProperties>(jsonBack); |
57 | 63 |
} |
58 | 64 |
|
65 |
//20180921 LJY |
|
66 |
//public ServiceDeepViewClient _Client; |
|
67 |
|
|
68 |
|
|
69 |
private string versionPath = null; |
|
70 |
|
|
59 | 71 |
protected override void OnStartup(StartupEventArgs e) |
60 | 72 |
{ |
61 | 73 |
try |
62 | 74 |
{ |
63 | 75 |
if (e.Args.Count() > 0) |
64 | 76 |
{ |
65 |
|
|
66 |
var result = ParamDecoding(e.Args[0].Replace(@"kcom://","").Replace(@"/","")); |
|
77 |
var result = ParamDecoding(e.Args[0].Replace(@"kcom://", "").Replace(@"/", "")); |
|
67 | 78 |
App.ViewInfo = new IKCOM.ViewInfo |
68 | 79 |
{ |
69 | 80 |
DocumentItemID = result.DocumentItemID, |
... | ... | |
78 | 89 |
}; |
79 | 90 |
ParameterMode = true; |
80 | 91 |
} |
92 |
else |
|
93 |
{ |
|
94 |
string[] strArg = Environment.GetCommandLineArgs(); |
|
95 |
if (strArg.Length > 1) |
|
96 |
{ |
|
97 |
//label1.Text = strArg[1]; |
|
98 |
|
|
99 |
var result = ParamDecoding(strArg[1].Replace(@"kcom://", "").Replace(@"/", "")); |
|
100 |
App.ViewInfo = new IKCOM.ViewInfo |
|
101 |
{ |
|
102 |
DocumentItemID = result.DocumentItemID, |
|
103 |
//DocumentItemID = "10001", |
|
104 |
bPartner = result.bPartner, |
|
105 |
CreateFinalPDFPermission = result.CreateFinalPDFPermission, |
|
106 |
NewCommentPermission = result.NewCommentPermission, |
|
107 |
ProjectNO = result.ProjectNO, |
|
108 |
UserID = result.UserID, |
|
109 |
//UserID = "H2009115", |
|
110 |
//Mode = 0 , 1 , 2 |
|
111 |
}; |
|
112 |
ParameterMode = true; |
|
113 |
} |
|
114 |
} |
|
81 | 115 |
|
82 | 116 |
//App.ViewInfo.CreateFinalPDFPermission = false; |
83 | 117 |
//App.ViewInfo.NewCommentPermission = false; |
84 | 118 |
|
85 |
//GetQueryStringParameters(); |
|
86 |
_binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly); |
|
119 |
//GetQueryStringParameters();
|
|
120 |
_binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
|
|
87 | 121 |
_binding.MaxBufferSize = 2147483647; |
88 | 122 |
_binding.MaxReceivedMessageSize = 2147483647; |
89 | 123 |
_binding.OpenTimeout = new TimeSpan(0, 1, 0); |
... | ... | |
102 | 136 |
#else |
103 | 137 |
_EndPoint = new EndpointAddress(string.Format("{0}/ServiceDeepView.svc", sBaseServiceURL)); |
104 | 138 |
#endif |
105 |
base.OnStartup(e); |
|
139 |
|
|
140 |
//20180913 LJY 어셈블리 버전 |
|
141 |
//string assemblyVersion = Assembly.LoadFile('your assembly file').GetName().Version.ToString(); |
|
142 |
//string fileVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion; |
|
143 |
//string productVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion; |
|
144 |
//_Client = new ServiceDeepViewClient(App._binding, App._EndPoint); |
|
145 |
//var serverVersion = _Client.GetCurrentVersion(); |
|
146 |
|
|
147 |
if (Environment.Is64BitProcess == true) //64 bit machine |
|
148 |
{ |
|
149 |
versionPath = KCOM.Properties.Settings.Default.UpdateVer64; |
|
150 |
} |
|
151 |
else //32 bit machine |
|
152 |
{ |
|
153 |
versionPath = KCOM.Properties.Settings.Default.UpdateVer86; |
|
154 |
} |
|
155 |
|
|
156 |
// 20180921 version.xml check로 변경 |
|
157 |
var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); |
|
158 |
try |
|
159 |
{ |
|
160 |
XmlDocument xdoc = new XmlDocument(); |
|
161 |
xdoc.Load(versionPath); |
|
162 |
XmlNode node = xdoc.SelectSingleNode("/RootElement/version"); |
|
163 |
|
|
164 |
if (assemblyVersion != node.InnerText) // node.InnerText 가 null이면 catch로 빠짐 |
|
165 |
{ |
|
166 |
if(MessageBox.Show("Ver. " + node.InnerText + " 업데이트가 있습니다.\r\nSmartUpdate를 실행합니다.", "MARKUS", MessageBoxButton.OKCancel) == MessageBoxResult.OK) |
|
167 |
{ |
|
168 |
UpdateCheck(e); |
|
169 |
} |
|
170 |
else |
|
171 |
{ |
|
172 |
base.Shutdown(); |
|
173 |
//현재 실행되고 있는 자기 자신 프로세스의 정보 // 위에꺼랑 두개 다 써줄필요가 있는..가? |
|
174 |
Process proc = Process.GetCurrentProcess(); |
|
175 |
proc.Kill(); |
|
176 |
} |
|
177 |
} |
|
178 |
else |
|
179 |
{ |
|
180 |
base.OnStartup(e); |
|
181 |
} |
|
182 |
} |
|
183 |
catch (Exception ex) //2. 파일이 없거나 파일내에 version의 값이 없다면 KCOM 실행하기 |
|
184 |
{ |
|
185 |
ErrorLogFileWrite("KCOM//UpdateCheck ERR : " + ex); |
|
186 |
base.OnStartup(e); |
|
187 |
} |
|
106 | 188 |
} |
107 | 189 |
catch (Exception ex) |
108 | 190 |
{ |
109 | 191 |
MessageBox.Show("에러 메시지" + ex.Message); |
110 | 192 |
} |
111 | 193 |
} |
194 |
|
|
195 |
protected void UpdateCheck(StartupEventArgs e) |
|
196 |
{ |
|
197 |
try |
|
198 |
{ |
|
199 |
if (e.Args.Count() > 0) |
|
200 |
{ |
|
201 |
ProcessStartInfo proInfo = new ProcessStartInfo(); |
|
202 |
var FileName = AppDomain.CurrentDomain.BaseDirectory + "SmartUpdate.exe"; |
|
203 |
|
|
204 |
Process.Start(FileName, e.Args[0]); |
|
205 |
|
|
206 |
//다른프로그램에서는 값 안넘기고 바로 실행해도 오류 없이 파일 업데이트 잘 됨! |
|
207 |
//Process.Start(FileName); |
|
208 |
|
|
209 |
base.Shutdown(); |
|
210 |
//현재 실행되고 있는 자기 자신 프로세스의 정보 |
|
211 |
Process proc = Process.GetCurrentProcess(); |
|
212 |
proc.Kill(); |
|
213 |
} |
|
214 |
} |
|
215 |
catch(Exception ee) |
|
216 |
{ |
|
217 |
ErrorLogFileWrite("KCOM//UpdateCheck ERR : " + ee); |
|
218 |
} |
|
219 |
} |
|
220 |
|
|
221 |
private void ErrorLogFileWrite(string Err) |
|
222 |
{ |
|
223 |
try |
|
224 |
{ |
|
225 |
string pathString = AppDomain.CurrentDomain.BaseDirectory + "Err"; |
|
226 |
if (!File.Exists(pathString)) |
|
227 |
{ |
|
228 |
Directory.CreateDirectory(pathString); |
|
229 |
} |
|
230 |
|
|
231 |
Err = Err + " " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "\r\n"; |
|
232 |
string path = pathString + "\\" + "Log_" + DateTime.Now.ToString("yyyy-MM-dd hh-mm") + ".txt"; |
|
233 |
File.AppendAllText(path, Err); |
|
234 |
} |
|
235 |
catch (Exception er) |
|
236 |
{ |
|
237 |
string strError = er.ToString(); |
|
238 |
//MessageBox.Show("err : " + er); |
|
239 |
} |
|
240 |
} |
|
112 | 241 |
} |
113 | 242 |
} |
내보내기 Unified diff