예제 #1
0
        public static GISADataset.FRDBaseDataDeDescricaoRow CreateFRDBaseDataDeDescricaoRow(GISADataset.FRDBaseRow CurrentFRDBase, GISADataset.TrusteeUserRow tuOperator, GISADataset.TrusteeUserRow tuAuthor, DateTime data, long IDTipoNivelRelacionado, bool isImportacao)
        {
            GISADataset.FRDBaseDataDeDescricaoRow dddRow = null;
            dddRow = GisaDataSetHelper.GetInstance().FRDBaseDataDeDescricao.NewFRDBaseDataDeDescricaoRow();
            if (CurrentFRDBase.ID <= 0)
            {
                throw new Exception(string.Format("Identificador negativo ({0}) no registo de frds!!", CurrentFRDBase.ID));
            }
            dddRow.IDFRDBase = CurrentFRDBase.ID;
            dddRow.TrusteeUserRowByTrusteeUserFRDBaseDataDeDescricao          = tuOperator;
            dddRow.TrusteeUserRowByTrusteeUserFRDBaseDataDeDescricaoAuthority = tuAuthor;
            dddRow.DataEdicao = GISA.Utils.GUIHelper.getTruncatedCurrentDate();
            if (data == DateTime.MinValue)
            {
                dddRow["DataAutoria"] = DBNull.Value;
            }
            else
            {
                dddRow.DataAutoria = data;
            }
            dddRow.IDTipoNivelRelacionado = IDTipoNivelRelacionado > 0 ? IDTipoNivelRelacionado : CurrentFRDBase.NivelRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica()[0].IDTipoNivelRelacionado;
            dddRow.Importacao             = isImportacao;
            dddRow.Versao    = new byte[] { };
            dddRow.isDeleted = 0;

            return(dddRow);
        }
예제 #2
0
        public static void ConfigureMenu(GISADataset CurrentDataSet, GISADataset.TipoNivelRelacionadoRow CurrentRow, ref ToolBarButton Button, EventHandler CurrentHandler, bool DocumentView)
        {
            ImageList ImgList = GetImageList();

            Menu.MenuItemCollection CurrentMenu = Button.DropDownMenu.MenuItems;

            foreach (GISADataset.TipoNivelRelacionadoRow subtnrRow in GetSubTipoNivelRelacionado(CurrentDataSet, CurrentRow))
            {
                // An option to create a certain type of nivel is shown if:
                // we are in the Strutcture view and we are providing options to create new structure items
                // *OR*
                // we are in Documents view and we are providing options to create new document items
                if ((!DocumentView && !(subtnrRow.TipoNivelRow.IsDocument ^ CurrentRow.TipoNivelRow.IsDocument)) || (DocumentView & CurrentRow.TipoNivelRow.IsDocument))
                {
                    // Adicionar opção de criação apenas para os tipos de nivelRelacionado que não sejam níveis orgânicos
                    if (!(GisaDataSetHelper.GetInstance().GlobalConfig[0].NiveisOrganicos && subtnrRow.IDTipoNivel == TipoNivel.ESTRUTURAL && CurrentRow.IDTipoNivel == TipoNivel.ESTRUTURAL))
                    {
                        AddMenuOption(CurrentMenu, CurrentRow, subtnrRow, CurrentHandler, ImgList);
                    }
                }
                else if (DocumentView)
                {
                    //Dim pxmi As PXMenuItem = New TipoNivelMenuItem("Criar" + subtnRow.Designacao, subtnRow, ImgList)
                    //Dim mi As MenuItem = DirectCast(pxmi, MenuItem)
                    if (subtnrRow.TipoNivelRow.IsDocument)
                    {
                        //If Not CurrentHandler Is Nothing Then AddHandler mi.Click, CurrentHandler
                        AddMenuOption(CurrentMenu, CurrentRow, subtnrRow, CurrentHandler, ImgList);
                    }
                }
            }
        }
예제 #3
0
        public static void verificaCodigosRepetidos(PersistencyHelper.PreConcArguments args)
        {
            var pcArgs = (PersistencyHelper.EnsureUniqueCodigoNivelPreConcArguments)args;
            var rhRow  = GisaDataSetHelper.GetInstance().RelacaoHierarquica.Cast <GISADataset.RelacaoHierarquicaRow>().SingleOrDefault(r => r.RowState != DataRowState.Deleted && r.ID == pcArgs.rhRowID && r.IDUpper == pcArgs.rhRowIDUpper);

            if (rhRow != null)
            {
                var codigo = rhRow.NivelRowByNivelRelacaoHierarquica.Codigo;
                var ID     = DBAbstractDataLayer.DataAccessRules.NivelRule.Current.GetIDCodigoRepetido(codigo, rhRow.ID, pcArgs.tran, pcArgs.testOnlyWithinNivel, rhRow.NivelRowByNivelRelacaoHierarquicaUpper.ID);

                if (ID > long.MinValue)
                {
                    // erro
                    pcArgs.message = string.Format(
                        "Não foi possível completar a operação uma vez que" + Environment.NewLine +
                        "por debaixo da entidade produtora selecionada" + Environment.NewLine +
                        "o código parcial '{0}' já é utilizado pela unidade " + Environment.NewLine +
                        "informacional com o identificador {1}.", codigo, rhRow.ID);

                    var tempgisaBackup3 = pcArgs.gisaBackup;
                    PersistencyHelper.BackupRow(ref tempgisaBackup3, rhRow);
                    pcArgs.gisaBackup = tempgisaBackup3;
                    rhRow.RejectChanges();
                }
                else
                {
                    pcArgs.successful = true;
                }
            }
        }
예제 #4
0
        public static GISADataset.RelacaoHierarquicaRow GetPrimeiraRelacaoEncontrada(GISADataset.NivelRow nivelRow)
        {
            GISADataset.RelacaoHierarquicaRow[] rhRows = null;
            GISADataset.RelacaoHierarquicaRow   rhRow  = null;
            try
            {
                rhRows = nivelRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica();
                if (rhRows.Length > 0)
                {
                    return(rhRows[0]);
                }

                rhRows = Nivel.GetSelf(GisaDataSetHelper.GetInstance(), nivelRow);
                if (rhRows.Length == 0)
                {
                    return(null);
                }

                rhRow = rhRows[0];
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
                throw;
            }
            return(rhRow);
        }
예제 #5
0
파일: Nivel.cs 프로젝트: huguitosilva1/gisa
		public void SetUp()
		{
			ds = new GISADataset();
			ds.Merge(GisaDataSetHelper.GetInstance());

			r1 = ds.Nivel.NewNivelRow();
			r1.IDTipoNivel = 1;
			r1.Codigo = "Teste";

			r2 = ds.Nivel.NewNivelRow();
			r2.IDTipoNivel = 2;
			r2.Codigo = "Teste";

			r3 = ds.RelacaoHierarquica.NewRelacaoHierarquicaRow();
			r3.ID = r2.ID;
			r3.IDUpper = r1.ID;

			ds.Nivel.Rows.Add(r1);
			ds.Nivel.Rows.Add(r2);
			ds.RelacaoHierarquica.Rows.Add(r3);

			GISADataset.NivelDesignadoRow r4 = ds.NivelDesignado.NewNivelDesignadoRow();
			r4.ID = r1.ID;
			r4.Designacao = "Designacao";
			ds.NivelDesignado.AddNivelDesignadoRow(r4);
		}
예제 #6
0
        public static void SetCodigo(PersistencyHelper.PreSaveArguments args)
        {
            PersistencyHelper.IsCodigoUFBeingUsedPreSaveArguments psa = null;
            psa = (PersistencyHelper.IsCodigoUFBeingUsedPreSaveArguments)args;
            GISADataset.NivelUnidadeFisicaCodigoRow codRow = null;

            // a atribuição de um código de referência ocorre quando se cria uma
            // UF nova ou se está a mudar a ED de uma UF e é atribuído só se não houver
            // qualquer conflito de concorrência
            if (!psa.cancelSetNewCodigo)
            {
                GISADataset.NivelRow nivelUFRow = (GISADataset.NivelRow)(GisaDataSetHelper.GetInstance().Nivel.Select("ID=" + psa.nivelUFRowID.ToString())[0]);
                codRow = UnidadesFisicasHelper.GetNewCodigoRow(nivelUFRow, System.DateTime.Now.Year);
                decimal newCounterValue = DBAbstractDataLayer.DataAccessRules.UFRule.Current.IsCodigoUFBeingUsed(codRow.ID, codRow.Ano, psa.tran);
                if (newCounterValue != 0M)
                {
                    nivelUFRow.Codigo = "UF" + codRow.Ano.ToString() + "-" + newCounterValue.ToString();
                }
                else
                {
                    nivelUFRow.Codigo = "UF" + codRow.Ano.ToString() + "-" + codRow.Contador.ToString();
                }

                //quer tenha sido adicionada uma entrada na tabela NivelUnidadeFisicaCodigo quer so tenha sido actualizado
                //o contador de uma das linhas, essa operação foi executada directamente na base de dados pelo que para
                //manter a coerência é necessário confirmar a mesma operação do lado do dataset
                codRow.AcceptChanges();
                DBAbstractDataLayer.DataAccessRules.UFRule.Current.ReloadNivelUFCodigo(GisaDataSetHelper.GetInstance(), codRow.ID, codRow.Ano, psa.tran);
            }
        }
예제 #7
0
 public static GISADataset.ControloAutDataDeDescricaoRow CreateControlAutDataDeDescricaoRow(GISADataset.ControloAutRow CurrentControloAut, GISADataset.TrusteeUserRow tuOperator, GISADataset.TrusteeUserRow tuAuthor, DateTime data, bool isImportacao)
 {
     GISADataset.ControloAutDataDeDescricaoRow cadddRow = null;
     cadddRow = GisaDataSetHelper.GetInstance().ControloAutDataDeDescricao.NewControloAutDataDeDescricaoRow();
     cadddRow.IDControloAut = CurrentControloAut.ID;
     if (CurrentControloAut.ID <= 0)
     {
         throw new Exception(string.Format("Identificador negativo ({0}) no registo de cas!!", CurrentControloAut.ID));
     }
     cadddRow.TrusteeUserRowByTrusteeUserControloAutDataDeDescricao          = tuOperator;
     cadddRow.TrusteeUserRowByTrusteeUserControloAutDataDeDescricaoAuthority = tuAuthor;
     cadddRow.DataEdicao = GISA.Utils.GUIHelper.getTruncatedCurrentDate();
     if (data == DateTime.MinValue)
     {
         cadddRow["DataAutoria"] = DBNull.Value;
     }
     else
     {
         cadddRow.DataAutoria = data;
     }
     cadddRow.IDTipoNoticiaAut = CurrentControloAut.IDTipoNoticiaAut;
     cadddRow.Importacao       = isImportacao;
     cadddRow.Versao           = new byte[] { };
     cadddRow.isDeleted        = 0;
     return(cadddRow);
 }
