Beispiel #1
0
        public static bool SetUserWealthBuffer()
        {
            try
            {
                if (mapUserWealth == null)
                    mapUserWealth = new Dictionary<int, UserWealth>();
                else
                    mapUserWealth.Clear();

                if (sqlConn.State == ConnectionState.Closed)
                    sqlConn.Open();

                sqlCmd = new SqlCommand("GetUserWealth" + playId, sqlConn);
                sqlReader = sqlCmd.ExecuteReader();
                while (sqlReader.Read())
                {
                    UserWealth userWealth = new UserWealth();
                    userWealth.Initialize();
                    userWealth.UserID = Convert.ToInt32(sqlReader["UserID"]);
                    userWealth.RMB = Convert.ToDecimal(sqlReader["WealthRMB"]);
                    userWealth.USD = Convert.ToDecimal(sqlReader["WealthUSD"]);
                    userWealth.HKD = Convert.ToDecimal(sqlReader["WealthHKD"]);

                    if (!mapUserWealth.ContainsKey(userWealth.UserID))
                    {
                        mapUserWealth.Add(userWealth.UserID, userWealth);
                    }
                }
                sqlReader.Close();

                Common.Log("mapUserWealth 加载成功.数目[" + mapUserWealth.Count.ToString() + "]");

                if (!GetDataSetUserWealth())
                {
                    Log("mapUserWealth DataSet转换失败");
                    return false;
                }
                else
                {
                    Log("mapUserWealth DataSet转换成功");
                }
                return true;
            }
            catch (Exception err)
            {
                Common.Log(err.ToString());
                return false;
            }
            finally
            {
                if (sqlConn.State != ConnectionState.Closed)
                    sqlConn.Close();
            }
        }
Beispiel #2
0
        public static bool SetUserWealthBuffer()
        {
            try
            {
                if (mapUserWealth == null)
                {
                    mapUserWealth = new Dictionary <int, UserWealth>();
                }
                else
                {
                    mapUserWealth.Clear();
                }

                if (sqlConn.State == ConnectionState.Closed)
                {
                    sqlConn.Open();
                }

                sqlCmd    = new SqlCommand("GetUserWealth" + playId, sqlConn);
                sqlReader = sqlCmd.ExecuteReader();
                while (sqlReader.Read())
                {
                    UserWealth userWealth = new UserWealth();
                    userWealth.Initialize();
                    userWealth.UserID = Convert.ToInt32(sqlReader["UserID"]);
                    userWealth.RMB    = Convert.ToDecimal(sqlReader["WealthRMB"]);
                    userWealth.USD    = Convert.ToDecimal(sqlReader["WealthUSD"]);
                    userWealth.HKD    = Convert.ToDecimal(sqlReader["WealthHKD"]);

                    if (!mapUserWealth.ContainsKey(userWealth.UserID))
                    {
                        mapUserWealth.Add(userWealth.UserID, userWealth);
                    }
                }
                sqlReader.Close();

                Common.Log("mapUserWealth 加载成功.数目[" + mapUserWealth.Count.ToString() + "]");

                if (!GetDataSetUserWealth())
                {
                    Log("mapUserWealth DataSet转换失败");
                    return(false);
                }
                else
                {
                    Log("mapUserWealth DataSet转换成功");
                }
                return(true);
            }
            catch (Exception err)
            {
                Common.Log(err.ToString());
                return(false);
            }
            finally
            {
                if (sqlConn.State != ConnectionState.Closed)
                {
                    sqlConn.Close();
                }
            }
        }