コード例 #1
0
        private void LoadOperationsAndPermissions(GISADataset.DepositoRow depRow, ListViewItem item)
        {
            Debug.Assert(CurrentTrustee != null);

            var operations = GisaDataSetHelper.GetInstance().DepositoTipoOperation.Cast <GISADataset.DepositoTipoOperationRow>().ToList();

            operations.ForEach(opRow =>
            {
                item.SubItems.Add(string.Empty).Tag = opRow;
                int colIndex          = GetColumnIndex(opRow.TipoOperationRow.Name);
                var permissaoEfectiva = PermissoesHelper.CalculateEffectivePermissions(CurrentTrustee, opRow.TipoOperationRow, depRow);
                var tdpRow            = GisaDataSetHelper.GetInstance().TrusteeDepositoPrivilege.Cast <GISADataset.TrusteeDepositoPrivilegeRow>()
                                        .SingleOrDefault(r => r.IDDeposito == depRow.ID && r.IDTipoOperation == opRow.IDTipoOperation && r.IDTrustee == CurrentTrustee.ID);

                //PermissoesHelper.PopulatePermission(item, colIndex, tdpRow, permissaoEfectiva);
                if (permissaoEfectiva == PermissoesHelper.PermissionType.ExplicitGrant)
                {
                    item.SubItems[colIndex].Text = "Sim";
                }
                else
                {
                    item.SubItems[colIndex].Text = "Não";
                }

                if (GisaDataSetHelper.GetInstance().TrusteeDepositoPrivilege.Select(string.Format("IDTrustee={0} AND IDDeposito={1} AND IDTipoOperation={2}", CurrentTrustee.ID, depRow.ID, opRow.IDTipoOperation)).Length == 0)
                {
                    item.SubItems[colIndex].Font = PermissoesHelper.fontItalic;
                }
            });
        }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
        private void nivelGrupoArquivosList1_BeforeNewListSelection(object sender, BeforeNewSelectionEventArgs e)
        {
            if (e.ItemToBeSelected.Tag != null)
            {
                PermissoesHelper.UpdateNivelPermissions((GISADataset.NivelRow)e.ItemToBeSelected.Tag, SessionHelper.GetGisaPrincipal().TrusteeUserOperator.ID);
            }

            try
            {
                Debug.WriteLine("nivelGrupoArquivosList1_BeforeNewListSelection");

                e.SelectionChange = UpdateContext(e.ItemToBeSelected);
                if (e.SelectionChange)
                {
                    updateContextStatusBar();
                    UpdateToolBarButtons(e.ItemToBeSelected);
                }
            }
            catch (GISA.Search.UpdateServerException)
            { }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
                throw;
            }
        }
コード例 #4
0
		private void ShowEffectivePermissions(ListViewItem item)
		{
			foreach (GISADataset.TipoOperationRow tipoOperation in GisaDataSetHelper.GetInstance().TipoOperation.Select(string.Empty, "ID"))
			{
				GISADataset.FunctionOperationRow[] functionOperations = (GISADataset.FunctionOperationRow[])(GisaDataSetHelper.GetInstance().FunctionOperation.Select(string.Format("IDTipoFunctionGroup={0} AND IdxTipoFunction = {1} AND IDTipoOperation = {2}", currentTipoFunction.IDTipoFunctionGroup, currentTipoFunction.idx, tipoOperation.ID)));

				item.SubItems.Add(string.Empty);

				if (functionOperations.Length > 0)
				{
					PermissoesHelper.PermissionType permissaoEfectiva = PermissoesHelper.CalculateEffectivePermissions((GISADataset.TrusteeRow)item.Tag, functionOperations[0]);

					int colIndex = GetColumnIndex(tipoOperation.Name);

					if (permissaoEfectiva == PermissoesHelper.PermissionType.ExplicitGrant)
						item.SubItems[colIndex].Text = "Sim";
					else
						item.SubItems[colIndex].Text = "Não";

					if (GisaDataSetHelper.GetInstance().TrusteePrivilege.Select(string.Format("IDTrustee={0} AND IDTipoFunctionGroup={1} AND IdxTipoFunction = {2} AND IDTipoOperation = {3}", ((GISADataset.TrusteeRow)item.Tag).ID, functionOperations[0].IDTipoFunctionGroup, functionOperations[0].IdxTipoFunction, functionOperations[0].IDTipoOperation)).Length == 0)
						item.SubItems[colIndex].Font = PermissoesHelper.fontItalic;
					else
                        item.SubItems[colIndex].Font = PermissoesHelper.fontRegular;
				}
			}
		}
コード例 #5
0
        private void AddObjetoDigital(GISADataset.ObjetoDigitalRow odRow)
        {
            var node = new TreeNode();

            node.ImageIndex         = 3;
            node.SelectedImageIndex = 3;
            node.Text = odRow.Titulo;
            node.Tag  = odRow;
            var odRowsSimples = odRow.GetObjetoDigitalRelacaoHierarquicaRowsByObjetoDigitalObjetoDigitalRelacaoHierarquicaUpper().Select(r => r.ObjetoDigitalRowByObjetoDigitalObjetoDigitalRelacaoHierarquica).ToList();

            if (odRowsSimples.Count > 0)
            {
                foreach (var odRowSimples in odRowsSimples.OrderBy(r => r.GUIOrder))
                {
                    var perm = PermissoesHelper.CalculateEffectivePermissions(odRowSimples, SessionHelper.GetGisaPrincipal().TrusteeUserOperator.TrusteeRow, CurrentFRDBase.NivelRow, PermissoesHelper.ObjDigOpREAD.TipoOperationRow);
                    if (perm == PermissoesHelper.PermissionType.ExplicitDeny || perm == PermissoesHelper.PermissionType.ImplicitDeny)
                    {
                        continue;
                    }

                    var subDocNode = new TreeNode();
                    subDocNode.Text               = odRowSimples.Titulo;
                    subDocNode.Tag                = odRowSimples;
                    subDocNode.ImageIndex         = 3;
                    subDocNode.SelectedImageIndex = 3;

                    node.Nodes.Add(subDocNode);
                }

                if (node.Nodes.Count == 0)
                {
                    return;
                }

                node.ForeColor = Color.Gray;
                node.Expand();
            }
            else
            {
                var perm = PermissoesHelper.CalculateEffectivePermissions(odRow, SessionHelper.GetGisaPrincipal().TrusteeUserOperator.TrusteeRow, CurrentFRDBase.NivelRow, PermissoesHelper.ObjDigOpREAD.TipoOperationRow);
                if (perm == PermissoesHelper.PermissionType.ExplicitDeny || perm == PermissoesHelper.PermissionType.ImplicitDeny)
                {
                    return;
                }
            }

            trvODsFedora.Nodes.Add(node);
        }
コード例 #6
0
		private void ValidateCreateRel(PersistencyHelper.PreConcArguments args)
		{
			PersistencyHelper.VerifyRelExistencePreConcArguments vrePsa = null;
			vrePsa = (PersistencyHelper.VerifyRelExistencePreConcArguments)args;

			DataRow[] newRelRow = null;

			if (vrePsa.isCARRow)
			{
				newRelRow = GisaDataSetHelper.GetInstance().ControloAutRel.Select(string.Format("((IDControloAut={0} AND IDControloAutAlias={1}) OR (IDControloAut={1} AND IDControloAutAlias={0})) AND IDTipoRel = {2}", vrePsa.ID, vrePsa.IDUpper, vrePsa.IDTipoRel));
			}
			else
			{
				newRelRow = GisaDataSetHelper.GetInstance().RelacaoHierarquica.Select(string.Format("ID={0} AND IDUpper={1} AND IDTipoNivelRelacionado = {2}", vrePsa.ID, vrePsa.IDUpper, vrePsa.IDTipoRel));
			}

			int result = ControloAutRule.Current.ExistsRel(vrePsa.ID, vrePsa.IDUpper, vrePsa.IDTipoRel, vrePsa.isCARRow, vrePsa.tran);
			switch (result)
			{
				case 0:
					vrePsa.CreateEditResult = PersistencyHelper.VerifyRelExistencePreConcArguments.CreateEditRelationErrors.NoError;
					break;
				case 1:
					vrePsa.CreateEditResult = PersistencyHelper.VerifyRelExistencePreConcArguments.CreateEditRelationErrors.RelationAlreadyExists;
					break;
				case 2:
					vrePsa.CreateEditResult = PersistencyHelper.VerifyRelExistencePreConcArguments.CreateEditRelationErrors.CyclicRelation;
					break;
				case 3:
					vrePsa.CreateEditResult = PersistencyHelper.VerifyRelExistencePreConcArguments.CreateEditRelationErrors.CADeleted;
					break;
			}

            if (!(result == Convert.ToInt32(PersistencyHelper.VerifyRelExistencePreConcArguments.CreateEditRelationErrors.NoError)) && newRelRow.Length > 0)
            {
                newRelRow[0].RejectChanges();
            }
            else if (newRelRow.Length > 0)
            {
                var rhRow = newRelRow[0] as GISADataset.RelacaoHierarquicaRow;
                if (rhRow == null) return;

                PermissoesHelper.AddNivelGrantPermissions(rhRow.NivelRowByNivelRelacaoHierarquica, rhRow.NivelRowByNivelRelacaoHierarquicaUpper, vrePsa.tran);
            }
		}		
コード例 #7
0
        protected virtual void NivelDocumentalListNavigator1_BeforeNewListSelection(object sender, BeforeNewSelectionEventArgs e)
        {
            var topLevelControl = (frmMain)TopLevelControl;

            topLevelControl.EnterWaitMode();

            var nRow      = default(GISADataset.NivelRow);
            var nUpperRow = GisaDataSetHelper.GetInstance().Nivel.Cast <GISADataset.NivelRow>().FirstOrDefault(r => r.RowState != DataRowState.Deleted && r.ID == this.nivelNavigator1.ContextBreadCrumbsPathID);

            if (e.ItemToBeSelected != null)
            {
                nRow = e.ItemToBeSelected.Tag as GISADataset.NivelRow;
            }

            if (nUpperRow != null)
            {
                PermissoesHelper.UpdateNivelPermissions(nRow, nUpperRow, SessionHelper.GetGisaPrincipal().TrusteeUserOperator.ID);
            }

            if (topLevelControl != null && topLevelControl.MasterPanelCount == 1)
            {
                try
                {
                    Debug.WriteLine("NivelDocumentalListNavigator1_BeforeNewListSelection");
                    e.SelectionChange = UpdateContext(e.ItemToBeSelected);

                    if (e.SelectionChange)
                    {
                        UpdateToolBarButtons(e.ItemToBeSelected);
                        updateContextStatusBar(e.ItemToBeSelected);
                    }
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex);
                    throw;
                }
            }

            ((frmMain)TopLevelControl).LeaveWaitMode();
        }
