コード例 #1
0
        /// <summary>
        /// Cria um parâmetro para a consulta.
        /// </summary>
        /// <param name="name">Nome do parâmetro.</param>
        /// <param name="value">Valor do parâmetro.</param>
        /// <returns>Objeto do tipo <see cref="GDAParameter"/>.</returns>
        protected override GDAParameter CreateParameter(string name, object value)
        {
            if (value is QueryInfo || value is Queryable)
            {
                value = null;
            }
            if (value is DateTime)
            {
                var date = (DateTime)value;
                if (date.Kind == DateTimeKind.Unspecified)
                {
                    value = new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, date.Millisecond, DateTimeKind.Local);
                }
            }
            if (value != null && value.GetType() == typeof(DateTimeOffset))
            {
                var date = (DateTimeOffset)value;
                                #if UNMANAGED
#elif DEVART
                value = new Devart.Data.Oracle.OracleTimeStamp(date.DateTime, date.Offset.ToString());
#else
                value = new global::Oracle.ManagedDataAccess.Types.OracleTimeStampTZ(date.DateTime, date.Offset.ToString());
                                #endif
                GDAParameter parameter = new GDAParameter(name, value);
                parameter.DbType = System.Data.DbType.DateTime;
                return(parameter);
            }
            else
            {
                return(new GDAParameter(name, value));
            }
        }
コード例 #2
0
        private static IEnumerable <GDADataRecord> NavigateRefCursor(GDAParameter a)
        {
            if (a.Value != null)
            {
                                #if UNMANAGED
                var b = a.Value as global::Oracle.DataAccess.Types.OracleRefCursor;
#elif DEVART
                var b = a.Value as Devart.Data.Oracle.OracleCursor;
#else
                var b = a.Value as global::Oracle.ManagedDataAccess.Types.OracleRefCursor;
                                #endif
                System.Data.IDataReader c = null;
                if (b != null)
                {
                    c = b.GetDataReader();
                }
                else if (a.Value is System.Data.IDataReader)
                {
                    c = (System.Data.IDataReader)a.Value;
                }
                if (c != null)
                {
                    while (c.Read())
                    {
                        yield return(new GDADataRecord(c, null));
                    }
                }
            }
        }
コード例 #3
0
        protected override GDAParameter CreateParameter(string a, object b)
        {
            if (b is QueryInfo || b is Queryable)
            {
                b = null;
            }
            if (b is DateTime)
            {
                var c = (DateTime)b;
                if (c.Kind == DateTimeKind.Unspecified)
                {
                    b = new DateTime(c.Year, c.Month, c.Day, c.Hour, c.Minute, c.Second, c.Millisecond, DateTimeKind.Local);
                }
            }
            if (b != null && b.GetType() == typeof(DateTimeOffset))
            {
                var c = (DateTimeOffset)b;
                                #if UNMANAGED
#elif DEVART
                b = new Devart.Data.Oracle.OracleTimeStamp(c.DateTime, c.Offset.ToString());
#else
                b = new global::Oracle.ManagedDataAccess.Types.OracleTimeStampTZ(c.DateTime, c.Offset.ToString());
                                #endif
                GDAParameter d = new GDAParameter(a, b);
                d.DbType = System.Data.DbType.DateTime;
                return(d);
            }
            else
            {
                return(new GDAParameter(a, b));
            }
        }
コード例 #4
0
        /// <summary>
        /// Navega pelo cursor.
        /// </summary>
        /// <param name="refCursorParameter"></param>
        /// <returns></returns>
        private static IEnumerable <GDADataRecord> NavigateRefCursor(GDAParameter refCursorParameter)
        {
            if (refCursorParameter.Value != null)
            {
                                #if UNMANAGED
                var cursor = refCursorParameter.Value as global::Oracle.DataAccess.Types.OracleRefCursor;
#elif DEVART
                var cursor = refCursorParameter.Value as Devart.Data.Oracle.OracleCursor;
#else
                var cursor = refCursorParameter.Value as global::Oracle.ManagedDataAccess.Types.OracleRefCursor;
                                #endif
                System.Data.IDataReader reader = null;
                if (cursor != null)
                {
                    reader = cursor.GetDataReader();
                }
                else if (refCursorParameter.Value is System.Data.IDataReader)
                {
                    reader = (System.Data.IDataReader)refCursorParameter.Value;
                }
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        yield return(new GDADataRecord(reader, null));
                    }
                }
            }
        }
コード例 #5
0
        private void ValidaCodigoInterno(NaturezaOperacao obj)
        {
            var pCfop   = new GDAParameter("?cfop", obj.IdCfop);
            var codCfop = CfopDAO.Instance.ObtemCodInterno((uint)obj.IdCfop);

            if (obj.CodInterno != null)
            {
                obj.CodInterno = obj.CodInterno.Trim();
            }

            if (String.IsNullOrEmpty(obj.CodInterno))
            {
                if (objPersistence.ExecuteSqlQueryCount(@"select count(*) from natureza_operacao 
                    where idCfop=?cfop and coalesce(codInterno, '')='' and idNaturezaOperacao<>" + obj.IdNaturezaOperacao, pCfop) > 0)
                {
                    throw new Exception("Já foi cadastrada a natureza de operação padrão para o CFOP " + codCfop + ".");
                }
            }
            else
            {
                if (objPersistence.ExecuteSqlQueryCount(@"select count(*) from natureza_operacao 
                    where idCfop=?cfop and codInterno=?cod and idNaturezaOperacao<>" + obj.IdNaturezaOperacao,
                                                        pCfop, new GDAParameter("?cod", obj.CodInterno)) > 0)
                {
                    throw new Exception("O código '" + obj.CodInterno + "' já está cadastrado para o CFOP " + codCfop + ".");
                }
            }
        }
コード例 #6
0
        private void ValidaExistencia(uint idNaturezaOperacao, string inicioTextoErro)
        {
            string       textoErro = inicioTextoErro + " Ela é utilizada em pelo menos {0}.";
            GDAParameter id        = new GDAParameter("?id", idNaturezaOperacao);

            if (objPersistence.ExecuteSqlQueryCount("select count(*) from nota_fiscal where idNaturezaOperacao=?id", id) > 0)
            {
                throw new Exception(String.Format(textoErro, "uma nota fiscal"));
            }

            if (objPersistence.ExecuteSqlQueryCount("select count(*) from produtos_nf where idNaturezaOperacao=?id", id) > 0)
            {
                throw new Exception(String.Format(textoErro, "um produto de nota fiscal"));
            }

            if (objPersistence.ExecuteSqlQueryCount("select count(*) from conhecimento_transporte where idNaturezaOperacao=?id", id) > 0)
            {
                throw new Exception(String.Format(textoErro, "um conhecimento de transporte"));
            }

            if (objPersistence.ExecuteSqlQueryCount(@"select count(*) from regra_natureza_operacao where
                IDNATUREZAOPERACAOPRODINTRA=?id Or IDNATUREZAOPERACAOREVINTRA=?id Or IDNATUREZAOPERACAOPRODINTER=?id Or
                IDNATUREZAOPERACAOREVINTER=?id Or IDNATUREZAOPERACAOPRODSTINTRA=?id Or IDNATUREZAOPERACAOREVSTINTRA=?id Or
                IDNATUREZAOPERACAOPRODSTINTER=?id Or IDNATUREZAOPERACAOREVSTINTER=?id", id) > 0)
            {
                throw new Exception(String.Format(textoErro, "uma regra de natureza de operação"));
            }
        }
コード例 #7
0
        public IList <DescontoAcrescimoCliente> GetByClienteGrupoSubgrupo(uint idCliente, uint idTabelaDesconto, uint idGrupo, uint idSubgrupo,
                                                                          string produto, int situacao, string sortExpression, int startRow, int pageSize)
        {
            GDAParameter p = new GDAParameter("?produto", "%" + produto + "%");

            return(LoadDataWithSortExpression(Sql(0, idCliente, idTabelaDesconto, idGrupo, idSubgrupo, produto, situacao, true), sortExpression, startRow, pageSize, p));
        }
コード例 #8
0
ファイル: MedidaProjetoDAO.cs プロジェクト: ertprs/Estudo
        public uint?FindByDescricao(GDASession session, uint idMedidaProjeto, string descricao)
        {
            var trataDescr         = "REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(Descricao, ' ', ''), '.', ''), 'ã', 'a'), 'á', 'a'), 'â', 'a'), 'é', 'e'), 'ê', 'e'), 'í', 'i'), 'ç', 'c')";
            var parametroDescricao = new GDAParameter("?descricao", MedidaProjetoModelo.TrataDescricao(descricao));

            if (idMedidaProjeto > 0)
            {
                if (objPersistence.ExecuteSqlQueryCount(string.Format("SELECT COUNT(*) FROM medida_projeto WHERE IdMedidaProjeto={0} AND {1}=?descricao", idMedidaProjeto, trataDescr), parametroDescricao) > 0)
                {
                    return(idMedidaProjeto);
                }
            }

            if (!string.IsNullOrWhiteSpace(descricao))
            {
                var sqlBase = string.Format("SELECT {0} FROM medida_projeto WHERE {1}=?descricao", "{0}", trataDescr);

                if (objPersistence.ExecuteSqlQueryCount(string.Format(sqlBase, "COUNT(*)"), parametroDescricao) > 0)
                {
                    return(ExecuteScalar <uint?>(string.Format(sqlBase, "IdMedidaProjeto"), parametroDescricao));
                }
            }

            return(null);
        }
コード例 #9
0
        /// <summary>
        /// Cria um parâmetro para a consulta.
        /// </summary>
        /// <param name="name">Nome do parâmetro.</param>
        /// <param name="value">Valor do parâmetro.</param>
        /// <returns>Objeto do tipo <see cref="GDAParameter"/>.</returns>
        protected override GDAParameter CreateParameter(string name, object value)
        {
            if (value != null && value.GetType() == typeof(DateTimeOffset))
            {
                var date = (DateTimeOffset)value;
                                #if DEVART
                value = new Devart.Data.Oracle.OracleTimeStamp(date.DateTime, date.Offset.ToString());
#else
                value = new OracleTimeStampTZ(date.DateTime, date.Offset.ToString());
                                #endif
                GDAParameter parameter = new GDAParameter(name, value);
                parameter.DbType = DbType.DateTime;
                return(parameter);
            }
            else if (value is Guid)
            {
                return(new GDAParameter(name, ((Guid)value).ToString()));
            }
            else
            {
                if (value != null && value.GetType().IsEnum)
                {
                    value = Convert.ChangeType(value, Enum.GetUnderlyingType(value.GetType()));
                }
                return(new GDAParameter(name, value));
            }
        }
コード例 #10
0
        /// <summary>
        /// Converte o parametro do GDA.
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public System.Data.IDbDataParameter Convert(GDAParameter parameter)
        {
            var p = this.CreateParameter();

            p.DbType = parameter.DbType;
            if (p.Direction != parameter.Direction)
            {
                p.Direction = parameter.Direction;
            }
            p.Size = parameter.Size;
            try
            {
                if (parameter.ParameterName[0] == '?')
                {
                    p.ParameterName = ParameterPrefix + parameter.ParameterName.Substring(1) + ParameterSuffix;
                }
                else
                {
                    p.ParameterName = parameter.ParameterName;
                }
            }
            catch (Exception ex)
            {
                throw new GDAException("Error on convert parameter name '" + parameter.ParameterName + "'.", ex);
            }
            SetParameterValue(p, parameter.Value == null ? DBNull.Value : parameter.Value);
            return(p);
        }
コード例 #11
0
ファイル: NativeQuery.cs プロジェクト: fabrimaciel/gda
 void IGDAParameterContainer.Add(GDAParameter parameter)
 {
     if (parameter == null)
     {
         throw new ArgumentNullException("parameter");
     }
     this._parameters.Add(parameter);
 }
コード例 #12
0
ファイル: NativeQuery.cs プロジェクト: fabrimaciel/gda
 /// <summary>
 /// Adiciona um novo parametro na consulta.
 /// </summary>
 /// <param name="parameter">Paramentro a ser adicionado.</param>
 /// <returns>Retorna a referencia da consulta aonde o parametro foi adicionado.</returns>
 public NativeQuery Add(GDAParameter parameter)
 {
     if (parameter != null)
     {
         var index = this._parameters.FindIndex(f => f.ParameterName == parameter.ParameterName);
         if (index >= 0)
         {
             this._parameters.RemoveAt(index);
         }
         this._parameters.Add(parameter);
     }
     return(this);
 }
コード例 #13
0
ファイル: SelectStatement.cs プロジェクト: fabrimaciel/gda
 /// <summary>
 /// Adiciona um novo parametro na consulta.
 /// </summary>
 /// <param name="parameter">Paramentro a ser adicionado.</param>
 /// <returns>Retorna a referencia da consulta aonde o parametro foi adicionado.</returns>
 public SelectStatement Add(GDAParameter parameter)
 {
     if (parameter != null)
     {
         var index = this.parameters.FindIndex(f => f.ParameterName == parameter.ParameterName);
         if (index >= 0)
         {
             this.parameters.RemoveAt(index);
         }
         this.parameters.Add(parameter);
     }
     return(this);
 }
コード例 #14
0
        //private ControleCreditoApuracaoDAO() { }

        public ControleCreditoApuracao ObterCreditoMesAnterior(string periodo, DataSourcesEFD.TipoImpostoEnum tipoImposto)
        {
            try
            {
                string sql = "SELECT * FROM controle_credito_apuracao WHERE PeriodoGeracao=?periodo AND TipoImposto = ?tipoImposto";

                GDAParameter[] param = new GDAParameter[] { new GDAParameter("?periodo", periodo), new GDAParameter("?tipoImposto", tipoImposto) };

                return(objPersistence.LoadOneData(sql, param));
            }
            catch
            {
                return(null);
            }
        }
コード例 #15
0
        /// <summary>
        /// Navega pelo cursor.
        /// </summary>
        /// <param name="refCursorParameter"></param>
        /// <returns></returns>
        private static IEnumerable <GDADataRecord> NavigateRefCursor(GDAParameter refCursorParameter)
        {
            if (refCursorParameter.Value != null)
            {
                                #if UNMANAGED
                var cursor = (global::Oracle.DataAccess.Types.OracleRefCursor)refCursorParameter.Value;
#else
                var cursor = (global::Oracle.ManagedDataAccess.Types.OracleRefCursor)refCursorParameter.Value;
                                #endif
                var reader = cursor.GetDataReader();
                while (reader.Read())
                {
                    yield return(new GDADataRecord(reader, null));
                }
            }
        }
コード例 #16
0
ファイル: NativeQuery.cs プロジェクト: fabrimaciel/gda
        /// <summary>
        /// Adds a parameter.
        /// </summary>
        /// <param name="name">parameter name</param>
        /// <param name="dbtype">database data type</param>
        /// <param name="size">size of the database data type</param>
        /// <param name="value">parameter value</param>
        public NativeQuery Add(string name, DbType dbtype, int size, object value)
        {
            GDAParameter p = new GDAParameter();

            p.ParameterName = name;
            p.DbType        = dbtype;
            p.Size          = size;
            p.Value         = value;
            var index = this._parameters.FindIndex(f => f.ParameterName == p.ParameterName);

            if (index >= 0)
            {
                this._parameters.RemoveAt(index);
            }
            this._parameters.Add(p);
            return(this);
        }
コード例 #17
0
        public string GetLojaByCNPJIE(GDASession sessao, string cnpj, string inscEst, bool ativa)
        {
            var param = new GDAParameter("?cnpj", cnpj.Replace("-", "").Replace("/", "").Replace(".", ""));
            var sql   = "Select idloja from loja where Replace(Replace(Replace(cnpj, '-',''), '.',''), '/','')=?cnpj";

            if (ativa)
            {
                sql += string.Format(" AND Situacao = {0} ", (int)Situacao.Ativo);
            }

            // Se houver mais de uma loja com o mesmo cnpj, filtra também pela inscrição estadual
            if (ExecuteScalar <bool>(sessao, "Select count(*) > 1 from loja where Replace(Replace(Replace(cnpj, '-',''), '.',''), '/','')=?cnpj", param))
            {
                return(ExecuteScalar <string>(sessao, sql + " And Replace(Replace(Replace(inscEst, '-',''), '.',''), '/','')=?inscEst", param, new GDAParameter("?inscEst", inscEst)));
            }

            return(ExecuteScalar <string>(sessao, sql, param));
        }
コード例 #18
0
ファイル: GrupoModeloDAO.cs プロジェクト: ertprs/Estudo
        public uint?FindByDescricao(GDASession session, uint idGrupoModelo, string descricao)
        {
            var p   = new GDAParameter("?descricao", descricao);
            var sql = "select count(*) from grupo_modelo where idGrupoModelo=" + idGrupoModelo + " and descricao=?descricao";

            if (objPersistence.ExecuteSqlQueryCount(session, sql, p) > 0)
            {
                return(idGrupoModelo);
            }

            sql = "select {0} from grupo_modelo where descricao=?descricao";
            if (objPersistence.ExecuteSqlQueryCount(session, string.Format(sql, "count(*)"), p) > 0)
            {
                object retorno = objPersistence.ExecuteScalar(session, string.Format(sql, "idGrupoModelo"), p);
                return(retorno != null && retorno != DBNull.Value && retorno.ToString() != "" ? (uint?)Glass.Conversoes.StrParaUint(retorno.ToString()) : null);
            }

            return(null);
        }
コード例 #19
0
        public override int Update(GrupoMedidaProjeto objUpdate)
        {
            // Verifica se este grupo medida projeto está associado a alguma medida de projeto
            if (CurrentPersistenceObject.ExecuteSqlQueryCount("Select Count(*) From medida_projeto Where idGrupoMedProj=" + objUpdate.IdGrupoMedProj) > 0)
            {
                throw new Exception("Esse grupo de medidas não pode ser atualizado pois existem medidas associadas a ele.");
            }

            //Verifica se este grupo medida projeto está associado a algum arquivo calcengine variável
            GDAParameter p = new GDAParameter("?variavelsistema", ObtemDescricao(objUpdate.IdGrupoMedProj));

            if (CurrentPersistenceObject.ExecuteSqlQueryCount("Select Count(*) From arquivo_calcengine_variavel Where variavelsistema=?variavelsistema", p) > 0)
            {
                throw new Exception("Esse grupo de medidas não pode ser atualizado pois existem arquivos calcengine variáveis associadas a ele.");
            }

            LogAlteracaoDAO.Instance.LogGrupoMedidaProjeto(objUpdate);
            return(base.Update(objUpdate));
        }
コード例 #20
0
        public override int DeleteByPrimaryKey(GDASession sessao, int key)
        {
            // Verifica se este grupo medida projeto está associado a alguma medida de projeto
            if (CurrentPersistenceObject.ExecuteSqlQueryCount("Select Count(*) From medida_projeto Where idGrupoMedProj=" + key) > 0)
            {
                throw new Exception("Esse grupo de medidas não pode ser excluído pois existem medidas associadas a ele.");
            }

            // Verifica se este grupo medida projeto está associado a algum arquivo calcengine variável
            GDAParameter p = new GDAParameter("?variavelsistema", ObtemDescricao((uint)key));

            if (CurrentPersistenceObject.ExecuteSqlQueryCount("Select Count(*) From arquivo_calcengine_variavel Where variavelsistema=?variavelsistema", p) > 0)
            {
                throw new Exception("Esse grupo de medidas não pode ser excluído pois existem arquivos calcengine variáveis associadas a ele.");
            }

            LogAlteracaoDAO.Instance.ApagaLogGrupoMedidaProjeto((uint)key);
            return(base.DeleteByPrimaryKey(sessao, key));
        }
コード例 #21
0
        /// <summary>
        /// Registra as informações do usuário.
        /// </summary>
        /// <param name="transaction"></param>
        protected override void RegisterUserInfo(IPersistenceTransactionExecuter transaction)
        {
            var trans2     = ((PersistenceTransactionExecuter)transaction).Transaction;
            var dataAccess = new DataAccess(trans2.ProviderConfiguration);

            dataAccess.ExecuteCommand(trans2, "ALTER SESSION SET NLS_SORT=BINARY_CI");
            dataAccess.ExecuteCommand(trans2, "ALTER SESSION SET NLS_COMP=LINGUISTIC");
            var profile = Security.Profile.ProfileManager.CurrentProfileInfo;
            var user    = Security.UserContext.Current.User;

            if (profile != null && user != null)
            {
                var parameters = new GDAParameter[] {
                    new GDAParameter("?profileId", profile.ProfileId),
                    new GDAParameter("?userKey", int.Parse(user.UserKey))
                };
                var command = new StringBuilder().AppendLine("DECLARE").AppendLine("v_exists NUMBER := 0;").AppendLine("BEGIN").AppendLine("SELECT COUNT(*) INTO v_exists FROM sys.all_tables WHERE OWNER = 'SECURITY' AND TABLE_NAME = 'USERINFO' AND TEMPORARY = 'Y';").AppendLine("IF v_exists = 0 THEN").AppendLine("EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE \"SECURITY\".\"USERINFO\"(\"PROFILEID\" NUMBER(9), \"USERID\" NUMBER(9)) ON COMMIT DELETE ROWS';").AppendLine("ELSE").AppendLine("DELETE FROM \"SECURITY\".\"USERINFO\";").AppendLine("END IF;").AppendLine("INSERT INTO \"SECURITY\".\"USERINFO\"(\"PROFILEID\", \"USERID\") VALUES(?profileId, ?userKey);").AppendLine("END;");
                dataAccess.ExecuteCommand(trans2, command.ToString(), parameters);
            }
        }
コード例 #22
0
ファイル: GDAHelper.cs プロジェクト: fabrimaciel/gda
 /// <summary>
 /// Converte um parametro do GDA para um parametro do ADO.NET.
 /// </summary>
 /// <param name="cmd"></param>
 /// <param name="parameter"></param>
 /// <param name="provider">Provider que será usado na conversão.</param>
 /// <returns></returns>
 internal static IDbDataParameter ConvertGDAParameter(IDbCommand cmd, GDAParameter parameter, GDA.Interfaces.IProvider provider)
 {
     if (provider is Interfaces.IParameterConverter2)
     {
         return(((Interfaces.IParameterConverter2)provider).Converter(cmd, parameter));
     }
     else if (provider is Interfaces.IParameterConverter)
     {
         return(((Interfaces.IParameterConverter)provider).Convert(parameter));
     }
     else
     {
         IDbDataParameter p = cmd.CreateParameter();
         if (p.Direction != parameter.Direction)
         {
             p.Direction = parameter.Direction;
         }
         p.Size = parameter.Size;
         try
         {
             if (parameter.ParameterName[0] == '?')
             {
                 p.ParameterName = provider.ParameterPrefix + parameter.ParameterName.Substring(1) + provider.ParameterSuffix;
             }
             else
             {
                 p.ParameterName = parameter.ParameterName;
             }
         }
         catch (Exception ex)
         {
             throw new GDAException("Error on convert parameter name '" + parameter.ParameterName + "'.", ex);
         }
         if (parameter.DbTypeIsDefined)
         {
             p.DbType = parameter.DbType;
         }
         provider.SetParameterValue(p, parameter.Value == null ? DBNull.Value : parameter.Value);
         return(p);
     }
 }
コード例 #23
0
 /// <summary>
 /// Registra as informações do usuário na transação do storedprocedure.
 /// </summary>
 /// <param name="transaction"></param>
 protected override void RegisterUserInfo(IStoredProcedureTransaction transaction)
 {
     if (!Colosoft.Security.UserContext.UserProcessing)
     {
         var profile = ProfileManager.CurrentProfileInfo;
         var user    = Colosoft.Security.UserContext.Current.User;
         if (profile != null && user != null)
         {
             var query      = "CREATE TABLE #UserInfo (ProfileId int, UserId int)";
             var parameters = new GDAParameter[] {
                 new GDAParameter("?profileId", profile.ProfileId),
                 new GDAParameter("?userKey", int.Parse(user.UserKey))
             };
             var session = ((GDAStoredProcedureTransaction)transaction).Session;
             var da      = new DataAccess(session.ProviderConfiguration);
             var r1      = da.ExecuteCommand(session, query);
             var query1  = "INSERT INTO #UserInfo(ProfileId, UserId) VALUES(?profileId, ?userKey)";
             da.ExecuteCommand(session, query1, parameters);
         }
     }
 }
コード例 #24
0
        /// <summary>
        /// Atribui medicoes passadas ao medidor passado
        /// </summary>
        /// <param name="idMedidor"></param>
        /// <param name="idMedicoes"></param>
        /// <param name="dataEfetuar"></param>
        public void SetMedicoesForMedidor(uint idMedidor, string idMedicoes, DateTime dataEfetuar)
        {
            if (!Config.PossuiPermissao(Config.FuncaoMenuMedicao.EfetuarMedicao))
            {
                throw new Exception("Apenas Aux. Escritório Medição pode efetuar medições.");
            }

            string[] idsMed  = idMedicoes.Split(',');
            string   sqlExec = String.Empty;
            string   sql     = "Update medicao Set dataEfetuar=?dataEfetuar, numSeq=$numSeq, situacao=" + (int)Medicao.SituacaoMedicao.EmAndamento +
                               ", idFuncMed=" + idMedidor + " Where idMedicao=$idMed";

            GDAParameter[] param = new GDAParameter[] { new GDAParameter("?dataEfetuar", dataEfetuar) };

            // Para cada medição
            for (int i = 0; i < idsMed.Length; i++)
            {
                sqlExec = sql.Replace("$numSeq", (i + 1).ToString()).Replace("$idMed", idsMed[i].ToString());
                objPersistence.ExecuteCommand(sqlExec, param);
            }
        }
コード例 #25
0
        public uint?FindByNome(GDASession session, uint idArquivoCalcEngine, string nome)
        {
            string trataNome = @"
                Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(nome, ' ', ''), 
                '.', ''), 'ã', 'a'), 'á', 'a'), 'â', 'a'), 'é', 'e'), 'ê', 'e'), 'í', 'i'), 'ç', 'c')";

            GDAParameter p   = new GDAParameter("?nome", ArquivoCalcEngine.TrataNome(nome));
            string       sql = "select count(*) from arquivo_calcengine where idArquivoCalcEngine=" + idArquivoCalcEngine + " and " + trataNome + "=?nome";

            if (objPersistence.ExecuteSqlQueryCount(session, sql, p) > 0)
            {
                return(idArquivoCalcEngine);
            }

            sql = "select {0} from arquivo_calcengine where " + trataNome + "=?nome";
            if (objPersistence.ExecuteSqlQueryCount(session, string.Format(sql, "count(*)"), p) > 0)
            {
                return(ExecuteScalar <uint?>(session, string.Format(sql, "idArquivoCalcEngine"), p));
            }

            return(null);
        }
コード例 #26
0
ファイル: FlagArqMesaDAO.cs プロジェクト: ertprs/Estudo
        public int?FindByDescricao(GDASession session, int idFlagArqMesa, string descricao)
        {
            var trataDescr = @"
                Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(descricao, ' ', ''), 
                '.', ''), 'ã', 'a'), 'á', 'a'), 'â', 'a'), 'é', 'e'), 'ê', 'e'), 'í', 'i'), 'ç', 'c')";

            var p   = new GDAParameter("?descricao", FlagArqMesaPecaProjMod.TrataDescricao(descricao));
            var sql = "select count(*) from flag_arq_mesa where idFlagArqMesa=" + idFlagArqMesa + " and " + trataDescr + "=?descricao";

            if (objPersistence.ExecuteSqlQueryCount(session, sql, p) > 0)
            {
                return(idFlagArqMesa);
            }

            sql = "select {0} from flag_arq_mesa where " + trataDescr + "=?descricao";
            if (objPersistence.ExecuteSqlQueryCount(session, string.Format(sql, "count(*)"), p) > 0)
            {
                return(ExecuteScalar <int?>(session, string.Format(sql, "idFlagArqMesa"), p));
            }

            return(null);
        }
コード例 #27
0
ファイル: VariableInfo.cs プロジェクト: fabrimaciel/gda
        /// <summary>
        /// Executa o replace da variável.
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="parameterContainer">Container dos parametros que serão processados.</param>
        /// <param name="classesDictionary"></param>
        /// <returns></returns>
        public bool Replace(GDA.Interfaces.IProvider provider, IGDAParameterContainer parameterContainer, Dictionary <string, Type> classesDictionary)
        {
            if (parameterContainer == null)
            {
                return(false);
            }
            GDAParameter parameter = null;

            if (!parameterContainer.TryGet(Name, out parameter))
            {
                return(false);
            }
            QueryReturnInfo returnInfo = null;

            if (parameter.Value is IQuery)
            {
                var query = (IQuery)parameter.Value;
                returnInfo = query.BuildResultInfo2(provider, query.AggregationFunctionProperty, classesDictionary);
            }
            else
            {
                returnInfo = parameter.Value as QueryReturnInfo;
            }
            if (returnInfo != null)
            {
                _expression.Text = returnInfo.CommandText;
                foreach (var p in returnInfo.Parameters)
                {
                    if (!parameterContainer.ContainsKey(p.ParameterName))
                    {
                        parameterContainer.Add(p);
                    }
                }
                return(true);
            }
            return(false);
        }
コード例 #28
0
        /// <summary>
        /// Retorna o parâmetro correspondente a chave primária
        /// </summary>
        /// <param name="transaction"></param>
        /// <param name="entityName">Nome da entidade</param>
        /// <returns>Pâremetro correspondente a chave primária</returns>
        public object GetPrimaryKey(IPersistenceTransactionExecuter transaction, string entityName)
        {
            var metadata         = _typeSchema.GetTypeMetadata(entityName);
            var identityMetadata = metadata.GetKeyProperties().FirstOrDefault();

            using (var session = new GDASession(GDASettings.GetProviderConfiguration(ProviderName)))
            {
                DataAccess da         = session != null ? new DataAccess(session.ProviderConfiguration) : new DataAccess();
                var        indexes    = new List <int>();
                var        script     = "BEGIN \"CONTROL\".\"GETIDENTITY\"(:1,:2,:3,:4); END;";
                var        parameters = new GDA.Collections.GDAParameterCollection();
                parameters.Add(new GDAParameter(":1", metadata.TableName.Schema, System.Data.ParameterDirection.Input));
                parameters.Add(new GDAParameter(":2", metadata.TableName.Name, System.Data.ParameterDirection.Input));
                parameters.Add(new GDAParameter(":3", identityMetadata.ColumnName, System.Data.ParameterDirection.Input));
                var resultParameter = new GDAParameter(":4", null)
                {
                    DbType    = System.Data.DbType.Int32,
                    Direction = System.Data.ParameterDirection.Output
                };
                parameters.Add(resultParameter);
                da.ExecuteCommand(session, script, parameters.ToArray());
                return(resultParameter.Value);
            }
        }
