프로젝트

일반

사용자정보

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

markus / ConvertService / ServiceBase / Markus.Service.DataBase / ConvertDatabase.cs @ 2decfbdf

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

1 ff4b1e6e taeseongkim
using Markus.EntityModel;
2
using Markus.Message;
3 53c9637d taeseongkim
using Markus.Service.Extensions;
4
using System;
5
using System.Collections.Generic;
6
using System.IO;
7
using System.Linq;
8 2decfbdf alzkakdixm
using static Markus.Service.DataBase.ConvertDatabase;
9
using System.Windows;
10
using System.Linq.Expressions;
11
using Markus.Service.Interface;
12 53c9637d taeseongkim
13
namespace Markus.Service.DataBase
14
{
15
    public class ConvertDatabase : IDisposable
16
    {
17 ff4b1e6e taeseongkim
        Markus.EntityModel.MarkusModel entities;
18 53c9637d taeseongkim
19
        public ConvertDatabase(string ConnectionString)
20
        {
21
            try
22
            {
23
                //해당 프로젝트의 데이터베이스 연결
24 ff4b1e6e taeseongkim
                entities = new Markus.EntityModel.MarkusModel(ConnectionString);
25 53c9637d taeseongkim
            }
26
            catch (Exception ex)
27
            {
28
                System.Diagnostics.Debug.WriteLine(ex.ToString());
29 06f13e11 taeseongkim
                throw ex;
30 53c9637d taeseongkim
            }
31
        }
32
33
        public void Dispose()
34
        {
35
            entities.Dispose();
36
        }
37
38
        /// <summary>
39
        /// 컨버터서비스를 이용하는 문서 정보 저장
40
        /// UniqueID
41
        /// using Markus.Service.Extensions;  new Guid().CreateUniqueGuid().ToString();
42
        /// </summary>
43
        /// <param name="ProjectNo">프로젝트</param>
44
        /// <param name="UniqueID">컨버터 서비스의 아이템 ID</param>
45
        /// <param name="originfilePath"></param>
46
        /// <param name="DocumentID"></param>
47
        /// <returns></returns>
48
        public bool SetConvertDoc(string ProjectNo, string UniqueID, string originfilePath, string DocumentID)
49
        {
50
            bool result = false;
51
52
            if (ProjectNo.IsNullOrEmpty())
53
            {
54
                throw new Exception("ProjectNo is Null");
55
            }
56
57
            if (UniqueID.IsNullOrEmpty())
58
            {
59
                throw new Exception("UniqueID is Null");
60
            }
61
62
            if (originfilePath.IsNullOrEmpty())
63
            {
64
                throw new Exception("originfilePath is Null");
65
            }
66
67
            if (DocumentID.IsNullOrEmpty())
68
            {
69
                throw new Exception("DocumentID is Null");
70
            }
71
72
            if (DocumentID.IsNullOrEmpty())
73
            {
74
                long _lastDocId = 0;
75
76
                if (entities.CONVERTER_DOC.Count() > 0)
77
                {
78
                    try
79
                    {
80
                        string qry = @"SELECT * FROM CONVERTER_DOC order by CAST(DOCUMENT_ID as int) desc";
81
                        var _item = entities.CONVERTER_DOC.SqlQuery(qry).FirstOrDefault();
82
83
                        if (_item != null)
84
                        {
85
                            _lastDocId = Convert.ToInt64(_item.DOCUMENT_ID) + 1;
86
                        }
87
                    }
88
                    catch (Exception)
89
                    {
90
91
                        throw;
92
                    }
93
                }
94
95
                DocumentID = _lastDocId.ToString();
96
            }
97
98
            CONVERTER_DOC convert_doc = new CONVERTER_DOC
99
            {
100
                ID = UniqueID,
101
                PROJECT_NO = ProjectNo,
102
                DOCUMENT_URL = originfilePath,
103
                DOCUMENT_ID = DocumentID,
104
                CREATE_DATETIME = DateTime.Now,
105
                STATUS = 0,
106
                TOTAL_PAGE = 0,
107
                CURRENT_PAGE = 0,
108
                RECONVERTER = 0
109
            };
110
111 2decfbdf alzkakdixm
            
112 53c9637d taeseongkim
            entities.CONVERTER_DOC.Add(convert_doc);
113
114
            if (entities.SaveChanges() == 1)
115
            {
116
                result = true;
117
            }
118
119
            return result;
120
        }
121
122 2decfbdf alzkakdixm
        //public bool SetDocument_Item(string Revision, string Document_No, string Document_Name, string Group_No)//세미
123
        //{
124
        //    bool result = false;
125
126
        //    if (Revision.IsNullOrEmpty())
127
        //    {
128
        //        throw new Exception("Revision is Null");
129
        //    }
130
131
        //    if (Document_No.IsNullOrEmpty())
132
        //    {
133
        //        throw new Exception("Document_No is Null");
134
        //    }
135
136
        //    if (Document_Name.IsNullOrEmpty())
137
        //    {
138
        //        throw new Exception("Document_Name is Null");
139
        //    }
140
141
        //    DOCUMENT_ITEM document_item = new DOCUMENT_ITEM
142
        //    {
143
        //        REVISION = Revision,
144
        //        DOCUMENT_NO = Document_No,
145
        //        DOCUMENT_NAME = Document_Name,
146
        //        GROUP_NO = Group_No
147
        //    };
148
149
        //    entities.DOCUMENT_ITEM.Add(document_item);
150
151
        //    if (entities.SaveChanges() == 1)
152
        //    {
153
        //        result = true;
154
        //    }
155
156
        //    return result;
157
        //}
158 53c9637d taeseongkim
        /// <summary>
159
        /// 컨버터서비스를 이용하는 문서 정보 저장
160
        /// UniqueID
161
        /// using Markus.Service.Extensions;  new Guid().CreateUniqueGuid().ToString();
162
        /// </summary>
163
        /// <param name="ProjectNo">프로젝트</param>
164
        /// <param name="UniqueID">컨버터 서비스의 아이템 ID</param>
165
        /// <param name="originfilePath"></param>
166
        /// <param name="DocumentID"></param>
167
        /// <returns></returns>
168
        public bool SetDocumentInfo(string ConvertID, int totalPage, List<DOCPAGE> pageinfo)
169
        {
170
            bool result = false;
171
172
            var convertDocItems = entities.CONVERTER_DOC.Where(f => f.ID == ConvertID);
173
174
            if (convertDocItems.Count() > 0)
175
            {
176
                var convertDoc = convertDocItems.First();
177
178 c47f358b taeseongkim
                string docId = new Guid().CreateUniqueGuid().ToString();
179 53c9637d taeseongkim
180
                var docinfo = entities.DOCINFO.FirstOrDefault(x => x.PROJECT_NO == convertDoc.PROJECT_NO && x.DOCUMENT_ID == convertDoc.DOCUMENT_ID);
181 41fa3d98 djkim
                
182 53c9637d taeseongkim
                if (docinfo != null)
183
                {
184 41fa3d98 djkim
                    // 기존 Docpage 삭제.
185 53c9637d taeseongkim
                    entities.DOCPAGE.RemoveRange(docinfo.DOCPAGE);
186 41fa3d98 djkim
187
                    // 기존 코멘트 유지를 위한 Docinfo update                    
188
                    docinfo.PROJECT_NO = convertDoc.PROJECT_NO;
189
                    docinfo.ORIGINAL_FILE = convertDoc.DOCUMENT_URL;
190
                    docinfo.PAGE_COUNT = totalPage;                    
191
                    docinfo.DOCPAGE = pageinfo;                    
192 53c9637d taeseongkim
                    entities.SaveChanges();
193 41fa3d98 djkim
                    result = true;
194 53c9637d taeseongkim
                }
195 41fa3d98 djkim
                else
196 53c9637d taeseongkim
                {
197 41fa3d98 djkim
                    DOCINFO instace = new DOCINFO
198
                    {
199
                        ID = docId,
200
                        PROJECT_NO = convertDoc.PROJECT_NO,
201
                        ORIGINAL_FILE = convertDoc.DOCUMENT_URL,
202
                        DOCUMENT_ID = convertDoc.DOCUMENT_ID,
203
                        PAGE_COUNT = totalPage,
204
                        DOCPAGE = pageinfo
205
                    };
206
207
                    entities.DOCINFO.Add(instace);
208
                    var save = entities.SaveChanges();
209
210
                    if (save == pageinfo.Count() + 1)
211
                    {
212
                        result = true;
213
                    }
214 53c9637d taeseongkim
                }
215 41fa3d98 djkim
216
                
217
                
218 53c9637d taeseongkim
            }
219
220
            return result;
221
        }
222
223
        public Interface.ConvertItem GetConvertItem(string ProjectNo, string UniqueID)
224
        {
225
            Interface.ConvertItem result = null;
226
227
            //var items = entities.CONVERTER_DOC.Where(f => f.PROJECT_NO == gProjectNo && f.ID == UniqueID);
228
            var items = entities.CONVERTER_DOC.Where(f => f.PROJECT_NO == ProjectNo && f.ID == UniqueID);
229
230
            if (items.Count() > 0)
231
            {
232
                var convertItem = items.First();
233 a0341bef taeseongkim
234 53c9637d taeseongkim
                string convertPath = Path.Combine(BaseStorage(convertItem.PROJECT_NO), convertItem.PROJECT_NO + "_Tile", (System.Convert.ToInt64(convertItem.DOCUMENT_ID) / 100).ToString(), convertItem.DOCUMENT_ID);
235
236
                result = new Interface.ConvertItem(convertItem.DOCUMENT_ID, convertItem.PROJECT_NO, convertItem.ID, convertItem.DOCUMENT_URL, convertPath);
237
            }
238
239
            return result;
240
        }
241
242
243
        public Interface.ConvertItem GetConvertItembyDocumentID(string ProjectNo, string DocumentID)
244
        {
245
            Interface.ConvertItem result = null;
246
247
            //var items = entities.CONVERTER_DOC.Where(f => f.PROJECT_NO == gProjectNo && f.ID == UniqueID);
248
            var items = entities.CONVERTER_DOC.Where(f => f.PROJECT_NO == ProjectNo && f.DOCUMENT_ID == DocumentID);
249
250
            if (items.Count() > 0)
251
            {
252
                var convertItem = items.First();
253
                string convertPath = Path.Combine(BaseStorage(convertItem.PROJECT_NO), convertItem.PROJECT_NO + "_Tile", (System.Convert.ToInt64(convertItem.DOCUMENT_ID) / 100).ToString(), convertItem.DOCUMENT_ID);
254
255
                if (convertItem.STATUS == (int)StatusCodeType.Completed)
256
                {
257
                    result = new Interface.ConvertItem(convertItem.DOCUMENT_ID, convertItem.PROJECT_NO, convertItem.ID, convertItem.DOCUMENT_URL, convertPath,
258 2decfbdf alzkakdixm
                                                        (StatusCodeType)convertItem.STATUS, convertItem.CURRENT_PAGE, convertItem.TOTAL_PAGE, convertItem.EXCEPTION);
259 53c9637d taeseongkim
                }
260
                else
261
                {
262
                    result = new Interface.ConvertItem(convertItem.DOCUMENT_ID, convertItem.PROJECT_NO, convertItem.ID, convertItem.DOCUMENT_URL, convertPath);
263
                }
264
            }
265
266
            return result;
267
        }
268
269
        /// <summary>
270
        /// service에서 대기중이거나 오류인 아이템을 가져가서 컨버터 프로세스를 호출한다.
271
        /// 컨버터 상태가 에러이거나 2보다 작은 경우 
272
        /// UniqueKey는 각 데이터베이스의 문서 정보에서 유일한 키이며 컨버터저장에서 같은 폴더로의 저장을 방지 한다.
273
        /// 
274
        /// </summary>
275
        /// <param name="aliveItems"></param>
276
        /// <param name="TakeCount"></param>
277
        /// <returns></returns>
278 ff4b1e6e taeseongkim
        public IEnumerable<CONVERTER_DOC> GetWaitConvertItems(List<string> projectList, int TakeCount)
279 53c9637d taeseongkim
        {
280
            var convertWaitingItems = entities.CONVERTER_DOC.OrderBy(x => x.CREATE_DATETIME).Where(
281
                                        x =>
282 b92f142f taeseongkim
                                        //projectList.Contains(x.PROJECT_NO) && x.RECONVERTER < 2 &&
283
                                         x.RECONVERTER < 2 &&
284 1ae729e4 taeseongkim
                                        (x.STATUS == (int)StatusCodeType.None || x.STATUS == (int)StatusCodeType.FileError || x.STATUS == (int)StatusCodeType.Error))
285 6f6e7dbf taeseongkim
                                    .GroupBy(x=>x.DOCUMENT_ID).Select(x => x.FirstOrDefault())
286
                                    .Take(TakeCount);
287 53c9637d taeseongkim
288 ff4b1e6e taeseongkim
            return convertWaitingItems;
289 0157b158 taeseongkim
        }
290 53c9637d taeseongkim
291 0157b158 taeseongkim
        public List<CONVERTER_DOC> GetConvertingItems(List<string> projectList)
292
        {
293
            var convertWaitingItems = entities.CONVERTER_DOC.OrderBy(x => x.CREATE_DATETIME).Where(
294
                                        x =>
295
                                        projectList.Contains(x.PROJECT_NO) &&
296 60723dc9 taeseongkim
                                         (x.STATUS > (int)StatusCodeType.None && x.STATUS < (int)StatusCodeType.Completed) && x.RECONVERTER < 2);
297 53c9637d taeseongkim
298 0157b158 taeseongkim
            return convertWaitingItems.ToList();
299 53c9637d taeseongkim
        }
300
301
        private string GetConvertPath(string ProjectNo,string DocumentID)
302
        {
303
            try
304
            {
305
                return Path.Combine(BaseStorage(ProjectNo), ProjectNo + "_Tile", (System.Convert.ToInt64(DocumentID) / 100).ToString(), DocumentID);
306
            }
307
            catch (Exception)
308
            {
309
                throw new Exception("GetConvertPath Error");
310
            }
311
312
        }
313
314
315
        /// <summary>
316
        /// 오류나 wait으로 남아 있는 데이터베이스의 Item을 StatusCodeType.None으로 복구
317
        /// </summary>
318 2bbea412 taeseongkim
        /// <param name="convertID">StatusCodeType을 변경하고자 하는 ConvertItem의 ID</param>
319
        /// <param name="ReConvert">ReConvert가 2이면 다시 Convert를 시도 안하기 때문에 기존 값으로 유지 하고 계속 시도 할수 있도록 0을 주는 경우가 있다.</param>
320 53c9637d taeseongkim
        /// <returns></returns>
321 2decfbdf alzkakdixm
        /// 
322
        public int SetCleanUpItem(ConvertItem _ConvertItem)
323 53c9637d taeseongkim
        {
324
            int result = 0;
325
326 2decfbdf alzkakdixm
            //var items = entities.CONVERTER_DOC.Where(x => x.ID == _ConvertItem.ConvertID && x.DOCUMENT_ID == _ConvertItem.DocumentID);
327
            var items = entities.CONVERTER_DOC.Where(x => x.ID == _ConvertItem.ConvertID);
328 53c9637d taeseongkim
329
            result = items.Count();
330
331
            if (items.Count() > 0)
332
            {
333 0157b158 taeseongkim
                var item = items.First();
334
335 2decfbdf alzkakdixm
                item.RECONVERTER = item.RECONVERTER - _ConvertItem.ReConverter;
336
                item.CREATE_DATETIME = DateTime.Now;//여기서도 변경 되고 디비에서도 변경됨
337 a0341bef taeseongkim
                //item.START_DATETIME = null;
338 2decfbdf alzkakdixm
                //item.END_DATETIME = null;
339
                item.STATUS = (int)StatusCodeType.None; //여기서는 값 변경 되는데 디비에서 변경 안됨 => 0 되었다가 파일수에 따라 점차 늘어나는것 
340
341 53c9637d taeseongkim
342 0157b158 taeseongkim
                result = entities.SaveChanges();
343 53c9637d taeseongkim
            }
344
345
            return result;
346
        }
347 2decfbdf alzkakdixm
        //public int SetCleanUpItem(string convertID,int ReConvert)
348
        //{
349
        //    int result = 0;
350
351
        //    var items = entities.CONVERTER_DOC.Where(x=> x.ID == convertID);
352
353
        //    result = items.Count();
354
355
        //    if (items.Count() > 0)
356
        //    {
357
        //        var item = items.First();
358
359
        //        item.RECONVERTER = item.RECONVERTER - ReConvert;
360
        //        item.CREATE_DATETIME = DateTime.Now;//여기서도 변경 되고 디비에서도 변경됨
361
        //        //item.START_DATETIME = null;
362
        //        //item.END_DATETIME = null;
363
        //        item.STATUS = (int)StatusCodeType.None; //여기서는 값 변경 되는데 디비에서 변경 안됨 => 0 되었다가 파일수에 따라 점차 늘어나는것 
364
365
366
        //        result = entities.SaveChanges();
367
        //    }
368
369
        //    return result;
370
        //}
371 53c9637d taeseongkim
372 5d863c06 taeseongkim
373
        /// <summary>
374
        /// Item 삭제
375
        /// </summary>
376
        /// <returns></returns>
377
        public int RemoveItem(string convertID)
378
        {
379
            int result = 0;
380
381
            var items = entities.CONVERTER_DOC.Where(x => x.ID == convertID);
382
383
            if (items.Count() > 0)
384
            {
385
                CONVERTER_DOC item = items.First();
386
                entities.CONVERTER_DOC.Remove(item);
387
388
                result = entities.SaveChanges();
389
            }
390
391
            return result;
392
        }
393
394 53c9637d taeseongkim
        /// <summary>
395
        /// 전체 컨버터를 가져온다. 비동기로 변경하여야 한다.
396
        /// </summary>
397
        /// <returns></returns>
398
        public List<Interface.ConvertItem> GetConvertItems( StatusCodeType statusCodeType)
399
        {
400
            List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();
401
402
            var items = entities.CONVERTER_DOC.Where(x=>x.STATUS == (int)statusCodeType).ToList(); //.Where(x => x.PROJECT_NO == gProjectNo);
403
404
            if (items.Count() > 0)
405
            {
406
                foreach (var item in items)
407
                {
408 06f13e11 taeseongkim
                    var convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
409
                    {
410
                        ReConverter = item.RECONVERTER,
411
                        ServiceID = item.SERVICE_ID,
412 2decfbdf alzkakdixm
                        ConvertState = ((StatusCodeType)item.STATUS),
413 06f13e11 taeseongkim
                        CreateTime = item.CREATE_DATETIME,
414
                        TotalPage = item.TOTAL_PAGE,
415
                        CurrentPageNo = item.CURRENT_PAGE,
416
417
                        ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID)
418
                    };
419
420 53c9637d taeseongkim
421
                    convertItems.Add(convertitem);
422
                }
423
            }
424
            return convertItems;
425
        }
426
427 0157b158 taeseongkim
        /// <summary>
428 b92f142f taeseongkim
        /// 전체 컨버터를 가져온다. 비동기로 변경하여야 한다.
429
        /// </summary>
430
        /// <returns></returns>
431
        public List<Interface.ConvertItem> GetConvertItems(StatusCodeType statusCodeType,Func<CONVERTER_DOC, bool> @where,int takeCount = 100)
432
        {
433
            List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();
434
435 60723dc9 taeseongkim
436
            var items = entities.CONVERTER_DOC.Where(x => x.STATUS == (int)statusCodeType).Take(takeCount).ToList(); //.Where(x => x.PROJECT_NO == gProjectNo);
437 b92f142f taeseongkim
438
            if (items.Count() > 0)
439
            {
440
                foreach (var item in items)
441
                {
442
                    var convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
443
                    {
444
                        ReConverter = item.RECONVERTER,
445
                        ServiceID = item.SERVICE_ID,
446 2decfbdf alzkakdixm
                        //ConvertState = ((StatusCodeType)item.STATUS).ToString(),
447
                        ConvertState = ((StatusCodeType)item.STATUS),
448 b92f142f taeseongkim
                        CreateTime = item.CREATE_DATETIME,
449
                        TotalPage = item.TOTAL_PAGE,
450
                        CurrentPageNo = item.CURRENT_PAGE,
451
452
                        ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID)
453
                    };
454
455
456
                    convertItems.Add(convertitem);
457
                }
458
            }
459
            return convertItems;
460
        }
461
462 2decfbdf alzkakdixm
        //List<Interface.ConvertItem> StatusKeep = new List<Interface.ConvertItem>();
463 a6e5055d alzkakdixm
464 2decfbdf alzkakdixm
        public IEnumerable<Interface.ConvertItem> GetConvertProjects(Markus.Service.Interface.ConvertItem selectedConvert)
465
        {
466
            List<Interface.ConvertItem> StatusKeep = new List<Interface.ConvertItem>();
467
            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();///////////////디비 테스트 후 해보기 
468
            stopwatch.Start();
469
            List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();//디비 다 조인 후 조건 비교 후 그리드 출력
470
            var query = from items in entities.CONVERTER_DOC //세미
471
                        join documents in entities.DOCUMENT_ITEM on items.DOCUMENT_ID equals documents.DOCUMENT_ID into GroupItems
472
                        from subpet in GroupItems.DefaultIfEmpty()
473
                        where items.PROJECT_NO == selectedConvert.ProjectNumber && items.DOCUMENT_ID == selectedConvert.DocumentID
474
                        orderby items.CREATE_DATETIME descending 
475
                        select new
476
                        {
477
                            ID = items.ID,
478
                            DOCUMENT_URL = items.DOCUMENT_URL,
479
                            RECONVERTER = items.RECONVERTER,
480
                            SERVICE_ID = items.SERVICE_ID,
481
                            STATUS = items.STATUS,
482
                            CREATE_DATETIME = items.CREATE_DATETIME,
483
                            TOTAL_PAGE = items.TOTAL_PAGE,
484
                            CURRENT_PAGE = items.CURRENT_PAGE,
485
                            EXCEPTION = items.EXCEPTION,
486
                            PROJECT_NO = items.PROJECT_NO,
487
                            DOCUMENT_ID = items.DOCUMENT_ID,
488
                            REVISION = subpet.REVISION,
489
                            DOCUMENT_NO = subpet.DOCUMENT_NO,
490
                            DOCUMENT_NAME = subpet.DOCUMENT_NAME,
491
                            GROUP_NO = subpet.GROUP_NO
492
                        };
493
494
            if (query.Count() > 0)//세미
495 a6e5055d alzkakdixm
            {
496 2decfbdf alzkakdixm
                foreach (var item in query)
497 a6e5055d alzkakdixm
                {
498 2decfbdf alzkakdixm
                    //var convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
499
                    Interface.ConvertItem convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
500 a6e5055d alzkakdixm
                    {
501 2decfbdf alzkakdixm
502 a6e5055d alzkakdixm
                        ReConverter = item.RECONVERTER,
503
                        ServiceID = item.SERVICE_ID,
504
                        //ConvertState = ((StatusCodeType)item.STATUS).ToString(),
505 2decfbdf alzkakdixm
                        //ConvertState = (item.STATUS).ToString(),
506
                        ConvertState = (StatusCodeType)item.STATUS,
507 a6e5055d alzkakdixm
                        CreateTime = item.CREATE_DATETIME,
508
                        TotalPage = item.TOTAL_PAGE,
509
                        CurrentPageNo = item.CURRENT_PAGE,
510
                        Exception = item.EXCEPTION,
511 2decfbdf alzkakdixm
                        ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID),
512
513
                        Revision = item.REVISION,
514
                        DocumnetNo = item.DOCUMENT_NO,
515
                        DocumnetName = item.DOCUMENT_NAME,
516
                        GroupNo = item.GROUP_NO
517 a6e5055d alzkakdixm
                    };
518 2decfbdf alzkakdixm
                    //if (@whereq(convertitem))
519
                    //{
520
                        ////convertItems.Add(convertitem);
521
                        StatusKeep.Add(convertitem);
522
                   // }
523 a6e5055d alzkakdixm
524
                }
525
            }
