Beispiel #1
0
        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);
            }
        }