فهرست منبع

offline_login增加first_name,last_name
修改Cart、Contact List、Wish List、Item Search和Search的数据加载,使用队列操作。

Pen Li 9 سال پیش
والد
کامیت
448760ea57

BIN
RedAnt ERP Mobile/RedAnt ERP Mobile.xcworkspace/xcuserdata/macmini1.xcuserdatad/UserInterfaceState.xcuserstate


+ 35 - 1
RedAnt ERP Mobile/common/Functions/cart/CartViewController.m

@@ -42,10 +42,21 @@
 @property (strong, nonatomic) IBOutlet UIButton *placeOrderButton;
 @property (strong, nonatomic) IBOutlet UIButton *cancelOrderButton;
 
+@property (nonatomic,strong) NSOperationQueue *dataOperationQueue;
+
 @end
 
 @implementation CartViewController
 
+- (NSOperationQueue *)dataOperationQueue {
+    if (!_dataOperationQueue) {
+        _dataOperationQueue = [[NSOperationQueue alloc] init];
+        _dataOperationQueue.maxConcurrentOperationCount = 1;
+    }
+    return _dataOperationQueue;
+}
+
+
 - (void)dealloc {
     [[NSNotificationCenter defaultCenter] removeObserver:self];
 }
@@ -535,8 +546,11 @@
     [[self navigationController] setNavigationBarHidden:YES animated:NO];
     
 }