예제 #8
0
        public static void RegisterRecordModificationFRD(GISADataset.FRDBaseRow CurrentFRDBase, bool existsModifiedDataFromRels, GISADataset.TrusteeUserRow tuOperator, GISADataset.TrusteeUserRow tuAuthor, DateTime data)
        {
            // só é registada uma nova entrada no controlo de descrição se alguma informação relativa à FRD
            // tiver sido modificada; é também possível que já tenha sido registado uma nova entrada no controlo mas
            // nesse caso não se adiciona outra
            if (CurrentFRDBase == null || CurrentFRDBase.RowState == DataRowState.Detached ||
                GisaDataSetHelper.GetInstance().FRDBaseDataDeDescricao.Select("IDFRDBase=" + CurrentFRDBase.ID.ToString(), "", DataViewRowState.Added).Length > 0)
            {
                return;
            }

            GISADataset.NivelUnidadeFisicaRow[] NivelUnidadeFisicaRows = new GISADataset.NivelUnidadeFisicaRow[] {};
            if (CurrentFRDBase.NivelRow.IDTipoNivel == TipoNivel.OUTRO)
            {
                NivelUnidadeFisicaRows = CurrentFRDBase.NivelRow.GetNivelDesignadoRows()[0].GetNivelUnidadeFisicaRows();
            }

            if (existsModifiedDataFromRels ||
                CurrentFRDBase.RowState != DataRowState.Unchanged ||
                Concorrencia.WasRecordModified(CurrentFRDBase) ||
                Concorrencia.WasRecordModified(CurrentFRDBase.NivelRow) ||
                (NivelUnidadeFisicaRows.Length > 0 && Concorrencia.isModifiedRow(NivelUnidadeFisicaRows[0])))
            {
                var dddRow = CreateFRDBaseDataDeDescricaoRow(CurrentFRDBase, tuOperator, tuAuthor, data);
                GisaDataSetHelper.GetInstance().FRDBaseDataDeDescricao.AddFRDBaseDataDeDescricaoRow(dddRow);
            }
        }
예제 #9
0
        public static bool IsNivelEntidadeDetentora(GISADataset.NivelRow nRow)
        {
            if (Nivel.GetSelf(GisaDataSetHelper.GetInstance(), nRow).Length == 0)
            {
                return(true);
            }

            return(false);
        }
예제 #10
0
 public static void RecordEstatisticaPesquisa(long id, string catCode) {
     try {
         using (var ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection())) {
             using (var tr = ho.Connection.BeginTransaction(IsolationLevel.Serializable)) {
                 using (var cmd = ho.Connection.CreateCommand()) {
                     cmd.Connection = ho.Connection;
                     cmd.Transaction = tr;
                     cmd.CommandText = "insert into EstatisticaPesquisa (ID, CatCode, UserID, AccessDateTime, AccessMethod, IPAddress) values (@ID, @CatCode, @UserID, @AccessDateTime, @AccessMethod, @IPAddress)";
                     cmd.CommandType = CommandType.Text;
                     var idParam = cmd.CreateParameter();
                     idParam.DbType = DbType.Int64;
                     idParam.ParameterName = "@ID";
                     idParam.Value = id;
                     var catCodeParam = cmd.CreateParameter();
                     catCodeParam.DbType = DbType.StringFixedLength;
                     catCodeParam.Size = 2;
                     catCodeParam.ParameterName = "@CatCode";
                     catCodeParam.Value = catCode;
                     var userIDParam = cmd.CreateParameter();
                     userIDParam.DbType = DbType.Int64;
                     userIDParam.ParameterName = "@UserID";
                     userIDParam.Value = (System.Threading.Thread.CurrentPrincipal as GisaPrincipal).TrusteeUserOperator.ID;
                     var accessDateTimeParam = cmd.CreateParameter();
                     accessDateTimeParam.DbType = DbType.DateTime;
                     accessDateTimeParam.ParameterName = "@AccessDateTime";
                     accessDateTimeParam.Value = DateTime.UtcNow;
                     var accessMethodParam = cmd.CreateParameter();
                     accessMethodParam.DbType = DbType.StringFixedLength;
                     accessMethodParam.Size = 1;
                     accessMethodParam.Value = "D";
                     accessMethodParam.ParameterName = "@AccessMethod";
                     var ipAddressParam = cmd.CreateParameter();
                     ipAddressParam.DbType = DbType.String;
                     ipAddressParam.Size = -1;
                     ipAddressParam.Value = Environment.MachineName;
                     ipAddressParam.ParameterName = "@IPAddress";
                     (ipAddressParam as System.Data.Common.DbParameter).IsNullable = false;
                     cmd.Parameters.Add(idParam);
                     cmd.Parameters.Add(catCodeParam);
                     cmd.Parameters.Add(userIDParam);
                     cmd.Parameters.Add(accessDateTimeParam);
                     cmd.Parameters.Add(accessMethodParam);
                     cmd.Parameters.Add(ipAddressParam);
                     cmd.ExecuteNonQuery();
                     cmd.CommandText = "EstatisticaPesquisaSimplificar";
                     cmd.CommandType = CommandType.StoredProcedure;
                     cmd.Parameters.Clear();
                     cmd.ExecuteNonQuery();
                     tr.Commit();
                 }
             }
         }
     } catch (Exception ex) {
         System.Diagnostics.Debug.WriteLine(ex);
     }
 }
        private void CreateDatabaseObjDigSimplesSolto(ObjDigSimples odSimples)
        {
            Debug.Assert(odSimples.guiorder > 0);
            var odRow = GisaDataSetHelper.GetInstance().ObjetoDigital.AddObjetoDigitalRow(odSimples.pid, odSimples.titulo, odSimples.publicado, odSimples.guiorder, new byte[] { }, 0);

            //PermissoesHelper.AddNewObjDigGrantPermissions(odRow, currentNivel);

            FedoraHelper.RelateODtoUI(odSimples, odRow, currentNivel.GetFRDBaseRows().Single());

            newObjects.Add(odRow, odSimples);
        }
        private static void UpdateNvlDocSimplesOrderNr(ObjDigSimples odSimples)
        {
            if (odSimples.gisa_id != null && odSimples.gisa_id.Length > 0)
            {
                var nds = GisaDataSetHelper.GetInstance().NivelDocumentoSimples.Cast <GISADataset.NivelDocumentoSimplesRow>().SingleOrDefault(r => r.RowState != DataRowState.Deleted && r.ID == FedoraHelper.GetGisaID(odSimples.gisa_id));

                if (nds != null)
                {
                    nds.GUIOrder = odSimples.guiorder;
                }
            }
        }
예제 #13
0
 public static string GenerateNewCodigoString(GISADataset.NivelRow nivelEDRow, int ano)
 {
     DataRow[] DataRows = GisaDataSetHelper.GetInstance().NivelUnidadeFisicaCodigo.Select("ID=" + nivelEDRow.ID.ToString() + " AND Ano=" + System.DateTime.Now.Year.ToString());
     if (DataRows.Length == 0)
     {
         return("UF" + DateTime.Now.Year.ToString() + "-" + 1.ToString());
     }
     else
     {
         return("UF" + DateTime.Now.Year.ToString() + "-" + (((GISADataset.NivelUnidadeFisicaCodigoRow)(DataRows[0])).Contador + 1).ToString());
     }
 }
예제 #14
0
파일: Nivel.cs 프로젝트: huguitosilva1/gisa
		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();
		}
예제 #15
0
        public static PersistencyHelper.SetNewNivelOrderPreSaveArguments AddNivelDocumentoSimplesWithDelegateArgs(GISADataset.NivelDesignadoRow ndRow, long IDUpper, long IDTipoNivelRelacionado)
        {
            if (IDTipoNivelRelacionado != TipoNivelRelacionado.SD)
            {
                return(null);
            }
            var psArgsNivelDocSimples = new PersistencyHelper.SetNewNivelOrderPreSaveArguments();

            GisaDataSetHelper.GetInstance().NivelDocumentoSimples.AddNivelDocumentoSimplesRow(ndRow, -1, new byte[] { }, 0);
            psArgsNivelDocSimples.nRowID      = ndRow.ID;
            psArgsNivelDocSimples.nRowIDUpper = IDUpper;
            return(psArgsNivelDocSimples);
        }
예제 #16
0
		public static GISADataset GetInstance()
		{
			if (mDataSet == null)
			{
				mDataSet = new GISADataset();

	#if DEBUG
				mDataSet.EnforceConstraints = false;
	#else
				mDataSet.EnforceConstraints = false;
	#endif

				//' This ensures that autonumber fields do not clash with database information
				foreach (DataTable t in mDataSet.Tables)
				{
					foreach (DataColumn c in t.Columns)
					{
						if (c.AutoIncrement)
						{
							c.AutoIncrementSeed = -1;
							c.AutoIncrementStep = -1;
						}
					}
				}

				// Carregar ficheiros xml embebidos no Gisa.Model contendo o meta model
				Assembly metaModelAssembly = Assembly.GetAssembly(typeof(MetaModelHelper));
				MetaModelHelper.MetaModel = new System.Xml.XmlDocument();
				MetaModelHelper.MetaModel.Load(metaModelAssembly.GetManifestResourceStream(metaModelAssembly.GetName().Name + ".MetaModel.GISADataset.xml"));
                MetaModelHelper.DataTypesDictionary = new System.Xml.XmlDocument();
                MetaModelHelper.DataTypesDictionary.Load(metaModelAssembly.GetManifestResourceStream(metaModelAssembly.GetName().Name + ".MetaModel.DataTypesDictionary.xml"));
                DBAbstractDataLayer.DataAccessRules.DALRule.MetaModel = new MetaModelHelper();

				IDbConnection conn = GisaDataSetHelper.GetConnection();
				try
				{
					conn.Open();
					GisaDataSetHelperRule.Current.LoadStaticDataTables(mDataSet, conn);
				} catch (System.SystemException ex)
				{
					// tratar as excepções de acesso à base de dados mantendo o dataset a null
					mDataSet = null;
					Trace.WriteLine(ex);
				}
				finally
				{
					conn.Close();
				}
			}
			return mDataSet;
		}
예제 #17
0
 public static void SetOrdemDocSimples(long ID, long IDUpper, IDbTransaction tran)
 {
     try
     {
         var nextGUIOrder = DBAbstractDataLayer.DataAccessRules.NivelRule.Current.GetDocNextGUIOrder(IDUpper, tran);
         var ndsRow       = GisaDataSetHelper.GetInstance().NivelDocumentoSimples.Cast <GISADataset.NivelDocumentoSimplesRow>().Single(r => r.ID == ID);
         ndsRow.GUIOrder = nextGUIOrder;
     }
     catch (Exception ex)
     {
         Trace.WriteLine(ex);
         throw;
     }
 }
예제 #18
0
        public static ArrayList GetPossibleSubItems(GISADataset.NivelRow nRow)         //PossibleSubNivel()
        {
            //ToDo()
            // Obter os TipoNivelRelacionados das RelacaoHierarquicas das EPs superiores. Para cada TiponivelRelacionado devolver também o intervalo da relação associada.
            // espandir os TipoNivelRelacionados permitidos como subníveis para cada um dos TipoNivelRelacionados encontrados anteriormente. Para cada um dos tipos de subnivel guardar o intervalo de data em que ele faz sentido

            ArrayList subNiveis = new ArrayList();

            GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
            try
            {
                Trace.WriteLine("<getPossibleSubTypesOf>");

                IDataReader dataReader = null;
                dataReader = TipoNivelRule.Current.GetPossibleSubItems(nRow.ID, ho.Connection);

                Trace.WriteLine("<getPossibleSubTypesOf/>");

                while (dataReader.Read())
                {
                    PossibleSubNivel subNivel = new PossibleSubNivel();
                    subNivel.SubIDTipoNivelRelacionado = System.Convert.ToInt64(dataReader.GetValue(0));
                    subNivel.Designacao = GisaDataSetHelper.GetDBNullableText(ref dataReader, 1);
                    subNivel.InicioAno  = GisaDataSetHelper.GetDBNullableText(ref dataReader, 2);
                    subNivel.InicioMes  = GisaDataSetHelper.GetDBNullableText(ref dataReader, 3);
                    subNivel.InicioDia  = GisaDataSetHelper.GetDBNullableText(ref dataReader, 4);
                    subNivel.FimAno     = GisaDataSetHelper.GetDBNullableText(ref dataReader, 5);
                    subNivel.FimMes     = GisaDataSetHelper.GetDBNullableText(ref dataReader, 6);
                    subNivel.FimDia     = GisaDataSetHelper.GetDBNullableText(ref dataReader, 7);
                    subNiveis.Add(subNivel);
                }
                dataReader.Close();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
                throw ex;
            }
            finally
            {
                ho.Dispose();
            }

            // não são encontrados subniveis organicos possiveis se não existirem
            if (subNiveis.Count == 0)
            {
            }

            return(subNiveis);
        }
예제 #19
0
 public static string getNextSeriesCodigo(bool incrementIt)
 {
     GISADataset.TipoNivelRelacionadoCodigoRow tnrcRow = null;
     tnrcRow = (GISADataset.TipoNivelRelacionadoCodigoRow)(GisaDataSetHelper.GetInstance().TipoNivelRelacionadoCodigo.Select()[0]);
     if (incrementIt)
     {
         tnrcRow.Contador += 1;
         return(tnrcRow.Contador.ToString("0"));
     }
     else
     {
         return((tnrcRow.Contador + 1).ToString("0"));
     }
 }
예제 #20
0
		public void RecalculatePrivileges(GISADataset.TipoServerRow tsRow, List<GISADataset.ModulesRow> modulesList, IDbTransaction Trans)
		{
			mTrusteePrivileges = (GISADataset.TrusteePrivilegeDataTable)(GisaDataSetHelper.GetInstance().TrusteePrivilege.Clone());

            string modules = string.Empty;
            foreach (GISADataset.ModulesRow mRow in modulesList)
            {
                modules += mRow.ID + ",";
            }
            modules = modules.TrimEnd(',');

			// This resolves user privileges and his groups.
			// Does not handle groups of groups. These are not supported by DB
			IDbConnection conn = GisaDataSetHelper.GetConnection();
			if (Trans == null && ! (conn.State == ConnectionState.Open))
			{
				try
				{
					conn.Open();
					TrusteeRule.Current.LoadTrusteePrivilegeData(mTrusteePrivileges, tsRow.BuiltInName, modules, TrusteeUserOperator.ID, conn, Trans);
				}
				catch (Exception ex)
				{
					Trace.WriteLine(ex);
				}
				finally
				{
					conn.Close();
				}
			}
			else if (Trans == null && conn.State == ConnectionState.Open)
			{
				try
				{
					TrusteeRule.Current.LoadTrusteePrivilegeData(mTrusteePrivileges, tsRow.BuiltInName, modules, TrusteeUserOperator.ID, conn, Trans);
				}
				catch (Exception ex)
				{
					Trace.WriteLine(ex);
				}
			}
			else
			{
				TrusteeRule.Current.LoadTrusteePrivilegeData(mTrusteePrivileges, tsRow.BuiltInName, modules, TrusteeUserOperator.ID, conn, Trans);
			}

			// Keep our copy of this data and merge it with the dataset
			GisaDataSetHelper.GetInstance().Merge(mTrusteePrivileges);

		}
예제 #21
0
		public bool CanPerform(TipoFunctionGroup TheTipoFunctionGroup, TipoFunction TheTipoFunction, TipoOperation TheTipoOperation)
		{
			try
			{
				DataRow[] dr = GisaDataSetHelper.GetInstance().TrusteePrivilege.Select(string.Format("IDTrustee={0} AND IDTipoFunctionGroup={1} AND IdxTipoFunction={2} AND IDTipoOperation={3}", this.TrusteeUserOperator.ID, TheTipoFunctionGroup, TheTipoFunction, TheTipoOperation), "");
				return dr.Length > 0 && ((GISADataset.TrusteePrivilegeRow)(dr.GetValue(0))).IsGrant;
			}
			catch (Exception ex)
			{
				Trace.WriteLine("IGisaPrincipal.CanPerform");
				Trace.WriteLine(ex);
				throw ex;
			}
		}
        private void CreateDatabaseObjDigSimples(ObjDigComposto odComp, GISADataset.ObjetoDigitalRow odRowComp, ObjDigSimples odSimples)
        {
            Debug.Assert(odComp != null);
            Debug.Assert(odSimples != null);
            Debug.Assert(odRowComp != null && odRowComp.RowState != DataRowState.Deleted);

            var orderNr = odComp.objSimples.IndexOf(odSimples);
            var odRow   = GisaDataSetHelper.GetInstance().ObjetoDigital.AddObjetoDigitalRow(odSimples.pid, odSimples.titulo, odSimples.publicado, (orderNr + 1), new byte[] { }, 0);


            GisaDataSetHelper.GetInstance().ObjetoDigitalRelacaoHierarquica.AddObjetoDigitalRelacaoHierarquicaRow(odRow, odRowComp, new byte[] { }, 0);
            //PermissoesHelper.AddNewObjDigGrantPermissions(odRow, currentNivel);

            newObjects.Add(odRow, odSimples);
        }
예제 #23
0
		public void Demand()
		{
			Report("{0}.Demand()", this.GetType().FullName);
			bool grantedOp = false;
			bool foundPermission = false;
			string failedOperation = null;

			// TODO: o código seguinte está errado. é preciso verificar 1º se o próprio utilizador tem permissões. caso não tenha permissões definidas a esse nível é então necessário verificar se ha permissões ao nivel dos seus grupos.
			//mPrincipal.TrusteeUserOperator

			GISADataset.TrusteePrivilegeRow[] groupPrivilegeRows = null;
			GISADataset.TrusteePrivilegeRow[] userPrivilegeRows = null;

			// tentar primeiro encontrar uma permissão definida directamente sobre o utilizador
			// uma vez que esta se sobreporá a qualquer uma que possa existir sobre os seus grupos
			string userFilter = null;
			userFilter = string.Format("IDTrustee = {0}", mPrincipal.TrusteeUserOperator.ID);
			userPrivilegeRows = (GISADataset.TrusteePrivilegeRow[])(GisaDataSetHelper.GetInstance().TrusteePrivilege.Select(userFilter));
			getPermissionFor(userPrivilegeRows, mClassName, mOperations, ref foundPermission, ref grantedOp, ref failedOperation);

			// só se torna necessário verificar se existem permissões de utilização
			// sobre os grupos deste utilizador se não tiver ainda sido encontrada 
			// nenhuma permissão sobre o próprio utilizador
			if (! foundPermission)
			{
				System.Text.StringBuilder groupFilterBuilder = new System.Text.StringBuilder();
				foreach (GISADataset.UserGroupsRow ugRow in mPrincipal.TrusteeUserOperator.GetUserGroupsRows())
				{
					if (groupFilterBuilder.Length > 0)
					{
						groupFilterBuilder.Append(" OR ");
					}
					groupFilterBuilder.Append(string.Format("IDTrustee={0}", ugRow.TrusteeGroupRow.ID));
				}
				groupPrivilegeRows = (GISADataset.TrusteePrivilegeRow[])(GisaDataSetHelper.GetInstance().TrusteePrivilege.Select(groupFilterBuilder.ToString()));
				getPermissionFor(groupPrivilegeRows, mClassName, mOperations, ref foundPermission, ref grantedOp, ref failedOperation);
			}

			if (! foundPermission)
			{
				throw new SecurityException("Sorry, user does not have permissions for this function. Failed on: " + mClassName + "." + mOperations.ToString(), this.GetType());
			}

			if (! grantedOp)
			{
				throw new SecurityException("Sorry, user does not have granted permissions for this function. Failed on: " + mClassName + "." + failedOperation, this.GetType());
			}
		}
예제 #24
0
파일: Nivel.cs 프로젝트: huguitosilva1/gisa
        public static bool HasTipologiaChanged(GISADataset.FRDBaseRow frdRow, out string newTip)
        {
            newTip = string.Empty;
            var newTipRow = frdRow.GetIndexFRDCARows().SingleOrDefault(r => r.RowState == DataRowState.Added && r["Selector"] != DBNull.Value && r.Selector == -1);
            if (newTipRow != null)
            {
                newTip = newTipRow.ControloAutRow.GetControloAutDicionarioRows().Single(r => r.IDTipoControloAutForma == (long)TipoControloAutForma.FormaAutorizada).DicionarioRow.Termo;
                return true;
            }
            

            var remTipRow = GisaDataSetHelper.GetInstance().IndexFRDCA.Cast<GISADataset.IndexFRDCARow>().SingleOrDefault(r => r.RowState == DataRowState.Deleted && System.Convert.ToInt64(r["IDFRDBase", DataRowVersion.Original]) == frdRow.ID && r["Selector", DataRowVersion.Original] != DBNull.Value && System.Convert.ToInt64(r["Selector", DataRowVersion.Original]) == -1);
            if (remTipRow != null) { newTip = null; return true; }

            return false;
        }
