Пример #1
0
		private void caList_BeforeNewListSelection(object sender, BeforeNewSelectionEventArgs e)
		{
			if (e.ItemToBeSelected.ListView == null || (e.ItemToBeSelected != null && e.ItemToBeSelected.ListView == null))
			{
				relacaoCA.ContextNivelRow = null;
			}
			else
			{
				GISADataset.ControloAutRow caRow = null;
				caRow = ((GISADataset.ControloAutDicionarioRow)e.ItemToBeSelected.Tag).ControloAutRow;

				IDbConnection conn = GisaDataSetHelper.GetConnection();
				try
				{
					conn.Open();

					DBAbstractDataLayer.DataAccessRules.NivelRule.Current.LoadNivelByControloAut(caRow.ID, GisaDataSetHelper.GetInstance(), conn);
				}
				catch (Exception ex)
				{
					Trace.WriteLine(ex);
					throw;
				}
				finally
				{
					conn.Close();
				}
				relacaoCA.ContextNivelRow = caRow.GetNivelControloAutRows()[0].NivelRow;
			}

			RefreshButtonState(e.ItemToBeSelected);
		}
Пример #2
0
        private void UpdateCA(GISADataset.ControloAutRow caRow)
        {
            switch (caRow.IDTipoNoticiaAut)
            {
            case (long)TipoNoticiaAut.EntidadeProdutora:
                GISA.Search.Updater.updateProdutor(caRow.ID);
                GISA.Search.Updater.updateNivelDocumentalComProdutores(caRow.GetNivelControloAutRows()[0].ID);
                break;

            case (long)TipoNoticiaAut.Onomastico:
            case (long)TipoNoticiaAut.Ideografico:
            case (long)TipoNoticiaAut.ToponimicoGeografico:
                GISA.Search.Updater.updateAssunto(caRow.ID);
                break;

            case (long)TipoNoticiaAut.TipologiaInformacional:
                GISA.Search.Updater.updateTipologia(caRow.ID);
                break;
            }
        }
Пример #3
0
        public override PersistencyHelper.SaveResult Save(bool activateOpcaoCancelar)
		{
            PersistencyHelper.SaveResult successfulSave = base.Save(activateOpcaoCancelar);
            if (successfulSave == PersistencyHelper.SaveResult.successful)
			{
				GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
                try
                {
                    List<string> IDNiveis = ControloAutRule.Current.GetNiveisDocAssociados(CurrentControloAut.ID, ho.Connection);
                    GISA.Search.Updater.updateNivelDocumental(IDNiveis);
                    switch (CurrentControloAut.IDTipoNoticiaAut)
                    {
                        case (long)TipoNoticiaAut.EntidadeProdutora:
                            GISA.Search.Updater.updateProdutor(CurrentControloAut.ID);
                            GISA.Search.Updater.updateNivelDocumentalComProdutores(CurrentControloAut.GetNivelControloAutRows()[0].ID);
                            break;
                        case (long)TipoNoticiaAut.Onomastico:
                        case (long)TipoNoticiaAut.Ideografico:
                        case (long)TipoNoticiaAut.ToponimicoGeografico:
                            GISA.Search.Updater.updateAssunto(CurrentControloAut.ID);
                            break;
                        case (long)TipoNoticiaAut.TipologiaInformacional:
                            GISA.Search.Updater.updateTipologia(CurrentControloAut.ID);
                            break;
                    }
                }
                catch (GISA.Search.UpdateServerException)
                { }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex.ToString());
                    throw;
                }
				finally
				{
					ho.Dispose();
				}
			}
            return successfulSave;
		}
