프로젝트

일반

사용자정보

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

markus / ConvertService / ServiceBase / ServiceTestApp / MainWindow.xaml.cs @ ff4b1e6e

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

1
using Markus.EntityModel;
2
using Markus.Service;
3
using Markus.Service.Extensions;
4
using Markus.Service.Helper;
5
using Microsoft.VisualStudio.TestTools.UnitTesting;
6
using Microsoft.Win32;
7
using Newtonsoft.Json;
8
using System;
9
using System.Collections.Generic;
10
using System.Diagnostics;
11
using System.IO;
12
using System.Linq;
13
using System.Net.Http;
14
using System.ServiceModel;
15
using System.Text;
16
using System.Threading.Tasks;
17
using System.Web.Script.Serialization;
18
using System.Windows;
19
using System.Windows.Data;
20
using System.Windows.Forms;
21
using static Markus.Service.Extensions.Encrypt;
22

    
23
namespace ServiceTestApp
24
{
25
    /// <summary>
26
    /// MainWindow.xaml에 대한 상호 작용 논리
27
    /// </summary>
28
    public partial class MainWindow : Window
29
    {
30
        public MainWindow()
31
        {
32
            InitializeComponent();
33

    
34
            var config = Markus.Service.Helper.ConfigHelper.AppConfig("ServiceStation.ini");
35
            MarkusDBConnectionString = AESEncrypter.Decrypt(config.GetValue(CONFIG_DEFINE.SERVICE, CONFIG_DEFINE.MARKUS_CONNECTION_STRING));
36

    
37
            datagrid.ItemsSource = convertItems;
38
          
39
            timer.Interval = new TimeSpan(0, 0, 0, 0, 700);
40
            timer.Tick += Timer_Tick;
41
            //timer.Start();
42
        }
43
        System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();
44
        private string MarkusDBConnectionString;
45

    
46
        private void Timer_0_Tick(object sender, EventArgs e)
47
        {
48
            BasicHttpBinding myBinding = new BasicHttpBinding();
49
            EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
50

    
51
            StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
52
 
53
            var result =  client.AliveConvertList();
54

    
55
            datagrid.ItemsSource = result;
56

    
57
            if(result.Count() < 2)
58
            {
59
                foreach (var filename in Directory.EnumerateFiles("D:\\Case"))
60
                {
61
                    var additem = client.ConvertMenualAdd("111111",  filename, "test");
62

    
63
                    if (!string.IsNullOrWhiteSpace(additem))
64
                    {
65
                        Log.Text += $"Wcf Station Service call{filename} {result}\n";
66
                    }
67
                    else
68
                    {
69
                        Log.Text += $"Call Error {filename} {result}\n";
70
                    }
71
                }
72
            }
73
        }
74

    
75
        private void Timer_Tick(object sender, EventArgs e)
76
        {
77
            timer.Stop();
78

    
79
            using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(MarkusDBConnectionString))
80
            {
81
                var data = database.GetConvertItems(Markus.Message.StatusCodeType.Saving);
82

    
83
                foreach (var item in data)
84
                {
85
                    var getitem = convertItems.Where(f => f.ConvertID == item.ConvertID);
86

    
87
                    if (getitem.Count() == 0)
88
                    {
89
                        convertItems.Add(item);
90
                    }
91
                    else
92
                    {
93
                        var binditem = getitem.First();
94

    
95
                        binditem.ConvertState = item.ConvertState;
96
                        binditem.CurrentPageNo = item.CurrentPageNo;
97
                        binditem.TotalPage = item.TotalPage;
98
                    }
99
                }
100

    
101
                var _removeitems = convertItems.Select(f => f.ConvertID).Except(data.Select(x => x.ConvertID)).ToList();
102

    
103
                foreach (var item in _removeitems)
104
                {
105
                    var items = convertItems.Where(x => x.ConvertID == item);
106

    
107
                    if (items.Count() > 0)
108
                    {
109
                        Markus.Service.Interface.ConvertItem convertItem = items.First();
110
                        convertItems.Remove(convertItem);
111
                    }
112
                }
113
            }
114

    
115
            var process = Process.GetProcessesByName("Markus.Service.ConvertProcess");
116

    
117
            this.Dispatcher.Invoke(() =>
118
            {
119
                CollectionViewSource.GetDefaultView(datagrid.ItemsSource).Refresh();
120

    
121
                if (process.Count() > 0)
122
                {
123
                    if (Log.Text.Length > int.MaxValue)
124
                    {
125
                        Log.Text = "";
126
                    }
127

    
128
                    Log.Text += "-------------------------------------\n";
129

    
130
                    Log.Text += $"  Physical memory usage     : {process.Sum(f => f.WorkingSet64)}" + "\n";
131
                    Log.Text += $"  Base priority             : {process.Sum(f => f.BasePriority)}" + "\n";
132
                    //Log.Text += $"  Priority class            : {process[0].PriorityClass}" + "\n";
133
                    //Log.Text += $"  User processor time       : {process[0].UserProcessorTime}" + "\n";
134
                    //Log.Text += $"  Privileged processor time : {process[0].PrivilegedProcessorTime}" + "\n";
135
                    //Log.Text += $"  Total processor time      : {process[0].TotalProcessorTime}" + "\n";
136
                    Log.Text += $"  Paged system memory size  : {process.Sum(f => f.PagedSystemMemorySize64)}" + "\n";
137
                    Log.Text += $"  Paged memory size         : {process.Sum(f => f.PagedMemorySize64)}" + "\n";
138
                }
139
            });
140

    
141
            //if (process.Count() < 3)
142
            //{
143
            //    BasicHttpBinding myBinding = new BasicHttpBinding();
144
            //    EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
145
            //    StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
146
            //    foreach (var filename in Directory.EnumerateFiles("D:\\Case"))
147
            //    {
148
            //        var _id = new Guid().CreateUniqueGuid().ToString();
149

    
150
            //        var result = client.ConvertMenualAdd("111111", _id, filename, "test");
151

    
152
            //        if (result)
153
            //        {
154
            //            Log.Text += $"Wcf Station Service call{filename} {result}\n";
155
            //        }
156
            //        else
157
            //        {
158
            //            Log.Text += $"Call Error {filename} {result}\n";
159
            //        }
160
            //    }
161
            //}
162

    
163
            timer.Start();
164

    
165
        }
166

    
167
        private System.Collections.ObjectModel.ObservableCollection<Markus.Service.Interface.ConvertItem> convertItems = new System.Collections.ObjectModel.ObservableCollection<Markus.Service.Interface.ConvertItem>();
168

    
169
        PrivateObject stationObj;
170
        Markus.Service.ServiceStation station = new Markus.Service.ServiceStation();
171

    
172
        private void Button_Click(object sender, RoutedEventArgs e)
173
        {
174
            station.StartService();
175

    
176
            // if (station == null)
177
            // {
178
            //     station = new PrivateObject(typeof(Markus.Service.StationService.ServiceStation));
179
            // }
180

    
181

    
182

    
183
            Log.Text += "Wcf Service start\n";
184
        }
185

    
186
        private async void ServiceCall_Click(object sender, RoutedEventArgs e)
187
        {
188
            ConvertService.ConvertServiceClient client = new ConvertService.ConvertServiceClient();
189
            var result = await client.ConvertAddAsync(1);
190

    
191
            Log.Text += $"Wcf Convert Service call{result}\n";
192
        }
193

    
194
        private async void StationServiceCall_Click(object sender, RoutedEventArgs e)
195
        {
196
            StationService.StationServiceClient client = new StationService.StationServiceClient();
197
            var result = await client.ConvertAddAsync("test", "11");
198

    
199
            Log.Text += $"Wcf Station Service call{result}\n";
200
        }
201

    
202
        private async void ItemAdd_Click(object sender, RoutedEventArgs e)
203
        {
204
            string ProjectNo = "111111";
205

    
206
            BasicHttpBinding myBinding = new BasicHttpBinding();
207
            EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
208
            StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
209
            foreach (var filename in GetFileList())
210
            {
211
                var result = await client.ConvertMenualAddAsync("111111", filename, "test");
212

    
213
                if (!string.IsNullOrWhiteSpace(result))
214
                {
215
                    Log.Text += $"Wcf Station Service call{filename} convert ID : {result}\n";
216
                }
217
                else
218
                {
219
                    Log.Text += $"Call Error {filename}\n";
220
                }
221
            }
222

    
223
            #region 데이터베이스 테스트 
224
            /*
225
            using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(ProjectNo))
226
            {
227
                foreach (var filename in GetFileList())
228
                {
229
                    var _id = new Guid().CreateUniqueGuid().ToString();
230

    
231
                    if (!database.SetConvertDoc(ProjectNo, _id, filename,_id))
232
                    {
233
                        System.Windows.MessageBox.Show("저장에 실패!");
234
                        break;
235
                    }
236
                }
237
            }
238
            */
239
            #endregion
240
        }
241

    
242
        private IEnumerable<string> GetFileList()
243
        {
244
            IEnumerable<string> result = new string[] { };
245

    
246
            using (FolderBrowserDialog dialog = new FolderBrowserDialog())
247
            {
248
                dialog.Description = "PDF가 있는 폴더를 선택하세요.";
249
                dialog.ShowNewFolderButton = false;
250
                dialog.RootFolder = Environment.SpecialFolder.MyComputer;
251

    
252
                if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
253
                {
254
                    result = Directory.EnumerateFiles(dialog.SelectedPath, "*.pdf", SearchOption.AllDirectories);
255
                }
256
            }
257

    
258
            return result;
259
        }
260

    
261
        private void ServiceInstall_Click(object sender, RoutedEventArgs e)
262
        {
263
            //Markus.Service.ProjectInstaller projectInstaller = new Markus.Service.ProjectInstaller();
264
            //Hashtable savedState = new Hashtable();
265
            //projectInstaller.serviceProcessInstaller.Install(savedState);
266

    
267
            //projectInstaller.serviceProcessInstaller.Uninstall(savedState);
268

    
269

    
270
            IntegratedServiceInstaller integrated = new IntegratedServiceInstaller();
271
            integrated.Install("ServiceStation", "ServiceStation", "test", System.ServiceProcess.ServiceAccount.LocalService, System.ServiceProcess.ServiceStartMode.Automatic);
272

    
273
        }
274

    
275
        private void LibInstall_Click(object sender, RoutedEventArgs e)
276
        {
277
            Markus.Library.Installer.Install();
278
        }
279

    
280
        private async void ItemAddFile_Click(object sender, RoutedEventArgs e)
281
        {
282
            System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
283

    
284
            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
285
            {
286
                BasicHttpBinding myBinding = new BasicHttpBinding();
287
                EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
288

    
289
                StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
290

    
291
                var result = await client.ConvertMenualAddAsync("111111", dialog.FileName, "test");
292

    
293
                Log.Text += $"Wcf Station Service call{dialog.FileName} {result}\n";
294
            }
295
        }
296

    
297
        private async void AliveList_Click(object sender, RoutedEventArgs e)
298
        {
299
            await AliveItemAsync();
300
        }
301
        private async Task AliveItemAsync()
302
        {
303
            BasicHttpBinding myBinding = new BasicHttpBinding();
304
            EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
305

    
306
            StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
307
            var _id = new Guid().CreateUniqueGuid().ToString();
308

    
309
            var result = await client.AliveConvertListAsync();
310

    
311
            datagrid.ItemsSource = result;
312
        }
313

    
314
        private async void WaitList_Click(object sender, RoutedEventArgs e)
315
        {
316
            BasicHttpBinding myBinding = new BasicHttpBinding();
317
            EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
318

    
319
            StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
320
            var _id = new Guid().CreateUniqueGuid().ToString();
321

    
322
            var result = await client.WaitConvertListAsync();
323

    
324
            datagrid.ItemsSource = result;
325
        }
326

    
327
        private void ProcessKill_Click(object sender, RoutedEventArgs e)
328
        {
329
            station.Stopprocess();
330
        }
331

    
332
        private void DeadLockProcessList_Click(object sender, RoutedEventArgs e)
333
        {
334
            station.DeadLockProcessKill();
335
        }
336

    
337
        private async void Button_Click_1(object sender, RoutedEventArgs e)
338
        {
339
            int count = 0;
340

    
341

    
342
            if(int.TryParse(txtProcessCount.Text,out count))
343
            {
344

    
345
            BasicHttpBinding myBinding = new BasicHttpBinding();
346
            EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
347

    
348
            StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
349

    
350
            var result = await client.SettingMultiProcessAsync(count);
351

    
352
            }
353
        }
354

    
355
        private async void RemoteFileList_Click(object sender, RoutedEventArgs e)
356
        {
357
            var uriList = new[]
358
            {
359
                "http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000053/250page.pdf",
360
                "http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000038/250page.pdf",
361
                "http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000027/BigSize.pdf",
362
                "http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000032/BigSize.pdf",
363
                "http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000087/1-5110-ZJ-492-005_C.pdf",
364
                "http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000070/VP-TEST-MARKUS-040.pdf",
365
                "http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000051/250page.pdf",
366
                "http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000039/250page.pdf",
367
                "http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000022/BigSize.pdf",
368
                "http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000023/BigSize.pdf",
369
                "http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000049/250page.pdf",
370
                "http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000050/250page.pdf",
371
                "http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000050/250page.pdf",
372
                "http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000036/250page.pdf"
373

    
374
            };
375
            BasicHttpBinding myBinding = new BasicHttpBinding();
376
            EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
377

    
378
            StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
379

    
380
            foreach (var item in uriList)
381
            {
382
                var result = await client.ConvertMenualAddAsync("111111", item, "test");
383
                Log.Text += $"Wcf Station Service call{item} {result}\n";
384
            }
385

    
386
        }
387

    
388
        private void Button_Click_2(object sender, RoutedEventArgs e)
389
        {
390
            var pageinfoList = new Markus.Message.PageInfo[]
391
            {
392
                new Markus.Message.PageInfo
393
                {
394
                    Width = 111,
395
                    Height = 111,
396
                    PageNo = 1,
397

    
398
                },
399
                new Markus.Message.PageInfo
400
                {
401
                    Width = 111,
402
                    Height = 111,
403
                    PageNo = 2,
404
                }
405

    
406
            };
407

    
408
            using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(MarkusDBConnectionString))
409
            {
410

    
411
                List<DOCPAGE> docPageList = new List<DOCPAGE>();
412

    
413
                docPageList = pageinfoList.Select(f => new DOCPAGE
414
                {
415
                    ID = GuidExtension.shortGuid(),
416
                    PAGE_WIDTH = f.Width.ToString(),
417
                    PAGE_HEIGHT = f.Height.ToString(),
418
                    PAGE_NUMBER = f.PageNo
419
                }).ToList();
420

    
421
                database.SetDocumentInfo("1df16d9a-1ea9-9a32-8a61-aad6ce4a2a49", 2, docPageList);
422
            }
423
        }
