프로젝트

일반

사용자정보

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

markus / KCOM / App.xaml.cs @ a1e2ba68

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

1 787a4489 KangIngu

2 af22332b ljiyeon
using KCOM.Common;
3 b60e844d taeseongkim
using KCOM.Views;
4
using log4net;
5 787a4489 KangIngu
using System;
6
using System.ComponentModel;
7 c4a4d59c ljiyeon
using System.IO;
8 787a4489 KangIngu
using System.Linq;
9
using System.ServiceModel;
10 cf2671a6 ljiyeon
using System.Threading.Tasks;
11 b60e844d taeseongkim
using System.Windows;
12 fa48eb85 taeseongkim
using System.Windows.Input;
13 902faaea taeseongkim
using System.Windows.Resources;
14 787a4489 KangIngu
15
namespace KCOM
16
{
17
    public class OpenProperties
18
    {
19
        public string DocumentItemID { get; set; }
20
        public bool bPartner { get; set; }
21
        public bool CreateFinalPDFPermission { get; set; }
22
        public bool NewCommentPermission { get; set; }
23
        public string ProjectNO { get; set; }
24
        public string UserID { get; set; }
25
        public int Mode { get; set; }
26
    }
27
    /// <summary>
28
    /// App.xaml에 대한 상호 작용 논리
29
    /// </summary>
30
    public partial class App : Application
31
    {
32 eeb0a39c taeseongkim
        public static PageManager.PageStorage PageStorage;
33 a1e2ba68 taeseongkim
        public static string MarkusVersion = "";
34 76dc223b taeseongkim
        public static string BaseAddress;
35
        public static string FileUploadUri;
36 a7578175 taeseongkim
        public static BasicHttpBinding _binding;
37 787a4489 KangIngu
        public static EndpointAddress _EndPoint;
38
        public static EndpointAddress _EndPoint_SaveLoad;
39
        public static EndpointAddress _EndPoint_Symbol;
40
        public static string UserID;
41
        public static string UserName;
42
        public static string UserIP;
43
        public static IKCOM.ViewInfo ViewInfo;
44
        public static string urlHost;
45
        public static string urlPort;
46
        public static string urlHost_DB;
47
        public static string urlPort_DB;
48
        public static string Custom_ViewInfoId;
49
        public static bool ParameterMode = false;
50 84c48033 djkim
        public static bool isExternal = false;
51 787a4489 KangIngu
52 a7346d3c humkyung
        /// <summary>
53
        /// logger
54
        /// </summary>
55 ce3f0d7a humkyung
        public static ILog FileLogger = null;
56 902faaea taeseongkim
        
57
        public static StreamResourceInfo DefaultArrowCursor;
58
59
        public static Stream DefaultArrowCursorStream
60
        {
61
            get {
62 9d5b4bc2 taeseongkim
                return Application.GetResourceStream(new Uri(@"pack://application:,,,/Resources/Cursor/customCursor2.cur", UriKind.Absolute)).Stream;
63
                //DefaultArrowCursor.Stream.Position = 0;
64
                //return DefaultArrowCursor.Stream;
65 902faaea taeseongkim
            }
66
        }
67 a7346d3c humkyung
68 76dc223b taeseongkim
        public static kr.co.devdoftech.cloud.FileUpload FileUploader
69
        {
70
            get { return new kr.co.devdoftech.cloud.FileUpload{ Url = FileUploadUri }; }
71
72
            private set {; }
73
        }
74
75 a7346d3c humkyung
        /// <summary>
76 2089959a taeseongkim
        /// VisualStudio Design Time여부
77
        /// </summary>
78
        public static bool IsDesignMode
79
        {
80
            get
81
            {
82
                try
83
                {
84
                    return DesignerProperties.GetIsInDesignMode(new DependencyObject());
85
                }
86
                catch (Exception)
87
                {
88
                    return false;
89
                }
90
            }
91
            private set { }
92
        }
93
94
        /// <summary>
95 a7346d3c humkyung
        /// Application Data Folder
96
        /// </summary>
97
        public static string AppDataFolder
98
        {
99
            get
100
            {
101
                return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MARKUS");
102
            }
103
        }
104 787a4489 KangIngu
105
        public static IKCOM.KCOM_SystemInfo SystemInfo { get; set; }
106 1137be84 djkim
107 264c9309 ljiyeon
108 787a4489 KangIngu
        private static OpenProperties ParamDecoding(string DecodingText, System.Text.Encoding oEncoding = null)
109
        {
110
            if (oEncoding == null)
111
                oEncoding = System.Text.Encoding.UTF8;
112
113
            byte[] byteArray = Convert.FromBase64String(DecodingText);
114
115
            string jsonBack = oEncoding.GetString(byteArray);
116
117
            return Newtonsoft.Json.JsonConvert.DeserializeObject<OpenProperties>(jsonBack);
118
        }
119
120 c4a4d59c ljiyeon
        private string versionPath = null;
121 cf2671a6 ljiyeon
        //public SplashScreen splash = new SplashScreen("splash.png");
122 e0cfc73c ljiyeon
        public static SplashScreenWindow splashScreen = new SplashScreenWindow();
123 cdfb57ff taeseongkim
124
        public App()
125
        {
126 aff63364 taeseongkim
            Telerik.Windows.Controls.StyleManager.ApplicationTheme = new Telerik.Windows.Controls.VisualStudio2013Theme();
127 b60e844d taeseongkim
128
            App.FileLogger = LogManager.GetLogger(typeof(App));
129 cdfb57ff taeseongkim
        }
130
131 eeb0a39c taeseongkim
        protected override void OnExit(ExitEventArgs e)
132
        {
133 81908c01 taeseongkim
            try
134
            {
135
                if (App.PageStorage != null)
136
                {
137
                    App.PageStorage.Clear();
138
                }
139
            }
140
            catch (Exception)
141
            {
142
            }
143 eeb0a39c taeseongkim
144
            base.OnExit(e);
145
        }
146
147 cdfb57ff taeseongkim
        protected override async void OnStartup(StartupEventArgs e)
148
        {
149 787a4489 KangIngu
            try
150 a7346d3c humkyung
            {
151 902faaea taeseongkim
                DefaultArrowCursor = Application.GetResourceStream(new Uri(@"pack://application:,,,/Resources/Cursor/customCursor2.cur", UriKind.Absolute));
152
153 cf2671a6 ljiyeon
                splashScreen.Show();
154 1137be84 djkim
155 b60e844d taeseongkim
                App.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
156 a7346d3c humkyung
                /// up to here
157 b60e844d taeseongkim
                //AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
158 a7346d3c humkyung
159 1137be84 djkim
                #region  //  DNS 체크
160
161
                string localdomain = CommonLib.Common.GetConfigString("HOST_DOMAIN", "DOMAIN", "");
162
163 8e6884a5 taeseongkim
                ViewerDataModel.Instance.IsDocumentHistory = Convert.ToBoolean(CommonLib.Common.GetConfigString("COMMON","IsDocumentHistory", "true"));
164
165 1137be84 djkim
                var hostEntry = CommonLib.DNSHelper.GetHostEntryTask();
166 df33d20a djkim
                
167 1137be84 djkim
                if (hostEntry == null)
168
                {
169
                    System.Diagnostics.Debug.WriteLine("(hostEntry == null");
170 664ea2e1 taeseongkim
                    //App.FileLogger.Debug("hostEntry == null");
171 1137be84 djkim
                    isExternal = true;
172
                }
173 ddfd4bc7 djkim
                else if (!string.IsNullOrEmpty(localdomain) && !hostEntry.HostName.ToUpper().EndsWith(localdomain.ToUpper()))
174 1137be84 djkim
                {
175
                    // 외부 사용자
176 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));
177 1137be84 djkim
                    isExternal = true;
178
                }
179
                #endregion
180
181 366f00c2 taeseongkim
182 787a4489 KangIngu
                if (e.Args.Count() > 0)
183
                {
184 c4a4d59c ljiyeon
                    var result = ParamDecoding(e.Args[0].Replace(@"kcom://", "").Replace(@"/", ""));
185 787a4489 KangIngu
                    App.ViewInfo = new IKCOM.ViewInfo
186
                    {
187
                        DocumentItemID = result.DocumentItemID,
188 35afe17c djkim
                        EnsembleID = result.DocumentItemID,
189 787a4489 KangIngu
                        //DocumentItemID = "10001",
190
                        bPartner = result.bPartner,
191 bc664e9b djkim
                        CreateFinalPDFPermission = result.CreateFinalPDFPermission,
192
                        NewCommentPermission = result.NewCommentPermission,
193 787a4489 KangIngu
                        ProjectNO = result.ProjectNO,
194
                        UserID = result.UserID,
195 9d5b4bc2 taeseongkim
                        isAdmin = Convert.ToBoolean(result.Mode)
196 787a4489 KangIngu
                        //UserID = "H2009115",
197 7cf8b728 taeseongkim
                        //Mode = result.Mode
198 787a4489 KangIngu
                    };
199
                    ParameterMode = true;
200 401a87f8 taeseongkim
                } 
201 c4a4d59c ljiyeon
                else
202
                {
203
                    string[] strArg = Environment.GetCommandLineArgs();
204
                    if (strArg.Length > 1)
205
                    {
206
                        var result = ParamDecoding(strArg[1].Replace(@"kcom://", "").Replace(@"/", ""));
207
                        App.ViewInfo = new IKCOM.ViewInfo
208
                        {
209
                            DocumentItemID = result.DocumentItemID,
210 35afe17c djkim
                            EnsembleID = result.DocumentItemID,
211 c4a4d59c ljiyeon
                            //DocumentItemID = "10001",
212
                            bPartner = result.bPartner,
213
                            CreateFinalPDFPermission = result.CreateFinalPDFPermission,
214
                            NewCommentPermission = result.NewCommentPermission,
215
                            ProjectNO = result.ProjectNO,
216
                            UserID = result.UserID,
217
                            //UserID = "H2009115",
218
                            //Mode = 0 , 1 , 2
219
                        };
220
                        ParameterMode = true;
221 1137be84 djkim
                    }
222 1ed8da93 humkyung
                    else
223
                    {
224
                        MessageBox.Show("문서 정보가 입력되지 않았습니다.\n프로그램이 종료됩니다.", "안내");
225
                        throw new ArgumentException("문서 정보가 입력되지 않았습니다.");
226
                    }
227 c4a4d59c ljiyeon
                }
228 992a98b4 KangIngu
229
                //App.ViewInfo.CreateFinalPDFPermission = false;
230
                //App.ViewInfo.NewCommentPermission = false;
231 c4a4d59c ljiyeon
                //GetQueryStringParameters();
232 a7578175 taeseongkim
                //_binding = new WSHttpBinding();
233
                //_binding.Security = new WSHttpSecurity { Transport = new HttpTransportSecurity { ClientCredentialType = HttpClientCredentialType.None }, Mode = SecurityMode.Transport };
234
                //_binding.MaxReceivedMessageSize = 2147483647;
235
                //_binding.OpenTimeout = new TimeSpan(0, 1, 0);
236
                //_binding.ReceiveTimeout = new TimeSpan(0, 10, 0);
237
                //_binding.CloseTimeout = new TimeSpan(0, 5, 0);
238
                //_binding.SendTimeout = new TimeSpan(0, 5, 0);
239
240
                _binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
241
                _binding.MaxBufferSize = 2147483647;
242 787a4489 KangIngu
                _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 a7578175 taeseongkim
                _binding.TextEncoding = System.Text.Encoding.UTF8;
248
                _binding.TransferMode = TransferMode.Buffered;
249 c8dd192f taeseongkim
                //_binding.TextEncoding = System.Text.Encoding.UTF8;
250 787a4489 KangIngu
                //Support.SetLicense();
251 af22332b ljiyeon
252 84c48033 djkim
#if DEBUG
253 eb5cdefc djkim
                //sBaseServiceURL = CommonLib.Common.GetConfigString("BaseClientAddress", "URL", "", isExternal);
254 566f0526 taeseongkim
                System.Diagnostics.Debug.WriteLine("sBaseServiceURL");
255 76dc223b taeseongkim
                BaseAddress = CommonLib.Common.GetConfigString("BaseClientAddress", "URL", "", isExternal);
256 992a98b4 KangIngu
#else
257 76dc223b taeseongkim
                BaseAddress = CommonLib.Common.GetConfigString("BaseClientAddress", "URL", "", isExternal);
258 992a98b4 KangIngu
#endif
259 76dc223b taeseongkim
260
                var UploadAddress = CommonLib.Common.GetConfigString("KCOM_kr_co_devdoftech_cloud_FileUpload", "URL", "");
261
262
                if (!string.IsNullOrWhiteSpace(UploadAddress) && !string.IsNullOrWhiteSpace(BaseAddress))
263
                {
264
                    var uri = new UriBuilder(UploadAddress);
265
                    var baseUri = new UriBuilder(BaseAddress);
266
267
                    uri.Host = baseUri.Host;
268
                    uri.Port = baseUri.Port;
269
270
                    FileUploadUri = uri.ToString();
271 a1e2ba68 taeseongkim
272
273 76dc223b taeseongkim
                }
274
275
                App.FileLogger.Debug(string.Format("{0}/ServiceDeepView.svc", BaseAddress));
276
                _EndPoint = new EndpointAddress(string.Format("{0}/ServiceDeepView.svc", BaseAddress));
277
278
                
279 264c9309 ljiyeon
280 cdfb57ff taeseongkim
                await SplashScreenAsnyc();
281
                base.OnStartup(e);
282 1edefbdf taeseongkim
                System.Windows.Input.Keyboard.AddPreviewKeyDownHandler(this.MainWindow, KeyDownEvent);
283
                //System.Windows.Input.Keyboard.AddKeyDownHandler(this.MainWindow, KeyDownEvent);
284 787a4489 KangIngu
            }
285
            catch (Exception ex)
286
            {
287 274cde11 taeseongkim
                Logger.sendReqLog("OnStartUp",ex.ToString() + " " + ex.InnerException?.ToString(),1);
288 787a4489 KangIngu
            }
289 f7e7a61a ljiyeon
            finally
290
            {
291 cdfb57ff taeseongkim
                await SplashScreenAsnyc();
292 1137be84 djkim
            }
293 787a4489 KangIngu
        }