--(void) reload_data
+-(void) operation_reload_data
 {
+    if (self.dataOperationQueue.operationCount > 1) {
+        return;
+    }
     dispatch_async(dispatch_get_main_queue(), ^{
         if(self.isrefreshing)
             return;
@@ -577,6 +591,11 @@
                 
                 int result=[[cart_json valueForKey:@"result"] intValue];
                 
+                if (self.dataOperationQueue.operationCount > 1) {
+                    self.isrefreshing=false;
+                    return;
+                }
+                
                 if(result==2||result==1||result==0)
                 {
                     
@@ -610,6 +629,21 @@
     });
     //    [[self navigationController] setNavigationBarHidden:YES animated:NO];
 }
+
+- (void) reload_data {
+    __weak typeof(self) weakself = self;
+    NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
+        
+        if (weakself) {
+            __strong typeof(weakself) strongself = weakself;
+            [strongself operation_reload_data];
+        }
+        
+    }];
+    
+    [self.dataOperationQueue addOperation:operation];
+}
+
 -(void)manually_refresh
 {
     UIRefreshControl *reF = (UIRefreshControl *)[self.view viewWithTag:200];

+ 33 - 3
RedAnt ERP Mobile/common/Functions/contact/ContactListViewController.m

@@ -21,10 +21,21 @@
 
 @interface ContactListViewController ()
 
+@property (nonatomic,strong) NSOperationQueue *dataOperationQueue;
+
 @end
 
 @implementation ContactListViewController
 
+- (NSOperationQueue *)dataOperationQueue {
+    if (!_dataOperationQueue) {
+        _dataOperationQueue = [[NSOperationQueue alloc] init];
+        _dataOperationQueue.maxConcurrentOperationCount = 1;
+    }
+    return _dataOperationQueue;
+}
+
+
 - (void)awakeFromNib {
     self.edit_icon = true;
     self.assig_icon = true;
@@ -229,9 +240,11 @@
     
 }
 
--(void) loadpage
+-(void) operation_loadpage
 {
-    
+    if (self.dataOperationQueue.operationCount > 1) {
+        return;
+    }
         dispatch_async(dispatch_get_main_queue(), ^{
     if(self.isrefreshing)
         return;
@@ -270,7 +283,10 @@ self.label_net_err.hidden=true;
         dispatch_async(dispatch_get_main_queue(), ^{
             
             [self.mum stopAnimating];
-            
+            self.isrefreshing=false;
+            if (self.dataOperationQueue.operationCount > 1) {
+                return ;
+            }
             
             
             if([[content valueForKey:@"result"] intValue]==2)
@@ -336,6 +352,20 @@ self.label_net_err.hidden=true;
         });
 }
 
+-(void) loadpage {
+    __weak typeof(self) weakself = self;
+    NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
+        
+        if (weakself) {
+            __strong typeof(weakself) strongself = weakself;
+            [strongself operation_loadpage];
+        }
+        
+    }];
+    
+    [self.dataOperationQueue addOperation:operation];
+}
+
 - (void)loadmore
 {
     //    self.btnrefresh.enabled = NO;

+ 57 - 6
RedAnt ERP Mobile/common/Functions/search+itemsearch/ItemSearchViewController.m

@@ -31,11 +31,20 @@
 
 @property (nonatomic,assign) BOOL addAll;
 
+@property (nonatomic,strong) NSOperationQueue *dataOperationQueue;
 
 @end
 
 @implementation ItemSearchViewController
 
+- (NSOperationQueue *)dataOperationQueue {
+    if (!_dataOperationQueue) {
+        _dataOperationQueue = [[NSOperationQueue alloc] init];
+        _dataOperationQueue.maxConcurrentOperationCount = 1;
+    }
+    return _dataOperationQueue;
+}
+
 -(void) reload_container_getdata:(bool)update_data
 {
     
@@ -479,8 +488,11 @@
 }
 
 #pragma mark get data
--(void) loadMore
+-(void) operation_loadMore
 {
+    if (self.dataOperationQueue.operationCount > 1) {
+        return ;
+    }
     dispatch_async(dispatch_get_main_queue(), ^{
         if(self.loadall )
         {
@@ -506,7 +518,10 @@
                                      ];
         dispatch_async(dispatch_get_main_queue(), ^{
             [self.mum stopAnimating];
-            
+            self.isrefreshing=false;
+            if (self.dataOperationQueue.operationCount > 1) {
+                return ;
+            }
             NSDictionary* more_items=[category_more objectForKey:@"items"];
             if([[category_more valueForKey:@"result"] intValue]==2)
             {
@@ -547,7 +562,7 @@
             {
                 [RAUtils message_alert:[category_more valueForKey:@"err_msg"] title:@"Search" controller:self] ;
             }
-            self.isrefreshing=false;
+            
             
         });
         //        dispatch_async(dispatch_get_main_queue(), ^{
@@ -592,10 +607,27 @@
     });
     });
 }
--(void) reload
-{
+
+-(void) loadMore {
+    __weak typeof(self) weakself = self;
+    NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
+        
+        if (weakself) {
+            __strong typeof(weakself) strongself = weakself;
+            [strongself operation_loadMore];
+        }
+        
+    }];
     
+    [self.dataOperationQueue addOperation:operation];
+}
+
+-(void) operation_reload
+{
     
+    if (self.dataOperationQueue.operationCount > 1) {
+        return ;
+    }
      dispatch_async(dispatch_get_main_queue(), ^{
          
          
@@ -624,6 +656,11 @@
         
         dispatch_async(dispatch_get_main_queue(), ^{
             [self.mum stopAnimating];
+            self.isrefreshing=false;
+            if (self.dataOperationQueue.operationCount > 1) {
+                return ;
+            }
+            
             self.category_data = [category_data mutableCopy];
             [self.collectionview reloadData];
             if([[category_data valueForKey:@"result"] intValue]==2)
@@ -649,13 +686,27 @@
                 [RAUtils message_alert:[category_data valueForKey:@"err_msg"] title:@"Search" controller:self] ;
             }
             
-            self.isrefreshing=false;
+            
             
           });
         });
     });
 }
 