526 2decfbdf alzkakdixm
            System.Diagnostics.Debug.WriteLine(new TimeSpan(stopwatch.ElapsedTicks).ToString());
527
            //return convertItems;//디비 다 조인 후 조건 비교 후 그리드 출력
528
            return StatusKeep;
529
530 a6e5055d alzkakdixm
531 2decfbdf alzkakdixm
        }
532
        public IEnumerable<Interface.ConvertItem> GetConvertProjects(System.Collections.ObjectModel.ObservableCollection<Interface.ConvertItem> selectedConvert)
533 a6e5055d alzkakdixm
        {
534 2decfbdf alzkakdixm
            List<Interface.ConvertItem> StatusKeep = new List<Interface.ConvertItem>();
535
            //System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();///////////////디비 테스트 후 해보기 
536
            //stopwatch.Start();
537
            List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();//디비 다 조인 후 조건 비교 후 그리드 출력
538 a6e5055d alzkakdixm
539 2decfbdf alzkakdixm
            foreach (var selectedConvertItem in selectedConvert)
540
            {
541
                var query = from items in entities.CONVERTER_DOC //세미
542
                            join documents in entities.DOCUMENT_ITEM on items.DOCUMENT_ID equals documents.DOCUMENT_ID into GroupItems
543
                            from subpet in GroupItems.DefaultIfEmpty()
544
                            where items.PROJECT_NO == selectedConvertItem.ProjectNumber && items.ID == selectedConvertItem.ConvertID 
545
                            select new
546
                            {
547
                                ID = items.ID,
548
                                DOCUMENT_URL = items.DOCUMENT_URL,
549
                                RECONVERTER = items.RECONVERTER,
550
                                SERVICE_ID = items.SERVICE_ID,
551
                                STATUS = items.STATUS,
552
                                CREATE_DATETIME = items.CREATE_DATETIME,
553
                                TOTAL_PAGE = items.TOTAL_PAGE,
554
                                CURRENT_PAGE = items.CURRENT_PAGE,
555
                                EXCEPTION = items.EXCEPTION,
556
                                PROJECT_NO = items.PROJECT_NO,
557
                                DOCUMENT_ID = items.DOCUMENT_ID,
558
                                REVISION = subpet.REVISION,
559
                                DOCUMENT_NO = subpet.DOCUMENT_NO,
560
                                DOCUMENT_NAME = subpet.DOCUMENT_NAME,
561
                                GROUP_NO = subpet.GROUP_NO
562
                            };
563
564
565
                if (query.Count() > 0)//세미
566
                {
567
                    foreach (var item in query)
568
                    {
569
                        //var convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
570
                        Interface.ConvertItem convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
571
                        {
572 a6e5055d alzkakdixm
573 2decfbdf alzkakdixm
                            ReConverter = item.RECONVERTER,
574
                            ServiceID = item.SERVICE_ID,
575
                            //ConvertState = ((StatusCodeType)item.STATUS).ToString(),
576
                            //ConvertState = (item.STATUS).ToString(),
577
                            ConvertState = (StatusCodeType)item.STATUS,
578
                            CreateTime = item.CREATE_DATETIME,
579
                            TotalPage = item.TOTAL_PAGE,
580
                            CurrentPageNo = item.CURRENT_PAGE,
581
                            Exception = item.EXCEPTION,
582
                            ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID),
583
584
                            Revision = item.REVISION,
585
                            DocumnetNo = item.DOCUMENT_NO,
586
                            DocumnetName = item.DOCUMENT_NAME,
587
                            GroupNo = item.GROUP_NO
588
                        };
589
                        //if (@whereq(convertitem))
590
                        //{
591
                        ////convertItems.Add(convertitem);
592
                        StatusKeep.Add(convertitem);
593
                        // }
594 a6e5055d alzkakdixm
595 2decfbdf alzkakdixm
                    }
596
                }
597
            }