コード例 #29
0
        /// <summary>
        /// Verifica se as medidas retiradas do modelo de projeto (Após atualizar modelo de projeto)
        /// estão sendo usadas em alguma expressão de cálculo
        /// </summary>
        public bool MedidasRetiradasEmUso(GDASession session, uint idProjetoModelo, string idsMedidaProjetoNovos)
        {
            if (string.IsNullOrWhiteSpace(idsMedidaProjetoNovos))
            {
                idsMedidaProjetoNovos = "0";
            }

            var sql = @"
                Select mpm.*, mp.Descricao as DescrMedida 
                From medida_projeto_modelo mpm 
                    Inner Join medida_projeto mp On (mpm.idMedidaProjeto=mp.idMedidaProjeto)
                Where mpm.idMedidaProjeto Not In (" + idsMedidaProjetoNovos.Trim(',') + @")
                And mpm.idProjetoModelo=" + idProjetoModelo + @"
                Order By mp.idMedidaProjeto";

            var lstMedidasRetiradas = objPersistence.LoadData(session, sql).ToList();

            foreach (var mpm in lstMedidasRetiradas)
            {
                var param = new GDAParameter("?expressao", mpm.CalcTipoMedida);

                if (objPersistence.ExecuteSqlQueryCount(session, "Select Count(*) From peca_projeto_modelo Where " +
                                                        "idProjetoModelo=" + idProjetoModelo + " And InStr(calculoQtde, ?expressao) > 0", param) > 0)
                {
                    return(true);
                }

                if (objPersistence.ExecuteSqlQueryCount(session, "Select Count(*) From peca_projeto_modelo Where " +
                                                        "idProjetoModelo=" + idProjetoModelo + " And InStr(calculoAltura, ?expressao) > 0", param) > 0)
                {
                    return(true);
                }

                if (objPersistence.ExecuteSqlQueryCount(session, "Select Count(*) From peca_projeto_modelo Where " +
                                                        "idProjetoModelo=" + idProjetoModelo + " And InStr(calculoLargura, ?expressao) > 0", param) > 0)
                {
                    return(true);
                }

                if (objPersistence.ExecuteSqlQueryCount(session, "Select Count(*) From material_projeto_modelo Where " +
                                                        "idProjetoModelo=" + idProjetoModelo + " And InStr(calculoQtde, ?expressao) > 0", param) > 0)
                {
                    return(true);
                }

                if (objPersistence.ExecuteSqlQueryCount(session, "Select Count(*) From material_projeto_modelo Where " +
                                                        "idProjetoModelo=" + idProjetoModelo + " And InStr(calculoAltura, ?expressao) > 0", param) > 0)
                {
                    return(true);
                }

                if (objPersistence.ExecuteSqlQueryCount(session, "Select Count(*) From posicao_peca_modelo Where " +
                                                        "idProjetoModelo=" + idProjetoModelo + " And InStr(calc, ?expressao) > 0", param) > 0)
                {
                    return(true);
                }

                if (objPersistence.ExecuteSqlQueryCount(session, "Select Count(*) From posicao_peca_modelo Where " +
                                                        "idProjetoModelo=" + idProjetoModelo + " And InStr(calc, ?expressao) > 0", param) > 0)
                {
                    return(true);
                }

                if (objPersistence.ExecuteSqlQueryCount(session, "Select Count(*) From posicao_peca_individual Where " +
                                                        "idPecaProjMod in (Select idPecaProjMod From peca_projeto_modelo Where idProjetoModelo=" + idProjetoModelo +
                                                        ") And InStr(calc, ?expressao) > 0", param) > 0)
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #30
0
 /// <summary>
 /// Tenta recupera o parametro pelo nome informado.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="parameter"></param>
 /// <returns></returns>
 bool IGDAParameterContainer.TryGet(string name, out GDAParameter parameter)
 {
     return(ParameterContainer.TryGet(name, out parameter));
 }