Proyectos de Subversion Iphone Microlearning - Inconcert

Rev

Rev 2 | Rev 17 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 2 Rev 15
Línea 8... Línea 8...
8
import Foundation
8
import Foundation
9
import SwiftyJSON
9
import SwiftyJSON
Línea 10... Línea 10...
10
 
10
 
11
class DataService
11
class DataService
-
 
12
{
12
{
13
    private let database = Database.sharedInstance
Línea 13... Línea 14...
13
    private var appData = AppData.sharedInstance
14
    private var appData = AppData.sharedInstance
Línea 25... Línea 26...
25
        let userUuid = appData.userUuid
26
        let userUuid = appData.userUuid
26
        var json : [String: Any]
27
        var json : [String: Any]
27
        var sync : SyncModel
28
        var sync : SyncModel
28
        var userLog : UserLogModel
29
        var userLog : UserLogModel
Línea -... Línea 30...
-
 
30
 
-
 
31
        let db = database.open()
-
 
32
        
29
 
33
        
30
        let syncDao = SyncDao.sharedInstance
34
        let syncDao = SyncDao(db : db)
31
        let progressDao = ProgressDao.sharedInstance
35
        let progressDao = ProgressDao(db : db)
Línea 32... Línea 36...
32
        let userLogDao = UserLogDao.sharedInstance
36
        let userLogDao = UserLogDao(db : db)
Línea 33... Línea 37...
33
            
37
            
34
        var progressCapsule = progressDao.selectByCapsuleUuidAndUserUuid(capsuleUuid: capsuleModel.uuid, userUuid: userUuid)
38
        var progressCapsule = progressDao.selectByCapsuleUuidAndUserUuid(capsuleUuid: capsuleModel.uuid, userUuid: userUuid)
Línea 109... Línea 113...
109
                    sync.data = data
113
                    sync.data = data
110
                }
114
                }
Línea 111... Línea 115...
111
                      
115
                      
112
            syncDao.insert(record : sync);
116
            syncDao.insert(record : sync);
-
 
117
        }
-
 
118
        
113
        }
119
        database.close()
Línea 114... Línea 120...
114
    }
120
    }
115
    
121
    
116
    func incompleteSlide (slide: SlideModel)
122
    func incompleteSlide (slide: SlideModel)
Línea 120... Línea 126...
120
       //                                 object: nil, userInfo: ["slideUuid": slide.uuid])
126
       //                                 object: nil, userInfo: ["slideUuid": slide.uuid])
121
    }
127
    }
Línea 122... Línea 128...
122
    
128
    
123
    func completeSlide( slide : SlideModel)
129
    func completeSlide( slide : SlideModel)
-
 
130
    {
-
 
131
        let db = database.open()
-
 
132
        let slideDao = SlideDao(db: db)
-
 
133
        let capsuleDao = CapsuleDao(db: db)
-
 
134
        let topicDao = TopicDao(db: db)
-
 
135
        let syncDao = SyncDao(db: db)
-
 
136
        let progressDao = ProgressDao(db: db)
-
 
137
        let userLogDao = UserLogDao(db: db)
-
 
138
        
124
    {
139
        
125
        var updateCapsuleAndTopics = false
140
        var updateCapsuleAndTopics = false
126
        let now = Date()
141
        let now = Date()
127
        let dateFormatter = DateFormatter()
142
        let dateFormatter = DateFormatter()
128
        dateFormatter.dateFormat = Constants.FORMAT_DATETIME_SERVICE
143
        dateFormatter.dateFormat = Constants.FORMAT_DATETIME_SERVICE
129
        let dateOn = dateFormatter.string(from: now)
144
        let dateOn = dateFormatter.string(from: now)
130
            
-
 
131
        let slideDao = SlideDao.sharedInstance
-
 
132
           
-
 
133
        let capsuleDao = CapsuleDao.sharedInstance
145
        
134
        let capsule = capsuleDao.selectByUuid(uuid: slide.capsuleUuid)
-
 
135
            
-
 
136
            
-
 
137
        let topicDao = TopicDao.sharedInstance
146
        let capsule = capsuleDao.selectByUuid(uuid: slide.capsuleUuid)
138
        let topic = topicDao.selectByUuid(uuid: slide.topicUuid)
-
 
Línea 139... Línea 147...
139
 
147
        let topic = topicDao.selectByUuid(uuid: slide.topicUuid)
140
 
148
 
141
        let userUuid = appData.userUuid
149
        let userUuid = appData.userUuid
142
        var json : [String: Any]
150
        var json : [String: Any]
Línea 143... Línea -...
143
        var sync : SyncModel
-
 
144
        var userLog : UserLogModel
-
 
145
 
-
 
-
 
151
        var sync : SyncModel
Línea 146... Línea 152...
146
        let syncDao = SyncDao.sharedInstance
152
        var userLog : UserLogModel
147
        let progressDao = ProgressDao.sharedInstance
153
 
148
        let userLogDao = UserLogDao.sharedInstance
154
        
Línea 386... Línea 392...
386
            
392
            
387
            print("Notification: \(Constants.NOTIFICATION_NAME_CHANGE_PERCENTAJE_COMPLETED_TOPIC) ")
393
            print("Notification: \(Constants.NOTIFICATION_NAME_CHANGE_PERCENTAJE_COMPLETED_TOPIC) ")
Línea 388... Línea 394...
388
            NotificationCenter.default.post(name: Constants.NOTIFICATION_NAME_CHANGE_PERCENTAJE_COMPLETED_TOPIC, object: nil, userInfo:["topicUuid": slide.topicUuid])
394
            NotificationCenter.default.post(name: Constants.NOTIFICATION_NAME_CHANGE_PERCENTAJE_COMPLETED_TOPIC, object: nil, userInfo:["topicUuid": slide.topicUuid])
-
 
395
            
-
 
396
        }
Línea 389... Línea 397...
389
            
397
        
Línea 390... Línea 398...
390
        }
398
        database.close()
391
          
399
          
-
 
400
    }
392
    }
401
 
393
 
402
    
394
    
403
    
395
    
404
    
396
    
405
    public func syncFromServer(json : JSON?, refresh : Bool = false) -> Bool
397
    public func syncFromServer(json : JSON?, refresh : Bool = false) -> Bool
406
    {
398
    {
407
        let db = database.open()
399
        let companyDao = CompanyDao.sharedInstance
408
        let companyDao = CompanyDao(db: db)
400
        let topicDao = TopicDao.sharedInstance
409
        let topicDao = TopicDao(db: db)
401
        let capsuleDao = CapsuleDao.sharedInstance
410
        let capsuleDao = CapsuleDao(db: db)
402
        let slideDao = SlideDao.sharedInstance
411
        let slideDao = SlideDao(db: db)
Línea 403... Línea 412...
403
        let quizDao = QuizDao.sharedInstance
412
        let quizDao = QuizDao(db: db)
404
        let questionDao = QuestionDao.sharedInstance
413
        let questionDao = QuestionDao(db: db)
405
        let answerDao = AnswerDao.sharedInstance
414
        let answerDao = AnswerDao(db: db)
Línea 793... Línea 802...
793
                }
802
                }
Línea 794... Línea 803...
794
 
803
 
795
            }
804
            }
Línea 796... Línea -...
796
        }
-
 
-
 
805
        }
797
         
806
         
798
        
807
        database.close()
Línea 799... Línea 808...
799
        return true;
808
        return true;