424

    
425
        private void wcfTest_Click(object sender, RoutedEventArgs e)
426
        {
427
            station.GetApplicationConfig();
428
            station.StartWcfService();
429
        }
430
        private static readonly HttpClient _Client = new HttpClient();
431
        private static JavaScriptSerializer _Serializer = new JavaScriptSerializer();
432

    
433
        private async void WebServiceTest_click(object sender, RoutedEventArgs e)
434
        {
435
            //string cookie = "";
436

    
437
            //var  uri = new Uri("http://localhost:9101/StationService/Rest/GetConvertItem"); // string 을 Uri 로 형변환
438
            //var wReq = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uri); // WebRequest 객체 형성 및 HttpWebRequest 로 형변환
439
            //wReq.Method = "POST"; // 전송 방법 "GET" or "POST"
440
            //wReq.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
441
            //wReq.Proxy = new System.Net.WebProxy("127.0.0.1", 8888);
442
            ////wReq.ServicePoint.Expect100Continue = false;
443
            ////wReq.CookieContainer = new System.Net.CookieContainer();
444
            ////wReq.CookieContainer.SetCookies(uri, cookie); // 넘겨줄 쿠키가 있을때 CookiContainer 에 저장
445

    
446
            ////POST 전송일 경우
447

    
448
            //string url = "http://localhost:9101/StationService/Rest/GetConvertItem";
449
            //var data = new SEND
450
            //{
451
            //    ProjectNo = "111111",
452
            //    DocumentID = "453"
453
            //};
454

    
455
            //var json = _Serializer.Serialize(data);
456
            //var response2 = await Request(HttpMethod.Post, url, json, new Dictionary<string, string>());
457
            //string responseText = await response2.Content.ReadAsStringAsync();
458

    
459
            //Console.WriteLine(responseText);
460

    
461

    
462
            //using (var client = new System.Net.Http.HttpClient())
463
            //{
464
            //    var uri2 = new Uri("http://localhost:9101/StationService/Rest/GetConvertItem");
465
 
466
            //    var data2 = new SEND
467
            //    {
468
            //        ProjectNo = "111111",
469
            //        DocumentID = "453"
470
            //    };
471

    
472
            //    var jsonRequest2 = JsonConvert.SerializeObject(data2);
473
            //    var stringContent = new System.Net.Http.StringContent(jsonRequest2, Encoding.UTF8, "application/json");
474
            //    var response = await client.PostAsync(uri2, stringContent);
475

    
476
            //    if (response.IsSuccessStatusCode)
477
            //    {
478
            //        System.Diagnostics.Debug.WriteLine(response.Content.Headers.First());
479
            //        System.Diagnostics.Debug.WriteLine(await response.Content.ReadAsStringAsync());
480
            //    }
481
            //}
482

    
483
            using (var client = new System.Net.Http.HttpClient())
484
            {
485
                var uri2 = new Uri("http://localhost:13009/MarkusService.svc/Rest/GetCommantList");
486

    
487
                var data2 = new SEND
488
                {
489
                    ProjectNo = "111111",
490
                    DocumentID = "453"
491
                };
492

    
493
                var jsonRequest2 = JsonConvert.SerializeObject(data2);
494
                var stringContent = new System.Net.Http.StringContent(jsonRequest2, Encoding.UTF8, "application/json");
495
                var response = await client.PostAsync(uri2, stringContent);
496

    
497
                if (response.IsSuccessStatusCode)
498
                {
499
                    System.Diagnostics.Debug.WriteLine(response.Content.Headers.First());
500
                    System.Diagnostics.Debug.WriteLine(await response.Content.ReadAsStringAsync());
501
                }
502
            }
503

    
504
            //var client2 = new System.Net.WebClient();
505
            //client2.Proxy = new System.Net.WebProxy("127.0.0.1", 8888);
506
            //var result = await client2.DownloadStringTaskAsync("http://localhost:9101/StationService/Rest/GetConvertItem?ProjectNo=111111&DocumentID=453");
507
            //System.Diagnostics.Debug.WriteLine(result);
508
        }