294 a7346d3c humkyung
295 b60e844d taeseongkim
        private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
296
        {
297 766cdfa1 taeseongkim
            Logger.sendReqLog("App Error ",e.Exception.ToString() + " " + e.Exception.InnerException?.ToString(), 1);
298 b60e844d taeseongkim
        }
299
300 fa48eb85 taeseongkim
        private void KeyDownEvent(object sender, KeyEventArgs e)
301
        {
302 8e6884a5 taeseongkim
            //if (e.Key == Key.Escape || e.Key == Key.Delete)
303
            //{
304 fa48eb85 taeseongkim
                System.Diagnostics.Debug.WriteLine("app key Event");
305
                Common.ViewerDataModel.Instance.SystemMain.KeyEventDownAction(sender, e);
306 8e6884a5 taeseongkim
            //}
307 fa48eb85 taeseongkim
        }
308
309 cdfb57ff taeseongkim
        private async Task<bool> SplashScreenAsnyc()
310
        {
311
            int value = 100 / ISplashMessage.SplashMessageCnt;
312
313
            for (int i = 1; i < ISplashMessage.SplashMessageCnt; i++)
314
            {
315 d33ef543 taeseongkim
                await Task.Delay(3);
316 cdfb57ff taeseongkim
                await splashScreen.Dispatcher.InvokeAsync(() => splashScreen.Progress = i * value);
317
            }
318
319 2007ecaa taeseongkim
            //splashScreen.Close();
320 cdfb57ff taeseongkim
321
            return true;
322
        }
