1 |
53c9637d
|
taeseongkim
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
2 |
|
|
using System;
|
3 |
|
|
using System.Collections.Generic;
|
4 |
|
|
using System.IO;
|
5 |
|
|
using System.Linq;
|
6 |
|
|
using System.ServiceModel;
|
7 |
|
|
using System.Text;
|
8 |
|
|
using System.Threading.Tasks;
|
9 |
|
|
using System.Windows;
|
10 |
|
|
using System.Windows.Controls;
|
11 |
|
|
using System.Windows.Data;
|
12 |
|
|
using System.Windows.Documents;
|
13 |
|
|
using System.Windows.Forms;
|
14 |
|
|
using System.Windows.Input;
|
15 |
|
|
using System.Windows.Media;
|
16 |
|
|
using System.Windows.Media.Imaging;
|
17 |
|
|
using System.Windows.Navigation;
|
18 |
|
|
using System.Windows.Shapes;
|
19 |
|
|
using Markus.Service.Extensions;
|
20 |
|
|
using System.Diagnostics;
|
21 |
|
|
using System.Collections;
|
22 |
|
|
using Microsoft.Win32;
|
23 |
|
|
using Markus.Service.IWcfService;
|
24 |
|
|
using Markus.Service;
|
25 |
|
|
using static Markus.Service.Extensions.Encrypt;
|
26 |
|
|
using Markus.Service.Helper;
|
27 |
|
|
using Markus.Service.DataBase;
|
28 |
|
|
using Newtonsoft.Json;
|
29 |
c433ebde
|
taeseongkim
|
using System.Web.Script.Serialization;
|
30 |
|
|
using System.Net.Http;
|
31 |
06f13e11
|
taeseongkim
|
using System.Web;
|
32 |
53c9637d
|
taeseongkim
|
|
33 |
|
|
namespace ServiceTestApp
|
34 |
|
|
{
|
35 |
|
|
/// <summary>
|
36 |
|
|
/// MainWindow.xaml에 대한 상호 작용 논리
|
37 |
|
|
/// </summary>
|
38 |
|
|
public partial class MainWindow : Window
|
39 |
|
|
{
|
40 |
|
|
public MainWindow()
|
41 |
|
|
{
|
42 |
|
|
InitializeComponent();
|
43 |
|
|
|
44 |
a537d79a
|
taeseongkim
|
var config = Markus.Service.Helper.ConfigHelper.AppConfig("ServiceStation.ini");
|
45 |
53c9637d
|
taeseongkim
|
MarkusDBConnectionString = AESEncrypter.Decrypt(config.GetValue(CONFIG_DEFINE.SERVICE, CONFIG_DEFINE.MARKUS_CONNECTION_STRING));
|
46 |
|
|
|
47 |
|
|
datagrid.ItemsSource = convertItems;
|
48 |
|
|
|
49 |
|
|
timer.Interval = new TimeSpan(0, 0, 0, 0, 700);
|
50 |
|
|
timer.Tick += Timer_Tick;
|
51 |
06f13e11
|
taeseongkim
|
//timer.Start();
|
52 |
53c9637d
|
taeseongkim
|
}
|
53 |
|
|
System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();
|
54 |
|
|
private string MarkusDBConnectionString;
|
55 |
|
|
|
56 |
|
|
private void Timer_0_Tick(object sender, EventArgs e)
|
57 |
|
|
{
|
58 |
|
|
BasicHttpBinding myBinding = new BasicHttpBinding();
|
59 |
|
|
EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
|
60 |
|
|
|
61 |
|
|
StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
|
62 |
|
|
|
63 |
|
|
var result = client.AliveConvertList();
|
64 |
|
|
|
65 |
|
|
datagrid.ItemsSource = result;
|
66 |
|
|
|
67 |
|
|
if(result.Count() < 2)
|
68 |
|
|
{
|
69 |
|
|
foreach (var filename in Directory.EnumerateFiles("D:\\Case"))
|
70 |
|
|
{
|
71 |
|
|
var additem = client.ConvertMenualAdd("111111", filename, "test");
|
72 |
|
|
|
73 |
|
|
if (!string.IsNullOrWhiteSpace(additem))
|
74 |
|
|
{
|
75 |
|
|
Log.Text += $"Wcf Station Service call{filename} {result}\n";
|
76 |
|
|
}
|
77 |
|
|
else
|
78 |
|
|
{
|
79 |
|
|
Log.Text += $"Call Error {filename} {result}\n";
|
80 |
|
|
}
|
81 |
|
|
}
|
82 |
|
|
}
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
private void Timer_Tick(object sender, EventArgs e)
|
86 |
|
|
{
|
87 |
|
|
timer.Stop();
|
88 |
|
|
|
89 |
|
|
using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(MarkusDBConnectionString))
|
90 |
|
|
{
|
91 |
|
|
var data = database.GetConvertItems(Markus.Message.StatusCodeType.Saving);
|
92 |
|
|
|
93 |
|
|
foreach (var item in data)
|
94 |
|
|
{
|
95 |
|
|
var getitem = convertItems.Where(f => f.ConvertID == item.ConvertID);
|
96 |
|
|
|
97 |
|
|
if (getitem.Count() == 0)
|
98 |
|
|
{
|
99 |
|
|
convertItems.Add(item);
|
100 |
|
|
}
|
101 |
|
|
else
|
102 |
|
|
{
|
103 |
|
|
var binditem = getitem.First();
|
104 |
|
|
|
105 |
|
|
binditem.ConvertState = item.ConvertState;
|
106 |
|
|
binditem.CurrentPageNo = item.CurrentPageNo;
|
107 |
|
|
binditem.TotalPage = item.TotalPage;
|
108 |
|
|
}
|
109 |
|
|
}
|
110 |
|
|
|
111 |
|
|
var _removeitems = convertItems.Select(f => f.ConvertID).Except(data.Select(x => x.ConvertID)).ToList();
|
112 |
|
|
|
113 |
|
|
foreach (var item in _removeitems)
|
114 |
|
|
{
|
115 |
|
|
var items = convertItems.Where(x => x.ConvertID == item);
|
116 |
|
|
|
117 |
|
|
if (items.Count() > 0)
|
118 |
|
|
{
|
119 |
|
|
Markus.Service.Interface.ConvertItem convertItem = items.First();
|
120 |
|
|
convertItems.Remove(convertItem);
|
121 |
|
|
}
|
122 |
|
|
}
|
123 |
|
|
}
|
124 |
|
|
|
125 |
|
|
var process = Process.GetProcessesByName("Markus.Service.ConvertProcess");
|
126 |
|
|
|
127 |
|
|
this.Dispatcher.Invoke(() =>
|
128 |
|
|
{
|
129 |
|
|
CollectionViewSource.GetDefaultView(datagrid.ItemsSource).Refresh();
|
130 |
|
|
|
131 |
|
|
if (process.Count() > 0)
|
132 |
|
|
{
|
133 |
|
|
if (Log.Text.Length > int.MaxValue)
|
134 |
|
|
{
|
135 |
|
|
Log.Text = "";
|
136 |
|
|
}
|
137 |
|
|
|
138 |
|
|
Log.Text += "-------------------------------------\n";
|
139 |
|
|
|
140 |
|
|
Log.Text += $" Physical memory usage : {process.Sum(f => f.WorkingSet64)}" + "\n";
|
141 |
|
|
Log.Text += $" Base priority : {process.Sum(f => f.BasePriority)}" + "\n";
|
142 |
|
|
//Log.Text += $" Priority class : {process[0].PriorityClass}" + "\n";
|
143 |
|
|
//Log.Text += $" User processor time : {process[0].UserProcessorTime}" + "\n";
|
144 |
|
|
//Log.Text += $" Privileged processor time : {process[0].PrivilegedProcessorTime}" + "\n";
|
145 |
|
|
//Log.Text += $" Total processor time : {process[0].TotalProcessorTime}" + "\n";
|
146 |
|
|
Log.Text += $" Paged system memory size : {process.Sum(f => f.PagedSystemMemorySize64)}" + "\n";
|
147 |
|
|
Log.Text += $" Paged memory size : {process.Sum(f => f.PagedMemorySize64)}" + "\n";
|
148 |
|
|
}
|
149 |
|
|
});
|
150 |
|
|
|
151 |
|
|
//if (process.Count() < 3)
|
152 |
|
|
//{
|
153 |
|
|
// BasicHttpBinding myBinding = new BasicHttpBinding();
|
154 |
|
|
// EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
|
155 |
|
|
// StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
|
156 |
|
|
// foreach (var filename in Directory.EnumerateFiles("D:\\Case"))
|
157 |
|
|
// {
|
158 |
|
|
// var _id = new Guid().CreateUniqueGuid().ToString();
|
159 |
|
|
|
160 |
|
|
// var result = client.ConvertMenualAdd("111111", _id, filename, "test");
|
161 |
|
|
|
162 |
|
|
// if (result)
|
163 |
|
|
// {
|
164 |
|
|
// Log.Text += $"Wcf Station Service call{filename} {result}\n";
|
165 |
|
|
// }
|
166 |
|
|
// else
|
167 |
|
|
// {
|
168 |
|
|
// Log.Text += $"Call Error {filename} {result}\n";
|
169 |
|
|
// }
|
170 |
|
|
// }
|
171 |
|
|
//}
|
172 |
|
|
|
173 |
|
|
timer.Start();
|
174 |
|
|
|
175 |
|
|
}
|
176 |
|
|
|
177 |
|
|
private System.Collections.ObjectModel.ObservableCollection<Markus.Service.Interface.ConvertItem> convertItems = new System.Collections.ObjectModel.ObservableCollection<Markus.Service.Interface.ConvertItem>();
|
178 |
|
|
|
179 |
|
|
PrivateObject stationObj;
|
180 |
|
|
Markus.Service.ServiceStation station = new Markus.Service.ServiceStation();
|
181 |
|
|
|
182 |
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
183 |
|
|
{
|
184 |
|
|
station.StartService();
|
185 |
|
|
|
186 |
|
|
// if (station == null)
|
187 |
|
|
// {
|
188 |
|
|
// station = new PrivateObject(typeof(Markus.Service.StationService.ServiceStation));
|
189 |
|
|
// }
|
190 |
|
|
|
191 |
|
|
|
192 |
|
|
|
193 |
|
|
Log.Text += "Wcf Service start\n";
|
194 |
|
|
}
|
195 |
|
|
|
196 |
|
|
private async void ServiceCall_Click(object sender, RoutedEventArgs e)
|
197 |
|
|
{
|
198 |
|
|
ConvertService.ConvertServiceClient client = new ConvertService.ConvertServiceClient();
|
199 |
|
|
var result = await client.ConvertAddAsync(1);
|
200 |
|
|
|
201 |
|
|
Log.Text += $"Wcf Convert Service call{result}\n";
|
202 |
|
|
}
|
203 |
|
|
|
204 |
|
|
private async void StationServiceCall_Click(object sender, RoutedEventArgs e)
|
205 |
|
|
{
|
206 |
|
|
StationService.StationServiceClient client = new StationService.StationServiceClient();
|
207 |
|
|
var result = await client.ConvertAddAsync("test", "11");
|
208 |
|
|
|
209 |
|
|
Log.Text += $"Wcf Station Service call{result}\n";
|
210 |
|
|
}
|
211 |
|
|
|
212 |
|
|
private async void ItemAdd_Click(object sender, RoutedEventArgs e)
|
213 |
|
|
{
|
214 |
|
|
string ProjectNo = "111111";
|
215 |
|
|
|
216 |
|
|
BasicHttpBinding myBinding = new BasicHttpBinding();
|
217 |
|
|
EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
|
218 |
|
|
StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
|
219 |
|
|
foreach (var filename in GetFileList())
|
220 |
|
|
{
|
221 |
|
|
var result = await client.ConvertMenualAddAsync("111111", filename, "test");
|
222 |
|
|
|
223 |
|
|
if (!string.IsNullOrWhiteSpace(result))
|
224 |
|
|
{
|
225 |
|
|
Log.Text += $"Wcf Station Service call{filename} convert ID : {result}\n";
|
226 |
|
|
}
|
227 |
|
|
else
|
228 |
|
|
{
|
229 |
|
|
Log.Text += $"Call Error {filename}\n";
|
230 |
|
|
}
|
231 |
|
|
}
|
232 |
|
|
|
233 |
|
|
#region 데이터베이스 테스트
|
234 |
|
|
/*
|
235 |
|
|
using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(ProjectNo))
|
236 |
|
|
{
|
237 |
|
|
foreach (var filename in GetFileList())
|
238 |
|
|
{
|
239 |
|
|
var _id = new Guid().CreateUniqueGuid().ToString();
|
240 |
|
|
|
241 |
|
|
if (!database.SetConvertDoc(ProjectNo, _id, filename,_id))
|
242 |
|
|
{
|
243 |
|
|
System.Windows.MessageBox.Show("저장에 실패!");
|
244 |
|
|
break;
|
245 |
|
|
}
|
246 |
|
|
}
|
247 |
|
|
}
|
248 |
|
|
*/
|
249 |
|
|
#endregion
|
250 |
|
|
}
|
251 |
|
|
|
252 |
|
|
private IEnumerable<string> GetFileList()
|
253 |
|
|
{
|
254 |
|
|
IEnumerable<string> result = new string[] { };
|
255 |
|
|
|
256 |
|
|
using (FolderBrowserDialog dialog = new FolderBrowserDialog())
|
257 |
|
|
{
|
258 |
|
|
dialog.Description = "PDF가 있는 폴더를 선택하세요.";
|
259 |
|
|
dialog.ShowNewFolderButton = false;
|
260 |
|
|
dialog.RootFolder = Environment.SpecialFolder.MyComputer;
|
261 |
|
|
|
262 |
|
|
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
263 |
|
|
{
|
264 |
|
|
result = Directory.EnumerateFiles(dialog.SelectedPath, "*.pdf", SearchOption.AllDirectories);
|
265 |
|
|
}
|
266 |
|
|
}
|
267 |
|
|
|
268 |
|
|
return result;
|
269 |
|
|
}
|
270 |
|
|
|
271 |
|
|
private void ServiceInstall_Click(object sender, RoutedEventArgs e)
|
272 |
|
|
{
|
273 |
|
|
//Markus.Service.ProjectInstaller projectInstaller = new Markus.Service.ProjectInstaller();
|
274 |
|
|
//Hashtable savedState = new Hashtable();
|
275 |
|
|
//projectInstaller.serviceProcessInstaller.Install(savedState);
|
276 |
|
|
|
277 |
|
|
//projectInstaller.serviceProcessInstaller.Uninstall(savedState);
|
278 |
|
|
|
279 |
|
|
|
280 |
|
|
IntegratedServiceInstaller integrated = new IntegratedServiceInstaller();
|
281 |
|
|
integrated.Install("ServiceStation", "ServiceStation", "test", System.ServiceProcess.ServiceAccount.LocalService, System.ServiceProcess.ServiceStartMode.Automatic);
|
282 |
|
|
|
283 |
|
|
}
|
284 |
|
|
|
285 |
|
|
private void LibInstall_Click(object sender, RoutedEventArgs e)
|
286 |
|
|
{
|
287 |
|
|
Markus.Library.Installer.Install();
|
288 |
|
|
}
|
289 |
|
|
|
290 |
|
|
private async void ItemAddFile_Click(object sender, RoutedEventArgs e)
|
291 |
|
|
{
|
292 |
|
|
System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
|
293 |
|
|
|
294 |
|
|
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
295 |
|
|
{
|
296 |
|
|
BasicHttpBinding myBinding = new BasicHttpBinding();
|
297 |
|
|
EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
|
298 |
|
|
|
299 |
|
|
StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
|
300 |
|
|
|
301 |
|
|
var result = await client.ConvertMenualAddAsync("111111", dialog.FileName, "test");
|
302 |
|
|
|
303 |
|
|
Log.Text += $"Wcf Station Service call{dialog.FileName} {result}\n";
|
304 |
|
|
}
|
305 |
|
|
}
|
306 |
|
|
|
307 |
|
|
private async void AliveList_Click(object sender, RoutedEventArgs e)
|
308 |
|
|
{
|
309 |
|
|
await AliveItemAsync();
|
310 |
|
|
}
|
311 |
|
|
private async Task AliveItemAsync()
|
312 |
|
|
{
|
313 |
|
|
BasicHttpBinding myBinding = new BasicHttpBinding();
|
314 |
|
|
EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
|
315 |
|
|
|
316 |
|
|
StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
|
317 |
|
|
var _id = new Guid().CreateUniqueGuid().ToString();
|
318 |
|
|
|
319 |
|
|
var result = await client.AliveConvertListAsync();
|
320 |
|
|
|
321 |
|
|
datagrid.ItemsSource = result;
|
322 |
|
|
}
|
323 |
|
|
|
324 |
|
|
private async void WaitList_Click(object sender, RoutedEventArgs e)
|
325 |
|
|
{
|
326 |
|
|
BasicHttpBinding myBinding = new BasicHttpBinding();
|
327 |
|
|
EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
|
328 |
|
|
|
329 |
|
|
StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
|
330 |
|
|
var _id = new Guid().CreateUniqueGuid().ToString();
|
331 |
|
|
|
332 |
|
|
var result = await client.WaitConvertListAsync();
|
333 |
|
|
|
334 |
|
|
datagrid.ItemsSource = result;
|
335 |
|
|
}
|
336 |
|
|
|
337 |
|
|
private void ProcessKill_Click(object sender, RoutedEventArgs e)
|
338 |
|
|
{
|
339 |
|
|
station.Stopprocess();
|
340 |
|
|
}
|
341 |
|
|
|
342 |
|
|
private void DeadLockProcessList_Click(object sender, RoutedEventArgs e)
|
343 |
|
|
{
|
344 |
|
|
station.DeadLockProcessKill();
|
345 |
|
|
}
|
346 |
|
|
|
347 |
|
|
private async void Button_Click_1(object sender, RoutedEventArgs e)
|
348 |
|
|
{
|
349 |
|
|
int count = 0;
|
350 |
|
|
|
351 |
|
|
|
352 |
|
|
if(int.TryParse(txtProcessCount.Text,out count))
|
353 |
|
|
{
|
354 |
|
|
|
355 |
|
|
BasicHttpBinding myBinding = new BasicHttpBinding();
|
356 |
|
|
EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
|
357 |
|
|
|
358 |
|
|
StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
|
359 |
|
|
|
360 |
|
|
var result = await client.SettingMultiProcessAsync(count);
|
361 |
|
|
|
362 |
|
|
}
|
363 |
|
|
}
|
364 |
|
|
|
365 |
|
|
private async void RemoteFileList_Click(object sender, RoutedEventArgs e)
|
366 |
|
|
{
|
367 |
|
|
var uriList = new[]
|
368 |
|
|
{
|
369 |
|
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000053/250page.pdf",
|
370 |
|
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000038/250page.pdf",
|
371 |
|
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000027/BigSize.pdf",
|
372 |
|
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000032/BigSize.pdf",
|
373 |
|
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000087/1-5110-ZJ-492-005_C.pdf",
|
374 |
|
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000070/VP-TEST-MARKUS-040.pdf",
|
375 |
|
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000051/250page.pdf",
|
376 |
|
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000039/250page.pdf",
|
377 |
|
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000022/BigSize.pdf",
|
378 |
|
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000023/BigSize.pdf",
|
379 |
|
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000049/250page.pdf",
|
380 |
|
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000050/250page.pdf",
|
381 |
|
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000050/250page.pdf",
|
382 |
|
|
"http://www.devdoftech.co.kr:5100/Doc_Manager/000000_app/VPCS_DOCLIB/40000036/250page.pdf"
|
383 |
|
|
|
384 |
|
|
};
|
385 |
|
|
BasicHttpBinding myBinding = new BasicHttpBinding();
|
386 |
|
|
EndpointAddress myEndpoint = new EndpointAddress(UriHelper.UriCreate("http://localhost:9101/StationService"));
|
387 |
|
|
|
388 |
|
|
StationService.StationServiceClient client = new StationService.StationServiceClient(myBinding, myEndpoint);
|
389 |
|
|
|
390 |
|
|
foreach (var item in uriList)
|
391 |
|
|
{
|
392 |
|
|
var result = await client.ConvertMenualAddAsync("111111", item, "test");
|
393 |
|
|
Log.Text += $"Wcf Station Service call{item} {result}\n";
|
394 |
|
|
}
|
395 |
|
|
|
396 |
|
|
}
|
397 |
|
|
|
398 |
|
|
private void Button_Click_2(object sender, RoutedEventArgs e)
|
399 |
|
|
{
|
400 |
|
|
var pageinfoList = new Markus.Message.PageInfo[]
|
401 |
|
|
{
|
402 |
|
|
new Markus.Message.PageInfo
|
403 |
|
|
{
|
404 |
|
|
Width = 111,
|
405 |
|
|
Height = 111,
|
406 |
|
|
PageNo = 1,
|
407 |
|
|
|
408 |
|
|
},
|
409 |
|
|
new Markus.Message.PageInfo
|
410 |
|
|
{
|
411 |
|
|
Width = 111,
|
412 |
|
|
Height = 111,
|
413 |
|
|
PageNo = 2,
|
414 |
|
|
}
|
415 |
|
|
|
416 |
|
|
};
|
417 |
|
|
|
418 |
|
|
using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(MarkusDBConnectionString))
|
419 |
|
|
{
|
420 |
|
|
|
421 |
|
|
List<DOCPAGE> docPageList = new List<DOCPAGE>();
|
422 |
|
|
|
423 |
|
|
docPageList = pageinfoList.Select(f => new DOCPAGE
|
424 |
|
|
{
|
425 |
|
|
ID = GuidExtension.shortGuid(),
|
426 |
|
|
PAGE_WIDTH = f.Width.ToString(),
|
427 |
|
|
PAGE_HEIGHT = f.Height.ToString(),
|
428 |
|
|
PAGE_NUMBER = f.PageNo
|
429 |
|
|
}).ToList();
|
430 |
|
|
|
431 |
|
|
database.SetDocumentInfo("1df16d9a-1ea9-9a32-8a61-aad6ce4a2a49", 2, docPageList);
|
432 |
|
|
}
|
433 |
|
|
}
|
434 |
|
|
|
435 |
|
|
private void wcfTest_Click(object sender, RoutedEventArgs e)
|
436 |
|
|
{
|
437 |
|
|
station.GetApplicationConfig();
|
438 |
|
|
station.StartWcfService();
|
439 |
|
|
}
|
440 |
c433ebde
|
taeseongkim
|
private static readonly HttpClient _Client = new HttpClient();
|
441 |
|
|
private static JavaScriptSerializer _Serializer = new JavaScriptSerializer();
|
442 |
53c9637d
|
taeseongkim
|
|
443 |
|
|
private async void WebServiceTest_click(object sender, RoutedEventArgs e)
|
444 |
|
|
{
|
445 |
|
|
string cookie = "";
|
446 |
|
|
|
447 |
|
|
var uri = new Uri("http://localhost:9101/StationService/Rest/GetConvertItem"); // string 을 Uri 로 형변환
|
448 |
|
|
var wReq = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uri); // WebRequest 객체 형성 및 HttpWebRequest 로 형변환
|
449 |
c433ebde
|
taeseongkim
|
wReq.Method = "POST"; // 전송 방법 "GET" or "POST"
|
450 |
|
|
wReq.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
|
451 |
|
|
wReq.Proxy = new System.Net.WebProxy("127.0.0.1", 8888);
|
452 |
|
|
//wReq.ServicePoint.Expect100Continue = false;
|
453 |
|
|
//wReq.CookieContainer = new System.Net.CookieContainer();
|
454 |
|
|
//wReq.CookieContainer.SetCookies(uri, cookie); // 넘겨줄 쿠키가 있을때 CookiContainer 에 저장
|
455 |
53c9637d
|
taeseongkim
|
|
456 |
|
|
//POST 전송일 경우
|
457 |
c433ebde
|
taeseongkim
|
|
458 |
|
|
string url = "http://localhost:9101/StationService/Rest/GetConvertItem";
|
459 |
|
|
var data = new SEND
|
460 |
53c9637d
|
taeseongkim
|
{
|
461 |
|
|
ProjectNo = "111111",
|
462 |
|
|
DocumentID = "453"
|
463 |
|
|
};
|
464 |
|
|
|
465 |
c433ebde
|
taeseongkim
|
var json = _Serializer.Serialize(data);
|
466 |
|
|
var response2 = await Request(HttpMethod.Post, url, json, new Dictionary<string, string>());
|
467 |
|
|
string responseText = await response2.Content.ReadAsStringAsync();
|
468 |
53c9637d
|
taeseongkim
|
|
469 |
c433ebde
|
taeseongkim
|
Console.WriteLine(responseText);
|
470 |
53c9637d
|
taeseongkim
|
|
471 |
|
|
|
472 |
|
|
using (var client = new System.Net.Http.HttpClient())
|
473 |
|
|
{
|
474 |
|
|
var uri2 = new Uri("http://localhost:9101/StationService/Rest/GetConvertItem");
|
475 |
c433ebde
|
taeseongkim
|
|
476 |
|
|
var data2 = new SEND
|
477 |
53c9637d
|
taeseongkim
|
{
|
478 |
|
|
ProjectNo = "111111",
|
479 |
|
|
DocumentID = "453"
|
480 |
|
|
};
|
481 |
|
|
|
482 |
|
|
var jsonRequest2 = JsonConvert.SerializeObject(data2);
|
483 |
|
|
var stringContent = new System.Net.Http.StringContent(jsonRequest2, Encoding.UTF8, "application/json");
|
484 |
|
|
var response = await client.PostAsync(uri2, stringContent);
|
485 |
|
|
|
486 |
|
|
if (response.IsSuccessStatusCode)
|
487 |
|
|
{
|
488 |
|
|
System.Diagnostics.Debug.WriteLine(response.Content.Headers.First());
|
489 |
|
|
System.Diagnostics.Debug.WriteLine(await response.Content.ReadAsStringAsync());
|
490 |
|
|
}
|
491 |
|
|
}
|
492 |
c433ebde
|
taeseongkim
|
|
493 |
|
|
//var client2 = new System.Net.WebClient();
|
494 |
|
|
//client2.Proxy = new System.Net.WebProxy("127.0.0.1", 8888);
|
495 |
|
|
//var result = await client2.DownloadStringTaskAsync("http://localhost:9101/StationService/Rest/GetConvertItem?ProjectNo=111111&DocumentID=453");
|
496 |
53c9637d
|
taeseongkim
|
//System.Diagnostics.Debug.WriteLine(result);
|
497 |
|
|
}
|
498 |
c433ebde
|
taeseongkim
|
|
499 |
|
|
static async Task<System.Net.Http.HttpResponseMessage> Request(HttpMethod pMethod, string pUrl, string pJsonContent, Dictionary<string, string> pHeaders)
|
500 |
|
|
{
|
501 |
|
|
var httpRequestMessage = new HttpRequestMessage();
|
502 |
|
|
httpRequestMessage.Method = pMethod;
|
503 |
|
|
httpRequestMessage.RequestUri = new Uri(pUrl);
|
504 |
|
|
foreach (var head in pHeaders)
|
505 |
|
|
{
|
506 |
|
|
httpRequestMessage.Headers.Add(head.Key, head.Value);
|
507 |
|
|
}
|
508 |
|
|
switch (pMethod.Method)
|
509 |
|
|
{
|
510 |
|
|
case "POST":
|
511 |
|
|
HttpContent httpContent = new StringContent(pJsonContent, Encoding.UTF8, "application/json");
|
512 |
|
|
httpRequestMessage.Content = httpContent;
|
513 |
|
|
break;
|
514 |
|
|
|
515 |
|
|
}
|
516 |
|
|
|
517 |
|
|
return await new HttpClient().SendAsync(httpRequestMessage);
|
518 |
|
|
}
|
519 |
06f13e11
|
taeseongkim
|
|
520 |
|
|
private async void ConvertWebServiceTest_click(object sender, RoutedEventArgs e)
|
521 |
|
|
{
|
522 |
|
|
using (Markus.Service.DataBase.ConvertDatabase database = new Markus.Service.DataBase.ConvertDatabase(MarkusDBConnectionString))
|
523 |
|
|
{
|
524 |
|
|
|
525 |
|
|
var items = database.GetConvertItems(Markus.Message.StatusCodeType.Completed).Take(100).ToList();
|
526 |
|
|
|
527 |
|
|
var service = new ConvertWebService.ConversionSoapClient();
|
528 |
|
|
|
529 |
|
|
int count = 0;
|
530 |
|
|
|
531 |
|
|
foreach (var item in items)
|
532 |
|
|
{
|
533 |
|
|
count++;
|
534 |
|
|
byte[] bytes = Encoding.UTF8.GetBytes(item.OriginfilePath);
|
535 |
|
|
var url = Convert.ToBase64String(bytes);
|
536 |
|
|
var result = await service.ConvertRunAsync(count.ToString(), item.UniqueKey, item.UniqueKey + count.ToString(), count.ToString(), "111111", item.UniqueKey, url);
|
537 |
|
|
|
538 |
|
|
System.Diagnostics.Debug.WriteLine(item.ConvertID + " " + result.ToString());
|
539 |
|
|
}
|
540 |
|
|
}
|
541 |
|
|
}
|
542 |
53c9637d
|
taeseongkim
|
}
|
543 |
|
|
|
544 |
|
|
class IntegratedServiceInstaller
|
545 |
|
|
{
|
546 |
|
|
public void Install(String ServiceName, String DisplayName, String Description,
|
547 |
|
|
System.ServiceProcess.ServiceAccount Account,
|
548 |
|
|
System.ServiceProcess.ServiceStartMode StartMode)
|
549 |
|
|
{
|
550 |
|
|
System.ServiceProcess.ServiceProcessInstaller ProcessInstaller = new System.ServiceProcess.ServiceProcessInstaller();
|
551 |
|
|
ProcessInstaller.Account = Account;
|
552 |
|
|
|
553 |
|
|
System.ServiceProcess.ServiceInstaller SINST = new System.ServiceProcess.ServiceInstaller();
|
554 |
|
|
|
555 |
|
|
System.Configuration.Install.InstallContext Context = new System.Configuration.Install.InstallContext();
|
556 |
|
|
string processPath = Process.GetCurrentProcess().MainModule.FileName;
|
557 |
|
|
if (processPath != null && processPath.Length > 0)
|
558 |
|
|
{
|
559 |
|
|
System.IO.FileInfo fi = new System.IO.FileInfo(processPath);
|
560 |
|
|
//Context = new System.Configuration.Install.InstallContext();
|
561 |
|
|
//Context.Parameters.Add("assemblyPath", fi.FullName);
|
562 |
|
|
//Context.Parameters.Add("startParameters", "Test");
|
563 |
|
|
|
564 |
|
|
String path = String.Format("/assemblypath={0}", fi.FullName);
|
565 |
|
|
String[] cmdline = { path };
|
566 |
|
|
Context = new System.Configuration.Install.InstallContext("", cmdline);
|
567 |
|
|
}
|
568 |
|
|
|
569 |
|
|
SINST.Context = Context;
|
570 |
|
|
SINST.DisplayName = DisplayName;
|
571 |
|
|
SINST.Description = Description;
|
572 |
|
|
SINST.ServiceName = ServiceName;
|
573 |
|
|
SINST.StartType = StartMode;
|
574 |
|
|
SINST.Parent = ProcessInstaller;
|
575 |
|
|
|
576 |
|
|
// http://bytes.com/forum/thread527221.html
|
577 |
|
|
// SINST.ServicesDependedOn = new String[] {};
|
578 |
|
|
|
579 |
|
|
System.Collections.Specialized.ListDictionary state = new System.Collections.Specialized.ListDictionary();
|
580 |
|
|
SINST.Install(state);
|
581 |
|
|
|
582 |
|
|
// http://www.dotnet247.com/247reference/msgs/43/219565.aspx
|
583 |
|
|
using (RegistryKey oKey = Registry.LocalMachine.OpenSubKey(String.Format(@"SYSTEM\CurrentControlSet\Services\{0}", SINST.ServiceName), true))
|
584 |
|
|
{
|
585 |
|
|
try
|
586 |
|
|
{
|
587 |
|
|
Object sValue = oKey.GetValue("ImagePath");
|
588 |
|
|
oKey.SetValue("ImagePath", sValue);
|
589 |
|
|
}
|
590 |
|
|
catch (Exception Ex)
|
591 |
|
|
{
|
592 |
|
|
// System.Console.WriteLine(Ex.Message);
|
593 |
|
|
}
|
594 |
|
|
}
|
595 |
|
|
|
596 |
|
|
}
|
597 |
|
|
public void Uninstall(String ServiceName)
|
598 |
|
|
{
|
599 |
|
|
System.ServiceProcess.ServiceInstaller SINST = new System.ServiceProcess.ServiceInstaller();
|
600 |
|
|
|
601 |
|
|
System.Configuration.Install.InstallContext Context = new System.Configuration.Install.InstallContext("c:\\install.log", null);
|
602 |
|
|
SINST.Context = Context;
|
603 |
|
|
SINST.ServiceName = ServiceName;
|
604 |
|
|
SINST.Uninstall(null);
|
605 |
|
|
}
|
606 |
|
|
}
|
607 |
c433ebde
|
taeseongkim
|
|
608 |
|
|
public class SEND
|
609 |
|
|
{
|
610 |
|
|
public string ProjectNo { get; set; }
|
611 |
|
|
public string DocumentID{ get; set; }
|
612 |
|
|
}
|
613 |
53c9637d
|
taeseongkim
|
} |