|
@@ -1822,12 +1822,11 @@
|
|
|
__block long ver = 0;
|
|
__block long ver = 0;
|
|
|
NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
|
|
NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
|
|
|
|
|
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
|
|
+
|
|
|
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
|
|
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
|
|
|
ver = appDelegate.authVer;
|
|
ver = appDelegate.authVer;
|
|
|
if(appDelegate.duid !=nil)
|
|
if(appDelegate.duid !=nil)
|
|
|
[params setValue:appDelegate.duid forKey:@"udid"];
|
|
[params setValue:appDelegate.duid forKey:@"udid"];
|
|
|
- });
|
|
|
|
|
|
|
|
|
|
[params setValue:@"handset_login" forKey:@"action"];
|
|
[params setValue:@"handset_login" forKey:@"action"];
|
|
|
// [headers setValue:[NSString stringWithFormat:@"%d",dataLength] forKey:@"Content-Length"];
|
|
// [headers setValue:[NSString stringWithFormat:@"%d",dataLength] forKey:@"Content-Length"];
|
|
@@ -1840,15 +1839,483 @@
|
|
|
#else
|
|
#else
|
|
|
[params setValue:@"false" forKey:@"is_debug"];
|
|
[params setValue:@"false" forKey:@"is_debug"];
|
|
|
#endif
|
|
#endif
|
|
|
- NSData* json=[self get_json:URL_UPDATE_AUTH parameters:params file:nil];
|
|
|
|
|
- if(json==nil)
|
|
|
|
|
- return ;
|
|
|
|
|
|
|
|
|
|
- int ret = [self parse_authinfo:json user:user password:password];
|
|
|
|
|
- DebugLog(@"parse_authinfo return %d ",ret);
|
|
|
|
|
|
|
|
|
|
|
|
+ [self request_interface:URL_UPDATE_AUTH parameters:params err_record_url:nil completionHandler:^(NSMutableDictionary *chresult) {
|
|
|
|
|
+ int ret = [self parse_logininfo:chresult user:user password:password] ;
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary * retjson = [NSMutableDictionary new];
|
|
|
|
|
+
|
|
|
|
|
+ retjson[@"result"]= [NSNumber numberWithInt:ret];
|
|
|
|
|
+
|
|
|
|
|
+ result(retjson);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ } retry:0];
|
|
|
|
|
|
|
|
- return ;
|
|
|
|
|
|
|
+// [self request_interface:URL_UPDATE_AUTH parameters:params err_record_url:nil completionHandler:result retry:0];
|
|
|
|
|
+//
|
|
|
|
|
+// NSData* json=[self get_json:URL_UPDATE_AUTH parameters:params file:nil];
|
|
|
|
|
+// if(json==nil)
|
|
|
|
|
+// return ;
|
|
|
|
|
+//
|
|
|
|
|
+// int ret = [self parse_authinfo:json user:user password:password];
|
|
|
|
|
+// DebugLog(@"parse_authinfo return %d ",ret);
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// return ;
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
++(int)parse_logininfo : (NSDictionary *) jsobj user:(NSString*) user password:(NSString*) password
|
|
|
|
|
+{
|
|
|
|
|
+ DebugLog(@"parse_authinfo");
|
|
|
|
|
+// NSError *error=nil;
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3 *db =[ApexMobileDB get_db];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+// NSDictionary *jsobj = //[NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
|
|
|
|
|
+ if(jsobj)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ UIApplication * app = [UIApplication sharedApplication];
|
|
|
|
|
+ AppDelegate *appDelegate = (AppDelegate *)[app delegate];
|
|
|
|
|
+ int result = [[jsobj valueForKey:@"result"] intValue];
|
|
|
|
|
+ if(result!=AP_USER_AUTH)
|
|
|
|
|
+ {
|
|
|
|
|
+ DebugLog(@"USER NOT AUTHORIZED CODE=%d ",result);
|
|
|
|
|
+ [appDelegate Logout];
|
|
|
|
|
+ return RESULT_FALSE;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ NSDictionary* objheader = [jsobj objectForKey:@"header"];
|
|
|
|
|
+
|
|
|
|
|
+ NSString* required_ver=[objheader objectForKey:@"client_ver"] ;
|
|
|
|
|
+ DebugLog(@"required_ver=%@ ",required_ver);
|
|
|
|
|
+ NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];
|
|
|
|
|
+ NSString* versionNum =[infoDict valueForKey:@"CFBundleVersion"];
|
|
|
|
|
+ versionNum = [NSString stringWithFormat:@"A%@",versionNum];
|
|
|
|
|
+ int ibadge = [[objheader valueForKey:@"badge"] intValue];
|
|
|
|
|
+
|
|
|
|
|
+ // if([ibadge isEqual:[NSNull null]])
|
|
|
|
|
+ // strbadge=@"0";
|
|
|
|
|
+ // if(ibadge==nil)
|
|
|
|
|
+ // ibadge=@"0";
|
|
|
|
|
+ // if([strbadge isEqualToString:@"null"])
|
|
|
|
|
+ // strbadge=@"0";
|
|
|
|
|
+ app.applicationIconBadgeNumber = ibadge;//[strbadge intValue];
|
|
|
|
|
+
|
|
|
|
|
+ BOOL bigger = [versionNum compare:required_ver] ;
|
|
|
|
|
+ if(!bigger)
|
|
|
|
|
+ return RESULT_VER_LOW;
|
|
|
|
|
+// appDelegate.sessionid = [objheader valueForKey:@"sessionid"];
|
|
|
|
|
+ appDelegate.user = user;
|
|
|
|
|
+ appDelegate.password = password;
|
|
|
|
|
+// DebugLog(@"sessionid=%@ ",appDelegate.sessionid);
|
|
|
|
|
+ if ([[objheader valueForKey:@"update"] boolValue]==false)
|
|
|
|
|
+ {
|
|
|
|
|
+ // no update on the server;
|
|
|
|
|
+ return RESULT_TRUE;
|
|
|
|
|
+ }
|
|
|
|
|
+ int Auth_InfoVer = [[objheader valueForKey:@"ver"] intValue];
|
|
|
|
|
+// NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
|
|
|
|
|
+// [defaults removeObjectForKey:[NSString stringWithFormat:@"%@_Auth_InfoVer",user]];
|
|
|
|
|
+// [defaults setInteger:Auth_InfoVer forKey:[NSString stringWithFormat:@"%@_Auth_InfoVer",user]];
|
|
|
|
|
+
|
|
|
|
|
+ [ApexMobileDB execSql:@"delete from auth_ver;" db:db];
|
|
|
|
|
+ [ApexMobileDB execSql:[NSString stringWithFormat:@"insert into auth_ver (ver) values (%d);",Auth_InfoVer] db:db];
|
|
|
|
|
+
|
|
|
|
|
+ // [defaults synchronize];
|
|
|
|
|
+
|
|
|
|
|
+ NSDictionary* objfuncs = [jsobj objectForKey:@"functions"];
|
|
|
|
|
+ NSArray* keys= [objfuncs allKeys];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ [ApexMobileDB execSql: [NSString stringWithFormat: @"update fields_info set abandon = 1 where user ='%@'",user] db:db];
|
|
|
|
|
+ [ApexMobileDB execSql: [NSString stringWithFormat: @"update actions_info set abandon = 1 where user ='%@'",user] db:db];
|
|
|
|
|
+ char* sql = "insert into fields_info(name,aname,field_type,function_name,behavior,priority,show,user) values(?,?,?,?,?,?,?,?)";
|
|
|
|
|
+ char* sql1 = "insert into actions_info(name,function_name,user,priority) values(?,?,?,?)";
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3_stmt *stmt;
|
|
|
|
|
+ sqlite3_stmt *stmt1;
|
|
|
|
|
+ sqlite3_prepare_v2(db, sql, -1, &stmt, nil);
|
|
|
|
|
+ sqlite3_prepare_v2(db, sql1, -1, &stmt1, nil);
|
|
|
|
|
+
|
|
|
|
|
+ // db.beginTransaction();
|
|
|
|
|
+ for(int i=0;i<keys.count;i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ NSString* func_name = keys[i];
|
|
|
|
|
+ NSDictionary *objfun = [objfuncs objectForKey:func_name];
|
|
|
|
|
+ int behavior, priority = 999;
|
|
|
|
|
+ int show =1;
|
|
|
|
|
+ NSDictionary *objbehavior = [objfun objectForKey:@"search"];
|
|
|
|
|
+ NSArray* keysbehavior= [objbehavior allKeys];
|
|
|
|
|
+ behavior = BEHAVIOR_SEARCH;
|
|
|
|
|
+ for(int j=0;j<keysbehavior.count;j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ NSString* field = keysbehavior[j];
|
|
|
|
|
+ NSDictionary* field_info = [objbehavior objectForKey:field];
|
|
|
|
|
+ NSString* field_name =[field_info valueForKey:@"name"] ;
|
|
|
|
|
+ NSString* field_type = [field_info valueForKey:@"type"] ;
|
|
|
|
|
+ NSString* alias_name = [field_info valueForKey:@"alias"] ;
|
|
|
|
|
+ priority = [[field_info valueForKey:@"priority"] intValue];
|
|
|
|
|
+ if(priority==999)
|
|
|
|
|
+ show=0;
|
|
|
|
|
+ else
|
|
|
|
|
+ show=1;
|
|
|
|
|
+ int id = [ApexMobileDB get_recordid:db table:@"fields_info" where:[NSString stringWithFormat:@"name='%@' and behavior=%d and function_name='%@' and user='%@'",field_name,behavior,func_name,user]];
|
|
|
|
|
+ if(id>=0)
|
|
|
|
|
+ [ApexMobileDB execSql:[NSString stringWithFormat:@"update fields_info set abandon = 0 where _id=%d",id] db:db];
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3_bind_text(stmt, 1, [field_name UTF8String], -1, NULL);
|
|
|
|
|
+ sqlite3_bind_text(stmt, 2, [alias_name UTF8String], -1, NULL);
|
|
|
|
|
+ sqlite3_bind_text(stmt, 3, [field_type UTF8String], -1, NULL);
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3_bind_text(stmt, 4, [func_name UTF8String], -1, NULL);
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3_bind_int(stmt, 5, behavior);
|
|
|
|
|
+ sqlite3_bind_int(stmt, 6, priority);
|
|
|
|
|
+ sqlite3_bind_int(stmt, 7, show);
|
|
|
|
|
+ sqlite3_bind_text(stmt, 8, [user UTF8String], -1, NULL);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (sqlite3_step(stmt) != SQLITE_DONE)
|
|
|
|
|
+ {
|
|
|
|
|
+ fprintf(stderr, "Error: insert search failed, error infomation: %s\n", sqlite3_errmsg(db));
|
|
|
|
|
+ }
|
|
|
|
|
+ sqlite3_reset(stmt);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ objbehavior = [objfun objectForKey:@"result"];
|
|
|
|
|
+ NSArray* keysresult= [objbehavior allKeys];
|
|
|
|
|
+ behavior = BEHAVIOR_RESULT;
|
|
|
|
|
+ for(int j=0;j<keysresult.count;j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ NSString* field = keysresult[j];
|
|
|
|
|
+ NSDictionary* field_info = [objbehavior objectForKey:field];
|
|
|
|
|
+ NSString* field_name =[field_info valueForKey:@"name"] ;
|
|
|
|
|
+ NSString* field_type = [field_info valueForKey:@"type"] ;
|
|
|
|
|
+ NSString* alias_name = [field_info valueForKey:@"alias"] ;
|
|
|
|
|
+ priority = [[field_info valueForKey:@"priority"] intValue];
|
|
|
|
|
+ if(priority==999)
|
|
|
|
|
+ show=0;
|
|
|
|
|
+ else
|
|
|
|
|
+ show=1;
|
|
|
|
|
+ int id = [ApexMobileDB get_recordid:db table:@"fields_info" where:[NSString stringWithFormat:@"name='%@' and behavior=%d and function_name='%@' and user='%@'",field_name,behavior,func_name,user]];
|
|
|
|
|
+ if(id>=0)
|
|
|
|
|
+ [ApexMobileDB execSql:[NSString stringWithFormat:@"update fields_info set abandon = 0 where _id=%d",id] db:db];
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ sqlite3_bind_text(stmt, 1, [field_name UTF8String], -1, NULL);
|
|
|
|
|
+ sqlite3_bind_text(stmt, 2, [alias_name UTF8String], -1, NULL);
|
|
|
|
|
+ sqlite3_bind_text(stmt, 3, [field_type UTF8String], -1, NULL);
|
|
|
|
|
+ sqlite3_bind_text(stmt, 4, [func_name UTF8String], -1, NULL);
|
|
|
|
|
+ sqlite3_bind_int(stmt, 5, behavior);
|
|
|
|
|
+ sqlite3_bind_int(stmt, 6, priority);
|
|
|
|
|
+ sqlite3_bind_int(stmt, 7, show);
|
|
|
|
|
+ sqlite3_bind_text(stmt, 8, [user UTF8String], -1, NULL);
|
|
|
|
|
+
|
|
|
|
|
+ if (sqlite3_step(stmt) != SQLITE_DONE)
|
|
|
|
|
+ {
|
|
|
|
|
+ fprintf(stderr, "Error: insert result failed, error infomation: %s\n", sqlite3_errmsg(db));
|
|
|
|
|
+ }
|
|
|
|
|
+ sqlite3_reset(stmt);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ objbehavior = [objfun objectForKey:@"actions"];
|
|
|
|
|
+ NSArray* keysactions= [objbehavior allKeys];
|
|
|
|
|
+ behavior = BEHAVIOR_SEARCH;
|
|
|
|
|
+ for(int j=0;j<keysactions.count;j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ NSString* actionname = keysactions[j];
|
|
|
|
|
+ int action_priority = [[objbehavior valueForKey:actionname] intValue];
|
|
|
|
|
+ int id = [ApexMobileDB get_recordid:db table:@"actions_info" where:[NSString stringWithFormat:@"name='%@' and function_name='%@' and user='%@'",actionname,func_name,user]];
|
|
|
|
|
+ if(id>=0)
|
|
|
|
|
+ [ApexMobileDB execSql:[NSString stringWithFormat:@"update actions_info set abandon = 0 , priority=%d where _id=%d",action_priority,id] db:db];
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3_bind_text(stmt1, 1, [actionname UTF8String], -1, NULL);
|
|
|
|
|
+ sqlite3_bind_text(stmt1, 2, [func_name UTF8String], -1, NULL);
|
|
|
|
|
+ sqlite3_bind_text(stmt1, 3, [user UTF8String], -1, NULL);
|
|
|
|
|
+ sqlite3_bind_int(stmt1, 4, action_priority);
|
|
|
|
|
+
|
|
|
|
|
+ if (sqlite3_step(stmt1) != SQLITE_DONE)
|
|
|
|
|
+ {
|
|
|
|
|
+ fprintf(stderr, "Error: insert action_info failed, error infomation: %s\n", sqlite3_errmsg(db));
|
|
|
|
|
+ }
|
|
|
|
|
+ sqlite3_reset(stmt1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ [ApexMobileDB execSql:@"delete from fields_info where abandon = 1" db:db];
|
|
|
|
|
+ [ApexMobileDB execSql:@"delete from actions_info where abandon = 1" db:db];
|
|
|
|
|
+
|
|
|
|
|
+ sqlite3_finalize(stmt);
|
|
|
|
|
+ sqlite3_finalize(stmt1);
|
|
|
|
|
+ sqlite3_close(db);
|
|
|
|
|
+
|
|
|
|
|
+ [ApexMobileDB deleteResultFields];
|
|
|
|
|
+ [ApexMobileDB updateResultDisplayFields];
|
|
|
|
|
+ /*
|
|
|
|
|
+
|
|
|
|
|
+ db.setTransactionSuccessful();
|
|
|
|
|
+ db.endTransaction();
|
|
|
|
|
+ */
|
|
|
|
|
+ return RESULT_TRUE;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ // NSDictionary *weatherInfo = [jsobj objectForKey:@"weatherinfo"];
|
|
|
|
|
+ // txtView.text = [NSString stringWithFormat:@"今天是 %@ %@ %@ 的天气状况是:%@ %@ ",[weatherInfo objectForKey:@"date_y"],[weatherInfo objectForKey:@"week"],[weatherInfo objectForKey:@"city"], [weatherInfo objectForKey:@"weather1"], [weatherInfo objectForKey:@"temp1"]];
|
|
|
|
|
+ // DebugLog(@"weatherInfo字典里面的内容为--》%@", weatherDic );
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return RESULT_USERAUTH_ERROR;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
++ (void)request_home:(resultHandler)result
|
|
|
|
|
+{
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
|
|
|
|
+
|
|
|
|
|
+// action=hand_new_home_list
|
|
|
|
|
+ [params setObject:@"hand_new_home_list" forKey:@"action"];
|
|
|
|
|
+ [params setObject:@(YES) forKey:@"request_location"];
|
|
|
|
|
+
|
|
|
|
|
+ AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
+ if(appDelegate.personalmode)
|
|
|
|
|
+ params[@"personal_mode"] = @"true";
|
|
|
|
|
+ else
|
|
|
|
|
+ params[@"personal_mode"] = @"false";
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ [self request_interface:URL_HOME parameters:params err_record_url:nil completionHandler:result retry:0];
|
|
|
|
|
+
|
|
|
|
|
+// NSData* json=[self get_json:URL_HOME parameters:params file:nil];
|
|
|
|
|
+//
|
|
|
|
|
+// if (json==nil)
|
|
|
|
|
+// {
|
|
|
|
|
+// return @{
|
|
|
|
|
+// @"result" : @RESULT_NET_ERROR,
|
|
|
|
|
+// @"err_msg" : MSG_NET_ERROR
|
|
|
|
|
+// };
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// NSDictionary *resultDic = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:nil];
|
|
|
|
|
+//
|
|
|
|
|
+// return resultDic;
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
++ (void)request_kpi:(resultHandler)result
|
|
|
|
|
+{
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
|
|
|
|
+
|
|
|
|
|
+ [params setObject:@"hand_new_kpi" forKey:@"action"];
|
|
|
|
|
+ AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
+ if(appDelegate.personalmode)
|
|
|
|
|
+ params[@"personal_mode"] = @"true";
|
|
|
|
|
+ else
|
|
|
|
|
+ params[@"personal_mode"] = @"false";
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ [self request_interface:URL_KPI parameters:params err_record_url:nil completionHandler:result retry:0];
|
|
|
|
|
+//
|
|
|
|
|
+// NSData* json=[self get_json:URL_KPI parameters:params file:nil];
|
|
|
|
|
+//
|
|
|
|
|
+// if (json==nil)
|
|
|
|
|
+// {
|
|
|
|
|
+// return @{
|
|
|
|
|
+// @"result" : @RESULT_NET_ERROR,
|
|
|
|
|
+// @"err_msg" : MSG_NET_ERROR
|
|
|
|
|
+// };
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// NSDictionary *resultDic = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:nil];
|
|
|
|
|
+//
|
|
|
|
|
+// return resultDic;
|
|
|
|
|
+//
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
++(void) request_detail: (NSMutableDictionary *) params completionHandler:(resultHandler)result
|
|
|
|
|
+{
|
|
|
|
|
+ DebugLog(@"get_detailcontent");
|
|
|
|
|
+ DetailContent * detailContent = [[DetailContent alloc] init];
|
|
|
|
|
+ NSMutableArray* segments = [[NSMutableArray alloc] init];
|
|
|
|
|
+ detailContent.segments = segments;
|
|
|
|
|
+ if(![NetworkUtils IsNetworkAvailable])
|
|
|
|
|
+ {
|
|
|
|
|
+ detailContent.result_code = RESULT_NET_NOTAVAILABLE;
|
|
|
|
|
+// return detailContent;
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
+ [params setValue:@"handset_search" forKey:@"action"];
|
|
|
|
|
+// [params setValue:appDelegate.sessionid forKey:@"sessionid"];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ [self request_interface:URL_REQUEST_RECORDS parameters:params err_record_url:nil completionHandler:^(NSMutableDictionary *chresult) {
|
|
|
|
|
+ NSString *str = [RAConvertor dict2string: chresult];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ str=[str stringByReplacingOccurrencesOfString:@"<table " withString:@"<table style=font-size:12px "];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ DebugLog(@"hack string: %@",str);
|
|
|
|
|
+ //------- hack-----------
|
|
|
|
|
+ NSDictionary *retjson=[RAConvertor string2dict:str];
|
|
|
|
|
+
|
|
|
|
|
+ result([retjson mutableCopy]);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ } retry:0];
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ NSData* json=[self get_json:URL_REQUEST_RECORDS parameters:params file:nil];
|
|
|
|
|
+ if (json==nil)
|
|
|
|
|
+ {
|
|
|
|
|
+ DebugLog(@"json is wrong");
|
|
|
|
|
+ detailContent.result_code = RESULT_NET_ERROR;
|
|
|
|
|
+ //return detailContent;
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //------------hack detail html 字体大小-----------
|
|
|
|
|
+ NSString *str = [[NSString alloc] initWithData:json encoding:NSUTF8StringEncoding];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ str=[str stringByReplacingOccurrencesOfString:@"<table " withString:@"<table style=font-size:12px "];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ DebugLog(@"hack string: %@",str);
|
|
|
|
|
+ //------- hack-----------
|
|
|
|
|
+ NSDictionary *jsobj=[RAConvertor string2dict:str];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSError *error=nil;
|
|
|
|
|
+// NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+ if(jsobj)
|
|
|
|
|
+ {
|
|
|
|
|
+ int result = [[jsobj valueForKey:@"result"] intValue];
|
|
|
|
|
+ if(result== AP_SESSION_EXPIRED)
|
|
|
|
|
+ {
|
|
|
|
|
+ [self Authorize:appDelegate.user password:appDelegate.password];
|
|
|
|
|
+ json=[self get_json:URL_REQUEST_RECORDS parameters:params file:nil];
|
|
|
|
|
+ if (json==nil)
|
|
|
|
|
+ {
|
|
|
|
|
+ DebugLog(@"json is wrong");
|
|
|
|
|
+ detailContent.result_code = RESULT_NET_ERROR;
|
|
|
|
|
+// return detailContent;
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
|
|
|
|
|
+ result = [[jsobj valueForKey:@"result"] intValue];
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ if(result!=AP_USER_AUTH)
|
|
|
|
|
+ {
|
|
|
|
|
+ DebugLog(@"USER NOT AUTHORIZED CODE=%d ",result);
|
|
|
|
|
+ detailContent.result_code = result;
|
|
|
|
|
+// return detailContent;
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+// if([params[@"action_type"] isEqualToString:@"Tracking"])
|
|
|
|
|
+// {
|
|
|
|
|
+// NSString *path = [[NSBundle mainBundle] pathForResource:@"fake_tracking.json" ofType:nil];
|
|
|
|
|
+// NSData *data = [[NSData alloc] initWithContentsOfFile:path];
|
|
|
|
|
+// NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
|
|
|
|
|
+// jsobj = json;
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ int count =[[jsobj valueForKey:@"count"] intValue];
|
|
|
|
|
+
|
|
|
|
|
+// if ([[params objectForKey:@"action_type"] isEqualToString:@"Detail"]) {
|
|
|
|
|
+// NSMutableDictionary *mJson = [jsobj mutableCopy];
|
|
|
|
|
+// NSDictionary *comm = @{
|
|
|
|
|
+// @"_name": @"Communication",
|
|
|
|
|
+// @"_type": @"communication",
|
|
|
|
|
+// @"cc": @"",
|
|
|
|
|
+// @"receipt": @"",
|
|
|
|
|
+// @"count": @2,
|
|
|
|
|
+// @"item0": @{
|
|
|
|
|
+// @"Sender": @"user name",
|
|
|
|
|
+// @"msg": @"content bla bla bla...",
|
|
|
|
|
+// @"mst_time": @"04/28/2018 20:15:33",
|
|
|
|
|
+// @"email_url": @"https://www.baidu.com"
|
|
|
|
|
+// },
|
|
|
|
|
+// @"item1": @{
|
|
|
|
|
+// @"Sender": @"user name",
|
|
|
|
|
+// @"msg": @"content bla bla bla...",
|
|
|
|
|
+// @"mst_time": @"04/28/2018 20:15:33"
|
|
|
|
|
+// }
|
|
|
|
|
+// };
|
|
|
|
|
+// [mJson setObject:comm forKey:[NSString stringWithFormat:@"group%d",count]];
|
|
|
|
|
+//
|
|
|
|
|
+// [mJson setObject:@(++count) forKey:@"count"];
|
|
|
|
|
+//
|
|
|
|
|
+// jsobj = mJson;
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ detailContent.result_code = RESULT_TRUE;
|
|
|
|
|
+ if(count==0)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+// return detailContent;
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for(int i=0;i<count;i++)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ NSDictionary* segment = [jsobj objectForKey:[NSString stringWithFormat:@"group%d",i]];
|
|
|
|
|
+ [segments addObject:segment];
|
|
|
|
|
+
|
|
|
|
|
+ /*
|
|
|
|
|
+ JSONObject groupobj = jsonObj.getJSONObject("group" + i);
|
|
|
|
|
+ View v = inflater.inflate(R.layout.group_tag, null);
|
|
|
|
|
+ v.setOnClickListener(this);
|
|
|
|
|
+
|
|
|
|
|
+ TextView tvgroup = (TextView) v.findViewById(R.id.tv_group);
|
|
|
|
|
+ String group_name = groupobj.getString("_name");
|
|
|
|
|
+ tvgroup.setText(group_name);
|
|
|
|
|
+ v.setId(commonUtil.generateViewId());
|
|
|
|
|
+ ll_root.addView(v);
|
|
|
|
|
+ String grouptype = groupobj.getString("_type");
|
|
|
|
|
+
|
|
|
|
|
+ */
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // NSDictionary* objrecords = [jsobj objectForKey:@"records"];
|
|
|
|
|
+
|
|
|
|
|
+ detailContent.originContent = jsobj;
|
|
|
|
|
+
|
|
|
|
|
+// return detailContent;
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+// return nil;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
@end
|
|
@end
|