Пример #4
0
        public override void ModelToView()
        {
            IsPopulated = false;
            lstVwRelacoes.Items.Clear();

            // Apresentar relações não hierarquicas
            string carId = CurrentControloAut.ID.ToString();

            QueryFilter = "IDControloAut=" + carId + " OR IDControloAutAlias=" + carId;
            foreach (GISADataset.ControloAutRelRow caRel in GisaDataSetHelper.GetInstance().ControloAutRel.Select(QueryFilter, "InicioAno, InicioMes, InicioDia, FimAno, FimMes, FimDia"))
            {
                if (caRel.TipoControloAutRelRow.ID != Convert.ToInt64(TipoControloAutRel.Instituicao))                 //System.Enum.Format(GetType(TipoControloAutRel), TipoControloAutRel.Instituicao, "D") Then
                {
                    GISADataset.ControloAutRow OtherControloAut = null;
                    if (caRel.ControloAutRowByControloAutControloAutRelAlias.ID != CurrentControloAut.ID)
                    {
                        OtherControloAut = caRel.ControloAutRowByControloAutControloAutRelAlias;
                    }
                    else
                    {
                        OtherControloAut = caRel.ControloAutRowByControloAutControloAutRel;
                    }
                    foreach (GISADataset.ControloAutDicionarioRow cad in OtherControloAut.GetControloAutDicionarioRows())
                    {
                        if (cad.IDTipoControloAutForma == Convert.ToInt64(TipoControloAutForma.FormaAutorizada))
                        {
                            ListViewItem tempWith1 = lstVwRelacoes.Items.Add(cad.DicionarioRow.Termo);
                            tempWith1.Tag = caRel;
                            if (cad.ControloAutRow.IsChaveColectividadeNull())
                            {
                                tempWith1.SubItems.Add(string.Empty);
                            }
                            else
                            {
                                tempWith1.SubItems.Add(cad.ControloAutRow.ChaveColectividade);
                            }
                            string rezDesTipoRel = null;
                            if (caRel.ControloAutRowByControloAutControloAutRelAlias.ID != CurrentControloAut.ID)
                            {
                                rezDesTipoRel = caRel.TipoControloAutRelRow.DesignacaoInversa;
                            }
                            else
                            {
                                rezDesTipoRel = caRel.TipoControloAutRelRow.Designacao;
                            }
                            tempWith1.SubItems.Add(rezDesTipoRel);
                            tempWith1.SubItems.Add(GUIHelper.GUIHelper.FormatStartDate(caRel));
                            tempWith1.SubItems.Add(GUIHelper.GUIHelper.FormatEndDate(caRel));
                            tempWith1.SubItems.Add(GUIHelper.GUIHelper.ClipText(caRel.Descricao));
                        }
                    }
                }
            }

            // Apresentar relações hierarquicas
            GISADataset.NivelRow nRow = null;
            GISADataset.NivelControloAutRow[] ncaRows = null;
            GISADataset.NivelControloAutRow   ncaRow  = null;
            ncaRows = CurrentControloAut.GetNivelControloAutRows();
            if (ncaRows.Length == 0)
            {
                MasterPanelControloAut.CreateAssociatedNivel(CurrentControloAut, ref nRow, ref ncaRow);
                try
                {
                    PersistencyHelper.save();
                    PersistencyHelper.cleanDeletedData();
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex);
                    throw;
                }
            }
            else
            {
                ncaRow = ncaRows[0];
                nRow   = ncaRow.NivelRow;
            }

            foreach (GISADataset.RelacaoHierarquicaRow rhRow in GisaDataSetHelper.GetInstance().RelacaoHierarquica.Select(string.Format("ID={0} OR IDUpper={0}", nRow.ID), "InicioAno, InicioMes, InicioDia, FimAno, FimMes, FimDia"))
            {
                // Só adicionar relações hierárquicas existentes entre níveis estruturais. Este teste não seria suficiente no caso de existirem níveis estruturais orgânicos relacionados com níveis estruturais temático-funcionais, mas tal não poderá acontecer em qualquer situação.
                if (rhRow.NivelRowByNivelRelacaoHierarquica.TipoNivelRow.ID == TipoNivel.ESTRUTURAL && rhRow.NivelRowByNivelRelacaoHierarquicaUpper.TipoNivelRow.ID == TipoNivel.ESTRUTURAL)
                {
                    GISADataset.ControloAutRow caRow = null;
                    caRow = rhRow.NivelRowByNivelRelacaoHierarquica.GetNivelControloAutRows()[0].ControloAutRow;
                    // Se estivermos a ver o extremo errado da relação hierarquica trocamos para o outro extremo
                    if (CurrentControloAut == caRow)
                    {
                        caRow = rhRow.NivelRowByNivelRelacaoHierarquicaUpper.GetNivelControloAutRows()[0].ControloAutRow;
                    }

                    GISADataset.ControloAutDicionarioRow cadRow = null;
                    cadRow = ControloAutHelper.getFormaAutorizada(caRow);

                    ListViewItem newItem = lstVwRelacoes.Items.Add(cadRow.DicionarioRow.Termo);
                    newItem.Tag = rhRow;
                    AddRelacaoHierarquicaToList(newItem);
                }
            }

            RefreshButtonState();
            PopulateDescricaoText();
            IsPopulated = true;
        }
