Proyectos de Subversion Iphone Microlearning - Inconcert

Rev

Rev 13 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 13 Rev 17
Línea 6... Línea 6...
6
//
6
//
Línea 7... Línea 7...
7
 
7
 
Línea 8... Línea 8...
8
import Foundation
8
import Foundation
9
 
-
 
Línea 10... Línea -...
10
class AppData {
-
 
11
    private let standardPreference = UserDefaults.standard
-
 
12
 
9
 
13
 
10
class AppData {
14
    
11
 
Línea 15... Línea 12...
15
    var deviceUuid : String = ""
12
    var deviceUuid : String = ""
Línea 37... Línea 34...
37
    var refreshContentMessageShowPending : Bool = false
34
    var refreshContentMessageShowPending : Bool = false
38
    var refreshContentActionRequired : Bool = false
35
    var refreshContentActionRequired : Bool = false
39
    var signoutActionRequired : Bool = false
36
    var signoutActionRequired : Bool = false
Línea 40... Línea -...
40
 
-
 
41
    
-
 
Línea -... Línea 37...
-
 
37
 
42
        /*
38
    
43
        private let appDao = AppDao.sharedInstance
39
 
44
 
40
 
Línea 45... Línea 41...
45
*/
41
 
46
    static let sharedInstance: AppData = {
42
    static let sharedInstance: AppData = {
Línea 53... Línea 49...
53
        load()
49
        load()
54
    }
50
    }
Línea 55... Línea 51...
55
    
51
    
56
    func load() -> Void
52
    func load() -> Void
-
 
53
    {
-
 
54
        let appDao = AppDao()
Línea 57... Línea -...
57
    {
-
 
58
        
-
 
59
        
-
 
60
        
55
        let appModel = appDao.selectOne()
61
        
-
 
62
       // let appModel = appDao.selectOne()
-
 
63
        
56
        
64
        self.deviceUuid = standardPreference.string(forKey: Constants.PREFERENCE_DEVICE_UUID) ?? ""
57
        self.deviceUuid = appModel.deviceUuid
65
        self.devicePassword = standardPreference.string(forKey: Constants.PREFERENCE_DEVICE_PASSWORD) ?? ""
58
        self.devicePassword = appModel.devicePassword
66
        self.deviceAes = standardPreference.string(forKey: Constants.PREFERENCE_DEVICE_AES) ?? ""
59
        self.deviceAes = appModel.deviceAes
67
        
60
        
68
        self.userUuid = standardPreference.string(forKey: Constants.PREFERENCE_USER_UUID) ?? ""
61
        self.userUuid = appModel.userUuid
69
        self.userEmail = standardPreference.string(forKey: Constants.PREFERENCE_USER_EMAIL) ?? ""
62
        self.userEmail = appModel.userEmail
70
        self.userFirstname = standardPreference.string(forKey: Constants.PREFERENCE_USER_FIRSTNAME) ?? ""
63
        self.userFirstname =  appModel.userFirstname
Línea 71... Línea 64...
71
        self.userLastname = standardPreference.string(forKey: Constants.PREFERENCE_USER_LASTNAME) ?? ""
64
        self.userLastname = appModel.userLastname
72
        self.userImage = standardPreference.string(forKey: Constants.PREFERENCE_USER_IMAGE) ?? ""
65
        self.userImage = appModel.userImage
73
 
66
 
74
        self.topicUuidActive =  standardPreference.string(forKey: Constants.PREFERENCE_TOPIC_UUID_ACTIVE) ?? ""
67
        self.topicUuidActive =  appModel.topicUuidActive
75
        self.capsuleUuidActive = standardPreference.string(forKey: Constants.PREFERENCE_CAPSULE_UUID_ACTIVE) ?? ""
68
        self.capsuleUuidActive = appModel.capsuleUuidActive
76
        self.capsuleUuidOld = standardPreference.string(forKey: Constants.PREFERENCE_CAPSULE_UUID_OLD) ?? ""
69
        self.capsuleUuidOld = appModel.capsuleUuidOld
77
        self.slideUuidActive = standardPreference.string(forKey: Constants.PREFERENCE_SLIDE_UUID_ACTIVE) ?? ""
70
        self.slideUuidActive = appModel.slideUuidActive
78
        self.companyUuidActive = standardPreference.string(forKey: Constants.PREFERENCE_COMPANY_UUID_ACTIVE) ?? ""
71
        self.companyUuidActive = appModel.companyUuidActive
79
        
72
        
80
        self.fcmToken = standardPreference.string(forKey: Constants.PREFERENCE_FCM_TOKEN) ?? ""
73
        self.fcmToken = appModel.fcmToken
81
        self.lastCheckChanges = standardPreference.string(forKey: Constants.PREFERENCE_LAST_CHECK_CHANGES) ?? ""
74
        self.lastCheckChanges = appModel.lastCheckChanges
82
        self.maxDateChanges = standardPreference.string(forKey: Constants.PREFERENCE_MAX_DATE_CHANGES) ?? ""
75
        self.maxDateChanges = appModel.maxDateChanges
83
        self.urlExternalDownloaded = standardPreference.string(forKey: Constants.PREFERENCE_URL_EXTERNAL_DOWNLOADED) ?? ""
76
        self.urlExternalDownloaded = appModel.urlExternalDownloaded
84
        
77
        
Línea 85... Línea 78...
85
        self.refreshContentMessage = standardPreference.string(forKey: Constants.PREFERENCE_REFRESH_CONTENT_MESSAGE) ?? ""
78
        self.refreshContentMessage = appModel.refreshContentMessage
Línea 86... Línea 79...
86
        self.refreshContentMessageShowPending = standardPreference.bool(forKey: Constants.PREFERENCE_REFRESH_CONTENT_MESSAGE_SHOW_PENDING)
79
        self.refreshContentMessageShowPending = appModel.refreshContentMessageShowPending
87
        self.refreshContentActionRequired = standardPreference.bool(forKey: Constants.PREFERENCE_REFRESH_CONTENT_ACTION_REQUIRED)
80
        self.refreshContentActionRequired = appModel.refreshContentActionRequired
88
        
81
        
89
        self.signoutActionRequired = standardPreference.bool(forKey: Constants.PREFERENCE_SIGNOUT_ACTION_REQUIRED)
82
        self.signoutActionRequired = appModel.signoutActionRequired
Línea 90... Línea 83...
90
 
83
 
Línea 111... Línea 104...
111
        print("AppData Load UrlExternalDownloaded : \(self.urlExternalDownloaded)")
104
        print("AppData Load UrlExternalDownloaded : \(self.urlExternalDownloaded)")
Línea 112... Línea 105...
112
        
105
        
113
        print("AppData Save RefreshContentMessage : \(self.refreshContentMessage)")
106
        print("AppData Save RefreshContentMessage : \(self.refreshContentMessage)")
114
        print("AppData Save RrefreshContentMessageShowPending : \(self.refreshContentMessageShowPending)")
107
        print("AppData Save RrefreshContentMessageShowPending : \(self.refreshContentMessageShowPending)")
115
        print("AppData Save RefreshContentActionRequired : \(self.refreshContentActionRequired)")
-
 
116
         */
108
        print("AppData Save RefreshContentActionRequired : \(self.refreshContentActionRequired)")
117
        
109
      
Línea 118... Línea 110...
118
        print("AppData Save SignoutActionRequired : \(self.signoutActionRequired)")
110
        print("AppData Save SignoutActionRequired : \(self.signoutActionRequired)")
Línea 119... Línea 111...
119
        
111
        
120
    }
112
    }
121
    
113
    
122
    func save() -> Void
114
    func save() -> Void
123
    {
115
    {
124
        /*
116
        
Línea 125... Línea 117...
125
        print("AppData Save Device UUID : \(self.deviceUuid)")
117
        print("AppData Save Device UUID : \(self.deviceUuid)")
Línea 146... Línea 138...
146
        print("AppData Save RefreshContentMessage : \(self.refreshContentMessage)")
138
        print("AppData Save RefreshContentMessage : \(self.refreshContentMessage)")
147
        print("AppData Save RrefreshContentMessageShowPending : \(self.refreshContentMessageShowPending)")
139
        print("AppData Save RrefreshContentMessageShowPending : \(self.refreshContentMessageShowPending)")
148
        print("AppData Save RefreshContentActionRequired : \(self.refreshContentActionRequired)")
140
        print("AppData Save RefreshContentActionRequired : \(self.refreshContentActionRequired)")
Línea 149... Línea 141...
149
        
141
        
150
        print("AppData Save SignoutActionRequired : \(self.signoutActionRequired)")
-
 
151
        */
142
        print("AppData Save SignoutActionRequired : \(self.signoutActionRequired)")
152
        
-
 
153
 
-
 
154
        standardPreference.set(self.deviceUuid, forKey: Constants.PREFERENCE_DEVICE_UUID)
-
 
155
        
-
 
156
        standardPreference.set(self.devicePassword, forKey: Constants.PREFERENCE_DEVICE_PASSWORD)
-
 
157
        standardPreference.set(self.deviceAes, forKey: Constants.PREFERENCE_DEVICE_AES)
-
 
158
        standardPreference.set(self.userUuid, forKey: Constants.PREFERENCE_USER_UUID)
-
 
159
        standardPreference.set(self.userEmail, forKey: Constants.PREFERENCE_USER_EMAIL)
-
 
160
        standardPreference.set(self.userFirstname, forKey: Constants.PREFERENCE_USER_FIRSTNAME)
-
 
161
        standardPreference.set(self.userLastname, forKey: Constants.PREFERENCE_USER_LASTNAME)
-
 
162
        standardPreference.set(self.userImage, forKey: Constants.PREFERENCE_USER_IMAGE)
-
 
163
 
-
 
164
        standardPreference.set(self.topicUuidActive, forKey: Constants.PREFERENCE_TOPIC_UUID_ACTIVE)
-
 
165
        standardPreference.set(self.capsuleUuidActive, forKey: Constants.PREFERENCE_CAPSULE_UUID_ACTIVE)
-
 
166
        standardPreference.set(self.capsuleUuidOld, forKey: Constants.PREFERENCE_CAPSULE_UUID_OLD)
-
 
167
        standardPreference.set(self.slideUuidActive, forKey: Constants.PREFERENCE_SLIDE_UUID_ACTIVE)
-
 
168
        standardPreference.set(self.companyUuidActive, forKey: Constants.PREFERENCE_COMPANY_UUID_ACTIVE)
-
 
169
        standardPreference.set(self.fcmToken, forKey: Constants.PREFERENCE_FCM_TOKEN)
-
 
170
        standardPreference.set(self.lastCheckChanges, forKey: Constants.PREFERENCE_LAST_CHECK_CHANGES)
-
 
171
        standardPreference.set(self.maxDateChanges, forKey: Constants.PREFERENCE_MAX_DATE_CHANGES)
-
 
172
        standardPreference.set(self.urlExternalDownloaded, forKey: Constants.PREFERENCE_URL_EXTERNAL_DOWNLOADED)
-
 
173
        
-
 
174
        standardPreference.set(self.refreshContentMessage, forKey: Constants.PREFERENCE_REFRESH_CONTENT_MESSAGE)
-
 
175
        standardPreference.set(self.refreshContentMessageShowPending, forKey: Constants.PREFERENCE_REFRESH_CONTENT_MESSAGE_SHOW_PENDING)
-
 
Línea -... Línea 143...
-
 
143
    
-
 
144
        
-
 
145
        let appDao = AppDao()
-
 
146
        var appModel = appDao.selectOne()
-
 
147
        appModel.deviceUuid = self.deviceUuid
-
 
148
        appModel.deviceAes = self.deviceAes
-
 
149
        appModel.devicePassword = self.devicePassword
-
 
150
        
-
 
151
        appModel.userUuid = self.userUuid
-
 
152
        appModel.userFirstname = self.userFirstname
-
 
153
        appModel.userLastname = self.userLastname
-
 
154
        appModel.userEmail = self.userEmail
-
 
155
        appModel.userImage = self.userImage
-
 
156
        
-
 
157
        appModel.topicUuidActive = self.topicUuidActive
-
 
158
        appModel.capsuleUuidActive = self.capsuleUuidActive
-
 
159
        appModel.capsuleUuidOld = self.capsuleUuidOld
-
 
160
        appModel.slideUuidActive = self.slideUuidActive
-
 
161
        appModel.companyUuidActive = self.companyUuidActive
-
 
162
        
-
 
163
        appModel.fcmToken = self.fcmToken
-
 
164
        appModel.lastCheckChanges = self.lastCheckChanges
-
 
165
        appModel.maxDateChanges = self.maxDateChanges
-
 
166
        appModel.urlExternalDownloaded = self.urlExternalDownloaded
-
 
167
        
176
        standardPreference.set(self.refreshContentActionRequired, forKey: Constants.PREFERENCE_REFRESH_CONTENT_ACTION_REQUIRED)
168
        appModel.refreshContentMessage = self.refreshContentMessage
-
 
169
        appModel.refreshContentMessageShowPending = self.refreshContentMessageShowPending
-
 
170
        appModel.refreshContentActionRequired = self.refreshContentActionRequired
-
 
171
        
-
 
172
        appModel.signoutActionRequired = self.signoutActionRequired
-
 
173
        
-
 
174
        if appModel.id == 0 {
-
 
175
            appModel.id = appDao.insert(model: appModel)
-
 
176
        } else {
177
        
177
            appDao.update(model: appModel)
178
        standardPreference.set(self.signoutActionRequired, forKey: Constants.PREFERENCE_SIGNOUT_ACTION_REQUIRED)
178
        }