예제 #25
0
        public static List <CAAssociado> GetRelatedControloAut(List <GISADataset.ControloAutDicionarioRow> cadRows)
        {
            var res = new List <CAAssociado>();
            var ho  = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());

            try
            {
                var start = DateTime.Now.Ticks;
                res = DiplomaModeloRule.Current.GetCANiveisAssociados(cadRows.Select(r => r.IDControloAut).ToList(), ho.Connection);
                Trace.WriteLine("<<LoadNivelDesignadoOfSelfAndParent>>: " + new TimeSpan(DateTime.Now.Ticks - start).ToString());
            }
            catch (Exception ex) { Debug.WriteLine(ex); throw ex; }
            finally { ho.Dispose(); }

            return(res);
        }
예제 #26
0
		//metodo que tem como objectivo criar dois arraylists onde mantem a lista de tabelas relaccionadas com 
		//as tabelas ControloAut e FRDBase
		private void calculaNuvens()
		{
//INSTANT C# NOTE: The ending condition of VB 'For' loops is tested only on entry to the loop. Instant C# has created a temporary variable in order to use the initial value of GisaDataSetHelper.GetInstance().Tables("ControloAut").ChildRelations.Count for every iteration:
			int tempFor1 = GisaDataSetHelper.GetInstance().Tables["ControloAut"].ChildRelations.Count;
			for (int i = 0; i < tempFor1; i++)
			{
				if (GisaDataSetHelper.GetInstance().Tables["ControloAut"].ChildRelations[i].ChildTable.ChildRelations.Count > 0)
				{
					calculaNuvens(GisaDataSetHelper.GetInstance().Tables["ControloAut"].ChildRelations[i].ChildTable, TableCloudType.CA);
				}
				if (! (nuvemCA.Contains(GisaDataSetHelper.GetInstance().Tables["ControloAut"].ChildRelations[i].ChildTable.TableName)))
				{
					nuvemCA.Add(GisaDataSetHelper.GetInstance().Tables["ControloAut"].ChildRelations[i].ChildTable.TableName);
				}
			}
			nuvemCA.Add("ControloAut");

//INSTANT C# NOTE: The ending condition of VB 'For' loops is tested only on entry to the loop. Instant C# has created a temporary variable in order to use the initial value of GisaDataSetHelper.GetInstance().Tables("FRDBase").ChildRelations.Count for every iteration:
			int tempFor2 = GisaDataSetHelper.GetInstance().Tables["FRDBase"].ChildRelations.Count;
			for (int j = 0; j < tempFor2; j++)
			{
				if (GisaDataSetHelper.GetInstance().Tables["FRDBase"].ChildRelations[j].ChildTable.ChildRelations.Count > 0)
				{
					calculaNuvens(GisaDataSetHelper.GetInstance().Tables["FRDBase"].ChildRelations[j].ChildTable, TableCloudType.FRD);
				}
				if (! (nuvemFRD.Contains(GisaDataSetHelper.GetInstance().Tables["FRDBase"].ChildRelations[j].ChildTable.TableName)))
				{
					nuvemFRD.Add(GisaDataSetHelper.GetInstance().Tables["FRDBase"].ChildRelations[j].ChildTable.TableName);
				}
			}
			nuvemFRD.Add("FRDBase");

//INSTANT C# NOTE: The ending condition of VB 'For' loops is tested only on entry to the loop. Instant C# has created a temporary variable in order to use the initial value of GisaDataSetHelper.GetInstance().Tables("FRDBase").ChildRelations.Count for every iteration:
			int tempFor3 = GisaDataSetHelper.GetInstance().Tables["Nivel"].ChildRelations.Count;
			for (int j = 0; j < tempFor3; j++)
			{
				if (GisaDataSetHelper.GetInstance().Tables["Nivel"].ChildRelations[j].ChildTable.ChildRelations.Count > 0)
				{
					calculaNuvens(GisaDataSetHelper.GetInstance().Tables["Nivel"].ChildRelations[j].ChildTable, TableCloudType.NVL);
				}
				if (! (nuvemNVL.Contains(GisaDataSetHelper.GetInstance().Tables["Nivel"].ChildRelations[j].ChildTable.TableName)))
				{
					nuvemNVL.Add(GisaDataSetHelper.GetInstance().Tables["Nivel"].ChildRelations[j].ChildTable.TableName);
				}
			}
			nuvemNVL.Add("Nivel");
		}
