Browse Source

Common 增加新的底层网络请求接口
apex mobile news 换用新的请求方式。

!!! 此为中间版本,无法正常运行 !!!

Ray Zhang 6 years ago
parent
commit
6292f07445

+ 4 - 4
Apex Mobile/Apex Mobile.xcodeproj/project.pbxproj

@@ -1791,7 +1791,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Developer";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 200117;
+				CURRENT_PROJECT_VERSION = 200203;
 				DEVELOPMENT_TEAM = "";
 				ENABLE_BITCODE = YES;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -1807,7 +1807,7 @@
 				HEADER_SEARCH_PATHS = "";
 				INFOPLIST_FILE = "Apex Mobile/Apex Mobile-Info.plist";
 				IPHONEOS_DEPLOYMENT_TARGET = 11.0;
-				MARKETING_VERSION = 2.80;
+				MARKETING_VERSION = 2.81;
 				OTHER_LDFLAGS = "-ObjC";
 				PRODUCT_BUNDLE_IDENTIFIER = "usai.apex.$(PRODUCT_NAME:rfc1034identifier)";
 				PRODUCT_NAME = "$(TARGET_NAME)";
@@ -1830,7 +1830,7 @@
 				CODE_SIGN_IDENTITY = "iPhone Distribution";
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 200117;
+				CURRENT_PROJECT_VERSION = 200203;
 				DEVELOPMENT_TEAM = "";
 				ENABLE_BITCODE = YES;
 				FRAMEWORK_SEARCH_PATHS = (
@@ -1842,7 +1842,7 @@
 				HEADER_SEARCH_PATHS = "";
 				INFOPLIST_FILE = "Apex Mobile/Apex Mobile-Info.plist";
 				IPHONEOS_DEPLOYMENT_TARGET = 11.0;
-				MARKETING_VERSION = 2.80;
+				MARKETING_VERSION = 2.81;
 				OTHER_LDFLAGS = "-ObjC";
 				PRODUCT_BUNDLE_IDENTIFIER = "usai.apex.$(PRODUCT_NAME:rfc1034identifier)";
 				PRODUCT_NAME = "$(TARGET_NAME)";

+ 1 - 0
Apex Mobile/Apex Mobile/NewsData.h

@@ -14,6 +14,7 @@
 @property bool finishload;
 @property (strong,nonatomic) NSString* _id;
 -(void) appenddata : (NSData*) data;
+-(void) append_jsondata : (NSDictionary*) jsobj;
 -(long) get_count;
 -(id)init : (int) limit;
 @end

+ 31 - 0
Apex Mobile/Apex Mobile/NewsData.m

@@ -20,6 +20,37 @@
     }
     return self;
 }