+-(void) reload {
+    __weak typeof(self) weakself = self;
+    NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
+        
+        if (weakself) {
+            __strong typeof(weakself) strongself = weakself;
+            [strongself operation_reload];
+        }
+        
+    }];
+    
+    [self.dataOperationQueue addOperation:operation];
+}
+
 /*
  #pragma mark - Navigation
  

+ 58 - 3
RedAnt ERP Mobile/common/Functions/search+itemsearch/SearchViewController.m

@@ -28,10 +28,21 @@
 
 @property (nonatomic,assign) BOOL addAll;
 
+@property (nonatomic,strong) NSOperationQueue *dataOperationQueue;
+
+
 @end
 
 @implementation SearchViewController
 
+- (NSOperationQueue *)dataOperationQueue {
+    if (!_dataOperationQueue) {
+        _dataOperationQueue = [[NSOperationQueue alloc] init];
+        _dataOperationQueue.maxConcurrentOperationCount = 1;
+    }
+    return _dataOperationQueue;
+}
+
 -(void) reload_container_getdata:(bool)update_data
 {
     if(self.disable_refresh)
@@ -1166,8 +1177,11 @@
     });
 }
 
--(void) loadMore
+-(void) operation_loadMore
 {
+    if (self.dataOperationQueue.operationCount > 1) {
+        return;
+    }
     dispatch_async(dispatch_get_main_queue(), ^{
         
         if(self.loadall)
@@ -1193,6 +1207,10 @@
         NSDictionary* category_more=[iSalesNetwork Search:self.offset limit:20 keywords:self.keywords matchfull:self.loadmore_matchfull];
         dispatch_async(dispatch_get_main_queue(), ^{
             [self.mum stopAnimating];
+            self.isrefreshing=false;
+            if (self.dataOperationQueue.operationCount > 1) {
+                return;
+            }
             
             NSDictionary* more_items=[category_more objectForKey:@"items"];
             if([[category_more valueForKey:@"result"] intValue]==2)
@@ -1277,9 +1295,26 @@
     });
         });
 }
--(void) reload
-{
+
+-(void) loadMore {
+    __weak typeof(self) weakself = self;
+    NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
+        
+        if (weakself) {
+            __strong typeof(weakself) strongself = weakself;
+            [strongself operation_loadMore];
+        }
+        
+    }];
     
+    [self.dataOperationQueue addOperation:operation];
+}
+
+-(void) operation_reload
+{
+    if (self.dataOperationQueue.operationCount > 1) {
+        return;
+    }
     dispatch_async(dispatch_get_main_queue(), ^{
         if(self.isrefreshing)
             return;
@@ -1304,6 +1339,11 @@
         dispatch_async(dispatch_get_main_queue(), ^{
             
             [self.mum stopAnimating];
+            self.isrefreshing=false;
+            if (self.dataOperationQueue.operationCount > 1) {
+                return;
+            }
+            
             self.category_data = [category_data mutableCopy];
             [self.collectionview reloadData];
             
@@ -1345,6 +1385,21 @@
         });
     });
 }
+
+-(void) reload {
+    __weak typeof(self) weakself = self;
+    NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
+        
+        if (weakself) {
+            __strong typeof(weakself) strongself = weakself;
+            [strongself operation_reload];
+        }
+        
+    }];
+    
+    [self.dataOperationQueue addOperation:operation];
+}
+
 -(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
 {
     [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];

+ 33 - 2
RedAnt ERP Mobile/common/Functions/watchlist/WatchListViewController.m

@@ -31,10 +31,21 @@
 @property (nonatomic,strong) SortButton *sortButton;
 @property (nonatomic,strong) UILabel *qtyLabel;
 
+@property (nonatomic,strong) NSOperationQueue *dataOperationQueue;
+
 @end
 
 @implementation WatchListViewController
 
+- (NSOperationQueue *)dataOperationQueue {
+    if (!_dataOperationQueue) {
+        _dataOperationQueue = [[NSOperationQueue alloc] init];
+        _dataOperationQueue.maxConcurrentOperationCount = 1;
+    }
+    return _dataOperationQueue;
+}
+
+
 -(void) logout
 {
     self.content_data = nil;
@@ -541,10 +552,12 @@
     [[self navigationController] setNavigationBarHidden:YES animated:NO];
 }
 
--(void) reload_data
+-(void) operation_reload_data
 {
     
-    
+    if (self.dataOperationQueue.operationCount > 1) {
+        return;
+    }
 
     dispatch_async(dispatch_get_main_queue(), ^{
         if(self.isrefreshing)
@@ -573,6 +586,11 @@
         dispatch_async(dispatch_get_main_queue(), ^{
             
             [self.mum stopAnimating];
+            self.isrefreshing=false;
+            if (self.dataOperationQueue.operationCount > 1) {
+                return ;
+            }
+            
             int result=[[cart_json valueForKey:@"result"] intValue];
             self.content_data = [cart_json mutableCopy];
             [self.itemListTable reloadData];
@@ -601,6 +619,19 @@
         });
 }
 
+-(void) reload_data {
+    __weak typeof(self) weakself = self;
+    NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
+        
+        if (weakself) {
+            __strong typeof(weakself) strongself = weakself;
+            [strongself operation_reload_data];
+        }
+        
+    }];
+    
+    [self.dataOperationQueue addOperation:operation];
+}
 
 
 - (void)didReceiveMemoryWarning

+ 3 - 1
RedAnt ERP Mobile/common/data_provider/iSalesDB.m

@@ -698,7 +698,7 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
     NSString* create_offline_setting=@"CREATE TABLE IF NOT EXISTS offline_setting ( _id INTEGER PRIMARY KEY, name VARCHAR(20),value VARCHAR(40));";
     
     
-    NSString* create_offline_login=@"CREATE TABLE IF NOT EXISTS offline_login ( _id INTEGER PRIMARY KEY, username VARCHAR(40),password VARCHAR(40), can_show_price integer ,can_see_price integer,contact_id VARCHAR(20),user_type integer,can_cancel_order integer,can_set_cart_price integer,can_create_portfolio integer, can_delete_order integer,can_submit_order integer,can_set_tearsheet_price integer,can_create_order integer, can_update_contact_info integer, mode VARCHAR(20), default_price text, price text, user_id integer,sales_code text);";
+    NSString* create_offline_login=@"CREATE TABLE IF NOT EXISTS offline_login ( _id INTEGER PRIMARY KEY, username VARCHAR(40),password VARCHAR(40), can_show_price integer ,can_see_price integer,contact_id VARCHAR(20),user_type integer,can_cancel_order integer,can_set_cart_price integer,can_create_portfolio integer, can_delete_order integer,can_submit_order integer,can_set_tearsheet_price integer,can_create_order integer, can_update_contact_info integer, mode VARCHAR(20), default_price text, price text, user_id integer,sales_code text,first_name text,last_name text);";
     
     NSString* create_offline_order=@"CREATE TABLE IF NOT EXISTS offline_order ( _id INTEGER PRIMARY KEY,so_id text, order_id text ,status integer, submit_as integer,general_notes TEXT ,internal_notes text,sales_rep TEXT,create_by TEXT, total_price float, erpOrderStatus integer, logist text, lift_gate integer, logistic_note text, paymentType text, credit_card_first_name text, credit_card_last_name text, credit_card_address1 text, credit_card_address2 text, credit_card_zipcode text, credit_card_type text, credit_card_number text, credit_card_security_code text, credit_card_expiration_month text , credit_card_expiration_year text,credit_card_city text, credit_card_state text,customer_cid text,customer_contact text,customer_email text,customer_phone text,customer_fax text,receive_cid text,receive_name text,receive_ext text,receive_contact text, receive_phone text,receive_fax text,receive_email text,sender_cid text,sender_name text,sender_ext text,sender_contact text, sender_phone text,sender_fax text,sender_email text,shipping_billto_cid text,shipping_billto_name text,shipping_billto_ext text,shipping_billto_contact text, shipping_billto_phone text,shipping_billto_fax text,shipping_billto_email text,billing_cid text,billing_name text,billing_ext text,billing_contact text, billing_phone text,billing_fax text,billing_email text,returnto_cid text,returnto_name text,returnto_ext text,returnto_contact text, returnto_phone text,returnto_fax text,returnto_email text, must_call int,poNumber text,comments text,comments_ext text,paymentsAndCredits float,shipping float,lift_gate_value float,handling_fee_value float,sign_picpath text,sync_data text,ship_via text,create_time TIMESTAMP default (datetime('now', 'localtime')),modify_time TIMESTAMP default (datetime('now', 'localtime')),vendor_no char,warehouse_name char,terms char,etd TIMESTAMP,carrier char ,sales_terms char,port_destination char);";
     
@@ -825,6 +825,8 @@ void decryptfield (sqlite3_context *context, int argc, sqlite3_value **argv) {
     
     [self alterTable:@"offline_cart" columns:@"client_reference char" rename:NO db:db];
     
+    [self alterTable:@"offline_login" columns:@"first_name text;last_name text" rename:NO db:db];
+    
     [self alterTable:@"offline_pdf" columns:@"off_params text" rename:NO db:db];
     
     [self execSql:create_order_trigger db:db];

+ 1 - 1
RedAnt ERP Mobile/iSales-NPD/config.h

@@ -10,7 +10,7 @@
 #define RedAnt_ERP_Mobile_config_h
 #define BUILD_NPD
 
-//#define test_server
+#define test_server
 #define exception_switch 1
 
 //#define ab_lager @"Delivery price"