AlarmMessageInfo.m 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. //
  2. // AlarmMessageInfo.m
  3. // FunSDKDemo
  4. //
  5. // Created by wujiangbo on 2018/12/1.
  6. // Copyright © 2018 wujiangbo. All rights reserved.
  7. //
  8. #import "AlarmMessageInfo.h"
  9. @implementation AlarmMessageInfo
  10. {
  11. NSDictionary *_json;
  12. }
  13. static AlarmMessageInfo* sharedJson = nil;
  14. + (AlarmMessageInfo *)shareInstance
  15. {
  16. @synchronized(self)
  17. {
  18. if (sharedJson == nil) {
  19. sharedJson = [[AlarmMessageInfo alloc]init];
  20. }
  21. return sharedJson;
  22. }
  23. }
  24. - (void)parseJsonData:(NSData*)data
  25. {
  26. NSError *error;
  27. if (data == nil) {
  28. return ;
  29. }
  30. _json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error];
  31. }
  32. - (NSString*)getChannel
  33. {
  34. if (_json == nil) {
  35. return nil;
  36. }
  37. NSDictionary *dictonary = [_json objectForKey:@"AlarmInfo"];
  38. return [dictonary objectForKey:@"Channel"];
  39. }
  40. - (NSString*)getEvent
  41. {
  42. if (_json == nil) {
  43. return nil;
  44. }
  45. NSDictionary *dictonary = [_json objectForKey:@"AlarmInfo"];
  46. const char * a =[[dictonary objectForKey:@"Event"] UTF8String];
  47. return [NSString stringWithUTF8String:a];
  48. }
  49. - (NSString*)getExtInfo
  50. {
  51. if (_json == nil) return nil;
  52. NSDictionary *dictonary = [_json objectForKey:@"AlarmInfo"];
  53. NSString *extInfo = [dictonary objectForKey:@"ExtInfo"];
  54. if (extInfo.length > 0) {
  55. NSArray *infos = [extInfo componentsSeparatedByString:@","];
  56. if (infos.count >=3) {
  57. return infos[2];
  58. }
  59. }
  60. return extInfo;
  61. }
  62. - (NSString *)getPushMSG{
  63. if (_json == nil) return nil;
  64. NSDictionary *dictonary = [_json objectForKey:@"AlarmInfo"];
  65. NSDictionary *extInfo = [dictonary objectForKey:@"ExtInfo"];
  66. if (extInfo) {
  67. return [extInfo objectForKey:@"Msg"];
  68. }
  69. return @"Unknow message";
  70. }
  71. - (NSString*)getStartTime
  72. {
  73. if (_json == nil) {
  74. return nil;
  75. }
  76. NSDictionary *dictonary = [_json objectForKey:@"AlarmInfo"];
  77. return [dictonary objectForKey:@"StartTime"];
  78. }
  79. - (NSString*)getStatus
  80. {
  81. if (_json == nil) {
  82. return nil;
  83. }
  84. NSDictionary *dictonary = [_json objectForKey:@"AlarmInfo"];
  85. const char * a =[[dictonary objectForKey:@"Status"] UTF8String];
  86. return TS(a);
  87. }
  88. - (NSString*)getPicSize{
  89. if (_json == nil) {
  90. return 0;
  91. }
  92. return [_json objectForKey:@"picSize"];
  93. }
  94. - (NSString*)getuId
  95. {
  96. if (_json == nil) {
  97. return nil;
  98. }
  99. return [_json objectForKey:@"ID"];
  100. }
  101. - (NSString*)getSessionID
  102. {
  103. if (_json == nil) {
  104. return nil;
  105. }
  106. return [_json objectForKey:@"SessionID"];
  107. }
  108. - (NSString*)getName
  109. {
  110. if (_json == nil) {
  111. return nil;
  112. }
  113. return [_json objectForKey:@"Name"];
  114. }
  115. - (NSDictionary *)getDicinfoSelf{
  116. if (_json) {
  117. return _json;
  118. }
  119. return nil;
  120. }
  121. @end