323
324 e0cfc73c ljiyeon
        public static void splashString(string text)
325
        {
326
            Task.Factory.StartNew(() =>
327
            {
328
                splashScreen.Dispatcher.Invoke(() => splashScreen.SplashText = text);
329 2917ab4a taeseongkim
            }).ConfigureAwait(false);
330 e0cfc73c ljiyeon
        }
331
332
333 a7346d3c humkyung
        /// <summary>
334
        /// log unhandled exception
335
        /// </summary>
336
        /// <author>humkyung</author>
337
        /// <date>2019.05.21</date>
338
        /// <param name="sender"></param>
339
        /// <param name="e"></param>
340
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
341
        {
342
            try
343
            {
344 360e4f75 djkim
                App.FileLogger.Fatal(e.ExceptionObject as Exception);
345 a7346d3c humkyung
            }
346
            catch (Exception ex)
347
            {
348 8614f701 taeseongkim
                Console.WriteLine(ex.InnerException?.ToString());
349 a7346d3c humkyung
            }
350
            finally
351
            {
352 8614f701 taeseongkim
#if RELEASE
353 a7346d3c humkyung
                Environment.Exit(0);
354 8614f701 taeseongkim
#endif
355 a7346d3c humkyung
            }
356
        }
357
358 c4a4d59c ljiyeon
        private void ErrorLogFileWrite(string Err)
359
        {
360 ce3f0d7a humkyung
            App.FileLogger.Debug(Err);
361 c4a4d59c ljiyeon
        }
362 787a4489 KangIngu
    }
363
}
클립보드 이미지 추가 (최대 크기: 500 MB)