AdminSetUserEnabled() private method

private AdminSetUserEnabled ( string databaseName, string userName, string fullName, string email, int enabled ) : bool
databaseName string
userName string
fullName string
email string
enabled int
return bool
Example #1
0
        public static bool Testing_SetupDatabase(string host, int port, string adminUser, string adminPwd, string user, string pwd, string projectName)
        {
            AssetServer.AdminSetCredentials(host, port, adminUser, adminPwd);
            MaintDatabaseRecord[] recordArray = AssetServer.AdminRefreshDatabases();
            if (recordArray == null)
            {
                return(false);
            }
            foreach (MaintDatabaseRecord record in recordArray)
            {
                if (record.name == projectName)
                {
                    AssetServer.AdminDeleteDB(projectName);
                }
            }
            if (AssetServer.AdminCreateDB(projectName) == 0)
            {
                return(false);
            }
            string databaseName = AssetServer.GetDatabaseName(host, adminUser, adminPwd, port.ToString(), projectName);

            if (!AssetServer.AdminSetUserEnabled(databaseName, user, user, string.Empty, 1))
            {
                return(false);
            }
            Testing_SetActiveDatabase(host, port, projectName, databaseName, user, pwd);
            return(true);
        }
Example #2
0
        public static bool Testing_SetupDatabase(string host, int port, string adminUser, string adminPwd, string user, string pwd, string projectName)
        {
            AssetServer.AdminSetCredentials(host, port, adminUser, adminPwd);
            MaintDatabaseRecord[] array = AssetServer.AdminRefreshDatabases();
            if (array == null)
            {
                return(false);
            }
            MaintDatabaseRecord[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                MaintDatabaseRecord maintDatabaseRecord = array2[i];
                if (maintDatabaseRecord.name == projectName)
                {
                    AssetServer.AdminDeleteDB(projectName);
                }
            }
            if (AssetServer.AdminCreateDB(projectName) == 0)
            {
                return(false);
            }
            string databaseName = AssetServer.GetDatabaseName(host, adminUser, adminPwd, port.ToString(), projectName);

            if (!AssetServer.AdminSetUserEnabled(databaseName, user, user, string.Empty, 1))
            {
                return(false);
            }
            ASEditorBackend.Testing_SetActiveDatabase(host, port, projectName, databaseName, user, pwd);
            return(true);
        }
Example #3
0
        public bool DoGUI()
        {
            bool enabled = GUI.enabled;

            if (ASServerAdminWindow.constants == null)
            {
                ASServerAdminWindow.constants            = new ASMainWindow.Constants();
                ASServerAdminWindow.constants.toggleSize = ASServerAdminWindow.constants.toggle.CalcSize(new GUIContent("X"));
            }
            if (this.resetKeyboardControl)
            {
                this.resetKeyboardControl  = false;
                GUIUtility.keyboardControl = 0;
            }
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical(ASServerAdminWindow.constants.groupBox, new GUILayoutOption[0]);
            GUILayout.Box("Server Connection", ASServerAdminWindow.constants.title, new GUILayoutOption[0]);
            GUILayout.BeginVertical(ASServerAdminWindow.constants.contentBox, new GUILayoutOption[0]);
            Event current = Event.current;

            if (current.type == EventType.KeyDown && current.keyCode == KeyCode.Return && this.CanPerformCurrentAction())
            {
                this.PerformCurrentAction();
            }
            if (current.type == EventType.KeyDown && current.keyCode == KeyCode.Escape && this.currAction != ASServerAdminWindow.Action.Main)
            {
                this.currAction = ASServerAdminWindow.Action.Main;
                current.Use();
            }
            GUILayout.BeginHorizontal();
            this.server = EditorGUILayout.TextField("Server Address:", this.server, new GUILayoutOption[0]);
            this.ServersPopup();
            GUILayout.EndHorizontal();
            this.user     = EditorGUILayout.TextField("User Name:", this.user, new GUILayoutOption[0]);
            this.password = EditorGUILayout.PasswordField("Password:"******"Connect", ASServerAdminWindow.constants.smallButton, new GUILayoutOption[0]))
            {
                this.PerformCurrentAction();
            }
            GUI.enabled = enabled;
            GUILayout.EndHorizontal();
            if (AssetServer.GetAssetServerError() != string.Empty)
            {
                GUILayout.Label(AssetServer.GetAssetServerError(), ASServerAdminWindow.constants.errorLabel, new GUILayoutOption[0]);
            }
            GUILayout.EndVertical();
            GUILayout.EndVertical();
            GUILayout.BeginVertical(ASServerAdminWindow.constants.groupBox, new GUILayoutOption[0]);
            GUILayout.Box("Admin Actions", ASServerAdminWindow.constants.title, new GUILayoutOption[0]);
            GUILayout.BeginVertical(ASServerAdminWindow.constants.contentBox, new GUILayoutOption[0]);
            this.ActionBox();
            GUILayout.EndVertical();
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical(ASServerAdminWindow.constants.groupBox, new GUILayoutOption[0]);
            GUILayout.Box("Project", ASServerAdminWindow.constants.title, new GUILayoutOption[0]);
            foreach (ListViewElement listViewElement in ListViewGUILayout.ListView(this.lv, ASServerAdminWindow.constants.background))
            {
                if (listViewElement.row == this.lv.row && Event.current.type == EventType.Repaint)
                {
                    ASServerAdminWindow.constants.entrySelected.Draw(listViewElement.position, false, false, false, false);
                }
                GUILayout.Label(this.databases[listViewElement.row].name);
            }
            if (this.lv.selectionChanged)
            {
                if (this.lv.row > -1)
                {
                    this.projectSelected = true;
                }
                this.currAction = ASServerAdminWindow.Action.Main;
                this.DoGetUsers();
            }
            GUILayout.EndVertical();
            GUILayout.BeginVertical(ASServerAdminWindow.constants.groupBox, new GUILayoutOption[0]);
            SplitterGUILayout.BeginHorizontalSplit(this.lvSplit);
            GUILayout.Box(string.Empty, ASServerAdminWindow.constants.columnHeader, new GUILayoutOption[0]);
            GUILayout.Box("User", ASServerAdminWindow.constants.columnHeader, new GUILayoutOption[0]);
            GUILayout.Box("Full Name", ASServerAdminWindow.constants.columnHeader, new GUILayoutOption[0]);
            GUILayout.Box("Email", ASServerAdminWindow.constants.columnHeader, new GUILayoutOption[0]);
            SplitterGUILayout.EndHorizontalSplit();
            int left = EditorStyles.label.margin.left;

            foreach (ListViewElement listViewElement in ListViewGUILayout.ListView(this.lv2, ASServerAdminWindow.constants.background))
            {
                if (listViewElement.row == this.lv2.row && Event.current.type == EventType.Repaint)
                {
                    ASServerAdminWindow.constants.entrySelected.Draw(listViewElement.position, false, false, false, false);
                }
                bool flag1 = this.users[listViewElement.row].enabled != 0;
                bool flag2 = GUI.Toggle(new Rect(listViewElement.position.x + 2f, listViewElement.position.y - 1f, ASServerAdminWindow.constants.toggleSize.x, ASServerAdminWindow.constants.toggleSize.y), flag1, string.Empty);
                GUILayout.Space(ASServerAdminWindow.constants.toggleSize.x);
                if (flag1 != flag2 && AssetServer.AdminSetUserEnabled(this.databases[this.lv.row].dbName, this.users[listViewElement.row].userName, this.users[listViewElement.row].fullName, this.users[listViewElement.row].email, !flag2 ? 0 : 1))
                {
                    this.users[listViewElement.row].enabled = !flag2 ? 0 : 1;
                }
                GUILayout.Label(this.users[listViewElement.row].userName, new GUILayoutOption[1]
                {
                    GUILayout.Width((float)(this.lvSplit.realSizes[1] - left))
                });
                GUILayout.Label(this.users[listViewElement.row].fullName, new GUILayoutOption[1]
                {
                    GUILayout.Width((float)(this.lvSplit.realSizes[2] - left))
                });
                GUILayout.Label(this.users[listViewElement.row].email);
            }
            if (this.lv2.selectionChanged)
            {
                if (this.lv2.row > -1)
                {
                    this.userSelected = true;
                }
                if (this.currAction == ASServerAdminWindow.Action.SetPassword)
                {
                    this.currAction = ASServerAdminWindow.Action.Main;
                }
            }
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            GUILayout.Space(10f);
            if (!this.splittersOk && Event.current.type == EventType.Repaint)
            {
                this.splittersOk = true;
                this.parentWin.Repaint();
            }
            return(true);
        }
        public bool DoGUI()
        {
            bool enabled = GUI.enabled;

            if (constants == null)
            {
                constants            = new ASMainWindow.Constants();
                constants.toggleSize = constants.toggle.CalcSize(new GUIContent("X"));
            }
            if (this.resetKeyboardControl)
            {
                this.resetKeyboardControl  = false;
                GUIUtility.keyboardControl = 0;
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.BeginVertical(constants.groupBox, new GUILayoutOption[0]);
            GUILayout.Box("Server Connection", constants.title, new GUILayoutOption[0]);
            GUILayout.BeginVertical(constants.contentBox, new GUILayoutOption[0]);
            Event current = Event.current;

            if (((current.type == EventType.KeyDown) && (current.keyCode == KeyCode.Return)) && this.CanPerformCurrentAction())
            {
                this.PerformCurrentAction();
            }
            if (((current.type == EventType.KeyDown) && (current.keyCode == KeyCode.Escape)) && (this.currAction != Action.Main))
            {
                this.currAction = Action.Main;
                current.Use();
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            this.server = EditorGUILayout.TextField("Server Address:", this.server, new GUILayoutOption[0]);
            this.ServersPopup();
            GUILayout.EndHorizontal();
            this.user     = EditorGUILayout.TextField("User Name:", this.user, new GUILayoutOption[0]);
            this.password = EditorGUILayout.PasswordField("Password:"******"Connect", constants.smallButton, new GUILayoutOption[0]))
            {
                this.PerformCurrentAction();
            }
            GUI.enabled = enabled;
            GUILayout.EndHorizontal();
            if (AssetServer.GetAssetServerError() != string.Empty)
            {
                GUILayout.Label(AssetServer.GetAssetServerError(), constants.errorLabel, new GUILayoutOption[0]);
            }
            GUILayout.EndVertical();
            GUILayout.EndVertical();
            GUILayout.BeginVertical(constants.groupBox, new GUILayoutOption[0]);
            GUILayout.Box("Admin Actions", constants.title, new GUILayoutOption[0]);
            GUILayout.BeginVertical(constants.contentBox, new GUILayoutOption[0]);
            this.ActionBox();
            GUILayout.EndVertical();
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.BeginVertical(constants.groupBox, new GUILayoutOption[0]);
            GUILayout.Box("Project", constants.title, new GUILayoutOption[0]);
            IEnumerator enumerator = ListViewGUILayout.ListView(this.lv, constants.background, new GUILayoutOption[0]).GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    ListViewElement element = (ListViewElement)enumerator.Current;
                    if ((element.row == this.lv.row) && (Event.current.type == EventType.Repaint))
                    {
                        constants.entrySelected.Draw(element.position, false, false, false, false);
                    }
                    GUILayout.Label(this.databases[element.row].name, new GUILayoutOption[0]);
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            if (this.lv.selectionChanged)
            {
                if (this.lv.row > -1)
                {
                    this.projectSelected = true;
                }
                this.currAction = Action.Main;
                this.DoGetUsers();
            }
            GUILayout.EndVertical();
            GUILayout.BeginVertical(constants.groupBox, new GUILayoutOption[0]);
            SplitterGUILayout.BeginHorizontalSplit(this.lvSplit, new GUILayoutOption[0]);
            GUILayout.Box("", constants.columnHeader, new GUILayoutOption[0]);
            GUILayout.Box("User", constants.columnHeader, new GUILayoutOption[0]);
            GUILayout.Box("Full Name", constants.columnHeader, new GUILayoutOption[0]);
            GUILayout.Box("Email", constants.columnHeader, new GUILayoutOption[0]);
            SplitterGUILayout.EndHorizontalSplit();
            int         left        = EditorStyles.label.margin.left;
            IEnumerator enumerator2 = ListViewGUILayout.ListView(this.lv2, constants.background, new GUILayoutOption[0]).GetEnumerator();

            try
            {
                while (enumerator2.MoveNext())
                {
                    ListViewElement element2 = (ListViewElement)enumerator2.Current;
                    if ((element2.row == this.lv2.row) && (Event.current.type == EventType.Repaint))
                    {
                        constants.entrySelected.Draw(element2.position, false, false, false, false);
                    }
                    bool flag2 = this.users[element2.row].enabled != 0;
                    bool flag3 = GUI.Toggle(new Rect(element2.position.x + 2f, element2.position.y - 1f, constants.toggleSize.x, constants.toggleSize.y), flag2, "");
                    GUILayout.Space(constants.toggleSize.x);
                    if ((flag2 != flag3) && AssetServer.AdminSetUserEnabled(this.databases[this.lv.row].dbName, this.users[element2.row].userName, this.users[element2.row].fullName, this.users[element2.row].email, !flag3 ? 0 : 1))
                    {
                        this.users[element2.row].enabled = !flag3 ? 0 : 1;
                    }
                    GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width((float)(this.lvSplit.realSizes[1] - left)) };
                    GUILayout.Label(this.users[element2.row].userName, options);
                    GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.Width((float)(this.lvSplit.realSizes[2] - left)) };
                    GUILayout.Label(this.users[element2.row].fullName, optionArray2);
                    GUILayout.Label(this.users[element2.row].email, new GUILayoutOption[0]);
                }
            }
            finally
            {
                IDisposable disposable2 = enumerator2 as IDisposable;
                if (disposable2 != null)
                {
                    disposable2.Dispose();
                }
            }
            if (this.lv2.selectionChanged)
            {
                if (this.lv2.row > -1)
                {
                    this.userSelected = true;
                }
                if (this.currAction == Action.SetPassword)
                {
                    this.currAction = Action.Main;
                }
            }
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            GUILayout.Space(10f);
            if (!this.splittersOk && (Event.current.type == EventType.Repaint))
            {
                this.splittersOk = true;
                this.parentWin.Repaint();
            }
            return(true);
        }