598
                //System.Diagnostics.Debug.WriteLine(new TimeSpan(stopwatch.ElapsedTicks).ToString());
599
                //return convertItems;//디비 다 조인 후 조건 비교 후 그리드 출력
600
                return StatusKeep;
601
602
            
603
604
        }
605
        //public IEnumerable<Interface.ConvertItem> GetConvertProjects(Func<Interface.ConvertItem, bool> @whereq, int status)//조인 후 조건 & 조건and조인
606
        ////public List<Interface.ConvertItem> GetConvertProjects(Expression<Func<CONVERTER_DOC, bool>> @where) //linq and entity and sql
607
        ////public IEnumerable<Interface.ConvertItem> GetConvertProjects(Func<CONVERTER_DOC, bool> @where) //원본
608
        //{
609
        //    System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();///////////////디비 테스트 후 해보기 
610
        //    stopwatch.Start();
611
        //    List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();//디비 다 조인 후 조건 비교 후 그리드 출력
612
        //    var query = from items in entities.CONVERTER_DOC //세미
613
        //                join documents in entities.DOCUMENT_ITEM on items.DOCUMENT_ID equals documents.DOCUMENT_ID
614
        //                where items.PROJECT_NO == documents.PROJECT_NO && items.STATUS == status
615
        //                orderby items.CREATE_DATETIME descending