コード例 #8
0
        // selecionar nivel documental
        protected override void NivelDocumentalListNavigator1_BeforeNewListSelection(object sender, GISA.Controls.BeforeNewSelectionEventArgs e)
        {
            var nRow = default(GISADataset.NivelRow);

            if (e.ItemToBeSelected != null)
            {
                nRow = e.ItemToBeSelected.Tag as GISADataset.NivelRow;
            }
            if (nRow != null && this.nivelNavigator1.PanelToggleState != GISA.Controls.Nivel.NivelNavigator.ToggleState.Estrutural)
            {
                PermissoesHelper.LoadObjDigitalPermissions(nRow, SessionHelper.GetGisaPrincipal().TrusteeUserOperator.TrusteeRow);
            }

            base.NivelDocumentalListNavigator1_BeforeNewListSelection(sender, e);

            objetoDigital = null;
            if (e.SelectionChange)
            {
                objetoDigital = CurrentContext.ObjetoDigital;
            }
        }
コード例 #9
0
        public static void ChangeODPermission(GISADataset.TrusteeRow user, GISADataset.NivelRow nivel, ListViewItem item, int colIndex)
        {
            var odRow   = item.Tag as GISADataset.ObjetoDigitalRow;
            var opRow   = item.SubItems[colIndex].Tag as GISADataset.ObjetoDigitalTipoOperationRow;
            var todpRow = GisaDataSetHelper.GetInstance().TrusteeObjetoDigitalPrivilege.Cast <GISADataset.TrusteeObjetoDigitalPrivilegeRow>()
                          .SingleOrDefault(r => r.RowState != DataRowState.Deleted && r.IDObjetoDigital == odRow.ID && r.IDTipoOperation == opRow.IDTipoOperation && r.IDTrustee == user.ID);

            if (todpRow != null)
            {
                if (todpRow.IsGrant)
                {
                    todpRow.IsGrant = false;
                }
                else
                {
                    todpRow.Delete();
                }
            }
            else
            {
                todpRow = GisaDataSetHelper.GetInstance().TrusteeObjetoDigitalPrivilege.Cast <GISADataset.TrusteeObjetoDigitalPrivilegeRow>()
                          .SingleOrDefault(r => r.RowState == DataRowState.Deleted && (long)r["IDObjetoDigital", DataRowVersion.Original] == odRow.ID && (byte)r["IDTipoOperation", DataRowVersion.Original] == opRow.IDTipoOperation && (long)r["IDTrustee", DataRowVersion.Original] == user.ID);

                if (todpRow != null)
                {
                    todpRow.RejectChanges();
                    todpRow.IsGrant = true;
                }
                else
                {
                    todpRow = GisaDataSetHelper.GetInstance().TrusteeObjetoDigitalPrivilege.AddTrusteeObjetoDigitalPrivilegeRow(user, odRow, opRow, true, new byte[] { }, 0);
                }
            }

            // popular as alterações
            var permissaoEfectiva = PermissoesHelper.CalculateEffectivePermissions(odRow, user, nivel, opRow.TipoOperationRow);

            PopulatePermission(item, colIndex, todpRow, permissaoEfectiva);
        }
コード例 #10
0
		private void LoadOperationsAndPermissions(GISADataset.TipoFunctionRow CurrentFunctionGroup, ListViewItem fgItem)
		{
			Debug.Assert(CurrentTrusteeRow != null);

			foreach (GISADataset.FunctionOperationRow fo in GisaDataSetHelper.GetInstance().FunctionOperation)
			{
				fgItem.SubItems.Add(string.Empty);
				if (CurrentFunctionGroup.IDTipoFunctionGroup == fo.IDTipoFunctionGroup && CurrentFunctionGroup.idx == fo.IdxTipoFunction)
				{
					int colIndex = GetColumnIndex(fo.TipoOperationRow.Name);

					PermissoesHelper.PermissionType permissaoEfectiva = PermissoesHelper.CalculateEffectivePermissions(CurrentTrusteeRow, fo);

					if (permissaoEfectiva == PermissoesHelper.PermissionType.ExplicitGrant)
						fgItem.SubItems[colIndex].Text = "Sim";
					else
						fgItem.SubItems[colIndex].Text = "Não";

					if (GisaDataSetHelper.GetInstance().TrusteePrivilege.Select(string.Format("IDTrustee={0} AND IDTipoFunctionGroup={1} AND IdxTipoFunction = {2} AND IDTipoOperation = {3}", CurrentTrusteeRow.ID, fo.IDTipoFunctionGroup, fo.IdxTipoFunction, fo.IDTipoOperation)).Length == 0)
						fgItem.SubItems[colIndex].Font = PermissoesHelper.fontItalic;
				}
			}
		}
