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.
108 lines
2.3 KiB
108 lines
2.3 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Threading;
|
|
|
|
using Sog;
|
|
using SimpleHttpServer;
|
|
using MySql.Data.MySqlClient;
|
|
using LitJson;
|
|
|
|
|
|
namespace SMWebServer
|
|
{
|
|
|
|
|
|
public class ChangeAuthority
|
|
{
|
|
private MySqlDB db;
|
|
|
|
|
|
|
|
|
|
|
|
public void InitConnection()
|
|
{
|
|
SMWebServerConfig config = SMWebServerUtils.GetServerConfig();//配置
|
|
db = new MySqlDB(config.dbname,
|
|
config.dbip,
|
|
config.dbuser,
|
|
config.dbpassword);
|
|
}
|
|
|
|
public void DoCheck(JsonData builder, HttpResponse rsp, HttpRequest request, HttpQueryParams query)
|
|
{
|
|
TraceLog.Trace("Login.ProccessRequest url {0} param count {1}", request.Url, query.Count);//在日志中打印出Url和count的内容
|
|
|
|
|
|
|
|
foreach(var a in query.m_map)
|
|
{
|
|
string strSql = string.Format("update account set jurisdiction='{0}' where account='{1}'", a.Value, a.Key);
|
|
MySqlDataReader reader = db.ExecReader(strSql);//运行sql语句得出返回值给reader
|
|
|
|
TraceLog.Trace("11111111");
|
|
if (reader == null)
|
|
{
|
|
TraceLog.Trace("数据库连接异常");
|
|
builder["code"] = 6;
|
|
builder["msg"] = "errror";
|
|
return;
|
|
}
|
|
|
|
reader.Close();
|
|
string Sql = string.Format("select jurisdiction from account where account = \"{0}\"", a.Key);
|
|
MySqlDataReader readr = db.ExecReader(Sql);//运行sql语句得出返回值给reader
|
|
if (readr == null)
|
|
{
|
|
TraceLog.Trace("数据库连接异常");
|
|
builder["code"] = 6;
|
|
builder["msg"] = "errror";
|
|
return;
|
|
}
|
|
string[] juris = new string[a.Key.Length];
|
|
|
|
while (readr.Read())
|
|
{
|
|
|
|
for(var i = 0; i < a.Key.Length; i++)
|
|
{
|
|
juris[i] = readr.GetString("jurisdiction");
|
|
if (a.Value == juris[i])
|
|
{
|
|
builder["code"] = 0;
|
|
builder["msg"] = "权限更改成功!";
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
readr.Close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
public void ProccessRequest(JsonData builder, HttpResponse rsp, HttpRequest request, HttpQueryParams query)//web端吧账号密码打包一个request发过来,调用这个方法
|
|
{
|
|
InitConnection();//初始化链接
|
|
|
|
DoCheck(builder, rsp, request, query);
|
|
|
|
db.Dispose();
|
|
|
|
|
|
return ;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|