프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / KCOM / App.xaml.cs @ d71ee575

이력 | 보기 | 이력해설 | 다운로드 (9.37 KB)

1 787a4489 KangIngu

2 c4a4d59c ljiyeon
using KCOM.ServiceDeepView;
3 787a4489 KangIngu
using System;
4
using System.Collections.Generic;
5
using System.ComponentModel;
6
using System.Configuration;
7
using System.Data;
8 c4a4d59c ljiyeon
using System.Diagnostics;
9
using System.IO;
10 787a4489 KangIngu
using System.Linq;
11 c4a4d59c ljiyeon
using System.Net;
12
using System.Reflection;
13 787a4489 KangIngu
using System.Runtime.CompilerServices;
14
using System.ServiceModel;
15
using System.Windows;
16 c4a4d59c ljiyeon
using System.Xml;
17 787a4489 KangIngu
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 c4a4d59c ljiyeon
        private string versionPath = null;
66
67 787a4489 KangIngu
        protected override void OnStartup(StartupEventArgs e)
68
        {
69
            try
70
            {
71
                if (e.Args.Count() > 0)
72
                {
73 c4a4d59c ljiyeon
                    var result = ParamDecoding(e.Args[0].Replace(@"kcom://", "").Replace(@"/", ""));
74 787a4489 KangIngu
                    App.ViewInfo = new IKCOM.ViewInfo
75
                    {
76
                        DocumentItemID = result.DocumentItemID,
77
                        //DocumentItemID = "10001",
78
                        bPartner = result.bPartner,
79 bc664e9b djkim
                        CreateFinalPDFPermission = result.CreateFinalPDFPermission,
80
                        NewCommentPermission = result.NewCommentPermission,
81 787a4489 KangIngu
                        ProjectNO = result.ProjectNO,
82
                        UserID = result.UserID,
83
                        //UserID = "H2009115",
84
                        //Mode = 0 , 1 , 2
85
                    };
86
                    ParameterMode = true;
87
                }
88 c4a4d59c ljiyeon
                else
89
                {
90
                    string[] strArg = Environment.GetCommandLineArgs();
91
                    if (strArg.Length > 1)
92
                    {
93
                        //label1.Text = strArg[1];
94
95
                        var result = ParamDecoding(strArg[1].Replace(@"kcom://", "").Replace(@"/", ""));
96
                        App.ViewInfo = new IKCOM.ViewInfo
97
                        {
98
                            DocumentItemID = result.DocumentItemID,
99
                            //DocumentItemID = "10001",
100
                            bPartner = result.bPartner,
101
                            CreateFinalPDFPermission = result.CreateFinalPDFPermission,
102
                            NewCommentPermission = result.NewCommentPermission,
103
                            ProjectNO = result.ProjectNO,
104
                            UserID = result.UserID,
105
                            //UserID = "H2009115",
106
                            //Mode = 0 , 1 , 2
107
                        };
108
                        ParameterMode = true;
109
                    }                
110
                }
111 992a98b4 KangIngu
112
                //App.ViewInfo.CreateFinalPDFPermission = false;
113
                //App.ViewInfo.NewCommentPermission = false;
114
115 c4a4d59c ljiyeon
                //GetQueryStringParameters();
116
                _binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
117 787a4489 KangIngu
                _binding.MaxBufferSize = 2147483647;
118
                _binding.MaxReceivedMessageSize = 2147483647;
119
                _binding.OpenTimeout = new TimeSpan(0, 1, 0);
120
                _binding.ReceiveTimeout = new TimeSpan(0, 10, 0);
121
                _binding.CloseTimeout = new TimeSpan(0, 5, 0);
122
                _binding.SendTimeout = new TimeSpan(0, 5, 0);
123
                _binding.TextEncoding = System.Text.Encoding.UTF8;
124
                _binding.TransferMode = TransferMode.Buffered;
125
                //Support.SetLicense();
126 992a98b4 KangIngu
127 814116a9 humkyung
                string sBaseServiceURL = global::KCOM.Properties.Settings.Default.BaseClientAddress;
128 992a98b4 KangIngu
#if DEBUG
129
                //_EndPoint = new EndpointAddress(@"http://10.11.252.3/MARKUS/ServiceDeepView.svc"); //효성
130 814116a9 humkyung
                _EndPoint = new EndpointAddress(string.Format("{0}/ServiceDeepView.svc", sBaseServiceURL));
131
132 992a98b4 KangIngu
#else
133 814116a9 humkyung
                _EndPoint = new EndpointAddress(string.Format("{0}/ServiceDeepView.svc", sBaseServiceURL));
134 992a98b4 KangIngu
#endif
135 c4a4d59c ljiyeon
                
136
                if (Environment.Is64BitProcess == true) //64 bit machine
137
                {
138
                    versionPath = KCOM.Properties.Settings.Default.UpdateVer64;
139
                }
140
                else //32 bit machine
141
                {
142
                    versionPath = KCOM.Properties.Settings.Default.UpdateVer86;
143
                }
144
145
                // 20180921 version.xml check로 변경
146
                var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
147
                try
148
                {
149
                    XmlDocument xdoc = new XmlDocument();
150
                    xdoc.Load(versionPath);                        
151
                    XmlNode node = xdoc.SelectSingleNode("/RootElement/version");
152
153
                    if (assemblyVersion != node.InnerText) // node.InnerText 가 null이면 catch로 빠짐
154
                    {
155 6707a5c7 ljiyeon
                        //if(MessageBox.Show("Ver. " + node.InnerText + " 업데이트가 있습니다.\r\nSmartUpdate를 실행합니다.", "MARKUS", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
156
                        //{
157
                        if(MessageBox.Show("Ver. " + node.InnerText , "MARKUS", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
158 c4a4d59c ljiyeon
                        {
159
                            UpdateCheck(e);
160
                        }
161
                        else
162
                        {
163
                            base.Shutdown();
164
                            //현재 실행되고 있는 자기 자신 프로세스의 정보 // 위에꺼랑 두개 다 써줄필요가 있는..가?
165
                            Process proc = Process.GetCurrentProcess();
166
                            proc.Kill();
167
                        }
168
                    }
169
                    else
170
                    {
171
                        base.OnStartup(e);
172
                    }                                              
173
                }
174
                catch (Exception ex) //2. 파일이 없거나 파일내에 version의 값이 없다면 KCOM 실행하기
175
                {
176
                    ErrorLogFileWrite("KCOM//UpdateCheck ERR : " + ex);
177
                    base.OnStartup(e);
178
                }           
179 787a4489 KangIngu
            }
180
            catch (Exception ex)
181
            {
182 6707a5c7 ljiyeon
                MessageBox.Show("Err" + ex.Message);
183 787a4489 KangIngu
            }
184
        }
185 c4a4d59c ljiyeon
        
186
        protected void UpdateCheck(StartupEventArgs e)
187
        {          
188
            try
189
            {
190
                if (e.Args.Count() > 0)
191
                {
192
                    ProcessStartInfo proInfo = new ProcessStartInfo();
193
                    var FileName = AppDomain.CurrentDomain.BaseDirectory + "SmartUpdate.exe";
194
                    
195
                    Process.Start(FileName, e.Args[0]);
196
197
                    //다른프로그램에서는 값 안넘기고 바로 실행해도 오류 없이 파일 업데이트 잘 됨!
198
                    //Process.Start(FileName);
199
200
                    base.Shutdown();
201
                    //현재 실행되고 있는 자기 자신 프로세스의 정보 
202
                    Process proc = Process.GetCurrentProcess();
203
                    proc.Kill();
204
                }                    
205
            }
206
            catch(Exception ee)
207
            {
208
                ErrorLogFileWrite("KCOM//UpdateCheck ERR : " + ee);
209
            }            
210
        }
211
212
        private void ErrorLogFileWrite(string Err)
213
        {
214
            try
215
            {
216
                string pathString = AppDomain.CurrentDomain.BaseDirectory + "Err";
217
                if (!File.Exists(pathString))
218
                {
219
                    Directory.CreateDirectory(pathString);
220
                }
221
222
                Err = Err + "   " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "\r\n";
223
                string path = pathString + "\\" + "Log_" + DateTime.Now.ToString("yyyy-MM-dd hh-mm") + ".txt";
224
                File.AppendAllText(path, Err);
225
            }
226
            catch (Exception er)
227
            {
228
                string strError = er.ToString();
229
                //MessageBox.Show("err : " + er);
230
            }
231
        }
232 787a4489 KangIngu
    }
233
}
클립보드 이미지 추가 (최대 크기: 500 MB)