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.
110 lines
3.4 KiB
110 lines
3.4 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Threading;
|
|
|
|
using SMWebServer;
|
|
using Sog;
|
|
using LitJson;
|
|
using SimpleHttpServer;
|
|
using MySql.Data.MySqlClient;
|
|
namespace SMWebServer
|
|
{
|
|
public class delete_username
|
|
{
|
|
private MySqlDB db;
|
|
public void InitConnection()
|
|
{
|
|
SMWebServerConfig config = SMWebServerUtils.GetServerConfig();
|
|
db = new MySqlDB(config.dbname,
|
|
config.dbip,
|
|
config.dbuser,
|
|
config.dbpassword);
|
|
}
|
|
|
|
public void Doadd_cooki(JsonData jsondata, HttpResponse rsp, HttpRequest request, HttpQueryParams query)
|
|
{
|
|
TraceLog.Trace("delete_username.ProccessRequest Url {0},param count{1}",request.Url,query.Count);
|
|
|
|
string Sqlfoundaccount = string.Format("select account, jurisdiction from account");
|
|
MySqlDataReader reader = db.ExecReader(Sqlfoundaccount);
|
|
if (reader == null)
|
|
{
|
|
TraceLog.Trace("连接数据库异常");
|
|
jsondata["ret"] = 6;
|
|
jsondata["msg"] = "error";
|
|
return;
|
|
}
|
|
|
|
JsonData msgdata = new JsonData();
|
|
jsondata["data"] = msgdata;msgdata.Add("");msgdata.Clear();
|
|
while (reader.Read())
|
|
{
|
|
//if (reader.GetString("account") != "test" && reader.GetString("account") != "2017kangpai")
|
|
//{
|
|
JsonData one = new JsonData();
|
|
|
|
one.Add(reader.GetString("account"));
|
|
one.Add(reader.GetString("jurisdiction"));
|
|
msgdata.Add(one);
|
|
//}
|
|
|
|
}
|
|
|
|
reader.Close();
|
|
|
|
string account = query.GetValue("account");
|
|
|
|
if(account == "")
|
|
{
|
|
jsondata["ret"] = 6;
|
|
jsondata["msg"] = "delete user account is empty";
|
|
return;
|
|
}
|
|
|
|
if(account != null)
|
|
{
|
|
string deleteSql = string.Format("delete from account where account='{0}'", account);
|
|
reader = db.ExecReader(deleteSql);
|
|
if(reader == null)
|
|
{
|
|
TraceLog.Trace("连接数据库异常");
|
|
jsondata["ret"] = 6;
|
|
jsondata["msg"] = "error";
|
|
return;
|
|
}
|
|
reader.Close();
|
|
string selectSql = string.Format("select from account where account='{0}'", account);
|
|
reader = db.ExecReader(deleteSql);
|
|
if (reader == null)
|
|
{
|
|
TraceLog.Trace("连接数据库异常");
|
|
jsondata["ret"] = 6;
|
|
jsondata["msg"] = "error";
|
|
return;
|
|
}
|
|
if (reader.HasRows == false)
|
|
{
|
|
jsondata["ret"] = 3;
|
|
jsondata["msg"] = "删除成功";
|
|
}
|
|
reader.Close();
|
|
return;
|
|
}
|
|
|
|
jsondata["ret"] = 3;
|
|
jsondata["msg"] = "删除成功";
|
|
return;
|
|
}
|
|
|
|
public void ProccessRequest(JsonData jsondata, HttpResponse rsp, HttpRequest request, HttpQueryParams query)
|
|
{
|
|
InitConnection();
|
|
|
|
Doadd_cooki(jsondata,rsp,request,query);
|
|
|
|
db.Dispose();
|
|
}
|
|
}
|
|
}
|
|
|