509

    
510
        static async Task<System.Net.Http.HttpResponseMessage> Request(HttpMethod pMethod, string pUrl, string pJsonContent, Dictionary<string, string> pHeaders)
511
        {
512
            var httpRequestMessage = new HttpRequestMessage();
513
            httpRequestMessage.Method = pMethod;
514
            httpRequestMessage.RequestUri = new Uri(pUrl);
515
            foreach (var head in pHeaders)
516
            {
517
                httpRequestMessage.Headers.Add(head.Key, head.Value);
518
            }
519
            switch (pMethod.Method)
520
            {
521
                case "POST":
522
                    HttpContent httpContent = new StringContent(pJsonContent, Encoding.UTF8, "application/json");
523
                    httpRequestMessage.Content = httpContent;
524
                    break;
525

    
526
            }
527

    
528
            return await new HttpClient().SendAsync(httpRequestMessage);
529
        }
530

    
531
        private async void ConvertWebServiceTest_click(object sender, RoutedEventArgs e)
532
        {
533
            using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(MarkusDBConnectionString))
534
            {
535

    
536
                var items = database.GetConvertItems(Markus.Message.StatusCodeType.Completed).Take(100).ToList();
537

    
538
                var service = new ConvertWebService.ConversionSoapClient();
539

    
540
                int count = 0;
541

    
542
                foreach (var item in items)
543
                {
544
                    count++;
545
                    byte[] bytes = Encoding.UTF8.GetBytes(item.OriginfilePath);
546
                    var url = Convert.ToBase64String(bytes);
547
                    var result = await service.ConvertRunAsync(count.ToString(), item.UniqueKey, item.UniqueKey + count.ToString(), count.ToString(), "111111", item.UniqueKey, url);
548

    
549
                    System.Diagnostics.Debug.WriteLine(item.ConvertID + " " + result.ToString());
550
                }
551
            }
