/// <summary>
    /// 复活继续
    /// </summary>
    /// <param name="clientId">int 客户端编号</param>
    /// <param name="isSkip">bool 是否跳过</param>
    /// <returns>int 受影响的行数</returns>
    public static int Revive(int clientId, bool isSkip)
    {
        string sql = "UPDATE tc_client SET lives=lives-@1,status=0 WHERE clientId=@0";

        using (MySqlADO ado = new MySqlADO())
        {
            return(ado.NonQuery(sql, clientId, (isSkip ? 1: 0)));
        }
    }
    /// <summary>
    /// 重新开始
    /// </summary>
    /// <param name="clientId">int 客户端编号</param>
    /// <returns>int 受影响的行数</returns>
    public static int Restart(int clientId)
    {
        string sql = "UPDATE tc_client SET score=0,status=0 WHERE clientId=@0";

        using (MySqlADO ado = new MySqlADO())
        {
            return(ado.NonQuery(sql, clientId));
        }
    }
    /// <summary>
    /// 激活复活卡
    /// </summary>
    /// <param name="clientId">int 客户端编号</param>
    /// <returns>int 受影响的行数</returns>
    public static int Activate(int clientId)
    {
        string sql = "UPDATE tc_client SET lives=lives+1 WHERE clientId=@0 ";

        using (MySqlADO ado = new MySqlADO())
        {
            return(ado.NonQuery(sql, clientId));
        }
    }
    /// <summary>
    /// 设置客户端资料
    /// </summary>
    /// <param name="clientId">int 客户端编号</param>
    /// <param name="nick">string 昵称</param>
    /// <param name="gender">int 性别</param>
    /// <param name="avatarUrl">string 头像图片</param>
    /// <returns>int 受影响的行数</returns>
    public static int SetUserInfo(int clientId, string nick, int gender, string avatarUrl)
    {
        string sql = "UPDATE tc_client SET nick=@1,gender=@2,avatarUrl=@3,lives=IF(IFNULL(actived,0)=0,2,lives),actived=1 WHERE clientId=@0";

        using (MySqlADO ado = new MySqlADO())
        {
            return(ado.NonQuery(sql, clientId, nick, gender, avatarUrl));
        }
    }
Exemple #5
0
    /// <summary>
    /// 创建群关系条目
    /// </summary>
    /// <param name="clientId">int 客户端编号</param>
    /// <param name="openGId">string 群标识</param>
    /// <returns>int 受影响的行数</returns>
    public static int Create(int clientId, string openGId)
    {
        string sql = "INSERT INTO tc_client_group (clientId, openGId) VALUES(@0, @1) ON DUPLICATE KEY UPDATE clientId=VALUES(clientId), openGId=VALUES(openGId), updateTime=Now()";

        using (MySqlADO ado = new MySqlADO())
        {
            return(ado.NonQuery(sql, clientId, openGId));
        }
    }
    /// <summary>
    /// 分享记录
    /// </summary>
    /// <param name="clientId">int 客户端编号</param>
    /// <param name="shareFrom">string 分享来源</param>
    /// <returns>int 受影响的行数</returns>
    public static int Create(int clientId, string shareFrom)
    {
        string sql = "INSERT INTO tc_client_share (clientId, shareFrom) VALUES(@0, @1)";

        using (MySqlADO ado = new MySqlADO())
        {
            return(ado.NonQuery(sql, clientId, shareFrom));
        }
    }
    /// <summary>
    /// 设置配置项目
    /// </summary>
    /// <param name="key">string 键名</param>
    /// <param name="value">string 键值</param>
    /// <returns>int 受影响的行数</returns>
    public static int SetItem(string key, string value)
    {
        string sql = "UPDATE tz_setting SET `value`=@1 WHERE `key`=@0";

        using (MySqlADO ado = new MySqlADO())
        {
            return(ado.NonQuery(sql, key, value));
        }
    }
Exemple #8
0
    /// <summary>
    /// 复活继续
    /// </summary>
    /// <param name="clientId">int 客户端编号</param>
    /// <returns>int 受影响的行数</returns>
    public static int Continue(int clientId)
    {
        string sql = "UPDATE tc_client SET cards=cards-1,status=0 WHERE clientId=@0";

        using (MySqlADO ado = new MySqlADO())
        {
            return(ado.NonQuery(sql, clientId));
        }
    }
    /// <summary>
    /// 创建关系条目
    /// </summary>
    /// <param name="fromClientId">int 邀请客户端编号</param>
    /// <param name="toClientId">int 被邀请客户端编号</param>
    /// <param name="relateType">RelateType 关系类型</param>
    /// <returns>int 受影响的行数</returns>
    public static int Create(int fromClientId, int toClientId, RelateType relateType)
    {
        string sql = "INSERT INTO tc_client_relate (fromClientId, toClientId, relateType, openGId) VALUES(@0, @1, @2, @3) ON DUPLICATE KEY UPDATE fromClientId=VALUES(fromClientId), toClientId=VALUES(toClientId), relateType=VALUES(relateType), openGId=VALUES(openGId), updateTime=Now()";

        using (MySqlADO ado = new MySqlADO())
        {
            return(ado.NonQuery(sql, fromClientId, toClientId, (int)relateType, String.Empty));
        }
    }
    /// <summary>
    /// 更新关系条目
    /// </summary>
    /// <param name="fromClientId">int 邀请客户端编号</param>
    /// <param name="toClientId">int 被邀请客户端编号</param>
    /// <param name="relateType">RelateType 关系类型</param>
    /// <returns>int 受影响的行数</returns>
    public static int Update(int fromClientId, int toClientId, RelateType relateType)
    {
        string sql = "UPDATE tc_client_relate SET relateType=IF(relateType>@2,@2,relateType) WHERE fromClientId=@0 AND toClientId=@1 ";

        using (MySqlADO ado = new MySqlADO())
        {
            return(ado.NonQuery(sql, fromClientId, toClientId, (int)relateType));
        }
    }
    /// <summary>
    /// 清空记录
    /// </summary>
    /// <param name="clientId">int 客户端编号</param>
    /// <returns>int 受影响的行数</returns>
    public static int Clear(int clientId)
    {
        string sql = "DELETE FROM tc_client_question WHERE clientId=@0";

        using (MySqlADO ado = new MySqlADO())
        {
            return(ado.NonQuery(sql, clientId));
        }
    }
    /// <summary>
    /// 重新开始
    /// </summary>
    /// <param name="clientId">int 客户端编号</param>
    /// <returns>int 受影响的行数</returns>
    public static int Restart(int clientId)
    {
        string sql = "DELETE FROM tc_client_dinosaur WHERE clientId=@0";

        using (MySqlADO ado = new MySqlADO())
        {
            return(ado.NonQuery(sql, clientId));
        }
    }
Exemple #13
0
    /// <summary>
    /// 激活复活卡
    /// </summary>
    /// <param name="clientId">int 客户端编号</param>
    /// <param name="toClientId">int 激活客户端编号</param>
    /// <param name="openGId">string 群标识</param>
    /// <returns>int 受影响的行数</returns>
    public static int Activate(int clientId, int toClientId, string openGId)
    {
        string sql = "INSERT INTO tc_client_live (clientId,toClientId,openGId) VALUES(@0,@1,@2)";

        using (MySqlADO ado = new MySqlADO())
        {
            return(ado.NonQuery(sql, clientId, toClientId, openGId));
        }
    }
    /// <summary>
    /// 答题结果
    /// </summary>
    /// <param name="clientId">int 客户端编号</param>
    /// <param name="questionId">int 题目编号</param>
    /// <param name="result">ResultType 答题结果</param>
    /// <returns>int 受影响的行数</returns>
    public static int Answer(int clientId, int questionId, ResultType result)
    {
        string sql = "UPDATE tc_client_question SET result=@2 WHERE clientId=@0 AND questionId=@1";

        using (MySqlADO ado = new MySqlADO())
        {
            return(ado.NonQuery(sql, clientId, questionId, (int)result));
        }
    }
Exemple #15
0
    /// <summary>
    /// 分享记录
    /// </summary>
    /// <param name="clientId">int 客户端编号</param>
    /// <param name="shareFrom">string 分享来源</param>
    /// <param name="shareAction">string 分享目的</param>
    /// <param name="shareQuestionId">int 分享题目编号</param>
    /// <returns>int 受影响的行数</returns>
    public static int Create(int clientId, string shareFrom, string shareAction, int shareQuestionId)
    {
        string sql = "INSERT INTO tc_client_share (clientId, shareFrom, shareAction, shareQuestionId) VALUES(@0, @1, @2, @3)";

        using (MySqlADO ado = new MySqlADO())
        {
            return(ado.NonQuery(sql, clientId, shareFrom, shareAction, shareQuestionId));
        }
    }
    /// <summary>
    /// 准备答题
    /// </summary>
    /// <param name="clientId">int 客户端编号</param>
    /// <param name="questionId">int 题目编号</param>
    /// <returns>int 受影响的行数</returns>
    public static int Ready(int clientId, int questionId)
    {
        string sql = "INSERT INTO tc_client_question (clientId,questionId,result) VALUES(@0,@1,0) " +
                     "ON DUPLICATE KEY UPDATE clientId=VALUES(clientId),questionId=VALUES(questionId),result=VALUES(result)";

        using (MySqlADO ado = new MySqlADO())
        {
            return(ado.NonQuery(sql, clientId, questionId));
        }
    }
    /// <summary>
    /// 答题结果
    /// </summary>
    /// <param name="clientId">int 客户端编号</param>
    /// <param name="dinosaurId">int 题目编号</param>
    /// <param name="result">int 答题结果</param>
    /// <returns>int 受影响的行数</returns>
    public static int Answer(int clientId, int dinosaurId, int result)
    {
        string sql = "INSERT INTO tc_client_dinosaur (clientId,dinosaurId,result) " +
                     "VALUES(@0,@1,@2) " +
                     "ON DUPLICATE KEY UPDATE clientId=VALUES(clientId),dinosaurId=VALUES(dinosaurId),result=VALUES(result),createTime=Now()";

        using (MySqlADO ado = new MySqlADO())
        {
            return(ado.NonQuery(sql, clientId, dinosaurId, result));
        }
    }
    /// <summary>
    /// 创建新用户
    /// </summary>
    /// <param name="clientId">int 客户端编号</param>
    /// <param name="openId">string 微信标识</param>
    /// <param name="sessionKey">string 微信会话标识</param>
    /// <param name="session3rd">string 三方会话标识</param>
    /// <returns>int 受影响的行数</returns>
    public static int Create(int clientId, string openId, string sessionKey, string session3rd)
    {
        string sql = "INSERT INTO tc_client (clientId,openId,sessionKey,session3rd) " +
                     "VALUES(@0,@1,@2,@3) " +
                     "ON DUPLICATE KEY UPDATE openId=VALUES(openId),sessionKey=VALUES(sessionKey),session3rd=VALUES(session3rd),updateTime=Now()";

        using (MySqlADO ado = new MySqlADO())
        {
            return(ado.NonQuery(sql, clientId, openId, sessionKey, session3rd));
        }
    }
Exemple #19
0
    /// <summary>
    /// 更新群关系条目
    /// </summary>
    /// <param name="openGId">string 群标识</param>
    /// <returns>int 受影响的行数</returns>
    public static int Renovate(string openGId)
    {
        string sql = "INSERT INTO tc_client_relate(fromClientId, toClientId, relateType, openGId) " +
                     "SELECT a.clientId, b.clientId,@1,@0 FROM tc_client_group a, tc_client_group b " +
                     "WHERE a.openGId=@0 AND b.openGId=@0 AND a.clientId!=b.clientId AND NOT EXISTS ( " +
                     "   SELECT * FROM tc_client_relate WHERE fromClientId=a.clientId and toClientId = b.clientId " +
                     ") ";

        using (MySqlADO ado = new MySqlADO())
        {
            return(ado.NonQuery(sql, openGId, (int)RelateType.FromGroup));
        }
    }
Exemple #20
0
    /// <summary>
    /// 答题结果
    /// </summary>
    /// <param name="clientId">int 客户端编号</param>
    /// <param name="result">int 答题结果</param>
    /// <returns>int 受影响的行数</returns>
    public static int Answer(int clientId, int result)
    {
        string sql = "UPDATE tc_client SET " +
                     "   duration=(SELECT COUNT(*) FROM tc_client_dinosaur WHERE clientId=@0 AND result=1), " +
                     "   score=IF(@1=1,score+1,score), " +
                     "   status=IF(@1=1,0,200) " +
                     "WHERE clientId=@0";

        using (MySqlADO ado = new MySqlADO())
        {
            return(ado.NonQuery(sql, clientId, result));
        }
    }
    /// <summary>
    /// 更新得分
    /// </summary>
    /// <param name="clientId">int 客户端编号</param>
    /// <param name="questionId">int 题目</param>
    /// <param name="degree">int 难度等级</param>
    /// <param name="result">ResultType 答题结果 [ 1 - 正确, 2 - 错误, 3 - 跳过 ]</param>
    /// <returns>int 受影响的行数</returns>
    public static int Score(int clientId, int questionId, int degree, ResultType result)
    {
        string sql = "UPDATE tc_client SET status=status WHERE clientId=@0";

        if (result == ResultType.Correct)
        {
            sql = "UPDATE tc_client SET score=score+@1 WHERE clientId=@0";
        }
        if (result == ResultType.Incorrect)
        {
            sql = "UPDATE tc_client SET status=200 WHERE clientId=@0";
        }
        using (MySqlADO ado = new MySqlADO())
        {
            return(ado.NonQuery(sql, clientId, degree));
        }
    }