コード例 #1
0
        public string SeleUserInfo()
        {
            string message = "", status = '"' + "200" + '"', msg = '"' + "OK" + '"';

            try
            {
                if (UserLoginInfor._User.U_Birthday == null || UserLoginInfor._User.U_Regtime == null || UserLoginInfor._User.U_Birthday == null)
                {
                    message = '"' + "false" + '"';
                }
                else
                {
                    message = '"' + "true" + '"';
                }
            }
            catch (Exception e)
            {
                status  = '"' + "500" + '"';
                msg     = '"' + "error" + '"';
                message = '"' + "true" + '"';
                error.WriteErrorLog(e, "UserLogin()", "TB_User");
            }
            string ret = "[{" + '"' + "status" + '"' + $":{status},"
                         + '"' + "msg" + '"' + $":{msg}," + '"'
                         + "message" + '"' + $":{message}" + "}]";

            return(ret);
        }
コード例 #2
0
        public string GetMusicTypeName(string typeName)
        {
            string message = "", code = '"' + "200" + '"', msg = '"' + "OK" + '"', total = "";

            try
            {
                string TypeId = "";
                try
                {
                    infor.WriteInforLog("根据类型查询音乐", "GetMusicTypeName()", "TB_Categorys");
                    var _types = db.Queryable <TB_Categorys>().Where(it => it.TypeName.Contains(typeName)).Select(it => it.TypeId);
                    infor.WriteInforLog($"执行的SQL语句为{_types.ToSql()}", "GetMusicTypeName()", "TB_Categorys");
                    TypeId = _types.First();
                }
                catch (Exception e)
                {
                    code    = '"' + "500" + '"';
                    msg     = '"' + "error" + '"';
                    message = '"' + '"' + "";
                    error.WriteErrorLog(e, "GetMusicTypeName()", "TB_Categorys");
                }
                infor.WriteInforLog("根据音乐类型ID查询对应的音乐", "GetMusicTypeName()", "TB_Music");
                var musicNameJson = _sugarTable.Where(it => it.M_Type == TypeId).Distinct();
                infor.WriteInforLog($"执行的SQL语句为{musicNameJson.ToSql()}", "GetMusicTypeName()", "TB_Music");
                message = musicNameJson.ToJson();
                infor.WriteInforLog($"根据音乐类型ID查询对应的音乐的总值:{musicNameJson.Count()}", "GetMusicTypeName()", "TB_Music");
                total = '"' + $"{musicNameJson.Count()}" + '"';
            }
            catch (Exception e)
            {
                code    = '"' + "500" + '"';
                msg     = '"' + "error" + '"';
                message = '"' + '"' + "";
                error.WriteErrorLog(e, "GetMusicTypeName()", "TB_Music");
            }

            return($"[{{" + '"' + "code" + '"' + $":{code}," + '"'
                   + "msg" + '"' + $":{msg}," + '"'
                   + "data" + '"' + $":{message}," + '"' + "Total" + '"' + $":{total}}}]");
        }
コード例 #3
0
        public string GetMusicTypeData()
        {
            string message = "", code = '"' + "200" + '"', msg = '"' + "OK" + '"', total = "";

            try
            {
                infor.WriteInforLog("查询音乐分类", "GetMusicTypeData()", "TB_Categorys");
                var music = _sugarTable.Where(it => it.TypeClass == "TB_Music");
                infor.WriteInforLog($"执行的SQL语句为{music.ToSql()}", "GetMusicTypeData()", "TB_Categorys");
                message = music.ToJson();
                infor.WriteInforLog($"获取音乐分类的总值:{music.Count()}", "GetMusicTypeData()", "TB_Categorys");
                total = '"' + $"{music.Count()}" + '"';
            }
            catch (Exception ex)
            {
                error.WriteErrorLog(ex, "GetMusicTypeData()", "TB_Categorys");
                code    = '"' + "500" + '"';
                msg     = '"' + "error" + '"';
                message = '"' + '"' + "";
            }
            return($"[{{" + '"' + "code" + '"' + $":{code}," + '"'
                   + "msg" + '"' + $":{msg}," + '"'
                   + "data" + '"' + $":{message}," + '"' + "Total" + '"' + $":{total}}}]");
        }
コード例 #4
0
        public string userResgister(string email, string userPass, string code)
        {
            string      message = "", status = '"' + "200" + '"', msg = '"' + "OK" + '"';
            ErrorMethod error = new ErrorMethod();
            InforMethod infor = new InforMethod();
            //if(code!=CODE)
            //{
            //    msg = '"' + "error" + '"';
            //    message = '"' + "验证错误" + '"';
            //    return $"[{{" + '"' + "status" + '"' + $":{status}," + '"'
            //         + "msg" + '"' + $":{msg},"
            //         + '"' + "data" + '"' + ':' + message + "}]";
            //}
            TB_User user = new TB_User();

            user.U_Email = email;
            //验证邮箱是否注册
            var result = _sugarTable.Where(it => it.U_Email.Contains(user.U_Email)).Any();

            if (result)
            {
                infor.WriteInforLog("邮箱已注册", "userResgister", "注册");
                status  = '"' + "200" + '"';
                msg     = '"' + "error" + '"';
                message = '"' + "邮箱已注册" + '"';
                return($"[{{" + '"' + "status" + '"' + $":{status}," + '"'
                       + "msg" + '"' + $":{msg}," + '"'
                       + "captcha" + '"' + ":" + $"{message}" + "}]");
            }
            user.U_PassWord = userPass;
            user.U_ICO      = "https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png";
            Random random = new Random();

            while (true)
            {
                user.U_Id = random.Next(10000000, 100000000);
                if (!_sugarTable.Where(it => it.U_Id == user.U_Id).Any())
                {
                    break;
                }
            }
            while (true)
            {
                user.U_Account = "music_" + Guid.NewGuid().ToString().Substring(0, 6);
                if (!_sugarTable.Where(it => it.U_Account == user.U_Account).Any())
                {
                    break;
                }
            }
            user.U_Regtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            try
            {
                db.Saveable <TB_User>(user).ExecuteCommand();
                message = '"' + $"注册账号为:{ user.U_Account}" + '"';
            }
            catch (Exception e)
            {
                code    = '"' + "500" + '"';
                msg     = '"' + "error" + '"';
                message = '"' + "注册失败" + '"';
                error.WriteErrorLog(e, "GetMusicTypeName()", "TB_Music");
            }
            string ret = "[{" + '"' + "status" + '"' + $":{status},"
                         + '"' + "msg" + '"' + $":{msg}," + '"'
                         + "data" + '"' + $":{message}" + "}]";

            return(ret);
        }