コード例 #11
0
        private void NivelDocumentalList1_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e)
        {
            object DragDropObject = null;

            GISADataset.NivelRow nRow = null;
            this.Cursor = Cursors.WaitCursor;

            if (e.Item == null)
            {
                return;
            }

            if (e.Item is ListViewItem)
            {
                if (NivelDocumentalList1.SelectedItems.Count > 1)
                {
                    List <ListViewItem>             lst  = new List <ListViewItem>();
                    Dictionary <long, ListViewItem> dick = new Dictionary <long, ListViewItem>();
                    List <long> nivelIDs = new List <long>();
                    var         perms    = new Dictionary <long, Dictionary <string, byte> >();
                    long        tmpID;
                    foreach (ListViewItem lvItem in NivelDocumentalList1.SelectedItems)
                    {
                        tmpID = ((GISADataset.NivelRow)lvItem.Tag).ID;
                        nivelIDs.Add(tmpID);
                        dick[tmpID] = lvItem;
                    }

                    GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
                    try
                    {
                        perms = PermissoesRule.Current.CalculateEffectivePermissions(nivelIDs, SessionHelper.GetGisaPrincipal().TrusteeUserOperator.ID, ho.Connection);
                    }
                    catch (Exception ex)
                    {
                        Trace.WriteLine(ex.ToString());
                        throw;
                    }
                    finally
                    {
                        ho.Dispose();
                    }

                    foreach (long idNivel in perms.Keys)
                    {
                        var nperm = perms[idNivel];
                        if (nperm.ContainsKey("Ler") && nperm["Ler"] == 1)
                        {
                            lst.Add(dick[idNivel]);
                        }
                    }
                    DragDropObject = lst.ToArray();
                }
                else if (e.Item != null)
                {
                    DragDropObject = (ListViewItem)e.Item;
                    nRow           = (GISADataset.NivelRow)(((ListViewItem)DragDropObject).Tag);
                    PermissoesHelper.UpdateNivelPermissions(nRow, SessionHelper.GetGisaPrincipal().TrusteeUserOperator.ID);
                    if (!PermissoesHelper.AllowRead)
                    {
                        return;
                    }
                }
            }

            if (DragDropObject == null)
            {
                return;
            }

            this.Cursor = Cursors.Default;
            Trace.WriteLine("Dragging " + DragDropObject.ToString().GetType().FullName);
            DoDragDrop(DragDropObject, DragDropEffects.Link);
        }
