프로젝트

일반

사용자정보

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

markus / ConvertService / ServiceController / StationControllerService / DataService.svc.cs @ fc4e50f2

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

1
using IFinalPDF;
2
using System;
3
using System.Collections.Generic;
4
using System.Configuration;
5
using System.Data.Entity.Core.Objects;
6
using System.Linq;
7
using System.Runtime.Remoting.Channels.Tcp;
8
//using System.Runtime.Serialization;
9
using System.ServiceModel;
10
using System.ServiceModel.Activation;
11
using System.Text;
12

    
13
namespace StationControllerService
14
{
15
    // 참고: "리팩터링" 메뉴에서 "이름 바꾸기" 명령을 사용하여 코드, svc 및 config 파일에서 클래스 이름 "DataService"을 변경할 수 있습니다.
16
    // 참고: 이 서비스를 테스트하기 위해 WCF 테스트 클라이언트를 시작하려면 솔루션 탐색기에서 DataService.svc나 DataService.svc.cs를 선택하고 디버깅을 시작하십시오.
17
    //[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
18

    
19
    public class DataService : IDataService
20
    {
21

    
22
        public List<SELECT_CONVERT_ITEM_Result> GET_SELECT_CONVERT_ITEM(string p_ID, string p_PROJECT_NO, string p_DOCUMENT_ID, Nullable<int> p_STATUS, Nullable<int> p_TAKE_COUNT, Nullable<System.DateTime> p_BEGIN_CREATE_DATETIME, Nullable<System.DateTime> p_FINISH_CREATE_DATETIME, Nullable<System.DateTime> p_BEGIN_START_DATETIE, Nullable<System.DateTime> p_FINISH_START_DATETIME, Nullable<System.DateTime> p_BEGIN_END_DATETIME, Nullable<System.DateTime> p_FINISH_END_DATETIME, string p_GROUP_NO, string p_DOCUMENT_NAME, string p_DOCUMENT_NO, string p_REVISION, string p_SERVICE_ID, Nullable<int> p_RECONVERTER, string p_DOCUMENT_URL, Nullable<int> p_ExcptionCheck)
23
        {
24
            List<SELECT_CONVERT_ITEM_Result> result = new List<SELECT_CONVERT_ITEM_Result>();
25

    
26
            try
27
            {
28
                ///var connectionstring = Properties.Resources.ConnectionString;
29

    
30
                using (markusEntities entities = new markusEntities())
31
                {
32
                    result = entities.SELECT_CONVERT_ITEM(p_ID, p_PROJECT_NO, p_DOCUMENT_ID, p_STATUS, p_TAKE_COUNT, p_BEGIN_CREATE_DATETIME, p_FINISH_CREATE_DATETIME, p_BEGIN_START_DATETIE, p_FINISH_START_DATETIME, p_BEGIN_END_DATETIME, p_FINISH_END_DATETIME, p_GROUP_NO, p_DOCUMENT_NAME, p_DOCUMENT_NO, p_REVISION, p_SERVICE_ID, p_RECONVERTER, p_DOCUMENT_URL, p_ExcptionCheck).ToList();
33

    
34
                    //System.Diagnostics.Debug.WriteLine("GET_SELECT_CONVERT_ITEM result count :" + result.Count());
35
                }
36
            }
37
            catch (Exception)
38
            {
39
                throw new FaultException("GET_SELECT_CONVERT_ITEM");
40
            }
41

    
42
            return result;
43
        }
44

    
45
        public int GET_SELECT_RERECONVERT_ITEM(string p_ID, Nullable<int> p_RECONVERTER, Nullable<System.DateTime> p_CREATE_DATETIME, Nullable<int> p_STATUS, Nullable<System.DateTime> p_END_DATETIME)
46
        {
47
            int result;
48

    
49
            try
50
            {
51
                //var connectionstring = Properties.Resources.ConnectionString;
52

    
53
                using (markusEntities entities = new markusEntities())
54
                {
55
                    result = entities.SELECT_RERECONVERT_ITEM(p_ID, p_RECONVERTER, p_CREATE_DATETIME, p_STATUS, p_END_DATETIME);
56
                }
57
            }
58
            catch (Exception)
59
            {
60
                throw new FaultException("GET_SELECT_RERECONVERT_ITEM");
61
            }
62

    
63
            return result;
64
        }
65

    
66
        public int GET_SELECT_CONVERT_DELETE(string p_ID)
67
        {
68
            int result;
69

    
70
            try
71
            {
72
                //var connectionstring = Properties.Resources.ConnectionString;
73

    
74
                using (markusEntities entities = new markusEntities())
75
                {
76
                    result = entities.SELECT_CONVERT_DELETE(p_ID);
77
                }
78
            }
79
            catch (Exception)
80
            {
81
                throw new FaultException("GET_SELECT_CONVERT_DELETE");
82
            }
83

    
84
            return result;
85
        }
86

    
87
        public List<SELECT_RUN_PROJECTS_Result> GET_SELECT_RUN_PROJECTS(int p_RUN_PROJECTS)
88
        {
89
            List<SELECT_RUN_PROJECTS_Result> result = new List<SELECT_RUN_PROJECTS_Result>();
90

    
91
            try
92
            {
93
                //var connectionstring = Properties.Resources.ConnectionString;
94

    
95
                using (markusEntities entities = new markusEntities())
96
                {
97
                    result = entities.SELECT_RUN_PROJECTS(p_RUN_PROJECTS).ToList();
98
                }
99
            }
100
            catch (Exception ex)
101
            {
102
                System.Diagnostics.Debug.WriteLine(ex);
103
                throw new FaultException("GET_SELECT_RUN_PROJECTS");
104
            }
105

    
106
            return result;
107
        }
108

    
109
        public int GET_SELECT_CONVERT_INSERT(string p_ID, string p_PROJECT_NO, string p_DOCUMENT_URL, string p_DOCUMENT_ID)
110
        {
111
            int result;
112

    
113
            try
114
            {
115
                //var connectionstring = Properties.Resources.ConnectionString;
116

    
117
                using (markusEntities entities = new markusEntities())
118
                {
119
                    result = entities.SELECT_CONVERT_INSERT(p_ID, p_PROJECT_NO, p_DOCUMENT_URL, p_DOCUMENT_ID);
120
                }
121
            }
122
            catch (Exception)
123
            {
124
                throw new FaultException("GET_SELECT_FINAL_PDF_INSERT");
125
            }
126

    
127
            return result;
128
        }
129

    
130
        public List<SELECT_FINAL_PDF_ITEM_Result> GET_SELECT_FINAL_PDF_ITEM(string p_ID, string p_PROJECT_NO, string p_DOCUMENT_ID, string p_MARKUPINFO_ID, string p_DOCINFO_ID, string p_DOCUMENT_NAME, string p_DOCUMENT_NO, string p_CREATE_USER_ID, Nullable<int> p_STATUS, Nullable<int> p_TAKE_COUNT, string p_GROUP_NO, string p_REVISION, Nullable<System.DateTime> p_BEGIN_CREATE_DATETIME, Nullable<System.DateTime> p_FINISH_CREATE_DATETIME, Nullable<System.DateTime> p_BEGIN_START_DATETIE, Nullable<System.DateTime> p_FINISH_START_DATETIME, Nullable<System.DateTime> p_BEGIN_END_DATETIME, Nullable<System.DateTime> p_FINISH_END_DATETIME, string p_DOCUMENT_URL, Nullable<int> p_ExcptionCheck)
131
        {
132
            List<SELECT_FINAL_PDF_ITEM_Result> result = new List<SELECT_FINAL_PDF_ITEM_Result>();
133

    
134
            try
135
            {
136
                //var connectionstring = Properties.Resources.ConnectionString;
137

    
138
                using (markusEntities entities = new markusEntities())
139
                {
140
                    result = entities.SELECT_FINAL_PDF_ITEM(p_ID, p_PROJECT_NO, p_DOCUMENT_ID, p_MARKUPINFO_ID, p_DOCINFO_ID, p_DOCUMENT_NAME, p_DOCUMENT_NO, p_CREATE_USER_ID, p_STATUS, p_TAKE_COUNT, p_GROUP_NO, p_REVISION, p_BEGIN_CREATE_DATETIME, p_FINISH_CREATE_DATETIME, p_BEGIN_START_DATETIE, p_FINISH_START_DATETIME, p_BEGIN_END_DATETIME, p_FINISH_END_DATETIME, p_DOCUMENT_URL, p_ExcptionCheck).ToList();
141
                }
142
            }
143
            catch (Exception)
144
            {
145
                throw new FaultException("GET_SELECT_FINAL_PDF_ITEM");
146
            }
147

    
148
            return result;
149
        }
150

    
151
        public int GET_SELECT_FINAL_PDF_DELETE(string p_ID)
152
        {
153
            int result;
154

    
155
            try
156
            {
157
                //var connectionstring = Properties.Resources.ConnectionString;
158

    
159
                using (markusEntities entities = new markusEntities())
160
                {
161
                    result = entities.SELECT_FINAL_PDF_DELETE(p_ID);
162
                }
163
            }
164
            catch (Exception)
165
            {
166
                throw new FaultException("GET_SELECT_FINAL_PDF_DELETE");
167
            }
168

    
169
            return result;
170
        }
171

    
172
        public int GET_SELECT_FINAL_PDF_INSERT(string p_ID, string p_PROJECT_NO, string p_DOCUMENT_URL, string p_DOCUMENT_ID)
173
        {
174
            int result;
175

    
176
            try
177
            {
178
                //var connectionstring = Properties.Resources.ConnectionString;
179

    
180
                using (markusEntities entities = new markusEntities())
181
                {
182
                    result = entities.SELECT_FINAL_PDF_INSERT(p_ID, p_PROJECT_NO, p_DOCUMENT_URL, p_DOCUMENT_ID, null, null, null, null);
183
                }
184
            }
185
            catch (Exception)
186
            {
187
                throw new FaultException("GET_SELECT_FINAL_PDF_INSERT");
188
            }
189

    
190
            return result;
191
        }
192

    
193
        public List<FINALPDF_COUNT_Result> GET_FINALPDF_COUNT(Nullable<int> p_STATUS, Nullable<System.DateTime> p_BEGIN_CREATE_DATETIME, Nullable<System.DateTime> p_FINISH_CREATE_DATETIME)
194
        {
195

    
196
            List<FINALPDF_COUNT_Result> result = new List<FINALPDF_COUNT_Result>();
197

    
198
            try
199
            {
200
                //var connectionstring = Properties.Resources.ConnectionString;
201

    
202
                using (markusEntities entities = new markusEntities())
203
                {
204
                    result = entities.FINALPDF_COUNT(p_STATUS, p_BEGIN_CREATE_DATETIME, p_FINISH_CREATE_DATETIME).ToList();
205
                }
206
            }
207
            catch (Exception)
208
            {
209
                throw new FaultException("GET_FINALPDF_COUNT");
210
            }
211

    
212
            return result;
213
        }
214

    
215
        public List<CONVERT_COUNT_Result> GET_CONVERT_COUNT(Nullable<int> p_STATUS, Nullable<System.DateTime> p_BEGIN_CREATE_DATETIME, Nullable<System.DateTime> p_FINISH_CREATE_DATETIME)
216
        {
217

    
218
            List<CONVERT_COUNT_Result> result = new List<CONVERT_COUNT_Result>();
219

    
220
            try
221
            {
222
                //var connectionstring = Properties.Resources.ConnectionString;
223

    
224
                using (markusEntities entities = new markusEntities())
225
                {
226
                    result = entities.CONVERT_COUNT(p_STATUS, p_BEGIN_CREATE_DATETIME, p_FINISH_CREATE_DATETIME).ToList();
227
                }
228
            }
229
            catch (Exception)
230
            {
231
                throw new FaultException("GET_CONVERT_COUNT");
232
            }
233

    
234
            return result;
235
        }
236

    
237
        public List<SELECT_DOCUMENT_ITEM_Result> GET_DOCUMENT_ITEM(Nullable<int> p_TAKE_COUNT, string p_REVISION, string p_DOCUMENT_N0, string p_DOCUMENT_NAME, string p_GROUP_N0, string p_ORIGINAL_FILE, string p_DOCUMENT_ID, string p_PROJECT_NO)
238
        {
239

    
240
            List<SELECT_DOCUMENT_ITEM_Result> result = new List<SELECT_DOCUMENT_ITEM_Result>();
241

    
242
            try
243
            {
244
                //var connectionstring = Properties.Resources.ConnectionString;
245

    
246
                using (markusEntities entities = new markusEntities())
247
                {
248
                    result = entities.SELECT_DOCUMENT_ITEM(p_TAKE_COUNT, p_REVISION, p_DOCUMENT_N0, p_DOCUMENT_NAME, p_GROUP_N0, p_ORIGINAL_FILE, p_DOCUMENT_ID, p_PROJECT_NO).ToList();
249
                }
250
            }
251
            catch (Exception ex)
252
            {
253
                System.Diagnostics.Debug.WriteLine(ex.ToString());
254
                throw new FaultException("GET_DOCUMENT_ITEM");
255
            }
256

    
257
            return result;
258
        }
259

    
260
        public List<SELECT_PROPERTIES_RUN_PROJECTS_Result> GET_PROPERTIES_RUN_PROJECTS(string p_PROJECT_NO)
261
        {
262

    
263
            List<SELECT_PROPERTIES_RUN_PROJECTS_Result> result = new List<SELECT_PROPERTIES_RUN_PROJECTS_Result>();
264

    
265
            try
266
            {
267
                //var connectionstring = Properties.Resources.ConnectionString;
268

    
269
                using (markusEntities entities = new markusEntities())
270
                {
271
                    result = entities.SELECT_PROPERTIES_RUN_PROJECTS(p_PROJECT_NO).ToList();
272
                }
273
            }
274
            catch (Exception ex)
275
            {
276
                System.Diagnostics.Debug.WriteLine(ex.ToString());
277
                throw new FaultException("GET_PROPERTIES_RUN_PROJECTS");
278
            }
279

    
280
            return result;
281
        }
282

    
283
        public int GET_RUNANDPROPERTY_INSERT(string p_PROJECT_NO, string p_PROJECT_NAME, string p_TYPE_InitialCatalog, string p_VALUE_InitialCatalog, string p_TYPE_TileSorceStorage,
284
            string p_VALUE_TileSorceStorage, string p_TYPE_TileSourcePath, string p_VALUE_TileSourcePath, string p_TYPE_FinalPDFStorageRemote, string p_VALUE_FinalPDFStorageRemote,
285
            string p_TYPE_FinalPDFStorageLocal, string p_VALUE_FinalPDFStorageLocal, string p_TYPE_UpLoadServiceUrl, string p_VALUE_UpLoadServiceUrl, Nullable<int> p_IS_ACTIVITY)
286
        {
287

    
288
            int result;
289

    
290
            try
291
            {
292
                //var connectionstring = Properties.Resources.ConnectionString;
293

    
294
                using (markusEntities entities = new markusEntities())
295
                {
296
                    result = entities.SELECT_RUNANDPROPERTY_INSERT(p_PROJECT_NO, p_PROJECT_NAME, p_TYPE_InitialCatalog, p_VALUE_InitialCatalog, p_TYPE_TileSorceStorage, p_VALUE_TileSorceStorage, p_TYPE_TileSourcePath, p_VALUE_TileSourcePath, p_TYPE_FinalPDFStorageRemote,
297
                        p_VALUE_FinalPDFStorageRemote, p_TYPE_FinalPDFStorageLocal, p_VALUE_FinalPDFStorageLocal, p_TYPE_UpLoadServiceUrl, p_VALUE_UpLoadServiceUrl, p_IS_ACTIVITY);
298
                }
299
            }
300
            catch (Exception ex)
301
            {
302
                System.Diagnostics.Debug.WriteLine(ex.ToString());
303
                throw new FaultException("GET_RUNANDPROPERTY_INSERT");
304
            }
305

    
306
            return result;
307

    
308
        }
309

    
310

    
311
        public List<FINAL_PDF_MARKUP_CHECK_Result> GET_FINAL_PDF_MARKUP_CHECK(string p_PROJECT_NO, string p_DOCUMENT_ID)
312
        {
313
            List<FINAL_PDF_MARKUP_CHECK_Result> results = new List<FINAL_PDF_MARKUP_CHECK_Result>();
314

    
315
            try
316
            {
317
                using (markusEntities entities = new markusEntities())
318
                {
319
                    results = entities.FINAL_PDF_MARKUP_CHECK(p_PROJECT_NO, p_DOCUMENT_ID).ToList();
320
                }
321
            }
322
            catch (Exception ex)
323
            {
324
                System.Diagnostics.Debug.WriteLine(ex.ToString());
325
                throw new FaultException("FINAL_PDF_MARKUP_CHECK");
326
            }
327
            return results;
328
        }
329

    
330
        public List<SELECT_DOCINFO_Result> GET_SELECT_DOCINFO(string p_DOCINFO_ID)
331
        {
332
            List<SELECT_DOCINFO_Result> results = new List<SELECT_DOCINFO_Result>();
333

    
334
            try
335
            {
336
                using (markusEntities entities = new markusEntities())
337
                {
338
                    results = entities.SELECT_DOCINFO(p_DOCINFO_ID).ToList();
339
                }
340
            }
341
            catch (Exception ex)
342
            {
343
                System.Diagnostics.Debug.WriteLine(ex.ToString());
344
                throw new FaultException("GET_SELECT_DOCINFO");
345
            }
346
            return results;
347
        }
348

    
349
        private static string shortGuid()
350
        {
351
            byte[] bytes = new byte[16];
352
            using (var provider = System.Security.Cryptography.RandomNumberGenerator.Create())
353
            {
354
                provider.GetBytes(bytes);
355
            }
356

    
357
            var guid = new Guid(bytes);
358

    
359
            return Convert.ToBase64String(guid.ToByteArray())
360
                .Substring(0, 10)
361
                .Replace("/", "")
362
                .Replace("+", "") + DateTime.UtcNow.Ticks.ToString("x");
363
        }
364

    
365
        public bool FinalPDF_GetFinalPDFStatus(string DocInfoID, string MarkupInfoID, string CreateUserID)
366
        {
367
            bool result = false;
368

    
369
            try
370
            {
371
                using (markusEntities _entity = new markusEntities())
372
                {
373
                    var finalpdf = _entity.SELECT_FINAL_PDF_ITEM(null, null, null, MarkupInfoID, DocInfoID, null, null, CreateUserID, 4, null, null, null, null, null, null, null, null, null, null, null).ToList();
374
                    if (finalpdf != null)
375
                    {
376
                        result = true;
377
                    }
378
                    else
379
                    {
380
                        result = false;
381
                    }
382
                }
383
            }
384
            catch (Exception ex)
385
            {
386
                System.Diagnostics.Debug.WriteLine(ex.ToString());
387
                throw new FaultException("FinalPDF_GetFinalPDFStatus");
388
            }
389
            return result;
390
        }
391

    
392
        private string _ChanID = null;
393
        TcpChannel chan = null;
394
        public FinalPDFResult SetFinalPDF(string ProjectNo, string DocInfoID, string MarkupInfoID, string CreateUserID)
395
        {
396
            #region 임시보관
397
            #endregion
398
            FinalPDFResult _result = new FinalPDFResult();
399
            RemFinalPDFObject remObj = null;
400
            try
401
            {
402
                string _finalID = shortGuid();
403
                int _DocTotalPages = -1;
404
                string docItemId;
405

    
406
                using (markusEntities entities = new markusEntities())
407
                {
408
                    var _doc = entities.SELECT_DOCINFO(DocInfoID).ToList();
409

    
410
                    if (_doc.Count() > 0)
411
                    {
412
                        _DocTotalPages = _doc.First().PAGE_COUNT.Value;
413
                        docItemId = _doc.First().DOCUMENT_ID;
414
                    }
415
                    else
416
                    {
417
                        _result.Status = FinalStatus.Error;
418
                        _result.Exception = "페이지 정보를 가져올 수 없습니다.";
419
                        return _result;
420
                    }
421
                }
422
                if (_DocTotalPages > 0)
423
                {
424
                    using (markusEntities entities = new markusEntities())
425
                    {
426
                        entities.SELECT_FINAL_PDF_INSERT(_finalID, ProjectNo, DocInfoID, docItemId, MarkupInfoID, CreateUserID, _DocTotalPages, (int)IFinalPDF.FinalStatus.Insert);
427
                    };
428

    
429
                    System.Runtime.Remoting.Channels.IChannel _ch = System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp");
430
                    if (_ch == null)
431
                    {
432
                        chan = new TcpChannel();
433
                        _ChanID = chan.ChannelName;
434
                        System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(chan, false);
435
                        // Create an instance of the remote object
436

    
437
                        //remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
438
                        //                          "tcp://localhost:9092/remFinalPDF");
439
                        remObj = (RemFinalPDFObject)Activator.GetObject(typeof(RemFinalPDFObject),
440
                                                  "tcp://192.168.0.67:9092/remFinalPDF");
441
                                                  //"tcp://localhost:9092/remFinalPDF");
442

    
443

    
444
                        //"tcp://localhost:8080/remFinalPDF");
445

    
446
                        _result = remObj.SetFinalPDF(ProjectNo, _finalID);
447
                        _result.FinalID = _finalID;
448
                        _result.Status = FinalStatus.Success;
449

    
450
                        //MarkupToPDF.MarkupToPDF fa = new MarkupToPDF.MarkupToPDF();
451
                        //fa.MakeFinalPDF(fm);
452
                    }
453
                    else
454
                    {
455
                        _ChanID = _ch.ChannelName;
456
                    }
457
                }
458
            }
459
            catch (Exception ex)
460
            {
461
                System.Diagnostics.Debug.WriteLine("KCOM_API - SetFinalPDF : " + ex.ToString());
462

    
463
                _result.Status = FinalStatus.Error;
464

    
465
                if (ex.GetType() == typeof(System.Net.Sockets.SocketException))
466
                    _result.Exception = "Final Server Not Connection";
467
                else _result.Exception = ex.ToString();
468
            }
469
            finally
470
            {
471
                remObj = null;
472
                if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel("tcp") != null)
473
                    System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(chan);
474

    
475
                GC.Collect(2);
476
            }
477
            return _result;
478
        }
479

    
480

    
481
        public List<SELECT_MARKUP_INFO_Result> SELECT_MARKUP_INFO(string p_DOCINFO_ID)
482
        {
483
            List<SELECT_MARKUP_INFO_Result> results = new List<SELECT_MARKUP_INFO_Result>();
484

    
485
            try
486
            {
487
                using (markusEntities entities = new markusEntities())
488
                {
489
                    results = entities.SELECT_MARKUP_INFO(p_DOCINFO_ID).ToList();
490
                }
491
            }
492
            catch (Exception ex)
493
            {
494
                System.Diagnostics.Debug.WriteLine(ex.ToString());
495
                throw new FaultException("SELECT_MARKUP_INFO");
496
            }
497
            return results;
498
        }
499
    }
500
}
클립보드 이미지 추가 (최대 크기: 500 MB)