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