You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.9 KiB
65 lines
2.9 KiB
using System;
|
|
using MySql.Data.MySqlClient;
|
|
using Sog;
|
|
|
|
namespace Operation
|
|
{
|
|
public class MailDBUtils
|
|
{
|
|
|
|
|
|
public static bool MailExists(MySqlDB db, string uuid)
|
|
{
|
|
string sql = "select count(*) as num from mail_box where uuid='" + uuid + "'";
|
|
var reader = db.ExecReader(sql);
|
|
var num = 0;
|
|
if (reader != null)
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
num = reader.GetInt32("num");
|
|
}
|
|
reader.Close();
|
|
}
|
|
return num > 0;
|
|
}
|
|
|
|
public static int DBInsertIntoMailBox(MySqlDB db, string _name, string title11, string content11, string realmlist11,
|
|
string herolist11, string language, string uuid, string curstr11, string itemstr11,
|
|
string timeLimit11, int isSendToAll, string equipStr, byte[] dataByte, string customItemStr)
|
|
{
|
|
if (MailExists(db, uuid))
|
|
{
|
|
return -1;
|
|
}
|
|
string[] startEndTime = timeLimit11.Split("#");
|
|
string startTime = startEndTime[0]; //开始时间
|
|
string endTime = startEndTime[1]; //结束时间
|
|
|
|
string sql = $"insert into mail_box set dater=?dater,datee=?datee,name=?name,title=?title,content=?content,realmlist=?realmlist,herolist=?herolist,data=?data,equipStr='{equipStr}',language='{language}',uuid='{uuid}',curstr='{curstr11}',itemstr='{itemstr11}',timeLimit=0,status=0, isSendToAll={isSendToAll},customItemStr='{customItemStr}'";
|
|
|
|
MySqlParameter p_dater = new MySqlParameter("?dater", MySqlDbType.DateTime) { Value = DateTime.Parse(startTime) }; //开始时间
|
|
MySqlParameter p_datee = new MySqlParameter("?datee", MySqlDbType.DateTime) { Value = DateTime.Parse(endTime) }; //结束时间
|
|
|
|
MySqlParameter p_name = new MySqlParameter("?name", MySqlDbType.VarChar, 100) { Value = _name };
|
|
MySqlParameter p_title = new MySqlParameter("?title", MySqlDbType.VarChar, 100) { Value = title11 };
|
|
MySqlParameter p_content = new MySqlParameter("?content", MySqlDbType.VarChar, 1000) { Value = content11 };
|
|
MySqlParameter p_realmlist = new MySqlParameter("?realmlist", MySqlDbType.VarChar, 1000) { Value = "" };
|
|
MySqlParameter p_herolist = new MySqlParameter("?herolist", MySqlDbType.VarChar, 1000) { Value = herolist11 };
|
|
MySqlParameter p_data = new MySqlParameter("?data", MySqlDbType.Blob) { Value = dataByte };
|
|
|
|
TraceLog.Trace("MailStatus.DBInsertIntoMailBox insert sql {0}", sql);
|
|
MySqlDataReader readr = db.ExecReader(sql, p_dater, p_datee, p_name, p_title, p_content, p_realmlist, p_herolist, p_data);
|
|
|
|
if (readr == null)
|
|
return 6;
|
|
|
|
readr.Close();
|
|
|
|
TraceLog.Trace("MailStatus.DBInsertIntoMailBox success");
|
|
return 0;
|
|
}
|
|
|
|
}
|
|
|
|
}
|