コード例 #12
0
        private void ChangePermission(GISADataset.TrusteeRow user, ListViewItem item, int colIndex)
        {
            var depRow = item.Tag as GISADataset.DepositoRow;
            var opRow  = item.SubItems[colIndex].Tag as GISADataset.DepositoTipoOperationRow;
            var tdpRow = GisaDataSetHelper.GetInstance().TrusteeDepositoPrivilege.Cast <GISADataset.TrusteeDepositoPrivilegeRow>()
                         .SingleOrDefault(r => r.RowState != DataRowState.Deleted && r.IDDeposito == depRow.ID && r.IDTipoOperation == opRow.IDTipoOperation && r.IDTrustee == user.ID);

            if (tdpRow != null)
            {
                if (tdpRow.IsGrant)
                {
                    tdpRow.IsGrant = false;
                }
                else
                {
                    tdpRow.Delete();
                }
            }
            else
            {
                tdpRow = GisaDataSetHelper.GetInstance().TrusteeDepositoPrivilege.Cast <GISADataset.TrusteeDepositoPrivilegeRow>()
                         .SingleOrDefault(r => r.RowState == DataRowState.Deleted && (long)r["IDDeposito", DataRowVersion.Original] == depRow.ID && (byte)r["IDTipoOperation", DataRowVersion.Original] == opRow.IDTipoOperation && (long)r["IDTrustee", DataRowVersion.Original] == user.ID);

                if (tdpRow != null)
                {
                    tdpRow.RejectChanges();
                    tdpRow.IsGrant = true;
                }
                else
                {
                    tdpRow = GisaDataSetHelper.GetInstance().TrusteeDepositoPrivilege.AddTrusteeDepositoPrivilegeRow(user, depRow, opRow, true, new byte[] { }, 0);
                }
            }

            // popular as alterações
            PermissoesHelper.PermissionType permissaoEfectiva = PermissoesHelper.CalculateEffectivePermissions(CurrentTrustee, opRow.TipoOperationRow, depRow);

            //PermissoesHelper.PopulatePermission(item, colIndex, tdpRow, permissaoEfectiva);
            if (permissaoEfectiva == PermissoesHelper.PermissionType.ExplicitGrant)
            {
                item.SubItems[colIndex].Text = "Sim";
            }
            else
            {
                item.SubItems[colIndex].Text = "Não";
            }

            GISADataset.TrusteeDepositoPrivilegeRow[] tpRows = (GISADataset.TrusteeDepositoPrivilegeRow[])(GisaDataSetHelper.GetInstance().TrusteeDepositoPrivilege.Select(string.Format("IDTrustee={0} AND IDDeposito={1} AND IDTipoOperation={2}", user.ID, depRow.ID, opRow.IDTipoOperation)));

            if (tpRows.Length == 0)
            {
                tpRows = (GISADataset.TrusteeDepositoPrivilegeRow[])(GisaDataSetHelper.GetInstance().TrusteeDepositoPrivilege.Select(string.Format("IDTrustee={0} AND IDDeposito={1} AND IDTipoOperation={2}", user.ID, depRow.ID, opRow.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;
                }
            }
        }
コード例 #13
0
ファイル: FRDOIRecolha.cs プロジェクト: huguitosilva1/gisa
        public override PersistencyHelper.SaveResult Save(bool activateOpcaoCancelar)
        {
            if (this.CurrentFRDBase == null)
            {
                return(PersistencyHelper.SaveResult.unsuccessful);
            }

            List <long>   IDs         = new List <long>();
            List <string> idsToUpdate = new List <string>();
            List <NivelRule.PublicacaoDocumentos> DocsID = new List <NivelRule.PublicacaoDocumentos> ();

            GISADataset.RelacaoHierarquicaRow rhRow          = null;
            PersistencyHelper.SaveResult      successfulSave = PersistencyHelper.SaveResult.unsuccessful;

            if ((CurrentFRDBase.NivelRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica().Length > 0))
            {
                rhRow = CurrentFRDBase.NivelRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica()[0];

                PersistencyHelper.PublishSubDocumentosPreSaveArguments   psArgs1 = new PersistencyHelper.PublishSubDocumentosPreSaveArguments();
                PersistencyHelper.AvaliaDocumentosTabelaPreSaveArguments psArgs2 = new PersistencyHelper.AvaliaDocumentosTabelaPreSaveArguments();

                // publicação de subdocumentos baseado na publicação dos documentos respectivos
                if (rhRow.IDTipoNivelRelacionado == TipoNivelRelacionado.D)
                {
                    //contexto é um documento
                    if (CurrentFRDBase.GetSFRDAvaliacaoRows().Length > 0)
                    {
                        GISADataset.SFRDAvaliacaoRow relRow = CurrentFRDBase.GetSFRDAvaliacaoRows()[0];

                        if ((relRow.RowState == DataRowState.Added && relRow.Publicar) || relRow.RowState == DataRowState.Modified)
                        {
                            DocsID.Add(new DBAbstractDataLayer.DataAccessRules.NivelRule.PublicacaoDocumentos(CurrentFRDBase.NivelRow.ID, CurrentFRDBase.GetSFRDAvaliacaoRows()[0].Publicar));
                            IDs.Add(CurrentFRDBase.NivelRow.ID);
                            PermissoesHelper.ChangeDocPermissionPublicados(CurrentFRDBase.NivelRow.ID, (CurrentFRDBase.GetSFRDAvaliacaoRows())[0].Publicar);
                        }
                    }
                }
                else if (rhRow.IDTipoNivelRelacionado == TipoNivelRelacionado.SR || rhRow.IDTipoNivelRelacionado == TipoNivelRelacionado.SSR)
                {
                    //o contexto é uma série ou subsérie e é alterado o estado de publicação de vários documentos simultaneamente
                    foreach (GISADataset.SFRDAvaliacaoRow sfrdAv in GisaDataSetHelper.GetInstance().SFRDAvaliacao.Select("", "", DataViewRowState.Added | DataViewRowState.ModifiedCurrent))
                    {
                        if (sfrdAv.FRDBaseRow.ID != CurrentFRDBase.ID)
                        {
                            DocsID.Add(new DBAbstractDataLayer.DataAccessRules.NivelRule.PublicacaoDocumentos(sfrdAv.FRDBaseRow.NivelRow.ID, sfrdAv.Publicar));
                            IDs.Add(sfrdAv.FRDBaseRow.NivelRow.ID);
                            PermissoesHelper.ChangeDocPermissionPublicados(sfrdAv.FRDBaseRow.NivelRow.ID, sfrdAv.Publicar);
                        }
                        else
                        {
                            IDs.Add(sfrdAv.FRDBaseRow.IDNivel);
                        }
                    }

                    if (!(CurrentFRDBase.GetSFRDAvaliacaoRows().Length == 0 || CurrentFRDBase.GetSFRDAvaliacaoRows()[0].IsIDModeloAvaliacaoNull() || (!(CurrentFRDBase.GetSFRDAvaliacaoRows()[0].RowState == DataRowState.Added) && !(CurrentFRDBase.GetSFRDAvaliacaoRows()[0]["IDModeloAvaliacao", DataRowVersion.Original] == DBNull.Value) && ((long)(CurrentFRDBase.GetSFRDAvaliacaoRows()[0]["IDModeloAvaliacao", DataRowVersion.Original])) == (long)(CurrentFRDBase.GetSFRDAvaliacaoRows()[0]["IDModeloAvaliacao", DataRowVersion.Current]))))
                    {
                        psArgs2.frdID             = CurrentFRDBase.ID;
                        psArgs2.modeloAvaliacaoID = CurrentFRDBase.GetSFRDAvaliacaoRows()[0].IDModeloAvaliacao;
                        psArgs2.avaliacaoTabela   = CurrentFRDBase.GetSFRDAvaliacaoRows()[0].AvaliacaoTabela;
                        if (CurrentFRDBase.GetSFRDAvaliacaoRows()[0].IsPrazoConservacaoNull())
                        {
                            psArgs2.prazoConservacao = 0;
                        }
                        else
                        {
                            psArgs2.prazoConservacao = CurrentFRDBase.GetSFRDAvaliacaoRows()[0].PrazoConservacao;
                        }

                        psArgs2.preservar = CurrentFRDBase.GetSFRDAvaliacaoRows()[0].Preservar;
                    }
                }
                else
                {
                    foreach (GISADataset.SFRDAvaliacaoRow sfrdAv in GisaDataSetHelper.GetInstance().SFRDAvaliacao.Select("", "", DataViewRowState.Added | DataViewRowState.ModifiedCurrent))
                    {
                        PermissoesHelper.ChangeDocPermissionPublicados(sfrdAv.FRDBaseRow.NivelRow.ID, sfrdAv.Publicar);
                        IDs.Add(sfrdAv.FRDBaseRow.IDNivel);
                    }
                }

                // actualização do objecto digital caso exista ou o módulo esteja activo
                rhRow = CurrentFRDBase.NivelRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica().First();
                var objDigital = default(ObjDigital);
                if (rhRow.IDTipoNivelRelacionado >= (long)TipoNivelRelacionado.D && SessionHelper.AppConfiguration.GetCurrentAppconfiguration().IsFedoraEnable())
                {
                    GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
                    try
                    {
                        GisaDataSetHelper.ManageDatasetConstraints(false);
                        if (!PanelAmbitoConteudo1.IsLoaded)
                        {
                            PanelAmbitoConteudo1.LoadData(CurrentFRDBase, ho.Connection);
                        }
                        if (!PanelIndexacao1.IsLoaded)
                        {
                            PanelIndexacao1.LoadData(CurrentFRDBase, ho.Connection);
                        }
                        GisaDataSetHelper.ManageDatasetConstraints(true);
                    }
                    catch (System.Data.ConstraintException Ex)
                    {
                        Trace.WriteLine(Ex);
                        GisaDataSetHelper.FixDataSet(GisaDataSetHelper.GetInstance(), ho.Connection);
                    }
                    catch (Exception e)
                    {
                        Trace.WriteLine(e);
                        throw;
                    }
                    finally
                    {
                        ho.Dispose();
                    }

                    // verificar alterações na tipologia e indexação
                    var tipologia = string.Empty;
                    var hasNewTip = Nivel.HasTipologiaChanged(CurrentFRDBase, out tipologia);
                    var assuntos  = Nivel.HasIndexacaoChanged(CurrentFRDBase);

                    if (hasNewTip || assuntos != null)
                    {
                        objDigital = FedoraHelper.UpdateTipAssuntos(CurrentFRDBase.NivelRow, hasNewTip ? tipologia : null, assuntos);
                    }
                }

                // actualizar objecto digital caso exista
                var preTransactionAction = new PreTransactionAction();
                var fedArgs = new PersistencyHelper.FedoraIngestPreTransactionArguments();
                preTransactionAction.args = fedArgs;

                preTransactionAction.preTransactionDelegate = delegate(PersistencyHelper.PreTransactionArguments preTransactionArgs)
                {
                    var    odComp        = this.PanelObjetoDigitalFedora1.GetObjDigitalComp();
                    var    odSimples     = this.PanelObjetoDigitalFedora1.GetObjDigitalSimples();
                    bool   ingestSuccess = true;
                    string msg           = null;

                    if (odComp != null)
                    {
                        ingestSuccess = SessionHelper.AppConfiguration.GetCurrentAppconfiguration().FedoraHelperSingleton.Ingest(odComp, out msg);
                    }
                    else if (odSimples != null && odSimples.Count > 0)
                    {
                        odSimples.ForEach(od => ingestSuccess &= SessionHelper.AppConfiguration.GetCurrentAppconfiguration().FedoraHelperSingleton.Ingest(od, out msg));
                    }

                    if (ingestSuccess)
                    {
                        this.PanelObjetoDigitalFedora1.odHelper.newObjects.Keys.ToList().ForEach(k => { k.pid = this.PanelObjetoDigitalFedora1.odHelper.newObjects[k].pid; });
                    }

                    preTransactionArgs.cancelAction = !ingestSuccess;
                    preTransactionArgs.message      = msg;
                };

                psArgs1.DocsID = DocsID;

                PostSaveAction postSaveAction = new PostSaveAction();
                PersistencyHelper.UpdatePermissionsPostSaveArguments argsPSAction = new PersistencyHelper.UpdatePermissionsPostSaveArguments();
                argsPSAction.NiveisIDs = IDs;
                argsPSAction.TrusteeID = PermissoesHelper.GrpAcessoPublicados.ID;
                postSaveAction.args    = argsPSAction;

                postSaveAction.postSaveDelegate = delegate(PersistencyHelper.PostSaveArguments postSaveArgs)
                {
                    if (!postSaveArgs.cancelAction && argsPSAction.NiveisIDs.Count > 0)
                    {
                        if (psArgs1 != null)
                        {
                            idsToUpdate = psArgs1.idsToUpdate;
                        }
                    }
                };

                PersistencyHelper.AvaliacaoPublicacaoPreSaveArguments args = new PersistencyHelper.AvaliacaoPublicacaoPreSaveArguments();
                args.psArgs1 = psArgs1;
                args.psArgs2 = psArgs2;

                successfulSave = PersistencyHelper.save(AvaliacaoPublicacao, args, postSaveAction, preTransactionAction, activateOpcaoCancelar);
            }
            else
            {
                successfulSave = PersistencyHelper.save();
            }

            if (successfulSave == PersistencyHelper.SaveResult.successful)
            {
                GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
                try
                {
                    if (CurrentFRDBase.NivelRow.IDTipoNivel == TipoNivel.DOCUMENTAL)
                    {
                        if (idsToUpdate == null)
                        {
                            idsToUpdate = new List <string>();
                        }
                        idsToUpdate.Add(CurrentFRDBase.NivelRow.ID.ToString());
                        GISA.Search.Updater.updateNivelDocumental(idsToUpdate);
                    }
                    ((frmMain)TopLevelControl).SetServerStatus();
                }
                catch (GISA.Search.UpdateServerException)
                {
                    ((frmMain)TopLevelControl).SetServerStatus();
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex.ToString());
                    throw;
                }
                finally
                {
                    ho.Dispose();
                }
            }

            return(successfulSave);
        }
コード例 #14
0
        // Trata a criação de novos níveis e respectivas relações. Caso se trate
        // de um nível orgânico (estrutural e que esteja associado a uma EP) o
        // nível correspondente deverá já existir e não será por isso criado,
        // será criada apenas a relação.
        private bool handleNewNivel(Form frm, GISADataset.NivelRow parentNivelRow, GISADataset.TipoNivelRelacionadoRow tnrRow)
        {
            frm.Text = "Criar " + tnrRow.Designacao;

            bool successfulSave = true;

            switch (frm.ShowDialog())
            {
            case DialogResult.OK:

                Trace.WriteLine("A criar nível...");

                long           click = DateTime.Now.Ticks;
                string         designacaoUFAssociada = string.Empty;
                PostSaveAction postSaveAction        = null;
                var            nRow   = GisaDataSetHelper.GetInstance().Nivel.AddNivelRow(tnrRow.TipoNivelRow, ((FormAddNivel)frm).txtCodigo.Text.Trim(), "NVL", new byte[] { }, 0);
                var            ndRow  = GisaDataSetHelper.GetInstance().NivelDesignado.AddNivelDesignadoRow(nRow, ((FormAddNivel)frm).txtDesignacao.Text.Trim(), new byte[] { }, 0);
                var            frdRow = GisaDataSetHelper.GetInstance().FRDBase.AddFRDBaseRow(nRow, (GISADataset.TipoFRDBaseRow)(GisaDataSetHelper.GetInstance().TipoFRDBase.Select("ID=" + DomainValuesHelper.stringifyEnumValue(TipoFRDBase.FRDOIRecolha))[0]), "", "", new byte[] { }, 0);
                var            rhRow  = GisaDataSetHelper.GetInstance().RelacaoHierarquica.AddRelacaoHierarquicaRow(nRow, parentNivelRow, tnrRow, null, null, null, null, null, null, null, new byte[] { }, 0);

                //valores por omissão
                var globalConfig = GisaDataSetHelper.GetInstance().GlobalConfig.Cast <GISADataset.GlobalConfigRow>().Single();
                if (globalConfig.ApplyDefaultValues)
                {
                    var sfrdcaRow = GisaDataSetHelper.GetInstance().SFRDCondicaoDeAcesso
                                    .AddSFRDCondicaoDeAcessoRow(frdRow, "", globalConfig.IsCondicaoDeAcessoNull() ? "" : globalConfig.CondicaoDeAcesso,
                                                                globalConfig.IsCondicaoDeReproducaoNull() ? "" : globalConfig.CondicaoDeReproducao, "", new byte[] {}, 0);

                    foreach (GISADataset.ConfigLinguaRow r in globalConfig.GetConfigLinguaRows())
                    {
                        GisaDataSetHelper.GetInstance().SFRDLingua.AddSFRDLinguaRow(sfrdcaRow, r.Iso639Row, new byte[] { }, 0);
                    }

                    foreach (GISADataset.ConfigAlfabetoRow r in globalConfig.GetConfigAlfabetoRows())
                    {
                        GisaDataSetHelper.GetInstance().SFRDAlfabeto.AddSFRDAlfabetoRow(sfrdcaRow, r.Iso15924Row, new byte[] { }, 0);
                    }
                }

                var selectedTipologia = ((FormNivelDocumentalFedora)frm).Tipologia;
                if (selectedTipologia != null)
                {
                    GisaDataSetHelper.GetInstance().IndexFRDCA.AddIndexFRDCARow(frdRow, selectedTipologia.ControloAutRow, -1, new byte[] { }, 0);
                }

                // Só adicionar permissões ao grupo TODOS dos níveis lógicos e a níveis documentais imediatamente
                // abaixo de níveis orgânicos (Documentos soltos e séries); caso se se trate de um nível estrutural
                // controlado, as permissões já foram atribuidas aquando da criação do controlo de autoridade
                if (nRow.IDTipoNivel == TipoNivel.DOCUMENTAL && parentNivelRow.IDTipoNivel == TipoNivel.ESTRUTURAL)
                {
                    var nUpperRow = rhRow == null ? default(GISADataset.NivelRow) : rhRow.NivelRowByNivelRelacaoHierarquicaUpper;
                    PermissoesHelper.AddNewNivelGrantPermissions(nRow, nUpperRow);
                }

                postSaveAction = new PostSaveAction();
                var args = new PersistencyHelper.GenericPostSaveArguments();
                postSaveAction.args             = args;
                postSaveAction.postSaveDelegate = delegate(PersistencyHelper.PostSaveArguments postSaveArgs)
                {
                    if (!postSaveArgs.cancelAction && nRow != null && nRow.RowState != DataRowState.Detached && nRow.RowState != DataRowState.Deleted)
                    {
                        // registar a criação do nivel documental
                        GISADataset.FRDBaseRow   frdDocRow  = null;
                        GISADataset.FRDBaseRow[] frdDocRows = nRow.GetFRDBaseRows();
                        if (frdDocRows.Length > 0)
                        {
                            frdDocRow = frdDocRows[0];
                        }
                        CurrentContext.RaiseRegisterModificationEvent(frdDocRow);

                        PersistencyHelperRule.Current.saveRows(GisaDataSetHelper.GetInstance().FRDBaseDataDeDescricao,
                                                               GisaDataSetHelper.GetInstance().FRDBaseDataDeDescricao.Cast <GISADataset.FRDBaseDataDeDescricaoRow>().Where(frd => frd.RowState == DataRowState.Added).ToArray(), postSaveArgs.tran);
                    }
                };

                // se se tratar de um (sub)documento é necessário garantir que se trata de um código
                // único dentro da sua série (se constituir série) ou nivel estrutural superior
                PersistencyHelper.ValidateNivelAddAndAssocNewUFPreConcArguments pcArgs = new PersistencyHelper.ValidateNivelAddAndAssocNewUFPreConcArguments();
                PersistencyHelper.SetNewCodigosPreSaveArguments           psArgs       = new PersistencyHelper.SetNewCodigosPreSaveArguments();
                PersistencyHelper.EnsureUniqueCodigoNivelPreConcArguments pcArgsNivel  = new PersistencyHelper.EnsureUniqueCodigoNivelPreConcArguments();

                pcArgs.argsNivel = pcArgsNivel;

                // dados que serão usados no delegate responsável pela criação do nível documental
                pcArgsNivel.nRowID              = nRow.ID;
                pcArgsNivel.ndRowID             = ndRow.ID;
                pcArgsNivel.rhRowID             = rhRow.ID;
                pcArgsNivel.rhRowIDUpper        = rhRow.IDUpper;
                pcArgsNivel.frdBaseID           = frdRow.ID;
                pcArgsNivel.testOnlyWithinNivel = true;

                // permitir ao delegate selecionar o delegate correspondente ao tipo de nível que se está a criar
                pcArgs.IDTipoNivelRelacionado = tnrRow.ID;

                psArgs.createNewNivelCodigo = false;
                psArgs.createNewUFCodigo    = false;
                psArgs.setNewCodigo         = rhRow.IDTipoNivelRelacionado == TipoNivelRelacionado.SD;
                psArgs.argsNivelDocSimples  = NiveisHelper.AddNivelDocumentoSimplesWithDelegateArgs(nRow.GetNivelDesignadoRows().Single(), rhRow.IDUpper, rhRow.IDTipoNivelRelacionado);

                PersistencyHelper.save(DelegatesHelper.ValidateNivelAddAndAssocNewUF, pcArgs, DelegatesHelper.SetNewCodigos, psArgs, postSaveAction);
                if (!pcArgsNivel.successful)
                {
                    successfulSave = false;
                    MessageBox.Show(pcArgsNivel.message, "Criação de unidade de descrição", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (parentNivelRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica()[0].TipoNivelRelacionadoRow.ID == TipoNivelRelacionado.SR)
                {
                    GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
                    try
                    {
                        DBAbstractDataLayer.DataAccessRules.FRDRule.Current.LoadSFRDAvaliacaoData(GisaDataSetHelper.GetInstance(), parentNivelRow.ID, ho.Connection);
                    }
                    finally
                    {
                        ho.Dispose();
                    }
                }

                PersistencyHelper.cleanDeletedData(new List <TableDepthOrdered.TableCloudType>(new TableDepthOrdered.TableCloudType[] { PersistencyHelper.determinaNuvem("RelacaoHierarquica"), PersistencyHelper.determinaNuvem("FRDBase") }));

                if (!successfulSave)
                {
                    return(successfulSave);
                }

                GISA.Search.Updater.updateNivelDocumentalComProdutores(nRow.ID);
                GISA.Search.Updater.updateNivelDocumental(nRow.ID);

                this.nivelNavigator1.AddNivel(nRow);

                Debug.WriteLine("<<A criar nível...>> " + new TimeSpan(DateTime.Now.Ticks - click).ToString());
                break;

            case DialogResult.Cancel:
                successfulSave = false;
                break;
            }

            return(successfulSave);
        }