Proyectos de Subversion Iphone Microlearning - Nuevo Interface

Rev

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

Rev 1 Rev 8
Línea 446... Línea 446...
446
    }
446
    }
Línea 447... Línea 447...
447
 
447
 
448
    
448
    
Línea 449... Línea 449...
449
    
449
    
450
    
450
    
451
   public func syncFromServer(json : JSON?) -> Bool
451
    public func syncFromServer(json : JSON?, refresh : Bool = false) -> Bool
Línea 459... Línea 459...
459
        let questionDao = QuestionDao.sharedInstance
459
        let questionDao = QuestionDao.sharedInstance
460
        let answerDao = AnswerDao.sharedInstance
460
        let answerDao = AnswerDao.sharedInstance
461
        let userLogDao = UserLogDao.sharedInstance
461
        let userLogDao = UserLogDao.sharedInstance
462
        let progressDao = ProgressDao.sharedInstance
462
        let progressDao = ProgressDao.sharedInstance
463
        let userExtendedDao = UserExtendedDao.sharedInstance
463
        let userExtendedDao = UserExtendedDao.sharedInstance
-
 
464
        let userNotificationDao = UserNotificationDao.sharedInstance
Línea 464... Línea 465...
464
 
465
 
465
        answerDao.removeAll()
466
        answerDao.removeAll()
466
        questionDao.removeAll()
467
        questionDao.removeAll()
Línea 472... Línea 473...
472
        companyDao.removeAll()
473
        companyDao.removeAll()
Línea 473... Línea 474...
473
                                
474
                                
474
        userLogDao.removeAll()
475
        userLogDao.removeAll()
475
        progressDao.removeAll()
476
        progressDao.removeAll()
-
 
477
        userExtendedDao.removeAll()
-
 
478
        userNotificationDao.removeAll()
Línea 476... Línea 479...
476
        userExtendedDao.removeAll()
479
        
477
        
480
        
478
        var companyModel : CompanyModel
481
        var companyModel : CompanyModel
479
        let now = Date()
482
        let now = Date()
Línea 480... Línea 483...
480
        let dateFormatter = DateFormatter()
483
        let dateFormatter = DateFormatter()
481
        dateFormatter.dateFormat = Constants.FORMAT_DATETIME_SERVICE
484
        dateFormatter.dateFormat = Constants.FORMAT_DATETIME_SERVICE
Línea 482... Línea 485...
482
 
485
 
Línea 483... Línea 486...
483
 
486
 
484
            
487
            
Línea 485... Línea 488...
485
        if(json?["data"]["max_date_changes"] != "") {
488
        if json?["data"]["max_date_changes"] != ""  {
486
            let maxDateChanges = json?["data"]["max_date_changes"].string ?? ""
489
            let maxDateChanges = json?["data"]["max_date_changes"].string ?? ""
487
            
490
            
Línea 488... Línea 491...
488
            print("maxDateChanges : \(maxDateChanges)")
491
            print("maxDateChanges : \(maxDateChanges)")
489
            
492
            
490
            appData.maxDateChanges = maxDateChanges
493
            appData.maxDateChanges = maxDateChanges
491
        } 
494
        } 
Línea 492... Línea 495...
492
        
495
        
