Example #1
0
        public virtual void CreateIPProxy(IPProxy iPProxy)
        {
            try
            {
                Database  database  = DatabaseFactory.CreateDatabase("DatabaseProxy");
                DbCommand dbCommand = database.GetStoredProcCommand("PR_IPProxy_Insert");

                database.AddInParameter(dbCommand, "@IPAddress", DbType.AnsiString, iPProxy.IPAddress);
                database.AddInParameter(dbCommand, "@IPPort", DbType.Int32, iPProxy.IPPort);
                database.AddInParameter(dbCommand, "@StatusIP", DbType.Boolean, iPProxy.StatusIP);
                database.AddInParameter(dbCommand, "@CreateDate", DbType.Int32, iPProxy.CreateDate);
                database.AddOutParameter(dbCommand, "@Id", DbType.Int32, iPProxy.Id);

                database.ExecuteNonQuery(dbCommand);
                iPProxy.Id = (int)database.GetParameterValue(dbCommand, "@Id");
            }
            catch (Exception ex)
            {
                // log this exception
                log4net.Util.LogLog.Error(ex.Message, ex);
                // wrap it and rethrow
                throw new ApplicationException();
            }
        }