프로젝트

일반

사용자정보

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

markus / MarkusLogview / SignalREngine / MyHub.cs @ 91b2b398

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

1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Threading.Tasks;
5
using System.Web;
6
using Microsoft.AspNet.SignalR;
7
using SignalREngine.Dto;
8
using Microsoft.AspNet.SignalR.Hubs;
9
using MarkusDataModel.DataModel;
10
using MarkusDataModel.Common;
11
using MarkusDataModel.DTOs;
12

    
13
using TableDependency.SqlClient;
14
using TableDependency.EventArgs;
15

    
16
using static ServiceInterface.LogView_Interface;
17
using ServiceInterface;
18
using System.Reflection;
19
using System.Diagnostics;
20
using TableDependency;
21
using IKCOM;
22

    
23
namespace SignalREngine
24
{
25
    [HubName("MarkusHub")]
26
    public class MyHub : Hub
27
    {
28
        #region Real Time Transport Data 
29

    
30
        private ServiceEventLogger _serviceEventLogger;
31

    
32
        public MyHub()
33
        {
34
            _serviceEventLogger = new ServiceEventLogger();
35
        }
36

    
37
        #region Entity Method 
38
        /// <summary>
39
        /// PDF status 가져오기
40
        /// </summary>
41
        /// <returns></returns>
42
        public List<StatusDTO> GetPdfStatus()
43
        {
44

    
45
            using (markusEntities ent = new markusEntities(ConnectStringBuilder.MarkusConnectionString().ToString()))
46
            {
47
                return ent.PROPERTIES
48
                    .Where(p => p.TYPE == "PDFStatus")
49
                    .Select(ret => new StatusDTO()
50
                    {
51
                        ID = ret.ID,
52
                        Property = ret.PROPERTY,
53
                        Type = ret.TYPE,
54
                        Value = ret.VALUE
55
                    }).ToList();
56

    
57
            }
58

    
59
        }
60

    
61
        /// <summary>
62
        /// 프로젝트 리스트 가져오기
63
        /// </summary>
64
        /// <param name="projNo"></param>
65
        /// <param name="pType"></param>
66
        /// <returns></returns>
67
        public IEnumerable<RunProjectsList> ProjectList(string projNo, string pType)
68
        {
69

    
70
            List<RunProjectsList> ConvertProjectList = new List<RunProjectsList>();
71
            GET_PROJECT_TYPE getProjType = new GET_PROJECT_TYPE();
72

    
73
            using (markusEntities entity = new markusEntities(ConnectStringBuilder.MarkusConnectionString().ToString()))
74
            {
75

    
76
                // 실행 프로젝트에 대해서 가져옴 ( IsActivity 가 1 인 프로젝트 ) 
77
                var runProject = entity
78
                .RUN_PROJECTS
79
                .Where(run => run.IS_ACTIVITY.Equals(1) && run.PROJECT_NO == projNo)
80
                .OrderBy(order => order.RUN_DATETIME)
81
                .ToList();
82

    
83
                if (runProject.Count > 0)
84
                {
85

    
86
                    // 프로젝트 리스트 불러오기 
87
                    var projectList = runProject.Select(ret => new RunProjectsList()
88
                    {
89
                        ProjectNO = ret.PROJECT_NO,
90
                        ProjectName = ret.PROJECT_NAME,
91
                        RunDateTime = ret.RUN_DATETIME,
92
                        IsActivity = ret.IS_ACTIVITY
93
                    }).ToList();
94

    
95
                    projectList.ForEach(proj =>
96
                    {
97

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

    
118
                        // Status 별로 분류
119
                        statusCount.ToList().ForEach(stat =>
120
                        {
121

    
122
                            switch (stat.Key)
123
                            {
124
                                case (int)PDFStatus.Insert:
125
                                    proj.Insert = stat.Count;
126
                                    break;
127
                                case (int)PDFStatus.Wait:
128
                                    proj.Wait = stat.Count;
129
                                    break;
130
                                case (int)PDFStatus.Crop:
131
                                    proj.Crop = stat.Count;
132
                                    break;
133
                                case (int)PDFStatus.Success:
134
                                    proj.Success = stat.Count;
135
                                    break;
136
                                case (int)PDFStatus.Error:
137
                                    proj.Error = stat.Count;
138
                                    break;
139
                            }
140

    
141
                            proj.Entire += stat.Count;
142

    
143
                        });
144

    
145
                        ConvertProjectList.Add(proj);
146

    
147
                    });
148

    
149
                }
150

    
151
            }
152

    
153
            return ConvertProjectList;
154

    
155
        }
156
        #endregion
157

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

    
172
        #region Convert Broadcast
173
        /// <summary>
174
        /// Insert 
175
        /// </summary>
176
        /// <returns></returns>
177
        public void BroadcastConvertTableInserted(CONVERTER_DOC InsertConvertData)
178
        {
179
            try
180
            {
181
                _serviceEventLogger.WriteEventEntry(MethodBase.GetCurrentMethod().Name, EventLogEntryType.SuccessAudit);
182
                Clients.All.BroadcastConvertTableInserted(InsertConvertData, GetPdfStatus());
183

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

    
217
            try
218
            {
219
                _serviceEventLogger.WriteEventEntry(MethodBase.GetCurrentMethod().Name, EventLogEntryType.SuccessAudit);
220
                Clients.All.BroadcastConvertTableDeleted(deletedConvertData);
221

    
222
            }
223
            catch (Exception ex)
224
            {
225
                _serviceEventLogger.WriteEventEntry(MethodBase.GetCurrentMethod().Name + " : " + ex.Message, EventLogEntryType.Error);
226
                throw;
227
            }
228

    
229
        }
230
        #endregion
231

    
232
        #region Final Broadcast 
233
        /// <summary>
234
        /// Insert
235
        /// </summary>
236
        /// <returns></returns>
237
        public void BroadcastMergeTableInserted(FINAL_PDF InsertData)
238
        {
239

    
240
            try
241
            {
242
                _serviceEventLogger.WriteEventEntry(MethodBase.GetCurrentMethod().Name, EventLogEntryType.SuccessAudit);
243
                Clients.All.BroadcastMergeTableInserted(InsertData, GetPdfStatus());
244
            }
245
            catch (Exception ex)
246
            {
247
                _serviceEventLogger.WriteEventEntry(MethodBase.GetCurrentMethod().Name + " : " + ex.Message, EventLogEntryType.Error);
248
                throw;
249
            }
250

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

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

    
289
        }
290

    
291
        #endregion
292

    
293
        #region hub override method 
294
        // hub disconnected
295
        public override Task OnDisconnected(bool stopCalled)
296
        {
297

    
298
            try
299
            {
300

    
301
                _serviceEventLogger.WriteEventEntry((MethodBase.GetCurrentMethod().Name + ", connection ID :" + Context.ConnectionId), EventLogEntryType.SuccessAudit);
302

    
303
                if (stopCalled)
304
                {
305
                    Console.WriteLine(String.Format("Client {0} explicitly closed the connection.", Context.ConnectionId));
306
                }
307
                else
308
                {
309
                    Console.WriteLine(String.Format("Client {0} timed out .", Context.ConnectionId));
310
                }
311

    
312
                return base.OnDisconnected(stopCalled);
313

    
314
            }
315
            catch (Exception)
316
            {
317
                _serviceEventLogger.WriteEventEntry((MethodBase.GetCurrentMethod().Name + ", connection ID :" + Context.ConnectionId), EventLogEntryType.Error);
318
                throw;
319
            }
320

    
321

    
322
        }
323

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

    
335
                _serviceEventLogger.WriteEventEntry((MethodBase.GetCurrentMethod().Name + ", connection ID :" + Context.ConnectionId), EventLogEntryType.SuccessAudit);
336
                return base.OnConnected();
337

    
338
            }
339
            catch (Exception)
340
            {
341
                _serviceEventLogger.WriteEventEntry((MethodBase.GetCurrentMethod().Name + ", connection ID :" + Context.ConnectionId), EventLogEntryType.Error);
342
                throw;
343
            }
344

    
345
        }
346

    
347
        public override Task OnReconnected()
348
        {
349
            // Add your own code here.
350
            // For example: in a chat application, you might have marked the
351
            // user as offline after a period of inactivity; in that case 
352
            // mark the user as online again.
353
            try
354
            {
355

    
356
                _serviceEventLogger.WriteEventEntry((MethodBase.GetCurrentMethod().Name + ", connection ID :" + Context.ConnectionId), EventLogEntryType.SuccessAudit);
357
                return base.OnReconnected();
358

    
359
            }
360
            catch (Exception)
361
            {
362
                _serviceEventLogger.WriteEventEntry((MethodBase.GetCurrentMethod().Name + ", connection ID :" + Context.ConnectionId), EventLogEntryType.Error);
363
                throw;
364
            }
365

    
366
        }
367
        #endregion
368

    
369
        #endregion
370
    }