예제 #27
0
파일: Nivel.cs 프로젝트: huguitosilva1/gisa
        public static List<string> HasIndexacaoChanged(GISADataset.FRDBaseRow frdRow)
        {
            var newIdxRows = frdRow.GetIndexFRDCARows().Where(r => r.RowState == DataRowState.Added && (r.ControloAutRow.IDTipoNoticiaAut == (long)TipoNoticiaAut.Ideografico || r.ControloAutRow.IDTipoNoticiaAut == (long)TipoNoticiaAut.Onomastico || r.ControloAutRow.IDTipoNoticiaAut == (long)TipoNoticiaAut.ToponimicoGeografico));
            if (newIdxRows.Count() > 0)
                return newIdxRows.Where(r => r.ControloAutRow.IDTipoNoticiaAut == (long)TipoNoticiaAut.Ideografico || r.ControloAutRow.IDTipoNoticiaAut == (long)TipoNoticiaAut.Onomastico || r.ControloAutRow.IDTipoNoticiaAut == (long)TipoNoticiaAut.ToponimicoGeografico).Select(r => r.ControloAutRow.GetControloAutDicionarioRows().Single(cad => cad.IDTipoControloAutForma == (long)TipoControloAutForma.FormaAutorizada).DicionarioRow.Termo).ToList();

            var remIdxRows = GisaDataSetHelper.GetInstance().IndexFRDCA.Cast<GISADataset.IndexFRDCARow>().Where(r => r.RowState == DataRowState.Deleted && (long)r["IDFRDBase", DataRowVersion.Original] == frdRow.ID);
            foreach (var idx in remIdxRows)
            {
                var res = new List<string>();
                var caRow = GisaDataSetHelper.GetInstance().ControloAut.Cast<GISADataset.ControloAutRow>().Single(r => r.ID == (long)idx["IDControloAut", DataRowVersion.Original]);
                if (caRow.IDTipoNoticiaAut == (long)TipoNoticiaAut.Ideografico || caRow.IDTipoNoticiaAut == (long)TipoNoticiaAut.Onomastico || caRow.IDTipoNoticiaAut == (long)TipoNoticiaAut.ToponimicoGeografico)
                    res.Add(caRow.GetControloAutDicionarioRows().Single(r => r.IDTipoControloAutForma == 1).DicionarioRow.Termo);
                return res;
            }
            return null;
        }
예제 #28
0
        // 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);
        }
예제 #29
0
        public static void RegisterRecordModificationCA(GISADataset.ControloAutRow CurrentControloAut, bool existsModifiedDataFromRels, GISADataset.TrusteeUserRow tuOperator, GISADataset.TrusteeUserRow tuAuthor, DateTime data)
        {
            // só é registada uma nova entrada no controlo de descrição se alguma informação relativa à FRD
            // tiver sido modificada; é também possível que já tenha sido registado uma nova entrada no controlo mas
            // nesse caso não se adiciona outra
            if (CurrentControloAut == null || CurrentControloAut.RowState == DataRowState.Detached ||
                GisaDataSetHelper.GetInstance().ControloAutDataDeDescricao.Select("IDControloAut=" + CurrentControloAut.ID.ToString(), "", DataViewRowState.Added).Length > 0)
            {
                return;
            }

            if (existsModifiedDataFromRels || Concorrencia.WasRecordModified(CurrentControloAut))
            {
                var cadddRow = CreateControlAutDataDeDescricaoRow(CurrentControloAut, tuOperator, tuAuthor, data);
                GisaDataSetHelper.GetInstance().ControloAutDataDeDescricao.AddControloAutDataDeDescricaoRow(cadddRow);
            }
        }
예제 #30
0
        public static bool isRemovable(GISADataset.NivelRow NivelRow, GISADataset.NivelRow NivelUpperRow, bool countUFs)
        {
            string filter = string.Empty;

            if (!countUFs)
            {
                filter = string.Format("rh.IDTipoNivelRelacionado != {0:d}", TipoNivelRelacionado.UF);
            }

            int  parentCount          = 0;
            int  directChildCount     = 0;
            bool moreThenOneParent    = false;
            bool notExistsDirectChild = false;
            bool connectionClose      = false;

            if (GisaDataSetHelper.GetConnection().State == ConnectionState.Closed)
            {
                connectionClose = true;
                GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetTempConnection());
                try
                {
                    parentCount          = DBAbstractDataLayer.DataAccessRules.NivelRule.Current.getParentCount(NivelRow.ID.ToString(), ho.Connection);
                    directChildCount     = DBAbstractDataLayer.DataAccessRules.NivelRule.Current.getDirectChildCount(NivelRow.ID.ToString(), filter, ho.Connection);
                    moreThenOneParent    = parentCount > 1;
                    notExistsDirectChild = directChildCount == 0;
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex);
                    throw;
                }
                finally
                {
                    ho.Dispose();
                }
            }

            return(!(TipoNivel.isNivelOrganico(NivelRow) && TipoNivel.isNivelOrganico(NivelUpperRow)) &&
                   (TipoNivel.isNivelOrganico(NivelRow) ||
                    (NivelRow != null && NivelRow.IDTipoNivel == TipoNivel.LOGICO && notExistsDirectChild) ||
                    (TipoNivel.isNivelOrganico(NivelUpperRow) && connectionClose && !moreThenOneParent && notExistsDirectChild) ||
                    ((NivelUpperRow == null || NivelUpperRow.IDTipoNivel == TipoNivel.DOCUMENTAL) && connectionClose && notExistsDirectChild) ||
                    (NivelUpperRow != null && NivelUpperRow.IDTipoNivel == TipoNivel.ESTRUTURAL && NivelRow.IDTipoNivel == TipoNivel.DOCUMENTAL && connectionClose && notExistsDirectChild && !moreThenOneParent) //permitir apagar séries/documentos soltos só com um produtor e sem niveis descendentes
                   ));                                                                                                                                                                                            // o estado da ligação tem de se ser fechado para que não ocorram situações de deadlock na BD
        }