Exemple #1
0
        private void cbConnection_SelectedIndexChanged(object sender, EventArgs e)
        {
            var config = (sender as ComboBox).SelectedItem as ConfigValue;

            if (config != null)
            {
                //using a hack to open the XML file instead of the connection.
                if (String.IsNullOrEmpty(config.EndpointAddress))
                {
                    if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        BusinessRules businessRules;

                        try
                        {
                            businessRules = MDSWrapper.BusinessRuleDeserialize(openFileDialog1.FileName);
                        }
                        catch (MDSManagerException exc)
                        {
                            MessageBox.Show(exc.Message);
                            return;
                        }
                        var dataSet = MDSDataUtils.NewBusinessRuleDataTable();
                        foreach (BusinessRule businessRule in businessRules.BusinessRulesMember)
                        {
                            MDSDataUtils.NewBRDataRow(dataSet, businessRule);
                        }
                        if ((sender as ComboBox) == cbConnection.ComboBox)
                        {
                            dgRules.DataSource = dataSet;
                        }
                        if ((sender as ComboBox) == cbConnection2.ComboBox)
                        {
                            businessRules2 = businessRules;

                            dgRules2.DataSource = dataSet;
                        }
                    }
                }
                else
                {
                    MDSWrapper.Configuration = config;
                    RefreshPermissionsList(sender);
                }
            }
        }
Exemple #2
0
        private void RefreshPermissionsList(object sender)
        {
            try
            {
                DataGridView ruleDataGrid = null;
                if (sender == cbConnection.ComboBox)
                {
                    ruleDataGrid = dgRules;
                }

                if (sender == cbConnection2.ComboBox)
                {
                    ruleDataGrid = dgRules2;
                }

                Cursor.Current = Cursors.WaitCursor;
                var dataSet = MDSDataUtils.NewPermissionDataTable();

                var users = MDSWrapper.UserSecurityPrincipalsGet();

                foreach (var user in users.Users)
                {
                    foreach (var modelPrivilege in user.SecurityPrivilege.ModelPrivileges)
                    {
                        MDSDataUtils.NewPermissionDataRow(dataSet, user.Identifier, modelPrivilege);
                    }
                    foreach (var hierarchPrivilege in user.SecurityPrivilege.HierarchyMemberPrivileges)
                    {
                        MDSDataUtils.NewPermissionDataRow(dataSet, user.Identifier, hierarchPrivilege);
                    }
                }

                var groups = MDSWrapper.GroupSecurityPrincipalsGet();

                foreach (var group in groups.Groups)
                {
                    foreach (var modelPrivilege in group.SecurityPrivilege.ModelPrivileges)
                    {
                        MDSDataUtils.NewPermissionDataRow(dataSet, group.Identifier, modelPrivilege);
                    }
                    foreach (var hierarchPrivilege in group.SecurityPrivilege.HierarchyMemberPrivileges)
                    {
                        MDSDataUtils.NewPermissionDataRow(dataSet, group.Identifier, hierarchPrivilege);
                    }
                }

                ruleDataGrid.DataSource = dataSet;
                //hiding the column ID
                ruleDataGrid.Columns[0].Visible = false;

                btExport.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }