private static DataTable GetEmptyDataTableByNameImp(IDbConnection conn, IDbTransaction transaction, string sTableName) { string sFormat = null; switch (ConnectionManager.Dialect) { case DatabaseDialect.MsSql: sFormat = "SELECT TOP 0 * FROM {0}"; break; case DatabaseDialect.MySql: sFormat = "SELECT * FROM {0} LIMIT 0"; break; case DatabaseDialect.PgSql: sFormat = "SELECT * FROM {0} _LIMIT_ 0"; break; case DatabaseDialect.LtSql: sFormat = "SELECT * FROM {0} LIMIT 0"; break; default: Debug.Assert(false); break; } DataTable dt = DataCopy.GetDataTable(conn, transaction, sFormat, sTableName); //dt = dt.Clone(); return(dt); }
public static PlayerTicket GetTicket(string number, string checksum) { using ( DataTable dt = DataCopy.GetDataTable("SELECT * FROM PlayerTickets WHERE number = '{0}' AND checksum='{1}'", number, checksum)) { return(dt.Rows != null && dt.Rows.Count == 1 ? CreateFromDataRow(dt.Rows[0]) : null); } }
public static List <PlayerSession> GetActivePlayerSessions() { var result = new List <PlayerSession>(); using ( DataTable dt = DataCopy.GetDataTable( "SELECT * FROM PlayerSessions WHERE closed = false ORDER BY PlayerSessionId DESC")) { result.AddRange(from DataRow dr in dt.Rows select CreateFromDataRow(dr)); } return(result); }
public static IList <PlayerTicket> GetTicketsForSession(string sessionId) { var result = new List <PlayerTicket>(); using ( DataTable dt = DataCopy.GetDataTable( "SELECT pt.* FROM PlayerTickets AS pt LEFT JOIN PlayerSessions AS ps ON pt.playersessionid = ps.playersessionid WHERE ps.sessionid ='" + sessionId + "' AND pt.closed = false ORDER BY PlayerTicketId DESC")) { result.AddRange(from DataRow dr in dt.Rows select CreateFromDataRow(dr)); } return(result); }
public static StationAppConfigSr LoadStationAppConfigByQuery(string sQuery) { using (DataTable dt = DataCopy.GetDataTable(sQuery)) { if (dt != null && dt.Rows.Count > 0) { StationAppConfigSr sac = StationAppConfigSr.CreateFromDataRow(dt.Rows[0]); return(sac); } } return(null); }
public static StationAppConfigSr GetValueByName(string propertyName) { using (DataTable dt = DataCopy.GetDataTable("SELECT * FROM StationAppConfig WHERE propertyname = '{0}'", propertyName)) { foreach (DataRow dr in dt.Rows) { StationAppConfigSr sac = StationAppConfigSr.CreateFromDataRow(dr); return(sac); } } return(null); }
public static List <StationAppConfigSr> GetAllSettings() { List <StationAppConfigSr> lResult = new List <StationAppConfigSr>(); using (DataTable dt = DataCopy.GetDataTable("SELECT * FROM StationAppConfig ORDER BY StationAppConfigID")) { foreach (DataRow dr in dt.Rows) { StationAppConfigSr sac = StationAppConfigSr.CreateFromDataRow(dr); lResult.Add(sac); } } return(lResult); }
public void Fill(bool bUseMaxLocalIdentity) { const int SHOW_DUPLICATE_LIMIT = 10; if (string.IsNullOrEmpty(m_sLocalIdColumnName) || string.IsNullOrEmpty(m_sSvrIdColumnName)) { return; } try { using (DataTable dt = DataCopy.GetDataTable(m_dsbc.Connection, m_dsbc.Transaction, "SELECT {0}, {1} FROM {2} WHERE {0} > {3}", m_sLocalIdColumnName, m_sSvrIdColumnName, m_sTableName, bUseMaxLocalIdentity ? m_lMaxLocalIdentity : ERROR_IDENTITY)) //using (DataTable dt = DataCopy.GetDataTable(m_dsbc.Dialect, m_dsbc.Connection, m_dsbc.Transaction, "SELECT {0}, {1} FROM {2}", m_sLocalIdColumnName, m_sSvrIdColumnName, m_sTableName)) { //this.Clear(); ErrorList elDuplicates = new ErrorList(); foreach (DataRow dr in dt.Rows) { FillFromDataRow(dr, elDuplicates); } if (elDuplicates.Count > 0) { m_dsbc.Warnings.AddFormat("Duplicate Server ID(s) found for Table: [{0}], [{1}]: {2}", m_sTableName, m_sSvrIdColumnName, elDuplicates.ToFormatStringWithLimit(", ", SHOW_DUPLICATE_LIMIT)); } // this.Trace(); } } catch (Exception excp) { string sError = string.Format("Error FillIdentityCache ({0}, {1}, {2}, {3})", m_sTableName, m_sLocalIdColumnName, m_sSvrIdColumnName, m_lMaxLocalIdentity); m_logger.ErrorFormat("{0}:\r\n{1}\r\n{2}", excp, sError, excp.Message, excp.StackTrace); throw new System.Exception(sError); } }
public static PlayerSession GetSession(string sessionId) { using ( var dt = DataCopy.GetDataTable("SELECT * FROM PlayerSessions WHERE sessionid = '{0}'", sessionId)) return(dt.Rows != null && dt.Rows.Count == 1 ? CreateFromDataRow(dt.Rows[0]) : null); }