+
+-(void) append_jsondata : (NSDictionary*) jsobj
+{
+//    NSError *error=nil;
+//    NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&error];
+    if(jsobj)
+    {
+        int count =  [[jsobj valueForKey:@"total" ] intValue];
+        if(count<self.limit)
+            self.finishload = true;
+        NSDictionary * objrecords = [jsobj objectForKey:@"records"];
+        for(int i=0;i<count;i++)
+        {
+            NSDictionary* objrec = [objrecords objectForKey:[NSString stringWithFormat:@"record%d",i ]];
+//            NSString* title = [objrec valueForKey:@"title"];
+//            NSString* content  = [objrec valueForKey:@"content"];
+//            NSString* image  = [objrec valueForKey:@"image"];
+//            NSString* _id  = [objrec valueForKey:@"id"];
+//            NSString* url  = [objrec valueForKey:@"url"];
+//
+//            NSMutableDictionary * map = [[NSMutableDictionary alloc] init];
+//            map setValue:title forKey:@"title"
+            self._id =[objrec valueForKey:@"id"];
+            [self.pagedata addObject:objrec];
+            
+        }
+        
+    }
+    
+    
+}
 -(void) appenddata : (NSData*) data
 {
     NSError *error=nil;

+ 50 - 0
Apex Mobile/Apex Mobile/NewsViewController.m

@@ -53,6 +53,56 @@
     //    self.tableview.hidden = true;
     
     //    [UIView commitAnimations];
+    
+    NSData* data=nil;
+    if([self.module_name isEqualToString:@"Announcements"])
+        [RANetwork get_announcements:self.lastid limit:self.limit];
+    else
+        [RANetwork request_marketnews:self.lastid limit:self.limit completionHandler:^(NSMutableDictionary *result) {
+                    dispatch_async(dispatch_get_main_queue(), ^{
+                        self.tableview.hidden =false;
+                        self.mum.hidden = true;
+                        if(result != nil)
+                        {
+                            [self.data append_jsondata: result];
+                            self.lastid = self.data._id;
+                            self.btnrefresh.hidden = false;
+                            if(self.data.finishload==true)
+                            {
+                                
+            //                    int i =self.btnrefresh.state;
+                                self.btnrefresh.titleLabel.text =NSLocalizedString(@"no_more",nil);
+                                //                    [self.btnrefresh setTitle:@"No more" forState:UIControlStateNormal];
+                            }
+                            else
+                            {
+                                self.btnrefresh.enabled = true;
+                                self.btnrefresh.titleLabel.text =NSLocalizedString(@"load_more",nil);
+                                //                    [self.btnrefresh setTitle:@"Load more" forState:UIControlStateNormal];
+                            }
+                            
+                            [self.tableview reloadData ];
+                            if (finish) {
+                                finish(2);
+                            }
+                        }
+                        else
+                        {
+                            self.btnrefresh.enabled = true;
+                            [self.btnrefresh setTitle:@"Load more" forState:UIControlStateNormal];
+                            if (finish) {
+                                finish(0);
+                            }
+                        }
+                        
+                        
+                        
+                        
+                        
+                    });
+        }];
+    
+    return;
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
         
         

+ 4 - 0
Apex Mobile/Apex Mobile/RANetwork.h

@@ -51,4 +51,8 @@
 
 + (NSString *)getDisplayFieldsForFunction:(NSString *)function limit:(NSUInteger)limit;
 
+
+// 新接口逐步替换以前的网络请求,2020
++(void)request_marketnews : (NSString*) id limit: (int) limit completionHandler:(resultHandler)result;
+
 @end

+ 29 - 0
Apex Mobile/Apex Mobile/RANetwork.m

@@ -1716,4 +1716,33 @@
     return [ApexMobileDB getDisplayFieldsForFunction:function withUser:appDelegate.user limit:limit];
 }
 
+
+
+
+#pragma mark new interface
+
++(void)request_marketnews : (NSString*) id limit: (int) limit completionHandler:(resultHandler)result
+{
+    if(![NetworkUtils IsNetworkAvailable])
+        return ;//RESULT_NET_NOTAVAILABLE;
+    
+    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
+    [params setValue:@"Market News" forKey:@"module_name"];
+    [params setValue:@"search" forKey:@"action_type"];
+    [params setValue:id forKey:@"id"];
+    [params setValue:[NSString stringWithFormat:@"%d",limit ] forKey:@"limit"];
+    
+    
+    [self request_interface:URL_ANNOUNCEMENTS parameters:params err_record_url:nil completionHandler:result retry:0];
+//    NSData* json=[self get_json:URL_ANNOUNCEMENTS parameters:params file:nil];
+//    if (json==nil)
+//    {
+//        DebugLog(@"json is wrong");
+//        return ;
+//    }
+    return ;
+    
+    
+    
+}
 @end

+ 15 - 13
Apex Mobile/Apex Mobile/Result/Cell/ApexResultDocumentCell.xib

@@ -1,11 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
-    <device id="retina4_7" orientation="portrait">
-        <adaptation id="fullscreen"/>
-    </device>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+    <device id="retina4_7" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -16,11 +14,11 @@
             <rect key="frame" x="0.0" y="0.0" width="567" height="100"/>
             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
             <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
-                <rect key="frame" x="0.0" y="0.0" width="567" height="99.5"/>
+                <rect key="frame" x="0.0" y="0.0" width="567" height="100"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
                     <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Svu-j8-b5X">
-                        <rect key="frame" x="5" y="15" width="557" height="84.5"/>
+                        <rect key="frame" x="5" y="15" width="557" height="85"/>
                         <subviews>
                             <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="mode_document" translatesAutoresizingMaskIntoConstraints="NO" id="HhT-58-RDI">
                                 <rect key="frame" x="10" y="18" width="48" height="48"/>
@@ -30,25 +28,28 @@
                                 </constraints>
                             </imageView>
                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" text="File:2018" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yj3-N6-PFN">
-                                <rect key="frame" x="66" y="10" width="76" height="20.5"/>
+                                <rect key="frame" x="66" y="10" width="448" height="20.5"/>
                                 <fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
                                 <nil key="textColor"/>
                                 <nil key="highlightedColor"/>
                             </label>
                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="PO#:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Xwz-QR-e6d">
