프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / KCOM / App.xaml.cs @ 5622deac

이력 | 보기 | 이력해설 | 다운로드 (23.4 KB)

1 787a4489 KangIngu

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