internal AAvatar OnCreateAvatar(string username, string avatarname, int isex)
    {
        var updateRes = ADatabaseConfigsManager.avatarDB.UpdateOneData(ADatabaseConfigsManager.tAvatarData, ADBAccessor.filter_eq(InfoNameDefs.Username, username)
                                                                       , ADBAccessor.updates_build(
                                                                           ADBAccessor.update(InfoNameDefs.AvatarName, avatarname)
                                                                           )
                                                                       , true);

        if (updateRes)
        {
            var a = new AAvatar(username, avatarname, null);
            OnAddAvatar(a);

            a.OnSetParamValue(InfoNameDefs.AvatarName, avatarname);
            a.OnSetParamValue(InfoNameDefs.AvatarSex, isex);
            return(a);
        }
        return(null);
    }
        public void avatarcreate(string username, string token, string avatarname, string sex)
        {
            avatarname = filtername(avatarname);
            var len = CommonUtil.GetStringLength(avatarname);

            if (len <= 2 || len > 12)
            {
                SendError(ErrorDefs.AvatarNameInvalidLength);
                return;
            }
            var isex = typeParser.intParse(sex);

            if (isex != 0 && isex != 1)
            {
                SendError(ErrorDefs.InvalidSex);
                return;
            }
            var check = CheckToken(username, token);

            if (!check)
            {
                SendError(ErrorDefs.InvalidToken);
                return;
            }
            {
                var a = AAvatarManager.Instance.OnGetAvatar(username);
                if (a != null)
                {
                    SendError(ErrorDefs.AlreadyHasAvatar);
                    return;
                }
            }
            var findRes = dbavatar.FindOneData(TableName, ADBAccessor.filter_eq(InfoNameDefs.AvatarName, avatarname));

            if (findRes != null && findRes.Contains(InfoNameDefs.AvatarName))
            {
                SendError(ErrorDefs.DuplicateAvatarName);
            }
            else
            {
                var updateRes = dbavatar.UpdateOneData(TableName, ADBAccessor.filter_eq(InfoNameDefs.Username, username)
                                                       , ADBAccessor.updates_build(
                                                           ADBAccessor.update(InfoNameDefs.AvatarName, avatarname)
                                                           )
                                                       , true);
                if (updateRes)
                {
                    var a = new AAvatar(username, avatarname, null);
                    AAvatarManager.Instance.OnAddAvatar(a);

                    a.OnSetParamValue(InfoNameDefs.AvatarName, avatarname);
                    a.OnSetParamValue(InfoNameDefs.AvatarSex, isex);
                    a.OnSetParamValue(InfoNameDefs.AvatarMoney, 1000);
                    a.OnSetParamValue(InfoNameDefs.AvatarGold, 1000);
                    SendError(InfoNameDefs.AvatarName, avatarname);
                }
                else
                {
                    SendDBError();
                }
            }
        }