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 Newtonsoft.Json.Linq;
|
9
|
using System;
|
10
|
using System.Collections.Generic;
|
11
|
using System.Diagnostics;
|
12
|
using System.IO;
|
13
|
using System.Linq;
|
14
|
using System.Net;
|
15
|
using System.Net.Http;
|
16
|
using System.ServiceModel;
|
17
|
using System.Text;
|
18
|
using System.Threading.Tasks;
|
19
|
using System.Web;
|
20
|
using System.Web.Script.Serialization;
|
21
|
using System.Windows;
|
22
|
using System.Windows.Data;
|
23
|
using System.Windows.Forms;
|
24
|
using static Markus.Service.Extensions.Encrypt;
|
25
|
|
26
|
namespace ServiceTestApp
|
27
|
{
|
28
|
/// <summary>
|
29
|
/// MainWindow.xaml에 대한 상호 작용 논리
|
30
|
/// </summary>
|
31
|
public partial class MainWindow : Window
|
32
|
{
|
33
|
public MainWindow()
|
34
|
{
|
35
|
InitializeComponent();
|
36
|
|
37
|
var config = Markus.Service.Helper.ConfigHelper.AppConfig("ServiceStation.ini");
|
38
|
MarkusDBConnectionString = AESEncrypter.Decrypt(config.GetValue(CONFIG_DEFINE.SERVICE, CONFIG_DEFINE.MARKUS_CONNECTION_STRING));
|
39
|
|
40
|
datagrid.ItemsSource = convertItems;
|
41
|
|
42
|
timer.Interval = new TimeSpan(0, 0, 0, 0, 700);
|
43
|
timer.Tick += Timer_Tick;
|
44
|
//timer.Start();
|
45
|
}
|
46
|
System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();
|
47
|
private string MarkusDBConnectionString;
|
48
|
|
49
|
private void Timer_0_Tick(object sender, EventArgs e)
|
50
|
{
|
51
|
BasicHttpBinding myBinding = new BasicHttpBinding();
|
52
|
EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
|
53
|
|
54
|
StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
|
55
|
|
56
|
var result = client.AliveConvertList();
|
57
|
|
58
|
datagrid.ItemsSource = result;
|
59
|
|
60
|
if(result.Count() < 2)
|
61
|
{
|
62
|
foreach (var filename in Directory.EnumerateFiles("D:\\Case"))
|
63
|
{
|
64
|
var additem = client.ConvertMenualAdd("111111", filename, "test");
|
65
|
|
66
|
if (!string.IsNullOrWhiteSpace(additem))
|
67
|
{
|
68
|
Log.Text += $"Wcf Station Service call{filename} {result}\n";
|
69
|
}
|
70
|
else
|
71
|
{
|
72
|
Log.Text += $"Call Error {filename} {result}\n";
|
73
|
}
|
74
|
}
|
75
|
}
|
76
|
}
|
77
|
|
78
|
private void Timer_Tick(object sender, EventArgs e)
|
79
|
{
|
80
|
timer.Stop();
|
81
|
|
82
|
using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(MarkusDBConnectionString))
|
83
|
{
|
84
|
var data = database.GetConvertItems(Markus.Message.StatusCodeType.Saving);
|
85
|
|
86
|
foreach (var item in data)
|
87
|
{
|
88
|
var getitem = convertItems.Where(f => f.ConvertID == item.ConvertID);
|
89
|
|
90
|
if (getitem.Count() == 0)
|
91
|
{
|
92
|
convertItems.Add(item);
|
93
|
}
|
94
|
else
|
95
|
{
|
96
|
var binditem = getitem.First();
|
97
|
|
98
|
binditem.ConvertState = item.ConvertState;
|
99
|
binditem.CurrentPageNo = item.CurrentPageNo;
|
100
|
binditem.TotalPage = item.TotalPage;
|
101
|
}
|
102
|
}
|
103
|
|
104
|
var _removeitems = convertItems.Select(f => f.ConvertID).Except(data.Select(x => x.ConvertID)).ToList();
|
105
|
|
106
|
foreach (var item in _removeitems)
|
107
|
{
|
108
|
var items = convertItems.Where(x => x.ConvertID == item);
|
109
|
|
110
|
if (items.Count() > 0)
|
111
|
{
|
112
|
Markus.Service.Interface.ConvertItem convertItem = items.First();
|
113
|
convertItems.Remove(convertItem);
|
114
|
}
|
115
|
}
|
116
|
}
|
117
|
|
118
|
var process = Process.GetProcessesByName("Markus.Service.ConvertProcess");
|
119
|
|
120
|
this.Dispatcher.Invoke(() =>
|
121
|
{
|
122
|
CollectionViewSource.GetDefaultView(datagrid.ItemsSource).Refresh();
|
123
|
|
124
|
if (process.Count() > 0)
|
125
|
{
|
126
|
if (Log.Text.Length > int.MaxValue)
|
127
|
{
|
128
|
Log.Text = "";
|
129
|
}
|
130
|
|
131
|
Log.Text += "-------------------------------------\n";
|
132
|
|
133
|
Log.Text += $" Physical memory usage : {process.Sum(f => f.WorkingSet64)}" + "\n";
|
134
|
Log.Text += $" Base priority : {process.Sum(f => f.BasePriority)}" + "\n";
|
135
|
//Log.Text += $" Priority class : {process[0].PriorityClass}" + "\n";
|
136
|
//Log.Text += $" User processor time : {process[0].UserProcessorTime}" + "\n";
|
137
|
//Log.Text += $" Privileged processor time : {process[0].PrivilegedProcessorTime}" + "\n";
|
138
|
//Log.Text += $" Total processor time : {process[0].TotalProcessorTime}" + "\n";
|
139
|
Log.Text += $" Paged system memory size : {process.Sum(f => f.PagedSystemMemorySize64)}" + "\n";
|
140
|
Log.Text += $" Paged memory size : {process.Sum(f => f.PagedMemorySize64)}" + "\n";
|
141
|
}
|
142
|
});
|
143
|
|
144
|
//if (process.Count() < 3)
|
145
|
//{
|
146
|
// BasicHttpBinding myBinding = new BasicHttpBinding();
|
147
|
// EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
|
148
|
// StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
|
149
|
// foreach (var filename in Directory.EnumerateFiles("D:\\Case"))
|
150
|
// {
|
151
|
// var _id = new Guid().CreateUniqueGuid().ToString();
|
152
|
|
153
|
// var result = client.ConvertMenualAdd("111111", _id, filename, "test");
|
154
|
|
155
|
// if (result)
|
156
|
// {
|
157
|
// Log.Text += $"Wcf Station Service call{filename} {result}\n";
|
158
|
// }
|
159
|
// else
|
160
|
// {
|
161
|
// Log.Text += $"Call Error {filename} {result}\n";
|
162
|
// }
|
163
|
// }
|
164
|
//}
|
165
|
|
166
|
timer.Start();
|
167
|
|
168
|
}
|
169
|
|
170
|
private System.Collections.ObjectModel.ObservableCollection<Markus.Service.Interface.ConvertItem> convertItems = new System.Collections.ObjectModel.ObservableCollection<Markus.Service.Interface.ConvertItem>();
|
171
|
|
172
|
PrivateObject stationObj;
|
173
|
Markus.Service.ServiceStation station = new Markus.Service.ServiceStation();
|
174
|
|
175
|
private void Button_Click(object sender, RoutedEventArgs e)
|
176
|
{
|
177
|
station.StartService();
|
178
|
|
179
|
// if (station == null)
|
180
|
// {
|
181
|
// station = new PrivateObject(typeof(Markus.Service.StationService.ServiceStation));
|
182
|
// }
|
183
|
|
184
|
|
185
|
|
186
|
Log.Text += "Wcf Service start\n";
|
187
|
}
|
188
|
|
189
|
private async void ServiceCall_Click(object sender, RoutedEventArgs e)
|
190
|
{
|
191
|
ConvertService.ConvertServiceClient client = new ConvertService.ConvertServiceClient();
|
192
|
var result = await client.ConvertAddAsync(1);
|
193
|
|
194
|
Log.Text += $"Wcf Convert Service call{result}\n";
|
195
|
}
|
196
|
|
197
|
private async void StationServiceCall_Click(object sender, RoutedEventArgs e)
|
198
|
{
|
199
|
StationService.StationServiceClient client = new StationService.StationServiceClient();
|
200
|
var result = await client.ConvertAddAsync("test", "11");
|
201
|
|
202
|
Log.Text += $"Wcf Station Service call{result}\n";
|
203
|
}
|
204
|
|
205
|
private async void ItemAdd_Click(object sender, RoutedEventArgs e)
|
206
|
{
|
207
|
string ProjectNo = "111111";
|
208
|
|
209
|
BasicHttpBinding myBinding = new BasicHttpBinding();
|
210
|
EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
|
211
|
StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
|
212
|
foreach (var filename in GetFileList())
|
213
|
{
|
214
|
var result = await client.ConvertMenualAddAsync("111111", filename, "test");
|
215
|
|
216
|
if (!string.IsNullOrWhiteSpace(result))
|
217
|
{
|
218
|
Log.Text += $"Wcf Station Service call{filename} convert ID : {result}\n";
|
219
|
}
|
220
|
else
|
221
|
{
|
222
|
Log.Text += $"Call Error {filename}\n";
|
223
|
}
|
224
|
}
|
225
|
|
226
|
#region 데이터베이스 테스트
|
227
|
/*
|
228
|
using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(ProjectNo))
|
229
|
{
|
230
|
foreach (var filename in GetFileList())
|
231
|
{
|
232
|
var _id = new Guid().CreateUniqueGuid().ToString();
|
233
|
|
234
|
if (!database.SetConvertDoc(ProjectNo, _id, filename,_id))
|
235
|
{
|
236
|
System.Windows.MessageBox.Show("저장에 실패!");
|
237
|
break;
|
238
|
}
|
239
|
}
|
240
|
}
|
241
|
*/
|
242
|
#endregion
|
243
|
}
|
244
|
|
245
|
private IEnumerable<string> GetFileList()
|
246
|
{
|
247
|
IEnumerable<string> result = new string[] { };
|
248
|
|
249
|
using (FolderBrowserDialog dialog = new FolderBrowserDialog())
|
250
|
{
|
251
|
dialog.Description = "PDF가 있는 폴더를 선택하세요.";
|
252
|
dialog.ShowNewFolderButton = false;
|
253
|
dialog.RootFolder = Environment.SpecialFolder.MyComputer;
|
254
|
|
255
|
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
256
|
{
|
257
|
result = Directory.EnumerateFiles(dialog.SelectedPath, "*.pdf", SearchOption.AllDirectories);
|
258
|
}
|
259
|
}
|
260
|
|
261
|
return result;
|
262
|
}
|
263
|
|
264
|
private void ServiceInstall_Click(object sender, RoutedEventArgs e)
|
265
|
{
|
266
|
//Markus.Service.ProjectInstaller projectInstaller = new Markus.Service.ProjectInstaller();
|
267
|
//Hashtable savedState = new Hashtable();
|
268
|
//projectInstaller.serviceProcessInstaller.Install(savedState);
|
269
|
|
270
|
//projectInstaller.serviceProcessInstaller.Uninstall(savedState);
|
271
|
|
272
|
|
273
|
IntegratedServiceInstaller integrated = new IntegratedServiceInstaller();
|
274
|
integrated.Install("ServiceStation", "ServiceStation", "test", System.ServiceProcess.ServiceAccount.LocalService, System.ServiceProcess.ServiceStartMode.Automatic);
|
275
|
|
276
|
}
|
277
|
|
278
|
private void LibInstall_Click(object sender, RoutedEventArgs e)
|
279
|
{
|
280
|
Markus.Library.Installer.Install();
|
281
|
}
|
282
|
|
283
|
private async void ItemAddFile_Click(object sender, RoutedEventArgs e)
|
284
|
{
|
285
|
System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
|
286
|
|
287
|
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
288
|
{
|
289
|
BasicHttpBinding myBinding = new BasicHttpBinding();
|
290
|
EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
|
291
|
|
292
|
StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
|
293
|
|
294
|
var result = await client.ConvertMenualAddAsync("111111", dialog.FileName, "test");
|
295
|
|
296
|
Log.Text += $"Wcf Station Service call{dialog.FileName} {result}\n";
|
297
|
}
|
298
|
}
|
299
|
|
300
|
private async void AliveList_Click(object sender, RoutedEventArgs e)
|
301
|
{
|
302
|
await AliveItemAsync();
|
303
|
}
|
304
|
private async Task AliveItemAsync()
|
305
|
{
|
306
|
BasicHttpBinding myBinding = new BasicHttpBinding();
|
307
|
EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
|
308
|
|
309
|
StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
|
310
|
var _id = new Guid().CreateUniqueGuid().ToString();
|
311
|
|
312
|
var result = await client.AliveConvertListAsync();
|
313
|
|
314
|
datagrid.ItemsSource = result;
|
315
|
}
|
316
|
|
317
|
private async void WaitList_Click(object sender, RoutedEventArgs e)
|
318
|
{
|
319
|
BasicHttpBinding myBinding = new BasicHttpBinding();
|
320
|
EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
|
321
|
|
322
|
StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
|
323
|
var _id = new Guid().CreateUniqueGuid().ToString();
|
324
|
|
325
|
var result = await client.WaitConvertListAsync();
|
326
|
|
327
|
datagrid.ItemsSource = result;
|
328
|
}
|
329
|
|
330
|
private void ProcessKill_Click(object sender, RoutedEventArgs e)
|
331
|
{
|
332
|
station.Stopprocess();
|
333
|
}
|
334
|
|
335
|
private void DeadLockProcessList_Click(object sender, RoutedEventArgs e)
|
336
|
{
|
337
|
station.DeadLockProcessKill();
|
338
|
}
|
339
|
|
340
|
private async void Button_Click_1(object sender, RoutedEventArgs e)
|
341
|
{
|
342
|
int count = 0;
|
343
|
|
344
|
|
345
|
if(int.TryParse(txtProcessCount.Text,out count))
|
346
|
{
|
347
|
|
348
|
BasicHttpBinding myBinding = new BasicHttpBinding();
|
349
|
EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
|
350
|
|
351
|
StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
|
352
|
|
353
|
var result = await client.SettingMultiProcessAsync(count);
|
354
|
|
355
|
}
|
356
|
}
|
357
|
|
358
|
private async void RemoteFileList_Click(object sender, RoutedEventArgs e)
|
359
|
{
|
360
|
var uriList = new[]
|
361
|
{
|
362
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000053/250page.pdf",
|
363
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000038/250page.pdf",
|
364
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000027/BigSize.pdf",
|
365
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000032/BigSize.pdf",
|
366
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000087/1-5110-ZJ-492-005_C.pdf",
|
367
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000070/VP-TEST-MARKUS-040.pdf",
|
368
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000051/250page.pdf",
|
369
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000039/250page.pdf",
|
370
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000022/BigSize.pdf",
|
371
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000023/BigSize.pdf",
|
372
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000049/250page.pdf",
|
373
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000050/250page.pdf",
|
374
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000050/250page.pdf",
|
375
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000036/250page.pdf"
|
376
|
|
377
|
};
|
378
|
BasicHttpBinding myBinding = new BasicHttpBinding();
|
379
|
EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
|
380
|
|
381
|
StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
|
382
|
|
383
|
foreach (var item in uriList)
|
384
|
{
|
385
|
var result = await client.ConvertMenualAddAsync("111111", item, "test");
|
386
|
Log.Text += $"Wcf Station Service call{item} {result}\n";
|
387
|
}
|
388
|
|
389
|
}
|
390
|
|
391
|
private void Button_Click_2(object sender, RoutedEventArgs e)
|
392
|
{
|
393
|
var pageinfoList = new Markus.Message.PageInfo[]
|
394
|
{
|
395
|
new Markus.Message.PageInfo
|
396
|
{
|
397
|
Width = 111,
|
398
|
Height = 111,
|
399
|
PageNo = 1,
|
400
|
|
401
|
},
|
402
|
new Markus.Message.PageInfo
|
403
|
{
|
404
|
Width = 111,
|
405
|
Height = 111,
|
406
|
PageNo = 2,
|
407
|
}
|
408
|
|
409
|
};
|
410
|
|
411
|
using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(MarkusDBConnectionString))
|
412
|
{
|
413
|
|
414
|
List<DOCPAGE> docPageList = new List<DOCPAGE>();
|
415
|
|
416
|
docPageList = pageinfoList.Select(f => new DOCPAGE
|
417
|
{
|
418
|
ID = GuidExtension.shortGuid(),
|
419
|
PAGE_WIDTH = f.Width.ToString(),
|
420
|
PAGE_HEIGHT = f.Height.ToString(),
|
421
|
PAGE_NUMBER = f.PageNo
|
422
|
}).ToList();
|
423
|
|
424
|
database.SetDocumentInfo("1df16d9a-1ea9-9a32-8a61-aad6ce4a2a49", 2, docPageList);
|
425
|
}
|
426
|
}
|
427
|
|
428
|
private void wcfTest_Click(object sender, RoutedEventArgs e)
|
429
|
{
|
430
|
station.GetApplicationConfig();
|
431
|
station.StartWcfService();
|
432
|
}
|
433
|
private static readonly HttpClient _Client = new HttpClient();
|
434
|
private static JavaScriptSerializer _Serializer = new JavaScriptSerializer();
|
435
|
|
436
|
private async void WebServiceTest_click(object sender, RoutedEventArgs e)
|
437
|
{
|
438
|
//string cookie = "";
|
439
|
|
440
|
//var uri = new Uri("http://localhost:9101/StationService/Rest/GetConvertItem"); // string 을 Uri 로 형변환
|
441
|
//var wReq = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uri); // WebRequest 객체 형성 및 HttpWebRequest 로 형변환
|
442
|
//wReq.Method = "POST"; // 전송 방법 "GET" or "POST"
|
443
|
//wReq.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
|
444
|
//wReq.Proxy = new System.Net.WebProxy("127.0.0.1", 8888);
|
445
|
////wReq.ServicePoint.Expect100Continue = false;
|
446
|
////wReq.CookieContainer = new System.Net.CookieContainer();
|
447
|
////wReq.CookieContainer.SetCookies(uri, cookie); // 넘겨줄 쿠키가 있을때 CookiContainer 에 저장
|
448
|
|
449
|
////POST 전송일 경우
|
450
|
|
451
|
//string url = "http://localhost:9101/StationService/Rest/GetConvertItem";
|
452
|
//var data = new SEND
|
453
|
//{
|
454
|
// ProjectNo = "111111",
|
455
|
// DocumentID = "453"
|
456
|
//};
|
457
|
|
458
|
//var json = _Serializer.Serialize(data);
|
459
|
//var response2 = await Request(HttpMethod.Post, url, json, new Dictionary<string, string>());
|
460
|
//string responseText = await response2.Content.ReadAsStringAsync();
|
461
|
|
462
|
//Console.WriteLine(responseText);
|
463
|
|
464
|
using (var client = new System.Net.Http.HttpClient())
|
465
|
{
|
466
|
|
467
|
var uri2 = new Uri("http://localhost:9101/StationService/Rest/GetConvertItem");
|
468
|
var data2 = new SEND
|
469
|
{
|
470
|
ProjectNo = "111111",
|
471
|
DocumentID = "453"
|
472
|
};
|
473
|
|
474
|
var jsonRequest2 = JsonConvert.SerializeObject(data2);
|
475
|
var stringContent = new System.Net.Http.StringContent(jsonRequest2, Encoding.UTF8, "application/json");
|
476
|
var response = await client.PostAsync(uri2, stringContent);
|
477
|
|
478
|
if (response.IsSuccessStatusCode)
|
479
|
{
|
480
|
System.Diagnostics.Debug.WriteLine(response.Content.Headers.First());
|
481
|
System.Diagnostics.Debug.WriteLine(await response.Content.ReadAsStringAsync());
|
482
|
}
|
483
|
}
|
484
|
|
485
|
//using (var client = new System.Net.Http.HttpClient())
|
486
|
//{
|
487
|
// var uri2 = new Uri("http://localhost:13009/MarkusService.svc/Rest/GetCommantList");
|
488
|
|
489
|
// var data2 = new SEND
|
490
|
// {
|
491
|
// ProjectNo = "111111",
|
492
|
// DocumentID = "453"
|
493
|
// };
|
494
|
|
495
|
// var jsonRequest2 = JsonConvert.SerializeObject(data2);
|
496
|
// var stringContent = new System.Net.Http.StringContent(jsonRequest2, Encoding.UTF8, "application/json");
|
497
|
// var response = await client.PostAsync(uri2, stringContent);
|
498
|
|
499
|
// if (response.IsSuccessStatusCode)
|
500
|
// {
|
501
|
// System.Diagnostics.Debug.WriteLine(response.Content.Headers.First());
|
502
|
// System.Diagnostics.Debug.WriteLine(await response.Content.ReadAsStringAsync());
|
503
|
// }
|
504
|
//}
|
505
|
|
506
|
//var client2 = new System.Net.WebClient();
|
507
|
//client2.Proxy = new System.Net.WebProxy("127.0.0.1", 8888);
|
508
|
//var result = await client2.DownloadStringTaskAsync("http://localhost:9101/StationService/Rest/GetConvertItem?ProjectNo=111111&DocumentID=453");
|
509
|
//System.Diagnostics.Debug.WriteLine(result);
|
510
|
}
|
511
|
|
512
|
static async Task<System.Net.Http.HttpResponseMessage> Request(HttpMethod pMethod, string pUrl, string pJsonContent, Dictionary<string, string> pHeaders)
|
513
|
{
|
514
|
var httpRequestMessage = new HttpRequestMessage();
|
515
|
httpRequestMessage.Method = pMethod;
|
516
|
httpRequestMessage.RequestUri = new Uri(pUrl);
|
517
|
foreach (var head in pHeaders)
|
518
|
{
|
519
|
httpRequestMessage.Headers.Add(head.Key, head.Value);
|
520
|
}
|
521
|
switch (pMethod.Method)
|
522
|
{
|
523
|
case "POST":
|
524
|
HttpContent httpContent = new StringContent(pJsonContent, Encoding.UTF8, "application/json");
|
525
|
httpRequestMessage.Content = httpContent;
|
526
|
break;
|
527
|
|
528
|
}
|
529
|
|
530
|
return await new HttpClient().SendAsync(httpRequestMessage);
|
531
|
}
|
532
|
|
533
|
private async void ConvertWebServiceTest_click(object sender, RoutedEventArgs e)
|
534
|
{
|
535
|
using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(MarkusDBConnectionString))
|
536
|
{
|
537
|
|
538
|
var items = database.GetConvertItems(Markus.Message.StatusCodeType.Completed).Take(100).ToList();
|
539
|
|
540
|
var service = new ConvertWebService.ConversionSoapClient();
|
541
|
|
542
|
int count = 0;
|
543
|
|
544
|
foreach (var item in items)
|
545
|
{
|
546
|
count++;
|
547
|
byte[] bytes = Encoding.UTF8.GetBytes(item.OriginfilePath);
|
548
|
var url = Convert.ToBase64String(bytes);
|
549
|
var result = await service.ConvertRunAsync(count.ToString(), item.UniqueKey, item.UniqueKey + count.ToString(), count.ToString(), "111111", item.UniqueKey, url);
|
550
|
|
551
|
System.Diagnostics.Debug.WriteLine(item.ConvertID + " " + result.ToString());
|
552
|
}
|
553
|
}
|
554
|
}
|
555
|
|
556
|
private async void DownLoadTest_click(object sender, RoutedEventArgs e)
|
557
|
{
|
558
|
await DownloadFileAsync("http://172.20.110.75:8880/ifweb/external/DLMFileDownload.jsp?objectId=33808.61925.45058.48300&format=Original PDF&fileName=MARKUS_20190731_0001_A.pdf");
|
559
|
}
|
560
|
|
561
|
private async Task<bool> DownloadFileAsync(string FileaPath)
|
562
|
{
|
563
|
bool result = false;
|
564
|
|
565
|
try
|
566
|
{
|
567
|
Uri pdfFileUri = null;
|
568
|
|
569
|
//if (saveItem.PdfFilePath.Contains("VPCS_DOCLIB"))
|
570
|
//{
|
571
|
// FileName = DocUri.Remove(0, DocUri.LastIndexOf("/") + 1);
|
572
|
// ProjectFolderPath = DownloadDir_PDF + "\\" + ConverterItem.PROJECT_NO + "_Tile"; //프로젝트 폴더
|
573
|
// ItemListPath = ProjectFolderPath + "\\" + (System.Convert.ToInt64(ConverterItem.DOCUMENT_ID) / 100).ToString();
|
574
|
// ItemPath = ItemListPath + "\\" + ConverterItem.DOCUMENT_ID;
|
575
|
// DownloadFilePath = ItemPath + "\\" + FileName;
|
576
|
//}
|
577
|
//else
|
578
|
//{
|
579
|
// ProjectFolderPath = DownloadDir_PDF + "\\" + ConverterItem.PROJECT_NO + "_Tile"; //프로젝트 폴더
|
580
|
// ItemListPath = ProjectFolderPath + "\\" + (System.Convert.ToInt64(ConverterItem.DOCUMENT_ID) / 100).ToString();
|
581
|
// ItemPath = ItemListPath + "\\" + ConverterItem.DOCUMENT_ID;
|
582
|
// FileName = HttpUtility.ParseQueryString(new Uri(DocUri).Query).Get("fileName");
|
583
|
// DownloadFilePath = string.IsNullOrWhiteSpace(FileName) ? ItemPath + "\\" + FileName : ItemPath + "\\" + FileName;
|
584
|
|
585
|
//}
|
586
|
|
587
|
FileaPath = HttpUtility.UrlDecode(FileaPath); //PDF 전체 경로
|
588
|
string FileName = DownloadUri.GetFileName(FileaPath);
|
589
|
|
590
|
string downloadFilePath = System.IO.Path.Combine(@"c:\temp", FileName);
|
591
|
|
592
|
// 드라이브 경로가 포함되었는지 판단.
|
593
|
if (Path.IsPathRooted(FileaPath))
|
594
|
{
|
595
|
if (File.Exists(FileaPath))
|
596
|
{
|
597
|
File.Copy(FileaPath, downloadFilePath, true);
|
598
|
}
|
599
|
else
|
600
|
{
|
601
|
throw new Exception("File Not Found. Please, check the file path.");
|
602
|
}
|
603
|
}
|
604
|
else if (Uri.TryCreate(FileaPath, UriKind.RelativeOrAbsolute, out pdfFileUri))
|
605
|
{
|
606
|
try
|
607
|
{
|
608
|
using (System.Net.WebClient webClient = new System.Net.WebClient())
|
609
|
{
|
610
|
webClient.UseDefaultCredentials = true;//.Headers.Add("Authorization: BASIC SGVsbG8="); //가상의 인증
|
611
|
|
612
|
//if (!System.IO.Directory.Exists(ConvertProcessContext.TempDirectory))
|
613
|
//{
|
614
|
// System.IO.Directory.CreateDirectory(ConvertProcessContext.TempDirectory);
|
615
|
//}
|
616
|
|
617
|
await webClient.DownloadFileTaskAsync(pdfFileUri, downloadFilePath);
|
618
|
}
|
619
|
}
|
620
|
catch (Exception)
|
621
|
{
|
622
|
throw new Exception("File Download Error. Please, check the file path.");
|
623
|
}
|
624
|
}
|
625
|
else
|
626
|
{
|
627
|
throw new Exception("Please, check the file path.");
|
628
|
}
|
629
|
|
630
|
if (File.Exists(downloadFilePath))
|
631
|
{
|
632
|
var file = File.Open(downloadFilePath, FileMode.Open);
|
633
|
|
634
|
if (file.Length == 0)
|
635
|
{
|
636
|
throw new Exception("File Size 0. Please, check the file path.");
|
637
|
}
|
638
|
|
639
|
file.Close();
|
640
|
file.Dispose();
|
641
|
|
642
|
FileaPath = downloadFilePath;
|
643
|
result = true;
|
644
|
|
645
|
}
|
646
|
}
|
647
|
catch (Exception EX)
|
648
|
{
|
649
|
System.Diagnostics.Debug.WriteLine(EX.ToString());
|
650
|
result = false;
|
651
|
}
|
652
|
|
653
|
return result;
|
654
|
}
|
655
|
|
656
|
private void ServiceCallTest_click(object sender, RoutedEventArgs e)
|
657
|
{
|
658
|
using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(MarkusDBConnectionString))
|
659
|
{
|
660
|
|
661
|
var items = database.GetConvertItems(Markus.Message.StatusCodeType.Completed).Take(100).ToList();
|
662
|
|
663
|
int count = 0;
|
664
|
|
665
|
foreach (var item in items)
|
666
|
{
|
667
|
database.SetCleanUpItem(item.ConvertID, 0);
|
668
|
|
669
|
System.Net.WebClient client = new System.Net.WebClient();
|
670
|
var convertResult = client.DownloadString($"http://192.168.0.129:9101/StationService/Rest/ConvertAdd?ProjectNo={item.ProjectNumber}&DocumentID={item.ConvertID}");
|
671
|
|
672
|
JObject jObject = JObject.Parse(convertResult, new JsonLoadSettings());
|
673
|
var result = jObject["ConvertAddResult"].ToString();
|
674
|
System.Diagnostics.Debug.WriteLine(item.ConvertID + " " + result.ToString());
|
675
|
}
|
676
|
}
|
677
|
}
|
678
|
|
679
|
private void ConfingSectionTest_click(object sender, RoutedEventArgs e)
|
680
|
{
|
681
|
var config = Markus.Service.Helper.ConfigHelper.AppConfig("Plugin.ini");
|
682
|
|
683
|
Dictionary<string, object> parameters = new Dictionary<string, object>();
|
684
|
|
685
|
var sections = config.Sections.Where(x => x.SectionName == "PemssDocumentInfo").FirstOrDefault();
|
686
|
|
687
|
foreach (var item in sections.Keys)
|
688
|
{
|
689
|
parameters.Add(item.Name,item.Content);
|
690
|
}
|
691
|
}
|
692
|
|
693
|
private void PemssPluginTest_click(object sender, RoutedEventArgs e)
|
694
|
{
|
695
|
|
696
|
}
|
697
|
|
698
|
private void MonitorTest_Click(object sender, RoutedEventArgs e)
|
699
|
{
|
700
|
Markus.Service.MonitorService.ServiceMonitor service = new Markus.Service.MonitorService.ServiceMonitor();
|
701
|
service.Start(null);
|
702
|
}
|
703
|
|
704
|
private async void FileDownloadTest_Click(object sender, RoutedEventArgs e)
|
705
|
{
|
706
|
try
|
707
|
{
|
708
|
if (!string.IsNullOrWhiteSpace(txtEncodeDownloadFile.Text))
|
709
|
{
|
710
|
txtDecodeDownloadFile.Text = HttpUtility.UrlDecode(txtEncodeDownloadFile.Text);
|
711
|
}
|
712
|
|
713
|
if(!string.IsNullOrWhiteSpace(txtDecodeDownloadFile.Text))
|
714
|
{
|
715
|
txtEncodeDownloadFile.Text = HttpUtility.UrlEncode(txtDecodeDownloadFile.Text);
|
716
|
}
|
717
|
|
718
|
string File = txtEncodeDownloadFile.Text;
|
719
|
string Savepath = txtSavePath.Text;
|
720
|
|
721
|
if (!System.IO.Directory.Exists(Savepath))
|
722
|
{
|
723
|
System.IO.Directory.CreateDirectory(Savepath);
|
724
|
}
|
725
|
|
726
|
Markus.Service.Convert.ConvertService convertService = new Markus.Service.Convert.ConvertService();
|
727
|
|
728
|
var result = await convertService.DownloadFileAsync(new Markus.Message.SaveItem { PdfFilePath = File, SavePath = Savepath });
|
729
|
|
730
|
System.Windows.MessageBox.Show(result.ToString());
|
731
|
}
|
732
|
catch (Exception ex)
|
733
|
{
|
734
|
System.Windows.MessageBox.Show(ex.ToString());
|
735
|
}
|
736
|
}
|
737
|
}
|
738
|
|
739
|
class IntegratedServiceInstaller
|
740
|
{
|
741
|
public void Install(String ServiceName, String DisplayName, String Description,
|
742
|
System.ServiceProcess.ServiceAccount Account,
|
743
|
System.ServiceProcess.ServiceStartMode StartMode)
|
744
|
{
|
745
|
System.ServiceProcess.ServiceProcessInstaller ProcessInstaller = new System.ServiceProcess.ServiceProcessInstaller();
|
746
|
ProcessInstaller.Account = Account;
|
747
|
|
748
|
System.ServiceProcess.ServiceInstaller SINST = new System.ServiceProcess.ServiceInstaller();
|
749
|
|
750
|
System.Configuration.Install.InstallContext Context = new System.Configuration.Install.InstallContext();
|
751
|
string processPath = Process.GetCurrentProcess().MainModule.FileName;
|
752
|
if (processPath != null && processPath.Length > 0)
|
753
|
{
|
754
|
System.IO.FileInfo fi = new System.IO.FileInfo(processPath);
|
755
|
//Context = new System.Configuration.Install.InstallContext();
|
756
|
//Context.Parameters.Add("assemblyPath", fi.FullName);
|
757
|
//Context.Parameters.Add("startParameters", "Test");
|
758
|
|
759
|
String path = String.Format("/assemblypath={0}", fi.FullName);
|
760
|
String[] cmdline = { path };
|
761
|
Context = new System.Configuration.Install.InstallContext("", cmdline);
|
762
|
}
|
763
|
|
764
|
SINST.Context = Context;
|
765
|
SINST.DisplayName = DisplayName;
|
766
|
SINST.Description = Description;
|
767
|
SINST.ServiceName = ServiceName;
|
768
|
SINST.StartType = StartMode;
|
769
|
SINST.Parent = ProcessInstaller;
|
770
|
|
771
|
// http://bytes.com/forum/thread527221.html
|
772
|
// SINST.ServicesDependedOn = new String[] {};
|
773
|
|
774
|
System.Collections.Specialized.ListDictionary state = new System.Collections.Specialized.ListDictionary();
|
775
|
SINST.Install(state);
|
776
|
|
777
|
// http://www.dotnet247.com/247reference/msgs/43/219565.aspx
|
778
|
using (RegistryKey oKey = Registry.LocalMachine.OpenSubKey(String.Format(@"SYSTEM\CurrentControlSet\Services\{0}", SINST.ServiceName), true))
|
779
|
{
|
780
|
try
|
781
|
{
|
782
|
Object sValue = oKey.GetValue("ImagePath");
|
783
|
oKey.SetValue("ImagePath", sValue);
|
784
|
}
|
785
|
catch (Exception Ex)
|
786
|
{
|
787
|
// System.Console.WriteLine(Ex.Message);
|
788
|
}
|
789
|
}
|
790
|
|
791
|
}
|
792
|
public void Uninstall(String ServiceName)
|
793
|
{
|
794
|
System.ServiceProcess.ServiceInstaller SINST = new System.ServiceProcess.ServiceInstaller();
|
795
|
|
796
|
System.Configuration.Install.InstallContext Context = new System.Configuration.Install.InstallContext("c:\\install.log", null);
|
797
|
SINST.Context = Context;
|
798
|
SINST.ServiceName = ServiceName;
|
799
|
SINST.Uninstall(null);
|
800
|
}
|
801
|
}
|
802
|
|
803
|
public class SEND
|
804
|
{
|
805
|
public string ProjectNo { get; set; }
|
806
|
public string DocumentID{ get; set; }
|
807
|
}
|
808
|
}
|