示例#1
0
		//metodo responsavel por eliminar toda a nuvem do CA actual em memoria
		public static PersistencyHelper.DeleteCAXPreConcArguments DeleteCAX(GISADataset.ControloAutRow caRow)
		{
			GISADataset.ControloAutDicionarioRow[] cadRows = caRow.GetControloAutDicionarioRows();
			GISADataset.DicionarioRow dRow = null;
			PersistencyHelper.DeleteCAXPreConcArguments args = new PersistencyHelper.DeleteCAXPreConcArguments();

			// eliminar registos de "Dicionario" e de "ControloAutDicionario"
            cadRows.ToList().ForEach(cadRow =>
            {
                dRow = cadRow.DicionarioRow;
                args.termos.Add(dRow);
                cadRow.Delete();
            });
			args.caRowID = caRow.ID;
			args.catCode = getCatCode(caRow.TipoNoticiaAutRow);

			// eliminar registos de IndexFRDCA
            caRow.GetIndexFRDCARows().ToList().ForEach(idx => idx.Delete());

			// Somente para notícias de autoridade relacionaveis
            caRow.GetControloAutRelRowsByControloAutControloAutRel().ToList().ForEach(carRow => carRow.Delete());
            caRow.GetControloAutRelRowsByControloAutControloAutRelAlias().ToList().ForEach(carRow => carRow.Delete());
            caRow.GetControloAutEntidadeProdutoraRows().ToList().ForEach(caepRow => caepRow.Delete());
            caRow.GetControloAutDatasExistenciaRows().ToList().ForEach(cadeRow => cadeRow.Delete());

			caRow.Delete();
			return args;
		}
示例#2
0
 // Devolve a forma autorizada do CA passado
 public static GISADataset.ControloAutDicionarioRow getFormaAutorizada(GISADataset.ControloAutRow caRow)
 {
     foreach (GISADataset.ControloAutDicionarioRow cadRow in caRow.GetControloAutDicionarioRows())
     {
         if (cadRow.IDTipoControloAutForma == (long)TipoControloAutForma.FormaAutorizada)
         {
             return(cadRow);
         }
     }
     return(null);
 }
示例#3
0
        // Adicionar um tecnico de obra (registo de autoridade onomastico):
        private void btnAddTecnicoObra_Click(object sender, EventArgs e)
        {
            FormPickControloAut frmPick = new FormPickControloAut();

            frmPick.Text = "Notícia de autoridade - Pesquisar registo de autoridade onomástico";
            frmPick.caList.AllowedNoticiaAut(TipoNoticiaAut.Onomastico);
            frmPick.caList.ReloadList();

            GISADataset.ControloAutRow            caRow      = null;
            GISADataset.LicencaObraTecnicoObraRow tecnicoRow = null;
            GISADataset.ControloAutDicionarioRow  cadRow     = null;

            if (frmPick.caList.Items.Count > 0)
            {
                frmPick.caList.SelectItem(frmPick.caList.Items[0]);
            }

            switch (frmPick.ShowDialog())
            {
            case DialogResult.OK:
                foreach (ListViewItem li in frmPick.caList.SelectedItems)
                {
                    cadRow = (GISADataset.ControloAutDicionarioRow)li.Tag;
                    caRow  = cadRow.ControloAutRow;
                    if (!existe_LicencaObraTecnicoObra(caRow))
                    {
                        if (cadRow.IDTipoControloAutForma != (long)TipoControloAutForma.FormaAutorizada)
                        {
                            GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
                            try
                            {
                                ControloAutRule.Current.LoadDicionarioAndControloAutDicionario(GisaDataSetHelper.GetInstance(), cadRow.IDControloAut, ho.Connection);
                            }
                            catch (Exception ex)
                            {
                                Trace.WriteLine(ex);
                                throw;
                            }
                            finally
                            {
                                ho.Dispose();
                            }
                            cadRow = caRow.GetControloAutDicionarioRows().Where(cad => cad.IDTipoControloAutForma == (long)TipoControloAutForma.FormaAutorizada).Single();
                        }

                        tecnicoRow = GisaDataSetHelper.GetInstance().LicencaObraTecnicoObra.NewLicencaObraTecnicoObraRow();
                        tecnicoRow.LicencaObraRow = CurrentLicencaObra;
                        tecnicoRow.ControloAutRow = caRow;
                        tecnicoRow.isDeleted      = 0;
                        // Dados:
                        Add_RowTecnicoObra(tecnicoRow);
                        // GUI: adicionar `a lista:
                        Add_ViewTecnicoObra(cadRow, tecnicoRow);
                    }
                }
                break;

            default:
                break;
            }
        }
示例#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
//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();
			}
		}