Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
GMPhobos
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
GMPhobos
Commits
301e3498
Commit
301e3498
authored
Mar 02, 2020
by
井庆林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
处理历史数据
parent
d83551e1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
3 deletions
+38
-3
PhobosDataManager.m
GMPhobos/Classes/PhobosDataManager.m
+38
-3
No files found.
GMPhobos/Classes/PhobosDataManager.m
View file @
301e3498
...
...
@@ -10,6 +10,7 @@
#import "PhobosUtil.h"
#import "PhobosConfig.h"
#import <MJExtension/MJExtension.h>
#import "Phobos.h"
@implementation
PhobosSendModel
...
...
@@ -26,6 +27,32 @@
@implementation
PhobosDataManager
+
(
void
)
initialize
{
static
dispatch_once_t
onceToken
;
dispatch_once
(
&
onceToken
,
^
{
NSMutableArray
*
dataArray
=
[
GMCache
fetchObjectAtDocumentPathWithkey
:
PhobosTempCacheKey
];
NSArray
*
array
=
[
GMCache
fetchObjectAtDocumentPathWithkey
:
PhobosCacheKey
];
if
(
dataArray
)
{
[
dataArray
addObjectsFromArray
:
array
];
}
else
{
dataArray
=
[
NSMutableArray
arrayWithArray
:
array
];
}
if
(
dataArray
.
count
>
0
)
{
[
self
utilSendDataArray
:
dataArray
currentAPI
:
Phobos
.
sharedClient
.
apiHost
success
:^
(
NSInteger
code
)
{
[
GMCache
removeObjectAtDocumentPathWithkey
:
PhobosCacheKey
];
[
GMCache
removeObjectAtDocumentPathWithkey
:
PhobosTempCacheKey
];
}];
}
NSString
*
exposureAPI
=
@""
;
NSArray
*
exposureArray
=
[
GMCache
fetchObjectAtDocumentPathWithkey
:[
PhobosUtil
MD5String
:
exposureAPI
]];
if
(
exposureArray
.
count
>
0
)
{
[
self
utilSendDataArray
:
exposureArray
currentAPI
:
exposureAPI
success
:^
(
NSInteger
code
)
{
[
GMCache
removeObjectAtDocumentPathWithkey
:[
PhobosUtil
MD5String
:
exposureAPI
]];
}];
}
});
}
+
(
NSArray
<
PhobosSendModel
*>
*
)
fetchCache
{
NSArray
*
data
=
[
GMCache
fetchObjectAtDocumentPathWithkey
:
PhobosNewCacheKey
];
NSArray
<
PhobosSendModel
*>
*
sendModelArray
=
[
PhobosSendModel
mj_objectArrayWithKeyValuesArray
:
data
];
...
...
@@ -121,9 +148,7 @@
[
temp
addObject
:
obj
.
data
];
}];
if
(
temp
.
count
>
0
)
{
NSData
*
JSON
=
[
PhobosUtil
encodeJSON
:
temp
];
NSData
*
compressedData
=
[
PhobosUtil
compressData
:
JSON
];
[
PhobosUtil
sendData
:
compressedData
currentAPI
:
api
success
:^
(
NSInteger
code
)
{
[
self
utilSendDataArray
:
temp
currentAPI
:
api
success
:^
(
NSInteger
code
)
{
[
data
enumerateObjectsUsingBlock
:
^
(
PhobosSendModel
*
obj
,
NSUInteger
idx
,
BOOL
*
_Nonnull
stop
)
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
if
(
code
==
200
)
{
...
...
@@ -138,4 +163,14 @@
}];
}
+
(
void
)
utilSendDataArray
:
(
NSArray
*
)
dataArray
currentAPI
:
(
NSString
*
)
currentAPI
success
:
(
SendDataSuccessBlock
)
success
{
NSData
*
JSON
=
[
PhobosUtil
encodeJSON
:
dataArray
];
NSData
*
compressedData
=
[
PhobosUtil
compressData
:
JSON
];
[
PhobosUtil
sendData
:
compressedData
currentAPI
:
currentAPI
success
:^
(
NSInteger
code
)
{
if
(
success
)
{
success
(
code
);
}
}];
}
@end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment