Esempio n. 1
0
        public HttpResponseMessage GetNfeByForn(HttpRequestMessage request, [FromBody] UploadParceiroPesquisa pesq, string cdpai)
        {
            ConfigAppMembers      cf  = Util.ConfigApp.getConfig();
            List <UploadParceiro> ret = new List <UploadParceiro>();
            string query = string.Empty;

            try
            {
                ret = Database.UploadParceiroADO.ConsultarNfe(pesq, cdpai, cf.cdentifilial, cf.datasource, cf.schema);
            }
            catch (Exception e)
            {
                Util.LogUtil.GravaLog(this, "GetPedidosByForn: " + e.ToString(), cf.Cnpj, Log.TipoLog.erro);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, "ERRO"));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, ret));
        }
        public static List <UploadParceiro> ConsultarNfe(UploadParceiroPesquisa upp, string cdpai, string cdentifilial, string datasource, string schema)
        {
            List <UploadParceiro> lstret    = new List <UploadParceiro>();
            UploadParceiro        uploadret = new UploadParceiro();
            StringBuilder         query     = new StringBuilder();

            query.Append("select cduploadparceiro,u.cdfornecedor,(select nmentidade from entidade where cdentidade = u.cdfornecedor) as nmfornecedor,txinfo,cdentifilial, ");
            query.Append(" to_char(dtinclusao,'DD/MM/YYYY') as dtinclusao,txpath from uploadparceiro u where stexcluido = 0 ");
            if (!string.IsNullOrEmpty(upp.dtinicio) && !string.IsNullOrEmpty(upp.dtfim))
            {
                query.AppendLine(string.Format(" and trunc(dtinclusao) between to_date('{0}','DD/MM/YYYY') and to_date('{1}','DD/MM/YYYY')", upp.dtinicio, upp.dtfim));
            }
            query.AppendLine(string.Format("and cdfornecedor = {0}", cdpai));
            query.AppendLine(string.Format("and cdentifilial = {0}", cdentifilial));
            query.AppendLine(" order by dtinclusao desc");
            using (OracleConnection connection = new OracleConnection(Util.OracleHelper.StrConn(schema, datasource)))
            {
                OracleCommand command = new OracleCommand(query.ToString(), connection);
                connection.Open();
                using (OracleDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        uploadret = new UploadParceiro();
                        uploadret.CdUploadParceiro = Convert.ToInt32(reader["cduploadparceiro"].ToString());
                        uploadret.dtinclusao       = reader["dtinclusao"].ToString();
                        uploadret.nmfornecedor     = reader["nmfornecedor"].ToString();
                        uploadret.txpath           = "/UPLOAD/" + reader["txpath"].ToString();
                        uploadret.txinfo           = reader["txinfo"].ToString();
                        uploadret.Cdfornecedor     = Convert.ToInt32(reader["Cdfornecedor"].ToString());
                        uploadret.cdentifilial     = Convert.ToInt32(reader["cdentifilial"].ToString());
                        lstret.Add(uploadret);
                    }
                }
            }
            return(lstret);
        }