public static DataTable PurchaserInfoById(Purchaser obj)
        {
            DataSet   dsDatos;
            DataTable dtDatos = new DataTable();

            try
            {
                var      ConectStr  = Tools.ConectionNow.BuildConection(obj.User);
                Database dbeAuction = new Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase(ConectStr);
                //  Database dbeAuction = DatabaseFactory.CreateDatabase("Auction");
                // Crear objeto SP
                DbCommand spComprador = dbeAuction.GetStoredProcCommand("SP_COMPRADORES");
                dbeAuction.AddInParameter(spComprador, "@i_operation", DbType.String, "S");
                dbeAuction.AddInParameter(spComprador, "@i_option", DbType.String, "B");
                dbeAuction.AddInParameter(spComprador, "@id_Comprador", DbType.Int32, obj.IdSegas);
                dbeAuction.AddInParameter(spComprador, "@IdSubasta", DbType.Int32, obj.IdSubasta);
                spComprador.CommandTimeout = 900000000;
                dsDatos = dbeAuction.ExecuteDataSet(spComprador);
                if (dsDatos.Tables[0].Rows.Count > 0)
                {
                    dtDatos = dsDatos.Tables[0];
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(string.Format("AuctionGas ApiWebServices Auditoria: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name));

                throw new Exception((string.Format("AuctionGas ApiWebServices Auditoria: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name)));
            }
            return(dtDatos);
        }
        public static bool SavePurchaserUser(Purchaser purchaserobj)
        {
            int  datos;
            bool SafeSave;

            try
            {
                var      ConectStr  = Tools.ConectionNow.BuildConection(purchaserobj.User);
                Database dbeAuction = new Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase(ConectStr);
                //  Database dbeAuction = DatabaseFactory.CreateDatabase("Auction");
                // Crear objeto SP
                DbCommand spComprador = dbeAuction.GetStoredProcCommand("SP_COMPRADORES");

                dbeAuction.AddInParameter(spComprador, "@i_operation", DbType.String, "IU");
                dbeAuction.AddInParameter(spComprador, "@i_option", DbType.String, "C");
                dbeAuction.AddInParameter(spComprador, "@id_Comprador", DbType.Int32, purchaserobj.IdSegas);
                dbeAuction.AddInParameter(spComprador, "@Nombre", DbType.String, purchaserobj.Nombre);
                dbeAuction.AddInParameter(spComprador, "@IdSubasta", DbType.Int32, purchaserobj.IdSubasta);
                dbeAuction.AddInParameter(spComprador, "@DemandaMaxima", DbType.Int32, purchaserobj.DemandaMaximaTotal);
                dbeAuction.AddInParameter(spComprador, "@IdOperador", DbType.Int32, purchaserobj.User.CodigoOperador);


                spComprador.CommandTimeout = 900000000;
                datos    = dbeAuction.ExecuteNonQuery(spComprador);
                SafeSave = true;
            }
            catch (Exception ex)
            {
                SafeSave = false;
                System.Diagnostics.Trace.WriteLine(string.Format("AuctionGas ApiWebServices Auditoria: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name));

                throw new Exception((string.Format("AuctionGas ApiWebServices Auditoria: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name)));
            }
            return(SafeSave);
        }
        public static bool PurchasersSaveState(Purchaser pucharserobj)
        {
            bool transOk = false;
            int  datos;

            try
            {
                var      ConectStr  = Tools.ConectionNow.BuildConection(pucharserobj.User);
                Database dbeAuction = new Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase(ConectStr);
                //  Database dbeAuction = DatabaseFactory.CreateDatabase("Auction");
                // Crear objeto SP
                DbCommand spComprador = dbeAuction.GetStoredProcCommand("SP_COMPRADORES");
                dbeAuction.AddInParameter(spComprador, "@i_operation", DbType.String, "IU");
                dbeAuction.AddInParameter(spComprador, "@i_option", DbType.String, "B");
                dbeAuction.AddInParameter(spComprador, "@id_Comprador", DbType.Int32, pucharserobj.IdSegas);
                dbeAuction.AddInParameter(spComprador, "@IdSubasta", DbType.Int32, pucharserobj.IdSubasta);
                dbeAuction.AddInParameter(spComprador, "@Estado", DbType.Boolean, pucharserobj.Estado);
                dbeAuction.AddInParameter(spComprador, "@Cubrimiento", DbType.Boolean, pucharserobj.Cubrimiento);
                dbeAuction.AddInParameter(spComprador, "@Listas", DbType.Boolean, pucharserobj.Listas);


                spComprador.CommandTimeout = 900000000;
                datos   = dbeAuction.ExecuteNonQuery(spComprador);
                transOk = true;
            }
            catch (Exception ex)
            {
                transOk = false;
                System.Diagnostics.Trace.WriteLine(string.Format("AuctionGas ApiWebServices Auditoria: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name));

                throw new Exception((string.Format("AuctionGas ApiWebServices Auditoria: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name)));
            }
            return(transOk);
        }
예제 #4
0
        public static Seller SellerSave(Seller sellerobj)
        {
            int datos;

            try
            {
                var      ConectStr  = Tools.ConectionNow.BuildConection(sellerobj.User);
                Database dbeAuction = new Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase(ConectStr);
                //  Database dbeAuction = DatabaseFactory.CreateDatabase("Auction");
                // Crear objeto SP
                // Crear objeto SP
                DbCommand spVendedor = dbeAuction.GetStoredProcCommand("SP_VENDEDORES");

                dbeAuction.AddInParameter(spVendedor, "@i_operation", DbType.String, "IU");
                dbeAuction.AddInParameter(spVendedor, "@i_option", DbType.String, "A");
                dbeAuction.AddInParameter(spVendedor, "@id_Vendedor", DbType.Int32, sellerobj.IdSegas);
                dbeAuction.AddInParameter(spVendedor, "@PTDVF", DbType.Decimal, sellerobj.PTDVF);
                dbeAuction.AddInParameter(spVendedor, "@CIFVF", DbType.Decimal, sellerobj.CIFVF);
                dbeAuction.AddInParameter(spVendedor, "@IdSubasta", DbType.Int32, sellerobj.IdSubasta);
                dbeAuction.AddInParameter(spVendedor, "@Nombre", DbType.String, sellerobj.Nombre);
                dbeAuction.AddInParameter(spVendedor, "@IdOperador", DbType.Int32, sellerobj.User.CodigoOperador);
                spVendedor.CommandTimeout = 900000000;
                datos = dbeAuction.ExecuteNonQuery(spVendedor);
                return(sellerobj);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(string.Format("AuctionGas ApiWebServices Auditoria: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name));
                throw new Exception((string.Format("AuctionGas ApiWebServices Auditoria: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name)));
            }
        }
예제 #5
0
        /// <summary>
        /// For getting data in single table from database
        /// </summary>
        /// <param name="spDOM"></param>
        /// <returns></returns>
        public static DataTable GetDT(XDocument spDOM, string ConnectionStr)
        {
            try
            {
                Database db = new Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase(ConnectionStr);

                DbParameter            parameter;
                DbCommand              cmd;
                IEnumerable <XElement> elems;
                IEnumerable <XElement> elem_list;
                string spName = GetProcName(spDOM);
                cmd = db.GetStoredProcCommand(spName);
                SetCommandTimeOut(cmd);
                elems     = spDOM.Descendants();
                elem_list = from elem in elems select elem;
                foreach (XElement element in elem_list)
                {
                    parameter = cmd.CreateParameter();
                    if (element.Name.ToString() != "BIC" && element.Name.ToString() != "XsdName" && element.Name.ToString() != "procName" && element.Name.ToString() != "pERRORXML")
                    {
                        parameter.ParameterName = "@" + element.Name.ToString();
                        parameter.Value         = element.Value;
                        cmd.Parameters.Add(parameter);
                    }
                }

                return(db.ExecuteDataSet(cmd).Tables[0]);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #6
0
        public static DataTable SearchMessages(UserAutentication objUser)
        {
            DataSet   datos;
            DataTable clientes = new DataTable();

            try
            {
                var      ConectStr  = Tools.ConectionNow.BuildConection(objUser);
                Database dbeAuction = new Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase(ConectStr);
                //  Database dbeAuction = DatabaseFactory.CreateDatabase("Auction");
                // Crear objeto SP

                // Crear objeto SP
                DbCommand spConsultarNotificaciones = dbeAuction.GetStoredProcCommand("SP_NOTIFICACIONES");

                dbeAuction.AddInParameter(spConsultarNotificaciones, "@i_operation", DbType.String, "S");
                dbeAuction.AddInParameter(spConsultarNotificaciones, "@i_option", DbType.String, "B");

                spConsultarNotificaciones.CommandTimeout = 900000000;
                datos = dbeAuction.ExecuteDataSet(spConsultarNotificaciones);
                if (datos.Tables[0].Rows.Count > 0)
                {
                    clientes = datos.Tables[0];
                }

                return(clientes);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(string.Format("AuctionGas ApiWebServices Auditoria: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name));

                throw new Exception((string.Format("AuctionGas ApiWebServices Auditoria: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name)));
            }
        }
예제 #7
0
        /// <summary>
        /// for getting integer result form database
        /// </summary>
        /// <param name="dom"></param>
        /// <returns></returns>
        public static int ExecuteScalarforInt(XDocument dom, string ConnectionStr)
        {
            try
            {
                Database               db = new Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase(ConnectionStr);
                DbParameter            parameter;
                DbCommand              cmd;
                IEnumerable <XElement> elems;
                IEnumerable <XElement> elem_list;
                string Procname = GetProcName(dom);
                cmd = db.GetStoredProcCommand(Procname);
                SetCommandTimeOut(cmd);
                elems     = dom.Descendants();
                elem_list = from elem in elems
                            select elem;
                foreach (XElement element in elem_list)
                {
                    parameter = cmd.CreateParameter();
                    if (element.Name.ToString() != "BIC" && element.Name.ToString() != "XsdName" && element.Name.ToString() != "procName" && element.Name.ToString() != "pERRORXML")
                    {
                        parameter.ParameterName = "@" + element.Name.ToString();
                        parameter.Value         = element.Value;
                        cmd.Parameters.Add(parameter);
                    }
                }

                int retval = Convert.ToInt32(db.ExecuteScalar(cmd));
                return(retval);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #8
0
        public static bool CreateToken(Token tokenObj)
        {
            bool InsertBDok = false;

            try
            {
                var ConectStr = ConfigurationSettings.AppSettings["ConectionAuction"];
                ConectStr = ConectStr.Replace("USER", tokenObj.UserName); //testgas1
                ConectStr = ConectStr.Replace("PASS", tokenObj.Password); //test12345
                                                                          //  Database dbeAuction = DatabaseFactory.CreateDatabase(a);
                Database dbeAuction = new Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase(ConectStr);
                // Crear objeto SP
                DbCommand spUsuarios = dbeAuction.GetStoredProcCommand("SP_USUARIOS");

                dbeAuction.AddInParameter(spUsuarios, "@i_operation", DbType.String, "IU");
                dbeAuction.AddInParameter(spUsuarios, "@i_option", DbType.String, "A");
                dbeAuction.AddInParameter(spUsuarios, "@UserId", DbType.String, tokenObj.IdUser);
                dbeAuction.AddInParameter(spUsuarios, "@UserName", DbType.String, tokenObj.UserName);
                dbeAuction.AddInParameter(spUsuarios, "@AuthToken", DbType.String, tokenObj.AuthToken);
                dbeAuction.AddInParameter(spUsuarios, "@Password", DbType.String, tokenObj.Password);


                dbeAuction.ExecuteNonQuery(spUsuarios);
                InsertBDok = true;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(string.Format("AuctionGas ApiWebServices Auditoria: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name));

                throw new Exception((string.Format("AuctionGas ApiWebServices Auditoria: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name)));
            }

            return(InsertBDok);
        }
예제 #9
0
        /// <summary>
        /// For getting xml from database
        /// </summary>
        /// <param name="dom"></param>
        /// <returns></returns>
        public static string GetXml(XDocument dom, string ConnectionStr)
        {
            try
            {
                Database               db = new Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase(ConnectionStr);
                DbParameter            parameter;
                DbCommand              cmd;
                IEnumerable <XElement> elems;
                IEnumerable <XElement> elem_list;
                string Procname = GetProcName(dom);
                cmd = db.GetStoredProcCommand(Procname);
                SetCommandTimeOut(cmd);
                string OutParameterName = "";

                elems     = dom.Descendants();
                elem_list = from elem in elems
                            select elem;
                foreach (XElement element in elem_list)
                {
                    parameter = cmd.CreateParameter();
                    if (element.Name.ToString() != "BIC" && element.Name.ToString() != "XsdName" && element.Name.ToString() != "procName" && element.Name.ToString() != "pFILESDATA")
                    {
                        OutParameterName        = element.Name.ToString();
                        parameter.ParameterName = "@" + element.Name.ToString();
                        if (element.Name.ToString().Trim() == "pERRORXML")
                        {
                            parameter.DbType    = DbType.Xml;
                            parameter.Direction = ParameterDirection.Output;
                        }
                        else
                        {
                            parameter.Value     = element.Value;
                            parameter.Direction = ParameterDirection.Input;
                        }

                        cmd.Parameters.Add(parameter);
                    }
                }

                db.ExecuteNonQuery(cmd);
                var retval = db.GetParameterValue(cmd, "@pERRORXML");
                return(Convert.ToString(retval));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #10
0
        /// <summary>
        /// Reads the application connection   string from Config database
        /// </summary>
        /// <param name="connectionStringID">value of connectionStringID</param>
        /// <returns>application connection   string</returns>
        private static string GetApplicationConnectionStringFromDB(string connectionStringID)
        {
            string configDatabaseConnectionString = null;
            string applicationConnectionString    = null;

            configDatabaseConnectionString = GetDatabaseConnectionStringFromRegistry(CONFIGSDATABASEKEY);

            Database database = new Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase(configDatabaseConnectionString);

            using (DbCommand cmd = database.GetStoredProcCommand(CONFIGURATIONCONNECTIONSTRINGGET))
            {
                database.AddInParameter(cmd, "@connectionStringKey", DbType.AnsiString, connectionStringID);
                database.AddOutParameter(cmd, "@connectionStringValue", DbType.AnsiString, 8000);
                database.ExecuteNonQuery(cmd);
                applicationConnectionString = (string)database.GetParameterValue(cmd, "@connectionStringValue");
            }

            return(applicationConnectionString);
        }
예제 #11
0
        public static DataTable SearchParams(Params paramsobj)
        {
            DataSet   datos;
            DataTable parametros   = new DataTable();
            string    tipoConsulta = "A";

            try
            {
                var      ConectStr  = Tools.ConectionNow.BuildConection(paramsobj.User);
                Database dbeAuction = new Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase(ConectStr);
                //  Database dbeAuction = DatabaseFactory.CreateDatabase("Auction");
                // Crear objeto SP
                DbCommand spParametros = dbeAuction.GetStoredProcCommand("SP_PARAMETROS");
                if (!String.IsNullOrEmpty(paramsobj.NombreParametro))
                {
                    tipoConsulta = "B";
                }

                dbeAuction.AddInParameter(spParametros, "@i_operation", DbType.String, "S");
                dbeAuction.AddInParameter(spParametros, "@i_option", DbType.String, tipoConsulta);
                dbeAuction.AddInParameter(spParametros, "@NombreParametro", DbType.String, paramsobj.NombreParametro);
                spParametros.CommandTimeout = 900000000;
                datos = dbeAuction.ExecuteDataSet(spParametros);
                if (datos.Tables[0].Rows.Count > 0)
                {
                    parametros = datos.Tables[0];
                }


                return(parametros);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(string.Format("AuctionGas ApiWebServices Auditoria: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name));
                throw new Exception((string.Format("AuctionGas ApiWebServices Auditoria: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name)));
            }
        }
예제 #12
0
        public static int InsertLogGas(GasLog gasobj)
        {
            int       datos;
            DataTable clientes = new DataTable();

            try
            {
                var      ConectStr = Tools.ConectionNow.BuildConection(gasobj.User);
                Database dbAuction = new Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase(ConectStr);
                //  Database dbeAuction = DatabaseFactory.CreateDatabase("Auction");
                // Crear objeto SP
                DbCommand spInsertarLog = dbAuction.GetStoredProcCommand("SP_GASLOG");

                dbAuction.AddInParameter(spInsertarLog, "@i_operation", DbType.String, "I");
                dbAuction.AddInParameter(spInsertarLog, "@i_option", DbType.String, "A");
                dbAuction.AddInParameter(spInsertarLog, "@Descripcion", DbType.String, gasobj.Descripcion);
                dbAuction.AddInParameter(spInsertarLog, "@NombreUsuario", DbType.String, gasobj.NombreUsuario);
                dbAuction.AddInParameter(spInsertarLog, "@IdUsuario", DbType.Int16, gasobj.IdUsuario);
                dbAuction.AddInParameter(spInsertarLog, "@TipoMovimiento", DbType.String, gasobj.Descripcion);
                dbAuction.AddInParameter(spInsertarLog, "@IdTipoAccion", DbType.Int16, gasobj.IdTipoAccion);
                dbAuction.AddInParameter(spInsertarLog, "@Nombre", DbType.String, gasobj.Nombre);
                dbAuction.AddInParameter(spInsertarLog, "@EstadoTrans", DbType.Boolean, gasobj.EstadoTransaccion);

                spInsertarLog.CommandTimeout = 900000000;
                datos = dbAuction.ExecuteNonQuery(spInsertarLog);


                return(datos);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(string.Format("AuctionGas ApiWebServices Auditoria: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name));

                throw new Exception("Excepcion en la funcion LogGas" + ex.StackTrace);
            }
        }
예제 #13
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method gets a sproc from the database and loads it into a generic
        /// method.  The results can be added to the stored procedure cache, if specified.</summary>
        ///
        /// <param name="sprocName">Name of the stored procedure to get.</param>
        /// <param name="addSprocToCache">Flag indicating whether to add sproc method to cache.</param>
        ///
        /// <returns>A stored procedure from the db as a GenericMethod.</returns>
        ///--------------------------------------------------------------------------------
        public GenericMethod GetSprocFromDB(string sprocName, bool addSprocToCache)
        {
            GenericMethod sprocMethod = null;

            try
            {
                // go to the database to retrieve the sproc
                DbCommand command        = _database.GetStoredProcCommand("sp_sproc_columns");
                string    sprocShortName = sprocName.Replace("[", "").Replace("]", "");
                if (sprocShortName.IndexOf('.') > 0)
                {
                    sprocShortName = sprocShortName.Substring(sprocShortName.IndexOf('.') + 1);
                }
                _database.AddInParameter(command, "@procedure_name", DbType.String, sprocShortName);
                command.Connection     = Connection;
                command.CommandTimeout = DBOptions.CommandTimeout;
                IDataReader dbSproc   = _database.ExecuteReader(command);
                bool        foundRows = false;
                // add sproc parameters to method
                while (dbSproc.Read())
                {
                    if (foundRows == false)
                    {
                        // create the method with sproc name
                        sprocMethod                     = new GenericMethod();
                        sprocMethod.MethodName          = sprocName;
                        sprocMethod.MethodParameterList = new SortableDataObjectList <GenericParameter>();
                        foundRows = true;
                    }
                    GenericParameter sprocParameter = new GenericParameter();
                    sprocParameter.ParameterName = dbSproc["COLUMN_NAME"].GetString();
                    if (sprocParameter.ParameterName.StartsWith("@") == true)
                    {
                        sprocParameter.ParameterName = sprocParameter.ParameterName.Substring(1);
                    }
                    sprocParameter.ParameterTypeCode = dbSproc["COLUMN_TYPE"].GetInt();
                    sprocParameter.DataTypeCode      = dbSproc["DATA_TYPE"].GetInt();
                    sprocParameter.DataTypeName      = dbSproc["TYPE_NAME"].GetString();
                    sprocParameter.Precision         = dbSproc["PRECISION"].GetInt();
                    sprocParameter.Size       = dbSproc["LENGTH"].GetInt();
                    sprocParameter.IsNullable = dbSproc["NULLABLE"].GetBool();
                    sprocParameter.Order      = dbSproc["ORDINAL_POSITION"].GetInt();
                    sprocMethod.MethodParameterList.Add(sprocParameter);
                }
                dbSproc.Close();

                if (foundRows == true)
                {
                    if (addSprocToCache == true)
                    {
                        // add sproc to the cache
                        DbProcs.MethodList.Add(sprocMethod);
                    }
                }
                else
                {
                    // sproc not found, throw exception
                    throw new System.Exception("MoPlus.Data.BuildSprocParamsWithInputValues - stored procedure" + sprocName + " not found in database.");
                }
            }
            catch (Exception ex)
            {
                bool reThrow = ExceptionHandler.HandleException(ex);
                if (reThrow)
                {
                    throw;
                }
            }

            return(sprocMethod);
        }
예제 #14
0
        public static DataTable SearchLog(GasLogSearch search)
        {
            DataSet   dsDatos;
            DataTable dtDatos = new DataTable();

            try
            {
                //Database dbAuction = DatabaseFactory.CreateDatabase("Auction");

                var      ConectStr = Tools.ConectionNow.BuildConection(search.User);
                Database dbAuction = new Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabase(ConectStr);


                // Crear objeto SP
                DbCommand spConsultarLog = dbAuction.GetStoredProcCommand("SP_GASLOG");

                dbAuction.AddInParameter(spConsultarLog, "@i_operation", DbType.String, "S");
                dbAuction.AddInParameter(spConsultarLog, "@i_option", DbType.String, "A");
                if (search.IdUsuario > 0)
                {
                    dbAuction.AddInParameter(spConsultarLog, "@IdUsuario", DbType.Int16, search.IdUsuario);
                }
                if (search.IdTipoAccion > 0)
                {
                    dbAuction.AddInParameter(spConsultarLog, "@IdTipoAccion", DbType.Int16, search.IdTipoAccion);
                }

                if (search.FechaInicio != null && search.FechaInicio.Length > 0)
                {
                    string   fechain = search.FechaInicio.Substring(0, 10) + " 00:00";
                    DateTime ffin    = Convert.ToDateTime(fechain);
                    dbAuction.AddInParameter(spConsultarLog, "@FechaInicio", DbType.DateTime, ffin);
                }
                if (search.FechaFin != null && search.FechaFin.Length > 0)
                {
                    string   fechaout = search.FechaFin.Substring(0, 10) + " 23:59";
                    DateTime ffout    = Convert.ToDateTime(fechaout);
                    dbAuction.AddInParameter(spConsultarLog, "@FechaFin", DbType.DateTime, ffout);
                }
                if (search.EstadoTransaccion != null && search.EstadoTransaccion.Trim().Length > 0)
                {
                    dbAuction.AddInParameter(spConsultarLog, "@EstadoTrans", DbType.Boolean, search.EstadoTransaccion == "SI" ? true: false);
                }

                spConsultarLog.CommandTimeout = 900000000;
                dsDatos = dbAuction.ExecuteDataSet(spConsultarLog);
                if (dsDatos.Tables[0].Rows.Count > 0)
                {
                    dtDatos = dsDatos.Tables[0];
                }
                //return datos;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(string.Format("AuctionGas ApiWebServices Auditoria: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name));

                throw new Exception("Excepcion en la funcion LogGas" + ex.StackTrace);
            }

            return(dtDatos);
        }