616
        //                select new
617
        //                {
618
        //                    ID = items.ID,
619
        //                    DOCUMENT_URL = items.DOCUMENT_URL,
620
        //                    RECONVERTER = items.RECONVERTER,
621
        //                    SERVICE_ID = items.SERVICE_ID,
622
        //                    STATUS = items.STATUS,
623
        //                    CREATE_DATETIME = items.CREATE_DATETIME,
624
        //                    TOTAL_PAGE = items.TOTAL_PAGE,
625
        //                    CURRENT_PAGE = items.CURRENT_PAGE,
626
        //                    EXCEPTION = items.EXCEPTION,
627
        //                    PROJECT_NO = items.PROJECT_NO,
628
        //                    DOCUMENT_ID = items.DOCUMENT_ID,
629
        //                    REVISION = documents.REVISION,
630
        //                    DOCUMENT_NO = documents.DOCUMENT_NO,
631
        //                    DOCUMENT_NAME = documents.DOCUMENT_NAME,
632
        //                    GROUP_NO = documents.GROUP_NO
633
        //                };
634
635
        //    if (query.Count() > 0)//세미
636
        //    {
637
        //        foreach (var item in query)
638
        //        {
639
        //            //var convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
640
        //            Interface.ConvertItem convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
641
        //            {
642
643
        //                ReConverter = item.RECONVERTER,
644
        //                ServiceID = item.SERVICE_ID,
645
        //                //ConvertState = ((StatusCodeType)item.STATUS).ToString(),
646
        //                ConvertState = (item.STATUS).ToString(),
647
        //                CreateTime = item.CREATE_DATETIME,
648
        //                TotalPage = item.TOTAL_PAGE,
649
        //                CurrentPageNo = item.CURRENT_PAGE,
650
        //                Exception = item.EXCEPTION,
651
        //                //ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID),
652
653
        //                Revision = item.REVISION,
654
        //                DocumnetNo = item.DOCUMENT_NO,
655
        //                DocumnetName = item.DOCUMENT_NAME,
656
        //                GroupNo = item.GROUP_NO
657
        //            };
658
        //            if (@whereq(convertitem))
659
        //            {
660
        //                //convertItems.Add(convertitem);
661
        //                StatusKeep.Add(convertitem);
662
        //            }
663
664
        //        }
665
        //    }
666
        //    System.Diagnostics.Debug.WriteLine(new TimeSpan(stopwatch.ElapsedTicks).ToString());
667
        //    //return convertItems;//디비 다 조인 후 조건 비교 후 그리드 출력
668
        //    return StatusKeep;
669
670
671
        //}
672
673
        //public IEnumerable<Interface.ConvertItem> GetConvertProjects(Func<CONVERTER_DOC, bool> @where) //@where는 입력값이 CONVERTER_DOC이고 출력값이 bool //부장님
674
        //public List<Interface.ConvertItem> GetConvertProjects(Func<CONVERTER_DOC, bool> @where) //@where는 입력값이 CONVERTER_DOC이고 출력값이 bool
675
        //System.Linq.IQueryable
676
        public IEnumerable<Interface.ConvertItem> GetConvertProjects(int status)//조인 후 조건 & 조건and조인
677
        //public List<Interface.ConvertItem> GetConvertProjects(Expression<Func<CONVERTER_DOC, bool>> @where) //linq and entity and sql
678
        //public IEnumerable<Interface.ConvertItem> GetConvertProjects(Func<CONVERTER_DOC, bool> @where) //원본
