public bool SetMovimento(GISADataset.MovimentoRow movRow, bool reqDeleted) { GISADataset.MovimentoRow oldMovRow = mState.mMovimento; bool oldIsMovDeleted = mState.mIsMovimentoDeleted; mState.mMovimento = movRow; mState.mIsMovimentoDeleted = reqDeleted; // Se mudarmos entre dois contextos vazios ou se mudarmos entre dois contextos apagados não queremos despoletar o evento if (!((movRow == null && oldMovRow == null) || ((movRow != null && movRow.RowState == DataRowState.Detached) && (oldMovRow != null && oldMovRow.RowState == DataRowState.Detached) || (((movRow != null && !(movRow.RowState == DataRowState.Detached)) && (oldMovRow != null && !(oldMovRow.RowState == DataRowState.Detached))) && movRow == oldMovRow)))) { MultiPanelControl.SaveArgs successfulSave = new MultiPanelControl.SaveArgs(PersistencyHelper.SaveResult.successful); try { if (MovimentoChanged != null) MovimentoChanged(successfulSave); if (successfulSave.save == PersistencyHelper.SaveResult.unsuccessful) { mState.mMovimento = oldMovRow; mState.mIsMovimentoDeleted= oldIsMovDeleted; } ReportAction("Context.Movimento"); } catch (InvalidOperationException) { Trace.WriteLine("Error. Restoring previous movimento."); mState.mMovimento = oldMovRow; mState.mIsMovimentoDeleted = oldIsMovDeleted; throw; } // se unsuccessful retorna false, senão retorna true return successfulSave.save != PersistencyHelper.SaveResult.unsuccessful; } else { return true; } }
public bool SetGrupoArquivo(GISADataset.NivelRow gaRow, bool gaDeleted) { if (mState.mGrupoArquivo == gaRow && !gaDeleted ^ this.mState.mIsGrupoArquivoDeleted) { if (GrupoArquivoChanged != null) GrupoArquivoChanged(null); return false; } GISADataset.NivelRow oldGrupoArquivoRow = mState.mGrupoArquivo; bool oldIsGrupoArquivoDeleted = mState.mIsGrupoArquivoDeleted; mState.mGrupoArquivo = gaRow; mState.mIsGrupoArquivoDeleted = gaDeleted; if (!((gaRow == null && oldGrupoArquivoRow == null) || ((gaRow != null && gaRow.RowState == DataRowState.Detached) && (oldGrupoArquivoRow != null && oldGrupoArquivoRow.RowState == DataRowState.Detached) || (((gaRow != null && !(gaRow.RowState == DataRowState.Detached)) && (oldGrupoArquivoRow != null && !(oldGrupoArquivoRow.RowState == DataRowState.Detached))) && gaRow == oldGrupoArquivoRow)))) { try { MultiPanelControl.SaveArgs successfulSave = new MultiPanelControl.SaveArgs(PersistencyHelper.SaveResult.successful); if (GrupoArquivoChanged != null) GrupoArquivoChanged(successfulSave); if (successfulSave.save == PersistencyHelper.SaveResult.unsuccessful) { mState.mGrupoArquivo = oldGrupoArquivoRow; mState.mIsGrupoArquivoDeleted = oldIsGrupoArquivoDeleted; } ReportAction("Context.GrupoArquivo"); return successfulSave.save != PersistencyHelper.SaveResult.unsuccessful; } catch (InvalidOperationException) { Trace.WriteLine("Error. Restoring previous GA."); mState.mGrupoArquivo = oldGrupoArquivoRow; mState.mIsGrupoArquivoDeleted = oldIsGrupoArquivoDeleted; throw; } } else { return true; } }
public bool SetPermissoesObjDigital(GISADataset.NivelRow nRow, GISADataset.TrusteeRow tRow, bool nvlDeleted, bool tDeleted) { GISADataset.NivelRow oldPermissoesNivelRow = mState.mPermissoesNivelObjDigital; GISADataset.TrusteeRow oldPermissoesTrusteeRow = mState.mPermissoesTrusteeObjDigital; bool oldPermissoesIsNivelDeleted = mState.mIsPermissoesNivelObjDigitalDeleted; bool oldPermissoesIsTrusteeDeleted = mState.mIsPermissoesTrusteeObjDigitalDeleted; mState.mPermissoesNivelObjDigital = nRow; mState.mPermissoesTrusteeObjDigital = tRow; mState.mIsPermissoesNivelObjDigitalDeleted = nvlDeleted; mState.mIsPermissoesTrusteeObjDigitalDeleted = tDeleted; // Se mudarmos entre dois contextos vazios ou se mudarmos entre dois contextos apagados não queremos despoletar o evento if (!((nRow == null && oldPermissoesNivelRow == null && tRow == null && oldPermissoesTrusteeRow == null) || ((nRow != null && nRow.RowState == DataRowState.Detached && tRow != null && tRow.RowState == DataRowState.Detached) && (oldPermissoesNivelRow != null && oldPermissoesNivelRow.RowState == DataRowState.Detached && oldPermissoesTrusteeRow != null && oldPermissoesTrusteeRow.RowState == DataRowState.Detached) || (((nRow != null && !(nRow.RowState == DataRowState.Detached)) && (oldPermissoesNivelRow != null && !(oldPermissoesNivelRow.RowState == DataRowState.Detached))) && nRow == oldPermissoesNivelRow && ((tRow != null && !(tRow.RowState == DataRowState.Detached)) && (oldPermissoesTrusteeRow != null && !(oldPermissoesTrusteeRow.RowState == DataRowState.Detached))) && tRow == oldPermissoesTrusteeRow)))) { MultiPanelControl.SaveArgs successfulSave = new MultiPanelControl.SaveArgs(PersistencyHelper.SaveResult.successful); try { if (PermissoesObjDigitalChanged != null) PermissoesObjDigitalChanged(successfulSave); if (successfulSave.save == PersistencyHelper.SaveResult.unsuccessful) { mState.mPermissoesNivelObjDigital = oldPermissoesNivelRow; mState.mPermissoesTrusteeObjDigital = oldPermissoesTrusteeRow; mState.mIsPermissoesNivelObjDigitalDeleted = oldPermissoesIsNivelDeleted; mState.mIsPermissoesTrusteeObjDigitalDeleted = oldPermissoesIsTrusteeDeleted; } ReportAction("Context.DocumentLevelPermissoesObjDigital"); } catch (InvalidOperationException) { Trace.WriteLine("Error. Restoring previous nivel."); mState.mPermissoesNivelObjDigital = oldPermissoesNivelRow; mState.mPermissoesTrusteeObjDigital = oldPermissoesTrusteeRow; mState.mIsPermissoesNivelObjDigitalDeleted = oldPermissoesIsNivelDeleted; mState.mIsPermissoesTrusteeObjDigitalDeleted = oldPermissoesIsTrusteeDeleted; throw; } return successfulSave.save != PersistencyHelper.SaveResult.unsuccessful; } else { return true; } }
public bool SetAutoEliminacao(GISADataset.AutoEliminacaoRow aeRow, bool aeDeleted) { if (mState.mAutoEliminacao == aeRow && !aeDeleted ^ this.mState.mIsAutoEliminacaoDeleted) { if (AutoEliminacaoChanged != null) AutoEliminacaoChanged(null); return false; } GISADataset.AutoEliminacaoRow oldAutoEliminacaoRow = mState.mAutoEliminacao; bool oldIsAutoEliminacaoDeleted = mState.mIsAutoEliminacaoDeleted; mState.mAutoEliminacao = aeRow; mState.mIsAutoEliminacaoDeleted = aeDeleted; try { MultiPanelControl.SaveArgs successfulSave = new MultiPanelControl.SaveArgs(PersistencyHelper.SaveResult.successful); if (AutoEliminacaoChanged != null) AutoEliminacaoChanged(successfulSave); if (successfulSave.save == PersistencyHelper.SaveResult.unsuccessful) { mState.mAutoEliminacao = oldAutoEliminacaoRow; mState.mIsAutoEliminacaoDeleted = oldIsAutoEliminacaoDeleted; } ReportAction("Context.AutoEliminacao"); return successfulSave.save != PersistencyHelper.SaveResult.unsuccessful; } catch (InvalidOperationException) { Trace.WriteLine("Error. Restoring previous AE."); mState.mAutoEliminacao = oldAutoEliminacaoRow; mState.mIsAutoEliminacaoDeleted = oldIsAutoEliminacaoDeleted; throw; } }
public bool SetDeposito(GISADataset.DepositoRow depRow, bool depDeleted) { if (mState.mDeposito == depRow && !depDeleted ^ this.mState.mIsDepositoDeleted) { if (DepositoChanged != null) DepositoChanged(null); return false; } GISADataset.DepositoRow oldDepositoRow = mState.mDeposito; bool oldIsDepositoDeleted = mState.mIsDepositoDeleted; mState.mDeposito = depRow; mState.mIsDepositoDeleted = depDeleted; try { MultiPanelControl.SaveArgs successfulSave = new MultiPanelControl.SaveArgs(PersistencyHelper.SaveResult.successful); if (DepositoChanged != null) DepositoChanged(successfulSave); if (successfulSave.save == PersistencyHelper.SaveResult.unsuccessful) { mState.mDeposito = oldDepositoRow; mState.mIsDepositoDeleted = oldIsDepositoDeleted; } ReportAction("Context.Deposito"); return successfulSave.save != PersistencyHelper.SaveResult.unsuccessful; } catch (InvalidOperationException) { Trace.WriteLine("Error. Restoring previous AE."); mState.mDeposito = oldDepositoRow; mState.mIsDepositoDeleted = oldIsDepositoDeleted; throw; } }
public bool SetFedoraNivel(GISADataset.NivelRow fedNivelRow, bool fedNivelDeleted) { GISADataset.NivelRow oldFedoraNivelRow = mState.mFedoraNivel; bool oldIsFedoraNivelDeleted = mState.mIsFedoraNivelDeleted; mState.mFedoraNivel= fedNivelRow; mState.mIsFedoraNivelDeleted = fedNivelDeleted; // Se mudarmos entre dois contextos vazios ou se mudarmos entre dois contextos apagados não queremos despoletar o evento if (!((fedNivelRow == null && oldFedoraNivelRow == null) || ((fedNivelRow != null && fedNivelRow.RowState == DataRowState.Detached) && (oldFedoraNivelRow != null && oldFedoraNivelRow.RowState == DataRowState.Detached) || (((fedNivelRow != null && !(fedNivelRow.RowState == DataRowState.Detached)) && (oldFedoraNivelRow != null && !(oldFedoraNivelRow.RowState == DataRowState.Detached))) && fedNivelRow == oldFedoraNivelRow)))) { MultiPanelControl.SaveArgs successfulSave = new MultiPanelControl.SaveArgs(PersistencyHelper.SaveResult.successful); try { if (FedoraNivelChanged != null) FedoraNivelChanged(successfulSave); if (successfulSave.save == PersistencyHelper.SaveResult.unsuccessful) { mState.mFedoraNivel = oldFedoraNivelRow; mState.mIsFedoraNivelDeleted = oldIsFedoraNivelDeleted; } ReportAction("Context.DocumentLevelFedoraNivel"); } catch (InvalidOperationException) { Trace.WriteLine("Error. Restoring previous fedora nivel."); mState.mFedoraNivel = oldFedoraNivelRow; mState.mIsFedoraNivelDeleted = oldIsFedoraNivelDeleted; throw; } // se unsuccessful retorna false, senão retorna true return successfulSave.save != PersistencyHelper.SaveResult.unsuccessful; } else return true; }
//INSTANT C# NOTE: C# does not support optional parameters. Overloaded method(s) are created above. //ORIGINAL LINE: Public Function SetNivel(ByVal nRow As GISADataset.NivelRow, Optional ByVal nvlDeleted As Boolean = false) As Boolean public bool SetNivel(GISADataset.NivelRow nRow, bool nvlDeleted) { // Se mudarmos para um contexto que não tenha uma FRD if (mState.mNivel == nRow && ! nvlDeleted ^ mState.mIsNivelDeleted) { return false; } GISADataset.NivelRow lastNivelSelected = mState.mNivel; mState.mNivel = nRow; mState.mIsNivelDeleted = nvlDeleted; MultiPanelControl.SaveArgs successfulSave = new MultiPanelControl.SaveArgs(PersistencyHelper.SaveResult.successful); if (NivelChanged != null) NivelChanged(successfulSave); ReportAction("Context.Nivel"); if (successfulSave.save == PersistencyHelper.SaveResult.unsuccessful) { mState.mNivel = lastNivelSelected; } return successfulSave.save != PersistencyHelper.SaveResult.unsuccessful; }
public bool SetPermissoes(GISADataset.NivelRow nRow, GISADataset.TrusteeRow tRow, bool nvlDeleted, bool tDeleted) { GISADataset.NivelRow oldPermissoesNivelRow = mState.mPermissoesNivel; GISADataset.TrusteeRow oldPermissoesTrusteeRow = mState.mPermissoesTrustee; bool oldPermissoesIsNivelDeleted = mState.mIsPermissoesNivelDeleted; bool oldPermissoesIsTrusteeDeleted = mState.mIsPermissoesTrusteeDeleted; mState.mPermissoesNivel = nRow; mState.mPermissoesTrustee = tRow; mState.mIsPermissoesNivelDeleted = nvlDeleted; mState.mIsPermissoesTrusteeDeleted = tDeleted; // Se mudarmos entre dois contextos vazios ou se mudarmos entre dois contextos apagados não queremos despoletar o evento if (!((nRow == null && oldPermissoesNivelRow == null && tRow == null && oldPermissoesTrusteeRow == null) || ((nRow != null && nRow.RowState == DataRowState.Detached && tRow != null && tRow.RowState == DataRowState.Detached) && (oldPermissoesNivelRow != null && oldPermissoesNivelRow.RowState == DataRowState.Detached && oldPermissoesTrusteeRow != null && oldPermissoesTrusteeRow.RowState == DataRowState.Detached) || (((nRow != null && !(nRow.RowState == DataRowState.Detached)) && (oldPermissoesNivelRow != null && ! (oldPermissoesNivelRow.RowState == DataRowState.Detached))) && nRow == oldPermissoesNivelRow && ((tRow != null && !(tRow.RowState == DataRowState.Detached)) && (oldPermissoesTrusteeRow != null && !(oldPermissoesTrusteeRow.RowState == DataRowState.Detached))) && tRow == oldPermissoesTrusteeRow)))) { List<long> niveisIDs = new List<long>(); foreach (GISADataset.TrusteeNivelPrivilegeRow tnpRow in GisaDataSetHelper.GetInstance().TrusteeNivelPrivilege.Select("", "", DataViewRowState.Added | DataViewRowState.ModifiedOriginal)) niveisIDs.Add(tnpRow.IDNivel); MultiPanelControl.SaveArgs successfulSave = new MultiPanelControl.SaveArgs(PersistencyHelper.SaveResult.successful); try { if (PermissoesChanged != null) PermissoesChanged(successfulSave); if (successfulSave.save == PersistencyHelper.SaveResult.unsuccessful) { mState.mPermissoesNivel = oldPermissoesNivelRow; mState.mPermissoesTrustee = oldPermissoesTrusteeRow; mState.mIsPermissoesNivelDeleted = oldPermissoesIsNivelDeleted; mState.mIsPermissoesTrusteeDeleted = oldPermissoesIsTrusteeDeleted; } ReportAction("Context.DocumentLevelPermissoesNivel"); } catch (InvalidOperationException) { Trace.WriteLine("Error. Restoring previous nivel."); mState.mPermissoesNivel = oldPermissoesNivelRow; mState.mPermissoesTrustee = oldPermissoesTrusteeRow; mState.mIsPermissoesNivelDeleted = oldPermissoesIsNivelDeleted; mState.mIsPermissoesTrusteeDeleted = oldPermissoesIsTrusteeDeleted; throw; } return successfulSave.save != PersistencyHelper.SaveResult.unsuccessful; } else { return true; } }
//INSTANT C# NOTE: C# does not support optional parameters. Overloaded method(s) are created above. //ORIGINAL LINE: Public Function SetTrustee(ByVal tRow As GISADataset.TrusteeRow, Optional ByVal tDeleted As Boolean = false) As Boolean public bool SetTrustee(GISADataset.TrusteeRow tRow, bool tDeleted) { if (mState.mTrustee == tRow && ! tDeleted ^ mState.mIsTrusteeDeleted) { return false; } GISADataset.TrusteeRow lastTrusteeSelected = mState.mTrustee; mState.mTrustee = tRow; mState.mIsTrusteeDeleted = tDeleted; List<long> niveisIDs = new List<long>(); foreach (GISADataset.TrusteeNivelPrivilegeRow tnpRow in GisaDataSetHelper.GetInstance().TrusteeNivelPrivilege.Select("", "", DataViewRowState.Added | DataViewRowState.ModifiedOriginal)) niveisIDs.Add(tnpRow.IDNivel); MultiPanelControl.SaveArgs successfulSave = new MultiPanelControl.SaveArgs(PersistencyHelper.SaveResult.successful); if (TrusteeChanged != null) TrusteeChanged(successfulSave); ReportAction("Context.Trustee"); if (successfulSave.save == PersistencyHelper.SaveResult.unsuccessful) { mState.mTrustee = lastTrusteeSelected; } return successfulSave.save != PersistencyHelper.SaveResult.unsuccessful; }
//INSTANT C# NOTE: C# does not support optional parameters. Overloaded method(s) are created above. //ORIGINAL LINE: Public Function SetTipoFunction(ByVal tfRow As GISADataset.TipoFunctionRow, Optional ByVal tfDeleted As Boolean = false) As Boolean public bool SetTipoFunction(GISADataset.TipoFunctionRow tfRow, bool tfDeleted) { if (mState.mTipoFunction == tfRow && ! tfDeleted ^ mState.mIsTipoFunctionDeleted) { return false; } GISADataset.TipoFunctionRow lastTipoFunctionSelected = mState.mTipoFunction; mState.mTipoFunction = tfRow; mState.mIsTipoFunctionDeleted = tfDeleted; MultiPanelControl.SaveArgs successfulSave = new MultiPanelControl.SaveArgs(PersistencyHelper.SaveResult.successful); if (TipoFunctionChanged != null) TipoFunctionChanged(successfulSave); ReportAction("Context.TipoFunction"); if (successfulSave.save == PersistencyHelper.SaveResult.unsuccessful) { mState.mTipoFunction = lastTipoFunctionSelected; } return successfulSave.save != PersistencyHelper.SaveResult.unsuccessful; }
public bool SetControloAutDicionario(GISADataset.ControloAutDicionarioRow cadRow, bool cadDeleted) { GISADataset.ControloAutRow caRow = null; GISADataset.ControloAutDicionarioRow lastCadRowSelected = mState.mControloAutDicionario; if (cadRow == null) caRow = null; else caRow = cadRow.ControloAutRow; if (cadRow == null && ControloAutDicionario == null) { } else if ((cadRow != null && cadRow.RowState == DataRowState.Detached) && (ControloAutDicionario != null && ControloAutDicionario.RowState == DataRowState.Detached) || (((cadRow != null && ! (cadRow.RowState == DataRowState.Detached)) && (ControloAutDicionario != null && ! (ControloAutDicionario.RowState == DataRowState.Detached))) && cadRow.ControloAutRow == ControloAutDicionario.ControloAutRow)) { // verificar se apesar de não ter existido mudança do controlo de autoridade selecionado // foi alterada a selecção sobre uma das suas formas if (! (cadRow == ControloAutDicionario)) { mState.mControloAutDicionario = cadRow; return true; } else if (cadRow == ControloAutDicionario) { return true; } else { if (ControloAutChanged != null) ControloAutChanged(null); return false; } } mState.mControloAutDicionario = cadRow; mState.mIsControloAutDicionarioDeleted = cadDeleted; MultiPanelControl.SaveArgs successfulSave = new MultiPanelControl.SaveArgs(PersistencyHelper.SaveResult.successful); if (ControloAutChanged != null) ControloAutChanged(successfulSave); ReportAction("Context.ControloAut"); if (successfulSave.save == PersistencyHelper.SaveResult.unsuccessful) { mState.mControloAutDicionario = lastCadRowSelected; } return successfulSave.save != PersistencyHelper.SaveResult.unsuccessful; }
public bool SetNivelUnidadeFisica(GISADataset.NivelRow nRow, bool nvlDeleted, bool multiselection) { if (multiselection) { return true; } if (mState.mNivelUnidadeFisica == nRow && ! nvlDeleted ^ this.mState.mIsNivelUnidadeFisicaDeleted) { if (NivelUnidadeFisicaChanged != null) NivelUnidadeFisicaChanged(null); return false; } GISADataset.NivelRow oldNivelUnidadeFisicaRow = mState.mNivelUnidadeFisica; bool oldIsNivelUnidadeFisicaDeleted = mState.mIsNivelUnidadeFisicaDeleted; mState.mNivelUnidadeFisica = nRow; mState.mIsNivelUnidadeFisicaDeleted = nvlDeleted; try { MultiPanelControl.SaveArgs successfulSave = new MultiPanelControl.SaveArgs(PersistencyHelper.SaveResult.successful); if (NivelUnidadeFisicaChanged != null) NivelUnidadeFisicaChanged(successfulSave); if (successfulSave.save == PersistencyHelper.SaveResult.unsuccessful) { mState.mNivelUnidadeFisica = oldNivelUnidadeFisicaRow; mState.mIsNivelUnidadeFisicaDeleted = oldIsNivelUnidadeFisicaDeleted; } ReportAction("Context.NivelUnidadeFisica"); return successfulSave.save != PersistencyHelper.SaveResult.unsuccessful; } catch (InvalidOperationException) { Trace.WriteLine("Error. Restoring previous UF."); mState.mNivelUnidadeFisica = oldNivelUnidadeFisicaRow; mState.mIsNivelUnidadeFisicaDeleted = oldIsNivelUnidadeFisicaDeleted; throw; } }
private void frmMain_Closing(object Sender, System.ComponentModel.CancelEventArgs e) { if (PanelDown.Controls.Count > 0) { GISAControl ctrl = (GISAControl)(SlavePanelStack.Peek()); PersistencyHelper.SaveResult successfulSave = PersistencyHelper.SaveResult.successful; MultiPanelControl.SaveArgs saveArgs = new MultiPanelControl.SaveArgs(successfulSave); ctrl.CurrentContext.saveState(); ctrl.CurrentContext.clear(); ctrl.Recontextualize(saveArgs); if (saveArgs.save == PersistencyHelper.SaveResult.unsuccessful) { e.Cancel = true; ctrl.CurrentContext.restoreState(); return; } PopSlavePanel(ctrl.GetType()); e.Cancel = SlavePanelStack.Count > 0; } //logout Thread t = new Thread(new ThreadStart(CleanupDB)); t.Start(); //delete temp files Thread t2 = new Thread(new ThreadStart(ImageHelper.DeleteTempFiles)); t2.Start(); }
public bool SetNivelEstrututalDocumental(GISADataset.NivelRow nRow, bool nvlDeleted) { // Se mudarmos para um contexto que não tenha uma FRD if (nRow != null && nRow.RowState != DataRowState.Detached && nRow.TipoNivelRow.ID == TipoNivel.LOGICO) { nRow = null; nvlDeleted = false; } GISADataset.NivelRow oldNivelRow = mState.mNivelEstrututalDocumental; bool oldIsNivelDeleted = mState.mIsNivelEstrututalDocumentalDeleted; mState.mNivelEstrututalDocumental = nRow; mState.mIsNivelEstrututalDocumentalDeleted = nvlDeleted; // Se mudarmos entre dois contextos vazios ou se mudarmos entre dois contextos apagados não queremos despoletar o evento if (! ((nRow == null && oldNivelRow == null) || ((nRow != null && nRow.RowState == DataRowState.Detached) && (oldNivelRow != null && oldNivelRow.RowState == DataRowState.Detached) || (((nRow != null && ! (nRow.RowState == DataRowState.Detached)) && (oldNivelRow != null && ! (oldNivelRow.RowState == DataRowState.Detached))) && nRow == oldNivelRow)))) { MultiPanelControl.SaveArgs successfulSave = new MultiPanelControl.SaveArgs(PersistencyHelper.SaveResult.successful); try { if (NivelEstrututalDocumentalChanged != null) NivelEstrututalDocumentalChanged(successfulSave); if (successfulSave.save == PersistencyHelper.SaveResult.unsuccessful) { mState.mNivelEstrututalDocumental = oldNivelRow; mState.mIsNivelEstrututalDocumentalDeleted = oldIsNivelDeleted; } ReportAction("Context.DocumentLevelNivel"); } catch (InvalidOperationException) { Trace.WriteLine("Error. Restoring previous nivel."); mState.mNivelEstrututalDocumental = oldNivelRow; mState.mIsNivelEstrututalDocumentalDeleted = oldIsNivelDeleted; throw; } // se unsuccessful retorna false, senão retorna true return successfulSave.save != PersistencyHelper.SaveResult.unsuccessful; } else return true; }
private void OutlookBarItemClicked(object Sender, LumiSoft.UI.Controls.WOutlookBar.ItemClicked_EventArgs e) { if (e.Item.Tag == null) { return; } this.outlookBar.Enabled = false; try { GISADataset.TipoFunctionRow masterTipoFunction = null; GISADataset.TipoFunctionRow slaveTipoFunction = null; slaveTipoFunction = (GISADataset.TipoFunctionRow)e.Item.Tag; masterTipoFunction = slaveTipoFunction.TipoFunctionRowParent; // Limpeza do contexto actual antes de fazer um recontextualize. É gravado // o estado actual do contexto para que possa ser recuparado caso se pretenda // cancelar a operação if (CurrentContext.Trustee != null) CurrentContext.SetTrustee(null, false); CurrentContext.saveState(); CurrentContext.clear(); PersistencyHelper.SaveResult successfulSave = PersistencyHelper.SaveResult.successful; MultiPanelControl.SaveArgs saveArgs = new MultiPanelControl.SaveArgs(successfulSave); // recontextualizar a seguir a uma limpeza de contexto para garantidamente gravar e sair do contexto antigo if (PanelDown.Controls.Count == 1) { ((GISAControl)(PanelDown.Controls[0])).Recontextualize(saveArgs); } // clear context information before activating a new master panel StatusBarPanelHint.Text = ""; // limpar propriedade que indica se algum painel está a ser usado como suporte // (mas o estado é guardado numa variável a fim de ser possível restituir o // estado anterior caso ocorra algum conflito de concorrência) bool isSptPanel = false; // As TipoFunctions costumam ser SlavePanels/FRDs tendo por // isso um TipoFunctionRowParent não nothing. No entanto, o // "slaveTipoFunction" será nothing se existir um MasterPanel // associado directamente ao outlookbaritem clicado. // Inspecção das permissoes de leitura. as permissoes estao // sempre associadas ao slavepanel uma vez que pode-se querer // comportamentos diferentes do painel superior consoante o // painel inferior em uso (Nota: o painel inferior é a maior // parte das vezes um multipanel). // Esta logica surge depois da persistencia dos dados na BD // para que qualquer alteração às permissões do próprio // utilizador consigam ser recarregadas logo na seguinte // mudança de contexto. if (!(CheckTipoFunctionPermissions(slaveTipoFunction, GisaPrincipalPermission.READ))) { #if ! ALLPRODUCTPERMISSIONS MessageBox.Show("Não possui permissões de acesso a esta funcionalidade", "Acesso negado", MessageBoxButtons.OK, MessageBoxIcon.Warning); RestoreOutlookBarSelection(); if (PanelDown.Controls.Count == 1) { ((GISAControl)(PanelDown.Controls[0])).Recontextualize(); } return; #endif } else if (saveArgs.save == PersistencyHelper.SaveResult.unsuccessful) { RestoreOutlookBarSelection(); return; } // limpar propriedade que indica se algum painel está a ser usado como suporte isSuportPanel = isSptPanel; Assembly masterAssembly = null; Assembly slaveAssembly = null; Type masterType = null; Type slaveType = null; if (masterTipoFunction != null) { masterAssembly = EnsureLoaded(masterTipoFunction.ModuleName); masterType = CheckGuiExtension(masterAssembly, masterTipoFunction.ClassName); ClearMasterPanelStack(MasterPanelStack, false); } if (slaveTipoFunction != null) { slaveAssembly = EnsureLoaded(slaveTipoFunction.ModuleName); slaveType = CheckGuiExtension(slaveAssembly, slaveTipoFunction.ClassName); ClearSlavePanelStack(SlavePanelStack, true); } else { Debug.Assert(false, "Slave panel inexistente!"); } if (masterTipoFunction != null) { PushMasterPanel(masterType); if (SlavePanelStack.Count > 0) { // teoria: esta situação nunca ocorre. para verificar fica aqui este assert Debug.Assert(false, "existe um slavepanel!?"); ((GISAControl)(SlavePanelStack.Peek())).Recontextualize(); // no caso de se revelar necessario este recontextualize será necessário também // verificar se qualquer eventual gravacao de dados foi bem sucedida. } } PushSlavePanel(slaveType); if (masterTipoFunction != null) { this.PanelUp.Visible = true; this.Splitter2.Visible = true; } else { this.PanelUp.Visible = false; this.Splitter2.Visible = false; foreach (GISAControl gc in MasterPanelStack) { gc.Visible = false; } } // durante a adição de um masterpanel ou na sua mudança de visibilidade pode // dar-se o caso de ser estabelecido um CurrentContext sem no entanto o evento // lançado ser recebido por alguem (uma vez que não existe slavepanel). // Por essa razão é necessário limpar qualquer contexto eventualmente existente // e tornar a defini-lo mais tarde, para que o evento seja desta vez recebido. CurrentContext.clear(); ((GISAControl)(SlavePanelStack.Peek())).ListeningToContextChanges = true; if (masterTipoFunction != null) { UpdateMasterPanelContext(masterType); // Actualizar as permissões do masterpanel tendo em conta o painel inferior // em uso e de forma a activar/desactivar funcionalidades da toolbar ((frmMain)TopLevelControl).ApplyMasterPermissions(); // É necessário voltar a actualizar a toolbar para refletir as permissões // obtidas do método anterior (em alguns casos - MasterPanelNiveis - a toolbar // é atualizada no momento da construção do master panel) ((frmMain)TopLevelControl).UpdateMasterToolBarButtons(); } LastBarClicked = outlookBar.ActiveBar; LastItemClicked = e.Item; } catch (System.Reflection.TargetInvocationException ex) { Trace.WriteLine(ex); MessageBox.Show("Ocorreu um erro durante carregamento de componentes da" + Environment.NewLine + "aplicação, tendo esta de ser fechada. Se o problema persistir" + Environment.NewLine + "por favor contacte o administrador de sistema.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } catch (System.IO.IOException ex) { Trace.WriteLine(ex); MessageBox.Show("Ocorreu um erro durante o acesso ao sistema de ficheiros," + Environment.NewLine + "a aplicação terá de ser fechada. Se o problema persistir" + Environment.NewLine + "por favor contacte o administrador de sistema.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } catch (SearchWebException ex) { Trace.WriteLine(ex); MessageBox.Show("Ocorreu um erro de comunicação com o servidor de pesquisa, a" + Environment.NewLine + "aplicação terá de ser fechada. Se o problema persistir" + Environment.NewLine + "por favor contacte o administrador de sistema.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } catch (Exception ex) { Trace.WriteLine(ex); MessageBox.Show("Ocorreu um erro durante o acesso à base de dados, a" + Environment.NewLine + "aplicação terá de ser fechada. Se o problema persistir" + Environment.NewLine + "por favor contacte o administrador de sistema.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } finally { this.outlookBar.Enabled = true; } }