修改采集工具bug。code review by 小熊
Showing
1 changed file
with
15 additions
and
5 deletions
@@ -346,6 +346,8 @@ static dispatch_queue_t persisting_queue() { | @@ -346,6 +346,8 @@ static dispatch_queue_t persisting_queue() { | ||
346 | if (itemData.dataType == YHItemDataTypeEvent) { | 346 | if (itemData.dataType == YHItemDataTypeEvent) { |
347 | YHEvent *event = (YHEvent *)itemData; | 347 | YHEvent *event = (YHEvent *)itemData; |
348 | if (event) { | 348 | if (event) { |
349 | + [self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypePerfor]; | ||
350 | + [self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypeErrors]; | ||
349 | [self.immediUploadItemDic setObject:[[NSMutableArray alloc]initWithObjects:event.jsonDictionary, nil] forKey:JsonKeyDataTypeEvents]; | 351 | [self.immediUploadItemDic setObject:[[NSMutableArray alloc]initWithObjects:event.jsonDictionary, nil] forKey:JsonKeyDataTypeEvents]; |
350 | 352 | ||
351 | [[YHNetworkService sharedInstance] uploadLogData:self.immediUploadItemDic completionBlock:^(BOOL success, NSError *error) { | 353 | [[YHNetworkService sharedInstance] uploadLogData:self.immediUploadItemDic completionBlock:^(BOOL success, NSError *error) { |
@@ -360,6 +362,8 @@ static dispatch_queue_t persisting_queue() { | @@ -360,6 +362,8 @@ static dispatch_queue_t persisting_queue() { | ||
360 | YHPerformance *perfms = (YHPerformance *)itemData; | 362 | YHPerformance *perfms = (YHPerformance *)itemData; |
361 | perfms.net = self.currentStatus.net; | 363 | perfms.net = self.currentStatus.net; |
362 | if (perfms) { | 364 | if (perfms) { |
365 | + [self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypeEvents]; | ||
366 | + [self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypeErrors]; | ||
363 | [self.immediUploadItemDic setObject:[[NSMutableArray alloc]initWithObjects:perfms.jsonDictionary, nil] forKey:JsonKeyDataTypePerfor]; | 367 | [self.immediUploadItemDic setObject:[[NSMutableArray alloc]initWithObjects:perfms.jsonDictionary, nil] forKey:JsonKeyDataTypePerfor]; |
364 | 368 | ||
365 | [[YHNetworkService sharedInstance] uploadLogData:self.immediUploadItemDic completionBlock:^(BOOL success, NSError *error) { | 369 | [[YHNetworkService sharedInstance] uploadLogData:self.immediUploadItemDic completionBlock:^(BOOL success, NSError *error) { |
@@ -373,6 +377,8 @@ static dispatch_queue_t persisting_queue() { | @@ -373,6 +377,8 @@ static dispatch_queue_t persisting_queue() { | ||
373 | } else if(itemData.dataType == YHItemDataTypeError) { | 377 | } else if(itemData.dataType == YHItemDataTypeError) { |
374 | YHError *error = (YHError *)itemData; | 378 | YHError *error = (YHError *)itemData; |
375 | if (error) { | 379 | if (error) { |
380 | + [self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypeEvents]; | ||
381 | + [self.immediUploadItemDic removeObjectForKey:JsonKeyDataTypePerfor]; | ||
376 | [self.immediUploadItemDic setObject:[[NSMutableArray alloc]initWithObjects:error.jsonDictionary, nil] forKey:JsonKeyDataTypeErrors]; | 382 | [self.immediUploadItemDic setObject:[[NSMutableArray alloc]initWithObjects:error.jsonDictionary, nil] forKey:JsonKeyDataTypeErrors]; |
377 | 383 | ||
378 | [[YHNetworkService sharedInstance] uploadLogData:self.immediUploadItemDic completionBlock:^(BOOL success, NSError *error) { | 384 | [[YHNetworkService sharedInstance] uploadLogData:self.immediUploadItemDic completionBlock:^(BOOL success, NSError *error) { |
@@ -646,7 +652,7 @@ static dispatch_queue_t persisting_queue() { | @@ -646,7 +652,7 @@ static dispatch_queue_t persisting_queue() { | ||
646 | //组合performance信息 | 652 | //组合performance信息 |
647 | if (performanceData.jsonDictionary) { | 653 | if (performanceData.jsonDictionary) { |
648 | NSMutableArray *events = [[NSMutableArray alloc]initWithObjects:performanceData.jsonDictionary,nil]; | 654 | NSMutableArray *events = [[NSMutableArray alloc]initWithObjects:performanceData.jsonDictionary,nil]; |
649 | -// self.allEventsCount = [events count]; | 655 | + // self.allEventsCount = [events count]; |
650 | [collectData setObject:events forKey:JsonKeyDataTypePerfor]; | 656 | [collectData setObject:events forKey:JsonKeyDataTypePerfor]; |
651 | } | 657 | } |
652 | 658 | ||
@@ -672,12 +678,12 @@ static dispatch_queue_t persisting_queue() { | @@ -672,12 +678,12 @@ static dispatch_queue_t persisting_queue() { | ||
672 | oldPerformance = [[NSMutableArray alloc]init]; | 678 | oldPerformance = [[NSMutableArray alloc]init]; |
673 | } | 679 | } |
674 | [oldPerformance addObject:performanceData.jsonDictionary]; | 680 | [oldPerformance addObject:performanceData.jsonDictionary]; |
675 | -// self.allEventsCount = [oldPerformance count]; | 681 | + // self.allEventsCount = [oldPerformance count]; |
676 | [collectData setObject:oldPerformance forKey:JsonKeyDataTypePerfor]; | 682 | [collectData setObject:oldPerformance forKey:JsonKeyDataTypePerfor]; |
677 | 683 | ||
678 | } else { | 684 | } else { |
679 | NSMutableArray *newPerformance = [[NSMutableArray alloc]initWithObjects:performanceData.jsonDictionary, nil]; | 685 | NSMutableArray *newPerformance = [[NSMutableArray alloc]initWithObjects:performanceData.jsonDictionary, nil]; |
680 | -// self.allEventsCount = [newEvents count]; | 686 | + // self.allEventsCount = [newEvents count]; |
681 | [collectData setObject:newPerformance forKey:JsonKeyDataTypePerfor]; | 687 | [collectData setObject:newPerformance forKey:JsonKeyDataTypePerfor]; |
682 | } | 688 | } |
683 | } | 689 | } |
@@ -882,7 +888,7 @@ static dispatch_queue_t persisting_queue() { | @@ -882,7 +888,7 @@ static dispatch_queue_t persisting_queue() { | ||
882 | [self.tempPerformanceArray removeAllObjects]; | 888 | [self.tempPerformanceArray removeAllObjects]; |
883 | } | 889 | } |
884 | 890 | ||
885 | -// self.allEventsCount = [eventJsonDicArray count]; | 891 | + // self.allEventsCount = [eventJsonDicArray count]; |
886 | [collectData setObject:eventJsonDicArray forKey:JsonKeyDataTypePerfor]; | 892 | [collectData setObject:eventJsonDicArray forKey:JsonKeyDataTypePerfor]; |
887 | 893 | ||
888 | } else { // 持久化文件不为空 | 894 | } else { // 持久化文件不为空 |
@@ -916,7 +922,7 @@ static dispatch_queue_t persisting_queue() { | @@ -916,7 +922,7 @@ static dispatch_queue_t persisting_queue() { | ||
916 | [self.tempPerformanceArray removeAllObjects]; | 922 | [self.tempPerformanceArray removeAllObjects]; |
917 | } | 923 | } |
918 | 924 | ||
919 | -// self.allEventsCount = [oldEvents count]; | 925 | + // self.allEventsCount = [oldEvents count]; |
920 | [collectData setObject:oldEvents forKey:JsonKeyDataTypePerfor]; | 926 | [collectData setObject:oldEvents forKey:JsonKeyDataTypePerfor]; |
921 | 927 | ||
922 | } else { | 928 | } else { |
@@ -951,6 +957,10 @@ static dispatch_queue_t persisting_queue() { | @@ -951,6 +957,10 @@ static dispatch_queue_t persisting_queue() { | ||
951 | if ([manager respondsToSelector:@selector(requestAlwaysAuthorization)]) { | 957 | if ([manager respondsToSelector:@selector(requestAlwaysAuthorization)]) { |
952 | [manager requestAlwaysAuthorization]; | 958 | [manager requestAlwaysAuthorization]; |
953 | } | 959 | } |
960 | + | ||
961 | + // if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9) { | ||
962 | + // manager.allowsBackgroundLocationUpdates = YES; | ||
963 | + // } | ||
954 | } | 964 | } |
955 | break; | 965 | break; |
956 | case kCLAuthorizationStatusRestricted: | 966 | case kCLAuthorizationStatusRestricted: |
-
Please register or login to post a comment