public int Execute(string sql, object paramPairs = null) { var conn = MysqlConnectionPool.getInstance().getConnection(); if (conn.State != ConnectionState.Open) { conn.Open(); } var result = conn.Execute(sql, paramPairs); MysqlConnectionPool.getInstance().releaseConnection(conn); return(result); }
public long Count(string sql, object paramPairs = null) { var conn = MysqlConnectionPool.getInstance().getConnection(); if (conn.State != ConnectionState.Open) { conn.Open(); } var result = conn.Query <long>(sql, paramPairs).SingleOrDefault(); MysqlConnectionPool.getInstance().releaseConnection(conn); return(result); }
public bool IsExist(string sql) { try { var conn = MysqlConnectionPool.getInstance().getConnection(); if (conn.State != ConnectionState.Open) { conn.Open(); } var result = conn.ExecuteScalar(sql) != null; MysqlConnectionPool.getInstance().releaseConnection(conn); return(result); } catch (Exception e) { log.Error(e.Message); throw; } }
public T QueryBuild <T>(Func <IDbConnection, T> callback) where T : class { try { var conn = MysqlConnectionPool.getInstance().getConnection(); if (conn.State != ConnectionState.Open) { conn.Open(); } var result = callback(conn); MysqlConnectionPool.getInstance().releaseConnection(conn); return(result); } catch (Exception e) { log.Error(e.Message); throw; } }
public void Initialize() { m_bStart = false; // the action stops at the beginning m_szIP = "192.168.1.3"; // modbus slave IP address m_iPort = 502; // modbus TCP port is 502 adamModbus = new AdamSocket(); adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP adamModbus.AdamSeriesType = AdamType.Adam6200; // set AdamSeriesType for ADAM-6217 m_Adam6000Type = Adam6000Type.Adam6217; // the sample is for ADAM-6217 m_iAiTotal = AnalogInput.GetChannelTotal(m_Adam6000Type); //channel number m_bChEnabled = new bool[m_iAiTotal]; m_byRange = new ushort[m_iAiTotal]; fValue = new float[m_iAiTotal]; pool = new MysqlConnectionPool(); Connect2Adam(); }