Commit 9c6ac187 authored by AvatarC's avatar AvatarC

不同用户:用不同的db

parent 12a6d2cd
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
//既有权限又被选择的 //既有权限又被选择的
- (NSArray *)functionsHasPermissionAndIsSelected; - (NSArray *)functionsHasPermissionAndIsSelected;
- (void)deleteTables;
#pragma displayFunction #pragma displayFunction
......
...@@ -30,7 +30,14 @@ ...@@ -30,7 +30,14 @@
- (BOOL)openDb { - (BOOL)openDb {
// NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); // NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
NSString *path = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject]; NSString *path = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject];
NSString *dbPath = [path stringByAppendingString:@"function.db"]; ICRUserUtil *user = [ICRUserUtil sharedInstance];
NSString *dbPath ;//= [path stringByAppendingString:@"function.db"];
if (user.userCode) {
dbPath = [NSString stringWithFormat:@"%@%@function.db",path,user.userCode];
} else {
dbPath = [path stringByAppendingString:@"function.db"];
}
self.dataBase = [FMDatabase databaseWithPath:dbPath]; self.dataBase = [FMDatabase databaseWithPath:dbPath];
CLog(@"dbPath = %@",dbPath); CLog(@"dbPath = %@",dbPath);
BOOL isOpen = [_dataBase open]; BOOL isOpen = [_dataBase open];
...@@ -48,8 +55,23 @@ ...@@ -48,8 +55,23 @@
} }
- (void)deleteTables {
if ([self openDb]) {
[self functionTableDelete];
[self displayFunctionTableDelete];
}
}
- (BOOL)functionTableDelete {
NSString *delSql = @"delete from function";
BOOL work = [_dataBase executeQuery:delSql];
return work;
}
- (BOOL)displayFunctionTableDelete {
NSString *delSql = @"delete from displayFunction";
BOOL work = [_dataBase executeQuery:delSql];
return work;
}
- (BOOL)functionTableCreate { - (BOOL)functionTableCreate {
// if (![_dataBase open]) { // if (![_dataBase open]) {
// [self openDb]; // [self openDb];
......
...@@ -131,6 +131,7 @@ ...@@ -131,6 +131,7 @@
//#else //#else
// //
//#endif //#endif
} }
#pragma mark - Logic #pragma mark - Logic
...@@ -169,8 +170,10 @@ ...@@ -169,8 +170,10 @@
#pragma 可以开新线程 ,待优化 #pragma 可以开新线程 ,待优化
//当登陆成功时就建立功能数据表 //当登陆成功时就建立功能数据表
// [[GXFFunctionDB sharedInstance] deleteTables];
[[GXFFunctionDB sharedInstance]createTables]; [[GXFFunctionDB sharedInstance]createTables];
//完成对初始化数据书库的操作 //完成对初始化数据书库的操作
if (![[GXFFunctionDBHelper sharedInstance] successInsertOriginFunctions]) { if (![[GXFFunctionDBHelper sharedInstance] successInsertOriginFunctions]) {
[[GXFFunctionDBHelper sharedInstance] insertAllOriginFunctions]; [[GXFFunctionDBHelper sharedInstance] insertAllOriginFunctions];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment