프로젝트

일반

사용자정보

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

markus / MarkusLogview / MARKUS_LOGVIEW / Controllers / MarkusHub.cs @ 84578b97

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

1
using System;
2
using System.Collections.Generic;
3
using System.Diagnostics;
4
using System.Linq;
5
using System.Reflection;
6
using System.Threading.Tasks;
7
using System.Web;
8
using IKCOM;
9
using MarkusDataModel.Common;
10
using MarkusDataModel.DataModel;
11
using MarkusDataModel.DTOs;
12
using Microsoft.AspNet.SignalR;
13
using Microsoft.AspNet.SignalR.Hubs;
14
using ServiceInterface;
15
using static ServiceInterface.LogView_Interface;
16

    
17
namespace MARKUS_LOGVIEW.Controllers
18
{
19
    [HubName("MarkusHub")]
20
    public class MyHub : Hub
21
    {
22
        #region Real Time Transport Data 
23

    
24
        //private ServiceEventLogger_iis _serviceEventLogger;
25

    
26
        public MyHub()
27
        {
28
            //_serviceEventLogger = new ServiceEventLogger_iis();
29
        }
30

    
31
        #region Entity Method 
32
        /// <summary>
33
        /// PDF status 가져오기
34
        /// </summary>
35
        /// <returns></returns>
36
        public List<StatusDTO> GetPdfStatus()
37
        {
38

    
39
            using (markusEntities ent = new markusEntities(ConnectStringBuilder.MarkusEntitiesConnectionString().ToString()))
40
            {
41
                return ent.PROPERTIES
42
                    .Where(p => p.TYPE == "PDFStatus")
43
                    .Select(ret => new StatusDTO()
44
                    {
45
                        ID = ret.ID,
46
                        Property = ret.PROPERTY,
47
                        Type = ret.TYPE,
48
                        Value = ret.VALUE
49
                    }).ToList();
50

    
51
            }
52

    
53
        }
54

    
55
        /// <summary>
56
        /// 프로젝트 리스트 가져오기
57
        /// </summary>
58
        /// <param name="projNo"></param>
59
        /// <param name="pType"></param>
60
        /// <returns></returns>
61
        public IEnumerable<RunProjectsList> ProjectList(string projNo, string pType)
62
        {
63

    
64
            List<RunProjectsList> ConvertProjectList = new List<RunProjectsList>();
65
            GET_PROJECT_TYPE getProjType = new GET_PROJECT_TYPE();
66

    
67
            using (markusEntities entity = new markusEntities(ConnectStringBuilder.MarkusEntitiesConnectionString().ToString()))
68
            {
69

    
70
                // 실행 프로젝트에 대해서 가져옴 ( IsActivity 가 1 인 프로젝트 ) 
71
                var runProject = entity
72
                .RUN_PROJECTS
73
                .Where(run => run.IS_ACTIVITY.Equals(1) && run.PROJECT_NO == projNo)
74
                .OrderBy(order => order.RUN_DATETIME)
75
                .ToList();
76

    
77
                if (runProject.Count > 0)
78
                {
79

    
80
                    // 프로젝트 리스트 불러오기 
81
                    var projectList = runProject.Select(ret => new RunProjectsList()
82
                    {
83
                        ProjectNO = ret.PROJECT_NO,
84
                        ProjectName = ret.PROJECT_NAME,
85
                        RunDateTime = ret.RUN_DATETIME,
86
                        IsActivity = ret.IS_ACTIVITY
87
                    }).ToList();
88

    
89
                    projectList.ForEach(proj =>
90
                    {
91

    
92
                        var statusCount = (pType == getProjType.Convert) ?
93
                            entity.CONVERTER_DOC
94
                            .Where(cd => cd.PROJECT_NO == proj.ProjectNO)
95
                            .GroupBy(g => g.STATUS).OrderBy(g => g.Key)
96
                            .Select(docStatus => new ConvertingStatus()
97
                            {
98
                                Key = docStatus.Key,
99
                                Count = docStatus.Count(),
100
                            })
101
                            :
102
                            entity.FINAL_PDF
103
                             .Where(cd => cd.PROJECT_NO == proj.ProjectNO)
104
                             .GroupBy(g => g.STATUS)
105
                             .OrderBy(g => g.Key)
106
                             .Select(docStatus => new ConvertingStatus()
107
                             {
108
                                 Key = docStatus.Key,
109
                                 Count = docStatus.Count(),
110
                             });
111

    
112
                        // Status 별로 분류
113
                        statusCount.ToList().ForEach(stat =>
114
                        {
115

    
116
                            switch (stat.Key)
117
                            {
118
                                case (int)PDFStatus.Insert:
119
                                    proj.Insert = stat.Count;
120
                                    break;
121
                                case (int)PDFStatus.Wait:
122
                                    proj.Wait = stat.Count;
123
                                    break;
124
                                case (int)PDFStatus.Crop:
125
                                    proj.Crop = stat.Count;
126
                                    break;
127
                                case (int)PDFStatus.Success:
128
                                    proj.Success = stat.Count;
129
                                    break;
130
                                case (int)PDFStatus.Error:
131
                                    proj.Error = stat.Count;
132
                                    break;
133
                            }
134

    
135
                            proj.Entire += stat.Count;
136

    
137
                        });
138

    
139
                        ConvertProjectList.Add(proj);
140

    
141
                    });
142

    
143
                }
144

    
145
            }
146

    
147
            return ConvertProjectList;
148

    
149
        }
150
        #endregion
151

    
152
        #region Project Broadcast
153
        /// <summary>
154
        /// 프로젝트 리스트 보내기
155
        /// </summary>
156
        /// <param name="ProjectNO"></param>
157
        /// <param name="pType"></param>
158
        /// <returns></returns>
159
        [HubMethodName("GetProjectList")]
160
        public void GetProjectList(string ProjectNO, string pType)
161
        {
162
            Clients.All.UpdateProjectList(ProjectList(ProjectNO, pType), pType);
163
        }
164
        #endregion
165

    
166
        #region Convert Broadcast
167
        /// <summary>
168
        /// Insert 
169
        /// </summary>
170
        /// <returns></returns>
171
        public void BroadcastConvertTableInserted(CONVERTER_DOC InsertConvertData)
172
        {
173
            try
174
            {
175
                //_serviceEventLogger.WriteEventEntry(MethodBase.GetCurrentMethod().Name, EventLogEntryType.SuccessAudit);
176
                Clients.All.BroadcastConvertTableInserted(InsertConvertData, GetPdfStatus());
177

    
178
            }
179
            catch (Exception)
180
            {
181
                //_serviceEventLogger.WriteEventEntry(MethodBase.GetCurrentMethod().Name, EventLogEntryType.Error);
182
                throw;
183
            }
184
        }
185
        /// <summary>
186
        /// Change
187
        /// </summary>
188
        /// <param name="changedConvertData"></param>
189
        /// <returns></returns>
190
        public void BroadcastConvertTableChanged(CONVERTER_DOC changedConvertData)
191
        {
192
            try
193
            {
194
                //_serviceEventLogger.WriteEventEntry(MethodBase.GetCurrentMethod().Name, EventLogEntryType.SuccessAudit);
195
                Clients.All.BroadcastConvertTableChanged(changedConvertData, GetPdfStatus());
196
            }
197
            catch (Exception ex)
198
            {
199
                //_serviceEventLogger.WriteEventEntry(MethodBase.GetCurrentMethod().Name + " : " + ex.Message, EventLogEntryType.Error);
200
                throw;
201
            }
202
        }
203
        /// <summary>
204
        /// Delete
205
        /// </summary>
206
        /// <param name="deletedConvertData"></param>
207
        /// <returns></returns>
208
        public void BroadcastConvertTableDeleted(CONVERTER_DOC deletedConvertData)
209
        {
210

    
211
            try
212
            {
213
                //_serviceEventLogger.WriteEventEntry(MethodBase.GetCurrentMethod().Name, EventLogEntryType.SuccessAudit);
214
                Clients.All.BroadcastConvertTableDeleted(deletedConvertData);
215

    
216
            }
217
            catch (Exception ex)
218
            {
219
                //_serviceEventLogger.WriteEventEntry(MethodBase.GetCurrentMethod().Name + " : " + ex.Message, EventLogEntryType.Error);
220
                throw;
221
            }
222

    
223
        }
224
        #endregion
225

    
226
        #region Final Broadcast 
227
        /// <summary>
228
        /// Insert
229
        /// </summary>
230
        /// <returns></returns>
231
        public void BroadcastMergeTableInserted(FINAL_PDF InsertData)
232
        {
233

    
234
            try
235
            {
236
                //_serviceEventLogger.WriteEventEntry(MethodBase.GetCurrentMethod().Name, EventLogEntryType.SuccessAudit);
237
                Clients.All.BroadcastMergeTableInserted(InsertData, GetPdfStatus());
238
            }
239
            catch (Exception ex)
240
            {
241
                //_serviceEventLogger.WriteEventEntry(MethodBase.GetCurrentMethod().Name + " : " + ex.Message, EventLogEntryType.Error);
242
                throw;
243
            }
244

    
245
        }
246
        /// <summary>
247
        /// Change
248
        /// </summary>
249
        /// <param name="changeFinalData"></param>
250
        /// <returns></returns>
251
        public void BroadcastMergeTableChanged(FINAL_PDF changeFinalData)
252
        {
253
            try
254
            {
255
                //_serviceEventLogger.WriteEventEntry(MethodBase.GetCurrentMethod().Name, EventLogEntryType.SuccessAudit);
256
                Clients.All.BroadcastMergeTableChanged(changeFinalData, GetPdfStatus());
257
            }
258
            catch (Exception ex)
259
            {
260
                //_serviceEventLogger.WriteEventEntry(MethodBase.GetCurrentMethod().Name + " : " + ex.Message, EventLogEntryType.Error);
261
                throw;
262
            }
263

    
264
        }
265
        /// <summary>
266
        /// Delete
267
        /// </summary>
268
        /// <param name="DeletedFinalData"></param>
269
        /// <returns></returns>
270
        public void BroadcastMergeTableDeleted(FINAL_PDF DeletedFinalData)
271
        {
272
            try
273
            {
274
                //_serviceEventLogger.WriteEventEntry(MethodBase.GetCurrentMethod().Name, EventLogEntryType.SuccessAudit);
275
                Clients.All.BroadcastMergeTableDeleted(DeletedFinalData);
276
            }
277
            catch (Exception ex)
278
            {
279
                //_serviceEventLogger.WriteEventEntry(MethodBase.GetCurrentMethod().Name + " : " + ex.Message, EventLogEntryType.Error);
280
                throw;
281
            }
282

    
283
        }
284

    
285
        #endregion
286

    
287
        #region hub override method 
288
        // hub disconnected
289
        public override Task OnDisconnected(bool stopCalled)
290
        {
291

    
292
            try
293
            {
294

    
295
                //_serviceEventLogger.WriteEventEntry((MethodBase.GetCurrentMethod().Name + ", connection ID :" + Context.ConnectionId), EventLogEntryType.SuccessAudit);
296

    
297
                if (stopCalled)
298
                {
299
                    Console.WriteLine(String.Format("Client {0} explicitly closed the connection.", Context.ConnectionId));
300
                }
301
                else
302
                {
303
                    Console.WriteLine(String.Format("Client {0} timed out .", Context.ConnectionId));
304
                }
305

    
306
                return base.OnDisconnected(stopCalled);
307

    
308
            }
309
            catch (Exception)
310
            {
311
                //_serviceEventLogger.WriteEventEntry((MethodBase.GetCurrentMethod().Name + ", connection ID :" + Context.ConnectionId), EventLogEntryType.Error);
312
                throw;
313
            }
314

    
315

    
316
        }
317

    
318
        public override Task OnConnected()
319
        {
320
            // Add your own code here.
321
            // For example: in a chat application, record the association between
322
            // the current connection ID and user name, and mark the user as online.
323
            // After the code in this method completes, the client is informed that
324
            // the connection is established; for example, in a JavaScript client,
325
            // the start().done callback is executed.
326
            try
327
            {
328

    
329
                //_serviceEventLogger.WriteEventEntry((MethodBase.GetCurrentMethod().Name + ", connection ID :" + Context.ConnectionId), EventLogEntryType.SuccessAudit);
330
                return base.OnConnected();
331

    
332
            }
333
            catch (Exception)
334
            {
335
                //_serviceEventLogger.WriteEventEntry((MethodBase.GetCurrentMethod().Name + ", connection ID :" + Context.ConnectionId), EventLogEntryType.Error);
336
                throw;
337
            }
338

    
339
        }
340

    
341
        public override Task OnReconnected()
342
        {
343
            // Add your own code here.
344
            // For example: in a chat application, you might have marked the
345
            // user as offline after a period of inactivity; in that case 
346
            // mark the user as online again.
347
            try
348
            {
349

    
350
                //_serviceEventLogger.WriteEventEntry((MethodBase.GetCurrentMethod().Name + ", connection ID :" + Context.ConnectionId), EventLogEntryType.SuccessAudit);
351
                return base.OnReconnected();
352

    
353
            }
354
            catch (Exception)
355
            {
356
                //_serviceEventLogger.WriteEventEntry((MethodBase.GetCurrentMethod().Name + ", connection ID :" + Context.ConnectionId), EventLogEntryType.Error);
357
                throw;
358
            }
359

    
360
        }
361
        #endregion
362

    
363
        #endregion
364
    }
365

    
366
    [HubName("MarkusLicenseHub")]
367
    public class MarkusLicenseHub : Hub
368
    {
369
        #region Markus Usage History Stamp
370

    
371
        LICENSE_COMMENT _COMMENT = new LICENSE_COMMENT();
372

    
373
        /// <summary>
374
        /// Markus 공지사항 전달 
375
        /// </summary>
376
        /// <param name="msg"></param>
377
        public void MarkusNotification(string msg)
378
        {
379
            Clients.All.MarkusNotification(msg);
380
        }
381

    
382
        /// <summary>
383
        /// Markus 프로그램에 접속하였을 때 로그 기록
384
        /// </summary>
385
        /// <param name="userID"></param>
386
        /// <param name="userName"></param>
387
        public int ConnectionMarkus(string userID,string projectNO)
388
        {
389
            #region 접속 기록 
390
            // 해당 사용자가 라이센스 이용자로 등록되어 있는지 확인.
391
            using (markusEntities ent = new markusEntities(ConnectStringBuilder.MarkusEntitiesConnectionString().ToString()))
392
            {
393

    
394
                MEMBER connectionUser = ent.MEMBER
395
                    .Where(mem => mem.ID == userID && mem.PROJECT_NO == projectNO)
396
                    .FirstOrDefault();
397

    
398
                if (connectionUser != null)
399
                {
400

    
401
                    return ConnectionStamp(connectionUser, Context.ConnectionId);
402

    
403
                }
404
                else
405
                {
406
                    return 404;
407
                }
408

    
409
            }
410
            #endregion
411
        }
412

    
413
        /// <summary>
414
        /// 다른기기 강제종료 하고 접속할려고 할때 해당 기기 로그 기록하고 다른기기에는 강제종료 메세지 전달 
415
        /// </summary>
416
        /// <param name="userID"></param>
417
        /// <param name="userName"></param>
418
        /// <returns></returns>
419
        public bool ForceConnectionMarkus(string userID)
420
        {
421
            #region 다른기기 강제종료 하고 접속할려고 할때 해당 기기 로그 기록하고 다른기기에는 강제종료 메세지 전달 
422
            try
423
            {
424
                using (markusEntities ent = new markusEntities(ConnectStringBuilder.MarkusEntitiesConnectionString().ToString()))
425
                {
426

    
427
                    var lastConnectionLog = ent.LICENSE_LOG
428
                        .Where(fil => fil.USER_ID == userID && fil.STATUS == (int)MARKUS_CONNECTION_TYPE.PROCESSING)
429
                        .OrderByDescending(order => order.EVENT_TIME)
430
                        .FirstOrDefault();
431

    
432
                    if (lastConnectionLog != null)
433
                    {
434

    
435
                        MEMBER connectionUser = ent.MEMBER
436
                            .Where(mem => mem.ID == userID)
437
                            .FirstOrDefault();
438

    
439
                        if (connectionUser != null)
440
                        {
441

    
442
                            ForceConnectionStamp(connectionUser, Context.ConnectionId);
443

    
444
                            Clients.Client(lastConnectionLog.CONNECTION_ID).ForceTerminate(true);
445

    
446
                            return true;
447

    
448
                        }
449
                        else
450
                        {
451
                            return false;
452
                        }
453

    
454
                    }
455
                    else
456
                    {
457
                        return false;
458
                    }
459

    
460
                }
461
            }
462
            catch (Exception)
463
            {
464
                throw;
465
            }
466
            #endregion
467
        }
468

    
469
        /// <summary>
470
        /// 프로그램을 정상적으로 종료하였을 때 로그 기록
471
        /// </summary>
472
        /// <param name="userID"></param>
473
        /// <param name="userName"></param>
474
        public void DisConnectionMarkus()
475
        {
476
            #region 종료 기록 
477
            try
478
            {
479
                Clients.Caller.DisconnectionMarkus(DisConnectionStamp(Context.ConnectionId));
480
            }
481
            catch (Exception)
482
            {
483

    
484
                throw;
485
            }
486
            #endregion
487
        }
488

    
489
        /// <summary>
490
        /// Force Connection Stamp
491
        /// </summary>
492
        /// <param name="connUser"></param>
493
        /// <returns></returns>
494
        public bool ForceConnectionStamp(MEMBER connUser, string connectionID)
495
        {
496
            #region Force Connection Stamp Method 
497
            try
498
            {
499

    
500

    
501
                using (markusEntities logEnt = new markusEntities(ConnectStringBuilder.MarkusEntitiesConnectionString().ToString()))
502
                {
503

    
504
                    LICENSE_LOG log = new LICENSE_LOG()
505
                    {
506
                        USER_ID = connUser.ID,
507
                        USER_NAME = connUser.NAME,
508
                        CONNECTION_ID = connectionID,
509
                        EVENT_TIME = DateTime.Now,
510
                        STATUS = (connUser.ISLICENSE == (int)LICENSE_TYPE.INACTIVE) ? (int)MARKUS_CONNECTION_TYPE.REJECT : (int)MARKUS_CONNECTION_TYPE.PROCESSING, // ** 2 인 경우는 "거부" 로 표시 
511
                        DESCRIPTION = (connUser.ISLICENSE == (int)LICENSE_TYPE.ACTIVE) ? _COMMENT.forceConnection : _COMMENT.reject // ** 
512
                    };
513

    
514
                    logEnt.LICENSE_LOG.AddObject(log);
515
                    logEnt.SaveChanges();
516

    
517
                    return (connUser.ISLICENSE == (int)LICENSE_TYPE.ACTIVE) ? true : false;
518

    
519
                }
520

    
521
            }
522
            catch (Exception)
523
            {
524
                throw;
525
            }
526
            #endregion
527
        }
528

    
529
        /// <summary>
530
        /// Connection Stamp
531
        /// </summary>
532
        /// <param name="connUser"></param>
533
        /// <param name="connectionID"></param>
534
        /// <returns></returns>
535
        public int ConnectionStamp(MEMBER connUser, string connectionID)
536
        {
537
            #region Connection Stamp Method 
538
            try
539
            {
540
                using (markusEntities ent = new markusEntities(ConnectStringBuilder.MarkusEntitiesConnectionString().ToString()))
541
                {
542
                    DateTime filDate = DateTime.Now.AddMonths(-1);
543

    
544
                    var currentLog = ent.LICENSE_LOG
545
                        .Where(fil => fil.USER_ID == connUser.ID && fil.USER_NAME == connUser.NAME && fil.EVENT_TIME > filDate)
546
                        .OrderByDescending(order => order.EVENT_TIME)
547
                        .FirstOrDefault();
548

    
549
                    if (currentLog != null)
550
                    {
551
                        if (currentLog.STATUS == (int)MARKUS_CONNECTION_TYPE.PROCESSING)
552
                        {
553
                            return -1;
554
                        }
555
                        else
556
                        {
557
                            LICENSE_LOG log = new LICENSE_LOG()
558
                            {
559
                                USER_ID = connUser.ID,
560
                                USER_NAME = connUser.NAME,
561
                                CONNECTION_ID = connectionID,
562
                                EVENT_TIME = DateTime.Now,
563
                                STATUS = (connUser.ISLICENSE == (int)LICENSE_TYPE.INACTIVE) ? (int)MARKUS_CONNECTION_TYPE.REJECT : (int)MARKUS_CONNECTION_TYPE.PROCESSING, // ** 2 인 경우는 "거부" 로 표시 
564
                                DESCRIPTION = (connUser.ISLICENSE == (int)LICENSE_TYPE.ACTIVE) ? null : _COMMENT.reject // ** 
565
                            };
566

    
567
                            ent.LICENSE_LOG.AddObject(log);
568
                            ent.SaveChanges();
569

    
570
                            return log.STATUS;
571
                        }
572
                    }
573
                    else
574
                    {
575

    
576
                        LICENSE_LOG log = new LICENSE_LOG()
577
                        {
578
                            USER_ID = connUser.ID,
579
                            USER_NAME = connUser.NAME,
580
                            CONNECTION_ID = connectionID,
581
                            EVENT_TIME = DateTime.Now,
582
                            STATUS = (connUser.ISLICENSE == (int)LICENSE_TYPE.INACTIVE) ? (int)MARKUS_CONNECTION_TYPE.REJECT : (int)MARKUS_CONNECTION_TYPE.PROCESSING, // ** 2 인 경우는 "거부" 로 표시 
583
                            DESCRIPTION = (connUser.ISLICENSE == (int)LICENSE_TYPE.ACTIVE) ? null : _COMMENT.reject // ** 
584
                        };
585

    
586
                        ent.LICENSE_LOG.AddObject(log);
587
                        ent.SaveChanges();
588

    
589
                        return log.STATUS;
590

    
591
                    }
592
                }
593
            }
594
            catch (Exception)
595
            {
596
                return 500;
597
            }
598
            #endregion
599
        }
600

    
601
        /// <summary>
602
        /// Disconnection Stamp
603
        /// </summary>
604
        /// <param name="connectionID"></param>
605
        /// <returns></returns>
606
        public bool DisConnectionStamp(string connectionID)
607
        {
608
            #region DisConnection Stamp Method 
609
            try
610
            {
611
                using (markusEntities ent = new markusEntities(ConnectStringBuilder.MarkusEntitiesConnectionString().ToString()))
612
                {
613

    
614
                    LICENSE_LOG disconnectionUSER = ent.LICENSE_LOG
615
                        .Where(log => log.CONNECTION_ID == connectionID)
616
                        .OrderByDescending(order => order.EVENT_TIME)
617
                        .FirstOrDefault();
618

    
619
                    if (disconnectionUSER != null)
620
                    {
621

    
622
                        if (disconnectionUSER.STATUS == (int)MARKUS_CONNECTION_TYPE.PROCESSING || disconnectionUSER.STATUS == (int)MARKUS_CONNECTION_TYPE.REJECT)
623
                        {
624

    
625
                            LICENSE_LOG disConnUser = new LICENSE_LOG()
626
                            {
627
                                USER_ID = disconnectionUSER.USER_ID,
628
                                USER_NAME = disconnectionUSER.USER_NAME,
629
                                CONNECTION_ID = disconnectionUSER.CONNECTION_ID,
630
                                EVENT_TIME = DateTime.Now,
631
                                STATUS = (int)MARKUS_CONNECTION_TYPE.TERMINATE
632
                            };
633

    
634
                            ent.LICENSE_LOG.AddObject(disConnUser);
635

    
636
                        }
637

    
638
                    }
639
                    else
640
                    {
641

    
642
                        LICENSE_LOG unknownUser = new LICENSE_LOG()
643
                        {
644
                            USER_NAME = "Unknown user",
645
                            USER_ID = "Unknown id",
646
                            CONNECTION_ID = connectionID,
647
                            EVENT_TIME = DateTime.Now,
648
                            STATUS = (int)MARKUS_CONNECTION_TYPE.REJECT
649
                        };
650

    
651
                        ent.LICENSE_LOG.AddObject(unknownUser);
652

    
653
                    }
654

    
655
                    ent.SaveChanges();
656

    
657
                    return true;
658

    
659
                }
660
            }
661
            catch (Exception ex)
662
            {
663
                return false;
664
                throw ex;
665
            }
666
            #endregion
667
        }
668

    
669
        /// <summary>
670
        /// 예기치 못하게 종료되었을 경우를 대비해 다시 한번 확인하여 로그 기록 
671
        /// </summary>
672
        /// <param name="stopCalled"></param>
673
        /// <returns></returns>
674
        public override Task OnDisconnected(bool stopCalled)
675
        {
676
            #region 종료 기록 ( 강제종료 , 시스템 종료 등 예기치 못한 상태를 대비 ) 
677
            try
678
            {
679

    
680
                if (stopCalled)
681
                {
682
                    Console.WriteLine(String.Format("Client {0} explicitly closed the connection.", Context.ConnectionId));
683
                }
684
                else
685
                {
686
                    Console.WriteLine(String.Format("Client {0} timed out .", Context.ConnectionId));
687
                }
688

    
689
                DisConnectionStamp(Context.ConnectionId);
690

    
691
                return base.OnDisconnected(stopCalled);
692

    
693
            }
694
            catch (Exception ex)
695
            {
696

    
697
                Console.WriteLine(ex.Message);
698
                throw;
699

    
700
            }
701
            #endregion
702
        }
703
        public override Task OnConnected()
704
        {
705
            // Add your own code here.
706
            // For example: in a chat application, record the association between
707
            // the current connection ID and user name, and mark the user as online.
708
            // After the code in this method completes, the client is informed that
709
            // the connection is established; for example, in a JavaScript client,
710
            // the start().done callback is executed.
711
            //Console.WriteLine("Context.ConnectionId " + Context.ConnectionId);
712
            //Console.WriteLine(Context.QueryString["userID"]);
713

    
714
            return base.OnConnected();
715

    
716
        }
717
        public override Task OnReconnected()
718
        {
719

    
720
            // Add your own code here.
721
            // For example: in a chat application, you might have marked the
722
            // user as offline after a period of inactivity; in that case 
723
            // mark the user as online again.
724
            return base.OnReconnected();
725

    
726
        }
727

    
728
        #endregion
729
    }
730
}
클립보드 이미지 추가 (최대 크기: 500 MB)