markus / KCOM / App.xaml.cs @ af22332b
이력 | 보기 | 이력해설 | 다운로드 (10.3 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 | 787a4489 | KangIngu | |
19 | namespace KCOM |
||
20 | { |
||
21 | public class OpenProperties |
||
22 | { |
||
23 | public string DocumentItemID { get; set; } |
||
24 | public bool bPartner { get; set; } |
||
25 | public bool CreateFinalPDFPermission { get; set; } |
||
26 | public bool NewCommentPermission { get; set; } |
||
27 | public string ProjectNO { get; set; } |
||
28 | public string UserID { get; set; } |
||
29 | public int Mode { get; set; } |
||
30 | } |
||
31 | /// <summary> |
||
32 | /// App.xaml에 대한 상호 작용 논리 |
||
33 | /// </summary> |
||
34 | public partial class App : Application |
||
35 | { |
||
36 | public static BasicHttpBinding _binding; |
||
37 | 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 | |||
51 | |||
52 | public static RestSharp.RestClient BaseClient { get; set; } |
||
53 | public static IKCOM.KCOM_SystemInfo SystemInfo { get; set; } |
||
54 | private static OpenProperties ParamDecoding(string DecodingText, System.Text.Encoding oEncoding = null) |
||
55 | { |
||
56 | if (oEncoding == null) |
||
57 | oEncoding = System.Text.Encoding.UTF8; |
||
58 | |||
59 | byte[] byteArray = Convert.FromBase64String(DecodingText); |
||
60 | |||
61 | string jsonBack = oEncoding.GetString(byteArray); |
||
62 | |||
63 | return Newtonsoft.Json.JsonConvert.DeserializeObject<OpenProperties>(jsonBack); |
||
64 | } |
||
65 | |||
66 | c4a4d59c | ljiyeon | private string versionPath = null; |
67 | c7fcb949 | ljiyeon | public SplashScreen splash = new SplashScreen("splash.png"); |
68 | c4a4d59c | ljiyeon | |
69 | 787a4489 | KangIngu | protected override void OnStartup(StartupEventArgs e) |
70 | { |
||
71 | try |
||
72 | c7fcb949 | ljiyeon | { |
73 | splash.Show(false, false); |
||
74 | |||
75 | 787a4489 | KangIngu | if (e.Args.Count() > 0) |
76 | { |
||
77 | c4a4d59c | ljiyeon | var result = ParamDecoding(e.Args[0].Replace(@"kcom://", "").Replace(@"/", "")); |
78 | 787a4489 | KangIngu | App.ViewInfo = new IKCOM.ViewInfo |
79 | { |
||
80 | DocumentItemID = result.DocumentItemID, |
||
81 | //DocumentItemID = "10001", |
||
82 | bPartner = result.bPartner, |
||
83 | bc664e9b | djkim | CreateFinalPDFPermission = result.CreateFinalPDFPermission, |
84 | NewCommentPermission = result.NewCommentPermission, |
||
85 | 787a4489 | KangIngu | ProjectNO = result.ProjectNO, |
86 | UserID = result.UserID, |
||
87 | //UserID = "H2009115", |
||
88 | //Mode = 0 , 1 , 2 |
||
89 | }; |
||
90 | ParameterMode = true; |
||
91 | } |
||
92 | c4a4d59c | ljiyeon | else |
93 | { |
||
94 | string[] strArg = Environment.GetCommandLineArgs(); |
||
95 | if (strArg.Length > 1) |
||
96 | { |
||
97 | //label1.Text = strArg[1]; |
||
98 | |||
99 | var result = ParamDecoding(strArg[1].Replace(@"kcom://", "").Replace(@"/", "")); |
||
100 | App.ViewInfo = new IKCOM.ViewInfo |
||
101 | { |
||
102 | DocumentItemID = result.DocumentItemID, |
||
103 | //DocumentItemID = "10001", |
||
104 | bPartner = result.bPartner, |
||
105 | CreateFinalPDFPermission = result.CreateFinalPDFPermission, |
||
106 | NewCommentPermission = result.NewCommentPermission, |
||
107 | ProjectNO = result.ProjectNO, |
||
108 | UserID = result.UserID, |
||
109 | //UserID = "H2009115", |
||
110 | //Mode = 0 , 1 , 2 |
||
111 | }; |
||
112 | ParameterMode = true; |
||
113 | } |
||
114 | } |
||
115 | 992a98b4 | KangIngu | |
116 | //App.ViewInfo.CreateFinalPDFPermission = false; |
||
117 | //App.ViewInfo.NewCommentPermission = false; |
||
118 | |||
119 | c4a4d59c | ljiyeon | //GetQueryStringParameters(); |
120 | _binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly); |
||
121 | 787a4489 | KangIngu | _binding.MaxBufferSize = 2147483647; |
122 | _binding.MaxReceivedMessageSize = 2147483647; |
||
123 | _binding.OpenTimeout = new TimeSpan(0, 1, 0); |
||
124 | _binding.ReceiveTimeout = new TimeSpan(0, 10, 0); |
||
125 | _binding.CloseTimeout = new TimeSpan(0, 5, 0); |
||
126 | _binding.SendTimeout = new TimeSpan(0, 5, 0); |
||
127 | _binding.TextEncoding = System.Text.Encoding.UTF8; |
||
128 | _binding.TransferMode = TransferMode.Buffered; |
||
129 | //Support.SetLicense(); |
||
130 | 992a98b4 | KangIngu | |
131 | 814116a9 | humkyung | string sBaseServiceURL = global::KCOM.Properties.Settings.Default.BaseClientAddress; |
132 | af22332b | ljiyeon | |
133 | var ipaddress = DNSHelper.GetDnsAdress(); |
||
134 | |||
135 | try |
||
136 | { |
||
137 | var hostName = Dns.GetHostEntry(ipaddress).HostName; |
||
138 | |||
139 | if (!hostName.EndsWith(KCOM.Properties.Settings.Default.HOST_DOMAIN)) |
||
140 | { |
||
141 | // 외부 사용자 |
||
142 | sBaseServiceURL = global::KCOM.Properties.Settings.Default.Remote_BaseClientAddress; |
||
143 | } |
||
144 | } |
||
145 | catch (Exception ex) |
||
146 | { |
||
147 | System.Diagnostics.Debug.WriteLine(ex.ToString()); |
||
148 | } |
||
149 | 992a98b4 | KangIngu | #if DEBUG |
150 | //_EndPoint = new EndpointAddress(@"http://10.11.252.3/MARKUS/ServiceDeepView.svc"); //효성 |
||
151 | 814116a9 | humkyung | _EndPoint = new EndpointAddress(string.Format("{0}/ServiceDeepView.svc", sBaseServiceURL)); |
152 | |||
153 | 992a98b4 | KangIngu | #else |
154 | 814116a9 | humkyung | _EndPoint = new EndpointAddress(string.Format("{0}/ServiceDeepView.svc", sBaseServiceURL)); |
155 | 992a98b4 | KangIngu | #endif |
156 | c4a4d59c | ljiyeon | |
157 | if (Environment.Is64BitProcess == true) //64 bit machine |
||
158 | { |
||
159 | versionPath = KCOM.Properties.Settings.Default.UpdateVer64; |
||
160 | } |
||
161 | else //32 bit machine |
||
162 | { |
||
163 | versionPath = KCOM.Properties.Settings.Default.UpdateVer86; |
||
164 | } |
||
165 | |||
166 | af22332b | ljiyeon | if (File.Exists(versionPath)) |
167 | c4a4d59c | ljiyeon | { |
168 | af22332b | ljiyeon | // 20180921 version.xml check로 변경 |
169 | var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); |
||
170 | try |
||
171 | c4a4d59c | ljiyeon | { |
172 | af22332b | ljiyeon | XmlDocument xdoc = new XmlDocument(); |
173 | xdoc.Load(versionPath); |
||
174 | XmlNode node = xdoc.SelectSingleNode("/RootElement/version"); |
||
175 | |||
176 | if (assemblyVersion != node.InnerText) // node.InnerText 가 null이면 catch로 빠짐 |
||
177 | c4a4d59c | ljiyeon | { |
178 | af22332b | ljiyeon | //if(MessageBox.Show("Ver. " + node.InnerText + " 업데이트가 있습니다.\r\nSmartUpdate를 실행합니다.", "MARKUS", MessageBoxButton.OKCancel) == MessageBoxResult.OK) |
179 | //{ |
||
180 | if (MessageBox.Show("Ver. " + node.InnerText, "MARKUS", MessageBoxButton.OKCancel) == MessageBoxResult.OK) |
||
181 | { |
||
182 | UpdateCheck(e); |
||
183 | } |
||
184 | else |
||
185 | { |
||
186 | base.Shutdown(); |
||
187 | //현재 실행되고 있는 자기 자신 프로세스의 정보 // 위에꺼랑 두개 다 써줄필요가 있는..가? |
||
188 | Process proc = Process.GetCurrentProcess(); |
||
189 | proc.Kill(); |
||
190 | } |
||
191 | c4a4d59c | ljiyeon | } |
192 | else |
||
193 | { |
||
194 | af22332b | ljiyeon | base.OnStartup(e); |
195 | splash.Close(new TimeSpan(0, 0, 2)); |
||
196 | c4a4d59c | ljiyeon | } |
197 | } |
||
198 | af22332b | ljiyeon | catch (Exception ex) //2. 파일이 없거나 파일내에 version의 값이 없다면 KCOM 실행하기 |
199 | c4a4d59c | ljiyeon | { |
200 | af22332b | ljiyeon | ErrorLogFileWrite("KCOM//UpdateCheck ERR : " + ex); |
201 | c4a4d59c | ljiyeon | base.OnStartup(e); |
202 | c7fcb949 | ljiyeon | splash.Close(new TimeSpan(0, 0, 2)); |
203 | af22332b | ljiyeon | } |
204 | c4a4d59c | ljiyeon | } |
205 | 787a4489 | KangIngu | } |
206 | catch (Exception ex) |
||
207 | { |
||
208 | 6707a5c7 | ljiyeon | MessageBox.Show("Err" + ex.Message); |
209 | 787a4489 | KangIngu | } |
210 | } |
||
211 | c4a4d59c | ljiyeon | |
212 | protected void UpdateCheck(StartupEventArgs e) |
||
213 | { |
||
214 | try |
||
215 | { |
||
216 | if (e.Args.Count() > 0) |
||
217 | { |
||
218 | ProcessStartInfo proInfo = new ProcessStartInfo(); |
||
219 | var FileName = AppDomain.CurrentDomain.BaseDirectory + "SmartUpdate.exe"; |
||
220 | |||
221 | Process.Start(FileName, e.Args[0]); |
||
222 | |||
223 | base.Shutdown(); |
||
224 | //현재 실행되고 있는 자기 자신 프로세스의 정보 |
||
225 | Process proc = Process.GetCurrentProcess(); |
||
226 | proc.Kill(); |
||
227 | } |
||
228 | } |
||
229 | catch(Exception ee) |
||
230 | { |
||
231 | ErrorLogFileWrite("KCOM//UpdateCheck ERR : " + ee); |
||
232 | } |
||
233 | } |
||
234 | |||
235 | private void ErrorLogFileWrite(string Err) |
||
236 | { |
||
237 | try |
||
238 | { |
||
239 | af22332b | ljiyeon | string FilePath = "C:\\ProgramData\\MARKUS\\"; |
240 | //string pathString = AppDomain.CurrentDomain.BaseDirectory + "Err"; |
||
241 | string pathString = FilePath + "Err"; |
||
242 | |||
243 | c4a4d59c | ljiyeon | if (!File.Exists(pathString)) |
244 | { |
||
245 | Directory.CreateDirectory(pathString); |
||
246 | } |
||
247 | |||
248 | Err = Err + " " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "\r\n"; |
||
249 | string path = pathString + "\\" + "Log_" + DateTime.Now.ToString("yyyy-MM-dd hh-mm") + ".txt"; |
||
250 | File.AppendAllText(path, Err); |
||
251 | } |
||
252 | catch (Exception er) |
||
253 | { |
||
254 | string strError = er.ToString(); |
||
255 | //MessageBox.Show("err : " + er); |
||
256 | } |
||
257 | } |
||
258 | 787a4489 | KangIngu | } |
259 | } |