Skip to content

Commit

Permalink
更新至0.2.1(修复了初始化时无法执行SQL语句的问题)
Browse files Browse the repository at this point in the history
  • Loading branch information
Misaka12456 committed Apr 10, 2022
1 parent f00b0b2 commit c471c66
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Version>0.2.0</Version>
<Company>123 Open-Source Organization</Company>
<Product>Arcaea Server 2(123 Marvelous Cube) Standalone Version</Product>
<AssemblyVersion>0.2.0</AssemblyVersion>
<AssemblyVersion>0.2.1</AssemblyVersion>
<FileVersion>0.2.0</FileVersion>
<Copyright>(C)Copyright 2015-2022 123 Open-Source Organization. All rights reserved.</Copyright>
<AssemblyTitle>123 Marvelous Cube Standalone Version</AssemblyTitle>
Expand Down
10 changes: 3 additions & 7 deletions Team123it.Arcaea.MarveCube/FirstStart/FirstStart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Text;
using System.Reflection;
using Newtonsoft.Json;
using System.Enhance.MySql.Data;

namespace Team123it.Arcaea.MarveCube.FirstStart
{
Expand All @@ -37,15 +38,10 @@ public static void FastInitialize()
cmd.CommandText = $"CREATE DATABASE {dbName};";
cmd.ExecuteNonQuery();
conn.Close();
conn = new MySqlConnection(DatabaseConnectURL);
conn.Open();
cmd = conn.CreateCommand();
cmd.CommandText = initSQLCodes;
cmd.ExecuteNonQuery();
conn.Close();
MysqlExecutor.ExecuteSqlFileData(DatabaseConnectURL, initSQLCodes);
c.WriteLine("数据库初始化成功完成");
}
catch (MySqlException)
catch (MySqlException ex)
{
c.WriteLine("无法连接到数据库, 请检查配置信息是否填写有误后单击任意键继续");
goto DoInitialize;
Expand Down
66 changes: 0 additions & 66 deletions Team123it.Arcaea.MarveCube/FirstStartData/Initialization.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
-- ----------------------------
-- Table structure for bests
-- ----------------------------
DROP TABLE IF EXISTS `bests`;
CREATE TABLE `bests` (
`user_id` int(11) NOT NULL,
Expand All @@ -19,10 +16,6 @@ CREATE TABLE `bests` (
`rating` decimal(10,3) DEFAULT NULL,
PRIMARY KEY (`user_id`,`song_id`,`difficulty`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Table structure for bests_special
-- ----------------------------
DROP TABLE IF EXISTS `bests_special`;
CREATE TABLE `bests_special` (
`user_id` int(11) NOT NULL,
Expand All @@ -41,9 +34,6 @@ CREATE TABLE `bests_special` (
`rating` decimal(10,3) DEFAULT NULL,
PRIMARY KEY (`user_id`,`song_id`,`difficulty`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
-- ----------------------------
-- Table structure for fixed_characters
-- ----------------------------
DROP TABLE IF EXISTS `fixed_characters`;
CREATE TABLE `fixed_characters` (
`character_id` int(11) NOT NULL,
Expand All @@ -67,10 +57,6 @@ CREATE TABLE `fixed_characters` (
`version` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`character_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Table structure for fixed_packs
-- ----------------------------
DROP TABLE IF EXISTS `fixed_packs`;
CREATE TABLE `fixed_packs` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
Expand All @@ -97,10 +83,6 @@ CREATE TABLE `fixed_packs` (
`version` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`,`pid`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=100 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Table structure for fixed_presents
-- ----------------------------
DROP TABLE IF EXISTS `fixed_presents`;
CREATE TABLE `fixed_presents` (
`present_id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
Expand All @@ -113,20 +95,12 @@ CREATE TABLE `fixed_presents` (
`items` text COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`present_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Table structure for fixed_properties
-- ----------------------------
DROP TABLE IF EXISTS `fixed_properties`;
CREATE TABLE `fixed_properties` (
`key` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`value` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`key`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Table structure for fixed_purchases
-- ----------------------------
DROP TABLE IF EXISTS `fixed_purchases`;
CREATE TABLE `fixed_purchases` (
`item_id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
Expand All @@ -138,10 +112,6 @@ CREATE TABLE `fixed_purchases` (
`discount_to` datetime DEFAULT NULL,
PRIMARY KEY (`item_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Table structure for fixed_songs
-- ----------------------------
DROP TABLE IF EXISTS `fixed_songs`;
CREATE TABLE `fixed_songs` (
`sid` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
Expand Down Expand Up @@ -186,30 +156,18 @@ CREATE TABLE `fixed_songs` (
`version` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`sid`,`date`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Table structure for fixed_songs_checksum
-- ----------------------------
DROP TABLE IF EXISTS `fixed_songs_checksum`;
CREATE TABLE `fixed_songs_checksum` (
`sid` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`filename` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`checksum` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Table structure for friend
-- ----------------------------
DROP TABLE IF EXISTS `friend`;
CREATE TABLE `friend` (
`user_id_me` int(11) NOT NULL,
`user_id_other` int(11) NOT NULL,
PRIMARY KEY (`user_id_me`,`user_id_other`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Table structure for logins
-- ----------------------------
DROP TABLE IF EXISTS `logins`;
CREATE TABLE `logins` (
`access_token` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
Expand All @@ -220,20 +178,12 @@ CREATE TABLE `logins` (
`last_login_deviceId` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`access_token`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Table structure for user_bydunlocks
-- ----------------------------
DROP TABLE IF EXISTS `user_bydunlocks`;
CREATE TABLE `user_bydunlocks` (
`user_id` int(11) NOT NULL,
`sid` varchar(255) NOT NULL,
PRIMARY KEY (`user_id`,`sid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- ----------------------------
-- Table structure for user_chars
-- ----------------------------
DROP TABLE IF EXISTS `user_chars`;
CREATE TABLE `user_chars` (
`user_id` int(11) NOT NULL,
Expand All @@ -253,10 +203,6 @@ CREATE TABLE `user_chars` (
`is_uncapped_override` int(11) DEFAULT 0,
PRIMARY KEY (`user_id`,`character_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Table structure for user_saves
-- ----------------------------
DROP TABLE IF EXISTS `user_saves`;
CREATE TABLE `user_saves` (
`user_id` int(10) unsigned NOT NULL,
Expand All @@ -270,10 +216,6 @@ CREATE TABLE `user_saves` (
`create_time` datetime DEFAULT NULL,
PRIMARY KEY (`user_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Table structure for user_world
-- ----------------------------
DROP TABLE IF EXISTS `user_world`;
CREATE TABLE `user_world` (
`user_id` int(11) NOT NULL,
Expand All @@ -283,10 +225,6 @@ CREATE TABLE `user_world` (
`is_locked` int(11) DEFAULT 0,
PRIMARY KEY (`user_id`,`map_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Table structure for users
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`user_id` int(11) NOT NULL AUTO_INCREMENT,
Expand Down Expand Up @@ -331,10 +269,6 @@ CREATE TABLE `users` (
PRIMARY KEY (`user_id`) USING BTREE,
UNIQUE KEY `name` (`name`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=10000024 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Table structure for world_songplay
-- ----------------------------
DROP TABLE IF EXISTS `world_songplay`;
CREATE TABLE `world_songplay` (
`user_id` int(11) NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using MySql.Data.MySqlClient;
using System.Collections;
using System.IO;
using System.Text;

namespace System.Enhance.MySql.Data
{
public class MysqlExecutor
{
public static bool ExecuteSqlFileData(string sqlConnString, string varData)
{
var stream = new MemoryStream();
var ws = new StreamWriter(stream, Encoding.UTF8);
ws.Write(varData);
ws.Flush();
stream.Seek(0, SeekOrigin.Begin);
var rs = new StreamReader(stream, Encoding.UTF8);
var alSql = new ArrayList();
string commandText = "";
string varLine = "";
while (rs.Peek() > -1)
{
varLine = rs.ReadLine();
if (varLine == "")
{
continue;
}
if (varLine != "GO")
{
commandText += varLine;
commandText += "\r\n";
}
else
{
commandText += "";
}
}
alSql.Add(commandText);
rs.Close();
try
{
ExecuteCommand(sqlConnString, alSql);
return true;
}
catch (Exception ex)
{
throw;
}
}
private static void ExecuteCommand(string sqlConnString, ArrayList varSqlList)
{
using var conn = new MySqlConnection(sqlConnString);
conn.Open();
var cmd = conn.CreateCommand();
try
{
foreach (string varcommandText in varSqlList)
{
cmd.CommandText = varcommandText;
cmd.ExecuteNonQuery();
}
}
catch (Exception ex)
{
throw;
}
finally
{
conn.Close();
}
}
}
}
6 changes: 3 additions & 3 deletions Team123it.Arcaea.MarveCube/Team123it.Arcaea.MarveCube.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>MarveCube</AssemblyName>
<Version>0.2.0</Version>
<Version>0.2.1</Version>
<Company>123 Open-Source Organization</Company>
<Product>Arcaea Server 2(123 Marvelous Cube Open-Source Version)</Product>
<AssemblyVersion>0.2.0</AssemblyVersion>
<FileVersion>0.2.0</FileVersion>
<AssemblyVersion>0.2.1</AssemblyVersion>
<FileVersion>0.2.1</FileVersion>
<Copyright>(C)Copyright 2015-2022 123 Open-Source Organization. All rights reserved.</Copyright>
<AssemblyTitle>Arcaea Server 2 - High-Speed Protable Arcaea API Server</AssemblyTitle>
<Platforms>x64;ARM64</Platforms>
Expand Down

0 comments on commit c471c66

Please sign in to comment.