679
        {
680
            // System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();///////////////디비 테스트 후 해보기 
681
            // stopwatch.Start();
682
683
            // //@ 심벌 ex) string filename = "C:\\Temp\\1.txt"; -> filename = @"C:\Temp\1.txt"; and 여러 문자열 사용 가능
684
            ////var items = entities.CONVERTER_DOC.Where(@where);//부장님
685
            // List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();
686
687
            // var query = from items in entities.CONVERTER_DOC //세미
688
            //              join documents in entities.DOCUMENT_ITEM on items.DOCUMENT_ID equals documents.DOCUMENT_ID
689
            //              //where @where(items)
690
            //             select new//new 다음에 클래스 이름 넣으면 안됨 
691
            //             {
692
            //                 ID = items.ID,
693
            //                 DOCUMENT_URL = items.DOCUMENT_URL,
694
            //                 RECONVERTER = items.RECONVERTER,
695
            //                 SERVICE_ID = items.SERVICE_ID,
696
            //                 STATUS = items.STATUS,
697
            //                 CREATE_DATETIME = items.CREATE_DATETIME,
698
            //                 TOTAL_PAGE = items.TOTAL_PAGE,
699
            //                 CURRENT_PAGE = items.CURRENT_PAGE,
700
            //                 EXCEPTION = items.EXCEPTION,
701
            //                 PROJECT_NO = items.PROJECT_NO,
702
            //                 DOCUMENT_ID = items.DOCUMENT_ID,
703
            //                 REVISION = documents.REVISION,
704
            //                 DOCUMENT_NO = documents.DOCUMENT_NO,
705
            //                 DOCUMENT_NAME = documents.DOCUMENT_NAME,
706
            //                 GROUP_NO = documents.GROUP_NO
707
            //             };
708
709
710
            // if (query.Count() > 0)//ConvertItem에 값들 넣어야 함 그래야 값이 바뀌면 propertychanged로 그리드 실시간 없데이트 가능
711
            // {
712
            //     foreach (var item in query)
713
            //     {
714
            //         var convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
715
            //         {
716
            //             ReConverter = item.RECONVERTER,
717
            //             ServiceID = item.SERVICE_ID,
718
            //             //ConvertState = ((StatusCodeType)item.STATUS).ToString(),
719
            //             ConvertState = (item.STATUS).ToString(),
720
            //             CreateTime = item.CREATE_DATETIME,
721
            //             TotalPage = item.TOTAL_PAGE,
722
            //             CurrentPageNo = item.CURRENT_PAGE,
723
            //             Exception = item.EXCEPTION,
724
            //             ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID),
725
726
            //             Revision = item.REVISION,
727
            //             DocumnetNo = item.DOCUMENT_NO,
728
            //             DocumnetName = item.DOCUMENT_NAME,
729
            //             GroupNo = item.GROUP_NO
730
            //         };
731
732
733
            //         convertItems.Add(convertitem);
734
            //     }
735
            // }
736
            //System.Diagnostics.Debug.WriteLine(new TimeSpan(stopwatch.ElapsedTicks).ToString());
737
            //return convertItems;///////////////디비 테스트 후 해보기 
738
739
            //select new Interface.ConvertItem(ConvertDoc.DOCUMENT_ID, ConvertDoc.PROJECT_NO, ConvertDoc.ID, ConvertDoc.DOCUMENT_URL)
740
            //{
741
            //    ReConverter = ConvertDoc.RECONVERTER,
742
            //    ServiceID = ConvertDoc.SERVICE_ID,
743
            //    //ConvertState = ((StatusCodeType)item.STATUS).ToString(),
744
            //    ConvertState = (ConvertDoc.STATUS).ToString(),
745
            //    CreateTime = ConvertDoc.CREATE_DATETIME,
746
            //    TotalPage = ConvertDoc.TOTAL_PAGE,
747
            //    CurrentPageNo = ConvertDoc.CURRENT_PAGE,
748
            //    Exception = ConvertDoc.EXCEPTION,
749
            //    ConvertPath = GetConvertPath(ConvertDoc.PROJECT_NO, ConvertDoc.DOCUMENT_ID),
750
751
            //    Revision = documents.REVISION,
752
            //    DocumnetNo = documents.DOCUMENT_NO,
753
            //    DocumnetName = documents.DOCUMENT_NAME,
754
            //    GroupNo = documents.GROUP_NO
755
            //};
756
            //System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();///////////////디비 테스트 후 해보기 
757
            //stopwatch.Start();
758
            List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();//디비 다 조인 후 조건 비교 후 그리드 출력
759
            var query = from items in entities.CONVERTER_DOC //세미
760
                        join documents in entities.DOCUMENT_ITEM on items.DOCUMENT_ID equals documents.DOCUMENT_ID into GroupItems
761
                        from subpet in GroupItems.DefaultIfEmpty()
762
                        where items.STATUS == status
763
                        orderby items.CREATE_DATETIME descending
764
                        select new
765
                        {
766
                            ID = items.ID,
767
                            DOCUMENT_URL = items.DOCUMENT_URL,
768
                            RECONVERTER = items.RECONVERTER,
769
                            SERVICE_ID = items.SERVICE_ID,
770
                            STATUS = items.STATUS,
771
                            CREATE_DATETIME = items.CREATE_DATETIME,
772
                            TOTAL_PAGE = items.TOTAL_PAGE,
773
                            CURRENT_PAGE = items.CURRENT_PAGE,
774
                            EXCEPTION = items.EXCEPTION,
775
                            PROJECT_NO = items.PROJECT_NO,
776
                            DOCUMENT_ID = items.DOCUMENT_ID,
777
                            REVISION = subpet.REVISION,
778
                            DOCUMENT_NO = subpet.DOCUMENT_NO,
779
                            DOCUMENT_NAME = subpet.DOCUMENT_NAME,
780
                            GROUP_NO = subpet.GROUP_NO
781
                            //REVISION = documents.REVISION,
782
                            //DOCUMENT_NO = documents.DOCUMENT_NO,
783
                            //DOCUMENT_NAME = documents.DOCUMENT_NAME,
784
                            //GROUP_NO = documents.GROUP_NO
785
                        };
786
787
            if (query.Count() > 0)//세미
788 a6e5055d alzkakdixm
            {
789 2decfbdf alzkakdixm
                foreach (var item in query)
790 a6e5055d alzkakdixm
                {
791 2decfbdf alzkakdixm
                    //var convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
792
                    Interface.ConvertItem convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
793 a6e5055d alzkakdixm
                    {
794 2decfbdf alzkakdixm
795 a6e5055d alzkakdixm
                        ReConverter = item.RECONVERTER,
796
                        ServiceID = item.SERVICE_ID,
797
                        //ConvertState = ((StatusCodeType)item.STATUS).ToString(),
798 2decfbdf alzkakdixm
                        //ConvertState = (item.STATUS).ToString(),
799
                        ConvertState = (StatusCodeType)item.STATUS,
800 a6e5055d alzkakdixm
                        CreateTime = item.CREATE_DATETIME,
801
                        TotalPage = item.TOTAL_PAGE,
802
                        CurrentPageNo = item.CURRENT_PAGE,
803
                        Exception = item.EXCEPTION,
804 2decfbdf alzkakdixm
                        //ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID),
805 a6e5055d alzkakdixm
806 2decfbdf alzkakdixm
                        Revision = item.REVISION,
807
                        DocumnetNo = item.DOCUMENT_NO,
808
                        DocumnetName = item.DOCUMENT_NAME,
809
                        GroupNo = item.GROUP_NO,
810
                        DocumentID = item.DOCUMENT_ID
811
                    };
812
                        convertItems.Add(convertitem);
813 a6e5055d alzkakdixm
                }
814
            }
815 2decfbdf alzkakdixm
            //System.Diagnostics.Debug.WriteLine(new TimeSpan(stopwatch.ElapsedTicks).ToString());
816
            return convertItems;//디비 다 조인 후 조건 비교 후 그리드 출력
817
818
                                //if (Wheredel(convertitem) == false)
819
                    //if (@where(convertitem) == false)
820
                    //{
821
                    //    break;
822
                    //}
823
                    //if (@where(convertitem))
824
                    //{
825
                    //    convertItems.Add(convertitem);
826
                    //}
827
828
                    //yield return new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
829
                    //{
830
                    //    ReConverter = item.RECONVERTER,
831
                    //    ServiceID = item.SERVICE_ID,
832
                    //    //ConvertState = ((StatusCodeType)item.STATUS).ToString(),
833
                    //    ConvertState = (item.STATUS).ToString(),
834
                    //    CreateTime = item.CREATE_DATETIME,
835
                    //    TotalPage = item.TOTAL_PAGE,
836
                    //    CurrentPageNo = item.CURRENT_PAGE,
837
                    //    Exception = item.EXCEPTION,
838
                    //    ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID),
839
840
                    //    Revision = item.REVISION,
841
                    //    DocumnetNo = item.DOCUMENT_NO,
842
                    //    DocumnetName = item.DOCUMENT_NAME,
843
                    //    GroupNo = item.GROUP_NO
844
                    //};
845
846
847
            //var query = entities.CONVERTER_DOC.Where(@where);//이렇게 해서 두 테이블 조인하는  프로시저 만들어라
848
849
            //if (query.Count() > 0)
850
            //{
851
            //    foreach (var item in query)
852
            //    {
853
            //        //var docitem = entities.DOCUMENT_ITEM.Where(x => x.DOCUMENT_ID == item.DOCUMENT_ID);
854
            //        if (@where(item))
855
            //        {
856
            //            //string rev = "";
857
            //            //string docNo = "";
858
            //            //string docName = "";
859
            //            //string grpNo = "";
860
861
            //            //if (item.Count() > 0)
862
            //            //{
863
            //            //    rev = docitem.First().REVISION;
864
            //            //    docNo = docitem.First().DOCUMENT_NO;
865
            //            //    docName = docitem.First().DOCUMENT_NAME;
866
            //            //    grpNo = docitem.First().GROUP_NO;
867
            //            //}
868
869
            //            yield return new Interface.ConvertItem(item.DOCUMENT_ID, item.projectNo, item.ID, item.DOCUMENT_URL)
870
            //            {
871
            //                ReConverter = item.RECONVERTER,
872
            //                ServiceID = item.SERVICE_ID,
873
            //                //ConvertState = ((StatusCodeType)item.STATUS).ToString(),
874
            //                CreateTime = item.CREATE_DATETIME,
875
            //                TotalPage = item.TOTAL_PAGE,
876
            //                CurrentPageNo = item.CURRENT_PAGE,
877
            //                Exception = item.EXCEPTION,
878
            //                ConvertPath = GetConvertPath(item.projectNo, item.DOCUMENT_ID),
879
880
            //                Revision = item.REVISION,
881
            //                DocumnetNo = item.DOCUMENT_NO,
882
            //                DocumnetName = item.DOCUMENT_NAME,
883
            //                GroupNo = item.GROUP_NO
884
            //            };
885
            //        }
886
            //    }
887
            //}//프로시저
888
889
            //var items = entities.CONVERTER_DOC.Where(@where);//부장님원본
890
            //if (items.Count() > 0)//원본
891
            //{
892
            //    foreach (var item in items)
893
            //    {
894
            //        yield return new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
895
            //        {
896
            //            ReConverter = item.RECONVERTER,
897
            //            ServiceID = item.SERVICE_ID,
898
            //            //ConvertState = ((StatusCodeType)item.STATUS).ToString(),
899
            //            ConvertState = (item.STATUS).ToString(),
900
            //            CreateTime = item.CREATE_DATETIME,
901
            //            TotalPage = item.TOTAL_PAGE,
902
            //            CurrentPageNo = item.CURRENT_PAGE,
903
            //            Exception = item.EXCEPTION,
904
            //            ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID)
905
            //        };
906
            //    }
907
            //}//원본
908
909
            //LINQKit 하다 말음
910
            //List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();
911
            //var query = 
912
            //    from items in entities.CONVERTER_DOC //세미
913
            //    join documents in entities.DOCUMENT_ITEM on items.DOCUMENT_ID equals documents.DOCUMENT_ID
914
            //    select new//new 다음에 클래스 이름 넣으면 안됨 
915
            //            {
916
            //                ID = items.ID,
917
            //                DOCUMENT_URL = items.DOCUMENT_URL,
918
            //                RECONVERTER = items.RECONVERTER,
919
            //                SERVICE_ID = items.SERVICE_ID,
920
            //                STATUS = items.STATUS,
921
            //                CREATE_DATETIME = items.CREATE_DATETIME,
922
            //                TOTAL_PAGE = items.TOTAL_PAGE,
923
            //                CURRENT_PAGE = items.CURRENT_PAGE,
924
            //                EXCEPTION = items.EXCEPTION,
925
            //                PROJECT_NO = items.PROJECT_NO,
926
            //                DOCUMENT_ID = items.DOCUMENT_ID,
927
            //                REVISION = documents.REVISION,
928
            //                DOCUMENT_NO = documents.DOCUMENT_NO,
929
            //                DOCUMENT_NAME = documents.DOCUMENT_NAME,
930
            //                GROUP_NO = documents.GROUP_NO
931
            //            };
932
933
            //if (query.Count() > 0)//ConvertItem에 값들 넣어야 함 그래야 값이 바뀌면 propertychanged로 그리드 실시간 없데이트 가능
934
            //{
935
            //    foreach (var item in query)
936
            //    {
937
            //        var convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
938
            //        {
939
            //            ReConverter = item.RECONVERTER,
940
            //            ServiceID = item.SERVICE_ID,
941
            //            //ConvertState = ((StatusCodeType)item.STATUS).ToString(),
942
            //            ConvertState = (item.STATUS).ToString(),
943
            //            CreateTime = item.CREATE_DATETIME,
944
            //            TotalPage = item.TOTAL_PAGE,
945
            //            CurrentPageNo = item.CURRENT_PAGE,
946
            //            Exception = item.EXCEPTION,
947
            //            ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID),
948
949
            //            Revision = item.REVISION,
950
            //            DocumnetNo = item.DOCUMENT_NO,
951
            //            DocumnetName = item.DOCUMENT_NAME,
952
            //            GroupNo = item.GROUP_NO
953
            //        };
954
955
956
            //        convertItems.Add(convertitem);
957
958
            //    }
959
            //}
960
            //return convertItems;
961
            //LINQKit
962 a6e5055d alzkakdixm
963
        }
