private MobeelizerOperationError Login(string instance, string user, string password, bool offline) { if (IsLoggedIn) { Logout(); } Log.i(TAG, "login: "******", " + application + ", " + instance + ", " + user + ", " + password); this.instance = instance; this.user = user; this.password = password; MobeelizerLoginResponse response = connectionManager.Login(offline); Log.i(TAG, "Login result: " + response.Error + ", " + response.Role + ", " + response.InstanceGuid); if (response.Error != null) { this.instance = null; this.user = null; this.password = null; return response.Error; } else { role = response.Role; instanceGuid = response.InstanceGuid; loggedIn = true; IDictionary<String, MobeelizerModel> models = new Dictionary<String, MobeelizerModel>(); foreach (MobeelizerModel model in definitionConverter.Convert(definition, entityPackage, role)) { models.Add(model.Name, model); } database = new MobeelizerDatabase(this, models); database.Open(); if (response.InitialSyncRequired) { Sync(true); } return null; } }
internal MobeelizerTransaction(MobeelizerDatabase db) { dataContext = new MobeelizerDatabaseContext(db.ConnectionString); this.db = db; }
internal void Logout() { if (!IsLoggedIn) { return; } if (CheckSyncStatus().IsRunning()) { throw new SystemException("Cannot logout when sync is in progress."); } Log.i(TAG, "logout"); this.instance = null; this.user = null; this.password = null; if (database != null) { database.Close(); database = null; } loggedIn = false; }