Beispiel #1
0
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            FormUserGroups form = new FormUserGroups();

            byte[] Versao = null;
            if (form.ShowDialog() == DialogResult.OK)
            {
                this.Cursor = Cursors.WaitCursor;
                GISADataset.TrusteeRow tRow    = null;
                List <long>            tRowIDs = new List <long>();
                foreach (ListViewItem item in form.lstVwTrustees.SelectedItems)
                {
                    tRow = (GISADataset.TrusteeRow)item.Tag;
                    // verificar se o utilizador foi anteriormente adicionado ao grupo
                    if (GisaDataSetHelper.GetInstance().UserGroups.Select(string.Format("IDUser={0} AND IDGroup={1}", (CurrentTrusteeRow.GetTrusteeUserRows()[0]).ID.ToString(), (tRow.GetTrusteeGroupRows()[0]).ID.ToString())).Length == 0)
                    {
                        tRowIDs.Add(tRow.ID);
                        GisaDataSetHelper.GetInstance().UserGroups.AddUserGroupsRow(CurrentTrusteeRow.GetTrusteeUserRows()[0], tRow.GetTrusteeGroupRows()[0], Versao, 0);
                    }
                }

                PersistencyHelper.save();
                PersistencyHelper.cleanDeletedData();
                EnumerateMembership(CurrentTrusteeRow);
                this.Cursor = Cursors.Default;
            }
        }
Beispiel #2
0
        public override void ViewToModel()
        {
            IsPopulated = false;
            if (CurrentTrusteeRow == null || CurrentTrusteeRow.RowState == DataRowState.Detached || !IsLoaded)
            {
                return;
            }

            base.ViewToModel();
            if (CurrentTrusteeRow.GetTrusteeUserRows().Length > 0)
            {
                // LDAP
                GISADataset.TrusteeUserRow turow = CurrentTrusteeRow.GetTrusteeUserRows()[0];
                turow.IsLDAPUser = chkLDAP.Checked;

                CurrentTrusteeRow.GetTrusteeUserRows()[0].FullName = txtFullName.Text;
                if (!(txtPassword.Text.Equals(mOriginalPasswd)) && !(txtPassword.Text.Length == 0))
                {
                    CurrentTrusteeRow.GetTrusteeUserRows()[0].Password = CryptographyHelper.GetMD5(txtPassword.Text);
                }
                CurrentTrusteeRow.GetTrusteeUserRows()[0].IsAuthority = chkAuthority.Checked;
            }
            CurrentTrusteeRow.IsActive = chkActive.Checked;

            IsPopulated = true;
        }
Beispiel #3
0
        public override void ModelToView()
        {
            if (CurrentTrusteeRow == null || CurrentTrusteeRow.RowState == DataRowState.Detached || !IsLoaded)
            {
                return;
            }

            base.ModelToView();
            if (CurrentTrusteeRow.GetTrusteeUserRows().Length > 0)
            {
                GISADataset.TrusteeUserRow turow = CurrentTrusteeRow.GetTrusteeUserRows()[0];
                chkLDAP.Checked = turow.IsLDAPUser;

                DataRow[] ugAcessoCompleto =
                    GisaDataSetHelper.GetInstance().UserGroups.Select(string.Format("IDUser={0} AND IDGroup={1}", CurrentTrusteeRow.ID, PermissoesHelper.GrpAcessoCompleto.ID));

                DataRow[] ugAcessoPublicados =
                    GisaDataSetHelper.GetInstance().UserGroups.Select(string.Format("IDUser={0} AND IDGroup={1}", CurrentTrusteeRow.ID, PermissoesHelper.GrpAcessoPublicados.ID));

                Debug.Assert(!(ugAcessoCompleto.Length == 1 && ugAcessoPublicados.Length == 1), "O utilizador não pode pertencer aos grupos ACESSO_COMPLETO e ACESSO_PUBLICADOS ao mesmo tempo.");
                Debug.Assert(!(ugAcessoCompleto.Length == 0 && ugAcessoPublicados.Length == 0), "O utilizador tem de pertencer ao grupo ACESSO_COMPLETO ou ao grupo ACESSO_PUBLICADOS.");

                if (ugAcessoCompleto.Length > 0)
                {
                    mTipoUser = TipoUser.AcessoTudo;
                }
                else if (ugAcessoPublicados.Length > 0)
                {
                    mTipoUser = TipoUser.AcessoInfoPub;
                }

                cbTipoUser.SelectedIndex = (int)Enum.Parse(typeof(TipoUser), mTipoUser.ToString());

                this.cbTipoUser.SelectedIndexChanged += new System.EventHandler(this.cbTipoUser_SelectedIndexChanged);
            }
        }
Beispiel #4
0
        public override void LoadData(DataRow CurrentDataRow, IDbConnection conn)
        {
            IsLoaded = false;
            base.LoadData(CurrentDataRow, conn);

            if (CurrentDataRow == null)
            {
                return;
            }

            if (!(CurrentTrusteeRow.GetTrusteeUserRows()[0].IsFullNameNull()))
            {
                txtFullName.Text = CurrentTrusteeRow.GetTrusteeUserRows()[0].FullName;
            }
            else
            {
                txtFullName.Text = string.Empty;
            }

            txtPassword.Text     = mOriginalPasswd;
            chkAuthority.Checked = CurrentTrusteeRow.GetTrusteeUserRows()[0].IsAuthority;
            UpdateButtonState();
            IsLoaded = true;
        }