transcation.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package dao
  2. import (
  3. "bet24.com/database"
  4. "bet24.com/log"
  5. "bet24.com/public"
  6. "bet24.com/servers/adminserver/config"
  7. )
  8. var (
  9. CenterDB *database.DataBase
  10. MSDB *database.DataBase
  11. Games []*Transaction_Game
  12. )
  13. func Run() {
  14. CenterDB = database.NewDataBase(
  15. config.Server.Datasource, config.Server.Database,
  16. public.DecryptDBString(config.Server.Login),
  17. public.DecryptDBString(config.Server.Password))
  18. MSDB = database.NewDataBase(
  19. config.Server.Datasource, config.Server.MSDBDatabase,
  20. public.DecryptDBString(config.Server.Login),
  21. public.DecryptDBString(config.Server.Password))
  22. // 创建游戏库
  23. gameCount := len(config.Server.Games)
  24. Games = make([]*Transaction_Game, gameCount)
  25. for i, v := range config.Server.Games {
  26. log.Debug("v.GameID=%d v.Database=%s", v.GameID, v.Database)
  27. Games[i] = NewTransactionGame(v.GameID, v.Datasource, v.Database, v.Login, v.Password)
  28. }
  29. }
  30. // 获取游戏库
  31. func GetGameDB(gameID int) *database.DataBase {
  32. for _, v := range Games {
  33. if gameID == v.GameID {
  34. return v.GameDB
  35. }
  36. }
  37. //log.Release("GetGameDB failed GameID = %d", gameID)
  38. return nil
  39. }