개정판 ff4b1e6e
데이터베이스 nuget으로 변경
Change-Id: I6167ddf20d4cdae727b0d9047dec4fdad0dcf81a
ConvertService/ServiceBase/Markus.Service.Station/StationService/ServiceStationTask.cs | ||
---|---|---|
133 | 133 |
|
134 | 134 |
foreach (var convert in convertItems) |
135 | 135 |
{ |
136 |
//ReflashSubService(); |
|
137 |
|
|
136 | 138 |
if (convert.STATUS > (int)StatusCodeType.None) |
137 | 139 |
{ |
138 | 140 |
database.SetCleanUpItem(convert.ID); |
... | ... | |
143 | 145 |
} |
144 | 146 |
} |
145 | 147 |
|
146 |
private void ReflashSubService() |
|
148 |
public bool IsDataBaseWaitingList(int overListCount) |
|
149 |
{ |
|
150 |
bool result = false; |
|
151 |
|
|
152 |
try |
|
153 |
{ |
|
154 |
using (DataBase.ConvertDatabase database = new DataBase.ConvertDatabase(MarkusDBConnectionString)) |
|
155 |
{ |
|
156 |
var convertItems = database.GetWaitConvertItems(this.RunProjectList, overListCount); |
|
157 |
|
|
158 |
if (convertItems.Count() > 0) |
|
159 |
{ |
|
160 |
result = true; |
|
161 |
} |
|
162 |
} |
|
163 |
} |
|
164 |
catch (Exception ex) |
|
165 |
{ |
|
166 |
logger.Error($"IsDataBaseWaitingList Error",ex); |
|
167 |
} |
|
168 |
|
|
169 |
return result; |
|
170 |
} |
|
171 |
|
|
172 |
private async void ReflashSubService() |
|
147 | 173 |
{ |
148 | 174 |
foreach (var subservice in StationServiceList) |
149 | 175 |
{ |
... | ... | |
153 | 179 |
|
154 | 180 |
if (subservice.IsOnline) |
155 | 181 |
{ |
156 |
var result = subservice.Service.AliveConvertList();
|
|
182 |
var result = await subservice.Service.AliveConvertListAsync();
|
|
157 | 183 |
|
158 | 184 |
subservice.ConvertItems = result.ToList(); |
159 | 185 |
subservice.AliveCount = result.Count(); |
... | ... | |
161 | 187 |
else |
162 | 188 |
{ |
163 | 189 |
logger.Error($"Connection Error {subservice.Properties.SERVICE_ADDRESS}"); |
164 |
subservice.ConvertItems = new List<WcfClient.StationServiceAsync.ConvertItem>();
|
|
190 |
subservice.ConvertItems = new List<WcfClient.StationServiceTask.ConvertItem>();
|
|
165 | 191 |
subservice.AliveCount = subservice.Properties.PROCESS_COUNT; |
166 | 192 |
} |
167 | 193 |
} |
... | ... | |
179 | 205 |
/// <param name="ProjectNo"></param> |
180 | 206 |
/// <param name="ConvertID"></param> |
181 | 207 |
/// <param name="UniqueKey">Document ID(문서의 유일키)</param> |
182 |
private void PassConvertItem(string ProjectNo,string ConvertID,string UniqueKey) |
|
208 |
private async void PassConvertItem(string ProjectNo,string ConvertID,string UniqueKey)
|
|
183 | 209 |
{ |
184 | 210 |
|
185 | 211 |
try |
186 | 212 |
{ |
187 |
|
|
188 | 213 |
var stationList = StationServiceList.Where(x => x.IsOnline); |
189 | 214 |
|
190 | 215 |
if (stationList.SelectMany(x => x.ConvertItems).Count(c => c.ProjectNumber == ProjectNo && c.UniqueKey == UniqueKey) == 0) |
... | ... | |
193 | 218 |
|
194 | 219 |
if (station != null) |
195 | 220 |
{ |
196 |
station.Service.ConvertAddAsync(ProjectNo, ConvertID); |
|
221 |
System.Diagnostics.Debug.WriteLine($"{station.Properties.SERVICE_ADDRESS} {station.Properties.PROCESS_COUNT}/{station.AliveCount}"); |
|
222 |
var result = await station.Service.ConvertAddAsync(ProjectNo, ConvertID); |
|
223 |
|
|
224 |
if(result.ToLower() == true.ToString().ToLower()) |
|
225 |
{ |
|
226 |
station.AliveCount++; |
|
227 |
} |
|
228 |
|
|
197 | 229 |
logger.Info($"PassConvertItem - Service ID : {station.Properties.ID} ConvertID : {ConvertID}"); |
198 | 230 |
} |
199 | 231 |
} |
... | ... | |
204 | 236 |
} |
205 | 237 |
} |
206 | 238 |
|
239 |
/// <summary> |
|
240 |
/// 컨버터 프로세스와 AiliveItems을 비교하여 AliveItems에 없는 경우 AliveItems을 제거 |
|
241 |
/// </summary> |
|
207 | 242 |
private void CleanUpAliveQueueItems() |
208 | 243 |
{ |
209 |
var processList = Process.GetProcessesByName("Markus.Service.ConvertProcess"); |
|
210 |
|
|
211 |
if (processList.Length == 0) |
|
244 |
if (AliveConvertQueue.Count() > 0) |
|
212 | 245 |
{ |
213 |
AliveConvertQueue.Clear(); |
|
214 |
System.Diagnostics.Debug.WriteLine("AliveConvertQueue.Clear()"); |
|
215 |
} |
|
216 |
else |
|
217 |
{ |
|
218 |
var argumentList = processList.Select(f => f.Arguments().CommandLine).SelectMany(f => f); |
|
246 |
var processList = Process.GetProcessesByName("Markus.Service.ConvertProcess"); |
|
219 | 247 |
|
220 |
for (int i = AliveConvertQueue.Count - 1; i >= 0; --i)
|
|
248 |
if (processList.Length == 0)
|
|
221 | 249 |
{ |
222 |
if (argumentList.Count(x => x == AliveConvertQueue[i].ConvertID) == 0) |
|
250 |
AliveConvertQueue.Clear(); |
|
251 |
System.Diagnostics.Debug.WriteLine("AliveConvertQueue.Clear()"); |
|
252 |
} |
|
253 |
else |
|
254 |
{ |
|
255 |
var argumentList = processList.Select(f => f.Arguments().CommandLine).SelectMany(f => f); |
|
256 |
|
|
257 |
for (int i = AliveConvertQueue.Count - 1; i >= 0; --i) |
|
223 | 258 |
{ |
224 |
AliveConvertQueue.RemoveAt(i); |
|
259 |
if (argumentList.Count(x => x == AliveConvertQueue[i].ConvertID) == 0) |
|
260 |
{ |
|
261 |
AliveConvertQueue.RemoveAt(i); |
|
262 |
} |
|
225 | 263 |
} |
226 | 264 |
} |
227 |
|
|
228 |
//foreach (var process in processList) |
|
229 |
//{ |
|
230 |
// var arguments = process.Arguments(); |
|
231 |
|
|
232 |
// if (arguments.CommandLine?.Count() == 2) |
|
233 |
// { |
|
234 |
// if (AliveConvertQueue.Count(x => x.ConvertID == arguments.CommandLine.First()) == 0) |
|
235 |
// { |
|
236 |
// var convetContext = ObjectToBytesStringConvert.BytesStringToObject<ProcessContext>(AESEncrypter.Decrypt(arguments.CommandLine[1])); |
|
237 |
|
|
238 |
// if (convetContext.ServiceStationUri == this.gServiceHostAddress.ToString()) |
|
239 |
// { |
|
240 |
// process.Kill(); |
|
241 |
// } |
|
242 |
// } |
|
243 |
// } |
|
244 |
//} |
|
245 | 265 |
} |
246 |
|
|
247 | 266 |
} |
248 | 267 |
|
249 |
private void CleanUpDataBaseItems() |
|
268 |
/// <summary> |
|
269 |
/// 데이터베이스에서 멈춰있거나 |
|
270 |
/// </summary> |
|
271 |
private async void CleanUpDataBaseItems() |
|
250 | 272 |
{ |
251 | 273 |
using (DataBase.ConvertDatabase database = new DataBase.ConvertDatabase(MarkusDBConnectionString)) |
252 | 274 |
{ |
253 | 275 |
var items = database.GetConvertingItems(RunProjectList); |
254 | 276 |
|
255 |
List< WcfClient.StationServiceAsync.ConvertItem> aliveItems = new List<WcfClient.StationServiceAsync.ConvertItem>();
|
|
277 |
List< WcfClient.StationServiceTask.ConvertItem> aliveItems = new List<WcfClient.StationServiceTask.ConvertItem>();
|
|
256 | 278 |
|
257 | 279 |
foreach (var item in StationServiceList.Where(x=>x.IsOnline)) |
258 | 280 |
{ |
259 | 281 |
try |
260 | 282 |
{ |
261 |
aliveItems.AddRange(item.Service.AliveConvertList()); |
|
283 |
var serviceItems = await item.Service.AliveConvertListAsync(); |
|
284 |
aliveItems.AddRange(serviceItems); |
|
262 | 285 |
} |
263 | 286 |
catch (Exception) |
264 | 287 |
{ |
... | ... | |
336 | 359 |
|
337 | 360 |
if (IsStation) |
338 | 361 |
{ |
339 |
System.Diagnostics.Debug.WriteLine("setDataBaseWaitingList"); |
|
340 |
setDataBaseWaitingList(); |
|
341 |
System.Diagnostics.Debug.WriteLine("ReleaseItems end"); |
|
362 |
if (!IsReleaseItems) |
|
363 |
{ |
|
364 |
System.Diagnostics.Debug.WriteLine("ConvertFinish ReleaseItems call"); |
|
365 |
ReleaseItems(); |
|
366 |
} |
|
342 | 367 |
} |
343 | 368 |
else |
344 | 369 |
{ |
내보내기 Unified diff