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