private void btnNavegar_Click(object sender, EventArgs e) { currentState = currentState == State.filter ? State.navigation : State.filter; this.grpNavegacao.Visible = currentState == State.navigation; this.controloAutList1.Visible = currentState == State.filter; this.btnNavegar.ImageIndex = currentState == State.filter ? 0 : 1; this.btnNavegar.Text = currentState == State.filter ? "Tesauro" : "Voltar"; this.toolTip1.SetToolTip(this.btnNavegar, currentState == State.filter ? SharedResourcesOld.CurrentSharedResources.NavThesaurusStrings[0] : SharedResourcesOld.CurrentSharedResources.NavThesaurusStrings[1]); if (currentState == State.navigation) { var cadRow = this.controloAutList1.SelectedItems[0].Tag as GISADataset.ControloAutDicionarioRow; GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { this.controlTermosIndexacao1.trVwTermoIndexacao.Nodes.Clear(); this.controlTermosIndexacao1.LoadData(cadRow.ControloAutRow, ho.Connection); } catch (Exception) { throw; } finally { ho.Dispose(); } } }
private void pxDataGridView1_SelectionChanged(object sender, EventArgs e) { var sel = pxDataGridView1.SelectedCells; if (sel.Count == 0) { controloLocalizacao1.ClearTree(); } else { var nivelID = long.Parse(sel[0].OwningRow.Cells[IDNIVEL].Value.ToString()); GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { controloLocalizacao1.BuildTree(nivelID, ho.Connection, SessionHelper.GetGisaPrincipal().TrusteeUserOperator.ID); } catch (Exception ex) { Trace.WriteLine(ex); throw; } finally { ho.Dispose(); } } }
public override void LoadData() { if (CurrentContext.Movimento == null) { CurrentMovimento = null; return; } CurrentMovimento = CurrentContext.Movimento; GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetTempConnection()); try { documentos = MovimentoRule.Current.GetDocumentos(CurrentMovimento.ID, GisaDataSetHelper.GetInstance(), ho.Connection); } catch (Exception ex) { Trace.WriteLine(ex); throw; } finally { ho.Dispose(); } }
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 = DBAbstractDataLayer.DataAccessRules.UFRule.Current.GetNiveisDocAssociados(CurrentFRDBase.NivelRow.ID, ho.Connection); GISA.Search.Updater.updateNivelDocumental(IDNiveis); GISA.Search.Updater.updateUnidadeFisica(CurrentFRDBase.NivelRow.ID); } catch (GISA.Search.UpdateServerException) { } catch (Exception ex) { Trace.WriteLine(ex.ToString()); throw; } finally { ho.Dispose(); } } return(successfulSave); }
private DateTime LoadLastTimeStamp() { var ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { DBAbstractDataLayer.DataAccessRules.IntGestDocRule.Current.LoadInteg_Config(GisaDataSetHelper.GetInstance(), ho.Connection); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); throw; } finally { ho.Dispose(); } var ts = GisaDataSetHelper.GetInstance().Integ_Config.Cast <GISADataset.Integ_ConfigRow>().Select(r => r.LastTimeStamp).SingleOrDefault(); if (ts == null) { return(DateTime.MinValue); } else { return(ts); } }
private void DeleteItem() { var lst = lstVwNiveisAssoc.SelectedItems.Cast <ListViewItem>() .Select(lvi => lvi.Tag).Cast <GISADataset.SFRDUnidadeFisicaRow>() .Select(sfrduf => sfrduf.FRDBaseRow.IDNivel).ToList(); GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { DBAbstractDataLayer.DataAccessRules.NivelRule.Current.LoadNivelRelacoesHierarquicas(GisaDataSetHelper.GetInstance(), lst, ho.Connection); } catch (Exception ex) { Trace.WriteLine(ex); throw; } finally { ho.Dispose(); } lstVwNiveisAssoc.SelectedItems.Cast <ListViewItem>().ToList() .ForEach(lvi => { var sfrduf = lvi.Tag as GISADataset.SFRDUnidadeFisicaRow; ordem.Remove(sfrduf.IDFRDBase); detalhes.Remove(sfrduf.FRDBaseRow.IDNivel); }); GUIHelper.GUIHelper.deleteSelectedLstVwItems(lstVwNiveisAssoc); UpdateListButtonsState(); }
private void OnTimedEvent(object source, EventArgs e) { clickTypeSelectorTimer.Stop(); string ufs = string.Empty; GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { if (this.txtCota.Text.Trim().Length > 0) { ufs = FRDRule.Current.UFsWithSameCota(CurrentUFFRDBase.ID, txtCota.Text, ho.Connection); } } catch (Exception ex) { Trace.WriteLine(ex); throw; } finally { ho.Dispose(); } if (ufs.Length == 0) { label1.Enabled = false; toolTip1.Active = false; } else { label1.Enabled = true; toolTip1.Active = true; toolTip1.SetToolTip(label1, "Unidades físicas com a mesma cota:" + ufs); } }
public void LoadData(bool excludeEmptyAutos) { GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); ArrayList aeList = null; try { Trace.WriteLine("<getAutosEliminacao>"); //TODO: apagar? //dataReader = GisaDataSetHelper.GetDBLayer().CallStoredProcedure("sp_getAutosEliminacao", param, types, values) aeList = RelatorioRule.Current.LoadDataFormAutoEliminacaoPicker(excludeEmptyAutos, ho.Connection); Trace.WriteLine("</getAutosEliminacao>"); foreach (object[] ae in aeList) { addAutoToListView(ae); } // obter também os autos de eliminação que possam já ter sido criados mas ainda não existam na BD foreach (GISADataset.AutoEliminacaoRow aeRow in GisaDataSetHelper.GetInstance().AutoEliminacao.Select("ID < 0")) { addAutoToListView(new object[] {aeRow.ID, aeRow.Designacao, 0, 0}); // FIXME: estes zeros nao deviam estar hardcoded } } catch (Exception ex) { Trace.WriteLine(ex); throw; } finally { ho.Dispose(); } UpdateButtonState(); }
private void RetrieveSelection(FormControloAutRel frm, DataRow relRow) { try { if (relRow != null) // edição { frm.SetEditMode(); } frm.ShowDialog(); GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { LoadData(CurrentControloAut, ho.Connection); ModelToView(); } finally { ho.Dispose(); } } catch (Exception ex) { Trace.WriteLine(ex); throw ex; } }
private void LoadNivelRoot(TreeView trvw) { long startTicks = DateTime.Now.Ticks; GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { long[] edIDs = DBAbstractDataLayer.DataAccessRules.NivelRule.Current.LoadEntidadesDetentoras(GisaDataSetHelper.GetInstance(), ho.Connection); trvw.Nodes.Clear(); GISADataset.NivelRow nRow = null; GISADataset.TipoNivelRelacionadoRow tnrRow = null; foreach (long edID in edIDs) { nRow = (GISADataset.NivelRow)(GisaDataSetHelper.GetInstance().Nivel.Select("ID=" + edID.ToString())[0]); tnrRow = (GISADataset.TipoNivelRelacionadoRow)(GisaDataSetHelper.GetInstance().TipoNivelRelacionado.Select(string.Format("ID={0}", TipoNivelRelacionado.ED))[0]); AddNivelDesignado(trvw.Nodes, nRow, null, tnrRow, ho.Connection); } } catch (Exception ex) { Trace.WriteLine(ex); throw; } finally { ho.Dispose(); } Debug.WriteLine("<<LoadNivelRoot>>: " + new TimeSpan(DateTime.Now.Ticks - startTicks).ToString()); }
protected override void EditTrustee() { if (lstVwTrustees.SelectedItems.Count == 0) return; ((frmMain)TopLevelControl).EnterWaitMode(); ListViewItem item = null; GISADataset.TrusteeRow truRow = null; item = lstVwTrustees.SelectedItems[0]; truRow = (GISADataset.TrusteeRow)item.Tag; GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { if (TrusteeRule.Current.hasRegistos(((GISADataset.TrusteeRow)(lstVwTrustees.SelectedItems[0].Tag)).ID, ho.Connection)) MessageBox.Show("Tenha em conta que alterações no nome de utilizador terá reflexos no registos no sistema.", "Utilizador", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { Trace.WriteLine(ex); throw; } finally { ho.Dispose(); } FormCreateTrustee form = new FormCreateTrustee(); form.Text = "Editar utilizador"; form.txtTrusteeName.Text = truRow.Name; switch (form.ShowDialog()) { case DialogResult.OK: PersistencyHelper.EditTrusteePreConcArguments ctpca = new PersistencyHelper.EditTrusteePreConcArguments(); ctpca.truRow = truRow; ctpca.username = form.txtTrusteeName.Text; Trace.WriteLine("A editar utilizador..."); PersistencyHelper.save(EditTrusteeIfUsernameDoesntExist, ctpca); PersistencyHelper.cleanDeletedData(); if (! ctpca.successful) { MessageBox.Show("Este nome já existe atribuído a um utilizador ou grupo, " + Environment.NewLine + "por favor escolha outro nome.", form.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); UpdateTrustees(null); } else { UpdateTrustees(truRow); UpdateContext(); } UpdateToolBarButtons(); break; case DialogResult.Cancel: break; } ((frmMain)TopLevelControl).LeaveWaitMode(); }
protected virtual void DisplayFormaAutorizada(GISADataset.ControloAutDicionarioRow ControloAutDicionario) { Debug.Assert(TempIndexFRDCA != null); if (ControloAutDicionario.IDTipoControloAutForma != Convert.ToInt64(TipoControloAutForma.FormaAutorizada)) { Debug.Assert(false, "CAD should always be Autorizado"); GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { DBAbstractDataLayer.DataAccessRules.ControloAutRule.Current.LoadFormaAutorizada(ControloAutDicionario.ControloAutRow.ID, GisaDataSetHelper.GetInstance(), ho.Connection); } finally { ho.Dispose(); } ControloAutDicionario = GISA.Model.ControloAutHelper.getFormaAutorizada(ControloAutDicionario.ControloAutRow); } ListViewItem li = ListView.Items.Add(ControloAutDicionario.DicionarioRow.Termo); li.Tag = TempIndexFRDCA; RaiseEventAddControloAut(li); }
public static void UpdateNivelPermissions(GISADataset.NivelRow NivelRow, long trusteeUserOperatorID) { ClearPermissons(); if (NivelRow == null) { return; } if (NivelRow.RowState == DataRowState.Detached) { return; } byte[] permissoes = null; GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetTempConnection()); try { permissoes = GetPermissons(NivelRow.ID, trusteeUserOperatorID, ho.Connection); } catch (Exception ex) { Trace.WriteLine(ex.ToString()); throw ex; } finally { ho.Dispose(); } mAllowCreate = permissoes[0] == 1; mAllowRead = permissoes[1] == 1; mAllowEdit = permissoes[2] == 1; mAllowDelete = permissoes[3] == 1; mAllowExpand = permissoes[4] == 1; }
public List <CorrespondenciaDocs> FilterPreviousIncorporations(List <CorrespondenciaDocs> corresp) { var desDictionary = corresp.ToDictionary(c => new IntGestDocRule.DocInPortoRecord() { IDExterno = c.EntidadeExterna.IDExterno, DataArquivo = c.EntidadeExterna.Timestamp, IDSistema = (int)c.EntidadeExterna.Sistema, IDTipoEntidade = (int)c.EntidadeExterna.Tipo }, c => c.EntidadeExterna); var correspDictionary = corresp.ToDictionary(c => c.EntidadeExterna, c => c); List <IntGestDocRule.DocInPortoRecord> diprecordsFiltered = null; var ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { diprecordsFiltered = IntGestDocRule.Current.FilterPreviousIncorporations(desDictionary.Keys.ToList(), ho.Connection); } catch (Exception e) { Console.WriteLine(e.ToString()); throw; } finally { ho.Dispose(); } var desFiltered = diprecordsFiltered.Where(rec => desDictionary.ContainsKey(rec)).Select(r => desDictionary[r]).ToList(); return(desFiltered.Where(de => correspDictionary.ContainsKey(de)).Select(d => correspDictionary[d]).ToList()); }
private void lstVwEstruturaDocs_SelectedIndexChanged(object sender, EventArgs e) { if (lstVwEstruturaDocs.SelectedItems.Count == 1) { // é utilizada a primeira relação encontrada GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { GISADataset.NivelRow nRow = null; nRow = (GISADataset.NivelRow)(lstVwEstruturaDocs.SelectedItems[0].Tag); panelInfoEPs1.BuildTree(nRow, ho.Connection); } catch (Exception ex) { Trace.WriteLine(ex); throw; } finally { ho.Dispose(); } } else if (lstVwEstruturaDocs.SelectedItems.Count == 0) { panelInfoEPs1.ClearAll(); } UpdateToolBarButtons(); }
private static PermissoesHelper.PermissionType GetEffectivePermission(ListViewItem item, int colIndex, string TipoOperationName, GISADataset.TrusteeNivelPrivilegeRow tnpRow, long IDTrustee) { PermissoesHelper.PermissionType permissaoEfectiva = PermissionType.ImplicitDeny; if ((tnpRow != null) && (tnpRow[TipoOperationName] != DBNull.Value)) { permissaoEfectiva = (byte)tnpRow[TipoOperationName] == 1 ? PermissionType.ExplicitGrant : PermissionType.ExplicitDeny; } else { var nRow = (GISADataset.NivelRow)item.Tag; var ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { var perms = PermissoesRule.Current.CalculateImplicitPermissions(nRow.ID, IDTrustee, ho.Connection); if (perms.ContainsKey(nRow.ID)) { permissaoEfectiva = GetPermissionValue(perms[nRow.ID], GisaDataSetHelper.GetInstance().NivelTipoOperation.Cast <GISADataset.NivelTipoOperationRow>().Single(r => r.TipoOperationRow.Name.Equals(TipoOperationName))) == 1 ? PermissionType.ImplicitGrant : PermissionType.ImplicitDeny; } } catch (Exception ex) { Trace.WriteLine(ex); throw; } finally { ho.Dispose(); } } return(permissaoEfectiva); }
private void comprovativoToolMenuItem_Click(object sender, EventArgs e) { GISADataset.MovimentoRow movRow = (GISADataset.MovimentoRow) this.movList.SelectedItems[0].Tag; List <MovimentoRule.DocumentoMovimentado> documents = new List <MovimentoRule.DocumentoMovimentado>(); GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { documents = MovimentoRule.Current.GetDocumentos(movRow.ID, GisaDataSetHelper.GetInstance(), ho.Connection); } catch (Exception ex) { Trace.WriteLine(ex); throw; } finally { ho.Dispose(); } Reports.Movimentos.RelatorioMovimento report = new Reports.Movimentos.RelatorioMovimento(movRow, documents, string.Format("Requisicao_{0}", movRow.ID), SessionHelper.GetGisaPrincipal().TrusteeUserOperator.ID); object o = new Reports.BackgroundRunner(TopLevelControl, report, 1); }
public override void ViewToModel() { if (CurrentFRDBase == null || CurrentFRDBase.RowState == DataRowState.Detached || !IsLoaded) { return; } // Nos subdocumentos, o campo estruturado fica activo quando o seu documento/processo tem a tipologia "processo de obras" associada GISADataset.FRDBaseRow frdRow = this.IDTipoNivelRelacionado == (long)TipoNivelRelacionado.SD ? GisaDataSetHelper.GetInstance().RelacaoHierarquica.Cast <GISADataset.RelacaoHierarquicaRow>().Single(r => r.ID == CurrentFRDBase.IDNivel) .NivelRowByNivelRelacaoHierarquicaUpper.GetFRDBaseRows().Single() : CurrentFRDBase; System.Diagnostics.Debug.Assert((this.IDTipoNivelRelacionado == (long)TipoNivelRelacionado.SD && !CurrentFRDBase.Equals(frdRow)) || this.IDTipoNivelRelacionado != (long)TipoNivelRelacionado.SD); var currentIndexFRDCA = GisaDataSetHelper.GetInstance().IndexFRDCA.Cast <GISADataset.IndexFRDCARow>().Where( r => (r.RowState == DataRowState.Added || r.RowState == DataRowState.Modified || r.RowState == DataRowState.Unchanged) && r.IDFRDBase == frdRow.ID && !r.IsSelectorNull() && r.Selector == -1).SingleOrDefault(); var indexFRDCADeletedList = GisaDataSetHelper.GetInstance().IndexFRDCA.Cast <GISADataset.IndexFRDCARow>().Where( r => r.RowState == DataRowState.Deleted && (long)r["IDFRDBase", DataRowVersion.Original] == frdRow.ID && r["Selector", DataRowVersion.Original] != DBNull.Value && (int)r["Selector", DataRowVersion.Original] == -1).ToArray(); var possuiDadosLicencaDeObras = false; GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { possuiDadosLicencaDeObras = FRDRule.Current.possuiDadosLicencaDeObras(GisaDataSetHelper.GetInstance(), frdRow.ID, ho.Connection); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); throw; } finally { ho.Dispose(); } if ((currentIndexFRDCA != null && IsRelatedToProcessoObras(currentIndexFRDCA.ControloAutRow)) || (indexFRDCADeletedList.Length == 0 && possuiDadosLicencaDeObras)) { if (this.IDTipoNivelRelacionado == (long)TipoNivelRelacionado.SD) { this.contInfLicencaObrasSD1.ViewToModel(); } else { this.contInfLicencaObras1.ViewToModel(); } } else { CurrentSFRDConteudoEEstrutura.ConteudoInformacional = txtConteudoInformacional.Text; } }
protected override void DeleteTrustee() { if (lstVwTrustees.SelectedItems.Count == 0) return; Int64 idTrustee = ((GISADataset.TrusteeRow)(lstVwTrustees.SelectedItems[0].Tag)).ID; if (idTrustee == SessionHelper.GetGisaPrincipal().TrusteeUserOperator.ID) { MessageBox.Show("O utilizador não pode ser removido visto estar a ser usado atualmente na aplicação.", "Utilizador", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } ((frmMain)TopLevelControl).EnterWaitMode(); GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { if (TrusteeRule.Current.hasRegistos(idTrustee, ho.Connection)) { MessageBox.Show("O utilizador não pode ser removido pois já criou registos no sistema.", "Utilizador", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } catch (Exception ex) { Trace.WriteLine(ex); throw; } finally { ho.Dispose(); ((frmMain)TopLevelControl).LeaveWaitMode(); } switch (MessageBox.Show("O utilizador será removido, deseja continuar?", "Utilizador", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) { case DialogResult.OK: Trace.WriteLine("A apagar utilizador..."); ListViewItem item = null; GISADataset.TrusteeRow truRow = null; item = lstVwTrustees.SelectedItems[0]; truRow = (GISADataset.TrusteeRow)item.Tag; // após a mundaça dfe contexto anterior pode ter-se chegado à conclusão // que a row já foi anteriormente eliminada por outro utilizador. if (truRow.RowState != DataRowState.Detached) DeleteTrusteeAndRelatedRows(truRow); // Remover a selecção do item vai provocar uma mudança de contexto que // por sua vez vai provocar uma gravação dos dados lstVwTrustees.clearItemSelection(item); item.Remove(); break; case DialogResult.Cancel: break; } ((frmMain)TopLevelControl).LeaveWaitMode(); }
private void lstVwAutosEliminacao_SelectedIndexChanged(object sender, EventArgs e) { if (lstVwAutosEliminacao.SelectedItems.Count == 1) { CurrentAutoEliminacao = lstVwAutosEliminacao.SelectedItems[0].Tag as GISADataset.AutoEliminacaoRow; if (CurrentAutoEliminacao == null) { throw new Exception("Auto eliminação inválido!"); } GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { // Carregar os detalhes deste auto de eliminacao: List <AutoEliminacaoRule.AutoEliminacao_UFsEliminadas> ufs_auto_eliminacao = AutoEliminacaoRule.Current.LoadUnidadesFisicasAvaliadas(GisaDataSetHelper.GetInstance(), CurrentAutoEliminacao.ID, ho.Connection); List <ListViewItem> items = new List <ListViewItem>(); foreach (AutoEliminacaoRule.AutoEliminacao_UFsEliminadas uf in ufs_auto_eliminacao) { ListViewItem item = new ListViewItem(""); item.Checked = uf.paraEliminar; item.SubItems.Add(uf.codigo); item.SubItems.Add(uf.designacao); item.SubItems.Add(GUIHelper.GUIHelper.FormatDimensoes(uf.altura, uf.largura, uf.profundidade, uf.tipoMedida)); item.Tag = uf.IDNivel; items.Add(item); if (uf.largura.HasValue) { larguraTotal += uf.largura.Value; } } this.lstVwUnidadesFisicas.Items.AddRange(items.ToArray()); grpUnidadesFisicasAvaliadas.Text = string.Format(grpUFsAssociadasText, this.lstVwUnidadesFisicas.Items.Count, larguraTotal); // Notas de eliminacao: if (CurrentAutoEliminacao.IsNotasEliminacaoNull()) { txt_NotasEliminacao.Text = ""; } else { txt_NotasEliminacao.Text = CurrentAutoEliminacao.NotasEliminacao; } } catch (Exception ex) { Debug.WriteLine(ex); throw; } finally { ho.Dispose(); } } else { ViewToModel(); lstVwUnidadesFisicas.Items.Clear(); } }
private void removeSelectedItem(DataGridView dataGrid) { string TitleMsgBox = "Remoção de item(s)"; var ans = MessageBox.Show("Tem a certeza que deseja " + "eliminar o(s) item(s) selecionado(s)?", TitleMsgBox, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (ans == DialogResult.Cancel) { return; } decimal largura = 0; var gridRowsToDelete = dataGrid.SelectedRows.Cast <DataGridViewRow>(); var ufIDs = gridRowsToDelete.Select(r => long.Parse(r.Cells[ID].Value.ToString())).ToArray(); GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { GisaDataSetHelper.ManageDatasetConstraints(false); largura = DBAbstractDataLayer.DataAccessRules.UFRule.Current.LoadDescricaoFisicaAndGetSomatorioLargura(GisaDataSetHelper.GetInstance(), ufIDs, ho.Connection); } catch (Exception ex) { Debug.WriteLine(ex); throw; } finally { ho.Dispose(); } // actualizar largura total larguraTotal -= largura; // apagar rows object[] res = new object[2]; res[0] = CurrentFRDBase.ID; DataView dv; DataRowView[] dr; dv = GisaDataSetHelper.GetInstance().SFRDUnidadeFisica.DefaultView; dv.ApplyDefaultSort = true; gridRowsToDelete.ToList().ForEach(r => { res[1] = r.Cells[ID].Value; dr = dv.FindRows(res); dr[0].Row.Delete(); ((DataRowView)r.DataBoundItem).Row.Delete(); }); UpdateListButtonsState(); // actualizar string UpdateInfoSuporte(); // actualizar datatable bounded à griddataview UFsRelacionadasDataTable.AcceptChanges(); }
private void ClearPanelStatusObjDigitais() { GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { ObjectoDigitalStatusRule.Current.removeOldODsFromQueue(ho.Connection); } catch (Exception e) { Trace.WriteLine(e.ToString()); } finally { ho.Dispose(); } this.ActivatePanelStatusObjDigitais(true); }
public static void AddNewObjDigGrantPermissions(List <GISADataset.ObjetoDigitalRow> odRows, GISADataset.NivelRow nRow) { var trusteeRow = SessionHelper.GetGisaPrincipal().TrusteeUserOperator.TrusteeRow; Dictionary <long, Dictionary <string, bool> > perms; GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { // carregar utilizadores e grupos PermissoesRule.Current.LoadUtilizadores(GisaDataSetHelper.GetInstance(), ho.Connection); // carregar permissões efectivas perms = PermissoesRule.Current.GetEffectiveReadWritePermissions(nRow.ID, ho.Connection); } catch (Exception e) { Trace.WriteLine(e); throw; } finally { ho.Dispose(); } // atribuir permissões efectivas a todos os utilizadores / grupos com base nas permissões efectivas de cada um ao nivel documental var ops = GisaDataSetHelper.GetInstance().ObjetoDigitalTipoOperation.Cast <GISADataset.ObjetoDigitalTipoOperationRow>().ToList(); var trustees = GisaDataSetHelper.GetInstance().Trustee.Cast <GISADataset.TrusteeRow>().ToList(); Dictionary <string, bool> perm; odRows.ForEach(odRow => { trustees.ForEach(tRow => { if (perms.ContainsKey(tRow.ID) && tRow.ID != trusteeRow.ID) { perm = perms[tRow.ID]; ops.ForEach(opRow => { if (perm.ContainsKey(opRow.TipoOperationRow.Name)) { GisaDataSetHelper.GetInstance().TrusteeObjetoDigitalPrivilege .AddTrusteeObjetoDigitalPrivilegeRow(tRow, odRow, opRow, perm[opRow.TipoOperationRow.Name], new byte[] { }, 0); } }); } }); }); // atribuir permissões totais ao utilizador que está a criar o OD odRows.ForEach(odRow => { ops.ForEach(opRow => { GisaDataSetHelper.GetInstance().TrusteeObjetoDigitalPrivilege .AddTrusteeObjetoDigitalPrivilegeRow(trusteeRow, odRow, opRow, true, new byte[] { }, 0); }); }); }
private void ExecuteFilter() { PersistencyHelper.SaveResult successfulSave = PersistencyHelper.save(); PersistencyHelper.cleanDeletedData(); if (successfulSave == PersistencyHelper.SaveResult.unsuccessful) { return; } else if (successfulSave == PersistencyHelper.SaveResult.successful) { GISA.Search.Updater.updateUnidadeFisica(CurrentNivel.GetFRDBaseRows()[0].NivelRow.ID); } if ((FilterTipoNivelRelacionado == -1) && (TextFilterDesignacao == string.Empty)) { filtered = false; filter.Clear(); GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { ordem = FRDRule.Current.LoadUFUnidadesDescricaoData(GisaDataSetHelper.GetInstance(), CurrentNivel.ID, ho.Connection); detalhes = FRDRule.Current.LoadUFUnidadesDescricaoDetalhe(GisaDataSetHelper.GetInstance(), CurrentNivel.ID, SessionHelper.GetGisaPrincipal().TrusteeUserOperator.ID, ho.Connection); } catch (Exception ex) { Trace.WriteLine(ex); throw; } finally { ho.Dispose(); } } else { filtered = true; filter.Clear(); GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { ordem = FRDRule.Current.LoadUFUnidadesDescricaoData(GisaDataSetHelper.GetInstance(), CurrentNivel.ID, ho.Connection); detalhes = FRDRule.Current.LoadUFUnidadesDescricaoDetalhe(GisaDataSetHelper.GetInstance(), CurrentNivel.ID, SessionHelper.GetGisaPrincipal().TrusteeUserOperator.ID, ho.Connection); filter = FRDRule.Current.FilterUFUnidadesDescricao(TextFilterDesignacao, FilterTipoNivelRelacionado, CurrentNivel.ID, ho.Connection); } catch (Exception ex) { Trace.WriteLine(ex); throw; } finally { ho.Dispose(); } } RepopulateNiveisAssociados(); }
/* * Refresh do painel de apresentacao das metricas de espaco + pieChart */ private void Display_MetrosLineares() { AutoEliminacaoRule.Info_UFs_Larguras ufs = new AutoEliminacaoRule.Info_UFs_Larguras(); // Metros lineares totais: double Metros_lineares_totais = 0.0; this.globalConfigRow = (GISADataset.GlobalConfigRow)(GisaDataSetHelper.GetInstance().GlobalConfig.Rows[0]); if (this.globalConfigRow.IsMetrosLinearesTotaisNull()) { this.txt_metrosLinearesTotais.Text = ""; } else { Metros_lineares_totais = (double)this.globalConfigRow.MetrosLinearesTotais; this.txt_metrosLinearesTotais.Text = Metros_lineares_totais.ToString(); } // Metros lineares ocupados: double Metros_lineares_ocupados = 0.0; GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { // UFS totais: ufs = AutoEliminacaoRule.Current.Get_Info_UFs_Larguras(ho.Connection); Metros_lineares_ocupados = AutoEliminacaoRule.Current.GetMetrosLinearesOcupados(ho.Connection); this.txt_metrosLinearesOcupados.Text = Metros_lineares_ocupados.ToString(); } catch (Exception e) { Debug.WriteLine(e); throw; } finally { ho.Dispose(); } // Metros lineares livres: double Metros_lineares_livres = Metros_lineares_totais - Metros_lineares_ocupados; this.txt_metrosLinearesLivres.Text = Metros_lineares_livres.ToString(); this.lblLivres.ForeColor = (Metros_lineares_livres <= 0.0 ? Color.Red : Color.Black); // Estimativa de ocupacao para ufs sem largura: double Metros_ocupados_estimados = ufs.Media_largura * ufs.TotalUFs_semLargura; if (Metros_lineares_livres > 0 && Metros_lineares_ocupados > 0) { CreateChart(this.zedGraphPieChartControl, Metros_lineares_livres, Metros_lineares_ocupados, Metros_ocupados_estimados); } else { CreateEmptyChart(this.zedGraphPieChartControl); } // UFs totais: this.txt_UFsTotais.Text = ufs.TotalUFs.ToString(); this.txt_UFsSemLargura.Text = ufs.TotalUFs_semLargura.ToString(); }
private void LoadUFRelacionada(long IDNivelUF) { GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { FRDRule.Current.LoadUFRelacionada(GisaDataSetHelper.GetInstance(), CurrentFRDBase.ID, IDNivelUF, ho.Connection); } catch (Exception ex) { Debug.WriteLine(ex); throw; } finally { ho.Dispose(); } }
protected override void EditTrustee() { if (lstVwTrustees.SelectedItems.Count == 0) return; GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { if (TrusteeRule.Current.hasUsers(((GISADataset.TrusteeRow)(lstVwTrustees.SelectedItems[0].Tag)).ID, ho.Connection)) MessageBox.Show("Tenha em conta que o Grupo de Utilizadores a editar já tem Utilizadores associados.", "Utilizador", MessageBoxButtons.OK, MessageBoxIcon.Warning); } catch (Exception ex) { Trace.WriteLine(ex); throw; } finally { ho.Dispose(); } ListViewItem item = null; GISADataset.TrusteeRow truRow = null; item = lstVwTrustees.SelectedItems[0]; truRow = (GISADataset.TrusteeRow)item.Tag; FormCreateTrustee form = new FormCreateTrustee(); form.Text = "Editar grupo de utilizadores"; form.txtTrusteeName.Text = truRow.Name; switch (form.ShowDialog()) { case DialogResult.OK: PersistencyHelper.EditTrusteePreConcArguments etpca = new PersistencyHelper.EditTrusteePreConcArguments(); etpca.truRow = truRow; etpca.username = form.txtTrusteeName.Text; Trace.WriteLine("A editar o grupo de utilizador..."); PersistencyHelper.save(editTrusteeIfUsernameDoesntExist, etpca); PersistencyHelper.cleanDeletedData(); if (! etpca.successful) { MessageBox.Show("Este nome já existe atribuído a um utilizador ou grupo, " + Environment.NewLine + "por favor escolha outro nome.", form.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); UpdateTrustees(null); } else UpdateTrustees(truRow); break; case DialogResult.Cancel: break; } }
public override void LoadData() { try { ((frmMain)TopLevelControl).EnterWaitMode(); GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { GisaDataSetHelper.ManageDatasetConstraints(false); if (!isLoaded) { if (CurrentContext.Deposito == null) { return; } // Recarregar a uf actual e guardar um contexto localmente DepositoRule.Current.LoadDepositoData(GisaDataSetHelper.GetInstance(), CurrentContext.Deposito.ID, ho.Connection); CurrentDeposito = GisaDataSetHelper.GetInstance().Deposito.Cast <GISADataset.DepositoRow>().SingleOrDefault(d => d.ID == CurrentContext.Deposito.ID); if (CurrentDeposito == null || CurrentDeposito.RowState == DataRowState.Detached || CurrentContext.Deposito == null || CurrentContext.Deposito.RowState == DataRowState.Detached) { return; } isLoaded = true; } GisaDataSetHelper.ManageDatasetConstraints(false); GISAPanel selectedPanel = (GISAPanel)this.DropDownTreeView1.SelectedNode.Tag; if (!selectedPanel.IsLoaded) { long startTicks = 0; startTicks = DateTime.Now.Ticks; selectedPanel.LoadData(CurrentDeposito, ho.Connection); Debug.WriteLine("Time dispend loading " + selectedPanel.ToString() + ": " + new TimeSpan(DateTime.Now.Ticks - startTicks).ToString()); } GisaDataSetHelper.ManageDatasetConstraints(true); } catch (System.Data.ConstraintException Ex) { Trace.WriteLine(Ex); GisaDataSetHelper.FixDataSet(GisaDataSetHelper.GetInstance(), ho.Connection); } finally { ho.Dispose(); } } finally { ((frmMain)TopLevelControl).LeaveWaitMode(); } }
protected override void UpdateTrustees(GISADataset.TrusteeRow tRow) { GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { TrusteeRule.Current.LoadTrusteesGrpForUpdate(GisaDataSetHelper.GetInstance(), ho.Connection); } finally { ho.Dispose(); } if (lstVwTrustees.SelectedItems.Count > 0) { lstVwTrustees.clearItemSelection(lstVwTrustees.SelectedItems[0]); } lstVwTrustees.Items.Clear(); ListViewItem item = null; ListViewItem selItem = null; foreach (GISADataset.TrusteeRow t in GisaDataSetHelper.GetInstance().Trustee) { #if TESTING if (t.CatCode == "GRP") { item = lstVwTrustees.Items.Add(""); if (t == tRow) { selItem = item; } UpdateListViewItem(item, t); if (t.BuiltInTrustee) { item.ForeColor = System.Drawing.Color.Gray; } } #else if (t.CatCode == "GRP" && ! t.BuiltInTrustee) { item = lstVwTrustees.Items.Add(""); if (t == tRow) { selItem = item; } UpdateListViewItem(item, t); } #endif } lstVwTrustees.Sort(); if (selItem != null) { lstVwTrustees.EnsureVisible(selItem.Index); lstVwTrustees.selectItem(selItem); } }
protected override void UpdateTrustees(GISADataset.TrusteeRow tRow) { GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection()); try { TrusteeRule.Current.LoadTrusteesUsr(GisaDataSetHelper.GetInstance(), ho.Connection); } catch (Exception ex) { Trace.WriteLine(ex); throw; } finally { ho.Dispose(); } lstVwTrustees.Items.Clear(); ListViewItem item = null; ListViewItem selItem = null; foreach (GISADataset.TrusteeRow t in GisaDataSetHelper.GetInstance().Trustee.Select("isDeleted = 0")) { #if TESTING if (t.CatCode == "USR") { item = lstVwTrustees.Items.Add(""); if (t == tRow) { selItem = item; } UpdateListViewItem(item, t); if (t.BuiltInTrustee) { item.ForeColor = System.Drawing.Color.Gray; } } #else if (t.CatCode == "USR" && ! t.BuiltInTrustee) { item = lstVwTrustees.Items.Add(""); if (t == tRow) { selItem = item; } UpdateListViewItem(item, t); } #endif } lstVwTrustees.Sort(); if (selItem != null) { lstVwTrustees.EnsureVisible(selItem.Index); lstVwTrustees.selectItem(selItem); } }