|
@@ -7721,5 +7721,679 @@ NSString *const ScreenCodeOfflineSync = @"Offline Sync Screen";
|
|
|
// else
|
|
// else
|
|
|
// return nil;
|
|
// return nil;
|
|
|
|
|
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
++ (void)request_fastdownload:(NSMutableDictionary *)params url:(NSString *)url completionHandler:(resultHandler)result
|
|
|
|
|
+{
|
|
|
|
|
+
|
|
|
|
|
+//#ifdef test_server
|
|
|
|
|
+// url=URL_REQUEST_RECORDS;
|
|
|
|
|
+// params[@"prefix"]=URL_REQUEST_RECORDS;
|
|
|
|
|
+//#endif
|
|
|
|
|
+
|
|
|
|
|
+ [self request_file_fast:url parameters:params completionHandler:result];
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
++(void) request_addto_portfolio:(NSString* ) item_id withScreen:(NSString *)screenName completionHandler:(resultHandler)result
|
|
|
|
|
+{
|
|
|
|
|
+ NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
|
|
|
|
|
+ AppDelegate *appDelegate = nil;
|
|
|
|
|
+
|
|
|
|
|
+ appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
+ if(appDelegate.user!=nil)
|
|
|
|
|
+ [params setValue:appDelegate.user forKey:@"user"];
|
|
|
|
|
+ if(appDelegate.contact_id!=nil)
|
|
|
|
|
+ [params setValue:appDelegate.contact_id forKey:@"contactId"];
|
|
|
|
|
+ if(appDelegate.password!=nil)
|
|
|
|
|
+ [params setValue:appDelegate.password forKey:@"password"];
|
|
|
|
|
+
|
|
|
|
|
+ [params setValue:item_id forKey:@"product_id"];
|
|
|
|
|
+
|
|
|
|
|
+ [params setObject:screenName forKey:kScreenName];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if(appDelegate.offline_mode)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
|
|
+ NSMutableDictionary* json = [[OLDataProvider offline_add2Portfolio:params] mutableCopy];
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+ result(json);
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ [self request_interface:URL_ADD_TO_PORTFOLIO parameters:params err_record_url:nil completionHandler:^(NSMutableDictionary *resulti) {
|
|
|
|
|
+ int result_code = [[resulti valueForKey:@"result"] intValue];
|
|
|
|
|
+
|
|
|
|
|
+ if (result_code==2)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ appDelegate.port_count =[[resulti valueForKey:@"portfolio_count"] intValue];
|
|
|
|
|
+
|
|
|
|
|
+ [appDelegate update_count_mark];
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ result(resulti);
|
|
|
|
|
+ } retry:0];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+//
|
|
|
|
|
+// NSData* json = nil;
|
|
|
|
|
+// if(appDelegate.offline_mode)
|
|
|
|
|
+// {
|
|
|
|
|
+// json = [OLDataProvider offline_add2Portfolio:params];
|
|
|
|
|
+// } else {
|
|
|
|
|
+// if(![self IsNetworkAvailable])
|
|
|
|
|
+// return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
|
|
|
|
|
+//
|
|
|
|
|
+// json=[self get_json:URL_ADD_TO_PORTFOLIO parameters:params];
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// if(json==nil)
|
|
|
|
|
+// return nil;
|
|
|
|
|
+// NSError *error=nil;
|
|
|
|
|
+// NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
|
|
|
|
|
+// int result = [[jsobj valueForKey:@"result"] intValue];
|
|
|
|
|
+//
|
|
|
|
|
+// if (result==2)
|
|
|
|
|
+// {
|
|
|
|
|
+//
|
|
|
|
|
+// // appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
|
|
|
|
|
+// // appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
|
|
|
|
|
+// appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
|
|
|
|
|
+//
|
|
|
|
|
+// [appDelegate update_count_mark];
|
|
|
|
|
+// }
|
|
|
|
|
+// return jsobj;
|
|
|
|
|
+}
|
|
|
|
|
++(void)request_addall_search:(long ) offset limit :(long)limit keywords :(NSString*) keywords matchfull:(bool)matchfull orderCode:(NSString*) orderCode addTo:(NSString*) addTo completionHandler:(resultHandler)result
|
|
|
|
|
+{
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
|
|
|
|
|
+ AppDelegate *appDelegate = nil;
|
|
|
|
|
+
|
|
|
|
|
+ appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
+ if(appDelegate.user!=nil)
|
|
|
|
|
+ [params setValue:appDelegate.user forKey:@"user"];
|
|
|
|
|
+ if(appDelegate.contact_id!=nil)
|
|
|
|
|
+ [params setValue:appDelegate.contact_id forKey:@"contactId"];
|
|
|
|
|
+ if(appDelegate.password!=nil)
|
|
|
|
|
+ [params setValue:appDelegate.password forKey:@"password"];
|
|
|
|
|
+ if(appDelegate.order_code!=nil)
|
|
|
|
|
+ [params setValue:appDelegate.order_code forKey:@"orderCode"];
|
|
|
|
|
+ // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
|
|
|
|
|
+ // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
|
|
|
|
|
+ // [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
|
|
|
|
|
+ // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
|
|
|
|
|
+ // [params setValue:filter forKey:@"filter"];
|
|
|
|
|
+ [params setValue:keywords forKey:@"keyword"];
|
|
|
|
|
+ [params setValue:addTo forKey:@"addTo"];
|
|
|
|
|
+
|
|
|
|
|
+ [params setValue:orderCode forKey:@"orderCode"];
|
|
|
|
|
+ [params setValue:[NSString stringWithFormat:@"%ld",limit] forKey:@"limit"];
|
|
|
|
|
+ [params setValue:[NSString stringWithFormat:@"%ld",offset] forKey:@"offset"];
|
|
|
|
|
+ if(matchfull)
|
|
|
|
|
+ [params setValue:@"true" forKey:@"exactMatch"];
|
|
|
|
|
+ else
|
|
|
|
|
+ [params setValue:@"false" forKey:@"exactMatch"];
|
|
|
|
|
+
|
|
|
|
|
+ [params setObject:ScreenCodeSearch forKey:kScreenName];
|
|
|
|
|
+ if ([addTo isEqualToString:@"cart"]) {
|
|
|
|
|
+ [params setObject:@"Add To Cart" forKey:kAction];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if(appDelegate.offline_mode)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
|
|
+ NSMutableDictionary* json = [[OLDataProvider offline_searchaddall:params] mutableCopy];
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+ result(json);
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSString * uuid= [[NSUUID UUID] UUIDString];
|
|
|
|
|
+ params[@"resultSerial"]=uuid;
|
|
|
|
|
+ __block bool bbreak = false;
|
|
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
|
|
+ for(int i=0;i<150;i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ // NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
|
|
|
|
|
+ // result_params[@"resultSerial"]=uuid;
|
|
|
|
|
+ if(bbreak)
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+ [self request_interface:URL_SEARCHADDALL parameters:params err_record_url:nil completionHandler:^(NSMutableDictionary *resulti) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if([resulti[@"result"] intValue]==2)
|
|
|
|
|
+ {
|
|
|
|
|
+ bbreak=true;
|
|
|
|
|
+ result(resulti);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ } retry:0];
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ sleep(2);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// NSData* json=nil;
|
|
|
|
|
+// if(appDelegate.offline_mode)
|
|
|
|
|
+// {
|
|
|
|
|
+// json=[OLDataProvider offline_searchaddall:params];
|
|
|
|
|
+// }
|
|
|
|
|
+// else
|
|
|
|
|
+// {
|
|
|
|
|
+// if(![self IsNetworkAvailable])
|
|
|
|
|
+// return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
|
|
|
|
|
+//
|
|
|
|
|
+// NSError *error=nil;
|
|
|
|
|
+//
|
|
|
|
|
+// NSString * uuid= [[NSUUID UUID] UUIDString];
|
|
|
|
|
+// params[@"resultSerial"]=uuid;
|
|
|
|
|
+//
|
|
|
|
|
+// for(int i=0;i<150;i++)
|
|
|
|
|
+// {
|
|
|
|
|
+// // NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
|
|
|
|
|
+// // result_params[@"resultSerial"]=uuid;
|
|
|
|
|
+// json=[self get_json:URL_SEARCHADDALL parameters:params];
|
|
|
|
|
+// if(json!=nil)
|
|
|
|
|
+// {
|
|
|
|
|
+//
|
|
|
|
|
+// NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
|
|
|
|
|
+// if([jsobj[@"result"] intValue]==2)
|
|
|
|
|
+// {
|
|
|
|
|
+// break;
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// sleep(2);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// if(json==nil)
|
|
|
|
|
+// return nil;
|
|
|
|
|
+// NSError *error=nil;
|
|
|
|
|
+// NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
|
|
|
|
|
+// return jsobj;
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
++(void) request_addto_cart_byname:(NSString* ) model_name withScreen:(NSString *)screenName completionHandler:(resultHandler)result
|
|
|
|
|
+{
|
|
|
|
|
+ NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
|
|
|
|
|
+ AppDelegate *appDelegate = nil;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
+ if(appDelegate.user!=nil)
|
|
|
|
|
+ [params setValue:appDelegate.user forKey:@"user"];
|
|
|
|
|
+ if(appDelegate.contact_id!=nil)
|
|
|
|
|
+ [params setValue:appDelegate.contact_id forKey:@"contactId"];
|
|
|
|
|
+ if(appDelegate.password!=nil)
|
|
|
|
|
+ [params setValue:appDelegate.password forKey:@"password"];
|
|
|
|
|
+
|
|
|
|
|
+ if(appDelegate.order_code!=nil)
|
|
|
|
|
+ [params setValue:appDelegate.order_code forKey:@"orderCode"];
|
|
|
|
|
+ [params setValue:model_name forKey:@"product_name"];
|
|
|
|
|
+ [params setValue:[NSString stringWithFormat:@"%d",-1] forKey:@"count"];
|
|
|
|
|
+
|
|
|
|
|
+ [params setObject:screenName forKey:kScreenName];
|
|
|
|
|
+ [params setObject:@"Add To Cart" forKey:kAction];
|
|
|
|
|
+ if (!model_name) {
|
|
|
|
|
+ model_name = @"";
|
|
|
|
|
+ }
|
|
|
|
|
+ [params setObject:@{@"ModelName" : model_name} forKey:kExtra];
|
|
|
|
|
+
|
|
|
|
|
+ NSDictionary* customerinfo= appDelegate.customerInfo;
|
|
|
|
|
+
|
|
|
|
|
+ NSArray* keys=[customerinfo allKeys];
|
|
|
|
|
+ for(int i=0;i<keys.count;i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ [params setValue:[customerinfo valueForKey:(NSString*)keys[i]] forKey:keys[i] ];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if(appDelegate.offline_mode)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
|
|
+ NSMutableDictionary* json = [[OLDataProvider offline_add2cartbyname:params] mutableCopy];
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+ result(json);
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ [self request_interface:URL_ADD_TO_CART parameters:params err_record_url:nil completionHandler:^(NSMutableDictionary *resulti) {
|
|
|
|
|
+ int result_code = [[resulti valueForKey:@"result"] intValue];
|
|
|
|
|
+
|
|
|
|
|
+ if (result_code==2||result_code==8)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ appDelegate.cart_count = [[resulti valueForKey:@"cart_count"] intValue];
|
|
|
|
|
+
|
|
|
|
|
+ [appDelegate update_count_mark];
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ result(resulti);
|
|
|
|
|
+ } retry:0];
|
|
|
|
|
+
|
|
|
|
|
+// NSData* json=nil;
|
|
|
|
|
+// if(appDelegate.offline_mode)
|
|
|
|
|
+// {
|
|
|
|
|
+// json= [OLDataProvider offline_add2cartbyname:params];
|
|
|
|
|
+// }
|
|
|
|
|
+// else
|
|
|
|
|
+// {
|
|
|
|
|
+// if(![self IsNetworkAvailable])
|
|
|
|
|
+// return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
|
|
|
|
|
+//
|
|
|
|
|
+// json=[self get_json:URL_ADD_TO_CART parameters:params];
|
|
|
|
|
+// }
|
|
|
|
|
+// if(json==nil)
|
|
|
|
|
+// return nil;
|
|
|
|
|
+// NSError *error=nil;
|
|
|
|
|
+// NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// int result = [[jsobj valueForKey:@"result"] intValue];
|
|
|
|
|
+//
|
|
|
|
|
+// if (result==2||result==8)
|
|
|
|
|
+// {
|
|
|
|
|
+//
|
|
|
|
|
+// appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
|
|
|
|
|
+// // appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
|
|
|
|
|
+// // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
|
|
|
|
|
+//
|
|
|
|
|
+// [appDelegate update_count_mark];
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// return jsobj;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
++(void) request_addto_wishlist:(NSString* ) item_id withScreen:(NSString *)screenName completionHandler:(resultHandler)result
|
|
|
|
|
+{
|
|
|
|
|
+ NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
|
|
|
|
|
+ AppDelegate *appDelegate = nil;
|
|
|
|
|
+
|
|
|
|
|
+ appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
+ if(appDelegate.user!=nil)
|
|
|
|
|
+ [params setValue:appDelegate.user forKey:@"user"];
|
|
|
|
|
+ if(appDelegate.contact_id!=nil)
|
|
|
|
|
+ [params setValue:appDelegate.contact_id forKey:@"contactId"];
|
|
|
|
|
+ if(appDelegate.password!=nil)
|
|
|
|
|
+ [params setValue:appDelegate.password forKey:@"password"];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ [params setValue:item_id forKey:@"product_id"];
|
|
|
|
|
+
|
|
|
|
|
+ [params setObject:screenName forKey:kScreenName];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if(appDelegate.offline_mode)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
|
|
+ NSMutableDictionary* json = [[OLDataProvider offline_add2wishlist:params] mutableCopy];
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+ result(json);
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ [self request_interface:URL_ADD_TO_WATCHLIST parameters:params err_record_url:nil completionHandler:^(NSMutableDictionary *resulti) {
|
|
|
|
|
+ int result_code = [[resulti valueForKey:@"result"] intValue];
|
|
|
|
|
+
|
|
|
|
|
+ if (result_code==2||result_code==8)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ appDelegate.wish_count =[[resulti valueForKey:@"wish_count"] intValue];
|
|
|
|
|
+
|
|
|
|
|
+ [appDelegate update_count_mark];
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ result(resulti);
|
|
|
|
|
+ } retry:0];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+// if(appDelegate.offline_mode)
|
|
|
|
|
+// {
|
|
|
|
|
+// return [OLDataProvider offline_add2wishlist:params];
|
|
|
|
|
+// }
|
|
|
|
|
+// if(![self IsNetworkAvailable])
|
|
|
|
|
+// return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
|
|
|
|
|
+//
|
|
|
|
|
+// NSData* json=[self get_json:URL_ADD_TO_WATCHLIST parameters:params];
|
|
|
|
|
+// if(json==nil)
|
|
|
|
|
+// return nil;
|
|
|
|
|
+// NSError *error=nil;
|
|
|
|
|
+// NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
|
|
|
|
|
+// int result = [[jsobj valueForKey:@"result"] intValue];
|
|
|
|
|
+//
|
|
|
|
|
+// if (result==2)
|
|
|
|
|
+// {
|
|
|
|
|
+//
|
|
|
|
|
+// //appDelegate.cart_count = [[jsobj valueForKey:@"cart_count"] intValue];
|
|
|
|
|
+// appDelegate.wish_count =[[jsobj valueForKey:@"wish_count"] intValue];
|
|
|
|
|
+// // appDelegate.port_count =[[jsobj valueForKey:@"portfolio_count"] intValue];
|
|
|
|
|
+//
|
|
|
|
|
+// [appDelegate update_count_mark];
|
|
|
|
|
+// }
|
|
|
|
|
+// return jsobj;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
++(void)request_addall_itemsearch:(long ) offset limit :(long)limit covertype:(NSString* ) covertype ctgid:(NSString*)ctgid modelname:(NSString*) modelname modeldescrip:(NSString*)modeldescrip alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price bestseller:(NSString*)bestseller orderCode:(NSString*) orderCode addTo:(NSString*) addTo completionHandler:(resultHandler)result
|
|
|
|
|
+{
|
|
|
|
|
+ // for debug
|
|
|
|
|
+ // return [RAUtils error_json:RESULT_NET_ERROR err_msg:nil];
|
|
|
|
|
+ //return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
|
|
|
|
|
+ AppDelegate *appDelegate = nil;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
+
|
|
|
|
|
+ if(appDelegate.user!=nil)
|
|
|
|
|
+ [params setValue:appDelegate.user forKey:@"user"];
|
|
|
|
|
+ if(appDelegate.contact_id!=nil)
|
|
|
|
|
+ [params setValue:appDelegate.contact_id forKey:@"contactId"];
|
|
|
|
|
+ if(appDelegate.password!=nil)
|
|
|
|
|
+ [params setValue:appDelegate.password forKey:@"password"];
|
|
|
|
|
+ if(appDelegate.order_code!=nil)
|
|
|
|
|
+ [params setValue:appDelegate.order_code forKey:@"orderCode"];
|
|
|
|
|
+
|
|
|
|
|
+ [params setValue:addTo forKey:@"addTo"];
|
|
|
|
|
+
|
|
|
|
|
+ [params setValue:orderCode forKey:@"orderCode"];
|
|
|
|
|
+
|
|
|
|
|
+ // [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
|
|
|
|
|
+ // [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
|
|
|
|
|
+ // [params setValue:[NSString stringWithFormat:@"%@",category] forKey:@"category"];
|
|
|
|
|
+ // [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
|
|
|
|
|
+ // [params setValue:filter forKey:@"filter"];
|
|
|
|
|
+ [params setValue:covertype forKey:@"covertype"];
|
|
|
|
|
+ [params setValue:ctgid forKey:@"ctgId"];
|
|
|
|
|
+ [params setValue:modelname forKey:@"modelName"];
|
|
|
|
|
+ [params setValue:modeldescrip forKey:@"modelDescription"];
|
|
|
|
|
+ [params setValue:alert forKey:@"alert"];
|
|
|
|
|
+ [params setValue:qty forKey:@"sold_by_qty"];
|
|
|
|
|
+ [params setValue:available forKey:@"available"];
|
|
|
|
|
+ [params setValue:price forKey:@"price"];
|
|
|
|
|
+ [params setValue:bestseller forKey:@"bestseller"];
|
|
|
|
|
+
|
|
|
|
|
+ [params setValue:[NSString stringWithFormat:@"%ld",limit] forKey:@"limit"];
|
|
|
|
|
+ [params setValue:[NSString stringWithFormat:@"%ld",offset] forKey:@"offset"];
|
|
|
|
|
+
|
|
|
|
|
+ [params setObject:ScreenCodeParticularCategory forKey:kScreenName];
|
|
|
|
|
+ if ([addTo isEqualToString:@"cart"]) {
|
|
|
|
|
+ [params setObject:@"Add To Cart" forKey:kAction];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if(appDelegate.offline_mode)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
|
|
+ NSMutableDictionary* json = [[OLDataProvider offline_itemsearchaddall:params] mutableCopy];
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+ result(json);
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSString * uuid= [[NSUUID UUID] UUIDString];
|
|
|
|
|
+ params[@"resultSerial"]=uuid;
|
|
|
|
|
+ __block bool bbreak = false;
|
|
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
|
|
+ for(int i=0;i<150;i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ // NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
|
|
|
|
|
+ // result_params[@"resultSerial"]=uuid;
|
|
|
|
|
+ if(bbreak)
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+ [self request_interface:URL_ITEMSEARCHADDALL parameters:params err_record_url:nil completionHandler:^(NSMutableDictionary *resulti) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if([resulti[@"result"] intValue]==2)
|
|
|
|
|
+ {
|
|
|
|
|
+ bbreak=true;
|
|
|
|
|
+ result(resulti);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ } retry:0];
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ sleep(2);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+//
|
|
|
|
|
+// NSData* json = nil;
|
|
|
|
|
+//
|
|
|
|
|
+// if(appDelegate.offline_mode)
|
|
|
|
|
+// {
|
|
|
|
|
+// json= [OLDataProvider offline_itemsearchaddall:params];
|
|
|
|
|
+// }
|
|
|
|
|
+// else
|
|
|
|
|
+// {
|
|
|
|
|
+// if(![self IsNetworkAvailable])
|
|
|
|
|
+// return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
|
|
|
|
|
+// NSError *error=nil;
|
|
|
|
|
+//
|
|
|
|
|
+// NSString * uuid= [[NSUUID UUID] UUIDString];
|
|
|
|
|
+// params[@"resultSerial"]=uuid;
|
|
|
|
|
+//
|
|
|
|
|
+// for(int i=0;i<150;i++)
|
|
|
|
|
+// {
|
|
|
|
|
+// // NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
|
|
|
|
|
+// // result_params[@"resultSerial"]=uuid;
|
|
|
|
|
+// json=[self get_json:URL_ITEMSEARCHADDALL parameters:params];
|
|
|
|
|
+// if(json!=nil)
|
|
|
|
|
+// {
|
|
|
|
|
+//
|
|
|
|
|
+// NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
|
|
|
|
|
+// if([jsobj[@"result"] intValue]==2)
|
|
|
|
|
+// {
|
|
|
|
|
+// break;
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// sleep(2);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// if(json==nil)
|
|
|
|
|
+// return nil;
|
|
|
|
|
+// NSError *error=nil;
|
|
|
|
|
+// NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
|
|
|
|
|
+// return jsobj;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
++(void)request_addall_category: (NSString*) category customid:(int) customid price_template:(int) price_template sort:(int) sort_by filter:(NSString*) filter keyword:(NSString*) keyword offset:(long) offset limit:(long) limit alert:(NSString*)alert qty:(NSString*)qty available:(NSString*)available price:(NSString*)price bestseller:(NSString*)bestseller modelname:(NSString*) modelname modeldescrip:(NSString*)modeldescrip orderCode:(NSString*) orderCode addTo:(NSString*) addTo completionHandler:(resultHandler)result
|
|
|
|
|
+
|
|
|
|
|
+{
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ AppDelegate *appDelegate = nil;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ appDelegate=(AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
|
|
|
|
|
+
|
|
|
|
|
+ if(appDelegate.user!=nil)
|
|
|
|
|
+ [params setValue:appDelegate.user forKey:@"user"];
|
|
|
|
|
+ if(appDelegate.contact_id!=nil)
|
|
|
|
|
+ [params setValue:appDelegate.contact_id forKey:@"contactId"];
|
|
|
|
|
+ if(appDelegate.password!=nil)
|
|
|
|
|
+ [params setValue:appDelegate.password forKey:@"password"];
|
|
|
|
|
+ if(appDelegate.order_code!=nil)
|
|
|
|
|
+ [params setValue:appDelegate.order_code forKey:@"orderCode"];
|
|
|
|
|
+
|
|
|
|
|
+ [params setValue:addTo forKey:@"addTo"];
|
|
|
|
|
+ [params setValue:orderCode forKey:@"orderCode"];
|
|
|
|
|
+ [params setValue:alert forKey:@"alert"];
|
|
|
|
|
+ [params setValue:qty forKey:@"sold_by_qty"];
|
|
|
|
|
+ [params setValue:available forKey:@"available"];
|
|
|
|
|
+ [params setValue:price forKey:@"price"];
|
|
|
|
|
+ [params setValue:bestseller forKey:@"bestseller"];
|
|
|
|
|
+ [params setValue:modelname forKey:@"modelName"];
|
|
|
|
|
+ [params setValue:modeldescrip forKey:@"modelDescription"];
|
|
|
|
|
+
|
|
|
|
|
+ [params setValue:[NSString stringWithFormat:@"%d",price_template] forKey:@"price_template"];
|
|
|
|
|
+ [params setValue:[NSString stringWithFormat:@"%d",customid] forKey:@"custom_id"];
|
|
|
|
|
+ [params setValue:category forKey:@"category"];
|
|
|
|
|
+ [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
|
|
|
|
|
+ [params setValue:[NSString stringWithFormat:@"%d",sort_by] forKey:@"sort_by"];
|
|
|
|
|
+ [params setValue:[NSString stringWithFormat:@"%ld",limit] forKey:@"limit"];
|
|
|
|
|
+ [params setValue:[NSString stringWithFormat:@"%ld",offset] forKey:@"offset"];
|
|
|
|
|
+ [params setValue:filter forKey:@"filter"];
|
|
|
|
|
+ [params setValue:keyword forKey:@"keyword"];
|
|
|
|
|
+
|
|
|
|
|
+ [params setObject:ScreenCodeCategory forKey:kScreenName];
|
|
|
|
|
+ if ([addTo isEqualToString:@"cart"]) {
|
|
|
|
|
+ [params setObject:@"Add To Cart" forKey:kAction];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if(appDelegate.offline_mode)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
|
|
+ NSMutableDictionary* json = [[OLDataProvider offline_categoryaddall:params] mutableCopy];
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+ result(json);
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ NSString * uuid= [[NSUUID UUID] UUIDString];
|
|
|
|
|
+ params[@"resultSerial"]=uuid;
|
|
|
|
|
+ __block bool bbreak = false;
|
|
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
|
|
+ for(int i=0;i<150;i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ // NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
|
|
|
|
|
+ // result_params[@"resultSerial"]=uuid;
|
|
|
|
|
+ if(bbreak)
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+ [self request_interface:URL_CATEGORYADDALL parameters:params err_record_url:nil completionHandler:^(NSMutableDictionary *resulti) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if([resulti[@"result"] intValue]==2|| [resulti[@"result"] intValue] == 8)
|
|
|
|
|
+ {
|
|
|
|
|
+ bbreak=true;
|
|
|
|
|
+ result(resulti);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ } retry:0];
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ sleep(2);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+//
|
|
|
|
|
+// NSData* json= nil;
|
|
|
|
|
+//
|
|
|
|
|
+// if(appDelegate.offline_mode)
|
|
|
|
|
+// {
|
|
|
|
|
+// json= [OLDataProvider offline_categoryaddall:params];
|
|
|
|
|
+// }
|
|
|
|
|
+// else
|
|
|
|
|
+// {
|
|
|
|
|
+// if(![self IsNetworkAvailable])
|
|
|
|
|
+// return [RAUtils error_json:RESULT_NET_NOTAVAILABLE err_msg:nil];
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// NSError *error=nil;
|
|
|
|
|
+//
|
|
|
|
|
+// NSString * uuid= [[NSUUID UUID] UUIDString];
|
|
|
|
|
+// params[@"resultSerial"]=uuid;
|
|
|
|
|
+//
|
|
|
|
|
+// for(int i=0;i<150;i++)
|
|
|
|
|
+// {
|
|
|
|
|
+// // NSMutableDictionary* result_params = [[NSMutableDictionary alloc]init];
|
|
|
|
|
+//// result_params[@"resultSerial"]=uuid;
|
|
|
|
|
+// json=[self get_json:URL_CATEGORYADDALL parameters:params];
|
|
|
|
|
+// if(json!=nil)
|
|
|
|
|
+// {
|
|
|
|
|
+//
|
|
|
|
|
+// NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
|
|
|
|
|
+// int resultInt = [jsobj[@"result"] intValue];
|
|
|
|
|
+// if(resultInt == 2 || resultInt == 8)
|
|
|
|
|
+// {
|
|
|
|
|
+// break;
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// sleep(2);
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+// if(json==nil)
|
|
|
|
|
+// return nil;
|
|
|
|
|
+// NSError *error=nil;
|
|
|
|
|
+// NSDictionary *jsobj = [NSJSONSerialization JSONObjectWithData:json options:NSJSONReadingMutableLeaves error:&error];
|
|
|
|
|
+// return jsobj;
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
@end
|
|
@end
|