-                                <rect key="frame" x="66" y="35.5" width="486" height="18"/>
+                                <rect key="frame" x="66" y="35.5" width="486" height="18.5"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="15"/>
                                 <color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                 <nil key="highlightedColor"/>
                             </label>
-                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="F/L" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="cse-Lk-XCd">
-                                <rect key="frame" x="528.5" y="10" width="23.5" height="21"/>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="F/L" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="cse-Lk-XCd">
+                                <rect key="frame" x="522" y="10" width="30" height="21"/>
+                                <constraints>
+                                    <constraint firstAttribute="width" constant="30" id="1Kb-OI-L1N"/>
+                                </constraints>
                                 <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                 <nil key="textColor"/>
                                 <nil key="highlightedColor"/>
                             </label>
-                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="BOL:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ms4-My-MJ5">
-                                <rect key="frame" x="66" y="58.5" width="486" height="18"/>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" text="BOL:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ms4-My-MJ5">
+                                <rect key="frame" x="66" y="59" width="486" height="18"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="15"/>
                                 <color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                 <nil key="highlightedColor"/>
@@ -67,6 +68,7 @@
                             <constraint firstItem="Xwz-QR-e6d" firstAttribute="leading" secondItem="yj3-N6-PFN" secondAttribute="leading" id="csQ-or-l7X"/>
                             <constraint firstItem="Ms4-My-MJ5" firstAttribute="leading" secondItem="Xwz-QR-e6d" secondAttribute="leading" id="czd-SF-AdZ"/>
                             <constraint firstItem="HhT-58-RDI" firstAttribute="top" secondItem="Svu-j8-b5X" secondAttribute="top" constant="18" id="hTL-HJ-cvG"/>
+                            <constraint firstItem="cse-Lk-XCd" firstAttribute="leading" secondItem="yj3-N6-PFN" secondAttribute="trailing" constant="8" id="soQ-Y0-pvN"/>
                             <constraint firstItem="Ms4-My-MJ5" firstAttribute="top" secondItem="Xwz-QR-e6d" secondAttribute="bottom" constant="5" id="tlr-Q6-yhp"/>
                             <constraint firstItem="cse-Lk-XCd" firstAttribute="centerY" secondItem="yj3-N6-PFN" secondAttribute="centerY" id="xYq-7t-jSb"/>
                         </constraints>

+ 7 - 1
common/NetworkUtils.h

@@ -19,7 +19,7 @@ typedef void(^progressHandler)(NSURLSessionTask *task,double progress);
 @interface NetworkUtils : NSObject
 +(bool) IsNetworkAvailable;
 +(NSData*)get_json : (NSString*) url parameters:(NSMutableDictionary *) params file:(NSString*)file_path err_recorder:(NSString* )recorder_url result_handler:(resultBlock)resultBlock decrypt_handler:(decryptBlock)decryptBlock;
-+(NSDictionary*)err_log:(NSString*) up_params result:(NSString*)result module:(NSString*) module code:(int) code;
+//+(NSDictionary*)err_log:(NSString*) up_params result:(NSString*)result module:(NSString*) module code:(int) code;
 
 
 + (NSURLSessionTask *)upload:(NSString *)filePath Params:(NSDictionary *)params ToHost:(NSString *)url Result:(resultHandler)r Progress:(progressHandler)p DecryptHandler:(id(^)(NSString *result))decrypt;
@@ -27,4 +27,10 @@ typedef void(^progressHandler)(NSURLSessionTask *task,double progress);
 + (NSURLSessionTask *)upload:(NSData *)filedata  FileName:(NSString*) filename Params:(NSDictionary *)params ToHost:(NSString *)urlString Result:(resultHandler)r Progress:(progressHandler)p DecryptHandler:(id (^)(NSString *))decrypt;
 
 + (NSURLSessionDataTask *)downloadFileOffset:(NSUInteger)offset Param:(NSDictionary *)param from:(NSString *)url method:(NSString *)method toPath:(NSString *)path progressHandler:(progressHandler)progressHandler completionHandler:(resultHandler)result;
+
+
+// 2020 新增网络访问底层接口,取代get_json
+// 普通请求
++(NSData*)request_interface : (NSString*) url parameters:(NSMutableDictionary *) params  err_record_url:(NSString* )recorder_url completionHandler:(resultHandler)result retry:(int) retry;
+
 @end

