markus / KCOM / App.xaml.cs @ 49a6d7c3
이력 | 보기 | 이력해설 | 다운로드 (23.5 KB)
1 |
|
---|---|
2 |
using KCOM.Common; |
3 |
using KCOM.Views; |
4 |
using License.Validator; |
5 |
using log4net; |
6 |
using System; |
7 |
using System.ComponentModel; |
8 |
using System.IO; |
9 |
using System.Linq; |
10 |
using System.Net; |
11 |
using System.ServiceModel; |
12 |
using System.Threading.Tasks; |
13 |
using System.Windows; |
14 |
using System.Windows.Input; |
15 |
using System.Windows.Resources; |
16 |
|
17 |
namespace KCOM |
18 |
{ |
19 |
public class OpenProperties |
20 |
{ |
21 |
public string DocumentItemID { get; set; } |
22 |
public bool bPartner { get; set; } |
23 |
public bool CreateFinalPDFPermission { get; set; } |
24 |
public bool NewCommentPermission { get; set; } |
25 |
public string ProjectNO { get; set; } |
26 |
public string UserID { get; set; } |
27 |
public int Mode { get; set; } |
28 |
} |
29 |
|
30 |
/// <summary> |
31 |
/// App.xaml에 대한 상호 작용 논리 |
32 |
/// </summary> |
33 |
public partial class App : Application |
34 |
{ |
35 |
public static PageManager.PageStorage PageStorage; |
36 |
public static string MarkusVersion = ""; |
37 |
public static string BaseAddress; |
38 |
public static string FileUploadUri; |
39 |
public static System.ServiceModel.Channels.Binding _binding; |
40 |
public static EndpointAddress _EndPoint; |
41 |
public static EndpointAddress _EndPoint_SaveLoad; |
42 |
public static EndpointAddress _EndPoint_Symbol; |
43 |
public static string UserName; |
44 |
public static IKCOM.ViewInfo ViewInfo; |
45 |
public static string urlHost; |
46 |
public static string urlPort; |
47 |
public static string urlHost_DB; |
48 |
public static string urlPort_DB; |
49 |
|
50 |
/// <summary> |
51 |
/// 현재 활성화된 MarkupInfo의 Id |
52 |
/// </summary> |
53 |
public static string Custom_ViewInfoId { get; set; } |
54 |
|
55 |
public static bool ParameterMode = false; |
56 |
public static bool isExternal = false; |
57 |
public static bool isAuthenticate = false; |
58 |
public static string AuthenticateToken = null; |
59 |
|
60 |
/// <summary> |
61 |
/// logger |
62 |
/// </summary> |
63 |
public static ILog FileLogger = null; |
64 |
|
65 |
public static StreamResourceInfo DefaultArrowCursor; |
66 |
|
67 |
public static Stream DefaultArrowCursorStream |
68 |
{ |
69 |
get { |
70 |
return Application.GetResourceStream(new Uri(@"pack://application:,,,/Resources/Cursor/customCursor2.cur", UriKind.Absolute)).Stream; |
71 |
//DefaultArrowCursor.Stream.Position = 0; |
72 |
//return DefaultArrowCursor.Stream; |
73 |
} |
74 |
} |
75 |
|
76 |
public static kr.co.devdoftech.cloud.FileUpload FileUploader |
77 |
{ |
78 |
get { return new kr.co.devdoftech.cloud.FileUpload{ Url = FileUploadUri }; } |
79 |
|
80 |
private set {; } |
81 |
} |
82 |
|
83 |
/// <summary> |
84 |
/// VisualStudio Design Time여부 |
85 |
/// </summary> |
86 |
public static bool IsDesignMode |
87 |
{ |
88 |
get |
89 |
{ |
90 |
try |
91 |
{ |
92 |
return DesignerProperties.GetIsInDesignMode(new DependencyObject()); |
93 |
} |
94 |
catch (Exception) |
95 |
{ |
96 |
return false; |
97 |
} |
98 |
} |
99 |
private set { } |
100 |
} |
101 |
|
102 |
/// <summary> |
103 |
/// Application Data Folder |
104 |
/// </summary> |
105 |
public static string AppDataFolder |
106 |
{ |
107 |
get |
108 |
{ |
109 |
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MARKUS"); |
110 |
} |
111 |
} |
112 |
|
113 |
public static IKCOM.KCOM_SystemInfo SystemInfo { get; set; } |
114 |
|
115 |
public static OpenProperties ParamDecoding(string DecodingText, System.Text.Encoding oEncoding = null) |
116 |
{ |
117 |
if (oEncoding == null) |
118 |
oEncoding = System.Text.Encoding.UTF8; |
119 |
|
120 |
byte[] byteArray = Convert.FromBase64String(DecodingText); |
121 |
|
122 |
string jsonBack = oEncoding.GetString(byteArray); |
123 |
|
124 |
return Newtonsoft.Json.JsonConvert.DeserializeObject<OpenProperties>(jsonBack); |
125 |
} |
126 |
|
127 |
private string versionPath = null; |
128 |
//public SplashScreen splash = new SplashScreen("splash.png"); |
129 |
public static SplashScreenWindow splashScreen = new SplashScreenWindow(); |
130 |
|
131 |
public App() |
132 |
{ |
133 |
Telerik.Windows.Controls.StyleManager.ApplicationTheme = new Telerik.Windows.Controls.VisualStudio2013Theme(); |
134 |
|
135 |
App.FileLogger = LogManager.GetLogger(typeof(App)); |
136 |
} |
137 |
|
138 |
protected override void OnExit(ExitEventArgs e) |
139 |
{ |
140 |
try |
141 |
{ |
142 |
if (App.PageStorage != null) |
143 |
{ |
144 |
App.PageStorage.Clear(); |
145 |
} |
146 |
} |
147 |
catch (Exception) |
148 |
{ |
149 |
} |
150 |
|
151 |
base.OnExit(e); |
152 |
} |
153 |
|
154 |
protected override async void OnStartup(StartupEventArgs e) |
155 |
{ |
156 |
try |
157 |
{ |
158 |
DefaultArrowCursor = Application.GetResourceStream(new Uri(@"pack://application:,,,/Resources/Cursor/customCursor2.cur", UriKind.Absolute)); |
159 |
|
160 |
splashScreen.Show(); |
161 |
|
162 |
App.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException; |
163 |
/// up to here |
164 |
//AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); |
165 |
|
166 |
#region // DNS 체크 |
167 |
|
168 |
string localdomain = CommonLib.Common.GetConfigString("HOST_DOMAIN", "DOMAIN", ""); |
169 |
|
170 |
ViewerDataModel.Instance.IsDocumentHistory = Convert.ToBoolean(CommonLib.Common.GetConfigString("COMMON","IsDocumentHistory", "true")); |
171 |
|
172 |
var hostEntry = CommonLib.DNSHelper.GetHostEntryTask(); |
173 |
|
174 |
if (hostEntry == null) |
175 |
{ |
176 |
System.Diagnostics.Debug.WriteLine("(hostEntry == null"); |
177 |
//App.FileLogger.Debug("hostEntry == null"); |
178 |
isExternal = true; |
179 |
} |
180 |
else if (!string.IsNullOrEmpty(localdomain) && !hostEntry.HostName.ToUpper().EndsWith(localdomain.ToUpper())) |
181 |
{ |
182 |
// 외부 사용자 |
183 |
App.FileLogger.Debug(string.Format("You are external user because located out side of given domain({0})\nYour domain is {1}", localdomain, hostEntry.HostName)); |
184 |
isExternal = true; |
185 |
} |
186 |
#endregion |
187 |
|
188 |
|
189 |
if (e.Args.Count() > 0) |
190 |
{ |
191 |
var result = ParamDecoding(e.Args[0].Replace(@"kcom://", "").Replace(@"/", "")); |
192 |
|
193 |
App.ViewInfo = new IKCOM.ViewInfo |
194 |
{ |
195 |
DocumentItemID = result.DocumentItemID, |
196 |
EnsembleID = result.DocumentItemID, |
197 |
//DocumentItemID = "10001", |
198 |
bPartner = result.bPartner, |
199 |
CreateFinalPDFPermission = result.CreateFinalPDFPermission, |
200 |
NewCommentPermission = result.NewCommentPermission, |
201 |
ProjectNO = result.ProjectNO, |
202 |
UserID = result.UserID, |
203 |
isAdmin = Convert.ToBoolean(result.Mode) |
204 |
//UserID = "H2009115", |
205 |
//Mode = result.Mode |
206 |
}; |
207 |
ParameterMode = true; |
208 |
} |
209 |
else |
210 |
{ |
211 |
string[] strArg = Environment.GetCommandLineArgs(); |
212 |
if (strArg.Length > 1) |
213 |
{ |
214 |
var result = ParamDecoding(strArg[1].Replace(@"kcom://", "").Replace(@"/", "")); |
215 |
App.ViewInfo = new IKCOM.ViewInfo |
216 |
{ |
217 |
DocumentItemID = result.DocumentItemID, |
218 |
EnsembleID = result.DocumentItemID, |
219 |
//DocumentItemID = "10001", |
220 |
bPartner = result.bPartner, |
221 |
CreateFinalPDFPermission = result.CreateFinalPDFPermission, |
222 |
NewCommentPermission = result.NewCommentPermission, |
223 |
ProjectNO = result.ProjectNO, |
224 |
UserID = result.UserID, |
225 |
//UserID = "H2009115", |
226 |
//Mode = 0 , 1 , 2 |
227 |
}; |
228 |
ParameterMode = true; |
229 |
} |
230 |
else |
231 |
{ |
232 |
MessageBox.Show("문서 정보가 입력되지 않았습니다.\n프로그램이 종료됩니다.", "안내"); |
233 |
throw new ArgumentException("문서 정보가 입력되지 않았습니다."); |
234 |
} |
235 |
} |
236 |
|
237 |
//App.ViewInfo.CreateFinalPDFPermission = false; |
238 |
//App.ViewInfo.NewCommentPermission = false; |
239 |
//GetQueryStringParameters(); |
240 |
//_binding = new WSHttpBinding(); |
241 |
//_binding.Security = new WSHttpSecurity { Transport = new HttpTransportSecurity { ClientCredentialType = HttpClientCredentialType.None }, Mode = SecurityMode.Transport }; |
242 |
//_binding.MaxReceivedMessageSize = 2147483647; |
243 |
//_binding.OpenTimeout = new TimeSpan(0, 1, 0); |
244 |
//_binding.ReceiveTimeout = new TimeSpan(0, 10, 0); |
245 |
//_binding.CloseTimeout = new TimeSpan(0, 5, 0); |
246 |
//_binding.SendTimeout = new TimeSpan(0, 5, 0); |
247 |
#if BASIC_BINDING |
248 |
|
249 |
#region 기본 binding |
250 |
BasicHttpBinding basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.None); |
251 |
basicHttpBinding.Security = new BasicHttpSecurity { Transport = new HttpTransportSecurity { ClientCredentialType = HttpClientCredentialType.None, ProxyCredentialType = HttpProxyCredentialType.None }, Mode = BasicHttpSecurityMode.None, Message = new BasicHttpMessageSecurity { AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Basic256, ClientCredentialType = BasicHttpMessageCredentialType.UserName } }; |
252 |
basicHttpBinding.MaxBufferSize = 2147483647; |
253 |
basicHttpBinding.MaxBufferPoolSize = 2147483647; |
254 |
basicHttpBinding.MaxReceivedMessageSize = 2147483647; |
255 |
basicHttpBinding.OpenTimeout = new TimeSpan(4, 30, 0); |
256 |
basicHttpBinding.ReceiveTimeout = new TimeSpan(4, 30, 0); |
257 |
basicHttpBinding.CloseTimeout = new TimeSpan(4, 30, 0); |
258 |
basicHttpBinding.SendTimeout = new TimeSpan(4, 30, 0); |
259 |
basicHttpBinding.TextEncoding = System.Text.Encoding.UTF8; |
260 |
basicHttpBinding.TransferMode = TransferMode.Buffered; |
261 |
basicHttpBinding.MessageEncoding = WSMessageEncoding.Text; |
262 |
basicHttpBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; |
263 |
|
264 |
|
265 |
//System.ServiceModel.Channels.ReliableSessionBindingElement reliableSession = new System.ServiceModel.Channels.ReliableSessionBindingElement(); |
266 |
//reliableSession.Ordered = true; |
267 |
//reliableSession.MaxRetryCount = 3; |
268 |
//basicHttpBinding.CreateBindingElements().Add(reliableSession); |
269 |
//basicHttpBinding.ProxyAddress = null; |
270 |
//basicHttpBinding.AllowCookies = false; |
271 |
//basicHttpBinding.BypassProxyOnLocal = false; |
272 |
//basicHttpBinding.UseDefaultWebProxy = false; |
273 |
//basicHttpBinding.ProxyAddress = new Uri("Http://localhost:8888"); |
274 |
|
275 |
_binding = basicHttpBinding; |
276 |
|
277 |
//System.ServiceModel.Channels.ReliableSessionBindingElement reliableSession = new System.ServiceModel.Channels.ReliableSessionBindingElement(); |
278 |
//reliableSession.Ordered = true; |
279 |
|
280 |
//System.ServiceModel.Channels.HttpTransportBindingElement httpTransport = new System.ServiceModel.Channels.HttpTransportBindingElement(); |
281 |
//httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous; |
282 |
//httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; |
283 |
//System.ServiceModel.Channels.CustomBinding binding = new System.ServiceModel.Channels.CustomBinding(reliableSession, httpTransport); |
284 |
#endregion |
285 |
#elif _CUSTOM_BINDING |
286 |
#region custombinding |
287 |
var customBinding = new System.ServiceModel.Channels.CustomBinding() |
288 |
{ |
289 |
OpenTimeout = new TimeSpan(0, 30, 0), |
290 |
ReceiveTimeout = new TimeSpan(0, 30, 0), |
291 |
CloseTimeout = new TimeSpan(0, 30, 0), |
292 |
SendTimeout = new TimeSpan(0, 30, 0), |
293 |
}; |
294 |
|
295 |
//var messageEncoding = new WcfExtensions.ServiceModel.Channels.CompressionBindingElement(); |
296 |
//messageEncoding.Level = WcfExtensions.ServiceModel.Channels.CompressionLevel.Maximum; |
297 |
|
298 |
var httpTranport = new System.ServiceModel.Channels.HttpsTransportBindingElement |
299 |
{ |
300 |
MaxBufferPoolSize = Int32.MaxValue, |
301 |
MaxBufferSize = Int32.MaxValue, |
302 |
MaxReceivedMessageSize = Int32.MaxValue, |
303 |
RequestInitializationTimeout = new TimeSpan(0, 30, 0), |
304 |
//UseDefaultWebProxy = false, |
305 |
//ProxyAddress = new Uri("Http://127.0.0.1:8888") |
306 |
}; |
307 |
|
308 |
customBinding.CreateBindingElements(); |
309 |
//customBinding.Elements.Add(messageEncoding); |
310 |
customBinding.Elements.Add(httpTranport); |
311 |
|
312 |
|
313 |
_binding = customBinding; |
314 |
#endregion |
315 |
|
316 |
#elif CUSTOM_BINDING |
317 |
#region custombinding |
318 |
var customBinding = new System.ServiceModel.Channels.CustomBinding() |
319 |
{ |
320 |
OpenTimeout = new TimeSpan(0, 30, 0), |
321 |
ReceiveTimeout = new TimeSpan(0, 30, 0), |
322 |
CloseTimeout = new TimeSpan(0, 30, 0), |
323 |
SendTimeout = new TimeSpan(0, 30, 0), |
324 |
}; |
325 |
|
326 |
//var messageEncoding = new WcfExtensions.ServiceModel.Channels.CompressionBindingElement(); |
327 |
//messageEncoding.Level = WcfExtensions.ServiceModel.Channels.CompressionLevel.Maximum; |
328 |
|
329 |
var httpTranport = new System.ServiceModel.Channels.HttpsTransportBindingElement |
330 |
{ |
331 |
MaxBufferPoolSize = Int32.MaxValue, |
332 |
MaxBufferSize = Int32.MaxValue, |
333 |
MaxReceivedMessageSize = Int32.MaxValue, |
334 |
RequestInitializationTimeout = new TimeSpan(0, 30, 0), |
335 |
//UseDefaultWebProxy = false, |
336 |
//ProxyAddress = new Uri("Http://127.0.0.1:8888") |
337 |
}; |
338 |
|
339 |
customBinding.CreateBindingElements(); |
340 |
|
341 |
var reliableSession = new System.ServiceModel.Channels.ReliableSessionBindingElement(); |
342 |
|
343 |
var encoding = new System.ServiceModel.Channels.TextMessageEncodingBindingElement |
344 |
{ |
345 |
MaxReadPoolSize = Int32.MaxValue, |
346 |
MaxWritePoolSize = Int32.MaxValue, |
347 |
MessageVersion = System.ServiceModel.Channels.MessageVersion.Soap12WSAddressing10, |
348 |
WriteEncoding = System.Text.Encoding.UTF8, |
349 |
ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas |
350 |
{ |
351 |
MaxArrayLength = Int32.MaxValue, |
352 |
MaxBytesPerRead = Int32.MaxValue, |
353 |
MaxDepth = Int32.MaxValue, |
354 |
MaxNameTableCharCount = Int32.MaxValue, |
355 |
MaxStringContentLength = Int32.MaxValue |
356 |
} |
357 |
}; |
358 |
//reliableSession.Ordered = true; // Set other properties as needed |
359 |
customBinding.Elements.Add(reliableSession); |
360 |
//customBinding.Elements.Add(messageEncoding); |
361 |
//customBinding.Elements.Add(encoding); |
362 |
customBinding.Elements.Add(httpTranport); |
363 |
|
364 |
_binding = customBinding; |
365 |
#endregion |
366 |
|
367 |
#else |
368 |
|
369 |
#region 기본 binding |
370 |
//BasicHttpBinding basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.None); |
371 |
//basicHttpBinding.Security = new BasicHttpSecurity { Transport = new HttpTransportSecurity { ClientCredentialType = HttpClientCredentialType.None, ProxyCredentialType = HttpProxyCredentialType.None }, Mode = BasicHttpSecurityMode.None, Message = new BasicHttpMessageSecurity { AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Basic256, ClientCredentialType = BasicHttpMessageCredentialType.UserName } }; |
372 |
//basicHttpBinding.MaxBufferSize = 2147483647; |
373 |
//basicHttpBinding.MaxBufferPoolSize = 2147483647; |
374 |
//basicHttpBinding.MaxReceivedMessageSize = 2147483647; |
375 |
//basicHttpBinding.OpenTimeout = new TimeSpan(4, 30, 0); |
376 |
//basicHttpBinding.ReceiveTimeout = new TimeSpan(4, 30, 0); |
377 |
//basicHttpBinding.CloseTimeout = new TimeSpan(4, 30, 0); |
378 |
//basicHttpBinding.SendTimeout = new TimeSpan(4, 30, 0); |
379 |
//basicHttpBinding.TextEncoding = System.Text.Encoding.UTF8; |
380 |
//basicHttpBinding.TransferMode = TransferMode.Buffered; |
381 |
//basicHttpBinding.MessageEncoding = WSMessageEncoding.Text; |
382 |
//basicHttpBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; |
383 |
|
384 |
|
385 |
//System.ServiceModel.Channels.ReliableSessionBindingElement reliableSession = new System.ServiceModel.Channels.ReliableSessionBindingElement(); |
386 |
//reliableSession.Ordered = true; |
387 |
//reliableSession.MaxRetryCount = 3; |
388 |
//basicHttpBinding.CreateBindingElements().Add(reliableSession); |
389 |
|
390 |
//_binding = basicHttpBinding; |
391 |
#endregion |
392 |
#endif |
393 |
|
394 |
//Support.SetLicense(); |
395 |
|
396 |
#if DEBUG |
397 |
//sBaseServiceURL = CommonLib.Common.GetConfigString("BaseClientAddress", "URL", "", isExternal); |
398 |
System.Diagnostics.Debug.WriteLine("sBaseServiceURL"); |
399 |
BaseAddress = CommonLib.Common.GetConfigString("BaseClientAddress", "URL", "", isExternal); |
400 |
#else |
401 |
BaseAddress = CommonLib.Common.GetConfigString("BaseClientAddress", "URL", "", isExternal); |
402 |
#endif |
403 |
|
404 |
if (isAuthenticate) |
405 |
{ |
406 |
App.AuthenticateToken = Authenticate(BaseAddress); |
407 |
} |
408 |
|
409 |
var UploadAddress = CommonLib.Common.GetConfigString("KCOM_kr_co_devdoftech_cloud_FileUpload", "URL", ""); |
410 |
|
411 |
if (!string.IsNullOrWhiteSpace(UploadAddress) && !string.IsNullOrWhiteSpace(BaseAddress)) |
412 |
{ |
413 |
var uploadUri = new UriBuilder(UploadAddress); |
414 |
var baseUri = new UriBuilder(BaseAddress); |
415 |
|
416 |
uploadUri.Host = baseUri.Host; |
417 |
uploadUri.Port = baseUri.Port; |
418 |
|
419 |
FileUploadUri = uploadUri.ToString(); |
420 |
} |
421 |
#if BASIC_BINDING |
422 |
_EndPoint = new EndpointAddress(string.Format("{0}/ServiceDeepView.svc", BaseAddress)); |
423 |
#elif CUSTOM_BINDING |
424 |
_EndPoint = new EndpointAddress(string.Format("{0}/ServiceDeepView.svc", BaseAddress)); |
425 |
|
426 |
#else |
427 |
_EndPoint = new EndpointAddress(string.Format("{0}/ServiceDeepView.svc", BaseAddress)); |
428 |
#endif |
429 |
|
430 |
App.FileLogger.Debug(_EndPoint.Uri); |
431 |
|
432 |
#if !DEBUG |
433 |
#endif |
434 |
//var license = new License.Validator.Valid(BaseAddress + "/License"); |
435 |
|
436 |
//license.ValidateError += License_ValidateError; |
437 |
|
438 |
//license.GetLicense("public.xml"); |
439 |
|
440 |
//if (license.Activate()) |
441 |
//{ |
442 |
|
443 |
//} |
444 |
//else |
445 |
//{ |
446 |
|
447 |
//} |
448 |
|
449 |
|
450 |
await SplashScreenAsnyc(); |
451 |
|
452 |
base.OnStartup(e); |
453 |
System.Windows.Input.Keyboard.AddPreviewKeyDownHandler(this.MainWindow, KeyDownEvent); |
454 |
|
455 |
|
456 |
//System.Windows.Input.Keyboard.AddKeyDownHandler(this.MainWindow, KeyDownEvent); |
457 |
} |
458 |
catch (Exception ex) |
459 |
{ |
460 |
Logger.sendReqLog("OnStartUp",ex.ToString() + " " + ex.InnerException?.ToString(),1); |
461 |
} |
462 |
finally |
463 |
{ |
464 |
await SplashScreenAsnyc(); |
465 |
} |
466 |
} |
467 |
|
468 |
|
469 |
private string Authenticate(string baseUri) |
470 |
{ |
471 |
string result = null; |
472 |
|
473 |
try |
474 |
{ |
475 |
Uri uri = new Uri(baseUri); |
476 |
string baseUrl = uri.Scheme + "://" + uri.Host + (uri.IsDefaultPort ? "" : ":" + uri.Port); |
477 |
|
478 |
using (System.Net.WebClient client = new System.Net.WebClient()) |
479 |
{ |
480 |
client.Headers.Add(HttpRequestHeader.Authorization, "!dsfadsfa@@~"); |
481 |
var response = client.DownloadString(baseUrl + "/Authenticate"); |
482 |
|
483 |
if (response != null) |
484 |
{ |
485 |
result = response; |
486 |
} |
487 |
} |
488 |
} |
489 |
catch (Exception) |
490 |
{ |
491 |
|
492 |
throw; |
493 |
} |
494 |
|
495 |
return result; |
496 |
} |
497 |
|
498 |
private void License_ValidateError(object sender, ValidateErrorArgs e) |
499 |
{ |
500 |
e.Received = true; |
501 |
|
502 |
Telerik.Windows.Controls.RadWindow.Alert(new Telerik.Windows.Controls.DialogParameters |
503 |
{ |
504 |
Content = "License Error : " + e.Message, |
505 |
Owner = splashScreen |
506 |
}); |
507 |
///MessageBox.Show(e.Message); |
508 |
Application.Current.Shutdown(); |
509 |
} |
510 |
|
511 |
private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) |
512 |
{ |
513 |
Logger.sendReqLog("App Error ",e.Exception.ToString() + " " + e.Exception.InnerException?.ToString(), 1); |
514 |
} |
515 |
|
516 |
private void KeyDownEvent(object sender, KeyEventArgs e) |
517 |
{ |
518 |
//if (e.Key == Key.Escape || e.Key == Key.Delete) |
519 |
//{ |
520 |
System.Diagnostics.Debug.WriteLine("app key Event"); |
521 |
Common.ViewerDataModel.Instance.SystemMain.KeyEventDownAction(sender, e); |
522 |
//} |
523 |
} |
524 |
|
525 |
private async Task<bool> SplashScreenAsnyc() |
526 |
{ |
527 |
int value = 100 / ISplashMessage.SplashMessageCnt; |
528 |
|
529 |
for (int i = 1; i < ISplashMessage.SplashMessageCnt; i++) |
530 |
{ |
531 |
await Task.Delay(1); |
532 |
await splashScreen.Dispatcher.InvokeAsync(() => splashScreen.Progress = i * value); |
533 |
} |
534 |
|
535 |
//splashScreen.Close(); |
536 |
|
537 |
return true; |
538 |
} |
539 |
|
540 |
public static void splashString(string text) |
541 |
{ |
542 |
Task.Factory.StartNew(() => |
543 |
{ |
544 |
splashScreen.Dispatcher.Invoke(() => splashScreen.SplashText = text); |
545 |
}).ConfigureAwait(false); |
546 |
} |
547 |
|
548 |
|
549 |
/// <summary> |
550 |
/// log unhandled exception |
551 |
/// </summary> |
552 |
/// <author>humkyung</author> |
553 |
/// <date>2019.05.21</date> |
554 |
/// <param name="sender"></param> |
555 |
/// <param name="e"></param> |
556 |
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) |
557 |
{ |
558 |
try |
559 |
{ |
560 |
App.FileLogger.Fatal(e.ExceptionObject as Exception); |
561 |
} |
562 |
catch (Exception ex) |
563 |
{ |
564 |
Console.WriteLine(ex.InnerException?.ToString()); |
565 |
} |
566 |
finally |
567 |
{ |
568 |
#if RELEASE |
569 |
Environment.Exit(0); |
570 |
#endif |
571 |
} |
572 |
} |
573 |
|
574 |
private void ErrorLogFileWrite(string Err) |
575 |
{ |
576 |
App.FileLogger.Debug(Err); |
577 |
} |
578 |
} |
579 |
} |