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
|
#if DEBUG
|
194
|
/*
|
195
|
ViewerDataModel.Instance.IsDocumentHistory = true;
|
196
|
result.DocumentItemID = "3712215963";
|
197
|
result.ProjectNO = "00000";
|
198
|
result.UserID = "user1";
|
199
|
doftech
|
200
|
* humkyung
|
201
|
P190111_qa03
|
202
|
P190111_qa04
|
203
|
P190111_sa03
|
204
|
P190111_sa04
|
205
|
P190111_sa05
|
206
|
user1
|
207
|
*/
|
208
|
#endif
|
209
|
|
210
|
App.ViewInfo = new IKCOM.ViewInfo
|
211
|
{
|
212
|
DocumentItemID = result.DocumentItemID,
|
213
|
EnsembleID = result.DocumentItemID,
|
214
|
//DocumentItemID = "10001",
|
215
|
bPartner = result.bPartner,
|
216
|
CreateFinalPDFPermission = result.CreateFinalPDFPermission,
|
217
|
NewCommentPermission = result.NewCommentPermission,
|
218
|
ProjectNO = result.ProjectNO,
|
219
|
UserID = result.UserID,
|
220
|
isAdmin = Convert.ToBoolean(result.Mode)
|
221
|
//UserID = "H2009115",
|
222
|
//Mode = result.Mode
|
223
|
};
|
224
|
ParameterMode = true;
|
225
|
}
|
226
|
else
|
227
|
{
|
228
|
string[] strArg = Environment.GetCommandLineArgs();
|
229
|
if (strArg.Length > 1)
|
230
|
{
|
231
|
var result = ParamDecoding(strArg[1].Replace(@"kcom://", "").Replace(@"/", ""));
|
232
|
App.ViewInfo = new IKCOM.ViewInfo
|
233
|
{
|
234
|
DocumentItemID = result.DocumentItemID,
|
235
|
EnsembleID = result.DocumentItemID,
|
236
|
//DocumentItemID = "10001",
|
237
|
bPartner = result.bPartner,
|
238
|
CreateFinalPDFPermission = result.CreateFinalPDFPermission,
|
239
|
NewCommentPermission = result.NewCommentPermission,
|
240
|
ProjectNO = result.ProjectNO,
|
241
|
UserID = result.UserID,
|
242
|
//UserID = "H2009115",
|
243
|
//Mode = 0 , 1 , 2
|
244
|
};
|
245
|
ParameterMode = true;
|
246
|
}
|
247
|
else
|
248
|
{
|
249
|
MessageBox.Show("문서 정보가 입력되지 않았습니다.\n프로그램이 종료됩니다.", "안내");
|
250
|
throw new ArgumentException("문서 정보가 입력되지 않았습니다.");
|
251
|
}
|
252
|
}
|
253
|
|
254
|
//App.ViewInfo.CreateFinalPDFPermission = false;
|
255
|
//App.ViewInfo.NewCommentPermission = false;
|
256
|
//GetQueryStringParameters();
|
257
|
//_binding = new WSHttpBinding();
|
258
|
//_binding.Security = new WSHttpSecurity { Transport = new HttpTransportSecurity { ClientCredentialType = HttpClientCredentialType.None }, Mode = SecurityMode.Transport };
|
259
|
//_binding.MaxReceivedMessageSize = 2147483647;
|
260
|
//_binding.OpenTimeout = new TimeSpan(0, 1, 0);
|
261
|
//_binding.ReceiveTimeout = new TimeSpan(0, 10, 0);
|
262
|
//_binding.CloseTimeout = new TimeSpan(0, 5, 0);
|
263
|
//_binding.SendTimeout = new TimeSpan(0, 5, 0);
|
264
|
#if BASIC_BINDING
|
265
|
|
266
|
#region 기본 binding
|
267
|
BasicHttpBinding basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.None);
|
268
|
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 } };
|
269
|
basicHttpBinding.MaxBufferSize = 2147483647;
|
270
|
basicHttpBinding.MaxBufferPoolSize = 2147483647;
|
271
|
basicHttpBinding.MaxReceivedMessageSize = 2147483647;
|
272
|
basicHttpBinding.OpenTimeout = new TimeSpan(4, 30, 0);
|
273
|
basicHttpBinding.ReceiveTimeout = new TimeSpan(4, 30, 0);
|
274
|
basicHttpBinding.CloseTimeout = new TimeSpan(4, 30, 0);
|
275
|
basicHttpBinding.SendTimeout = new TimeSpan(4, 30, 0);
|
276
|
basicHttpBinding.TextEncoding = System.Text.Encoding.UTF8;
|
277
|
basicHttpBinding.TransferMode = TransferMode.Buffered;
|
278
|
basicHttpBinding.MessageEncoding = WSMessageEncoding.Text;
|
279
|
basicHttpBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
|
280
|
|
281
|
|
282
|
//System.ServiceModel.Channels.ReliableSessionBindingElement reliableSession = new System.ServiceModel.Channels.ReliableSessionBindingElement();
|
283
|
//reliableSession.Ordered = true;
|
284
|
//reliableSession.MaxRetryCount = 3;
|
285
|
//basicHttpBinding.CreateBindingElements().Add(reliableSession);
|
286
|
//basicHttpBinding.ProxyAddress = null;
|
287
|
//basicHttpBinding.AllowCookies = false;
|
288
|
//basicHttpBinding.BypassProxyOnLocal = false;
|
289
|
//basicHttpBinding.UseDefaultWebProxy = false;
|
290
|
//basicHttpBinding.ProxyAddress = new Uri("Http://localhost:8888");
|
291
|
|
292
|
_binding = basicHttpBinding;
|
293
|
|
294
|
//System.ServiceModel.Channels.ReliableSessionBindingElement reliableSession = new System.ServiceModel.Channels.ReliableSessionBindingElement();
|
295
|
//reliableSession.Ordered = true;
|
296
|
|
297
|
//System.ServiceModel.Channels.HttpTransportBindingElement httpTransport = new System.ServiceModel.Channels.HttpTransportBindingElement();
|
298
|
//httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous;
|
299
|
//httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
|
300
|
//System.ServiceModel.Channels.CustomBinding binding = new System.ServiceModel.Channels.CustomBinding(reliableSession, httpTransport);
|
301
|
#endregion
|
302
|
#elif _CUSTOM_BINDING
|
303
|
#region custombinding
|
304
|
var customBinding = new System.ServiceModel.Channels.CustomBinding()
|
305
|
{
|
306
|
OpenTimeout = new TimeSpan(0, 30, 0),
|
307
|
ReceiveTimeout = new TimeSpan(0, 30, 0),
|
308
|
CloseTimeout = new TimeSpan(0, 30, 0),
|
309
|
SendTimeout = new TimeSpan(0, 30, 0),
|
310
|
};
|
311
|
|
312
|
//var messageEncoding = new WcfExtensions.ServiceModel.Channels.CompressionBindingElement();
|
313
|
//messageEncoding.Level = WcfExtensions.ServiceModel.Channels.CompressionLevel.Maximum;
|
314
|
|
315
|
var httpTranport = new System.ServiceModel.Channels.HttpsTransportBindingElement
|
316
|
{
|
317
|
MaxBufferPoolSize = Int32.MaxValue,
|
318
|
MaxBufferSize = Int32.MaxValue,
|
319
|
MaxReceivedMessageSize = Int32.MaxValue,
|
320
|
RequestInitializationTimeout = new TimeSpan(0, 30, 0),
|
321
|
//UseDefaultWebProxy = false,
|
322
|
//ProxyAddress = new Uri("Http://127.0.0.1:8888")
|
323
|
};
|
324
|
|
325
|
customBinding.CreateBindingElements();
|
326
|
//customBinding.Elements.Add(messageEncoding);
|
327
|
customBinding.Elements.Add(httpTranport);
|
328
|
|
329
|
|
330
|
_binding = customBinding;
|
331
|
#endregion
|
332
|
|
333
|
#elif CUSTOM_BINDING
|
334
|
#region custombinding
|
335
|
var customBinding = new System.ServiceModel.Channels.CustomBinding()
|
336
|
{
|
337
|
OpenTimeout = new TimeSpan(0, 30, 0),
|
338
|
ReceiveTimeout = new TimeSpan(0, 30, 0),
|
339
|
CloseTimeout = new TimeSpan(0, 30, 0),
|
340
|
SendTimeout = new TimeSpan(0, 30, 0),
|
341
|
};
|
342
|
|
343
|
//var messageEncoding = new WcfExtensions.ServiceModel.Channels.CompressionBindingElement();
|
344
|
//messageEncoding.Level = WcfExtensions.ServiceModel.Channels.CompressionLevel.Maximum;
|
345
|
|
346
|
var httpTranport = new System.ServiceModel.Channels.HttpsTransportBindingElement
|
347
|
{
|
348
|
MaxBufferPoolSize = Int32.MaxValue,
|
349
|
MaxBufferSize = Int32.MaxValue,
|
350
|
MaxReceivedMessageSize = Int32.MaxValue,
|
351
|
RequestInitializationTimeout = new TimeSpan(0, 30, 0),
|
352
|
//UseDefaultWebProxy = false,
|
353
|
//ProxyAddress = new Uri("Http://127.0.0.1:8888")
|
354
|
};
|
355
|
|
356
|
customBinding.CreateBindingElements();
|
357
|
|
358
|
var reliableSession = new System.ServiceModel.Channels.ReliableSessionBindingElement();
|
359
|
|
360
|
var encoding = new System.ServiceModel.Channels.TextMessageEncodingBindingElement
|
361
|
{
|
362
|
MaxReadPoolSize = Int32.MaxValue,
|
363
|
MaxWritePoolSize = Int32.MaxValue,
|
364
|
MessageVersion = System.ServiceModel.Channels.MessageVersion.Soap12WSAddressing10,
|
365
|
WriteEncoding = System.Text.Encoding.UTF8,
|
366
|
ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas
|
367
|
{
|
368
|
MaxArrayLength = Int32.MaxValue,
|
369
|
MaxBytesPerRead = Int32.MaxValue,
|
370
|
MaxDepth = Int32.MaxValue,
|
371
|
MaxNameTableCharCount = Int32.MaxValue,
|
372
|
MaxStringContentLength = Int32.MaxValue
|
373
|
}
|
374
|
};
|
375
|
//reliableSession.Ordered = true; // Set other properties as needed
|
376
|
customBinding.Elements.Add(reliableSession);
|
377
|
//customBinding.Elements.Add(messageEncoding);
|
378
|
//customBinding.Elements.Add(encoding);
|
379
|
customBinding.Elements.Add(httpTranport);
|
380
|
|
381
|
_binding = customBinding;
|
382
|
#endregion
|
383
|
|
384
|
#else
|
385
|
|
386
|
#region 기본 binding
|
387
|
//BasicHttpBinding basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.None);
|
388
|
//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 } };
|
389
|
//basicHttpBinding.MaxBufferSize = 2147483647;
|
390
|
//basicHttpBinding.MaxBufferPoolSize = 2147483647;
|
391
|
//basicHttpBinding.MaxReceivedMessageSize = 2147483647;
|
392
|
//basicHttpBinding.OpenTimeout = new TimeSpan(4, 30, 0);
|
393
|
//basicHttpBinding.ReceiveTimeout = new TimeSpan(4, 30, 0);
|
394
|
//basicHttpBinding.CloseTimeout = new TimeSpan(4, 30, 0);
|
395
|
//basicHttpBinding.SendTimeout = new TimeSpan(4, 30, 0);
|
396
|
//basicHttpBinding.TextEncoding = System.Text.Encoding.UTF8;
|
397
|
//basicHttpBinding.TransferMode = TransferMode.Buffered;
|
398
|
//basicHttpBinding.MessageEncoding = WSMessageEncoding.Text;
|
399
|
//basicHttpBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
|
400
|
|
401
|
|
402
|
//System.ServiceModel.Channels.ReliableSessionBindingElement reliableSession = new System.ServiceModel.Channels.ReliableSessionBindingElement();
|
403
|
//reliableSession.Ordered = true;
|
404
|
//reliableSession.MaxRetryCount = 3;
|
405
|
//basicHttpBinding.CreateBindingElements().Add(reliableSession);
|
406
|
|
407
|
//_binding = basicHttpBinding;
|
408
|
#endregion
|
409
|
#endif
|
410
|
|
411
|
//Support.SetLicense();
|
412
|
|
413
|
#if DEBUG
|
414
|
//sBaseServiceURL = CommonLib.Common.GetConfigString("BaseClientAddress", "URL", "", isExternal);
|
415
|
System.Diagnostics.Debug.WriteLine("BaseServiceURL");
|
416
|
BaseAddress = CommonLib.Common.GetConfigString("BaseClientAddress", "URL", "", isExternal);
|
417
|
#else
|
418
|
BaseAddress = CommonLib.Common.GetConfigString("BaseClientAddress", "URL", "", isExternal);
|
419
|
#endif
|
420
|
|
421
|
if (isAuthenticate)
|
422
|
{
|
423
|
App.AuthenticateToken = Authenticate(BaseAddress);
|
424
|
}
|
425
|
|
426
|
var UploadAddress = CommonLib.Common.GetConfigString("KCOM_kr_co_devdoftech_cloud_FileUpload", "URL", "");
|
427
|
|
428
|
if (!string.IsNullOrWhiteSpace(UploadAddress) && !string.IsNullOrWhiteSpace(BaseAddress))
|
429
|
{
|
430
|
var uploadUri = new UriBuilder(UploadAddress);
|
431
|
var baseUri = new UriBuilder(BaseAddress);
|
432
|
|
433
|
uploadUri.Host = baseUri.Host;
|
434
|
uploadUri.Port = baseUri.Port;
|
435
|
|
436
|
FileUploadUri = uploadUri.ToString();
|
437
|
}
|
438
|
#if BASIC_BINDING
|
439
|
_EndPoint = new EndpointAddress(string.Format("{0}/ServiceDeepView.svc", BaseAddress));
|
440
|
#elif CUSTOM_BINDING
|
441
|
_EndPoint = new EndpointAddress(string.Format("{0}/ServiceDeepView.svc", BaseAddress));
|
442
|
|
443
|
#else
|
444
|
_EndPoint = new EndpointAddress(string.Format("{0}/ServiceDeepView.svc", BaseAddress));
|
445
|
#endif
|
446
|
|
447
|
App.FileLogger.Debug(_EndPoint.Uri);
|
448
|
|
449
|
#if !DEBUG
|
450
|
#endif
|
451
|
//var license = new License.Validator.Valid(BaseAddress + "/License");
|
452
|
|
453
|
//license.ValidateError += License_ValidateError;
|
454
|
|
455
|
//license.GetLicense("public.xml");
|
456
|
|
457
|
//if (license.Activate())
|
458
|
//{
|
459
|
|
460
|
//}
|
461
|
//else
|
462
|
//{
|
463
|
|
464
|
//}
|
465
|
|
466
|
|
467
|
await SplashScreenAsnyc();
|
468
|
|
469
|
base.OnStartup(e);
|
470
|
System.Windows.Input.Keyboard.AddPreviewKeyDownHandler(this.MainWindow, KeyDownEvent);
|
471
|
|
472
|
|
473
|
//System.Windows.Input.Keyboard.AddKeyDownHandler(this.MainWindow, KeyDownEvent);
|
474
|
}
|
475
|
catch (Exception ex)
|
476
|
{
|
477
|
Logger.sendReqLog("OnStartUp",ex.ToString() + " " + ex.InnerException?.ToString(),1);
|
478
|
}
|
479
|
finally
|
480
|
{
|
481
|
await SplashScreenAsnyc();
|
482
|
}
|
483
|
}
|
484
|
|
485
|
|
486
|
private string Authenticate(string baseUri)
|
487
|
{
|
488
|
string result = null;
|
489
|
|
490
|
try
|
491
|
{
|
492
|
Uri uri = new Uri(baseUri);
|
493
|
string baseUrl = uri.Scheme + "://" + uri.Host + (uri.IsDefaultPort ? "" : ":" + uri.Port);
|
494
|
|
495
|
using (System.Net.WebClient client = new System.Net.WebClient())
|
496
|
{
|
497
|
client.Headers.Add(HttpRequestHeader.Authorization, "!dsfadsfa@@~");
|
498
|
var response = client.DownloadString(baseUrl + "/Authenticate");
|
499
|
|
500
|
if (response != null)
|
501
|
{
|
502
|
result = response;
|
503
|
}
|
504
|
}
|
505
|
}
|
506
|
catch (Exception)
|
507
|
{
|
508
|
|
509
|
throw;
|
510
|
}
|
511
|
|
512
|
return result;
|
513
|
}
|
514
|
|
515
|
private void License_ValidateError(object sender, ValidateErrorArgs e)
|
516
|
{
|
517
|
e.Received = true;
|
518
|
|
519
|
Telerik.Windows.Controls.RadWindow.Alert(new Telerik.Windows.Controls.DialogParameters
|
520
|
{
|
521
|
Content = "License Error : " + e.Message,
|
522
|
Owner = splashScreen
|
523
|
});
|
524
|
///MessageBox.Show(e.Message);
|
525
|
Application.Current.Shutdown();
|
526
|
}
|
527
|
|
528
|
private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
|
529
|
{
|
530
|
Logger.sendReqLog("App Error ",e.Exception.ToString() + " " + e.Exception.InnerException?.ToString(), 1);
|
531
|
}
|
532
|
|
533
|
private void KeyDownEvent(object sender, KeyEventArgs e)
|
534
|
{
|
535
|
//if (e.Key == Key.Escape || e.Key == Key.Delete)
|
536
|
//{
|
537
|
System.Diagnostics.Debug.WriteLine("app key Event");
|
538
|
Common.ViewerDataModel.Instance.SystemMain.KeyEventDownAction(sender, e);
|
539
|
//}
|
540
|
}
|
541
|
|
542
|
private async Task<bool> SplashScreenAsnyc()
|
543
|
{
|
544
|
int value = 100 / ISplashMessage.SplashMessageCnt;
|
545
|
|
546
|
for (int i = 1; i < ISplashMessage.SplashMessageCnt; i++)
|
547
|
{
|
548
|
await Task.Delay(1);
|
549
|
await splashScreen.Dispatcher.InvokeAsync(() => splashScreen.Progress = i * value);
|
550
|
}
|
551
|
|
552
|
//splashScreen.Close();
|
553
|
|
554
|
return true;
|
555
|
}
|
556
|
|
557
|
public static void splashString(string text)
|
558
|
{
|
559
|
Task.Factory.StartNew(() =>
|
560
|
{
|
561
|
splashScreen.Dispatcher.Invoke(() => splashScreen.SplashText = text);
|
562
|
}).ConfigureAwait(false);
|
563
|
}
|
564
|
|
565
|
|
566
|
/// <summary>
|
567
|
/// log unhandled exception
|
568
|
/// </summary>
|
569
|
/// <author>humkyung</author>
|
570
|
/// <date>2019.05.21</date>
|
571
|
/// <param name="sender"></param>
|
572
|
/// <param name="e"></param>
|
573
|
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
574
|
{
|
575
|
try
|
576
|
{
|
577
|
App.FileLogger.Fatal(e.ExceptionObject as Exception);
|
578
|
}
|
579
|
catch (Exception ex)
|
580
|
{
|
581
|
Console.WriteLine(ex.InnerException?.ToString());
|
582
|
}
|
583
|
finally
|
584
|
{
|
585
|
#if RELEASE
|
586
|
Environment.Exit(0);
|
587
|
#endif
|
588
|
}
|
589
|
}
|
590
|
|
591
|
private void ErrorLogFileWrite(string Err)
|
592
|
{
|
593
|
App.FileLogger.Debug(Err);
|
594
|
}
|
595
|
}
|
596
|
}
|