964
965
        public List<Interface.ConvertItem> GetConvertProjectsStatus(Func<CONVERTER_DOC, bool> @where)
966
        {
967
            List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();
968
969
970
            //var items = entities.CONVERTER_DOC.Where(x => x.STATUS == (int)statusCodeType).Take(takeCount).ToList(); //.Where(x => x.PROJECT_NO == gProjectNo);
971
            var items = entities.CONVERTER_DOC.Where(x => x.STATUS<= 4);
972
973
            if (items.Count() > 0)
974
            {
975
                foreach (var item in items)
976
                {
977
                    var convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL)
978
                    {
979
                        ReConverter = item.RECONVERTER,
980
                        ServiceID = item.SERVICE_ID,
981
                        //ConvertState = ((StatusCodeType)item.STATUS).ToString(),
982 2decfbdf alzkakdixm
                        //ConvertState = (item.STATUS).ToString(),
983
                        ConvertState = (StatusCodeType)item.STATUS,
984 a6e5055d alzkakdixm
                        CreateTime = item.CREATE_DATETIME,
985
                        TotalPage = item.TOTAL_PAGE,
986
                        CurrentPageNo = item.CURRENT_PAGE,
987
                        Exception = item.EXCEPTION,
988
                        ConvertPath = GetConvertPath(item.PROJECT_NO, item.DOCUMENT_ID)
989
                    };
990
991
992
                    convertItems.Add(convertitem);
993
                }
994
            }