552
        }
553
    }
554

    
555
    class IntegratedServiceInstaller
556
    {
557
        public void Install(String ServiceName, String DisplayName, String Description,
558
            System.ServiceProcess.ServiceAccount Account,
559
            System.ServiceProcess.ServiceStartMode StartMode)
560
        {
561
            System.ServiceProcess.ServiceProcessInstaller ProcessInstaller = new System.ServiceProcess.ServiceProcessInstaller();
562
            ProcessInstaller.Account = Account;
563

    
564
            System.ServiceProcess.ServiceInstaller SINST = new System.ServiceProcess.ServiceInstaller();
565

    
566
            System.Configuration.Install.InstallContext Context = new System.Configuration.Install.InstallContext();
567
            string processPath = Process.GetCurrentProcess().MainModule.FileName;
568
            if (processPath != null && processPath.Length > 0)
569
            {
570
                System.IO.FileInfo fi = new System.IO.FileInfo(processPath);
571
                //Context = new System.Configuration.Install.InstallContext();
572
                //Context.Parameters.Add("assemblyPath", fi.FullName);
573
                //Context.Parameters.Add("startParameters", "Test");
574

    
575
                String path = String.Format("/assemblypath={0}", fi.FullName);
576
                String[] cmdline = { path };
577
                Context = new System.Configuration.Install.InstallContext("", cmdline);
578
            }
579

    
580
            SINST.Context = Context;
581
            SINST.DisplayName = DisplayName;
582
            SINST.Description = Description;
583
            SINST.ServiceName = ServiceName;
584
            SINST.StartType = StartMode;
585
            SINST.Parent = ProcessInstaller;
586

    
587
            // http://bytes.com/forum/thread527221.html
588
            //            SINST.ServicesDependedOn = new String[] {};
589

    
590
            System.Collections.Specialized.ListDictionary state = new System.Collections.Specialized.ListDictionary();
591
            SINST.Install(state);
592

    
593
            // http://www.dotnet247.com/247reference/msgs/43/219565.aspx
594
            using (RegistryKey oKey = Registry.LocalMachine.OpenSubKey(String.Format(@"SYSTEM\CurrentControlSet\Services\{0}", SINST.ServiceName), true))
595
            {
596
                try
597
                {
598
                    Object sValue = oKey.GetValue("ImagePath");
599
                    oKey.SetValue("ImagePath", sValue);
600
                }
601
                catch (Exception Ex)
602
                {
603
                    //                    System.Console.WriteLine(Ex.Message);
604
                }
605
            }
606

    
607
        }
608
        public void Uninstall(String ServiceName)
609
        {
610
            System.ServiceProcess.ServiceInstaller SINST = new System.ServiceProcess.ServiceInstaller();
611

    
612
            System.Configuration.Install.InstallContext Context = new System.Configuration.Install.InstallContext("c:\\install.log", null);
613
            SINST.Context = Context;
614
            SINST.ServiceName = ServiceName;
615
            SINST.Uninstall(null);
616
        }
617
    }
618

    
619
    public class SEND
620
    {
621
        public string ProjectNo { get; set; }
622
        public string DocumentID{ get; set; }
623
}
624
}
클립보드 이미지 추가 (최대 크기: 500 MB)