+ 334 - 0
common/NetworkUtils.m

@@ -286,6 +286,8 @@ repeat:
     //    NSError *error=nil;
     //    NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
     //    return jsobj;
+    
+    // 子类没有处理err_log函数时的默认处理。
     NSMutableDictionary* jsobj = [@{@"result":@"2"} mutableCopy];
     return jsobj;
 }
@@ -551,4 +553,336 @@ repeat:
     
 }
 
+#pragma mark new interface
+
++(NSData*)request_interface : (NSString*) url parameters:(NSMutableDictionary *) params  err_record_url:(NSString* )recorder_url completionHandler:(resultHandler)result retry:(int) retry
+{
+//    __block int retry = 0;
+    
+
+    
+    
+//repeat:
+//    {
+        
+        //    return [self fake_json:url];
+        
+        //    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+        //分界线的标识符
+        NSString *TWITTERFON_FORM_BOUNDARY = @"AaB03x";
+        //根据url初始化request
+        NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]
+                                                               cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
+                                                           timeoutInterval:JSON_TIMEOUT];
+
+        //分界线 --AaB03x
+        NSString *MPboundary=[[NSString alloc]initWithFormat:@"--%@",TWITTERFON_FORM_BOUNDARY];
+        //结束符 AaB03x--
+        NSString *endMPboundary=[[NSString alloc]initWithFormat:@"%@--",MPboundary];
+        //要上传的图片
+        //    UIImage *image=[params objectForKey:@"pic"];
+        //得到图片的data
+        /*
+//            NSData* data = [NSData dataWithContentsOfFile:file_path];
+         
+         */
+        //http body的字符串
+        NSMutableString *body=[[NSMutableString alloc]init];
+        
+        //    NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
+        //     [params setValue:@"handset_login" forKey:@"action"];
+        //    [headers setValue:[NSString stringWithFormat:@"%d",dataLength] forKey:@"Content-Length"];
+        
+        //    [params setValue:appDelegate.sessionid forKey:@"sessionid"];
+        //   [params setValue:password forKey:@"password"];
+        //    [params setValue:[NSString stringWithFormat:@"%d",ver]  forKey:@"auth_ver"];
+        
+        
+        
+        //    [headers setValue:headQuerlString forKey:@"param"];
+        
+        //参数的集合的所有key的集合
+        NSArray *keys= [params allKeys];
+        DebugLog(@"================parms==================");
+        //遍历keys
+        for(int i=0;i<[keys count];i++)
+        {
+            //得到当前key
+            NSString *key=[keys objectAtIndex:i];
+            //如果key不是pic,说明value是字符类型,比如name:Boris
+            if(![key isEqualToString:@"pic"])
+            {
+                //添加分界线,换行
+                [body appendFormat:@"%@\r\n",MPboundary];
+                //添加字段名称,换2行
+                [body appendFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n",key];
+                //添加字段的值
+                [body appendFormat:@"%@\r\n",[params objectForKey:key]];
+                DebugLog(@"parameter: key=%@   value=%@",key,[params objectForKey:key]);
+            }
+        }
+        DebugLog(@"================parms==================");
+        ////添加分界线,换行
+       /* [body appendFormat:@"%@\r\n",MPboundary];
+        
+        
+        //声明pic字段,文件名为boris.png
+        
+        NSString * file_format=[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"upfile\"; filename=\"%@\"\r\n", [file_path lastPathComponent]];
+
+        
+        
+        [body appendFormat:@"%@", file_format];
+        //声明上传文件的格式
+        [body appendFormat:@"Content-Type: application/zip\r\n\r\n"];
+        
+        
+        */
+        //声明结束符:--AaB03x--
+        NSString *end=[[NSString alloc]initWithFormat:@"\r\n%@",endMPboundary];
+        //声明myRequestData,用来放入http body
+        NSMutableData *myRequestData=[NSMutableData data];
+        //将body字符串转化为UTF8格式的二进制
+        [myRequestData appendData:[body dataUsingEncoding:NSUTF8StringEncoding]];
+        
+        
+        /*
+        //将image的data加入
+            [myRequestData appendData:data];
+        
+        */
+        
+        //加入结束符--AaB03x--
+        [myRequestData appendData:[end dataUsingEncoding:NSUTF8StringEncoding]];
+        
+        
+        
+        
+        //设置HTTPHeader中Content-Type的值
+        NSString *content=[[NSString alloc]initWithFormat:@"multipart/form-data; boundary=%@",TWITTERFON_FORM_BOUNDARY];
+        //设置HTTPHeader
+        [request setValue:content forHTTPHeaderField:@"Content-Type"];
+        
+        [request setValue:@"multipart/form-data" forHTTPHeaderField:@"enctype"];
+        
+        // 关闭keep alive
+        [request setValue:@"close" forHTTPHeaderField:@"Connection"];
+        //设置Content-Length
+        [request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)[myRequestData length]] forHTTPHeaderField:@"Content-Length"];
+        //设置http body
+        [request setHTTPBody:myRequestData];
+        //http method
+        [request setHTTPMethod:@"POST"];
+        
+        
+        
+         
+         NSURLSession *urlSession = [self standSession];
+         
+         if (urlSession.delegate) {
+             if ([urlSession.delegate isKindOfClass:[RANetworkTaskDelegate class]]) {
+                 
+                 RANetworkTaskDelegate *delegate = (RANetworkTaskDelegate *)urlSession.delegate;
+                 
+//                 if (p) {
+//                     delegate.p = p;
+//                 }
+//
+                 if (result) {
+                     delegate.r = result;
+                 }
+//
+//                 if (decrypt) {
+//                     delegate.decryptHandler = decrypt;
+//                 }
+                 
+             }
+         }
+         
+        NSURLSessionDataTask *dataTask =[urlSession dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
+            
+                        NSData *responseData =data;
+                        NSHTTPURLResponse* urlResponse =response;
+                        if (responseData==nil) {
+
+                            //            DebugLog(@"response error:%@", [error localizedDescription]);
+
+
+                            NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
+                            //#define RESULT_FALSE 0
+                            //#define RESULT_TRUE         2
+                            //#define RESULT_NET_ERROR             -3
+                            //#define RESULT_NET_NOTAVAILABLE          -4
+                            //#define RESULT_ERROR                 -5
+                            //#define RESULT_LOCALFILE_ERROR             -7
+                            //#define RESULT_USERAUTH_ERROR             -9
+                            //#define RESULT_UPDATE_USERAUTH_ERROR     -11
+                            //#define RESULT_SESSION_EXPIRED              -13
+                            //#define RESULT_VER_LOW
+
+                            //     NSString * moreinfo = error.description ;
+
+                            NSString* err_msg = [error localizedDescription];
+
+
+                            //-----------------retry 3 times for error code -1005------------------------
+                            if(error.code==-1005&&retry<3)
+                            {
+                                int new_retry=retry+1;
+                                [self request_interface:url parameters:params err_record_url:recorder_url completionHandler:result retry:new_retry];
+            //                    retry++;
+            //                    goto repeat;
+
+                            }
+                            //-----------------end retry 3 times for error code -1005------------------------
+
+                            NSDictionary* error_json = [RAUtils error_dict:error];
+                            [ret setObject:error_json forKey:@"err_obj"];
+                            NSString* resp_msg= nil;
+
+                            if(err_msg.length==0)
+                            {
+                                err_msg =[NSHTTPURLResponse localizedStringForStatusCode:urlResponse.statusCode];
+                                resp_msg = err_msg;
+                            }
+                            [ret setValue:[NSString stringWithFormat:@"%d",RESULT_NET_ERROR] forKey:@"result"];
+                            [ret setValue:err_msg forKey:@"err_msg"];
+                            [ret setValue:resp_msg forKey:@"resp_msg"];
+                            [ret setValue:[NSString stringWithFormat:@"%ld",(long)urlResponse.statusCode] forKey:@"resp_code"];
+
+
+                            NSData *jsonData = [NSJSONSerialization dataWithJSONObject:ret
+                                                                               options:0
+                                                                                 error:nil];
+                            if(![url isEqualToString:recorder_url])
+                            {
+                                [self err_log:[RAUtils base64en:[RAConvertor dict2string:params]] result:[RAUtils base64en:[RAConvertor dict2string:ret]] module:url code:RESULT_NET_ERROR];
+                            }
+                            return ;
+
+                        }
+
+                        return ;
+                    
+        }];
+//         NSURLSessionDataTask *dataTask = [urlSession dataTaskWithRequest:request ];
+         
+         [dataTask resume];
+         
+         return nil;
+         
+         
+         
+        
+//
+//
+//        NSHTTPURLResponse* urlResponse = nil;
+//
+//        NSError *error = nil;
+//        NSLog(@"begin request %@",url);
+//
+//        NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
+//
+//
+//        DebugLog(@"url: %@",url);
+//
+//        DebugLog(@"response: %@",[NSHTTPURLResponse localizedStringForStatusCode:urlResponse.statusCode]);
+//
+//
+//        NSLog(@"get response");
+//        if (responseData==nil) {
+//
+//            //            DebugLog(@"response error:%@", [error localizedDescription]);
+//
+//
+//            NSMutableDictionary* ret = [[NSMutableDictionary alloc] init];
+//            //#define RESULT_FALSE 0
+//            //#define RESULT_TRUE         2
+//            //#define RESULT_NET_ERROR             -3
+//            //#define RESULT_NET_NOTAVAILABLE          -4
+//            //#define RESULT_ERROR                 -5
+//            //#define RESULT_LOCALFILE_ERROR             -7
+//            //#define RESULT_USERAUTH_ERROR             -9
+//            //#define RESULT_UPDATE_USERAUTH_ERROR     -11
+//            //#define RESULT_SESSION_EXPIRED              -13
+//            //#define RESULT_VER_LOW
+//
+//            //     NSString * moreinfo = error.description ;
+//
+//            NSString* err_msg = [error localizedDescription];
+//
+//
+//            //-----------------retry 3 times for error code -1005------------------------
+//            if(error.code==-1005&&retry<3)
+//            {
+//                retry++;
+//                goto repeat;
+//
+//            }
+//            //-----------------end retry 3 times for error code -1005------------------------
+//
+//            NSDictionary* error_json = [RAUtils error_dict:error];
+//            [ret setObject:error_json forKey:@"err_obj"];
+//            NSString* resp_msg= nil;
+//
+//            if(err_msg.length==0)
+//            {
+//                err_msg =[NSHTTPURLResponse localizedStringForStatusCode:urlResponse.statusCode];
+//                resp_msg = err_msg;
+//            }
+//            [ret setValue:[NSString stringWithFormat:@"%d",RESULT_NET_ERROR] forKey:@"result"];
+//            [ret setValue:err_msg forKey:@"err_msg"];
+//            [ret setValue:resp_msg forKey:@"resp_msg"];
+//            [ret setValue:[NSString stringWithFormat:@"%ld",(long)urlResponse.statusCode] forKey:@"resp_code"];
+//
+//
+//            NSData *jsonData = [NSJSONSerialization dataWithJSONObject:ret
+//                                                               options:0
+//                                                                 error:nil];
+//            if(![url isEqualToString:recorder_url])
+//            {
+//                [self err_log:[RAUtils base64en:[RAConvertor dict2string:params]] result:[RAUtils base64en:[RAConvertor dict2string:ret]] module:url code:RESULT_NET_ERROR];
+//            }
+//            return jsonData;
+//
+//        }
+//        else
+//        {
+//          //  NSString* err_msg = [error localizedDescription];
+//            NSMutableString *str = [[NSMutableString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
+//
+//            DebugLog(@"data string: %@",str);
+//            NSError *error1 = nil;
+//
+//            NSMutableDictionary* jsobj = [[NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&error1] mutableCopy];
+//
+//            if(jsobj==nil)// 服务器返回不是json
+//            {
+//
+//                jsobj=[[NSMutableDictionary alloc] init];
+//                [jsobj setValue:[NSNumber numberWithInt:RESULT_NO_RESPONSE] forKey:@"result"];
+//
+//            }
+////            if([jsobj[@"encrypt"] boolValue]==true)
+////            {
+////                jsobj = decryptBlock(jsobj);
+////            }
+////            if (resultBlock) {
+////                jsobj = resultBlock(jsobj);
+////            }
+//
+//            int result=[[jsobj valueForKey:@"result"] intValue];
+//            if(![url isEqualToString:recorder_url]&&/*![url isEqualToString:URL_DOWNLOAD_OFFLINE]&&*/result!=2&&result!=99)
+//            {
+//                [self err_log:[RAUtils base64en:[RAConvertor dict2string:params]] result:[RAUtils base64en:str] module:url code:result];
+//            }
+//            NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsobj
+//                                                               options:0
+//                                                                 error:nil];
+//            return jsonData;
+//
+//        }
+//        return responseData;
+//    }
+}
 @end