371

    
372
    [HubName("MarkusLicenseHub")]
373
    public class MarkusLicenseHub : Hub
374
    {
375
        LICENSE_COMMENT _COMMENT = new LICENSE_COMMENT();
376

    
377
        #region Markus Usage History Stamp
378
        /// <summary>
379
        /// Markus 공지사항 전달 
380
        /// </summary>
381
        /// <param name="msg"></param>
382
        public void MarkusNotification(string msg)
383
        {
384
            Clients.All.MarkusNotification(msg);
385
        }
386

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

    
399
                MEMBER connectionUser = ent.MEMBER
400
                    .Where(mem => mem.ID == userID && mem.NAME == userName)
401
                    .FirstOrDefault();
402

    
403
                if (connectionUser != null)
404
                {
405

    
406
                    return ConnectionStamp(connectionUser, Context.ConnectionId);
407

    
408
                }
409
                else
410
                {
411
                    return 404;
412
                }
413

    
414
            }
415
            #endregion
416
        }
417

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

    
432
                    var lastConnectionLog = ent.LICENSE_LOG
433
                        .Where(fil => fil.USER_ID == userID && fil.USER_NAME == userName && fil.STATUS == (int)MARKUS_CONNECTION_TYPE.PROCESSING)
434
                        .OrderByDescending(order => order.EVENT_TIME)
435
                        .FirstOrDefault();
436

    
437
                    if (lastConnectionLog != null)
438
                    {
439

    
440
                        //using (CloudMarkusCIEntities entity = new CloudMarkusCIEntities(ConnectStringBuilder.ProjectCIConnectString("000000").ToString()))
441
                        //{
442

    
443
                        //    MEMBER connectionUser = entity.MEMBER
444
                        //        .Where(mem => mem.ID == userID && mem.NAME == userName)
445
                        //        .FirstOrDefault();
446

    
447
                        //    if (connectionUser != null)
448
                        //    {
449

    
450
                        //        ForceConnectionStamp(connectionUser, Context.ConnectionId);
451

    
452
                        //        Clients.Client(lastConnectionLog.CONNECTION_ID).ForceTerminate(true);
453

    
454
                       return true;
455

    
456
                        //    }
457
                        //    else
458
                        //    {
459
                        //        return false;
460
                        //    }
461

    
462
                        //}
463

    
464
                    }
465
                    else
466
                    {
467
                        return false;
468
                    }
469

    
470
                }
471
            }
472
            catch (Exception)
473
            {
474
                throw;
475
            }
476
            #endregion
477
        }
478

    
479
        /// <summary>
480
        /// 프로그램을 정상적으로 종료하였을 때 로그 기록
481
        /// </summary>
482
        /// <param name="userID"></param>
483
        /// <param name="userName"></param>
484
        public void DisConnectionMarkus()
485
        {
486
            #region 종료 기록 
487
            try
488
            {
489
                Clients.Caller.DisconnectionMarkus(DisConnectionStamp(Context.ConnectionId));
490
            }
491
            catch (Exception)
492
            {
493

    
494
                throw;
495
            }
496
            #endregion
497
        }
498

    
499
        /// <summary>
500
        /// Force Connection Stamp
501
        /// </summary>
502
        /// <param name="connUser"></param>
503
        /// <returns></returns>
504
        public bool ForceConnectionStamp(MEMBER connUser, string connectionID)
505
        {
506
            #region Force Connection Stamp Method 
507
            try
508
            {
509
                
510

    
511
                using (markusEntities logEnt = new markusEntities(ConnectStringBuilder.MarkusConnectionString().ToString()))
512
                {
513

    
514
                    LICENSE_LOG log = new LICENSE_LOG()
515
                    {
516
                        USER_ID = connUser.ID,
517
                        USER_NAME = connUser.NAME,
518
                        CONNECTION_ID = connectionID,
519
                        EVENT_TIME = DateTime.Now,
520
                        STATUS = (connUser.ISLICENSE == (int)LICENSE_TYPE.INACTIVE) ? (int)MARKUS_CONNECTION_TYPE.REJECT : (int)MARKUS_CONNECTION_TYPE.PROCESSING, // ** 2 인 경우는 "거부" 로 표시 
521
                        DESCRIPTION = (connUser.ISLICENSE == (int)LICENSE_TYPE.ACTIVE) ? _COMMENT.forceConnection : _COMMENT.reject // ** 
522
                    };
523

    
524
                    logEnt.LICENSE_LOG.AddObject(log);
525
                    logEnt.SaveChanges();
526

    
527
                    return (connUser.ISLICENSE == (int)LICENSE_TYPE.ACTIVE) ? true : false;
528

    
529
                }
530

    
531
            }
532
            catch (Exception)
533
            {
534
                throw;
535
            }
536
            #endregion
537
        }
538

    
539
        /// <summary>
540
        /// Connection Stamp
541
        /// </summary>
542
        /// <param name="connUser"></param>
543
        /// <param name="connectionID"></param>
544
        /// <returns></returns>
545
        public int ConnectionStamp(MEMBER connUser, string connectionID)
546
        {
547
            #region Connection Stamp Method 
548
            try
549
            {
550
                using (markusEntities ent = new markusEntities(ConnectStringBuilder.MarkusConnectionString().ToString()))
551
                {
552
                    DateTime filDate = DateTime.Now.AddMonths(-1);
553

    
554
                    var currentLog = ent.LICENSE_LOG
555
                        .Where(fil => fil.USER_ID == connUser.ID && fil.USER_NAME == connUser.NAME && fil.EVENT_TIME > filDate)
556
                        .OrderByDescending(order => order.EVENT_TIME)
557
                        .FirstOrDefault();
558

    
559
                    if (currentLog != null)
560
                    {
561
                        if (currentLog.STATUS == (int)MARKUS_CONNECTION_TYPE.PROCESSING)
562
                        {
563
                            return -1;
564
                        }
565
                        else
566
                        {
567
                            LICENSE_LOG log = new LICENSE_LOG()
568
                            {
569
                                USER_ID = connUser.ID,
570
                                USER_NAME = connUser.NAME,
571
                                CONNECTION_ID = connectionID,
572
                                EVENT_TIME = DateTime.Now,
573
                                STATUS = (connUser.ISLICENSE == (int)LICENSE_TYPE.INACTIVE) ? (int)MARKUS_CONNECTION_TYPE.REJECT : (int)MARKUS_CONNECTION_TYPE.PROCESSING, // ** 2 인 경우는 "거부" 로 표시 
574
                                DESCRIPTION = (connUser.ISLICENSE == (int)LICENSE_TYPE.ACTIVE) ? null : _COMMENT.reject // ** 
575
                            };
576

    
577
                            ent.LICENSE_LOG.AddObject(log);
578
                            ent.SaveChanges();
579

    
580
                            return log.STATUS;
581
                        }
582
                    }
583
                    else
584
                    {
585

    
586
                        LICENSE_LOG log = new LICENSE_LOG()
587
                        {
588
                            USER_ID = connUser.ID,
589
                            USER_NAME = connUser.NAME,
590
                            CONNECTION_ID = connectionID,
591
                            EVENT_TIME = DateTime.Now,
592
                            STATUS = (connUser.ISLICENSE == (int)LICENSE_TYPE.INACTIVE) ? (int)MARKUS_CONNECTION_TYPE.REJECT : (int)MARKUS_CONNECTION_TYPE.PROCESSING, // ** 2 인 경우는 "거부" 로 표시 
593
                            DESCRIPTION = (connUser.ISLICENSE == (int)LICENSE_TYPE.ACTIVE) ? null : _COMMENT.reject // ** 
594
                        };
595

    
596
                        ent.LICENSE_LOG.AddObject(log);
597
                        ent.SaveChanges();
598

    
599
                        return log.STATUS;
600

    
601
                    }
602
                }
603
            }
604
            catch (Exception)
605
            {
606
                return 500;
607
            }
608
            #endregion
609
        }
610

    
611
        /// <summary>
612
        /// Disconnection Stamp
613
        /// </summary>
614
        /// <param name="connectionID"></param>
615
        /// <returns></returns>
616
        public bool DisConnectionStamp(string connectionID)
617
        {
618
            #region DisConnection Stamp Method 
619
            try
620
            {
621
                using (markusEntities ent = new markusEntities(ConnectStringBuilder.MarkusConnectionString().ToString()))
622
                {
623

    
624
                    LICENSE_LOG disconnectionUSER = ent.LICENSE_LOG
625
                        .Where(log => log.CONNECTION_ID == connectionID)
626
                        .OrderByDescending(order => order.EVENT_TIME)
627
                        .FirstOrDefault();
628

    
629
                    if (disconnectionUSER != null)
630
                    {
631

    
632
                        if (disconnectionUSER.STATUS == (int)MARKUS_CONNECTION_TYPE.PROCESSING || disconnectionUSER.STATUS == (int)MARKUS_CONNECTION_TYPE.REJECT)
633
                        {
634

    
635
                            LICENSE_LOG disConnUser = new LICENSE_LOG()
636
                            {
637
                                USER_ID = disconnectionUSER.USER_ID,
638
                                USER_NAME = disconnectionUSER.USER_NAME,
639
                                CONNECTION_ID = disconnectionUSER.CONNECTION_ID,
640
                                EVENT_TIME = DateTime.Now,
641
                                STATUS = (int)MARKUS_CONNECTION_TYPE.TERMINATE
642
                            };
643

    
644
                            ent.LICENSE_LOG.AddObject(disConnUser);
645

    
646
                        }
647

    
648
                    }
649
                    else
650
                    {
651

    
652
                        LICENSE_LOG unknownUser = new LICENSE_LOG()
653
                        {
654
                            USER_NAME = "Unknown user",
655
                            USER_ID = "Unknown id",
656
                            CONNECTION_ID = connectionID,
657
                            EVENT_TIME = DateTime.Now,
658
                            STATUS = (int)MARKUS_CONNECTION_TYPE.TERMINATE
659
                        };
660

    
661
                        ent.LICENSE_LOG.AddObject(unknownUser);
662

    
663
                    }
664

    
665
                    ent.SaveChanges();
666

    
667
                    return true;
668

    
669
                }
670
            }
671
            catch (Exception ex)
672
            {
673
                return false;
674
                throw;
675
            }
676
            #endregion
677
        }
678

    
679
        /// <summary>
680
        /// 예기치 못하게 종료되었을 경우를 대비해 다시 한번 확인하여 로그 기록 
681
        /// </summary>
682
        /// <param name="stopCalled"></param>
683
        /// <returns></returns>
684
        public override Task OnDisconnected(bool stopCalled)
685
        {
686
            #region 종료 기록 ( 강제종료 , 시스템 종료 등 예기치 못한 상태를 대비 ) 
687
            try
688
            {
689

    
690
                if (stopCalled)
691
                {
692
                    Console.WriteLine(String.Format("Client {0} explicitly closed the connection.", Context.ConnectionId));
693
                }
694
                else
695
                {
696
                    Console.WriteLine(String.Format("Client {0} timed out .", Context.ConnectionId));
697
                }
698

    
699
                DisConnectionStamp(Context.ConnectionId);
700

    
701
                return base.OnDisconnected(stopCalled);
702

    
703
            }
704
            catch (Exception ex)
705
            {
706

    
707
                Console.WriteLine(ex.Message);
708
                throw;
709

    
710
            }
711
            #endregion
712
        }
713
        public override Task OnConnected()
714
        {
715
            // Add your own code here.
716
            // For example: in a chat application, record the association between
717
            // the current connection ID and user name, and mark the user as online.
718
            // After the code in this method completes, the client is informed that
719
            // the connection is established; for example, in a JavaScript client,
720
            // the start().done callback is executed.
721
            //Console.WriteLine("Context.ConnectionId " + Context.ConnectionId);
722
            //Console.WriteLine(Context.QueryString["userID"]);
723

    
724
            return base.OnConnected();
725

    
726
        }
727
        public override Task OnReconnected()
728
        {
729

    
730
            // Add your own code here.
731
            // For example: in a chat application, you might have marked the
732
            // user as offline after a period of inactivity; in that case 
733
            // mark the user as online again.
734
            return base.OnReconnected();
735

    
736
        }
737

    
738
        #endregion
739
    }
740

    
741
}
클립보드 이미지 추가 (최대 크기: 500 MB)