| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- //
- // AlarmMessageInfo.m
- // FunSDKDemo
- //
- // Created by wujiangbo on 2018/12/1.
- // Copyright © 2018 wujiangbo. All rights reserved.
- //
- #import "AlarmMessageInfo.h"
- @implementation AlarmMessageInfo
- {
- NSDictionary *_json;
- }
- static AlarmMessageInfo* sharedJson = nil;
- + (AlarmMessageInfo *)shareInstance
- {
- @synchronized(self)
- {
- if (sharedJson == nil) {
- sharedJson = [[AlarmMessageInfo alloc]init];
- }
- return sharedJson;
- }
- }
- - (void)parseJsonData:(NSData*)data
- {
- NSError *error;
- if (data == nil) {
- return ;
- }
- _json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error];
- }
- - (NSString*)getChannel
- {
- if (_json == nil) {
- return nil;
- }
-
- NSDictionary *dictonary = [_json objectForKey:@"AlarmInfo"];
- return [dictonary objectForKey:@"Channel"];
- }
- - (NSString*)getEvent
- {
- if (_json == nil) {
- return nil;
- }
-
- NSDictionary *dictonary = [_json objectForKey:@"AlarmInfo"];
- const char * a =[[dictonary objectForKey:@"Event"] UTF8String];
- return [NSString stringWithUTF8String:a];
- }
- - (NSString*)getExtInfo
- {
- if (_json == nil) return nil;
-
- NSDictionary *dictonary = [_json objectForKey:@"AlarmInfo"];
- NSString *extInfo = [dictonary objectForKey:@"ExtInfo"];
-
- if (extInfo.length > 0) {
- NSArray *infos = [extInfo componentsSeparatedByString:@","];
- if (infos.count >=3) {
- return infos[2];
- }
- }
- return extInfo;
- }
- - (NSString *)getPushMSG{
- if (_json == nil) return nil;
-
- NSDictionary *dictonary = [_json objectForKey:@"AlarmInfo"];
- NSDictionary *extInfo = [dictonary objectForKey:@"ExtInfo"];
-
- if (extInfo) {
- return [extInfo objectForKey:@"Msg"];
- }
-
- return @"Unknow message";
- }
- - (NSString*)getStartTime
- {
- if (_json == nil) {
- return nil;
- }
-
- NSDictionary *dictonary = [_json objectForKey:@"AlarmInfo"];
- return [dictonary objectForKey:@"StartTime"];
- }
- - (NSString*)getStatus
- {
- if (_json == nil) {
- return nil;
- }
-
- NSDictionary *dictonary = [_json objectForKey:@"AlarmInfo"];
- const char * a =[[dictonary objectForKey:@"Status"] UTF8String];
- return TS(a);
- }
- - (NSString*)getPicSize{
- if (_json == nil) {
- return 0;
- }
- return [_json objectForKey:@"picSize"];
- }
- - (NSString*)getuId
- {
- if (_json == nil) {
- return nil;
- }
- return [_json objectForKey:@"ID"];
- }
- - (NSString*)getSessionID
- {
- if (_json == nil) {
- return nil;
- }
- return [_json objectForKey:@"SessionID"];
- }
- - (NSString*)getName
- {
- if (_json == nil) {
- return nil;
- }
- return [_json objectForKey:@"Name"];
- }
- - (NSDictionary *)getDicinfoSelf{
- if (_json) {
- return _json;
- }
-
- return nil;
- }
- @end
|