private void AcceptNivelRow(GISADataset.NivelRow NivelRow) { // aceitar o drop apenas se se tratar de uma UF ainda não associada var nufRow = NivelRow.GetNivelDesignadoRows()[0].GetNivelUnidadeFisicaRows()[0]; var ufs = GetUFInfo(NivelRow); var nufdRow = nufRow.GetNivelUnidadeFisicaDepositoRows().SingleOrDefault(); if (nufdRow == null) { nufdRow = GisaDataSetHelper.GetInstance().NivelUnidadeFisicaDeposito.NewNivelUnidadeFisicaDepositoRow(); nufdRow.NivelUnidadeFisicaRow = nufRow; nufdRow.DepositoRow = CurrentDeposito; nufdRow.Versao = new byte[]{}; nufdRow.isDeleted = 0; GisaDataSetHelper.GetInstance().NivelUnidadeFisicaDeposito.AddNivelUnidadeFisicaDepositoRow(nufdRow); PopulateAssociacoes(ufs); ufsAssociadas.Add(ufs.ToList().Single()); } else if (nufdRow.IDDeposito != CurrentDeposito.ID) { // ToDo: deixa-se substituir? } else if (nufdRow.IDDeposito == CurrentDeposito.ID && !ufsAssociadas.Contains(ufs.ToList().Single())) { PopulateAssociacoes(ufs); ufsAssociadas.Add(ufs.ToList().Single()); } }
private void AddDetalhe(GISADataset.NivelRow nRow, string nCod) { if (detalhes[nRow.ID] == null) { ArrayList aux = new ArrayList(); GISADataset.SFRDDatasProducaoRow sfrddprow = null; string ia = null; string im = null; string id = null; string fa = null; string fm = null; string fd = null; if (nRow.GetFRDBaseRows()[0].GetSFRDDatasProducaoRows().Length > 0) { sfrddprow = (GISADataset.SFRDDatasProducaoRow)(nRow.GetFRDBaseRows()[0].GetSFRDDatasProducaoRows()[0]); if (sfrddprow.IsInicioAnoNull()) ia = ""; else ia = sfrddprow.InicioAno; if (sfrddprow.IsInicioMesNull()) im = ""; else im = sfrddprow.InicioMes; if (sfrddprow.IsInicioDiaNull()) id = ""; else id = sfrddprow.InicioDia; if (sfrddprow.IsFimAnoNull()) fa = ""; else fa = sfrddprow.FimAno; if (sfrddprow.IsFimMesNull()) fm = ""; else fm = sfrddprow.FimMes; if (sfrddprow.IsFimDiaNull()) fd = ""; else fd = sfrddprow.FimDia; } else { ia = ""; im = ""; id = ""; fa = ""; fm = ""; fd = ""; } GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { if (nRow.IDTipoNivel == 3) aux.Add(nRow.GetNivelDesignadoRows()[0].Designacao); else { DBAbstractDataLayer.DataAccessRules.NivelRule.Current.FillNivelControloAutRows(GisaDataSetHelper.GetInstance(), nRow.ID, ho.Connection); if (nRow.GetNivelControloAutRows().Length > 0) aux.Add(nRow.GetNivelControloAutRows()[0].ControloAutRow.GetControloAutDicionarioRows()[0].DicionarioRow.Termo); else if (nRow.GetNivelDesignadoRows().Length > 0) aux.Add(nRow.GetNivelDesignadoRows()[0].Designacao); } aux.Add(nRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica()[0].TipoNivelRelacionadoRow.ID); aux.Add(ia); aux.Add(im); aux.Add(id); aux.Add(fa); aux.Add(fm); aux.Add(fd); aux.Add(nCod); aux.Add("1"); // Se aparece aqui é porque temos permissao... if (MovimentoRule.Current.estaRequisitado(nRow.ID, ho.Connection)) aux.Add(true); else aux.Add(false); } catch (Exception ex) { Trace.WriteLine(ex); throw; } finally { ho.Dispose(); } detalhes.Add(nRow.ID, aux); } }
private static DocumentoGisa GetNewDocumentoCompostoGisa(GISADataset.NivelRow nivelRow, List<long> IDNivelProdutores) { var di = new DocumentoGisa(); di.Tipo = TipoEntidadeInterna.DocumentoComposto; di.Estado = TipoEstado.SemAlteracoes; di.Id = nivelRow.ID; di.Codigo = nivelRow.Codigo; di.Titulo = nivelRow.GetNivelDesignadoRows()[0].Designacao; var cadRowProdutores = IDNivelProdutores.SelectMany(i => GisaDataSetHelper.GetInstance().NivelControloAut.Cast<GISADataset.NivelControloAutRow>().Where(r => r.ID == i)).SelectMany(nca => nca.ControloAutRow.GetControloAutDicionarioRows()); di.Produtores.AddRange(cadRowProdutores.Where(cad => cad.IDTipoControloAutForma == (long)TipoControloAutForma.FormaAutorizada).Select(cad => cad.DicionarioRow.Termo)); var frdRow = nivelRow.GetFRDBaseRows().Single(); var dpRow = frdRow.GetSFRDDatasProducaoRows().SingleOrDefault(); if (dpRow != null && !(dpRow.InicioAno.Length == 0 || dpRow.InicioMes.Length == 0 || dpRow.InicioDia.Length == 0 || dpRow.FimAno.Length == 0 || dpRow.FimMes.Length == 0 || dpRow.FimDia.Length == 0)) di.DataCriacao.AdicionaValorOriginal(new DataIncompleta(dpRow.InicioAno, dpRow.InicioMes, dpRow.InicioDia, dpRow.FimAno, dpRow.FimMes, dpRow.FimDia)); return di; }
private static DocumentoGisa GetNewDocumentoAnexoGisa(GISADataset.NivelRow nivelRow, List<long> docProds) { var di = new DocumentoGisa(); di.Tipo = TipoEntidadeInterna.DocumentoSimples; di.Estado = TipoEstado.SemAlteracoes; di.Id = nivelRow.ID; di.Codigo = nivelRow.Codigo; di.Titulo = nivelRow.GetNivelDesignadoRows()[0].Designacao; return di; }
private static DocumentoGisa GetNewDocumentoGisa(GISADataset.NivelRow nivelRow, List<long> IDNivelProdutores) { var di = new DocumentoGisa(); di.Tipo = TipoEntidadeInterna.DocumentoSimples; di.Estado = TipoEstado.SemAlteracoes; di.Id = nivelRow.ID; di.Codigo = nivelRow.Codigo; di.Titulo = nivelRow.GetNivelDesignadoRows()[0].Designacao; var frdRow = nivelRow.GetFRDBaseRows()[0]; var codigoRow = GisaDataSetHelper.GetInstance().Codigo.Cast<GISADataset.CodigoRow>().Where( row => ((GISADataset.CodigoRow)row).Codigo.StartsWith("ne:", StringComparison.InvariantCultureIgnoreCase)).SingleOrDefault(); if (codigoRow != null) di.NumeroEspecifico.AdicionaValorOriginal(codigoRow.Codigo); var dpRow = frdRow.GetSFRDDatasProducaoRows().SingleOrDefault(); if (dpRow != null && !(dpRow.InicioAno.Length == 0 || dpRow.InicioMes.Length == 0 || dpRow.InicioDia.Length == 0 || dpRow.FimAno.Length == 0 || dpRow.FimMes.Length == 0 || dpRow.FimDia.Length == 0)) di.DataCriacao.AdicionaValorOriginal(new DataIncompleta(dpRow.InicioAno, dpRow.InicioMes, dpRow.InicioDia, dpRow.FimAno, dpRow.FimMes, dpRow.FimDia)); // preencher com Tipologia e termos de indexação var cadRows = GisaDataSetHelper.GetInstance().FRDBase.Cast<GISADataset.FRDBaseRow>().Where(r => r.IDNivel == nivelRow.ID).SelectMany(frd => frd.GetIndexFRDCARows()).SelectMany(r => r.ControloAutRow.GetControloAutDicionarioRows()); var onomasticos = cadRows.Where(cad => cad.ControloAutRow.IDTipoNoticiaAut == (long)TipoNoticiaAut.Onomastico && cad.IDTipoControloAutForma == (long)TipoControloAutForma.FormaAutorizada); var ideograficos = cadRows.Where(cad => cad.ControloAutRow.IDTipoNoticiaAut == (long)TipoNoticiaAut.Ideografico && cad.IDTipoControloAutForma == (long)TipoControloAutForma.FormaAutorizada); var geograficos = cadRows.Where(cad => cad.ControloAutRow.IDTipoNoticiaAut == (long)TipoNoticiaAut.ToponimicoGeografico && cad.IDTipoControloAutForma == (long)TipoControloAutForma.FormaAutorizada); var tipologia = cadRows.Where(cad => cad.ControloAutRow.IDTipoNoticiaAut == (long)TipoNoticiaAut.TipologiaInformacional && cad.IDTipoControloAutForma == (long)TipoControloAutForma.FormaAutorizada).ToList().SingleOrDefault(); di.Onomasticos.AddRange(onomasticos.Select(cad => cad.DicionarioRow.Termo)); di.Ideograficos.AddRange(ideograficos.Select(cad => cad.DicionarioRow.Termo)); di.Toponimias.AddRange(geograficos.Select(cad => cad.DicionarioRow.Termo)); if (tipologia != null) di.Tipologia = tipologia.DicionarioRow.Termo; var cadRowProdutores = IDNivelProdutores.SelectMany(i => GisaDataSetHelper.GetInstance().NivelControloAut.Cast<GISADataset.NivelControloAutRow>().Where(r => r.ID == i)).SelectMany(nca => nca.ControloAutRow.GetControloAutDicionarioRows()); di.Produtores.AddRange(cadRowProdutores.Where(cad => cad.IDTipoControloAutForma == (long)TipoControloAutForma.FormaAutorizada).Select(cad => cad.DicionarioRow.Termo)); return di; }
private void EditNivel(FormAddNivel frm, GISADataset.NivelRow NivelRow) { GISADataset.TipoNivelRelacionadoRow tnrRow; if (NivelRow.IDTipoNivel == TipoNivel.LOGICO && GisaDataSetHelper.GetInstance().RelacaoHierarquica.Select("ID="+NivelRow.ID.ToString()).Length == 0) tnrRow = GisaDataSetHelper.GetInstance().TipoNivelRelacionado.Cast<GISADataset.TipoNivelRelacionadoRow>().Single(r => r.ID == TipoNivelRelacionado.ED); else tnrRow = GisaDataSetHelper.GetInstance().RelacaoHierarquica.Cast<GISADataset.RelacaoHierarquicaRow>().First(r => r.ID == NivelRow.ID && r.RowState != DataRowState.Deleted).TipoNivelRelacionadoRow; string WindowTitle = string.Format("Editar {0}", tnrRow.Designacao); // Don't allow to edit a Nivel without a Controlo // Autoridade using a form with Controlo Autoridade. // frm will only be of type FormNivelEstrutural if the // related administration option is set to "demand a ControloAutoridade" if (frm is FormNivelEstrutural && ! (NivelRow.CatCode.Trim().Equals("CA"))) { MessageBox.Show("O nível selecionado não foi definido com " + "base numa entidade produtora." + System.Environment.NewLine + "Assim, para que este nível seja editável é necessário " + "que a aplicação esteja " + System.Environment.NewLine + "configurada para lidar com níveis não controlados.", WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else if (! (frm is FormNivelEstrutural) && ! (NivelRow.CatCode.Trim().Equals("NVL"))) { MessageBox.Show("O nível selecionado foi definido com " + "base numa entidade produtora." + System.Environment.NewLine + "Assim, para que este nível seja editável é necessário " + "que a aplicação esteja " + System.Environment.NewLine + "configurada para lidar com níveis controlados.", WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } frm.Text = WindowTitle; frm.txtCodigo.Text = NivelRow.Codigo; frm.txtDesignacao.Text = Nivel.GetDesignacao(NivelRow); // se se tratar de uma série ou subsérie o código será sempre automático if (tnrRow.ID == TipoNivelRelacionado.SR || tnrRow.ID == TipoNivelRelacionado.SSR) frm.txtCodigo.Enabled = false; frm.LoadData(); if (NivelRow.TipoNivelRow.ID != TipoNivel.LOGICO) { // populate controls with data so that it can be edited if (frm is FormNivelEstrutural) { FormNivelEstrutural tempWith1 = (FormNivelEstrutural)frm; if (NivelRow.CatCode.Trim().Equals("CA")) { tempWith1.caList.txtFiltroDesignacao.Text = tempWith1.txtDesignacao.Text; tempWith1.caList.ReloadList(); tempWith1.chkControloAut = true; } else if (NivelRow.CatCode.Trim().Equals("NVL")) tempWith1.chkControloAut = false; } } // show form and receive user feedback switch (frm.ShowDialog()) { case DialogResult.OK: Trace.WriteLine("A editar nível..."); GISADataset.NivelDesignadoRow ndRow = null; // Um Nivel documental deve ter obrigatoriamente um NivelDesignado. Debug.Assert(NivelRow.GetNivelDesignadoRows().Length > 0); ndRow = NivelRow.GetNivelDesignadoRows()[0]; NivelRow.Codigo = frm.txtCodigo.Text; ndRow.Designacao = frm.txtDesignacao.Text; // registar a edição do item selecionado if (NivelRow.IDTipoNivel != TipoNivel.LOGICO) CurrentContext.RaiseRegisterModificationEvent(NivelRow.GetFRDBaseRows()[0]); PersistencyHelper.EnsureUniqueCodigoNivelPreConcArguments pcArgs = new PersistencyHelper.EnsureUniqueCodigoNivelPreConcArguments(); pcArgs.nRowID = NivelRow.ID; pcArgs.ndRowID = ndRow.ID; // Se se tratar de uma entidade detentora não passar os Ids de uma relação // hierárquica para um nível superior pois não existe nenhum. if (NivelRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica().Length > 0) { pcArgs.rhRowID = NivelRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica()[0].ID; pcArgs.rhRowIDUpper = NivelRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica()[0].IDUpper; } pcArgs.testOnlyWithinNivel = true; PersistencyHelper.SaveResult successfulSave = PersistencyHelper.save(DelegatesHelper.ensureUniqueCodigo, pcArgs); if (! pcArgs.successful) MessageBox.Show(pcArgs.message, "Criação de unidade de descrição", MessageBoxButtons.OK, MessageBoxIcon.Warning); else if (successfulSave == PersistencyHelper.SaveResult.successful) { GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { List<string> IDNiveis = new List<string>(); IDNiveis.Add(NivelRow.ID.ToString()); GISA.Search.Updater.updateNivelDocumental(IDNiveis); } catch (Exception ex) { Trace.WriteLine(ex.ToString()); throw; } finally { ho.Dispose(); } } PersistencyHelper.cleanDeletedData(PersistencyHelper.determinaNuvem("RelacaoHierarquica")); // Actualizar a interface com os novos valores. Se editarmos a // raiz (estrutural) da vista documental é necessário actualizar // automaticamente também a vista estrutural. if (! (NivelRow.RowState == DataRowState.Detached)) { if (this.nivelNavigator1.PanelToggleState == NivelNavigator.ToggleState.Estrutural) this.nivelNavigator1.UpdateSelectedNodeName(Nivel.GetDesignacao(NivelRow)); else this.nivelNavigator1.UpdateSelectedListItemName(Nivel.GetDesignacao(NivelRow)); } // Forçar a gravação do documento CurrentContext.SetNivelEstrututalDocumental(null); CurrentContext.SetNivelEstrututalDocumental(NivelRow); break; } }
private static string GetDesignacaoInDataSet(GISADataset.NivelRow Nivel) { bool nivelOrganico = isNivelOrganico(Nivel); GisaDataSetHelper.HoldOpen ho = null; if (! nivelOrganico) { if (Nivel.GetNivelDesignadoRows().Length == 0) { ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { NivelRule.Current.FillNivelDesignado(GisaDataSetHelper.GetInstance(), Nivel.ID, ho.Connection); } catch (Exception ex) { Trace.WriteLine(ex); throw; } finally { ho.Dispose(); } } Debug.Assert(Nivel.GetNivelDesignadoRows().Length > 0); return Nivel.GetNivelDesignadoRows()[0].Designacao; } if (nivelOrganico) { if (Nivel.GetNivelControloAutRows().Length == 0 || Nivel.GetNivelControloAutRows()[0].ControloAutRow.GetControloAutDicionarioRows().Length == 0) { ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { NivelRule.Current.FillNivelControloAutRows(GisaDataSetHelper.GetInstance(), Nivel.ID, ho.Connection); } catch (Exception ex) { Trace.WriteLine(ex); throw; } finally { ho.Dispose(); } } Debug.Assert(Nivel.GetNivelControloAutRows().Length > 0); Debug.Assert(Nivel.GetNivelControloAutRows()[0].ControloAutRow.GetControloAutDicionarioRows().Length > 0); foreach (GISADataset.ControloAutDicionarioRow cad in Nivel.GetNivelControloAutRows()[0].ControloAutRow.GetControloAutDicionarioRows()) { if (cad.IDTipoControloAutForma == (long)TipoControloAutForma.FormaAutorizada) { return cad.DicionarioRow.Termo; } } } #if (DEBUG) Debug.WriteLine("Nivel ID=", Nivel.ID.ToString()); Debug.WriteLine("Nivel IDTipoNivel=", Nivel.IDTipoNivel.ToString()); throw new ArgumentException("details not found in Nivel.Table.DataSet", "Nivel"); #else { Console.WriteLine("details not found in Nivel.Table.DataSet / Tipo=" + Nivel.IDTipoNivel.ToString()); return ""; } #endif }