// returns the updated NivelUnidadeFisicaCodigoRow considering a new Codigo public static GISADataset.NivelUnidadeFisicaCodigoRow GetNewCodigoRow(GISADataset.NivelRow nivelRow, int ano) { GISADataset.NivelRow ParentEDRow = nivelRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica()[0].NivelRowByNivelRelacaoHierarquicaUpper; DataRow[] DataRows = GisaDataSetHelper.GetInstance().NivelUnidadeFisicaCodigo.Select("ID=" + ParentEDRow.ID.ToString() + " AND Ano=" + System.DateTime.Now.Year.ToString()); GISADataset.NivelUnidadeFisicaCodigoRow codigoRow = null; if (DataRows.Length == 0) { codigoRow = GisaDataSetHelper.GetInstance().NivelUnidadeFisicaCodigo.AddNivelUnidadeFisicaCodigoRow(ParentEDRow, System.DateTime.Now.Year, 1M, new byte[] { }, 0); } else { codigoRow = (GISADataset.NivelUnidadeFisicaCodigoRow)(DataRows[0]); codigoRow.Contador = codigoRow.Contador + 1; } return codigoRow; }
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 long GetEntidadeDetentoraID(GISADataset.NivelRow nRow) { Debug.Assert(nRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica().Length > 0); GISADataset.NivelRow nED = nRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica()[0].NivelRowByNivelRelacaoHierarquicaUpper; while (nED.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica().Length > 0) nED = nED.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica()[0].NivelRowByNivelRelacaoHierarquicaUpper; return nED.ID; }
private void GetEntidadesProdutoras(GISADataset.NivelRow NivelRow) { EPs = new ArrayList(); foreach (GISADataset.RelacaoHierarquicaRow rh in NivelRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica()) { if (rh.NivelRowByNivelRelacaoHierarquicaUpper.GetNivelControloAutRows().Length > 0) { foreach (GISADataset.NivelControloAutRow n in rh.NivelRowByNivelRelacaoHierarquicaUpper.GetNivelControloAutRows()) { if (n.ControloAutRow.TipoNoticiaAutRow.ID == Convert.ToInt64(TipoNoticiaAut.EntidadeProdutora)) EPs.Add(n.NivelRow); } } else GetEntidadesProdutoras(rh.NivelRowByNivelRelacaoHierarquicaUpper); } }
public virtual bool isShowable(GISADataset.NivelRow nivel, GISADataset.NivelRow nivelUpper) { return (nivelUpper != null && nivelUpper.TipoNivelRow.IsStructure) || nivel.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica()[0].TipoNivelRelacionadoRow.ID < TipoNivelRelacionado.D; }
private bool ClipboardNivelRowIsAncestorOf(GISADataset.NivelRow targetRow) { // subir na árvore partindo do nó sobre o qual se pretende "colar" e // à procura do nó "recortado". Se o encontrarmos significa que não // podemos permitir um "colar". Ao permiti-lo faziamos com que um // descendente fosse pai de um seu ascendente (!) foreach(var ClipboardNivelItem in mClipboardNivelItems) { ArrayList openTargetRows = new ArrayList(); openTargetRows.Add(targetRow); while (openTargetRows.Count > 0) { targetRow = (GISADataset.NivelRow)(openTargetRows[0]); if (targetRow == ((GISADataset.RelacaoHierarquicaRow)ClipboardNivelItem).NivelRowByNivelRelacaoHierarquica) return true; foreach (GISADataset.RelacaoHierarquicaRow nhRow in targetRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica()) openTargetRows.Add(nhRow.NivelRowByNivelRelacaoHierarquicaUpper); openTargetRows.Remove(targetRow); } } return false; }
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; } }
// 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; // se se tratar de uma série ou subsérie if (tnrRow.ID == TipoNivelRelacionado.SR || tnrRow.ID == TipoNivelRelacionado.SSR) { FormNivelDocumental frmDoc = (FormNivelDocumental)frm; frmDoc.grpCodigo.Text += " previsto"; frmDoc.txtCodigo.Enabled = false; GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { NivelRule.Current.FillTipoNivelRelacionadoCodigo(GisaDataSetHelper.GetInstance(), ho.Connection); } catch (Exception ex) { Trace.WriteLine(ex); throw; } finally { ho.Dispose(); } frmDoc.txtCodigo.Text = NiveisHelper.getNextSeriesCodigo(false); } bool successfulSave = true; switch (frm.ShowDialog()) { case DialogResult.OK: { Trace.WriteLine("A criar nível..."); long click = DateTime.Now.Ticks; GISADataset.NivelRow nRow = null; GISADataset.NivelDesignadoRow ndRow = null; GISADataset.NivelControloAutRow ncaRow = null; GISADataset.FRDBaseRow frdRow = null; string designacaoUFAssociada = string.Empty; bool addNewUF = false; PostSaveAction postSaveAction = null; // Create a new Nivel with or without a Notícia autoridade if (frm is FormNivelEstrutural && ((FormNivelEstrutural)frm).chkControloAut) { GISADataset.ControloAutRow caRow = null; caRow = ((GISADataset.ControloAutDicionarioRow)(((FormNivelEstrutural)frm). caList.SelectedItems[0].Tag)).ControloAutRow; GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { DBAbstractDataLayer.DataAccessRules.NivelRule.Current.LoadNivelByControloAut(caRow.ID, GisaDataSetHelper.GetInstance(), ho.Connection); } finally { ho.Dispose(); } ncaRow = caRow.GetNivelControloAutRows()[0]; nRow = ncaRow.NivelRow; // Impedir criação de relações repetidas entre niveis // estruturais e níveis "logicos" if (GisaDataSetHelper.GetInstance().RelacaoHierarquica.Select(string.Format("ID={0} AND IDUpper={1} OR ID={1} AND IDUpper={0}", parentNivelRow.ID, nRow.ID)).Length > 0) { MessageBox.Show("A relação pretendida já existe e não pode ser duplicada.", "Adição de relação", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } } else { nRow = GisaDataSetHelper.GetInstance().Nivel. AddNivelRow(tnrRow.TipoNivelRow, ((FormAddNivel)frm).txtCodigo.Text.Trim(), "NVL", new byte[]{}, 0); ndRow = GisaDataSetHelper.GetInstance().NivelDesignado. AddNivelDesignadoRow(nRow, ((FormAddNivel)frm).txtDesignacao.Text.Trim(), new byte[]{}, 0); if (nRow.IDTipoNivel != TipoNivel.LOGICO) frdRow = GisaDataSetHelper.GetInstance().FRDBase.AddFRDBaseRow(nRow, (GISADataset.TipoFRDBaseRow)(GisaDataSetHelper.GetInstance().TipoFRDBase. Select("ID=" + DomainValuesHelper.stringifyEnumValue(TipoFRDBase.FRDOIRecolha))[0]), "", "", new byte[]{}, 0); if (nRow.IDTipoNivel == TipoNivel.DOCUMENTAL && ((FormNivelDocumental)frm).CreateUFAssociada) { designacaoUFAssociada = ((FormNivelDocumental)frm).DesignacaoUF; addNewUF = true; } } // valores por omissão var globalConfig = GisaDataSetHelper.GetInstance().GlobalConfig.Cast<GISADataset.GlobalConfigRow>().Single(); if (globalConfig.ApplyDefaultValues && nRow.IDTipoNivel == TipoNivel.DOCUMENTAL) { 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); } GISADataset.RelacaoHierarquicaRow rhRow = null; // garantir que os nós raiz não são criados com pais if (tnrRow.ID != TipoNivelRelacionado.ED) rhRow = GisaDataSetHelper.GetInstance().RelacaoHierarquica. AddRelacaoHierarquicaRow(nRow, parentNivelRow, tnrRow, null, null, null, null, null, null, null, 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.LOGICO || (nRow.IDTipoNivel == TipoNivel.DOCUMENTAL && parentNivelRow.IDTipoNivel == TipoNivel.ESTRUTURAL)) { var nUpperRow = rhRow == null ? default(GISADataset.NivelRow) : rhRow.NivelRowByNivelRelacaoHierarquicaUpper; PermissoesHelper.AddNewNivelGrantPermissions(nRow, nUpperRow); } // actualizar permissões implícitas postSaveAction = new PostSaveAction(); PersistencyHelper.UpdatePermissionsPostSaveArguments args = new PersistencyHelper.UpdatePermissionsPostSaveArguments(); postSaveAction.args = args; postSaveAction.postSaveDelegate = delegate(PersistencyHelper.PostSaveArguments postSaveArgs) { if (!postSaveArgs.cancelAction && nRow != null && nRow.RowState != DataRowState.Detached && nRow.RowState != DataRowState.Deleted) { if (addNewUF) { // registar a criação da unidade física GISADataset.FRDBaseRow frdUFRow = nRow.GetFRDBaseRows()[0].GetSFRDUnidadeFisicaRows()[0].NivelRow.GetFRDBaseRows()[0]; CurrentContext.RaiseRegisterModificationEvent(frdUFRow); } // 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 uma série ou subsérie if (tnrRow.ID == TipoNivelRelacionado.SR || tnrRow.ID == TipoNivelRelacionado.SSR) { // é necessário garantir que o código gerado ainda não está // em uso, por isso geramo-lo dentro da própria transacção PersistencyHelper.ValidateNivelAddAndAssocNewUFPreConcArguments pcArgs = new PersistencyHelper.ValidateNivelAddAndAssocNewUFPreConcArguments(); PersistencyHelper.SetNewCodigosPreSaveArguments psArgs = new PersistencyHelper.SetNewCodigosPreSaveArguments(); PersistencyHelper.VerifyIfRHNivelUpperExistsPreConcArguments pcArgsNivel = new PersistencyHelper.VerifyIfRHNivelUpperExistsPreConcArguments(); PersistencyHelper.FetchLastCodigoSeriePreSaveArguments psArgsNivel = new PersistencyHelper.FetchLastCodigoSeriePreSaveArguments(); PersistencyHelper.AddEditUFPreConcArguments pcArgsUF = new PersistencyHelper.AddEditUFPreConcArguments(); PersistencyHelper.IsCodigoUFBeingUsedPreSaveArguments psArgsUF = new PersistencyHelper.IsCodigoUFBeingUsedPreSaveArguments(); pcArgs.argsNivel = pcArgsNivel; pcArgs.argsUF = pcArgsUF; psArgs.argsNivel = psArgsNivel; psArgs.argsUF = psArgsUF; // 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; // dados para a atribuição de um código ao nível documental psArgsNivel.nRowID = nRow.ID; psArgsNivel.pcArgs = pcArgsNivel; if (addNewUF) { // dados que serão usados no delegate responsável pela criação da unidade física pcArgsUF.Operation = PersistencyHelper.AddEditUFPreConcArguments.Operations.Create; pcArgsUF.psa = psArgsUF; // dados que serão usados no delegate que fará a associação entre o nível documental e unidade física pcArgs.addNewUF = true; pcArgs.IDFRDBaseNivelDoc = frdRow.ID; pcArgs.produtor = this.nivelNavigator1.SelectedNode; pcArgs.designacaoUFAssociada = designacaoUFAssociada; } // permitir ao delegate selecionar o delegate correspondente ao tipo de nível que se está a criar pcArgs.IDTipoNivelRelacionado = tnrRow.ID; psArgs.createNewNivelCodigo = true; psArgs.createNewUFCodigo = addNewUF; PersistencyHelper.save(DelegatesHelper.ValidateNivelAddAndAssocNewUF, pcArgs, DelegatesHelper.SetNewCodigos, psArgs, postSaveAction); if (! pcArgsNivel.RHNivelUpperExists) { successfulSave = false; MessageBox.Show(pcArgsNivel.message, "Criação de unidade de descrição", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (addNewUF && pcArgsUF.OperationError == PersistencyHelper.AddEditUFPreConcArguments.OperationErrors.NewUF) MessageBox.Show(pcArgsUF.message, "Criar unidade física", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (tnrRow.ID == TipoNivelRelacionado.D || tnrRow.ID == TipoNivelRelacionado.SD) { // 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(); PersistencyHelper.AddEditUFPreConcArguments pcArgsUF = new PersistencyHelper.AddEditUFPreConcArguments(); PersistencyHelper.IsCodigoUFBeingUsedPreSaveArguments psArgsUF = new PersistencyHelper.IsCodigoUFBeingUsedPreSaveArguments(); pcArgs.argsNivel = pcArgsNivel; pcArgs.argsUF = pcArgsUF; // 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; if (addNewUF) { // dados que serão usados no delegate responsável pela criação da unidade física pcArgsUF.Operation = PersistencyHelper.AddEditUFPreConcArguments.Operations.Create; pcArgsUF.psa = psArgsUF; // dados que serão usados no delegate que fará a associação entre o nível documental e unidade física pcArgs.addNewUF = true; pcArgs.IDFRDBaseNivelDoc = frdRow.ID; pcArgs.produtor = this.nivelNavigator1.SelectedNode; pcArgs.designacaoUFAssociada = designacaoUFAssociada; } // 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 = addNewUF; psArgs.setNewCodigo = rhRow.IDTipoNivelRelacionado == TipoNivelRelacionado.SD; psArgs.argsUF = psArgsUF; 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(); } } } else if (nRow.IDTipoNivel == TipoNivel.ESTRUTURAL && ! (nRow.CatCode.Trim().Equals("CA"))) { // se se tratar de um nivel estrutural temático-funcional // é necessário garantir que se trata de um código único no sistema PersistencyHelper.EnsureUniqueCodigoNivelPreConcArguments pcArgs = new PersistencyHelper.EnsureUniqueCodigoNivelPreConcArguments(); pcArgs.nRowID = nRow.ID; pcArgs.ndRowID = ndRow.ID; pcArgs.rhRowID = rhRow.ID; pcArgs.rhRowIDUpper = rhRow.IDUpper; PersistencyHelper.save(DelegatesHelper.ensureUniqueCodigo, pcArgs, postSaveAction); if (! pcArgs.successful) { successfulSave = false; MessageBox.Show(pcArgs.message, "Criação de unidade de descrição", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else if (nRow.IDTipoNivel == TipoNivel.LOGICO && nRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica().Length == 0) { // se se tratar de uma entidade detentora // é necessário garantir que se trata de um código único no sistema PersistencyHelper.EnsureUniqueCodigoNivelPreConcArguments pcArgs = new PersistencyHelper.EnsureUniqueCodigoNivelPreConcArguments(); pcArgs.nRowID = nRow.ID; pcArgs.ndRowID = ndRow.ID; pcArgs.testOnlyWithinNivel = true; PersistencyHelper.save(DelegatesHelper.ensureUniqueCodigo, pcArgs, postSaveAction); if (!pcArgs.successful) { successfulSave = false; MessageBox.Show(pcArgs.message, "Criação de unidade de descrição", MessageBoxButtons.OK, MessageBoxIcon.Warning); // forçar o refresh das entidades produtoras (qualquer outro que esteja expandido // vai ser colapsado) resetEstrutura(); } } else if (nRow.IDTipoNivel == TipoNivel.ESTRUTURAL && nRow.CatCode.Trim().Equals("CA")) { GISADataset.TipoFRDBaseRow tipoFRD = (GISADataset.TipoFRDBaseRow)(GisaDataSetHelper.GetInstance().TipoFRDBase.Select("ID=" + DomainValuesHelper.stringifyEnumValue(TipoFRDBase.FRDOIRecolha))[0]); if (GisaDataSetHelper.GetInstance().FRDBase.Select(string.Format("IDNivel={0} AND IDTipoFRDBase={1}", nRow.ID.ToString(), tipoFRD.ID.ToString())).Length == 0) { GISADataset.FRDBaseRow frdNivelDocRow = GisaDataSetHelper.GetInstance().FRDBase.AddFRDBaseRow(nRow, tipoFRD, "", "", new byte[] { }, 0); GisaDataSetHelper.GetInstance().SFRDDatasProducao.AddSFRDDatasProducaoRow(frdNivelDocRow, "", "", "", "", false, "", "", "", "", false, new byte[] { }, 0); GisaDataSetHelper.GetInstance().SFRDConteudoEEstrutura.AddSFRDConteudoEEstruturaRow(frdNivelDocRow, "", "", new byte[] { }, 0); GisaDataSetHelper.GetInstance().SFRDContexto.AddSFRDContextoRow(frdNivelDocRow, "", "", "", false, new byte[] { }, 0); GisaDataSetHelper.GetInstance().SFRDDocumentacaoAssociada.AddSFRDDocumentacaoAssociadaRow(frdNivelDocRow, "", "", "", "", new byte[] { }, 0); GisaDataSetHelper.GetInstance().SFRDDimensaoSuporte.AddSFRDDimensaoSuporteRow(frdNivelDocRow, "", new byte[] { }, 0); GisaDataSetHelper.GetInstance().SFRDNotaGeral.AddSFRDNotaGeralRow(frdNivelDocRow, "", new byte[] { }, 0); var CurrentSFRDAvaliacao = GisaDataSetHelper.GetInstance().SFRDAvaliacao.NewSFRDAvaliacaoRow(); CurrentSFRDAvaliacao.FRDBaseRow = frdNivelDocRow; CurrentSFRDAvaliacao.IDPertinencia = 1; CurrentSFRDAvaliacao.IDDensidade = 1; CurrentSFRDAvaliacao.IDSubdensidade = 1; CurrentSFRDAvaliacao.Publicar = false; CurrentSFRDAvaliacao.Observacoes = ""; CurrentSFRDAvaliacao.AvaliacaoTabela = false; GisaDataSetHelper.GetInstance().SFRDAvaliacao.AddSFRDAvaliacaoRow(CurrentSFRDAvaliacao); var sfrdcda = GisaDataSetHelper.GetInstance().SFRDCondicaoDeAcesso.AddSFRDCondicaoDeAcessoRow(frdNivelDocRow, "", "", "", "", new byte[] { }, 0); var caRow = nRow.GetNivelControloAutRows().Single().ControloAutRow; if (!caRow.IsIDIso639p2Null()) GisaDataSetHelper.GetInstance().SFRDLingua.AddSFRDLinguaRow(sfrdcda, caRow.Iso639Row, new byte[] { }, 0); else if (globalConfig.ApplyDefaultValues) { foreach (GISADataset.ConfigLinguaRow r in globalConfig.GetConfigLinguaRows()) GisaDataSetHelper.GetInstance().SFRDLingua.AddSFRDLinguaRow(sfrdcda, r.Iso639Row, new byte[] { }, 0); } if (!caRow.IsIDIso15924Null()) GisaDataSetHelper.GetInstance().SFRDAlfabeto.AddSFRDAlfabetoRow(sfrdcda, caRow.Iso15924Row, new byte[] { }, 0); else if (globalConfig.ApplyDefaultValues) { foreach (GISADataset.ConfigAlfabetoRow r in globalConfig.GetConfigAlfabetoRows()) GisaDataSetHelper.GetInstance().SFRDAlfabeto.AddSFRDAlfabetoRow(sfrdcda, r.Iso15924Row, new byte[] { }, 0); } } var sucessfulSave = PersistencyHelper.save(postSaveAction); if(sucessfulSave == PersistencyHelper.SaveResult.successful) GISA.Search.Updater.updateProdutor(nRow.GetNivelControloAutRows()[0].IDControloAut); } else PersistencyHelper.save(postSaveAction); PersistencyHelper.cleanDeletedData(new List<TableDepthOrdered.TableCloudType>(new TableDepthOrdered.TableCloudType[] { PersistencyHelper.determinaNuvem("RelacaoHierarquica"), PersistencyHelper.determinaNuvem("FRDBase") })); if (! successfulSave) return successfulSave; // Para as EDs if (rhRow == null) { //update data resetEstrutura(); } else { if (addNewUF) { // registar a criação da unidade física GISADataset.FRDBaseRow frdUFRow = nRow.GetFRDBaseRows()[0].GetSFRDUnidadeFisicaRows()[0].NivelRow.GetFRDBaseRows()[0]; GISA.Search.Updater.updateUnidadeFisica(frdUFRow.IDNivel); } if (nRow.IDTipoNivel == TipoNivel.DOCUMENTAL) { GISA.Search.Updater.updateNivelDocumentalComProdutores(nRow.ID); GISA.Search.Updater.updateNivelDocumental(nRow.ID); } if (this.nivelNavigator1.PanelToggleState == NivelNavigator.ToggleState.Estrutural) this.nivelNavigator1.RefreshTreeViewControlSelectedBranch(); else 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; }
public static GISADataset.RelacaoHierarquicaRow[] GetParentRelations(GISADataset.NivelRow CurrentNivel, GISADataset.NivelRow UpperNivel, IDbConnection connection) { try { NivelRule.Current.LoadNivelParents(UpperNivel.ID, GisaDataSetHelper.GetInstance(), connection); } catch (Exception ex) { Trace.WriteLine(ex); throw; } return UpperNivel.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica(); }
//TODO: FUNCAO MANTIDA PARA COMPATIBILIDADE DE CODIGO EXISTENTE, DEVERÁ DESAPARECER, SER UNIFICADA COM A ASSINATURA SEGUINTE, OU SER REFORMULADA ASSIM QUE POSSIVEL public static GISADataset.RelacaoHierarquicaRow[] GetParents(GISADataset CurrentDataSet, GISADataset.NivelRow CurrentNivel) { IDbConnection conn = GisaDataSetHelper.GetConnection(); try { conn.Open(); NivelRule.Current.LoadNivelGrandparents(CurrentNivel.ID, GisaDataSetHelper.GetInstance(), conn); } finally { conn.Close(); } GISADataset.RelacaoHierarquicaRow[] Parents = null; ArrayList Result = new ArrayList(); Parents = CurrentNivel.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica(); foreach (GISADataset.RelacaoHierarquicaRow rhRow in Parents) { Result.AddRange(rhRow.NivelRowByNivelRelacaoHierarquicaUpper.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica()); } return (GISADataset.RelacaoHierarquicaRow[])(Result.ToArray(typeof(GISADataset.RelacaoHierarquicaRow))); }
public static GISADataset.RelacaoHierarquicaRow[] GetSelf(GISADataset CurrentDataSet, GISADataset.NivelRow CurrentNivel) { //TODO: chamar método que faz os fill: fillSelf(CurrentDataSet, CurrentNivel.ID, conn, tran) return CurrentNivel.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica(); }
public static bool IsDocumentTopLevel(GISADataset.NivelRow dr) { if (! dr.TipoNivelRow.IsDocument) { return false; } foreach (GISADataset.RelacaoHierarquicaRow nh in dr.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica()) { if (nh.NivelRowByNivelRelacaoHierarquicaUpper.TipoNivelRow.IsDocument) { return false; } } return true; }