// 该类负责发送2G/3G Http请求的数据
#import <Foundation/Foundation.h>
#import "ASIHTTPRequest.h"
#import "ASINetworkQueue.h"
#import "ASIDownloadCache.h"
#import "ASIFormDataRequest.h"
#import <SystemConfiguration/CaptiveNetwork.h>
#import "DeviceInfo.h"
@protocolDataRequestManagerDelegate;
//开关状态
#define openCommd @"FE000011010002FFFF1001FFFF2001FFFF3001FFFF"
#define closeCommd @"FE000011010001FFFF1001FFFF2001FFFF3001FFFF"
#define DataBaseURL @"http://yun.lierda.com/usvc/"
//对应的操作
typedefenum
{
DataRequestStart = 0,
SecurityCodeRequest, //验证码
ResignRequest, //注册
LoginRequest, //登陆
AddDeviceRequest, //添加设备
ControlDeviceRequest, //控制设备
QueryDeviceRequest,//查询设备
}DataRequestDataType;
@interface DataRequestManager : NSObject<ASIHTTPRequestDelegate>
@property (nonatomic , assign) id<DataRequestManagerDelegate> delegete;
+ (DataRequestManager *)getInstance;
//1.获取验证码请求接口
- (void)postSecurityCodeWithRequest;
//2.注册接口
- (void)resignWithRequest;
//3.登陆接口
- (void)loginWithRequest;
//4.添加设备
- (void)addDeviceWithRequest:(DeviceInfo *)devInfo;
//5.控制设备
- (void)managerDeviceWithRequest:(NSMutableArray *)devInfoArray isOpen:(BOOL)isopen;
//4.查询设备
- (void)queryDeviceWithInfo:(DeviceInfo *)devInfo;
@end
@protocol DataRequestManagerDelegate <NSObject>
@optional
//发送http数据后的回调
-(void)DataRequestManager:(DataRequestManager *)dataManager receiveData:(NSDictionary *)resultDic errorType:(DataRequestDataType)type;
//发送数据失败
-(void)DataRequestManager:(DataRequestManager *)dataManager receiveData:(NSDictionary *)resultDic successType:(DataRequestDataType)type;
@end
//
// DataRequestManager.m
// SmartHomeWIFI
//
// Created by showsoft_004 on 14-2-27.
// Copyright (c) 2014年 huhuaxiang. All rights reserved.
//
//3G状态获取网络数据
#import "DataRequestManager.h"
#import "SBJson.h"
#import "NetworkTools.h"
#import "UserInfo.h"
#import "UserDataManager.h"
#import "DeviceDataManager.h"
#import "ByteUnit.h"
#define SNKey @"SN"
#define CIDKey @"CID"
#define SIDKey @"SID"
#define captchaPart1Key @"captchaPart1"
#define captchaPart2Key @"captchaPart2"
static DataRequestManager * instance = nil;
@interface DataRequestManager ()
{
ASIHTTPRequest *ordinaryRequest;//基本请求
ASINetworkQueue *requestQueue;
ASIFormDataRequest *requestOfPost;//表单提交
DataRequestDataType currRequestType;
NSMutableDictionary *networkDatas;
UserInfo *regexUserData;
int requestErrorNum;//每次请求的错误数
DeviceInfo *tempDevInfo;
NSMutableArray *controlDeviceArray;
BOOL sendControlDevState;
}
@end
@implementation DataRequestManager
@synthesize delegete;
- (id)init{
self = [super init];
if (self) {
requestQueue = [[ASINetworkQueue alloc] init];
[requestQueue setDelegate:self];
[requestQueue setShouldCancelAllRequestsOnFailure:NO];
[requestQueue setShowAccurateProgress:YES];
if ([requestQueue isSuspended]) {
[requestQueue go];
}
requestErrorNum=0;
networkDatas=[[NSMutableDictionary alloc]init];
}
returnself;
}
- (void)dealloc{
[requestQueue cancelAllOperations];
requestQueue = nil ;
if( ordinaryRequest ){
[ordinaryRequest clearDelegatesAndCancel];
self.delegete = nil;
ordinaryRequest = nil ;
}
if( requestOfPost ){
[requestOfPost clearDelegatesAndCancel];
requestOfPost.delegate = nil;
requestOfPost = nil ;
}
}
+ (DataRequestManager *)getInstance
{
@synchronized(self){
if (instance == nil) {
instance = [[DataRequestManager alloc] init];
}
}
return instance;
}
#pragma mark -- Method
- (NSURL*)generateURL:(NSString*)baseURL params:(NSDictionary*)params {
if (params) {
NSMutableArray* pairs = [NSMutableArray array];
for (NSString* key in params.keyEnumerator) {
NSString* value = [params objectForKey:key];
//please free memory if you use Create, add by hejiang
CFStringRef loc_StringRef=CFURLCreateStringByAddingPercentEscapes(
NULL, /* allocator */
(CFStringRef)value,
NULL, /* charactersToLeaveUnescaped */
(CFStringRef)@"!*'();:@&=+$,/?%#[]",
kCFStringEncodingUTF8);
//NSString* escaped_value = ( NSString *)loc_StringRef;
CFRelease(loc_StringRef);
//escaped_value = nil;//remove warrning escaped_value 作用是什么
[pairs addObject:[NSString stringWithFormat:@"%@=%@", key, value]];
}
NSString* query = [pairs componentsJoinedByString:@"&"];
// query = [query stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
query = [query stringByAddingPercentEscapesUsingEncoding:CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000)];
NSString* url = [NSString stringWithFormat:@"%@?%@", baseURL, query];
NSLog(@"-- url = %@",url);
return [NSURLURLWithString:url];
} else {
return [NSURL URLWithString:baseURL];
}
}
//1.输入验证码
- (void)postSecurityCodeWithRequest
{
//请求参数
NSMutableDictionary *dic=[[NSMutableDictionaryalloc]init];
[dic setObject:[NetworkToolsgetLocalMacAddress] forKey:@"phone"];
[dic setObject:[NSStringstringWithFormat:@"%@@ucot.com",[NetworkToolsgetLocalMacAddress]] forKey:@"email"];
[dic setObject:[NSNumbernumberWithInt:500000] forKey:@"timeout"];
[dic setObject:[NSNumbernumberWithInt:0] forKey:@"SN"];
[dic setObject:[NSNumbernumberWithInt:10031] forKey:@"CID"];
[dic setObject:[NSNumbernumberWithInt:1212611785] forKey:@"SID"];
[dic setObject:@"CaptchaReq"forKey:@"NM"];
NSString *json = [selfchangObjectToJsonString:dic];
NSMutableDictionary *params = [NSMutableDictionarydictionaryWithObjectsAndKeys:
json , @"debug",
nil];
// NSString *string = [NSString stringWithFormat:@"%@%@" , DataBaseURL , @"User_login"];
NSURL *url = [self generateURL:DataBaseURL params: params ];
//发送请求
ordinaryRequest = [ASIHTTPRequestrequestWithURL:url];
[ordinaryRequestsetDelegate:self];
ordinaryRequest.timeOutSeconds = 20;
ordinaryRequest.numberOfTimesToRetryOnTimeout = 20;
[ordinaryRequestsetDefaultResponseEncoding:NSUTF8StringEncoding];
[ordinaryRequeststartAsynchronous];
currRequestType=SecurityCodeRequest;
}
//2.注册接口
- (void)resignWithRequest
{
//请求参数
int captchaPart1=[[[networkDatasobjectForKey:[NSNumbernumberWithInt:SecurityCodeRequest]]objectForKey:@"captchaPart1"]integerValue];
int captchaPart2=[[[networkDatasobjectForKey:[NSNumbernumberWithInt:SecurityCodeRequest]]objectForKey:@"captchaPart2"]integerValue];
regexUserData=[[UserInfoalloc]init];
regexUserData.userName=[NSStringstringWithFormat:@"%@@ucot.com",[NetworkToolsgetLocalMacAddress]];
regexUserData.displayName=[NSStringstringWithFormat:@"%@%@",@"shenxianjun",[NetworkToolsgetLocalMacAddress]];
regexUserData.passWord=@"123456";
regexUserData.clientID=@"F0002C0004";
regexUserData.clientMAC=[NetworkToolsgetLocalMacAddress];
regexUserData.clientName=[NetworkToolsgetLocalMacAddress];
regexUserData.CID=10201;
regexUserData.SID=1212611785;
regexUserData.SN=0;
NSMutableDictionary *dic=[[NSMutableDictionaryalloc]init];
// int sn=[[[networkDatas objectForKey:[NSNumber numberWithInt:SecurityCodeRequest]]objectForKey:SNKey]integerValue];
// int CID=10201;//[[[networkDatas objectForKey:[NSNumber numberWithInt:SecurityCodeRequest]]objectForKey:CIDKey]integerValue];
// int SID=[[[networkDatas objectForKey:[NSNumber numberWithInt:SecurityCodeRequest]]objectForKey:SIDKey]integerValue];
[dic setObject:[NSNumbernumberWithInt:regexUserData.SN] forKey:SNKey];
[dic setObject:[NSNumbernumberWithInt:regexUserData.CID] forKey:CIDKey];
[dic setObject:[NSNumbernumberWithInt:regexUserData.SID] forKey:SIDKey];
[dic setObject:[NSString stringWithFormat:@"%d%d",captchaPart1,captchaPart2] forKey:@"captcha"];//验证
[dic setObject:regexUserData.clientIDforKey:@"clientId"];
[dic setObject:[NSNumbernumberWithInt:regexUserData.timeout] forKey:@"timeout"];
[dic setObject:@"UserAddReq"forKey:@"NM"];
//userDic
NSMutableDictionary *userDic=[[NSMutableDictionaryalloc]init];
[userDic setObject:regexUserData.displayNameforKey:@"displayName"];
[userDic setObject:regexUserData.userNameforKey:@"userName"];
[userDic setObject:regexUserData.passWordforKey:@"password"];
[userDic setObject:[NetworkTools getLocalMacAddress] forKey:@"phone"];
[userDic setObject:[NSStringstringWithFormat:@"%@@ucot.com",[NetworkToolsgetLocalMacAddress]] forKey:@"email"];
[userDic setObject:[NSStringstringWithFormat:@"%@%@",[NetworkToolsgetLocalMacAddress],@"345676"] forKey:@"idCard"];
[userDic setObject:@"shenzhen"forKey:@"answer"];
[userDic setObject:@"1" forKey:@"questionId"];
[dic setObject:userDic forKey:@"userInfo"];
NSString *json = [selfchangObjectToJsonString:dic];
NSMutableDictionary *params = [NSMutableDictionarydictionaryWithObjectsAndKeys:
json , @"debug",
nil];
// NSString *string = [NSString stringWithFormat:@"%@%@" , DataBaseURL , @"User_login"];
NSURL *url = [self generateURL:DataBaseURL params: params ];
ordinaryRequest = [ASIHTTPRequestrequestWithURL:url];
[ordinaryRequestsetDelegate:self];
ordinaryRequest.timeOutSeconds = 20;
ordinaryRequest.numberOfTimesToRetryOnTimeout = 20;
[ordinaryRequestsetDefaultResponseEncoding:NSUTF8StringEncoding];
[ordinaryRequeststartAsynchronous];
currRequestType=ResignRequest;
}
//3.登陆接口
- (void)loginWithRequest
{
regexUserData=[[UserDataManagerinstance]currUserInfo];
if(regexUserData.userName.length<1)//用户没有注册
{
[selfpostSecurityCodeWithRequest];//获取验证码用于注册
return;
}
NSMutableDictionary *dic=[[NSMutableDictionaryalloc]init];
[dic setObject:regexUserData.userNameforKey:@"userName"];
[dic setObject:regexUserData.passWordforKey:@"password"];
[dic setObject:regexUserData.clientIDforKey:@"clientId"];
[dic setObject:regexUserData.clientNameforKey:@"clientName"];
[dic setObject:regexUserData.clientMACforKey:@"mac"];
[dic setObject:[NSNumbernumberWithInt:regexUserData.timeout] forKey:@"timeout"];
[dic setObject:regexUserData.clientMACforKey:@"mac"];
[dic setObject:[NSNumbernumberWithInt:10000] forKey:@"agingTime"];
[dic setObject:[NSNumbernumberWithInt:regexUserData.SN] forKey:@"SN"];
[dic setObject:[NSNumbernumberWithInt:10011] forKey:@"CID"];
[dic setObject:[NSNumbernumberWithInt:0] forKey:@"SID"];
[dic setObject:@"loginReq"forKey:@"NM"];
NSString *json = [selfchangObjectToJsonString:dic];
NSMutableDictionary *params = [NSMutableDictionarydictionaryWithObjectsAndKeys:
json , @"debug",
nil];
// NSString *string = [NSString stringWithFormat:@"%@%@" , DataBaseURL , @"User_login"];
NSURL *url = [self generateURL:DataBaseURL params: params ];
ordinaryRequest = [ASIHTTPRequestrequestWithURL:url];
[ordinaryRequestsetDelegate:self];
ordinaryRequest.timeOutSeconds = 20;
ordinaryRequest.numberOfTimesToRetryOnTimeout = 20;
[ordinaryRequestsetDefaultResponseEncoding:NSUTF8StringEncoding];
[ordinaryRequeststartAsynchronous];
currRequestType=LoginRequest;
}
//4.添加设备
-(void)addDeviceWithRequest:(DeviceInfo *)devInfo
{
tempDevInfo=devInfo;
if(!tempDevInfo)return;
NSMutableDictionary *dic=[[NSMutableDictionaryalloc]init];
[dic setObject:[@"ACCF23123456"uppercaseString] forKey:@"mac"];
// [dic setObject:[devInfo.mac uppercaseString] forKey:@"mac"];
[dic setObject:delaultKeyforKey:@"localkey"];
[dic setObject:devInfo.deviceName forKey:@"name"];
[dic setObject:[NSNumbernumberWithBool:YES] forKey:@"needRemoteControl"];
[dic setObject:@"20140101"forKey:@"serialNo"];
[dic setObject:[NSNumbernumberWithInt:1] forKey:@"factoryId"];
[dic setObject:[NSNumbernumberWithInt:1] forKey:@"type"];
[dic setObject:@"1.0.0"forKey:@"hardwareVer"];
[dic setObject:@"1.0.0"forKey:@"softwareVer"];
[dic setObject:delaultKeyforKey:@"tempKey"];
[dic setObject:[NSNumbernumberWithInt:125.313643243] forKey:@"gpsLat"];
[dic setObject:[NSNumbernumberWithInt:43.89833761] forKey:@"gpsLat"];
[dic setObject:@"CN"forKey:@"country"];
[dic setObject:@"SiChuan"forKey:@"state"];
[dic setObject:@"shenzhen"forKey:@"city"];
[dic setObject:@"None"forKey:@"district"];
[dic setObject:@"mylight.jpg"forKey:@"image"];
NSMutableDictionary *dic2=[[NSMutableDictionaryalloc]init];
[dic2 setObject:dic forKey:@"deviceInfo"];
[dic2 setObject:[NSNumbernumberWithInt:regexUserData.timeout] forKey:@"timeout"];
[dic2 setObject:[NSNumbernumberWithInt:0] forKey:@"SN"];
[dic2 setObject:[NSNumbernumberWithInt:30011] forKey:@"CID"];
[dic2 setObject:[NSNumbernumberWithInt:regexUserData.SID] forKey:@"SID"];
[dic2 setObject:@"DeviceAddReq"forKey:@"NM"];
NSString *json = [selfchangObjectToJsonString:dic2];
NSMutableDictionary *params = [NSMutableDictionarydictionaryWithObjectsAndKeys:
json , @"debug",
nil];
// NSString *string = [NSString stringWithFormat:@"%@%@" , DataBaseURL , @"User_login"];
NSURL *url = [self generateURL:DataBaseURL params: params ];
ordinaryRequest = [ASIHTTPRequestrequestWithURL:url];
[ordinaryRequestsetDelegate:self];
ordinaryRequest.timeOutSeconds = 20;
ordinaryRequest.numberOfTimesToRetryOnTimeout = 20;
[ordinaryRequestsetDefaultResponseEncoding:NSUTF8StringEncoding];
[ordinaryRequeststartAsynchronous];
currRequestType=AddDeviceRequest;
}
//5.控制设备
- (void)managerDeviceWithRequest:(NSMutableArray *)devInfoArray isOpen:(BOOL)isopen
{
controlDeviceArray=devInfoArray;
sendControlDevState=isopen;
NSMutableDictionary *dic=[[NSMutableDictionaryalloc]init];
for (DeviceInfo *info in devInfoArray) {
// [dic setObject:isopen?openCommd:closeCommd forKey:[@"ACCF23123456" uppercaseString]];
[dic setObject:isopen?openCommd:closeCommd forKey:[info.mac uppercaseString]];
}
NSMutableDictionary *dic2=[[NSMutableDictionaryalloc]init];
[dic2 setObject:dic forKey:@"input"];
[dic2 setObject:[NSNumbernumberWithInt:regexUserData.timeout] forKey:@"timeout"];
[dic2 setObject:[NSNumbernumberWithInt:0] forKey:@"SN"];
[dic2 setObject:[NSNumbernumberWithInt:20021] forKey:@"CID"];
[dic2 setObject:[NSNumbernumberWithInt:regexUserData.SID] forKey:@"SID"];
[dic2 setObject:@"DeviceGetRep"forKey:@"NM"];
NSString *json = [selfchangObjectToJsonString:dic2];
NSMutableDictionary *params = [NSMutableDictionarydictionaryWithObjectsAndKeys:
json , @"debug",
nil];
// NSString *string = [NSString stringWithFormat:@"%@%@" , DataBaseURL , @"User_login"];
NSURL *url = [self generateURL:DataBaseURL params: params ];
ordinaryRequest = [ASIHTTPRequestrequestWithURL:url];
[ordinaryRequestsetDelegate:self];
ordinaryRequest.timeOutSeconds = 20;
ordinaryRequest.numberOfTimesToRetryOnTimeout = 20;
[ordinaryRequestsetDefaultResponseEncoding:NSUTF8StringEncoding];
[ordinaryRequeststartAsynchronous];
currRequestType=ControlDeviceRequest;
}
//4.查询设备
- (void)queryDeviceWithInfo:(DeviceInfo *)devInfo
{
tempDevInfo=devInfo;
if(!tempDevInfo)return;
//字典一
NSMutableDictionary *dic1 = [[NSMutableDictionaryalloc] init];
[dic1 setObject:@"FD00000102"forKey:@"ACCF23123456"];
// [dic1 setObject:@"FD00000102" forKey:[devInfo.mac uppercaseString]];
//字典二
NSMutableDictionary *dic=[[NSMutableDictionaryalloc]init];
[dic setObject:dic1 forKey:@"input"];
[dic setObject:[NSNumbernumberWithInt:regexUserData.timeout] forKey:@"timeout"];
[dic setObject:[NSNumbernumberWithInt:0] forKey:@"SN"];
[dic setObject:[NSNumbernumberWithInt:20021] forKey:@"CID"];
[dic setObject:[NSNumbernumberWithInt:regexUserData.SID] forKey:@"SID"];
[dic setObject:@"DeviceSetReq"forKey:@"NM"];
NSString *json = [selfchangObjectToJsonString:dic];
NSMutableDictionary *params = [NSMutableDictionarydictionaryWithObjectsAndKeys:json,@"debug", nil];
NSURL *url = [self generateURL:DataBaseURL params:params];
ordinaryRequest = [ASIHTTPRequestrequestWithURL:url];
[ordinaryRequestsetDelegate:self];
ordinaryRequest.timeOutSeconds = 20;
ordinaryRequest.numberOfTimesToRetryOnTimeout = 20;
[ordinaryRequestsetDefaultResponseEncoding:NSUTF8StringEncoding];
[ordinaryRequeststartAsynchronous];
currRequestType=QueryDeviceRequest;
}
//将对象转换成json字符串
- (NSString *)changObjectToJsonString: (id)object{
NSData *tempData = [NSJSONSerialization dataWithJSONObject:object options:0 error:nil];
NSString *jsonString = [[NSStringalloc] initWithData:tempData encoding:NSUTF8StringEncoding];
return jsonString;
}
- (NSString *)URLEncodedString:(NSString *)string
{
NSString *result = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
(CFStringRef)string,
NULL,
CFSTR("!*'();:@&=+$,/?%#[]"),
kCFStringEncodingUTF8));
return result;
}
#pragma mark Request
- (void)request:(ASIHTTPRequest *)request didReceiveData:(NSData *)data
{
SBJsonParser *json=[[SBJsonParseralloc]init];
NSDictionary *dic=[json objectWithData:data];
if(!dic)
{
requestErrorNum++;
if(requestErrorNum==4)//超过3次请求失败
{
if([delegete respondsToSelector:@selector(DataRequestManager:receiveData:errorType:)])
[delegeteDataRequestManager:selfreceiveData:nilerrorType:currRequestType];
return;
}
}else
requestErrorNum=0;
if(currRequestType==SecurityCodeRequest)
{
if([[dic objectForKey:@"result"]integerValue]!=1)//请求失败则重新请求
{
[selfpostSecurityCodeWithRequest];
return;
}
[networkDatassetObject:dic forKey:[NSNumbernumberWithInt:SecurityCodeRequest]];
//注册用户
[selfresignWithRequest];
}
elseif(currRequestType==ResignRequest)//注册
{
if(!dic)//失败
{
[selfresignWithRequest];
return;
}
int result=[[dic objectForKey:@"result"]integerValue];
if(result==1)//成功
{
[[UserDataManagerinstance]insertOrUpdateUserData:regexUserData];
[self loginWithRequest];
}
else if(result==-104)//已经存在
{
[[UserDataManagerinstance]insertOrUpdateUserData:regexUserData];
[self loginWithRequest];//登录
}else if(result==-114)//以成功的方式处理
{
[[UserDataManagerinstance]insertOrUpdateUserData:regexUserData];
[self loginWithRequest];//登录
}
else
{
if([delegete respondsToSelector:@selector(DataRequestManager:receiveData:errorType:)])
[delegeteDataRequestManager:selfreceiveData:dic errorType:currRequestType];
}
}
elseif(currRequestType==LoginRequest)//登录
{
if(!dic)
{
[self loginWithRequest];
return;
}
int result=[[dic objectForKey:@"result"]integerValue];
if(result==1)//成功
{
regexUserData.userID=[[dic objectForKey:@"userId"]integerValue];
regexUserData.SID=[[dic objectForKey:@"SID"]integerValue];
if(delegete&&[delegete respondsToSelector:@selector(DataRequestManager:receiveData:successType:)])
[delegeteDataRequestManager:selfreceiveData:dic successType:currRequestType];
}else
{
if([delegete respondsToSelector:@selector(DataRequestManager:receiveData:errorType:)])
[delegeteDataRequestManager:selfreceiveData:dic errorType:currRequestType];
}
}
elseif(currRequestType==AddDeviceRequest)
{
if(!dic)
{
[selfaddDeviceWithRequest:tempDevInfo];
return;
}
int result=[[dic objectForKey:@"result"]integerValue];
switch (result) {
case -202://设备已经添加
case -15://设备在其他服务器
case 1://成功
{
if([delegete respondsToSelector:@selector(DataRequestManager:receiveData:successType:)])
[delegeteDataRequestManager:selfreceiveData:dic successType:currRequestType];
// [self managerDeviceWithRequest:tempDevInfo isOpen:YES];
}
break;
default:
{
//不管是否添加成功,都执行
if([delegete respondsToSelector:@selector(DataRequestManager:receiveData:successType:)])
[delegeteDataRequestManager:selfreceiveData:dic successType:currRequestType];
// if([delegete respondsToSelector:@selector(DataRequestManager:receiveData:errorType:)])
// [delegete DataRequestManager:self receiveData:dic errorType:currRequestType];
}
break;
}
}
elseif(currRequestType==ControlDeviceRequest)
{
if(!dic)
{
[selfmanagerDeviceWithRequest:controlDeviceArrayisOpen:sendControlDevState];
return;
}
int result=[[dic objectForKey:@"result"]integerValue];
if(result==1)//操作成功
{
if([delegete respondsToSelector:@selector(DataRequestManager:receiveData:successType:)])
[delegeteDataRequestManager:selfreceiveData:dic successType:currRequestType];
}else
{
if([delegete respondsToSelector:@selector(DataRequestManager:receiveData:errorType:)])
[delegeteDataRequestManager:selfreceiveData:dic errorType:currRequestType];
}
}elseif(currRequestType==QueryDeviceRequest)
{
if(!dic)//如果返回失败则再次发送请求
{
[selfqueryDeviceWithInfo:tempDevInfo];
return;
}
int result=[[dic objectForKey:@"result"]integerValue];
if(result==1)//操作成功
{
if([delegete respondsToSelector:@selector(DataRequestManager:receiveData:successType:)])
[delegeteDataRequestManager:selfreceiveData:dic successType:currRequestType];
}else
{
if([delegete respondsToSelector:@selector(DataRequestManager:receiveData:errorType:)])
[delegeteDataRequestManager:selfreceiveData:dic errorType:currRequestType];
}
}
}
//清理普通请求
-(void)clearOrdinaryRequest{
//清除之前,先清除队列之中的请求
// [self clearRequestInQueueWithArray];
if (ordinaryRequest) {
[ordinaryRequestclearDelegatesAndCancel];
ordinaryRequest=nil;
}
}
@end