Exemplo n.º 1
0
        // 返回玩家反馈消息
        public async Task <GMGetFanKuiList> GetCharacterFanKuiAsync(string TimeBegin, string TimeEnd, int StartIndex, int EndIndex, int State)
        {
            var result = new GMGetFanKuiList();

            result.FanKuiList.Clear();
            var sql = string.Format("SELECT * FROM giftcodedb.question where createtime >= '{0}' and createtime <= '{1}' and state = {2} limit {3},{4};",
                                    TimeBegin, TimeEnd, State, StartIndex, EndIndex);
            MySqlConnection conn   = null;
            MySqlDataReader reader = null;

            try
            {
                conn = CheckConnection();
                using (var cmd = conn.CreateCommand())
                {
                    cmd.CommandText = sql;
                    cmd.CommandType = CommandType.Text;
                    using (reader = cmd.ExecuteReader())
                    {
                        if (reader != null)
                        {
                            while (reader.Read())
                            {
//                                 result += " CharacterId: " + reader.GetUInt32("ById").ToString();
//                                 result += " CharacterName: " + reader.GetString("ByName");
//                                 result += " Title: " + reader.GetString("Title");
//                                 result += " Content: " + reader.GetString("Text");
//                                 result += " createTime: " + reader.GetString("createtime");
//                                 result += " state " + reader.GetInt16("state") + ";   ";
                                var tmp = new GMGetFanKui();
                                tmp.Id          = reader.GetUInt32("id");
                                tmp.CharacterId = reader.GetInt64("ById");
                                tmp.Name        = reader.GetString("ByName");
                                tmp.Title       = reader.GetString("Title");
                                tmp.Content     = reader.GetString("Text");
                                tmp.CreateTime  = reader.GetString("createtime");
                                tmp.State       = reader.GetInt32("state");
                                result.FanKuiList.Add(tmp);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("GetCharacterFanKuiAsync error !! {0}", ex);
                return(result);
            }
            finally
            {
                if (conn != null)
                {
                    mConnections.Push(conn);
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        // 修改玩家反馈消息状态
        public async Task <GMGetFanKuiList> SetCharacterFanKuiStateAsync(List <int> Ids, int State)
        {
            var result = new GMGetFanKuiList();

            result.FanKuiList.Clear();

            var ids = string.Empty;

            for (int i = 0; i < Ids.Count; i++)
            {
                if (i != Ids.Count - 1)
                {
                    ids = ids + Ids[i] + ",";
                }
                else
                {
                    ids = ids + Ids[i];
                }
            }

            var             sql    = string.Format("Update giftcodedb.question set state = {0} where id IN({1});", State, ids);
            MySqlConnection conn   = null;
            MySqlDataReader reader = null;

            try
            {
                conn = CheckConnection();
                using (var cmd = conn.CreateCommand())
                {
                    cmd.CommandText = sql;
                    cmd.CommandType = CommandType.Text;
                    using (reader = cmd.ExecuteReader())
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("GetCharacterFanKuiAsync error !! {0}", ex);
                return(result);
            }
            finally
            {
                if (conn != null)
                {
                    mConnections.Push(conn);
                }
            }
            return(result);
        }