GetConnection() публичный статический Метод

public static GetConnection ( ) : IDbConnection
Результат IDbConnection
Пример #1
0
		// Assume-se que anteriormente à criação do GisaPrincipal terá já de 
		// existir carregada a licença da aplicação
		public GisaPrincipal(GISADataset.TrusteeUserRow tuRow) : base(new GenericIdentity(tuRow.TrusteeRow.Name), new string[]{})
		{
			IDbConnection conn = GisaDataSetHelper.GetConnection();
			try
			{
				conn.Open();
				// Carregar os grupos a que este utilizador pertence
				TrusteeRule.Current.LoadGroups(GisaDataSetHelper.GetInstance(), tuRow.ID, conn);

				// Estabelecer qual é o utilizador actual. Ao faze-lo são automaticamente calculadas as suas permissões
				TrusteeUserOperator = tuRow;
				if (! TrusteeUserOperator.IsIDTrusteeUserDefaultAuthorityNull())
				{
					TrusteeUserAuthor = TrusteeUserOperator.TrusteeUserRowParent;
				}
			}
			finally
			{
				conn.Close();
			}
		}
Пример #2
0
        public static bool NivelFoiMovimentado(long IDNivel)
        {
            bool foiMov = false;

            GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
            try
            {
                foiMov = MovimentoRule.Current.foiMovimentado(IDNivel, ho.Connection);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.ToString());
                throw;
            }
            finally
            {
                ho.Dispose();
            }

            return(foiMov);
        }
Пример #3
0
        public static string GetConteudoInformacional(GISADataset ds, GISADataset.NivelRow nivelUF)
        {
            var ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());

            try
            {
                DBAbstractDataLayer.DataAccessRules.UFRule.Current.LoadUFConteudoEstruturaData(ds, nivelUF.GetFRDBaseRows()[0].ID, ho.Connection);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
                throw;
            }
            finally
            {
                ho.Dispose();
            }

            var ce = nivelUF.GetFRDBaseRows()[0].GetSFRDConteudoEEstruturaRows().FirstOrDefault();

            return(ce != null ? ce.ConteudoInformacional : "");
        }
Пример #4
0
		public static TrusteeRule.IndexErrorMessages validateUser(string username, string password)
		{
			TrusteeRule.IndexErrorMessages messageCode = 0;
			IDbConnection conn = GisaDataSetHelper.GetConnection();

			try
			{
				conn.Open();

				//validar utilizador
				messageCode = TrusteeRule.Current.validateUser(username, password, conn);
			}
			catch (Exception ex)
			{
				Trace.WriteLine("Register Client Application: " + ex.ToString());
			}
			finally
			{
				conn.Close();
			}

			return messageCode;
		}
Пример #5
0
		//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 void LoadData()
        {
            currentODSimples = new List <ObjDigSimples>();
            docSimplesSemOD  = new List <SubDocumento>();
            var tnrID = currentNivel.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica().First().IDTipoNivelRelacionado;

            // só é considerado válido um contexto definido por um nivel documental
            if (currentNivel.IDTipoNivel != TipoNivel.DOCUMENTAL)
            {
                mContexto = ObjetoDigitalFedoraHelper.Contexto.nenhum;
                return;
            }

            mContexto = IdentifyViewMode(currentNivel);

            GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
            try
            {
                GisaDataSetHelper.ManageDatasetConstraints(false);

                // carregar a informação da bd consuante o tipo nivel selecionado
                if (tnrID == (long)TipoNivelRelacionado.SD)
                {
                    var nUpperRow = currentNivel.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica().Single().NivelRowByNivelRelacaoHierarquicaUpper;
                    DBAbstractDataLayer.DataAccessRules.FedoraRule.Current.LoadObjDigitalData(GisaDataSetHelper.GetInstance(), nUpperRow.ID, nUpperRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica().First().IDTipoNivelRelacionado, ho.Connection);
                }
                else
                {
                    DBAbstractDataLayer.DataAccessRules.FedoraRule.Current.LoadObjDigitalData(GisaDataSetHelper.GetInstance(), currentNivel.ID, tnrID, ho.Connection);
                }

                GisaDataSetHelper.ManageDatasetConstraints(true);
            }
            catch (Exception e)
            {
                // TODO: apanhar a excepção provocada por uma falha com a comunicação com o servidor
                Trace.WriteLine(e);
                throw;
            }
            finally
            {
                ho.Dispose();
            }

            List <string> pidsParaApagar = new List <string>(); // por algum motivo, no repositório, o objeto composto tem na sua estrutura ods simples que já foram apagados

            var frdRow  = currentNivel.GetFRDBaseRows().Single();
            var imgRows = new List <GISADataset.SFRDImagemRow>();

            imgRows.AddRange(frdRow.GetSFRDImagemRows().Where(r => r.Tipo.Equals(FedoraHelper.typeFedora)));

            if (imgRows.Count == 0)
            {
                if (tnrID == (long)TipoNivelRelacionado.SD) // Identificar, caso exista, o OD Composto no documento/processo do subdocumento
                {
                    var nUpperRow = currentNivel.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica().Single().NivelRowByNivelRelacaoHierarquicaUpper;
                    // determinar se o documento/processo tem um OD composto associado
                    var imgRowsUpper = nUpperRow.GetFRDBaseRows().Single().GetSFRDImagemRows().Where(r => r.Tipo.Equals(FedoraHelper.typeFedora)).ToList();

                    if (imgRowsUpper.Count != 1)
                    {
                        return;                          // não existe nenhum OD composto para o OD simples associado ao subdocumento
                    }
                    // o documento/processo tem um OD associado. Determinar se esse OD é composto
                    var odRowUpper = imgRowsUpper[0].GetSFRDImagemObjetoDigitalRows().Single().ObjetoDigitalRow;

                    if (odRowUpper.GetObjetoDigitalRelacaoHierarquicaRowsByObjetoDigitalObjetoDigitalRelacaoHierarquicaUpper().Count() > 0)
                    {
                        // o OD é composto
                        currentODComp = SessionHelper.AppConfiguration.GetCurrentAppconfiguration().FedoraHelperSingleton.LoadID(odRowUpper.pid, null) as ObjDigComposto;
                        currentObjetoDigitalRowComp = odRowUpper;

                        if (currentODComp == null)
                        {
                            return;                        // não se conseguiu obter o OD do servidor...
                        }
                        // clona o próprio e todos os seus simples
                        currentODComp.original = currentODComp.Clone();
                    }
                }
                else if (tnrID == (long)TipoNivelRelacionado.D) // documento/processo sem ODs associados directamente mas com subdocumentos com ODs simples
                {
                    GetSubDocsImgRows(imgRows);
                    GetODRows(imgRows);
                }
            }
            else if (imgRows.Count == 1) // existe 1 OD associado mas não se sabe se é simples ou composto
            {
                var odRow = imgRows[0].GetSFRDImagemObjetoDigitalRows().Single().ObjetoDigitalRow;
                var od    = SessionHelper.AppConfiguration.GetCurrentAppconfiguration().FedoraHelperSingleton.LoadID(odRow.pid, null);

                if (od == null)
                {
                    ObjectNotFound(odRow.pid);
                    return;
                }

                od.publicado = odRow.Publicado;

                if (tnrID == (long)TipoNivelRelacionado.SD) // o OD é garantidamente simples
                {
                    PermissoesHelper.LoadObjDigitalPermissions(currentNivel, SessionHelper.GetGisaPrincipal().TrusteeUserOperator.TrusteeRow);
                    currentObjetoDigitalRow = odRow;
                    currentODSimples        = new List <ObjDigSimples>()
                    {
                        od as ObjDigSimples
                    };

                    var nUpperRow = currentNivel.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica().Single().NivelRowByNivelRelacaoHierarquicaUpper;
                    // determinar se o documento/processo tem um OD composto associado
                    var imgRowsUpper = nUpperRow.GetFRDBaseRows().Single().GetSFRDImagemRows().Where(r => r.Tipo.Equals(FedoraHelper.typeFedora)).ToList();

                    if (imgRowsUpper.Count == 1)
                    {
                        // o documento/processo tem um OD associado. Determinar se esse OD é composto
                        var odRowUpper = imgRowsUpper[0].GetSFRDImagemObjetoDigitalRows().Single().ObjetoDigitalRow;

                        if (odRowUpper.GetObjetoDigitalRelacaoHierarquicaRowsByObjetoDigitalObjetoDigitalRelacaoHierarquicaUpper().Count() > 0)
                        {
                            // o OD é composto
                            currentODComp = SessionHelper.AppConfiguration.GetCurrentAppconfiguration().FedoraHelperSingleton.LoadID(odRowUpper.pid, null) as ObjDigComposto;
                            currentObjetoDigitalRowComp = odRowUpper;

                            if (currentODComp == null)
                            {
                                ObjectNotFound(odRowUpper.pid); return;
                            }                                                                      // não se conseguiu obter o OD do servidor...

                            ((ObjDigSimples)od).parentDocumentTitle = nUpperRow.GetNivelDesignadoRows().Single().Designacao;
                            //currentODComp.publicado = currentObjetoDigitalRowComp.Publicado;
                            currentODComp.objSimples[currentODComp.objSimples.FindIndex(obj => obj.pid == od.pid)] = od as ObjDigSimples;

                            // clona o próprio e todos os seus simples
                            currentODComp.original = currentODComp.Clone();
                        }
                    }
                }
                else if (tnrID == (long)TipoNivelRelacionado.D) // se a UI selecionada for um documento/processo também tem que se ter em conta os OD simples de subdocumentos
                {
                    if (od.GetType() == typeof(ObjDigSimples))
                    {
                        currentObjetoDigitalRow = imgRows.Single().GetSFRDImagemObjetoDigitalRows().Single().ObjetoDigitalRow;
                        GetSubDocsImgRows(imgRows);
                        GetODRows(imgRows);
                    }
                    else
                    {
                        currentODComp = od as ObjDigComposto;
                        currentObjetoDigitalRowComp = odRow;
                        currentODComp.objSimples.ForEach(odSimples =>
                        {
                            var odSimplesRow = GisaDataSetHelper.GetInstance().ObjetoDigital.Cast <GISADataset.ObjetoDigitalRow>().SingleOrDefault(r => r.pid.Equals(odSimples.pid));
                            if (odSimplesRow != null)
                            {
                                odSimples.guiorder  = odSimplesRow.GUIOrder;
                                odSimples.publicado = odSimplesRow.Publicado;
                            }
                            else if (odSimples.serverState == ServerState.Deleted)
                            {
                                pidsParaApagar.Add(odSimples.pid);
                            }
                        });

                        if (pidsParaApagar.Count > 0)
                        {
                            FedoraHelper.FixObjetoDigital(ref currentODComp, pidsParaApagar, frdRow, ref currentObjetoDigitalRowComp, ref currentObjetoDigitalRow);
                        }
                    }
                }
                else
                {
                    if (od.GetType() == typeof(ObjDigSimples))
                    {
                        currentODSimples = new List <ObjDigSimples>()
                        {
                            od as ObjDigSimples
                        };
                        currentObjetoDigitalRow = odRow;
                    }
                    else
                    {
                        currentODComp = od as ObjDigComposto;
                        currentObjetoDigitalRowComp = odRow;
                    }
                }

                od.original = od.Clone();
            }
            else
            {
                // caso onde estão associados vários simples soltos e garantidamente a UI selecionada não é um subdocumento (um subdocumento só pode ter um OD simples associado)
                Trace.Assert(tnrID != (long)TipoNivelRelacionado.SD);
                GetSubDocsImgRows(imgRows);
                GetODRows(imgRows);
            }

            // preencher o estado publicado nos objetos digitais
            if (currentODComp != null)
            {
                var odRow = default(GISADataset.ObjetoDigitalRow);
                currentODComp.objSimples.ToList().ForEach(odSimples =>
                {
                    odRow = GisaDataSetHelper.GetInstance().ObjetoDigital.Cast <GISADataset.ObjetoDigitalRow>().SingleOrDefault(r => r.pid.Equals(odSimples.pid));
                    odSimples.publicado = odRow.Publicado;
                });

                odRow = GisaDataSetHelper.GetInstance().ObjetoDigital.Cast <GISADataset.ObjetoDigitalRow>().Single(r => r.pid.Equals(currentODComp.pid));
                currentODComp.publicado = odRow.Publicado;
            }
            else
            {
                currentODSimples.ToList().ForEach(odSimples =>
                {
                    var odRow           = GisaDataSetHelper.GetInstance().ObjetoDigital.Cast <GISADataset.ObjetoDigitalRow>().Single(r => r.pid.Equals(odSimples.pid));
                    odSimples.publicado = odRow.Publicado;
                });
            }

            // obter documentos simples sem objeto digital para efeitos de ordenação
            GetSubDocsSemODs();
        }
Пример #7
0
		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
		}