Commit 0caeec4a authored by yueming lu's avatar yueming lu

修改枚举

parent 9f93ec88
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
typedef NS_ENUM(int, PhobosDataSendStatus) { typedef NS_ENUM(int, PhobosDataSendStatus) {
PhobosDataSendStatusToBeSend = 1, // 待发送数据 PhobosDataSendStatus_wait = 1, // 待发送数据
PhobosDataSendStatusSending = 2, // 发送中数据 PhobosDataSendStatus_send = 2, // 发送中数据
PhobosDataSendStatusFinish = 3, // 发送完成数据 PhobosDataSendStatus_finish = 3, // 发送完成数据
PhobosDataSendStatusError = 4, // 发送失败数据 PhobosDataSendStatus_error = 4, // 发送失败数据
}; };
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
model.data = [GMPhobosSqulitModel dictionaryToJsonString:data]; model.data = [GMPhobosSqulitModel dictionaryToJsonString:data];
NSTimeInterval time = [[NSDate date] timeIntervalSince1970] * 1000; NSTimeInterval time = [[NSDate date] timeIntervalSince1970] * 1000;
model.messageId = [NSString stringWithFormat:@"%.f*%lld", time, mach_absolute_time()]; model.messageId = [NSString stringWithFormat:@"%.f*%lld", time, mach_absolute_time()];
model.status = PhobosDataSendStatusToBeSend; model.status = PhobosDataSendStatus_wait;
model.phobosType = phobosType; model.phobosType = phobosType;
model.api = urlapi; model.api = urlapi;
model.immediately = status; model.immediately = status;
......
...@@ -82,13 +82,13 @@ static PhobosDataManager *dataManager; ...@@ -82,13 +82,13 @@ static PhobosDataManager *dataManager;
#pragma mark - 方法只用在APP启动的时候 #pragma mark - 方法只用在APP启动的时候
- (void)resetData { - (void)resetData {
/** 将上次没有获取到发送结果的数据的状态修改为发送失败,待下次重新发送 */ /** 将上次没有获取到发送结果的数据的状态修改为发送失败,待下次重新发送 */
NSString *whereStr = [NSString stringWithFormat:@"where status = %d", PhobosDataSendStatusSending]; NSString *whereStr = [NSString stringWithFormat:@"where status = %d", PhobosDataSendStatus_send];
[_squlitManager gm_updateTable:KtableName dicOrModel:@{@"status":@(PhobosDataSendStatusError)} whereFormat:whereStr]; [_squlitManager gm_updateTable:KtableName dicOrModel:@{@"status":@(PhobosDataSendStatus_error)} whereFormat:whereStr];
/** 将发送成功的数据删除 */ /** 将发送成功的数据删除 */
NSString *whereDelet = [NSString stringWithFormat:@"where status = %d", PhobosDataSendStatusFinish]; NSString *whereDelet = [NSString stringWithFormat:@"where status = %d", PhobosDataSendStatus_finish];
[_squlitManager gm_deleteTable:KtableName whereFormat:whereDelet]; [_squlitManager gm_deleteTable:KtableName whereFormat:whereDelet];
/** 设置未发送数据数量 */ /** 设置未发送数据数量 */
NSString *whereCount = [NSString stringWithFormat:@"where status = %d or status = %d", PhobosDataSendStatusToBeSend, PhobosDataSendStatusError]; NSString *whereCount = [NSString stringWithFormat:@"where status = %d or status = %d", PhobosDataSendStatus_wait, PhobosDataSendStatus_error];
_messageCont = [_squlitManager gm_tableItemCount:KtableName whereFormat:whereCount]; _messageCont = [_squlitManager gm_tableItemCount:KtableName whereFormat:whereCount];
} }
...@@ -117,17 +117,17 @@ static PhobosDataManager *dataManager; ...@@ -117,17 +117,17 @@ static PhobosDataManager *dataManager;
#pragma mark - 获取待发送数据并修改状态为“发送” #pragma mark - 获取待发送数据并修改状态为“发送”
- (NSArray *)fetchToBeSendDataEntitiesAndUpdateWithSendStatus { - (NSArray *)fetchToBeSendDataEntitiesAndUpdateWithSendStatus {
NSString *where = [NSString stringWithFormat:@"where status = %d or status = %d", PhobosDataSendStatusToBeSend, PhobosDataSendStatusError]; NSString *where = [NSString stringWithFormat:@"where status = %d or status = %d", PhobosDataSendStatus_wait, PhobosDataSendStatus_error];
/**获取待发送的数据*/ /**获取待发送的数据*/
NSArray *array = [_squlitManager gm_lookupTable:KtableName filterArray:nil objectClass:[GMPhobosSqulitModel class] whereFormat:where]; NSArray *array = [_squlitManager gm_lookupTable:KtableName filterArray:nil objectClass:[GMPhobosSqulitModel class] whereFormat:where];
/**将待发送的数据修改为“发送中”*/ /**将待发送的数据修改为“发送中”*/
[_squlitManager gm_updateTable:KtableName dicOrModel:@{@"status":@(PhobosDataSendStatusSending)} whereFormat:where]; [_squlitManager gm_updateTable:KtableName dicOrModel:@{@"status":@(PhobosDataSendStatus_send)} whereFormat:where];
return array; return array;
} }
#pragma mark - 是否需要发送数据 #pragma mark - 是否需要发送数据
- (void)disposeSendDataWithImmediately:(BOOL)status { - (void)disposeSendDataWithImmediately:(BOOL)status {
NSString *where = [NSString stringWithFormat:@"where status = %d or status = %d", PhobosDataSendStatusToBeSend, PhobosDataSendStatusError]; NSString *where = [NSString stringWithFormat:@"where status = %d or status = %d", PhobosDataSendStatus_wait, PhobosDataSendStatus_error];
_messageCont = [_squlitManager gm_tableItemCount:KtableName whereFormat:where]; _messageCont = [_squlitManager gm_tableItemCount:KtableName whereFormat:where];
if (status || _messageCont >= PhobosShardCount) { if (status || _messageCont >= PhobosShardCount) {
NSArray *array = [self fetchToBeSendDataEntitiesAndUpdateWithSendStatus]; NSArray *array = [self fetchToBeSendDataEntitiesAndUpdateWithSendStatus];
...@@ -158,7 +158,7 @@ static PhobosDataManager *dataManager; ...@@ -158,7 +158,7 @@ static PhobosDataManager *dataManager;
for (GMPhobosSqulitModel *model in entities) { for (GMPhobosSqulitModel *model in entities) {
NSString *whereStr = [NSString stringWithFormat:@"where messageId = '%@'", model.messageId]; NSString *whereStr = [NSString stringWithFormat:@"where messageId = '%@'", model.messageId];
bool status = [_squlitManager gm_updateTable:KtableName bool status = [_squlitManager gm_updateTable:KtableName
dicOrModel: @{@"status":@(PhobosDataSendStatusError)} dicOrModel: @{@"status":@(PhobosDataSendStatus_error)}
whereFormat:whereStr]; whereFormat:whereStr];
NSLog(@"发送失败后修改状态:%d",status); NSLog(@"发送失败后修改状态:%d",status);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment