Exemple #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);
        }
Exemple #2
0
        // 返回玩家反馈消息
        public AsyncReturnValue <GMGetFanKuiList> GetCharacterFanKuiAsync(Coroutine co, string TimeBegin, string TimeEnd, int StartIndex, int EndIndex, int State, ClientAgentBase agent)
        {
            var ret = AsyncReturnValue <GMGetFanKuiList> .Create();

            ret.Value = new GMGetFanKuiList();

            Task.Run(() =>
            {
                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");
                                    ret.Value.FanKuiList.Add(tmp);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error(ex, "GetCharacterFanKuiAsync error !! {0}");
                }
                finally
                {
                    if (conn != null)
                    {
                        mConnections.Push(conn);
                    }
                    if (!agent.mWaitingEvents.IsAddingCompleted)
                    {
                        agent.mWaitingEvents.Add(new Scorpion.ContinueEvent(co));
                    }
                }
            });
            return(ret);
        }