Пример #1
0
        /// <summary>
        /// 获取区域列表
        /// </summary>
        /// <param name="gameId"></param>
        /// <returns></returns>
        public List<RemotingInterface.AreaInfo> GetAreaList(int gameId)
        {
            SqlConnection sqlConn = new SqlConnection(Common.strConn);
            if (sqlConn.State == ConnectionState.Closed)
                sqlConn.Open();
            try
            {
                if (gameId == 0)
                    return null;

                SqlCommand sqlCmd = new SqlCommand("SELECT * FROM [Area] where GameId=" + gameId + " ORDER BY AreaID", sqlConn);
                SqlDataReader sqlReader = sqlCmd.ExecuteReader();

                List<RemotingInterface.AreaInfo> listArea = new List<RemotingInterface.AreaInfo>();
                RemotingInterface.AreaInfo areaInfo = new RemotingInterface.AreaInfo();
                areaInfo.Clear();

                while (sqlReader.Read())
                {
                    areaInfo.AreaId = Convert.ToInt32(sqlReader["AreaId"]);
                    areaInfo.AreaName = sqlReader["AreaName"].ToString();
                    areaInfo.AreaRegDateStart = Convert.ToDateTime(sqlReader["AreaRegDateStart"]);
                    areaInfo.AreaRegDateEnd = Convert.ToDateTime(sqlReader["AreaRegDateEnd"]);
                    areaInfo.AreaDateStart = Convert.ToDateTime(sqlReader["AreaDateStart"]);
                    areaInfo.AreaDateEnd = Convert.ToDateTime(sqlReader["AreaDateEnd"]);
                    areaInfo.AreaState = Convert.ToByte(sqlReader["AreaState"]);
                    areaInfo.CreateDate = Convert.ToDateTime(sqlReader["CreateDate"]);
                    areaInfo.AreaDescription = sqlReader["AreaDescription"].ToString();

                    if (listArea.Contains(areaInfo))
                        listArea[areaInfo.AreaId] = areaInfo;
                    else
                        listArea.Add(areaInfo);

                    Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ": Load the Area list : GameId = " + gameId + "\t AreaId = " + areaInfo.AreaId + " \t AreaName = " + areaInfo.AreaName);

                }

                return listArea;
            }
            catch (Exception ex)
            {
                Loger.Debug(ex.ToString());
                return null;
            }
            finally
            {
                if (sqlConn.State != ConnectionState.Closed)
                    sqlConn.Close();
            }
        }
Пример #2
0
        /// <summary>
        /// 获取区域列表
        /// </summary>
        /// <param name="gameId"></param>
        /// <returns></returns>
        public List <RemotingInterface.AreaInfo> GetAreaList(int gameId)
        {
            SqlConnection sqlConn = new SqlConnection(Common.strConn);

            if (sqlConn.State == ConnectionState.Closed)
            {
                sqlConn.Open();
            }
            try
            {
                if (gameId == 0)
                {
                    return(null);
                }

                SqlCommand    sqlCmd    = new SqlCommand("SELECT * FROM [Area] where GameId=" + gameId + " ORDER BY AreaID", sqlConn);
                SqlDataReader sqlReader = sqlCmd.ExecuteReader();

                List <RemotingInterface.AreaInfo> listArea = new List <RemotingInterface.AreaInfo>();
                RemotingInterface.AreaInfo        areaInfo = new RemotingInterface.AreaInfo();
                areaInfo.Clear();

                while (sqlReader.Read())
                {
                    areaInfo.AreaId           = Convert.ToInt32(sqlReader["AreaId"]);
                    areaInfo.AreaName         = sqlReader["AreaName"].ToString();
                    areaInfo.AreaRegDateStart = Convert.ToDateTime(sqlReader["AreaRegDateStart"]);
                    areaInfo.AreaRegDateEnd   = Convert.ToDateTime(sqlReader["AreaRegDateEnd"]);
                    areaInfo.AreaDateStart    = Convert.ToDateTime(sqlReader["AreaDateStart"]);
                    areaInfo.AreaDateEnd      = Convert.ToDateTime(sqlReader["AreaDateEnd"]);
                    areaInfo.AreaState        = Convert.ToByte(sqlReader["AreaState"]);
                    areaInfo.CreateDate       = Convert.ToDateTime(sqlReader["CreateDate"]);
                    areaInfo.AreaDescription  = sqlReader["AreaDescription"].ToString();

                    if (listArea.Contains(areaInfo))
                    {
                        listArea[areaInfo.AreaId] = areaInfo;
                    }
                    else
                    {
                        listArea.Add(areaInfo);
                    }

                    Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ": Load the Area list : GameId = " + gameId + "\t AreaId = " + areaInfo.AreaId + " \t AreaName = " + areaInfo.AreaName);
                }

                return(listArea);
            }
            catch (Exception ex)
            {
                Loger.Debug(ex.ToString());
                return(null);
            }
            finally
            {
                if (sqlConn.State != ConnectionState.Closed)
                {
                    sqlConn.Close();
                }
            }
        }