프로젝트

일반

사용자정보

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

markus / KCOM / App.xaml.cs @ c4a4d59c

이력 | 보기 | 이력해설 | 다운로드 (9.85 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
        //20180921 LJY
66
        //public ServiceDeepViewClient _Client;
67

    
68

    
69
        private string versionPath = null;
70

    
71
        protected override void OnStartup(StartupEventArgs e)
72
        {
73
            try
74
            {
75
                if (e.Args.Count() > 0)
76
                {
77
                    var result = ParamDecoding(e.Args[0].Replace(@"kcom://", "").Replace(@"/", ""));
78
                    App.ViewInfo = new IKCOM.ViewInfo
79
                    {
80
                        DocumentItemID = result.DocumentItemID,
81
                        //DocumentItemID = "10001",
82
                        bPartner = result.bPartner,
83
                        CreateFinalPDFPermission = result.CreateFinalPDFPermission,
84
                        NewCommentPermission = result.NewCommentPermission,
85
                        ProjectNO = result.ProjectNO,
86
                        UserID = result.UserID,
87
                        //UserID = "H2009115",
88
                        //Mode = 0 , 1 , 2
89
                    };
90
                    ParameterMode = true;
91
                }
92
                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

    
116
                //App.ViewInfo.CreateFinalPDFPermission = false;
117
                //App.ViewInfo.NewCommentPermission = false;
118

    
119
                //GetQueryStringParameters();
120
                _binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
121
                _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

    
131
                string sBaseServiceURL = global::KCOM.Properties.Settings.Default.BaseClientAddress;
132
#if DEBUG
133
                //_EndPoint = new EndpointAddress(@"http://10.11.252.3/MARKUS/ServiceDeepView.svc"); //효성
134
                _EndPoint = new EndpointAddress(string.Format("{0}/ServiceDeepView.svc", sBaseServiceURL));
135

    
136
#else
137
                _EndPoint = new EndpointAddress(string.Format("{0}/ServiceDeepView.svc", sBaseServiceURL));
138
#endif
139

    
140
                //20180913 LJY 어셈블리 버전
141
                //string assemblyVersion = Assembly.LoadFile('your assembly file').GetName().Version.ToString();
142
                //string fileVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;
143
                //string productVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion;
144
                //_Client = new ServiceDeepViewClient(App._binding, App._EndPoint);
145
                //var serverVersion = _Client.GetCurrentVersion();
146
                
147
                if (Environment.Is64BitProcess == true) //64 bit machine
148
                {
149
                    versionPath = KCOM.Properties.Settings.Default.UpdateVer64;
150
                }
151
                else //32 bit machine
152
                {
153
                    versionPath = KCOM.Properties.Settings.Default.UpdateVer86;
154
                }
155

    
156
                // 20180921 version.xml check로 변경
157
                var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
158
                try
159
                {
160
                    XmlDocument xdoc = new XmlDocument();
161
                    xdoc.Load(versionPath);                        
162
                    XmlNode node = xdoc.SelectSingleNode("/RootElement/version");
163

    
164
                    if (assemblyVersion != node.InnerText) // node.InnerText 가 null이면 catch로 빠짐
165
                    {
166
                        if(MessageBox.Show("Ver. " + node.InnerText + " 업데이트가 있습니다.\r\nSmartUpdate를 실행합니다.", "MARKUS", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
167
                        {
168
                            UpdateCheck(e);
169
                        }
170
                        else
171
                        {
172
                            base.Shutdown();
173
                            //현재 실행되고 있는 자기 자신 프로세스의 정보 // 위에꺼랑 두개 다 써줄필요가 있는..가?
174
                            Process proc = Process.GetCurrentProcess();
175
                            proc.Kill();
176
                        }
177
                    }
178
                    else
179
                    {
180
                        base.OnStartup(e);
181
                    }                                              
182
                }
183
                catch (Exception ex) //2. 파일이 없거나 파일내에 version의 값이 없다면 KCOM 실행하기
184
                {
185
                    ErrorLogFileWrite("KCOM//UpdateCheck ERR : " + ex);
186
                    base.OnStartup(e);
187
                }           
188
            }
189
            catch (Exception ex)
190
            {
191
                MessageBox.Show("에러 메시지" + ex.Message);
192
            }
193
        }
194
        
195
        protected void UpdateCheck(StartupEventArgs e)
196
        {          
197
            try
198
            {
199
                if (e.Args.Count() > 0)
200
                {
201
                    ProcessStartInfo proInfo = new ProcessStartInfo();
202
                    var FileName = AppDomain.CurrentDomain.BaseDirectory + "SmartUpdate.exe";
203
                    
204
                    Process.Start(FileName, e.Args[0]);
205

    
206
                    //다른프로그램에서는 값 안넘기고 바로 실행해도 오류 없이 파일 업데이트 잘 됨!
207
                    //Process.Start(FileName);
208

    
209
                    base.Shutdown();
210
                    //현재 실행되고 있는 자기 자신 프로세스의 정보 
211
                    Process proc = Process.GetCurrentProcess();
212
                    proc.Kill();
213
                }                    
214
            }
215
            catch(Exception ee)
216
            {
217
                ErrorLogFileWrite("KCOM//UpdateCheck ERR : " + ee);
218
            }            
219
        }
220

    
221
        private void ErrorLogFileWrite(string Err)
222
        {
223
            try
224
            {
225
                string pathString = AppDomain.CurrentDomain.BaseDirectory + "Err";
226
                if (!File.Exists(pathString))
227
                {
228
                    Directory.CreateDirectory(pathString);
229
                }
230

    
231
                Err = Err + "   " + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "\r\n";
232
                string path = pathString + "\\" + "Log_" + DateTime.Now.ToString("yyyy-MM-dd hh-mm") + ".txt";
233
                File.AppendAllText(path, Err);
234
            }
235
            catch (Exception er)
236
            {
237
                string strError = er.ToString();
238
                //MessageBox.Show("err : " + er);
239
            }
240
        }
241
    }
242
}
클립보드 이미지 추가 (최대 크기: 500 MB)