markus / KCOM / App.xaml.cs @ df2e7646
이력 | 보기 | 이력해설 | 다운로드 (11.8 KB)
1 | 787a4489 | KangIngu | |
---|---|---|---|
2 | af22332b | ljiyeon | using KCOM.Common; |
3 | c4a4d59c | ljiyeon | using KCOM.ServiceDeepView; |
4 | 787a4489 | KangIngu | using System; |
5 | using System.Collections.Generic; |
||
6 | using System.ComponentModel; |
||
7 | using System.Configuration; |
||
8 | using System.Data; |
||
9 | c4a4d59c | ljiyeon | using System.Diagnostics; |
10 | using System.IO; |
||
11 | 787a4489 | KangIngu | using System.Linq; |
12 | c4a4d59c | ljiyeon | using System.Net; |
13 | using System.Reflection; |
||
14 | 787a4489 | KangIngu | using System.Runtime.CompilerServices; |
15 | using System.ServiceModel; |
||
16 | using System.Windows; |
||
17 | c4a4d59c | ljiyeon | using System.Xml; |
18 | a7346d3c | humkyung | using log4net; |
19 | e52385b9 | ljiyeon | using System.Text; |
20 | using System.Runtime.InteropServices; |
||
21 | cf2671a6 | ljiyeon | using KCOM.Views; |
22 | using System.Threading.Tasks; |
||
23 | 787a4489 | KangIngu | |
24 | a7346d3c | humkyung | [assembly: log4net.Config.XmlConfigurator(Watch = true)] |
25 | 787a4489 | KangIngu | namespace KCOM |
26 | { |
||
27 | public class OpenProperties |
||
28 | { |
||
29 | public string DocumentItemID { get; set; } |
||
30 | public bool bPartner { get; set; } |
||
31 | public bool CreateFinalPDFPermission { get; set; } |
||
32 | public bool NewCommentPermission { get; set; } |
||
33 | public string ProjectNO { get; set; } |
||
34 | public string UserID { get; set; } |
||
35 | public int Mode { get; set; } |
||
36 | 0f6604ce | taeseongkim | |
37 | /// <summary> |
||
38 | /// pemss에서 전달되는 ID |
||
39 | /// </summary> |
||
40 | public string pId { get; set; } |
||
41 | |||
42 | /// <summary> |
||
43 | /// pemss에서 전달되는 ID |
||
44 | /// </summary> |
||
45 | public string uId { get; set; } |
||
46 | 63a36cc0 | taeseongkim | |
47 | public string cId { get; set; } |
||
48 | 787a4489 | KangIngu | } |
49 | /// <summary> |
||
50 | /// App.xaml에 대한 상호 작용 논리 |
||
51 | /// </summary> |
||
52 | public partial class App : Application |
||
53 | { |
||
54 | 0f6604ce | taeseongkim | public static bool IsDesignMode |
55 | { |
||
56 | get |
||
57 | { |
||
58 | b10671a4 | taeseongkim | try |
59 | { |
||
60 | return DesignerProperties.GetIsInDesignMode(new DependencyObject()); |
||
61 | } |
||
62 | catch (Exception) |
||
63 | { |
||
64 | return false; |
||
65 | } |
||
66 | 0f6604ce | taeseongkim | } |
67 | private set { } |
||
68 | } |
||
69 | |||
70 | 787a4489 | KangIngu | public static BasicHttpBinding _binding; |
71 | public static EndpointAddress _EndPoint; |
||
72 | 6f67c93d | taeseongkim | public static EndpointAddress _PemssEndPoint; |
73 | 787a4489 | KangIngu | public static EndpointAddress _EndPoint_SaveLoad; |
74 | public static EndpointAddress _EndPoint_Symbol; |
||
75 | public static string UserID; |
||
76 | public static string UserName; |
||
77 | public static string UserIP; |
||
78 | public static IKCOM.ViewInfo ViewInfo; |
||
79 | 3a4649f8 | taeseongkim | public static IKCOM.PEMSSInfo PEMSSInfo; |
80 | 787a4489 | KangIngu | public static string urlHost; |
81 | public static string urlPort; |
||
82 | public static string urlHost_DB; |
||
83 | public static string urlPort_DB; |
||
84 | public static string Custom_ViewInfoId; |
||
85 | public static bool ParameterMode = false; |
||
86 | 84c48033 | djkim | public static bool isExternal = false; |
87 | 787a4489 | KangIngu | |
88 | a7346d3c | humkyung | /// <summary> |
89 | /// logger |
||
90 | /// </summary> |
||
91 | ce3f0d7a | humkyung | public static ILog DBLogger = null; |
92 | public static ILog FileLogger = null; |
||
93 | a7346d3c | humkyung | |
94 | /// <summary> |
||
95 | /// 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 | 1137be84 | djkim | |
106 | 787a4489 | KangIngu | public static RestSharp.RestClient BaseClient { get; set; } |
107 | public static IKCOM.KCOM_SystemInfo SystemInfo { get; set; } |
||
108 | 1137be84 | djkim | |
109 | 264c9309 | ljiyeon | |
110 | 787a4489 | KangIngu | private 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 | |||
119 | return Newtonsoft.Json.JsonConvert.DeserializeObject<OpenProperties>(jsonBack); |
||
120 | } |
||
121 | |||
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 | b10671a4 | taeseongkim | Telerik.Windows.Controls.StyleManager.ApplicationTheme = new Telerik.Windows.Controls.Office2016Theme(); |
129 | cdfb57ff | taeseongkim | } |
130 | |||
131 | protected override async void OnStartup(StartupEventArgs e) |
||
132 | { |
||
133 | 1137be84 | djkim | |
134 | 787a4489 | KangIngu | try |
135 | a7346d3c | humkyung | { |
136 | 566f0526 | taeseongkim | |
137 | |||
138 | cf2671a6 | ljiyeon | splashScreen.Show(); |
139 | 1137be84 | djkim | |
140 | a7346d3c | humkyung | /// create log database and table |
141 | using (IAbstractDatabase database = new AppSQLiteDatabase() { FilePath = Path.Combine(AppDataFolder, "log4net.db") }) |
||
142 | { |
||
143 | string sSql = "CREATE TABLE IF NOT EXISTS Log (LogId INTEGER PRIMARY KEY,Date DATETIME NOT NULL,Level VARCHAR(50) NOT NULL,Logger VARCHAR(255) NOT NULL,Message TEXT DEFAULT NULL,StackTrace TEXT DEFAULT NULL);"; |
||
144 | database.ExecuteNonQuery(sSql); |
||
145 | } |
||
146 | /// up to here |
||
147 | AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); |
||
148 | ce3f0d7a | humkyung | log4net.GlobalContext.Properties["LogDBFilePath"] = Path.Combine(AppDataFolder, "log4net.db"); |
149 | log4net.GlobalContext.Properties["LogFilePath"] = Path.Combine(AppDataFolder, "Log", "log4net.log"); |
||
150 | App.DBLogger = LogManager.GetLogger("DBLogger"); |
||
151 | App.FileLogger = LogManager.GetLogger("EventLogger"); |
||
152 | a7346d3c | humkyung | |
153 | 1137be84 | djkim | #region // DNS 체크 |
154 | |||
155 | string localdomain = CommonLib.Common.GetConfigString("HOST_DOMAIN", "DOMAIN", ""); |
||
156 | |||
157 | var hostEntry = CommonLib.DNSHelper.GetHostEntryTask(); |
||
158 | |||
159 | if (hostEntry == null) |
||
160 | { |
||
161 | System.Diagnostics.Debug.WriteLine("(hostEntry == null"); |
||
162 | App.FileLogger.Fatal("hostEntry == null"); |
||
163 | isExternal = true; |
||
164 | } |
||
165 | else if (!hostEntry.HostName.EndsWith(localdomain)) |
||
166 | { |
||
167 | // 외부 사용자 |
||
168 | App.FileLogger.Fatal("hostEntry != localdomain :" + hostEntry.HostName); |
||
169 | isExternal = true; |
||
170 | } |
||
171 | #endregion |
||
172 | cf2671a6 | ljiyeon | //splash.Show(false, false); |
173 | 1137be84 | djkim | |
174 | 787a4489 | KangIngu | if (e.Args.Count() > 0) |
175 | { |
||
176 | c4a4d59c | ljiyeon | var result = ParamDecoding(e.Args[0].Replace(@"kcom://", "").Replace(@"/", "")); |
177 | 787a4489 | KangIngu | App.ViewInfo = new IKCOM.ViewInfo |
178 | { |
||
179 | DocumentItemID = result.DocumentItemID, |
||
180 | 35afe17c | djkim | EnsembleID = result.DocumentItemID, |
181 | 787a4489 | KangIngu | //DocumentItemID = "10001", |
182 | bPartner = result.bPartner, |
||
183 | bc664e9b | djkim | CreateFinalPDFPermission = result.CreateFinalPDFPermission, |
184 | NewCommentPermission = result.NewCommentPermission, |
||
185 | 787a4489 | KangIngu | ProjectNO = result.ProjectNO, |
186 | UserID = result.UserID, |
||
187 | //UserID = "H2009115", |
||
188 | //Mode = 0 , 1 , 2 |
||
189 | }; |
||
190 | 3a4649f8 | taeseongkim | |
191 | App.PEMSSInfo = new IKCOM.PEMSSInfo |
||
192 | { |
||
193 | 63a36cc0 | taeseongkim | UserID = result.uId, |
194 | CommentID = result.cId |
||
195 | 3a4649f8 | taeseongkim | }; |
196 | |||
197 | 787a4489 | KangIngu | ParameterMode = true; |
198 | } |
||
199 | c4a4d59c | ljiyeon | else |
200 | { |
||
201 | string[] strArg = Environment.GetCommandLineArgs(); |
||
202 | if (strArg.Length > 1) |
||
203 | { |
||
204 | //label1.Text = strArg[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 | 3a4649f8 | taeseongkim | |
221 | App.PEMSSInfo = new IKCOM.PEMSSInfo |
||
222 | { |
||
223 | UserID = result.uId |
||
224 | }; |
||
225 | |||
226 | c4a4d59c | ljiyeon | ParameterMode = true; |
227 | 1137be84 | djkim | } |
228 | c4a4d59c | ljiyeon | } |
229 | 992a98b4 | KangIngu | |
230 | //App.ViewInfo.CreateFinalPDFPermission = false; |
||
231 | //App.ViewInfo.NewCommentPermission = false; |
||
232 | c4a4d59c | ljiyeon | //GetQueryStringParameters(); |
233 | _binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly); |
||
234 | 787a4489 | KangIngu | _binding.MaxBufferSize = 2147483647; |
235 | _binding.MaxReceivedMessageSize = 2147483647; |
||
236 | _binding.OpenTimeout = new TimeSpan(0, 1, 0); |
||
237 | _binding.ReceiveTimeout = new TimeSpan(0, 10, 0); |
||
238 | _binding.CloseTimeout = new TimeSpan(0, 5, 0); |
||
239 | _binding.SendTimeout = new TimeSpan(0, 5, 0); |
||
240 | _binding.TextEncoding = System.Text.Encoding.UTF8; |
||
241 | _binding.TransferMode = TransferMode.Buffered; |
||
242 | //Support.SetLicense(); |
||
243 | af22332b | ljiyeon | |
244 | 84c48033 | djkim | string sBaseServiceURL = string.Empty;//CommonLib.Common.GetConfigString("BaseClientAddress", "URL", ""); |
245 | 1137be84 | djkim | |
246 | 84c48033 | djkim | #if DEBUG |
247 | eb5cdefc | djkim | //sBaseServiceURL = CommonLib.Common.GetConfigString("BaseClientAddress", "URL", "", isExternal); |
248 | 566f0526 | taeseongkim | System.Diagnostics.Debug.WriteLine("sBaseServiceURL"); |
249 | cdfb57ff | taeseongkim | sBaseServiceURL = CommonLib.Common.GetConfigString("Debug_BaseClientAddress", "URL", "", isExternal); |
250 | 992a98b4 | KangIngu | #else |
251 | 36d6ae21 | taeseongkim | sBaseServiceURL = CommonLib.Common.GetConfigString("BaseClientAddress", "URL", "", isExternal); |
252 | 992a98b4 | KangIngu | #endif |
253 | cdfb57ff | taeseongkim | |
254 | 84c48033 | djkim | _EndPoint = new EndpointAddress(string.Format("{0}/ServiceDeepView.svc", sBaseServiceURL)); |
255 | 84190963 | taeseongkim | |
256 | 0b75c341 | taeseongkim | #if DEBUG |
257 | _PemssEndPoint = new EndpointAddress(string.Format("{0}/PemssService.svc", "http://localhost:13009")); |
||
258 | #else |
||
259 | _PemssEndPoint = new EndpointAddress(string.Format("{0}/PemssService.svc", sBaseServiceURL)); |
||
260 | #endif |
||
261 | 709b3fb7 | taeseongkim | |
262 | cdfb57ff | taeseongkim | await SplashScreenAsnyc(); |
263 | base.OnStartup(e); |
||
264 | |||
265 | //this.MainWindow = new MainWindow(); |
||
266 | |||
267 | 787a4489 | KangIngu | } |
268 | catch (Exception ex) |
||
269 | { |
||
270 | 5aaf27a2 | djkim | MessageBox.Show("Err:" + ex.ToString()); |
271 | 787a4489 | KangIngu | } |
272 | f7e7a61a | ljiyeon | finally |
273 | { |
||
274 | cdfb57ff | taeseongkim | await SplashScreenAsnyc(); |
275 | 1137be84 | djkim | } |
276 | 787a4489 | KangIngu | } |
277 | a7346d3c | humkyung | |
278 | cdfb57ff | taeseongkim | private async Task<bool> SplashScreenAsnyc() |
279 | { |
||
280 | int value = 100 / ISplashMessage.SplashMessageCnt; |
||
281 | |||
282 | for (int i = 1; i < ISplashMessage.SplashMessageCnt; i++) |
||
283 | { |
||
284 | System.Threading.Thread.Sleep(3); |
||
285 | await splashScreen.Dispatcher.InvokeAsync(() => splashScreen.Progress = i * value); |
||
286 | } |
||
287 | |||
288 | splashScreen.Close(); |
||
289 | |||
290 | return true; |
||
291 | } |
||
292 | |||
293 | e0cfc73c | ljiyeon | public static void splashString(string text) |
294 | { |
||
295 | Task.Factory.StartNew(() => |
||
296 | { |
||
297 | splashScreen.Dispatcher.Invoke(() => splashScreen.SplashText = text); |
||
298 | }); |
||
299 | } |
||
300 | |||
301 | |||
302 | a7346d3c | humkyung | /// <summary> |
303 | /// log unhandled exception |
||
304 | /// </summary> |
||
305 | /// <author>humkyung</author> |
||
306 | /// <date>2019.05.21</date> |
||
307 | /// <param name="sender"></param> |
||
308 | /// <param name="e"></param> |
||
309 | private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) |
||
310 | { |
||
311 | try |
||
312 | { |
||
313 | 360e4f75 | djkim | App.FileLogger.Fatal(e.ExceptionObject as Exception); |
314 | //App.DBLogger.Fatal(e.ExceptionObject as Exception); |
||
315 | a7346d3c | humkyung | } |
316 | catch (Exception ex) |
||
317 | { |
||
318 | 8614f701 | taeseongkim | Console.WriteLine(ex.InnerException?.ToString()); |
319 | a7346d3c | humkyung | } |
320 | finally |
||
321 | { |
||
322 | 8614f701 | taeseongkim | #if RELEASE |
323 | a7346d3c | humkyung | Environment.Exit(0); |
324 | 8614f701 | taeseongkim | #endif |
325 | a7346d3c | humkyung | } |
326 | } |
||
327 | |||
328 | c4a4d59c | ljiyeon | private void ErrorLogFileWrite(string Err) |
329 | { |
||
330 | ce3f0d7a | humkyung | App.FileLogger.Debug(Err); |
331 | c4a4d59c | ljiyeon | } |
332 | 787a4489 | KangIngu | } |
333 | } |