995
996
            return convertItems;
997
        }
998
999 b92f142f taeseongkim
1000
        /// <summary>
1001 0157b158 taeseongkim
        /// 현재 서비스에서 컨버터중인 아이템.
1002
        /// </summary>
1003
        /// <returns></returns>
1004
        public List<Interface.ConvertItem> GetServiceAliveItems(string ServiceID)
1005
        {
1006
            List<Interface.ConvertItem> convertItems = new List<Interface.ConvertItem>();
1007
1008
            var items = entities.CONVERTER_DOC.Where(x => x.SERVICE_ID == ServiceID && x.STATUS > (int)StatusCodeType.None && x.STATUS < (int)StatusCodeType.Completed).ToList(); //.Where(x => x.PROJECT_NO == gProjectNo);
1009
1010
            if (items.Count() > 0)
1011
            {
1012
                foreach (var item in items)
1013
                {
1014
                    var convertitem = new Interface.ConvertItem(item.DOCUMENT_ID, item.PROJECT_NO, item.ID, item.DOCUMENT_URL);
1015
                    convertItems.Add(convertitem);
1016
                }
1017
            }
1018
            return convertItems;
1019
        }
1020
        
1021
        public SERVICE_PROPERTIES GetServiceProperties(string ServiceID)
1022
        {
1023
            SERVICE_PROPERTIES result = null;
1024
1025
            var items =  entities.SERVICE_PROPERTIES.Where(x => x.ID == ServiceID);
1026
1027
            if(items.Count() > 0)
1028
            {
1029
                result = items.First();
1030
            }
1031
1032
            return result;
1033
        }
1034 53c9637d taeseongkim
1035 0157b158 taeseongkim
        public bool SetConvertState(string ServiceID, string UniqueID,int State,int CurrentPage,int TotalPage,string Error)
1036 53c9637d taeseongkim
        {
1037
            bool result = false;
1038
1039
            try
1040
            {
1041
                var items = entities.CONVERTER_DOC.SingleOrDefault(f => f.ID == UniqueID);
1042
                //var items = entities.CONVERTER_DOC.SingleOrDefault(f => f.PROJECT_NO == gProjectNo && f.ID == UniqueID);
1043
1044
                if (items != null)
1045
                {
1046 0157b158 taeseongkim
                    items.SERVICE_ID = ServiceID;
1047 53c9637d taeseongkim
                    items.STATUS = State;
1048
                    items.CURRENT_PAGE = CurrentPage;
1049
                    items.TOTAL_PAGE = TotalPage;
1050
1051
                    StatusCodeType statusCode = (StatusCodeType)State;
1052
1053 65fbe3cb taeseongkim
                    if (items.START_DATETIME == null)
1054 a8f1a865 taeseongkim
                    {
1055
                        items.START_DATETIME = DateTime.Now;
1056
                    }
1057
1058 53c9637d taeseongkim
                    switch (statusCode)
1059
                    {
1060
                        case StatusCodeType.None:
1061
                            break;
1062
                        case StatusCodeType.Wait:
1063
                            items.START_DATETIME = DateTime.Now;
1064
                            break;
1065
                        case StatusCodeType.PageLoading:
1066
                            break;
1067
                        case StatusCodeType.Saving:
1068
                            break;
1069
                        case StatusCodeType.Completed:
1070 a0341bef taeseongkim
                            items.CURRENT_PAGE = items.TOTAL_PAGE;
1071 53c9637d taeseongkim
                            items.END_DATETIME= DateTime.Now;
1072
                            break;
1073
                        case StatusCodeType.FileError:
1074
                            Error = $" file Error :" + Error;
1075
                            items.END_DATETIME = DateTime.Now;
1076
                            break;
1077
                        case StatusCodeType.PageError:
1078
                            Error = $" Page No {CurrentPage} Error :" + Error;
1079
                            break;
1080
                        case StatusCodeType.NeedsPassword:
1081
                            break;
1082
                        case StatusCodeType.Error:
1083
                            Error = $" Error :" + Error;
1084
                            items.END_DATETIME = DateTime.Now;
1085
                            break;
1086
                        default:
1087
                            break;
1088
                    }
1089
1090
                    if(items.EXCEPTION == null)
1091
                    {
1092
                        items.EXCEPTION = "";
1093
                    }
1094
1095
                    if (items.EXCEPTION.Length < 255)
1096
                    {
1097
                        items.EXCEPTION = items.EXCEPTION + Error;
1098
                    }
1099
1100
                    entities.SaveChanges();
1101
                    result = true;
1102
                }
1103
            }
1104
            catch (Exception ex)
1105
            {
1106
                throw new Exception("SetConvertState",ex);
1107
            }
1108
1109
            return result;
1110
        }
1111
1112
        private string BaseStorage(string ProjectNo)
1113
        {
1114
            string result = "";
1115
1116
            var properties = entities.PROPERTIES.Where(f => f.PROPERTY == ProjectNo && f.TYPE == PROPERTIES_DEFINE.TILE_SOURCE_STORAGE);
1117
1118
            if(properties.Count() > 0)
1119
            {
1120
                result = properties.First().VALUE;
1121
            }
1122
            else
1123
            {
1124
                throw new Exception($"Project {ProjectNo} BaseStorage Not Setting.");
1125
            }
1126
1127
            return result;
1128
        }
1129
1130
    }
1131
}
클립보드 이미지 추가 (최대 크기: 500 MB)