markus / KCOM / App.xaml.cs @ b60e844d
이력 | 보기 | 이력해설 | 다운로드 (11.6 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 | b60e844d | taeseongkim | using log4net; |
15 | 787a4489 | KangIngu | |
16 | namespace KCOM |
||
17 | { |
||
18 | public class OpenProperties |
||
19 | { |
||
20 | public string DocumentItemID { get; set; } |
||
21 | public bool bPartner { get; set; } |
||
22 | public bool CreateFinalPDFPermission { get; set; } |
||
23 | public bool NewCommentPermission { get; set; } |
||
24 | public string ProjectNO { get; set; } |
||
25 | public string UserID { get; set; } |
||
26 | public int Mode { get; set; } |
||
27 | } |
||
28 | /// <summary> |
||
29 | /// App.xaml에 대한 상호 작용 논리 |
||
30 | /// </summary> |
||
31 | public partial class App : Application |
||
32 | { |
||
33 | eeb0a39c | taeseongkim | public static PageManager.PageStorage PageStorage; |
34 | |||
35 | 787a4489 | KangIngu | public static BasicHttpBinding _binding; |
36 | 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 | DefaultArrowCursor.Stream.Position = 0; |
||
62 | return DefaultArrowCursor.Stream; |
||
63 | } |
||
64 | } |
||
65 | a7346d3c | humkyung | |
66 | /// <summary> |
||
67 | 2089959a | taeseongkim | /// VisualStudio Design Time여부 |
68 | /// </summary> |
||
69 | public static bool IsDesignMode |
||
70 | { |
||
71 | get |
||
72 | { |
||
73 | try |
||
74 | { |
||
75 | return DesignerProperties.GetIsInDesignMode(new DependencyObject()); |
||
76 | } |
||
77 | catch (Exception) |
||
78 | { |
||
79 | return false; |
||
80 | } |
||
81 | } |
||
82 | private set { } |
||
83 | } |
||
84 | |||
85 | /// <summary> |
||
86 | a7346d3c | humkyung | /// Application Data Folder |
87 | /// </summary> |
||
88 | public static string AppDataFolder |
||
89 | { |
||
90 | get |
||
91 | { |
||
92 | return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MARKUS"); |
||
93 | } |
||
94 | } |
||
95 | 787a4489 | KangIngu | |
96 | public static IKCOM.KCOM_SystemInfo SystemInfo { get; set; } |
||
97 | 1137be84 | djkim | |
98 | 264c9309 | ljiyeon | |
99 | 787a4489 | KangIngu | private static OpenProperties ParamDecoding(string DecodingText, System.Text.Encoding oEncoding = null) |
100 | { |
||
101 | if (oEncoding == null) |
||
102 | oEncoding = System.Text.Encoding.UTF8; |
||
103 | |||
104 | byte[] byteArray = Convert.FromBase64String(DecodingText); |
||
105 | |||
106 | string jsonBack = oEncoding.GetString(byteArray); |
||
107 | |||
108 | return Newtonsoft.Json.JsonConvert.DeserializeObject<OpenProperties>(jsonBack); |
||
109 | } |
||
110 | |||
111 | c4a4d59c | ljiyeon | private string versionPath = null; |
112 | cf2671a6 | ljiyeon | //public SplashScreen splash = new SplashScreen("splash.png"); |
113 | e0cfc73c | ljiyeon | public static SplashScreenWindow splashScreen = new SplashScreenWindow(); |
114 | cdfb57ff | taeseongkim | |
115 | public App() |
||
116 | { |
||
117 | aff63364 | taeseongkim | Telerik.Windows.Controls.StyleManager.ApplicationTheme = new Telerik.Windows.Controls.VisualStudio2013Theme(); |
118 | b60e844d | taeseongkim | |
119 | App.FileLogger = LogManager.GetLogger(typeof(App)); |
||
120 | cdfb57ff | taeseongkim | } |
121 | |||
122 | eeb0a39c | taeseongkim | protected override void OnExit(ExitEventArgs e) |
123 | { |
||
124 | 81908c01 | taeseongkim | try |
125 | { |
||
126 | if (App.PageStorage != null) |
||
127 | { |
||
128 | App.PageStorage.Clear(); |
||
129 | } |
||
130 | } |
||
131 | catch (Exception) |
||
132 | { |
||
133 | } |
||
134 | eeb0a39c | taeseongkim | |
135 | base.OnExit(e); |
||
136 | } |
||
137 | |||
138 | cdfb57ff | taeseongkim | protected override async void OnStartup(StartupEventArgs e) |
139 | { |
||
140 | 787a4489 | KangIngu | try |
141 | a7346d3c | humkyung | { |
142 | 902faaea | taeseongkim | DefaultArrowCursor = Application.GetResourceStream(new Uri(@"pack://application:,,,/Resources/Cursor/customCursor2.cur", UriKind.Absolute)); |
143 | |||
144 | cf2671a6 | ljiyeon | splashScreen.Show(); |
145 | 1137be84 | djkim | |
146 | b60e844d | taeseongkim | App.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException; |
147 | a7346d3c | humkyung | /// up to here |
148 | b60e844d | taeseongkim | //AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); |
149 | a7346d3c | humkyung | |
150 | 1137be84 | djkim | #region // DNS 체크 |
151 | |||
152 | string localdomain = CommonLib.Common.GetConfigString("HOST_DOMAIN", "DOMAIN", ""); |
||
153 | |||
154 | var hostEntry = CommonLib.DNSHelper.GetHostEntryTask(); |
||
155 | df33d20a | djkim | |
156 | 1137be84 | djkim | if (hostEntry == null) |
157 | { |
||
158 | System.Diagnostics.Debug.WriteLine("(hostEntry == null"); |
||
159 | 1ed8da93 | humkyung | App.FileLogger.Debug("hostEntry == null"); |
160 | 1137be84 | djkim | isExternal = true; |
161 | } |
||
162 | ddfd4bc7 | djkim | else if (!string.IsNullOrEmpty(localdomain) && !hostEntry.HostName.ToUpper().EndsWith(localdomain.ToUpper())) |
163 | 1137be84 | djkim | { |
164 | // 외부 사용자 |
||
165 | 1ed8da93 | humkyung | App.FileLogger.Debug(string.Format("You are external user because located out side of given domain({0})\nYour domain is {1}", localdomain, hostEntry.HostName)); |
166 | 1137be84 | djkim | isExternal = true; |
167 | } |
||
168 | #endregion |
||
169 | |||
170 | 366f00c2 | taeseongkim | |
171 | 787a4489 | KangIngu | if (e.Args.Count() > 0) |
172 | { |
||
173 | c4a4d59c | ljiyeon | var result = ParamDecoding(e.Args[0].Replace(@"kcom://", "").Replace(@"/", "")); |
174 | 787a4489 | KangIngu | App.ViewInfo = new IKCOM.ViewInfo |
175 | { |
||
176 | DocumentItemID = result.DocumentItemID, |
||
177 | 35afe17c | djkim | EnsembleID = result.DocumentItemID, |
178 | 787a4489 | KangIngu | //DocumentItemID = "10001", |
179 | bPartner = result.bPartner, |
||
180 | bc664e9b | djkim | CreateFinalPDFPermission = result.CreateFinalPDFPermission, |
181 | NewCommentPermission = result.NewCommentPermission, |
||
182 | 787a4489 | KangIngu | ProjectNO = result.ProjectNO, |
183 | UserID = result.UserID, |
||
184 | //UserID = "H2009115", |
||
185 | //Mode = 0 , 1 , 2 |
||
186 | }; |
||
187 | ParameterMode = true; |
||
188 | } |
||
189 | c4a4d59c | ljiyeon | else |
190 | { |
||
191 | string[] strArg = Environment.GetCommandLineArgs(); |
||
192 | if (strArg.Length > 1) |
||
193 | { |
||
194 | var result = ParamDecoding(strArg[1].Replace(@"kcom://", "").Replace(@"/", "")); |
||
195 | App.ViewInfo = new IKCOM.ViewInfo |
||
196 | { |
||
197 | DocumentItemID = result.DocumentItemID, |
||
198 | 35afe17c | djkim | EnsembleID = result.DocumentItemID, |
199 | c4a4d59c | ljiyeon | //DocumentItemID = "10001", |
200 | bPartner = result.bPartner, |
||
201 | CreateFinalPDFPermission = result.CreateFinalPDFPermission, |
||
202 | NewCommentPermission = result.NewCommentPermission, |
||
203 | ProjectNO = result.ProjectNO, |
||
204 | UserID = result.UserID, |
||
205 | //UserID = "H2009115", |
||
206 | //Mode = 0 , 1 , 2 |
||
207 | }; |
||
208 | ParameterMode = true; |
||
209 | 1137be84 | djkim | } |
210 | 1ed8da93 | humkyung | else |
211 | { |
||
212 | MessageBox.Show("문서 정보가 입력되지 않았습니다.\n프로그램이 종료됩니다.", "안내"); |
||
213 | throw new ArgumentException("문서 정보가 입력되지 않았습니다."); |
||
214 | } |
||
215 | c4a4d59c | ljiyeon | } |
216 | 992a98b4 | KangIngu | |
217 | //App.ViewInfo.CreateFinalPDFPermission = false; |
||
218 | //App.ViewInfo.NewCommentPermission = false; |
||
219 | c4a4d59c | ljiyeon | //GetQueryStringParameters(); |
220 | _binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly); |
||
221 | 787a4489 | KangIngu | _binding.MaxBufferSize = 2147483647; |
222 | _binding.MaxReceivedMessageSize = 2147483647; |
||
223 | _binding.OpenTimeout = new TimeSpan(0, 1, 0); |
||
224 | _binding.ReceiveTimeout = new TimeSpan(0, 10, 0); |
||
225 | _binding.CloseTimeout = new TimeSpan(0, 5, 0); |
||
226 | _binding.SendTimeout = new TimeSpan(0, 5, 0); |
||
227 | _binding.TextEncoding = System.Text.Encoding.UTF8; |
||
228 | _binding.TransferMode = TransferMode.Buffered; |
||
229 | //Support.SetLicense(); |
||
230 | af22332b | ljiyeon | |
231 | 84c48033 | djkim | string sBaseServiceURL = string.Empty;//CommonLib.Common.GetConfigString("BaseClientAddress", "URL", ""); |
232 | 1137be84 | djkim | |
233 | 84c48033 | djkim | #if DEBUG |
234 | eb5cdefc | djkim | //sBaseServiceURL = CommonLib.Common.GetConfigString("BaseClientAddress", "URL", "", isExternal); |
235 | 566f0526 | taeseongkim | System.Diagnostics.Debug.WriteLine("sBaseServiceURL"); |
236 | ff01c725 | humkyung | sBaseServiceURL = CommonLib.Common.GetConfigString("BaseClientAddress", "URL", "", isExternal); |
237 | 992a98b4 | KangIngu | #else |
238 | 36d6ae21 | taeseongkim | sBaseServiceURL = CommonLib.Common.GetConfigString("BaseClientAddress", "URL", "", isExternal); |
239 | 992a98b4 | KangIngu | #endif |
240 | 4eb4f3f9 | humkyung | App.FileLogger.Debug(string.Format("{0}/ServiceDeepView.svc", sBaseServiceURL)); |
241 | 84c48033 | djkim | _EndPoint = new EndpointAddress(string.Format("{0}/ServiceDeepView.svc", sBaseServiceURL)); |
242 | 264c9309 | ljiyeon | |
243 | cdfb57ff | taeseongkim | await SplashScreenAsnyc(); |
244 | base.OnStartup(e); |
||
245 | d97dbc7f | taeseongkim | |
246 | fa48eb85 | taeseongkim | System.Windows.Input.Keyboard.AddKeyDownHandler(this.MainWindow, KeyDownEvent); |
247 | 787a4489 | KangIngu | } |
248 | catch (Exception ex) |
||
249 | { |
||
250 | d0286794 | taeseongkim | Logger.sendReqLog("OnStartUp",ex.ToString() + " " + ex.InnerException?.ToString(),1); |
251 | 787a4489 | KangIngu | } |
252 | f7e7a61a | ljiyeon | finally |
253 | { |
||
254 | cdfb57ff | taeseongkim | await SplashScreenAsnyc(); |
255 | 1137be84 | djkim | } |
256 | 787a4489 | KangIngu | } |
257 | a7346d3c | humkyung | |
258 | b60e844d | taeseongkim | private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) |
259 | { |
||
260 | throw new NotImplementedException(); |
||
261 | } |
||
262 | |||
263 | fa48eb85 | taeseongkim | private void KeyDownEvent(object sender, KeyEventArgs e) |
264 | { |
||
265 | if (e.Key == Key.Escape || e.Key == Key.Delete) |
||
266 | { |
||
267 | System.Diagnostics.Debug.WriteLine("app key Event"); |
||
268 | Common.ViewerDataModel.Instance.SystemMain.KeyEventDownAction(sender, e); |
||
269 | } |
||
270 | } |
||
271 | |||
272 | cdfb57ff | taeseongkim | private async Task<bool> SplashScreenAsnyc() |
273 | { |
||
274 | int value = 100 / ISplashMessage.SplashMessageCnt; |
||
275 | |||
276 | for (int i = 1; i < ISplashMessage.SplashMessageCnt; i++) |
||
277 | { |
||
278 | d33ef543 | taeseongkim | await Task.Delay(3); |
279 | cdfb57ff | taeseongkim | await splashScreen.Dispatcher.InvokeAsync(() => splashScreen.Progress = i * value); |
280 | } |
||
281 | |||
282 | splashScreen.Close(); |
||
283 | |||
284 | return true; |
||
285 | } |
||
286 | |||
287 | e0cfc73c | ljiyeon | public static void splashString(string text) |
288 | { |
||
289 | Task.Factory.StartNew(() => |
||
290 | { |
||
291 | splashScreen.Dispatcher.Invoke(() => splashScreen.SplashText = text); |
||
292 | 2917ab4a | taeseongkim | }).ConfigureAwait(false); |
293 | e0cfc73c | ljiyeon | } |
294 | |||
295 | |||
296 | a7346d3c | humkyung | /// <summary> |
297 | /// log unhandled exception |
||
298 | /// </summary> |
||
299 | /// <author>humkyung</author> |
||
300 | /// <date>2019.05.21</date> |
||
301 | /// <param name="sender"></param> |
||
302 | /// <param name="e"></param> |
||
303 | private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) |
||
304 | { |
||
305 | try |
||
306 | { |
||
307 | 360e4f75 | djkim | App.FileLogger.Fatal(e.ExceptionObject as Exception); |
308 | a7346d3c | humkyung | } |
309 | catch (Exception ex) |
||
310 | { |
||
311 | 8614f701 | taeseongkim | Console.WriteLine(ex.InnerException?.ToString()); |
312 | a7346d3c | humkyung | } |
313 | finally |
||
314 | { |
||
315 | 8614f701 | taeseongkim | #if RELEASE |
316 | a7346d3c | humkyung | Environment.Exit(0); |
317 | 8614f701 | taeseongkim | #endif |
318 | a7346d3c | humkyung | } |
319 | } |
||
320 | |||
321 | c4a4d59c | ljiyeon | private void ErrorLogFileWrite(string Err) |
322 | { |
||
323 | ce3f0d7a | humkyung | App.FileLogger.Debug(Err); |
324 | c4a4d59c | ljiyeon | } |
325 | 787a4489 | KangIngu | } |
326 | } |