...
|
...
|
@@ -232,11 +232,13 @@ static dispatch_queue_t persisting_queue() { |
|
|
self.device.ak = appId;
|
|
|
self.device.ch = channelId;
|
|
|
|
|
|
// 设置device
|
|
|
[self.immediUploadItemDic setObject:self.device.jsonDictionary forKey:JsonKeyDataTypeDevice];
|
|
|
|
|
|
// 设置status
|
|
|
[self.immediUploadItemDic setObject: [[NSMutableArray alloc]initWithObjects:self.currentStatus.jsonDictionary, nil] forKey:JsonKeyDataTypeStatus];
|
|
|
@synchronized(self.immediUploadItemDic) {
|
|
|
// 设置device
|
|
|
[self.immediUploadItemDic setObject:self.device.jsonDictionary forKey:JsonKeyDataTypeDevice];
|
|
|
|
|
|
// 设置status
|
|
|
[self.immediUploadItemDic setObject: [[NSMutableArray alloc]initWithObjects:self.currentStatus.jsonDictionary, nil] forKey:JsonKeyDataTypeStatus];
|
|
|
}
|
|
|
|
|
|
[self startObserverNetworkReachabilityStatus];
|
|
|
|
...
|
...
|
@@ -369,48 +371,54 @@ static dispatch_queue_t persisting_queue() { |
|
|
if (itemData.dataType == YHItemDataTypeEvent) {
|
|
|
YHEvent *event = (YHEvent *)itemData;
|
|
|
if (event) {
|
|
|
[self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypePerfor];
|
|
|
[self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypeErrors];
|
|
|
[self.immediUploadItemDic setObject:[[NSMutableArray alloc]initWithObjects:event.jsonDictionary, nil] forKey:JsonKeyDataTypeEvents];
|
|
|
|
|
|
[[YHNetworkService sharedInstance] uploadLogData:self.immediUploadItemDic completionBlock:^(BOOL success, NSError *error) {
|
|
|
if (success) {
|
|
|
YALog(@"upload immedialite event success.");
|
|
|
} else {
|
|
|
YALog(@"uploadImmedilyWithEvent error = %@", error.localizedDescription);
|
|
|
}
|
|
|
}];
|
|
|
@synchronized(self.immediUploadItemDic) {
|
|
|
[self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypePerfor];
|
|
|
[self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypeErrors];
|
|
|
[self.immediUploadItemDic setObject:[[NSMutableArray alloc]initWithObjects:event.jsonDictionary, nil] forKey:JsonKeyDataTypeEvents];
|
|
|
|
|
|
[[YHNetworkService sharedInstance] uploadLogData:self.immediUploadItemDic completionBlock:^(BOOL success, NSError *error) {
|
|
|
if (success) {
|
|
|
YALog(@"upload immedialite event success.");
|
|
|
} else {
|
|
|
YALog(@"uploadImmedilyWithEvent error = %@", error.localizedDescription);
|
|
|
}
|
|
|
}];
|
|
|
}
|
|
|
}
|
|
|
} else if (itemData.dataType == YHItemDataTypePerformance) {
|
|
|
YHPerformance *perfms = (YHPerformance *)itemData;
|
|
|
perfms.net = self.currentStatus.net;
|
|
|
if (perfms) {
|
|
|
[self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypeEvents];
|
|
|
[self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypeErrors];
|
|
|
[self.immediUploadItemDic setObject:[[NSMutableArray alloc]initWithObjects:perfms.jsonDictionary, nil] forKey:JsonKeyDataTypePerfor];
|
|
|
|
|
|
[[YHNetworkService sharedInstance] uploadLogData:self.immediUploadItemDic completionBlock:^(BOOL success, NSError *error) {
|
|
|
if (success) {
|
|
|
YALog(@"upload immedialite event success.");
|
|
|
} else {
|
|
|
YALog(@"uploadImmedilyWithEvent error = %@", error.localizedDescription);
|
|
|
}
|
|
|
}];
|
|
|
@synchronized(self.immediUploadItemDic) {
|
|
|
[self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypeEvents];
|
|
|
[self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypeErrors];
|
|
|
[self.immediUploadItemDic setObject:[[NSMutableArray alloc]initWithObjects:perfms.jsonDictionary, nil] forKey:JsonKeyDataTypePerfor];
|
|
|
|
|
|
[[YHNetworkService sharedInstance] uploadLogData:self.immediUploadItemDic completionBlock:^(BOOL success, NSError *error) {
|
|
|
if (success) {
|
|
|
YALog(@"upload immedialite event success.");
|
|
|
} else {
|
|
|
YALog(@"uploadImmedilyWithEvent error = %@", error.localizedDescription);
|
|
|
}
|
|
|
}];
|
|
|
}
|
|
|
}
|
|
|
} else if(itemData.dataType == YHItemDataTypeError) {
|
|
|
YHError *error = (YHError *)itemData;
|
|
|
if (error) {
|
|
|
[self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypeEvents];
|
|
|
[self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypePerfor];
|
|
|
[self.immediUploadItemDic setObject:[[NSMutableArray alloc]initWithObjects:error.jsonDictionary, nil] forKey:JsonKeyDataTypeErrors];
|
|
|
|
|
|
[[YHNetworkService sharedInstance] uploadLogData:self.immediUploadItemDic completionBlock:^(BOOL success, NSError *error) {
|
|
|
if (success) {
|
|
|
YALog(@"upload immedialite error success.");
|
|
|
} else {
|
|
|
YALog(@"uploadImmedilyWithError error = %@", error.localizedDescription);
|
|
|
}
|
|
|
}];
|
|
|
@synchronized(self.immediUploadItemDic) {
|
|
|
[self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypeEvents];
|
|
|
[self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypePerfor];
|
|
|
[self.immediUploadItemDic setObject:[[NSMutableArray alloc]initWithObjects:error.jsonDictionary, nil] forKey:JsonKeyDataTypeErrors];
|
|
|
|
|
|
[[YHNetworkService sharedInstance] uploadLogData:self.immediUploadItemDic completionBlock:^(BOOL success, NSError *error) {
|
|
|
if (success) {
|
|
|
YALog(@"upload immedialite error success.");
|
|
|
} else {
|
|
|
YALog(@"uploadImmedilyWithError error = %@", error.localizedDescription);
|
|
|
}
|
|
|
}];
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
// 不处理非 Event 和 Error 类型的数据
|
...
|
...
|
@@ -568,15 +576,17 @@ static dispatch_queue_t persisting_queue() { |
|
|
// 更新立即上传信息
|
|
|
- (void)updateImmediUploadDic
|
|
|
{
|
|
|
NSMutableArray *allStatus = [self.immediUploadItemDic objectForKey:JsonKeyDataTypeStatus];
|
|
|
if ([allStatus count]) {
|
|
|
[allStatus replaceObjectAtIndex:0 withObject:self.currentStatus.jsonDictionary];
|
|
|
[self.immediUploadItemDic setObject:allStatus forKey:JsonKeyDataTypeStatus];
|
|
|
} else {
|
|
|
NSException *exception = [NSException exceptionWithName:NSGenericException
|
|
|
reason:@"appId and sessionId do not be initialized. Please use prepareImmediUploadDic:sessionId:channelId: first."
|
|
|
userInfo:nil];
|
|
|
[exception raise];
|
|
|
@synchronized(self.immediUploadItemDic) {
|
|
|
NSMutableArray *allStatus = [self.immediUploadItemDic objectForKey:JsonKeyDataTypeStatus];
|
|
|
if ([allStatus count]) {
|
|
|
[allStatus replaceObjectAtIndex:0 withObject:self.currentStatus.jsonDictionary];
|
|
|
[self.immediUploadItemDic setObject:allStatus forKey:JsonKeyDataTypeStatus];
|
|
|
} else {
|
|
|
NSException *exception = [NSException exceptionWithName:NSGenericException
|
|
|
reason:@"appId and sessionId do not be initialized. Please use prepareImmediUploadDic:sessionId:channelId: first."
|
|
|
userInfo:nil];
|
|
|
[exception raise];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -606,7 +616,9 @@ static dispatch_queue_t persisting_queue() { |
|
|
collectData = [[NSMutableDictionary alloc]init];
|
|
|
|
|
|
//直接添加 immediUploadDataDic 内容(里面包含 device 信息)
|
|
|
[collectData addEntriesFromDictionary:self.immediUploadItemDic];
|
|
|
@synchronized(self.immediUploadItemDic) {
|
|
|
[collectData addEntriesFromDictionary:self.immediUploadItemDic];
|
|
|
}
|
|
|
|
|
|
//组合event信息
|
|
|
if (event.jsonDictionary) {
|
...
|
...
|
@@ -675,14 +687,16 @@ static dispatch_queue_t persisting_queue() { |
|
|
collectData = [[NSMutableDictionary alloc]init];
|
|
|
|
|
|
//直接添加 immediUploadDataDic 内容(里面包含 device 信息)
|
|
|
[self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypeErrors];
|
|
|
[self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypeEvents];
|
|
|
[collectData addEntriesFromDictionary:self.immediUploadItemDic];
|
|
|
@synchronized(self.immediUploadItemDic) {
|
|
|
[self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypeErrors];
|
|
|
[self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypeEvents];
|
|
|
[collectData addEntriesFromDictionary:self.immediUploadItemDic];
|
|
|
}
|
|
|
|
|
|
//组合performance信息
|
|
|
if (performanceData.jsonDictionary) {
|
|
|
NSMutableArray *events = [[NSMutableArray alloc]initWithObjects:performanceData.jsonDictionary,nil];
|
|
|
// self.allEventsCount = [events count];
|
|
|
|
|
|
[collectData setObject:events forKey:JsonKeyDataTypePerfor];
|
|
|
}
|
|
|
|
...
|
...
|
@@ -708,19 +722,17 @@ static dispatch_queue_t persisting_queue() { |
|
|
oldPerformance = [[NSMutableArray alloc]init];
|
|
|
}
|
|
|
[oldPerformance addObject:performanceData.jsonDictionary];
|
|
|
// self.allEventsCount = [oldPerformance count];
|
|
|
|
|
|
[collectData setObject:oldPerformance forKey:JsonKeyDataTypePerfor];
|
|
|
|
|
|
} else {
|
|
|
NSMutableArray *newPerformance = [[NSMutableArray alloc]initWithObjects:performanceData.jsonDictionary, nil];
|
|
|
// self.allEventsCount = [newEvents count];
|
|
|
|
|
|
[collectData setObject:newPerformance forKey:JsonKeyDataTypePerfor];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return [collectData writeToFile:self.eventFileName atomically:YES];
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
// 将一个错误写入到文件
|
...
|
...
|
@@ -743,7 +755,9 @@ static dispatch_queue_t persisting_queue() { |
|
|
if (!collectData) {
|
|
|
collectData = [[NSMutableDictionary alloc]init];
|
|
|
//直接添加 immediUploadDataDic 内容(里面包含 device 信息)
|
|
|
[collectData addEntriesFromDictionary:self.immediUploadItemDic];
|
|
|
@synchronized(self.immediUploadItemDic) {
|
|
|
[collectData addEntriesFromDictionary:self.immediUploadItemDic];
|
|
|
}
|
|
|
|
|
|
//组合error信息
|
|
|
if (errorData.jsonDictionary) {
|
...
|
...
|
@@ -816,178 +830,160 @@ static dispatch_queue_t persisting_queue() { |
|
|
|
|
|
- (void)writeTempEventArray
|
|
|
{
|
|
|
if ([self.tempEventArray count] > 0) {
|
|
|
NSMutableDictionary *collectData = [[NSMutableDictionary alloc] initWithContentsOfFile:self.eventFileName];
|
|
|
|
|
|
//无本地持久化数据
|
|
|
if (!collectData) {
|
|
|
collectData = [[NSMutableDictionary alloc]init];
|
|
|
|
|
|
//直接添加 immediUploadDataDic 内容(里面包含 device 信息)
|
|
|
[collectData addEntriesFromDictionary:self.immediUploadItemDic];
|
|
|
@synchronized(self.tempEventArray) {
|
|
|
if ([self.tempEventArray count] > 0) {
|
|
|
NSMutableDictionary *collectData = [[NSMutableDictionary alloc] initWithContentsOfFile:self.eventFileName];
|
|
|
|
|
|
//组合event信息
|
|
|
NSMutableArray *eventJsonDicArray = [NSMutableArray array];
|
|
|
if ([self.tempEventArray count] > 0) {
|
|
|
//无本地持久化数据
|
|
|
if (!collectData) {
|
|
|
collectData = [[NSMutableDictionary alloc]init];
|
|
|
|
|
|
//直接添加 immediUploadDataDic 内容(里面包含 device 信息)
|
|
|
@synchronized(self.immediUploadItemDic) {
|
|
|
[collectData addEntriesFromDictionary:self.immediUploadItemDic];
|
|
|
}
|
|
|
|
|
|
//组合event信息
|
|
|
NSMutableArray *eventJsonDicArray = [NSMutableArray array];
|
|
|
for (YHEvent *aEvent in self.tempEventArray) {
|
|
|
if (aEvent.jsonDictionary) {
|
|
|
[eventJsonDicArray addObject:aEvent.jsonDictionary];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@synchronized(self.tempEventArray) {
|
|
|
[self.tempEventArray removeAllObjects];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
self.allEventsCount = [eventJsonDicArray count];
|
|
|
[collectData setObject:eventJsonDicArray forKey:JsonKeyDataTypeEvents];
|
|
|
|
|
|
} else { // 持久化文件不为空
|
|
|
|
|
|
// 检查当前session与本地文件中最近存储的session是否相同
|
|
|
NSMutableArray *status = [collectData objectForKey:JsonKeyDataTypeStatus];
|
|
|
if ([status count]) {
|
|
|
NSMutableDictionary *tempStatus = [status lastObject];
|
|
|
//如果不同则插入新的状态
|
|
|
if (![[tempStatus objectForKey:JsonKeyStatusSID] isEqualToString:self.currentStatus.sid]) {
|
|
|
[status addObject:self.currentStatus.jsonDictionary];
|
|
|
|
|
|
// 更新items中status
|
|
|
[collectData setObject:status forKey:JsonKeyDataTypeStatus];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//组合event信息
|
|
|
if ([collectData.allKeys containsObject:JsonKeyDataTypeEvents]) {
|
|
|
NSMutableArray *oldEvents = [collectData objectForKey:JsonKeyDataTypeEvents];
|
|
|
if (!oldEvents) {
|
|
|
oldEvents = [[NSMutableArray alloc]init];
|
|
|
[self.tempEventArray removeAllObjects];
|
|
|
|
|
|
self.allEventsCount = [eventJsonDicArray count];
|
|
|
[collectData setObject:eventJsonDicArray forKey:JsonKeyDataTypeEvents];
|
|
|
|
|
|
} else { // 持久化文件不为空
|
|
|
|
|
|
// 检查当前session与本地文件中最近存储的session是否相同
|
|
|
NSMutableArray *status = [collectData objectForKey:JsonKeyDataTypeStatus];
|
|
|
if ([status count]) {
|
|
|
NSMutableDictionary *tempStatus = [status lastObject];
|
|
|
//如果不同则插入新的状态
|
|
|
if (![[tempStatus objectForKey:JsonKeyStatusSID] isEqualToString:self.currentStatus.sid]) {
|
|
|
[status addObject:self.currentStatus.jsonDictionary];
|
|
|
|
|
|
// 更新items中status
|
|
|
[collectData setObject:status forKey:JsonKeyDataTypeStatus];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if ([self.tempEventArray count] > 0) {
|
|
|
//组合event信息
|
|
|
if ([collectData.allKeys containsObject:JsonKeyDataTypeEvents]) {
|
|
|
NSMutableArray *oldEvents = [collectData objectForKey:JsonKeyDataTypeEvents];
|
|
|
if (!oldEvents) {
|
|
|
oldEvents = [[NSMutableArray alloc]init];
|
|
|
}
|
|
|
|
|
|
for (YHEvent *aEvent in self.tempEventArray) {
|
|
|
if (aEvent.jsonDictionary) {
|
|
|
[oldEvents addObject:aEvent.jsonDictionary];
|
|
|
}
|
|
|
}
|
|
|
@synchronized(self.tempEventArray) {
|
|
|
[self.tempEventArray removeAllObjects];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
self.allEventsCount = [oldEvents count];
|
|
|
[collectData setObject:oldEvents forKey:JsonKeyDataTypeEvents];
|
|
|
|
|
|
} else {
|
|
|
NSMutableArray *newEvents = [[NSMutableArray alloc]init];
|
|
|
|
|
|
if ([self.tempEventArray count] > 0) {
|
|
|
[self.tempEventArray removeAllObjects];
|
|
|
|
|
|
self.allEventsCount = [oldEvents count];
|
|
|
[collectData setObject:oldEvents forKey:JsonKeyDataTypeEvents];
|
|
|
|
|
|
} else {
|
|
|
NSMutableArray *newEvents = [[NSMutableArray alloc]init];
|
|
|
|
|
|
for (YHEvent *aEvent in self.tempEventArray) {
|
|
|
if (aEvent.jsonDictionary) {
|
|
|
[newEvents addObject:aEvent.jsonDictionary];
|
|
|
}
|
|
|
}
|
|
|
@synchronized(self.tempEventArray) {
|
|
|
[self.tempEventArray removeAllObjects];
|
|
|
}
|
|
|
[self.tempEventArray removeAllObjects];
|
|
|
|
|
|
self.allEventsCount = [newEvents count];
|
|
|
[collectData setObject:newEvents forKey:JsonKeyDataTypeEvents];
|
|
|
}
|
|
|
|
|
|
self.allEventsCount = [newEvents count];
|
|
|
[collectData setObject:newEvents forKey:JsonKeyDataTypeEvents];
|
|
|
}
|
|
|
|
|
|
[collectData writeToFile:self.eventFileName atomically:YES];
|
|
|
}
|
|
|
|
|
|
[collectData writeToFile:self.eventFileName atomically:YES];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- (void)writeTempPerformanceArray
|
|
|
{
|
|
|
if ([self.tempPerformanceArray count] > 0) {
|
|
|
NSMutableDictionary *collectData = [[NSMutableDictionary alloc] initWithContentsOfFile:self.eventFileName];
|
|
|
|
|
|
//无本地持久化数据
|
|
|
if (!collectData) {
|
|
|
collectData = [[NSMutableDictionary alloc]init];
|
|
|
@synchronized(self.tempPerformanceArray) {
|
|
|
if ([self.tempPerformanceArray count] > 0) {
|
|
|
NSMutableDictionary *collectData = [[NSMutableDictionary alloc] initWithContentsOfFile:self.eventFileName];
|
|
|
|
|
|
//直接添加 immediUploadDataDic 内容(里面包含 device 信息)
|
|
|
[collectData addEntriesFromDictionary:self.immediUploadItemDic];
|
|
|
|
|
|
//组合event信息
|
|
|
NSMutableArray *eventJsonDicArray = [NSMutableArray array];
|
|
|
if ([self.tempPerformanceArray count] > 0) {
|
|
|
//无本地持久化数据
|
|
|
if (!collectData) {
|
|
|
collectData = [[NSMutableDictionary alloc]init];
|
|
|
|
|
|
//直接添加 immediUploadDataDic 内容(里面包含 device 信息)
|
|
|
@synchronized(self.immediUploadItemDic) {
|
|
|
[collectData addEntriesFromDictionary:self.immediUploadItemDic];
|
|
|
}
|
|
|
|
|
|
//组合event信息
|
|
|
NSMutableArray *eventJsonDicArray = [NSMutableArray array];
|
|
|
for (YHPerformance *aEvent in self.tempPerformanceArray) {
|
|
|
if (aEvent.jsonDictionary) {
|
|
|
[eventJsonDicArray addObject:aEvent.jsonDictionary];
|
|
|
}
|
|
|
}
|
|
|
@synchronized(self.tempPerformanceArray){
|
|
|
[self.tempPerformanceArray removeAllObjects];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// self.allEventsCount = [eventJsonDicArray count];
|
|
|
[collectData setObject:eventJsonDicArray forKey:JsonKeyDataTypePerfor];
|
|
|
|
|
|
} else { // 持久化文件不为空
|
|
|
|
|
|
// 检查当前session与本地文件中最近存储的session是否相同
|
|
|
NSMutableArray *status = [collectData objectForKey:JsonKeyDataTypeStatus];
|
|
|
if ([status count]) {
|
|
|
NSMutableDictionary *tempStatus = [status lastObject];
|
|
|
//如果不同则插入新的状态
|
|
|
if (![[tempStatus objectForKey:JsonKeyStatusSID] isEqualToString:self.currentStatus.sid]) {
|
|
|
[status addObject:self.currentStatus.jsonDictionary];
|
|
|
|
|
|
// 更新items中status
|
|
|
[collectData setObject:status forKey:JsonKeyDataTypeStatus];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//组合performance信息
|
|
|
if ([collectData.allKeys containsObject:JsonKeyDataTypePerfor]) {
|
|
|
NSMutableArray *oldEvents = [collectData objectForKey:JsonKeyDataTypeEvents];
|
|
|
if (!oldEvents) {
|
|
|
oldEvents = [[NSMutableArray alloc]init];
|
|
|
|
|
|
[self.tempPerformanceArray removeAllObjects];
|
|
|
|
|
|
[collectData setObject:eventJsonDicArray forKey:JsonKeyDataTypePerfor];
|
|
|
|
|
|
} else { // 持久化文件不为空
|
|
|
|
|
|
// 检查当前session与本地文件中最近存储的session是否相同
|
|
|
NSMutableArray *status = [collectData objectForKey:JsonKeyDataTypeStatus];
|
|
|
if ([status count]) {
|
|
|
NSMutableDictionary *tempStatus = [status lastObject];
|
|
|
//如果不同则插入新的状态
|
|
|
if (![[tempStatus objectForKey:JsonKeyStatusSID] isEqualToString:self.currentStatus.sid]) {
|
|
|
[status addObject:self.currentStatus.jsonDictionary];
|
|
|
|
|
|
// 更新items中status
|
|
|
[collectData setObject:status forKey:JsonKeyDataTypeStatus];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if ([self.tempPerformanceArray count] > 0) {
|
|
|
//组合performance信息
|
|
|
if ([collectData.allKeys containsObject:JsonKeyDataTypePerfor]) {
|
|
|
NSMutableArray *oldEvents = [collectData objectForKey:JsonKeyDataTypeEvents];
|
|
|
if (!oldEvents) {
|
|
|
oldEvents = [[NSMutableArray alloc]init];
|
|
|
}
|
|
|
|
|
|
for (YHPerformance *aEvent in self.tempPerformanceArray) {
|
|
|
if (aEvent.jsonDictionary) {
|
|
|
[oldEvents addObject:aEvent.jsonDictionary];
|
|
|
}
|
|
|
}
|
|
|
@synchronized(self.tempPerformanceArray){
|
|
|
[self.tempPerformanceArray removeAllObjects];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// self.allEventsCount = [oldEvents count];
|
|
|
[collectData setObject:oldEvents forKey:JsonKeyDataTypePerfor];
|
|
|
|
|
|
} else {
|
|
|
NSMutableArray *newEvents = [[NSMutableArray alloc]init];
|
|
|
|
|
|
if ([self.tempPerformanceArray count] > 0) {
|
|
|
[self.tempPerformanceArray removeAllObjects];
|
|
|
|
|
|
[collectData setObject:oldEvents forKey:JsonKeyDataTypePerfor];
|
|
|
|
|
|
} else {
|
|
|
NSMutableArray *newEvents = [[NSMutableArray alloc]init];
|
|
|
|
|
|
for (YHPerformance *aEvent in self.tempPerformanceArray) {
|
|
|
if (aEvent.jsonDictionary) {
|
|
|
[newEvents addObject:aEvent.jsonDictionary];
|
|
|
}
|
|
|
}
|
|
|
@synchronized(self.tempPerformanceArray){
|
|
|
[self.tempPerformanceArray removeAllObjects];
|
|
|
}
|
|
|
[self.tempPerformanceArray removeAllObjects];
|
|
|
|
|
|
self.allEventsCount = [newEvents count];
|
|
|
[collectData setObject:newEvents forKey:JsonKeyDataTypePerfor];
|
|
|
}
|
|
|
|
|
|
self.allEventsCount = [newEvents count];
|
|
|
[collectData setObject:newEvents forKey:JsonKeyDataTypePerfor];
|
|
|
}
|
|
|
|
|
|
[collectData writeToFile:self.eventFileName atomically:YES];
|
|
|
}
|
|
|
|
|
|
[collectData writeToFile:self.eventFileName atomically:YES];
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#pragma mark - CLLocationManagerDelegate
|
...
|
...
|
|