Proyectos de Subversion Iphone Microlearning - Nuevo Interface

Rev

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

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