private void ChangePermission(GISADataset.TrusteeRow user, ListViewItem item, int colIndex) { GISADataset.TipoFunctionRow tipoFunction = (GISADataset.TipoFunctionRow)item.Tag; GISADataset.TipoOperationRow tipoOperation = (GISADataset.TipoOperationRow)(GisaDataSetHelper.GetInstance().TipoOperation.Select(string.Format("Name='{0}'", lstvwPermissoes.Columns[colIndex].Text))[0]); string query = "IDTrustee={0} AND IDTipoFunctionGroup={1} AND IdxTipoFunction = {2} AND IDTipoOperation = {3}"; query = string.Format(query, user.ID, tipoFunction.IDTipoFunctionGroup, tipoFunction.idx, tipoOperation.ID); GISADataset.TrusteePrivilegeRow[] trusteePrivileges = null; trusteePrivileges = (GISADataset.TrusteePrivilegeRow[])(GisaDataSetHelper.GetInstance().TrusteePrivilege.Select(query)); // alterar permissões no dataset if (trusteePrivileges.Length > 0) { if (trusteePrivileges[0].IsGrant) trusteePrivileges[0].IsGrant = false; else trusteePrivileges[0].Delete(); } else { trusteePrivileges = (GISADataset.TrusteePrivilegeRow[])(GisaDataSetHelper.GetInstance().TrusteePrivilege.Select(query, "", DataViewRowState.Deleted)); if (trusteePrivileges.Length > 0) { trusteePrivileges[0].RejectChanges(); trusteePrivileges[0].IsGrant = true; } else GisaDataSetHelper.GetInstance().TrusteePrivilege.AddTrusteePrivilegeRow(user, tipoFunction.IDTipoFunctionGroup, tipoFunction.idx, tipoOperation.ID, true, new byte[] { }, 0); } // popular as alterações GISADataset.FunctionOperationRow functionOperation = (GISADataset.FunctionOperationRow)(GisaDataSetHelper.GetInstance().FunctionOperation.Select(string.Format("IDTipoFunctionGroup={0} AND IdxTipoFunction={1} AND IDTipoOperation={2}", tipoFunction.IDTipoFunctionGroup, tipoFunction.idx, tipoOperation.ID))[0]); PermissoesHelper.PermissionType permissaoEfectiva = PermissoesHelper.CalculateEffectivePermissions(CurrentTrusteeRow, functionOperation); if (permissaoEfectiva == PermissoesHelper.PermissionType.ExplicitGrant) item.SubItems[functionOperation.TipoOperationRow.ID].Text = "Sim"; else item.SubItems[functionOperation.TipoOperationRow.ID].Text = "Não"; GISADataset.TrusteePrivilegeRow[] tpRows = (GISADataset.TrusteePrivilegeRow[])(GisaDataSetHelper.GetInstance().TrusteePrivilege.Select(string.Format("IDTrustee={0} AND IDTipoFunctionGroup={1} AND IdxTipoFunction = {2} AND IDTipoOperation = {3}", user.ID, functionOperation.IDTipoFunctionGroup, functionOperation.IdxTipoFunction, functionOperation.IDTipoOperation))); if (tpRows.Length == 0) { tpRows = (GISADataset.TrusteePrivilegeRow[])(GisaDataSetHelper.GetInstance().TrusteePrivilege.Select(string.Format("IDTrustee={0} AND IDTipoFunctionGroup={1} AND IdxTipoFunction = {2} AND IDTipoOperation = {3}", user.ID, functionOperation.IDTipoFunctionGroup, functionOperation.IdxTipoFunction, functionOperation.IDTipoOperation), "", DataViewRowState.Deleted)); if (tpRows.Length == 0) item.SubItems[colIndex].Font = PermissoesHelper.fontItalic; else item.SubItems[colIndex].Font = PermissoesHelper.fontBoldItalic; } else { if (tpRows[0].RowState == DataRowState.Modified && !(tpRows[0].IsGrant ^ (bool)(tpRows[0]["IsGrant", DataRowVersion.Original]))) item.SubItems[colIndex].Font = PermissoesHelper.fontRegular; else item.SubItems[colIndex].Font = PermissoesHelper.fontBold; } }
private bool CanChangePermission(ListViewItem item, int colIndex) { if (colIndex == 0 || item.Tag is GISADataset.TipoFunctionGroupRow) return false; GISADataset.TipoFunctionRow tipoFunction = (GISADataset.TipoFunctionRow)item.Tag; GISADataset.TipoOperationRow tipoOperation = (GISADataset.TipoOperationRow)(GisaDataSetHelper.GetInstance().TipoOperation.Select(string.Format("Name='{0}'", lstvwPermissoes.Columns[colIndex].Text))[0]); GISADataset.FunctionOperationRow[] functionOperation = (GISADataset.FunctionOperationRow[])(GisaDataSetHelper.GetInstance().FunctionOperation.Select(string.Format("IDTipoFunctionGroup={0} AND IdxTipoFunction={1} AND IDTipoOperation={2}", tipoFunction.IDTipoFunctionGroup, tipoFunction.idx, tipoOperation.ID))); if (functionOperation.Length == 0) return false; else return true; }
public static PermissionType CalculateEffectivePermissions(GISADataset.ObjetoDigitalRow odRow, GISADataset.TrusteeRow tRow, GISADataset.NivelRow nRow, GISADataset.TipoOperationRow opRow) { var tdpRow = GisaDataSetHelper.GetInstance().TrusteeObjetoDigitalPrivilege.Cast <GISADataset.TrusteeObjetoDigitalPrivilegeRow>() .SingleOrDefault(r => r.RowState != DataRowState.Deleted && r.IDTrustee == tRow.ID && r.IDTipoOperation == opRow.ID && r.IDObjetoDigital == odRow.ID); if (tdpRow != null) { return(tdpRow.IsGrant ? PermissionType.ExplicitGrant : PermissionType.ExplicitDeny); } else { var ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { var perm = PermissoesRule.Current.CalculateODGroupPermissions(tRow.ID, odRow.ID, opRow.ID, ho.Connection); if (perm < 0) { var nivelPerms = PermissoesRule.Current.CalculateEffectivePermissions(new List <long>() { nRow.ID }, tRow.ID, ho.Connection); return(GetPermissionValue(nivelPerms[nRow.ID], GisaDataSetHelper.GetInstance().NivelTipoOperation.Cast <GISADataset.NivelTipoOperationRow>().Single(r => r.TipoOperationRow.Name.Equals(opRow.Name))) == 1 ? PermissionType.ImplicitGrant : PermissionType.ImplicitDeny); } else { return(perm == 0 ? PermissionType.ImplicitDeny : PermissionType.ImplicitGrant); } } catch (Exception ex) { Trace.WriteLine(ex); throw; } finally { ho.Dispose(); } } }
public static PermissionType CalculateEffectivePermissions(GISADataset.TrusteeRow tRow, GISADataset.TipoOperationRow opRow, GISADataset.DepositoRow depRow) { var tdpRow = GisaDataSetHelper.GetInstance().TrusteeDepositoPrivilege.Cast <GISADataset.TrusteeDepositoPrivilegeRow>() .SingleOrDefault(r => r.RowState != DataRowState.Deleted && r.IDTrustee == tRow.ID && r.IDTipoOperation == opRow.ID && r.IDDeposito == depRow.ID); if (tdpRow != null) { return(tdpRow.IsGrant ? PermissionType.ExplicitGrant : PermissionType.ExplicitDeny); } if (tRow.CatCode.Equals("USR")) { if (tRow.GetTrusteeUserRows().Length > 0) { var ugRows = tRow.GetTrusteeUserRows()[0].GetUserGroupsRows(); return(CalculateGroupPermissionsDepositos(ugRows, opRow, depRow)); } } return(PermissionType.ImplicitDeny); }
private static PermissionType CalculateGroupPermissionsObjDigitais(GISADataset.UserGroupsRow[] ugRows, GISADataset.TipoOperationRow opRow, GISADataset.ObjetoDigitalRow odRow) { PermissionType GroupPermission = PermissionType.ImplicitDeny; if (ugRows == null) { return(GroupPermission); } ugRows.ToList().ForEach(ugRow => { var pgRows = GisaDataSetHelper.GetInstance().TrusteeObjetoDigitalPrivilege.Cast <GISADataset.TrusteeObjetoDigitalPrivilegeRow>() .Where(r => r.RowState != DataRowState.Deleted && r.IDObjetoDigital == odRow.ID && r.IDTipoOperation == opRow.ID && r.IDTrustee == ugRow.TrusteeGroupRow.TrusteeRow.ID).Cast <DataRow>().ToArray(); GroupPermission = CalculateGroupPermissions(GroupPermission, pgRows); }); return(GroupPermission); }