|
|
@@ -17,6 +17,8 @@
|
|
|
#import "SelectUploadOrderViewController.h"
|
|
|
#import "iSalesDB.h"
|
|
|
#import "iSalesNetwork.h"
|
|
|
+#import "NotificationNameCenter.h"
|
|
|
+#import "CustomerEditViewController.h"
|
|
|
|
|
|
|
|
|
#define UNZIP_OPEN_FAILED 0
|
|
|
@@ -462,6 +464,11 @@ void UncaughtExceptionHandler(NSException *exception) {
|
|
|
NSString *sql = [NSString stringWithFormat:@"insert into errlog (errmsg,params) values ('%@','%@');",versionNum,content];
|
|
|
|
|
|
[iSalesDB execSql:sql];
|
|
|
+
|
|
|
+ NSString *cachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject];
|
|
|
+ NSString *urgencyFile = [cachePath stringByAppendingPathComponent:@"urgency"];
|
|
|
+ AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
|
|
|
+ [NSKeyedArchiver archiveRootObject:appDelegate.urgencyDic toFile:urgencyFile];
|
|
|
}
|
|
|
|
|
|
- (void)handleErrorLog {
|
|
|
@@ -518,6 +525,78 @@ void UncaughtExceptionHandler(NSException *exception) {
|
|
|
}
|
|
|
|
|
|
|
|
|
+}
|
|
|
+
|
|
|
+- (void)handleUrgencyFile {
|
|
|
+
|
|
|
+// id root = self.window.rootViewController;
|
|
|
+// NSArray *child = self.window.rootViewController.childViewControllers;
|
|
|
+//
|
|
|
+// NSLog(@"rootViewController:%@",root);
|
|
|
+// NSLog(@"child: %@",child);
|
|
|
+
|
|
|
+ NSLog(@"urgencyDic: %@",self.urgencyDic);
|
|
|
+ if (self.urgencyDic.allKeys.count) {
|
|
|
+
|
|
|
+ MainViewController *mainVC = [self.window.rootViewController.childViewControllers lastObject];
|
|
|
+
|
|
|
+ NSString *user = [self.urgencyDic objectForKey:@"user"];
|
|
|
+ if (![user isEqualToString:self.user]) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ BOOL offline_mode = [[self.urgencyDic objectForKey:@"offline_mode"] boolValue];
|
|
|
+ if (!((self.offline_mode && offline_mode) || (!self.offline_mode && !offline_mode))) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ NSString *firstClassName = [self.urgencyDic objectForKey:@"firt_class_name"];
|
|
|
+
|
|
|
+ NSString *changed_data_key = [NSString stringWithFormat:@"%@_changed_data",firstClassName];
|
|
|
+ NSMutableDictionary *changed_data = [self.urgencyDic objectForKey:changed_data_key];
|
|
|
+
|
|
|
+ if ([firstClassName isEqualToString:@"CustomerEditViewController"]) {
|
|
|
+ // CustomerEditViewController
|
|
|
+
|
|
|
+ NSString *contact_id = [self.urgencyDic objectForKey:@"contact_id"];
|
|
|
+
|
|
|
+ NSMutableDictionary * params= [[NSMutableDictionary alloc] init];
|
|
|
+
|
|
|
+
|
|
|
+ [params setValue:contact_id forKey:@"contact_id"];
|
|
|
+ CustomerEditViewController * cuseditVC =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"CustomerEditViewController"];
|
|
|
+
|
|
|
+ cuseditVC.bnewcustomer=false;
|
|
|
+ cuseditVC.url_type = URL_REMOTE;
|
|
|
+ cuseditVC.request_url=URL_EDIT_CUSTOMER;
|
|
|
+
|
|
|
+ cuseditVC.params = params;
|
|
|
+ cuseditVC.changed_data = changed_data;
|
|
|
+
|
|
|
+// cuseditVC.delegate=self;
|
|
|
+
|
|
|
+
|
|
|
+ [[mainVC navigationController] setNavigationBarHidden:NO animated:NO];
|
|
|
+ [mainVC.navigationController pushViewController:cuseditVC animated:false];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ } else if ([firstClassName isEqualToString:@"CreateOrderViewController"]) {
|
|
|
+ // CreateOrderViewController
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ } else if ([firstClassName isEqualToString:@"AddressEditorViewController"]) {
|
|
|
+ // AddressEditorViewController
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- (void)initialExceptionHandler {
|
|
|
@@ -529,16 +608,28 @@ void UncaughtExceptionHandler(NSException *exception) {
|
|
|
NSString *urgencyFile = [cachePath stringByAppendingPathComponent:@"urgency"];
|
|
|
|
|
|
if ([manager fileExistsAtPath:urgencyFile]) {
|
|
|
- _urgencyDic = [NSMutableDictionary dictionaryWithContentsOfFile:urgencyFile];
|
|
|
+
|
|
|
+ _urgencyDic = [NSKeyedUnarchiver unarchiveObjectWithFile:urgencyFile];
|
|
|
+
|
|
|
+// _urgencyDic = [NSMutableDictionary dictionaryWithContentsOfFile:urgencyFile];
|
|
|
} else {
|
|
|
_urgencyDic = [NSMutableDictionary dictionary];
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+- (void)becomeObserver {
|
|
|
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleUrgencyFile) name:LoginOK_HandleUrgencyFile_Notification object:nil];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)dealloc {
|
|
|
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
+}
|
|
|
+
|
|
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
|
|
{
|
|
|
[self initialExceptionHandler];
|
|
|
+ [self becomeObserver];
|
|
|
|
|
|
[DefaultAppearance init_appearance];
|
|
|
|