493
        if(json?["data"]["device"] != "") {
496
        if !refresh  && json?["data"]["device"] != "" {
494
            let deviceAes = json?["data"]["device"]["aes"].string ?? ""
497
            let deviceAes = json?["data"]["device"]["aes"].string ?? ""
495
            let devicePassword = json?["data"]["device"]["password"].string ?? ""
498
            let devicePassword = json?["data"]["device"]["password"].string ?? ""
496
            
499
            
497
            print("deviceAes: \(deviceAes)")
500
            print("deviceAes: \(deviceAes)")
498
            print("devicePassword: \(devicePassword)")
501
            print("devicePassword: \(devicePassword)")
Línea 586... Línea 589...
586
                    capsuleModel.uuid = capsule.1["uuid"].string ?? ""
589
                    capsuleModel.uuid = capsule.1["uuid"].string ?? ""
587
                    capsuleModel.name = capsule.1["name"].string ?? ""
590
                    capsuleModel.name = capsule.1["name"].string ?? ""
588
                    capsuleModel.description = capsule.1["description"].string ?? ""
591
                    capsuleModel.description = capsule.1["description"].string ?? ""
589
                    capsuleModel.image = capsule.1["image"].string ?? ""
592
                    capsuleModel.image = capsule.1["image"].string ?? ""
590
                    capsuleModel.position = Int(capsule.1["position"].string ?? "") ?? 1
593
                    capsuleModel.position = Int(capsule.1["position"].string ?? "") ?? 1
-
 
594
                    capsuleModel.linkComments = capsule.1["link_comments"].string ?? ""
-
 
595
                    capsuleModel.linkCommentAdd = capsule.1["link_comment_add"].string ?? ""
-
 
596
                    capsuleModel.totalComments = Int(capsule.1["total_comments"].string ?? "") ?? 1
-
 
597
                    capsuleModel.totalRating = Decimal(Double(capsule.1["total_rating"].string ?? "") ?? 0)
591
                    capsuleModel.addedOn = capsule.1["added_on"].string ?? ""
598
                    capsuleModel.addedOn = capsule.1["added_on"].string ?? ""
592
                    capsuleModel.updatedOn = capsule.1["updated_on"].string ?? ""
599
                    capsuleModel.updatedOn = capsule.1["updated_on"].string ?? ""
Línea 593... Línea 600...
593
                    
600
                    
594
                    print("capsuletopicUuid: \(capsuleModel.topicUuid)")
601
                    print("capsuletopicUuid: \(capsuleModel.topicUuid)")
595
                    print("capsuleUuid: \(capsuleModel.uuid)")
602
                    print("capsuleUuid: \(capsuleModel.uuid)")
596
                    print("capsuleName: \(capsuleModel.name)")
603
                    print("capsuleName: \(capsuleModel.name)")
597
                    print("capsuleDescription: \(capsuleModel.description)")
604
                    print("capsuleDescription: \(capsuleModel.description)")
598
                    print("capsuleImage: \(capsuleModel.image)")
605
                    print("capsuleImage: \(capsuleModel.image)")
-
 
606
                    print("capsulePosition: \(capsuleModel.position)")
-
 
607
                    print("capsuleLinkComments: \(capsuleModel.linkComments)")
-
 
608
                    print("capsuleLinkCommentAdd: \(capsuleModel.linkCommentAdd)")
-
 
609
                    print("capsuleTotalComments: \(capsuleModel.totalComments)")
Línea 599... Línea 610...
599
                    print("capsulePosition: \(capsuleModel.position)")
610
                    print("capsuleTotalRating: \(capsuleModel.totalRating)")
600
 
611
 
Línea 838... Línea 849...
838
                    progressDao.insert(record: progressModel)
849
                    progressDao.insert(record: progressModel)
839
                }
850
                }
Línea 840... Línea 851...
840
 
851
 
841
            }
852
            }
842
        }
853
        }
843
                
-
 
844
        /*
-
 
845
        let now = Date()
-
 
846
        let dateFormatter = DateFormatter()
-
 
847
        dateFormatter.dateFormat = Constants.FORMAT_DATETIME_SERVICE
-
 
848
        let dateOn = dateFormatter.string(from: now)
-
 
849
 
-
 
850
        userUuid = appData.string(forKey: Constants.APP_DATA_FIELD_USER_UUID) ?? ""
-
 
851
                                
-
 
852
                                
-
 
853
        var userLog = UserLogModel()
-
 
854
        userLog.userUuid = userUuid
-
 
855
        userLog.companyUuid = ""
-
 
856
        userLog.topicUuid = ""
-
 
857
        userLog.capsuleUuid = ""
-
 
858
        userLog.slideUuid = ""
-
 
859
        userLog.activity = Constants.USER_LOG_ACTIVITY_SIGNIN;
-
 
860
        userLog.addedOn =  dateOn
-
 
861
             
-
 
862
        userLogDao.insert(record : userLog);
-
 
863
                                
-
 
864
        var json = userLog.toJson()
-
 
865
        json[Constants.SYNC_ADAPTER_DATA_TYPE_FIELD_NAME] = Constants.SYNC_ADAPTER_DATA_TYPE_USER_LOG
-
 
866
                                
-
 
867
        var sync = SyncModel()
-
 
868
        sync.type = Constants.SYNC_ADAPTER_TYPE_SYNC
-
 
869
        if let theJSONData = try?  JSONSerialization.data(withJSONObject: json, options: .prettyPrinted),
-
 
870
            let data = String(data: theJSONData, encoding: String.Encoding.ascii) {
-
 
871
            sync.data = data
-
 
872
        }
-
 
873
                                
-
 
874
        let syncDao = SyncDao.sharedInstance
-
 
875
        syncDao.insert(record : sync)
-
 
Línea 876... Línea 854...
876
        */
854
         
877
        
855