Пример #5
0
		protected override void AcceptContents(object Value)
		{
			GISADataset.ControloAutRow ControloAutRow = (GISADataset.ControloAutRow)Value;

			if (FRDBase != null)
			{
				// Carregar nivel do CA largado

				IDbConnection conn = GisaDataSetHelper.GetConnection();
				try
				{
					conn.Open();
					DBAbstractDataLayer.DataAccessRules.NivelRule.Current.LoadNivelByControloAut(ControloAutRow.ID, GisaDataSetHelper.GetInstance(), conn);
				}
				finally
				{
					conn.Close();
				}

				if (IsValidRelacaoHierarquica(ControloAutRow))
				{
					// Apresentar form que permita escolher a data da relação
					FormRelacaoHierarquica frmRh = new FormRelacaoHierarquica();
					// Pode-se obter a primeira relação encontrada para efeitos de determinação 
					// do tipo de nível uma vez que o tipo de nível dos níveis documentais nunca se alterará
					frmRh.relacaoNvl.TipoNivelRelacionadoRow = TipoNivelRelacionado.GetPrimeiraRelacaoEncontrada(this.FRDBase.NivelRow).TipoNivelRelacionadoRow;
					frmRh.relacaoNvl.ContextNivelRow = ControloAutRow.GetNivelControloAutRows()[0].NivelRow;
					if (frmRh.ShowDialog() == DialogResult.Cancel)
					{
						return;
					}

					if (GisaDataSetHelper.GetInstance().RelacaoHierarquica.Select(string.Format("ID={0} AND IDUpper={1}", this.FRDBase.NivelRow.ID, ControloAutRow.GetNivelControloAutRows()[0].NivelRow.ID), "", DataViewRowState.Deleted).Length > 0)
					{

						GisaDataSetHelper.GetInstance().RelacaoHierarquica.Select(string.Format("ID={0} AND IDUpper={1}", this.FRDBase.NivelRow.ID, ControloAutRow.GetNivelControloAutRows()[0].NivelRow.ID), "", DataViewRowState.Deleted)[0].AcceptChanges();
					}

					GISADataset.RelacaoHierarquicaRow rhRow = null;
					rhRow = GisaDataSetHelper.GetInstance().RelacaoHierarquica.NewRelacaoHierarquicaRow();
					TempRelacaoHierarquica = rhRow;

					rhRow.ID = this.FRDBase.NivelRow.ID;
					rhRow.IDUpper = ControloAutRow.GetNivelControloAutRows()[0].NivelRow.ID;
					rhRow.IDTipoNivelRelacionado = TipoNivelRelacionado.GetTipoNivelRelacionadoDaPrimeiraRelacaoEncontrada(this.FRDBase.NivelRow).ID;
					rhRow.Descricao = frmRh.relacaoNvl.txtDescricao.Text;
					rhRow.InicioAno = frmRh.relacaoNvl.dtRelacaoInicio.ValueYear;
					rhRow.InicioMes = frmRh.relacaoNvl.dtRelacaoInicio.ValueMonth;
					rhRow.InicioDia = frmRh.relacaoNvl.dtRelacaoInicio.ValueDay;
					rhRow.FimAno = frmRh.relacaoNvl.dtRelacaoFim.ValueYear;
					rhRow.FimMes = frmRh.relacaoNvl.dtRelacaoFim.ValueMonth;
					rhRow.FimDia = frmRh.relacaoNvl.dtRelacaoFim.ValueDay;
					GisaDataSetHelper.GetInstance().RelacaoHierarquica.AddRelacaoHierarquicaRow(rhRow);

                    // no caso de se tratar de uma entidade produtora é necessário validar o código de referência do nivel documental do contexto
                    if (ControloAutRow.IDTipoNoticiaAut == (long)TipoNoticiaAut.EntidadeProdutora)
                    {
                        var argsPC = new PersistencyHelper.EnsureUniqueCodigoNivelPreConcArguments();
                        argsPC.rhRowID = rhRow.ID;
                        argsPC.rhRowIDUpper = rhRow.IDUpper;

                        var postSaveAction = new PostSaveAction();
                        PersistencyHelper.UpdatePermissionsPostSaveArguments args = new PersistencyHelper.UpdatePermissionsPostSaveArguments();
                        postSaveAction.args = args;

                        postSaveAction.postSaveDelegate = delegate(PersistencyHelper.PostSaveArguments postSaveArgs)
                        {
                            if (argsPC.successful)
                            {
                                if (this.parent == null)
                                    Debug.Assert(false, "CONTEXTO PARENT DEVE ESTAR DEFINIDO.");

                                if (this.parent.GetType() == typeof(MasterPanelSeries))
                                {
                                    ((MasterPanelSeries)this.parent).CurrentContext.RaiseRegisterModificationEvent(this.FRDBase);
                                    PersistencyHelperRule.Current.saveRows(GisaDataSetHelper.GetInstance().FRDBaseDataDeDescricao,
                                        GisaDataSetHelper.GetInstance().FRDBaseDataDeDescricao.Cast<GISADataset.FRDBaseDataDeDescricaoRow>().Where(r => r.RowState == DataRowState.Added).ToArray(), postSaveArgs.tran);
                                }
                            }
                        };

                        var result = PersistencyHelper.save(DelegatesHelper.verificaCodigosRepetidos, argsPC, postSaveAction, true);

                        if (result == PersistencyHelper.SaveResult.successful)
                        {
                            PersistencyHelper.cleanDeletedData();
                            GisaDataSetHelper.VisitControloAutDicionario(ControloAutRow, DisplayFormaAutorizada);
                            GISA.Search.Updater.updateNivelDocumental(this.FRDBase.NivelRow.ID);
                        }
                        else
                        {
                            if (argsPC.message.Length > 0)
                                MessageBox.Show(argsPC.message, "Adição", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }

					
				}
				else
				{
					MessageBox.Show("Não é possível a existência de items repetidos.", "Adição", MessageBoxButtons.OK, MessageBoxIcon.Warning);
				}
			}
			else if (this.ControloAut != null)
			{
				Debug.Assert(false, "ORGANIC RELATIONS BETWEEN CAS NOT IMPLEMENTED. SHOULDN'T BE NEEDED");
			}
		}
Пример #6
0
		private bool IsValidRelacaoHierarquica(GISADataset.ControloAutRow ControloAutRow)
		{

			if (GisaDataSetHelper.GetInstance().RelacaoHierarquica.Select(string.Format("ID={0} AND IDUpper={1} OR ID={1} AND IDUpper={0}", ControloAutRow.GetNivelControloAutRows()[0].NivelRow.ID, this.FRDBase.NivelRow.ID)).Length > 0)
			{
				return false;
			}
			return true;
		}
Пример #7
0
//INSTANT C# NOTE: C# does not support optional parameters. Overloaded method(s) are created above.
//ORIGINAL LINE: Public Shared Sub DeleteControloAut(ByVal caList As ControloAutList, ByVal Caption As String, ByVal Interrogacao As String, ByVal MessageBoxText As String, Optional ByVal caller As Control = null)
		public static void DeleteControloAut(ControloAutList caList, string Caption, string Interrogacao, string MessageBoxText, Control caller)
		{

			bool HasDocumentData = false;
            List<string> nivelIDsAssoc = new List<string>();
			string Detalhes = null;
			
            if (caller != null) ((frmMain)caller.TopLevelControl).EnterWaitMode();
            Detalhes = ControloAutHelper.GetControloAutUsage(caList.SelectedItems.Cast<ListViewItem>().Select(i => i.Tag as GISADataset.ControloAutDicionarioRow).ToList(), ref HasDocumentData, ref nivelIDsAssoc);
            if (caller != null) ((frmMain)caller.TopLevelControl).LeaveWaitMode();

			if (Detalhes.Length > 0)
			{
                FormDeletionReport form = new FormDeletionReport();
                form.Text = Caption;
                form.Interrogacao = Interrogacao;
                form.Detalhes = Detalhes;
				if (HasDocumentData)
				{
                    form.SetBtnOKVisible(false);
                    form.Interrogacao = "Este elemento não pode ser removido enquanto lhe existirem associados níveis documentais.";
				}

                if (form.ShowDialog() == DialogResult.Cancel) return;
			}
			else
			{
				switch (MessageBox.Show(MessageBoxText, Caption, MessageBoxButtons.OKCancel))
				{
					case System.Windows.Forms.DialogResult.OK:
					break;
					case System.Windows.Forms.DialogResult.Cancel:
						return;
					default:
						Debug.Assert(false, "Unexpected DialogResult.");
						break;
				}
			}

			Trace.WriteLine("A apagar notícia de autoridade...");

			ListViewItem selectedItem = null;
			if (caList.SelectedItems.Count > 0)
			{
				Debug.Assert(caList.SelectedItems.Count == 1, "Só deveria existir 1 item selecionado.");
				selectedItem = caList.SelectedItems[0];

				GISADataset.ControloAutDicionarioRow cadRow = null;
				GISADataset.ControloAutRow caRow = null;
				cadRow = (GISADataset.ControloAutDicionarioRow)selectedItem.Tag;
				caRow = cadRow.ControloAutRow;

				// Remover a selecção do item vai provocar uma mudança de contexto que 
				// por sua vez vai provocar uma gravação dos dados
				caList.ClearItemSelection(selectedItem);

                var ho = default(GisaDataSetHelper.HoldOpen);
                if (caller != null && caller.GetType() == typeof(MasterPanelControloAut))
                {
                    ((MasterPanelControloAut)caller).CurrentContext.RaiseRegisterModificationEvent(caRow);

                    if (caRow.IDTipoNoticiaAut == (long)TipoNoticiaAut.EntidadeProdutora)
                    {
                        var frdRow = default(GISADataset.FRDBaseRow);
                        long IDTipoNivelRelacionado = -1;
                        ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
                        try
                        {
                            DBAbstractDataLayer.DataAccessRules.FRDRule.Current.LoadFRD(GisaDataSetHelper.GetInstance(), caRow.GetNivelControloAutRows().Single().ID, ho.Connection);
                            frdRow = caRow.GetNivelControloAutRows().Single().NivelRow.GetFRDBaseRows().SingleOrDefault();
                            DBAbstractDataLayer.DataAccessRules.NivelRule.Current.LoadNivelParents(caRow.GetNivelControloAutRows().Single().ID, GisaDataSetHelper.GetInstance(), ho.Connection);
                            if (frdRow != null)
                                IDTipoNivelRelacionado = DBAbstractDataLayer.DataAccessRules.NivelRule.Current.GetNivelLastIDTipoNivelRelacionado(frdRow.ID, ho.Connection);
                        }
                        finally
                        {
                            ho.Dispose();
                        }

                        if (frdRow != null) // frd pode ainda não ter sido criado
                        {
                            var caRegRow = GisaDataSetHelper.GetInstance().ControloAutDataDeDescricao.Cast<GISADataset.ControloAutDataDeDescricaoRow>().Single(r => r.RowState == DataRowState.Added);
                            var nvlRegRow = RecordRegisterHelper
                                            .CreateFRDBaseDataDeDescricaoRow(frdRow,
                                                caRegRow.TrusteeUserRowByTrusteeUserControloAutDataDeDescricao,
                                                caRegRow.TrusteeUserRowByTrusteeUserControloAutDataDeDescricaoAuthority,
                                                caRegRow.DataAutoria,
                                                IDTipoNivelRelacionado);
                            nvlRegRow.DataEdicao = caRegRow.DataEdicao;

                            GisaDataSetHelper.GetInstance().FRDBaseDataDeDescricao.AddFRDBaseDataDeDescricaoRow(nvlRegRow);
                        }
                    }
                }

				selectedItem.Remove();

                ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
                List<long> lowerIDsList = new List<long>();
                try {
                    lowerIDsList = DiplomaModeloRule.Current.GetIDLowers(caRow.ID, ho.Connection);
                } 
                finally {
                    ho.Dispose();
                }

				// Como os dados acabaram de ser gravados pode ter-se chegado à conclusão que o contexto existente já não existia, daí este teste
				if (caRow.RowState != DataRowState.Detached)
				{
					try
					{
                        var oldTermo = caRow.GetControloAutDicionarioRows().Single(cad => cad.IDTipoControloAutForma == (long)TipoControloAutForma.FormaAutorizada).DicionarioRow.Termo;
                        var IDTipoNoticiaAut = caRow.IDTipoNoticiaAut;
						PersistencyHelper.DeleteIDXPreSaveArguments preSaveArgs = new PersistencyHelper.DeleteIDXPreSaveArguments();
						GISADataset.NivelControloAutRow[] ncaRows = null;
						GISADataset.NivelRow nRow = null;
						ncaRows = caRow.GetNivelControloAutRows();
						if (ncaRows.Length > 0)
						{
							nRow = ((GISADataset.NivelControloAutRow)(ncaRows[0])).NivelRow;
							preSaveArgs.ID = nRow.ID;
						}
						PersistencyHelper.DeleteCAXPreConcArguments preConcArgs = DeleteCAX(caRow);
                        PersistencyHelper.SaveResult successfulSave = PersistencyHelper.save(deleteCAXTermos, preConcArgs, Nivel.DeleteNivelXInDataBase, preSaveArgs);
						PersistencyHelper.cleanDeletedData();

                        if (successfulSave == PersistencyHelper.SaveResult.successful) {
                            if (SessionHelper.AppConfiguration.GetCurrentAppconfiguration().IsFedoraEnable())
                                SessionHelper.AppConfiguration.GetCurrentAppconfiguration().FedoraHelperSingleton.ActualizaObjDigitaisPorNivel(nivelIDsAssoc, oldTermo, null, IDTipoNoticiaAut);
                            Search.Updater.updateNivelDocumental(nivelIDsAssoc);
                            Search.Updater.updateNivelDocumentalComProdutores(lowerIDsList.Select(t => t.ToString()).ToList<string>());
                        }
					}
					catch (Exception ex)
					{
						Trace.WriteLine(ex);
						throw;
					}
				}
                else
                    GisaDataSetHelper.GetInstance().ControloAutDataDeDescricao.Cast<GISADataset.ControloAutDataDeDescricaoRow>().Single(r => r.RowState == DataRowState.Added && r.IDControloAut == caRow.ID).RejectChanges();
			}
		}