服务端相关代码也合并到仓库
This commit is contained in:
1 parent
fef54e1f0f
commit
879b72e21a
32 files changed
+3625
No files matched your search
@@ -6,3 +6,4 @@ obj
|
|||||||
.psd
|
.psd
|
||||||
packages
|
packages
|
||||||
.user
|
.user
|
||||||
|
bin
|
||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.14.36221.1 d17.14
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KJD_WebService", "KJD_WebService\KJD_WebService.csproj", "{A6C03FE1-142A-4C97-99A9-67FD915836B6}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{A6C03FE1-142A-4C97-99A9-67FD915836B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{A6C03FE1-142A-4C97-99A9-67FD915836B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{A6C03FE1-142A-4C97-99A9-67FD915836B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{A6C03FE1-142A-4C97-99A9-67FD915836B6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {373F414C-6CDF-49C0-B074-A7D07D7B82B7}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -0,0 +1,404 @@
|
|||||||
|
using KJD_Web.Model;
|
||||||
|
using KJD_Web.Model.ShopModel;
|
||||||
|
using KJD_Web.Utils;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Security;
|
||||||
|
|
||||||
|
namespace KJD_Web.BLL
|
||||||
|
{
|
||||||
|
public class ShopManage
|
||||||
|
{
|
||||||
|
public string GetShop(string inputData, bool isAdmin = false)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(inputData))
|
||||||
|
{
|
||||||
|
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
||||||
|
var password = RegexUtils.GetStringQuery(ref inputData, "password");
|
||||||
|
var search_user_name = RegexUtils.GetStringQuery(ref inputData, "search_user_name");
|
||||||
|
var search_login_name = RegexUtils.GetStringQuery(ref inputData, "search_login_name");
|
||||||
|
var search_notes = RegexUtils.GetStringQuery(ref inputData, "search_notes");
|
||||||
|
var search_id = RegexUtils.GetStringQuery(ref inputData, "search_id");
|
||||||
|
var search_name = RegexUtils.GetStringQuery(ref inputData, "search_name");
|
||||||
|
var s_page = RegexUtils.GetStringQuery(ref inputData, "page");
|
||||||
|
int page = 0;
|
||||||
|
int.TryParse(s_page, out page);
|
||||||
|
var s_page_size = RegexUtils.GetStringQuery(ref inputData, "page_size");
|
||||||
|
int page_size;
|
||||||
|
int.TryParse(s_page_size, out page_size);
|
||||||
|
if (page_size == 0)
|
||||||
|
page_size = 50;
|
||||||
|
int r2 = 0;
|
||||||
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
||||||
|
|
||||||
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||||
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
|
|
||||||
|
string sql = "select count(id) from kjd.shop where 1=1";
|
||||||
|
if (isAdmin)
|
||||||
|
sql += " and (cookie='' or shop_id!='')";
|
||||||
|
if (!isAdmin)
|
||||||
|
sql += " and (user_name='" + user_name + "' or sub_user_name='" + user_name + "')";
|
||||||
|
if (!string.IsNullOrWhiteSpace(search_user_name))
|
||||||
|
sql += " and user_name like '%" + search_user_name + "%'";
|
||||||
|
if (!string.IsNullOrWhiteSpace(search_login_name))
|
||||||
|
sql += " and login_name like '%" + search_login_name + "%'";
|
||||||
|
if (!string.IsNullOrWhiteSpace(search_notes))
|
||||||
|
sql += " and notes like '%" + search_notes + "%'";
|
||||||
|
if (!string.IsNullOrWhiteSpace(search_id))
|
||||||
|
sql += " and shop_id like '%" + search_id + "%'";
|
||||||
|
if (!string.IsNullOrWhiteSpace(search_name))
|
||||||
|
sql += " and shop_account like '%" + search_name + "%'";
|
||||||
|
var count = mySql.ExecuteRowCount(sql);
|
||||||
|
|
||||||
|
DataTable dt;
|
||||||
|
if (count == 0)
|
||||||
|
{
|
||||||
|
dt = new DataTable();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sql = "select id,login_name,login_pass,cookie,shop_id,shop_account,sub_user_name,user_name,company_name,notes,login_status" +
|
||||||
|
" from kjd.shop where 1=1";
|
||||||
|
if (isAdmin)
|
||||||
|
sql += " and (cookie='' or shop_id!='')";
|
||||||
|
if (!isAdmin)
|
||||||
|
sql += " and (user_name='" + user_name + "' or sub_user_name='" + user_name + "')";
|
||||||
|
if (!string.IsNullOrWhiteSpace(search_user_name))
|
||||||
|
sql += " and user_name like '%" + search_user_name + "%'";
|
||||||
|
if (!string.IsNullOrWhiteSpace(search_login_name))
|
||||||
|
sql += " and login_name like '%" + search_login_name + "%'";
|
||||||
|
if (!string.IsNullOrWhiteSpace(search_notes))
|
||||||
|
sql += " and notes like '%" + search_notes + "%'";
|
||||||
|
if (!string.IsNullOrWhiteSpace(search_id))
|
||||||
|
sql += " and shop_id like '%" + search_id + "%'";
|
||||||
|
if (!string.IsNullOrWhiteSpace(search_name))
|
||||||
|
sql += " and shop_account like '%" + search_name + "%'";
|
||||||
|
sql += " order by id desc";
|
||||||
|
sql += " limit " + Math.Max(page - 1, 0) * page_size + "," + page_size;
|
||||||
|
dt = mySql.ExecuteDataTable(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
mySql.Close();
|
||||||
|
if (dt != null)
|
||||||
|
{
|
||||||
|
List<ShopParam> shopList=new List<ShopParam>();
|
||||||
|
foreach (DataRow row in dt.Rows)
|
||||||
|
{
|
||||||
|
ShopParam shop = new ShopParam
|
||||||
|
{
|
||||||
|
id = Convert.ToInt32(row["id"]),
|
||||||
|
login_name = row["login_name"].ToString(),
|
||||||
|
login_pass = row["login_pass"].ToString(),
|
||||||
|
cookie = row["cookie"].ToString(),
|
||||||
|
shop_id = row["shop_id"].ToString(),
|
||||||
|
shop_account = row["shop_account"].ToString(),
|
||||||
|
sub_user_name = row["sub_user_name"].ToString(),
|
||||||
|
user_name = row["user_name"].ToString(),
|
||||||
|
company_name = row["company_name"].ToString(),
|
||||||
|
notes = row["notes"].ToString(),
|
||||||
|
login_status = row["login_status"].ToString(),
|
||||||
|
};
|
||||||
|
shopList.Add(shop);
|
||||||
|
}
|
||||||
|
var data = JsonUtils.SerializerObjectToString(shopList);
|
||||||
|
//return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
|
||||||
|
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"count\":" + count + "}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取一个手机登录号码下的所有店铺(以便有则更新,无则新增)
|
||||||
|
public string GetOneLoginNameShop(string inputData)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(inputData))
|
||||||
|
{
|
||||||
|
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
||||||
|
var login_name = RegexUtils.GetStringQuery(ref inputData, "login_name");
|
||||||
|
var password = RegexUtils.GetStringQuery(ref inputData, "password");
|
||||||
|
int r2 = 0;
|
||||||
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
||||||
|
|
||||||
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||||
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
|
string sql = "select id,login_name,login_pass,cookie,shop_id,shop_account,sub_user_name,user_name from kjd.shop where user_name='"
|
||||||
|
+ user_name + "' and login_name='" + login_name + "'";
|
||||||
|
|
||||||
|
var dt = mySql.ExecuteDataTable(sql);
|
||||||
|
mySql.Close();
|
||||||
|
if (dt != null)
|
||||||
|
{
|
||||||
|
List<ShopParam> shopList = new List<ShopParam>();
|
||||||
|
foreach (DataRow row in dt.Rows)
|
||||||
|
{
|
||||||
|
ShopParam shop = new ShopParam
|
||||||
|
{
|
||||||
|
id = Convert.ToInt32(row["id"]),
|
||||||
|
login_name = row["login_name"].ToString(),
|
||||||
|
login_pass = row["login_pass"].ToString(),
|
||||||
|
cookie = row["cookie"].ToString(),
|
||||||
|
shop_id = row["shop_id"].ToString(),
|
||||||
|
shop_account = row["shop_account"].ToString(),
|
||||||
|
sub_user_name = row["sub_user_name"].ToString(),
|
||||||
|
user_name = row["user_name"].ToString(),
|
||||||
|
company_name = row["company_name"].ToString(),
|
||||||
|
notes = row["notes"].ToString(),
|
||||||
|
login_status = row["login_status"].ToString(),
|
||||||
|
};
|
||||||
|
shopList.Add(shop);
|
||||||
|
}
|
||||||
|
var data = JsonUtils.SerializerObjectToString(shopList);
|
||||||
|
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取一个手机登录号码下特定ID的店铺
|
||||||
|
public string GetOneIdShop(string inputData)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(inputData))
|
||||||
|
{
|
||||||
|
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
||||||
|
var login_name = RegexUtils.GetStringQuery(ref inputData, "login_name");
|
||||||
|
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id");
|
||||||
|
var password = RegexUtils.GetStringQuery(ref inputData, "password");
|
||||||
|
int r2 = 0;
|
||||||
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
||||||
|
|
||||||
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||||
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
|
string sql = "select id,login_name,login_pass,cookie,shop_id,shop_account,sub_user_name,user_name from kjd.shop where user_name='"
|
||||||
|
+ user_name + "' and login_name='" + login_name + "' and shop_id='" + shop_id + "'";
|
||||||
|
|
||||||
|
var dt = mySql.ExecuteDataTable(sql);
|
||||||
|
mySql.Close();
|
||||||
|
if (dt != null)
|
||||||
|
{
|
||||||
|
List<ShopParam> shopList = new List<ShopParam>();
|
||||||
|
foreach (DataRow row in dt.Rows)
|
||||||
|
{
|
||||||
|
ShopParam shop = new ShopParam
|
||||||
|
{
|
||||||
|
id = Convert.ToInt32(row["id"]),
|
||||||
|
login_name = row["login_name"].ToString(),
|
||||||
|
login_pass = row["login_pass"].ToString(),
|
||||||
|
cookie = row["cookie"].ToString(),
|
||||||
|
shop_id = row["shop_id"].ToString(),
|
||||||
|
shop_account = row["shop_account"].ToString(),
|
||||||
|
sub_user_name = row["sub_user_name"].ToString(),
|
||||||
|
user_name = row["user_name"].ToString(),
|
||||||
|
company_name = row["company_name"].ToString(),
|
||||||
|
notes = row["notes"].ToString(),
|
||||||
|
login_status = row["login_status"].ToString(),
|
||||||
|
};
|
||||||
|
shopList.Add(shop);
|
||||||
|
}
|
||||||
|
var data = JsonUtils.SerializerObjectToString(shopList);
|
||||||
|
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public string AddShop(string inputData, bool isAdmin=false)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(inputData))
|
||||||
|
{
|
||||||
|
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
||||||
|
if (isAdmin)
|
||||||
|
user_name = RegexUtils.GetStringQuery(ref inputData, "shop_user_name");
|
||||||
|
string login_name = RegexUtils.GetStringQuery(ref inputData, "login_name");
|
||||||
|
string login_pass = RegexUtils.GetStringQuery(ref inputData, "login_pass");
|
||||||
|
string sub_user_name = RegexUtils.GetStringQuery(ref inputData, "sub_user_name");
|
||||||
|
string cookie = RegexUtils.GetStringQuery(ref inputData, "cookie");
|
||||||
|
string shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id");
|
||||||
|
string shop_account = RegexUtils.GetStringQuery(ref inputData, "shop_account");
|
||||||
|
string group_name = RegexUtils.GetStringQuery(ref inputData, "group_name");
|
||||||
|
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"));
|
||||||
|
int r2 = 0;
|
||||||
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(user_name))
|
||||||
|
{
|
||||||
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(login_name))
|
||||||
|
{
|
||||||
|
return "{\"code\":501,\"msg\":\"没有店铺登录名\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||||
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
|
string sql = "";
|
||||||
|
if (string.IsNullOrEmpty(shop_id))
|
||||||
|
sql = "select exists (select 1 from kjd.shop where login_name='" + login_name + "' and user_name='" + user_name + "')";
|
||||||
|
else
|
||||||
|
sql = "select exists (select 1 from kjd.shop where login_name='" + login_name + "' and user_name='" + user_name +
|
||||||
|
"' and shop_id='" + shop_id + "')";
|
||||||
|
var exist = mySql.ExecuteFirstInt(sql);
|
||||||
|
if (exist>0)
|
||||||
|
{
|
||||||
|
mySql.Close();
|
||||||
|
return "{\"code\":500,\"msg\":\"店铺" + login_name +" " + shop_account + "已存在\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
sql = "insert into kjd.shop (login_name,login_pass,cookie,shop_account,shop_id,sub_user_name,user_name,group_name,notes,add_time,mdy_time) " +
|
||||||
|
"values ('" + login_name + "','" + login_pass + "','" + cookie + "','" + shop_account + "','" + shop_id + "','" +
|
||||||
|
sub_user_name + "','" + user_name + "','" + group_name + "','" + notes + "','" +
|
||||||
|
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
|
||||||
|
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
|
||||||
|
var rst = mySql.ExecuteNonQuery(sql);
|
||||||
|
mySql.Close();
|
||||||
|
if (rst)
|
||||||
|
{
|
||||||
|
return "{\"code\":200,\"msg\":\"success\"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public string MdyShop(string inputData, bool isAdmin=false)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(inputData))
|
||||||
|
{
|
||||||
|
string user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
||||||
|
if (isAdmin)
|
||||||
|
user_name = RegexUtils.GetStringQuery(ref inputData, "shop_user_name");
|
||||||
|
string login_name = RegexUtils.GetStringQuery(ref inputData, "login_name");
|
||||||
|
string login_pass = RegexUtils.GetStringQuery(ref inputData, "login_pass");
|
||||||
|
string sub_user_name = RegexUtils.GetStringQuery(ref inputData, "sub_user_name");
|
||||||
|
string cookie = RegexUtils.GetStringQuery(ref inputData, "cookie");
|
||||||
|
string new_shop_id = RegexUtils.GetStringQuery(ref inputData, "new_shop_id");
|
||||||
|
string old_shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id");
|
||||||
|
string shop_account = RegexUtils.GetStringQuery(ref inputData, "shop_account");
|
||||||
|
string group_name = RegexUtils.GetStringQuery(ref inputData, "group_name");
|
||||||
|
string notes = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "notes"));
|
||||||
|
string login_status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "login_status"));
|
||||||
|
|
||||||
|
int r2 = 0;
|
||||||
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(user_name))
|
||||||
|
{
|
||||||
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(login_name))
|
||||||
|
{
|
||||||
|
return "{\"code\":501,\"msg\":\"没有店铺登录名\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||||
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
|
string sql = "update kjd.shop set";
|
||||||
|
if (login_pass != null)
|
||||||
|
sql += " login_pass='" + login_pass + "',";
|
||||||
|
if (cookie != null)
|
||||||
|
sql += " cookie='" + cookie + "',";
|
||||||
|
if (new_shop_id != null)
|
||||||
|
sql += " shop_id='" + new_shop_id + "',";
|
||||||
|
if (shop_account != null)
|
||||||
|
sql += " shop_account='" + shop_account + "',";
|
||||||
|
if (sub_user_name != null)
|
||||||
|
sql += " sub_user_name='" + sub_user_name + "',";
|
||||||
|
if (group_name != null)
|
||||||
|
sql += " group_name='" + group_name + "',";
|
||||||
|
if (notes != null)
|
||||||
|
sql += " notes='" + notes + "',";
|
||||||
|
if (login_status != null)
|
||||||
|
sql += " login_status='" + login_status + "',";
|
||||||
|
sql = sql.TrimEnd(',');
|
||||||
|
sql += " where login_name='" + login_name + "' and (user_name='" + user_name + "' or sub_user_name='" + user_name + "')";
|
||||||
|
if (!string.IsNullOrEmpty(old_shop_id))
|
||||||
|
sql += " and shop_id='" + old_shop_id + "'";
|
||||||
|
|
||||||
|
var rst = mySql.ExecuteNonQuery(sql);
|
||||||
|
mySql.Close();
|
||||||
|
if (rst)
|
||||||
|
{
|
||||||
|
return "{\"code\":200,\"msg\":\"success\"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public string MdyCookieAndLoginStatus(string inputData)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(inputData))
|
||||||
|
{
|
||||||
|
string login_name = RegexUtils.GetStringQuery(ref inputData, "login_name");
|
||||||
|
string cookie = RegexUtils.GetStringQuery(ref inputData, "cookie");
|
||||||
|
string login_status = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "login_status"));
|
||||||
|
|
||||||
|
int r2 = 0;
|
||||||
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(login_name))
|
||||||
|
{
|
||||||
|
return "{\"code\":500,\"msg\":\"店铺没有登录名\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||||
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
|
string sql = "update kjd.shop set";
|
||||||
|
if (cookie != null)
|
||||||
|
sql += " cookie='" + cookie + "',";
|
||||||
|
if (login_status != null)
|
||||||
|
sql += " login_status='" + login_status + "',";
|
||||||
|
sql = sql.TrimEnd(',');
|
||||||
|
sql += " where login_name='" + login_name + "'";
|
||||||
|
|
||||||
|
var rst = mySql.ExecuteNonQuery(sql);
|
||||||
|
mySql.Close();
|
||||||
|
if (rst)
|
||||||
|
{
|
||||||
|
return "{\"code\":200,\"msg\":\"success\"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string DelShop(string inputData, bool isAdmin=false)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(inputData))
|
||||||
|
{
|
||||||
|
var login_name = RegexUtils.GetStringQuery(ref inputData, "login_name");
|
||||||
|
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
||||||
|
if (isAdmin)
|
||||||
|
user_name = RegexUtils.GetStringQuery(ref inputData, "shop_user_name");
|
||||||
|
var shop_id = RegexUtils.GetStringQuery(ref inputData, "shop_id");
|
||||||
|
var password = RegexUtils.GetStringQuery(ref inputData, "password");
|
||||||
|
int r2 = 0;
|
||||||
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(user_name))
|
||||||
|
{
|
||||||
|
return "{\"code\":500,\"msg\":\"没有用户名\"}";
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(login_name))
|
||||||
|
{
|
||||||
|
return "{\"code\":501,\"msg\":\"没有店铺登录名\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||||
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
|
string sql = "delete from kjd.shop where user_name='" + user_name + "' and login_name='" + login_name + "'";
|
||||||
|
if (!string.IsNullOrEmpty(shop_id))
|
||||||
|
sql += " and shop_id='" + shop_id + "'";
|
||||||
|
|
||||||
|
var rst = mySql.ExecuteNonQuery(sql);
|
||||||
|
mySql.Close();
|
||||||
|
if (rst)
|
||||||
|
{
|
||||||
|
return "{\"code\":200,\"msg\":\"success\"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
using KJD_Web.Utils;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace KJD_Web.BLL
|
||||||
|
{
|
||||||
|
public class UpadteManage
|
||||||
|
{
|
||||||
|
public string GetUpdate(string inputData)
|
||||||
|
{
|
||||||
|
//string time1 = Encryption(time);
|
||||||
|
//return "time=" + time + "&code=" + time1 + "&NbCodeVersion=1" + "&version=" + BaseClass.VersionCount
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(inputData))
|
||||||
|
{
|
||||||
|
var time = 0;
|
||||||
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "time"), out time);
|
||||||
|
string time1 = RegexUtils.GetStringQuery(ref inputData, "code");
|
||||||
|
if (time1 != EncrypUtil.Encryption(time))
|
||||||
|
return "{\"code\":20000,\"msg\":\"校验失败\"}";
|
||||||
|
|
||||||
|
var version = 0;
|
||||||
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "version"), out version);
|
||||||
|
var serverVersion = System.Configuration.ConfigurationManager.ConnectionStrings["UpdateVersion"].ConnectionString;
|
||||||
|
var UpdateFiles = System.Configuration.ConfigurationManager.ConnectionStrings["UpdateFiles"].ConnectionString;
|
||||||
|
var UpdateExe = System.Configuration.ConfigurationManager.ConnectionStrings["UpdateExe"].ConnectionString;
|
||||||
|
var UpdateExeChk = System.Configuration.ConfigurationManager.ConnectionStrings["UpdateExeChk"].ConnectionString;
|
||||||
|
|
||||||
|
if (version > 0)
|
||||||
|
{
|
||||||
|
return "{\"code\":200,\"msg\":\"success\",\"next_version\":" + serverVersion + ",\"exe_check\":\"" + UpdateExeChk +
|
||||||
|
"\",\"exe_address\":\"" + UpdateExe + "\",\"file_address\":\"" + UpdateFiles + "\"}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "{\"code\":501,\"msg\":\"failed\"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,410 @@
|
|||||||
|
using KJD_Web.Model;
|
||||||
|
using KJD_Web.Utils;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.UI.WebControls;
|
||||||
|
|
||||||
|
namespace KJD_Web.BLL
|
||||||
|
{
|
||||||
|
public class UserManage
|
||||||
|
{
|
||||||
|
public string CheckUserLogin(string inputData)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(inputData))
|
||||||
|
{
|
||||||
|
var mobile = RegexUtils.GetStringQuery(ref inputData, "mobile");
|
||||||
|
var password = RegexUtils.GetStringQuery(ref inputData, "password");
|
||||||
|
int r2 = 0;
|
||||||
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
||||||
|
|
||||||
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||||
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
|
string sql = "select * from kjd.user where user_name='"
|
||||||
|
+ mobile + "' and password='" + password + "'";
|
||||||
|
|
||||||
|
var dt = mySql.ExecuteDataTable(sql);
|
||||||
|
mySql.Close();
|
||||||
|
if (dt != null)
|
||||||
|
{
|
||||||
|
foreach (DataRow row in dt.Rows)
|
||||||
|
{
|
||||||
|
|
||||||
|
UserLoginResultParam user = new UserLoginResultParam
|
||||||
|
{
|
||||||
|
id = Convert.ToInt32(row["id"]),
|
||||||
|
user_name = row["user_name"].ToString(),
|
||||||
|
nick_name = row["nick_name"].ToString(),
|
||||||
|
mobile = row["user_name"].ToString(),
|
||||||
|
password = row["password"].ToString(),
|
||||||
|
group_id = row["group_id"].ToString(),
|
||||||
|
card_id = row["card_id"].ToString(),
|
||||||
|
company_name = row["company_name"].ToString(),
|
||||||
|
};
|
||||||
|
if (string.IsNullOrEmpty(user.company_name))
|
||||||
|
{
|
||||||
|
user.company_name = "-";
|
||||||
|
}
|
||||||
|
var data = JsonUtils.SerializerObjectToString(user);
|
||||||
|
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
|
||||||
|
}
|
||||||
|
return "{\"code\":1,\"msg\":\"用户名或密码错误\"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public string AddSubUser(string inputData)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(inputData))
|
||||||
|
{
|
||||||
|
var parent_user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
||||||
|
var nick_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_nick_name"));
|
||||||
|
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_name"));
|
||||||
|
var mobile = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_mobile"));
|
||||||
|
var password = RegexUtils.GetStringQuery(ref inputData, "sub_password");
|
||||||
|
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id");
|
||||||
|
var card_id = RegexUtils.GetStringQuery(ref inputData, "card_id");
|
||||||
|
var company_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "company"));
|
||||||
|
var notes = RegexUtils.GetStringQuery(ref inputData, "notes");
|
||||||
|
int r2 = 0;
|
||||||
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
||||||
|
|
||||||
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||||
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
|
string sql = "";
|
||||||
|
sql = "select exists (select 1 from kjd.user where user_name='" + user_name + "')";
|
||||||
|
var exist = mySql.ExecuteFirstInt(sql);
|
||||||
|
if (exist > 0)
|
||||||
|
{
|
||||||
|
mySql.Close();
|
||||||
|
return "{\"code\":500,\"msg\":\"用户名已存在\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
sql = "insert into kjd.user (nick_name,user_name,mobile,password,card_id,group_id,company_name,notes,parent_user_name,add_time,mdy_time) " +
|
||||||
|
"values ('" + nick_name + "','" + user_name + "','" + mobile + "','" + password + "','" + card_id + "','" +
|
||||||
|
group_id + "','" + company_name + "','" + notes + "','" + parent_user_name + "','" +
|
||||||
|
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
|
||||||
|
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
|
||||||
|
var rst = mySql.ExecuteNonQuery(sql);
|
||||||
|
mySql.Close();
|
||||||
|
if (!rst)
|
||||||
|
return "{\"code\":501,\"msg\":\""+ mySql.Message + "\"}";
|
||||||
|
else
|
||||||
|
return "{\"code\":200,\"msg\":\"子账户创建成功!\"}";
|
||||||
|
}
|
||||||
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetSubUser(string inputData)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(inputData))
|
||||||
|
{
|
||||||
|
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
||||||
|
var password = RegexUtils.GetStringQuery(ref inputData, "password");
|
||||||
|
var group = RegexUtils.GetStringQuery(ref inputData, "group");
|
||||||
|
int r2 = 0;
|
||||||
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
||||||
|
|
||||||
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||||
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
|
string sql = "select * from kjd.user where parent_user_name='"
|
||||||
|
+ user_name + "'";
|
||||||
|
|
||||||
|
var dt = mySql.ExecuteDataTable(sql);
|
||||||
|
mySql.Close();
|
||||||
|
if (dt != null)
|
||||||
|
{
|
||||||
|
List<UserLoginResultParam> userList = new List<UserLoginResultParam>();
|
||||||
|
foreach (DataRow row in dt.Rows)
|
||||||
|
{
|
||||||
|
|
||||||
|
UserLoginResultParam user = new UserLoginResultParam
|
||||||
|
{
|
||||||
|
id = Convert.ToInt32(row["id"]),
|
||||||
|
user_name = row["user_name"].ToString(),
|
||||||
|
nick_name = row["nick_name"].ToString(),
|
||||||
|
mobile = row["mobile"].ToString(),
|
||||||
|
password = row["password"].ToString(),
|
||||||
|
group_id = row["group_id"].ToString(),
|
||||||
|
card_id = row["card_id"].ToString(),
|
||||||
|
parent_user_name = row["parent_user_name"].ToString(),
|
||||||
|
company_name = row["company_name"].ToString(),
|
||||||
|
notes = row["notes"].ToString(),
|
||||||
|
};
|
||||||
|
if (string.IsNullOrEmpty(user.mobile))
|
||||||
|
{
|
||||||
|
user.mobile = row["user_name"].ToString();
|
||||||
|
}
|
||||||
|
userList.Add(user);
|
||||||
|
}
|
||||||
|
var data = JsonUtils.SerializerObjectToString(userList);
|
||||||
|
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public string UpdateSubUser(string inputData)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(inputData))
|
||||||
|
{
|
||||||
|
var id = RegexUtils.GetStringQuery(ref inputData, "id");
|
||||||
|
var parent_user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
||||||
|
var nick_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_nick_name"));
|
||||||
|
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_name"));
|
||||||
|
var mobile = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "sub_mobile"));
|
||||||
|
var password = RegexUtils.GetStringQuery(ref inputData, "sub_password");
|
||||||
|
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id");
|
||||||
|
var card_id = RegexUtils.GetStringQuery(ref inputData, "card_id");
|
||||||
|
int r2 = 0;
|
||||||
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
||||||
|
|
||||||
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||||
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
|
string sql = "";
|
||||||
|
//sql = "select * from kjd.user where parent_user_name='"
|
||||||
|
// + user_name + "'";
|
||||||
|
sql = "update kjd.user set";
|
||||||
|
if (!string.IsNullOrEmpty(nick_name))
|
||||||
|
sql += " nick_name='" + nick_name + "',";
|
||||||
|
if (!string.IsNullOrEmpty(user_name))
|
||||||
|
sql += " user_name='" + user_name + "',";
|
||||||
|
if (!string.IsNullOrEmpty(mobile))
|
||||||
|
sql += " mobile='" + mobile + "',";
|
||||||
|
if (!string.IsNullOrEmpty(password))
|
||||||
|
sql += " password='" + password + "',";
|
||||||
|
if (!string.IsNullOrEmpty(group_id))
|
||||||
|
sql += " group_id=" + group_id + ",";
|
||||||
|
if (!string.IsNullOrEmpty(card_id))
|
||||||
|
sql += " card_id='" + card_id + "',";
|
||||||
|
sql = sql.TrimEnd(',');
|
||||||
|
sql += " where id=" + id + "";
|
||||||
|
|
||||||
|
var rst = mySql.ExecuteNonQuery(sql);
|
||||||
|
mySql.Close();
|
||||||
|
if (rst)
|
||||||
|
{
|
||||||
|
return "{\"code\":200,\"msg\":\"success\"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string DelUser(string inputData)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(inputData))
|
||||||
|
{
|
||||||
|
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
||||||
|
var id = RegexUtils.GetStringQuery(ref inputData, "id");
|
||||||
|
int r2 = 0;
|
||||||
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
||||||
|
|
||||||
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||||
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
|
string sql = "delete from kjd.user where id='"
|
||||||
|
+ id + "'";
|
||||||
|
|
||||||
|
var rst = mySql.ExecuteNonQuery(sql);
|
||||||
|
mySql.Close();
|
||||||
|
if (rst)
|
||||||
|
{
|
||||||
|
return "{\"code\":200,\"msg\":\"success\"}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return "{\"code\":200,\"msg\":\"删除失败,请稍后重试\"}";
|
||||||
|
}
|
||||||
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetAllUser(string inputData)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(inputData))
|
||||||
|
{
|
||||||
|
var user_name = RegexUtils.GetStringQuery(ref inputData, "user_name");
|
||||||
|
var password = RegexUtils.GetStringQuery(ref inputData, "password");
|
||||||
|
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id");
|
||||||
|
var search = RegexUtils.GetStringQuery(ref inputData, "search");
|
||||||
|
int r2 = 0;
|
||||||
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
||||||
|
|
||||||
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||||
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
|
//string sql = "select * from kjd.user where group_id=3";
|
||||||
|
string sql = "select * from kjd.user where 1=1";
|
||||||
|
if (!string.IsNullOrEmpty(group_id))
|
||||||
|
sql+=" and group_id=" + group_id + " ";
|
||||||
|
if (!string.IsNullOrEmpty(search))
|
||||||
|
sql += " and (user_name like '%" + search +
|
||||||
|
"%' or nick_name like '%" + search +
|
||||||
|
"%' or company_name like '%" + search + "%')";
|
||||||
|
sql += " order by id desc";
|
||||||
|
|
||||||
|
var dt = mySql.ExecuteDataTable(sql);
|
||||||
|
mySql.Close();
|
||||||
|
if (dt != null)
|
||||||
|
{
|
||||||
|
List<UserLoginResultParam> userList = new List<UserLoginResultParam>();
|
||||||
|
foreach (DataRow row in dt.Rows)
|
||||||
|
{
|
||||||
|
|
||||||
|
UserLoginResultParam user = new UserLoginResultParam
|
||||||
|
{
|
||||||
|
id = Convert.ToInt32(row["id"]),
|
||||||
|
user_name = row["user_name"].ToString(),
|
||||||
|
nick_name = row["nick_name"].ToString(),
|
||||||
|
mobile = row["mobile"].ToString(),
|
||||||
|
password = row["password"].ToString(),
|
||||||
|
group_id = row["group_id"].ToString(),
|
||||||
|
card_id = row["card_id"].ToString(),
|
||||||
|
parent_user_name = row["parent_user_name"].ToString(),
|
||||||
|
company_name = row["company_name"].ToString(),
|
||||||
|
notes = row["notes"].ToString(),
|
||||||
|
};
|
||||||
|
if (string.IsNullOrEmpty(user.mobile))
|
||||||
|
{
|
||||||
|
user.mobile = row["user_name"].ToString();
|
||||||
|
}
|
||||||
|
userList.Add(user);
|
||||||
|
}
|
||||||
|
var data = JsonUtils.SerializerObjectToString(userList);
|
||||||
|
return "{\"code\":200,\"msg\":\"success\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public string AddUser(string inputData)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(inputData))
|
||||||
|
{
|
||||||
|
var nick_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_nick_name"));
|
||||||
|
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_user_name"));
|
||||||
|
var mobile = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_mobile"));
|
||||||
|
var password = RegexUtils.GetStringQuery(ref inputData, "add_password");
|
||||||
|
var company_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_company"));
|
||||||
|
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id");
|
||||||
|
var card_id = RegexUtils.GetStringQuery(ref inputData, "card_id");
|
||||||
|
var notes = RegexUtils.GetStringQuery(ref inputData, "notes");
|
||||||
|
int r2 = 0;
|
||||||
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
||||||
|
|
||||||
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||||
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
|
string sql = "";
|
||||||
|
sql = "select exists (select 1 from kjd.user where user_name='" + user_name + "')";
|
||||||
|
var exist = mySql.ExecuteFirstInt(sql);
|
||||||
|
if (exist > 0)
|
||||||
|
{
|
||||||
|
mySql.Close();
|
||||||
|
return "{\"code\":500,\"msg\":\"用户名已存在\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
sql = "insert into kjd.user (nick_name,user_name,mobile,password,card_id,group_id,company_name,notes,add_time,mdy_time) " +
|
||||||
|
"values ('" + nick_name + "','" + user_name + "','" + mobile + "','" + password + "','" + card_id + "','" +
|
||||||
|
group_id + "','" + company_name + "','" + notes + "','" +
|
||||||
|
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" +
|
||||||
|
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');";
|
||||||
|
var rst = mySql.ExecuteNonQuery(sql);
|
||||||
|
mySql.Close();
|
||||||
|
if (!rst)
|
||||||
|
return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}";
|
||||||
|
else
|
||||||
|
return "{\"code\":200,\"msg\":\"success\"}";
|
||||||
|
}
|
||||||
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public string UpdateUser(string inputData)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(inputData))
|
||||||
|
{
|
||||||
|
var id = RegexUtils.GetStringQuery(ref inputData, "id");
|
||||||
|
var nick_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_nick_name"));
|
||||||
|
var user_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_user_name"));
|
||||||
|
var mobile = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_mobile"));
|
||||||
|
var company_name = HtmlUtils.UrlDecodeUtf8(RegexUtils.GetStringQuery(ref inputData, "add_company"));
|
||||||
|
var password = RegexUtils.GetStringQuery(ref inputData, "add_password");
|
||||||
|
var group_id = RegexUtils.GetStringQuery(ref inputData, "group_id");
|
||||||
|
var card_id = RegexUtils.GetStringQuery(ref inputData, "card_id");
|
||||||
|
int r2 = 0;
|
||||||
|
int.TryParse(RegexUtils.GetStringQuery(ref inputData, "r2"), out r2);
|
||||||
|
|
||||||
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString;
|
||||||
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
|
string sql = "";
|
||||||
|
//sql = "select * from kjd.user where parent_user_name='"
|
||||||
|
// + user_name + "'";
|
||||||
|
sql = "update kjd.user set";
|
||||||
|
if (!string.IsNullOrEmpty(nick_name))
|
||||||
|
sql += " nick_name='" + nick_name + "',";
|
||||||
|
if (!string.IsNullOrEmpty(user_name))
|
||||||
|
sql += " user_name='" + user_name + "',";
|
||||||
|
if (!string.IsNullOrEmpty(mobile))
|
||||||
|
sql += " mobile='" + mobile + "',";
|
||||||
|
if (!string.IsNullOrEmpty(company_name))
|
||||||
|
sql += " company_name='" + company_name + "',";
|
||||||
|
if (!string.IsNullOrEmpty(password))
|
||||||
|
sql += " password='" + password + "',";
|
||||||
|
if (!string.IsNullOrEmpty(group_id))
|
||||||
|
sql += " group_id=" + group_id + ",";
|
||||||
|
if (!string.IsNullOrEmpty(card_id))
|
||||||
|
sql += " card_id='" + card_id + "',";
|
||||||
|
sql = sql.TrimEnd(',');
|
||||||
|
sql += " where id=" + id + "";
|
||||||
|
|
||||||
|
var rst = mySql.ExecuteNonQuery(sql);
|
||||||
|
mySql.Close();
|
||||||
|
if (rst)
|
||||||
|
{
|
||||||
|
return "{\"code\":200,\"msg\":\"success\"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "{\"code\":19999,\"msg\":\"未知错误\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public string ChangePassword(string inputData)
|
||||||
|
{
|
||||||
|
var userName = RegexUtils.GetStringJson(ref inputData, "user_name");
|
||||||
|
var password = RegexUtils.GetStringJson(ref inputData, "password");
|
||||||
|
var newPassword = RegexUtils.GetStringJson(ref inputData, "new_password");
|
||||||
|
|
||||||
|
string conn = System.Configuration.ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;
|
||||||
|
MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
|
string sql = "select user_id,password from pepdtp.user where user_id='"
|
||||||
|
+ userName + "' and password='" + password + "'";
|
||||||
|
|
||||||
|
var dw = mySql.ExecuteDataTableRow(sql);
|
||||||
|
if (dw != null)
|
||||||
|
{
|
||||||
|
UserLoginResultParam user = new UserLoginResultParam
|
||||||
|
{
|
||||||
|
user_name = dw["user_id"].ToString(),
|
||||||
|
password = dw["password"].ToString(),
|
||||||
|
};
|
||||||
|
sql = "update pepdtp.user set password = '" + newPassword + "' where user_id='" + userName + "'";
|
||||||
|
var result = mySql.ExecuteNonQuery(sql);
|
||||||
|
mySql.Close();
|
||||||
|
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
return "{\"code\":0,\"msg\":\"密码修改成功!\"}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return "{\"code\":19999,\"msg\":\"密码修改失败!请稍后再试。\"}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mySql.Close();
|
||||||
|
return "{\"code\":1,\"msg\":\"原密码错误。\"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<%@ Application Codebehind="Global.asax.cs" Inherits="KJD_Web.Global" Language="C#" %>
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Security;
|
||||||
|
using System.Web.SessionState;
|
||||||
|
|
||||||
|
namespace KJD_Web
|
||||||
|
{
|
||||||
|
public class Global : System.Web.HttpApplication
|
||||||
|
{
|
||||||
|
|
||||||
|
protected void Application_Start(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void Session_Start(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void Application_BeginRequest(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string hPath = Request.Url.LocalPath.ToString();
|
||||||
|
if (!hPath.Contains(".asmx") && hPath.Contains("/user/"))
|
||||||
|
{
|
||||||
|
hPath = hPath.Replace("/user/", "/UserService.asmx/");
|
||||||
|
Context.RewritePath(hPath);
|
||||||
|
}
|
||||||
|
else if (!hPath.Contains(".asmx") && hPath.Contains("/shop/"))
|
||||||
|
{
|
||||||
|
hPath = hPath.Replace("/shop/", "/ShopService.asmx/");
|
||||||
|
Context.RewritePath(hPath);
|
||||||
|
}
|
||||||
|
else if (!hPath.Contains(".asmx") && hPath.Contains("/update/"))
|
||||||
|
{
|
||||||
|
hPath = hPath.Replace("/update/", "/UpdateService.asmx/");
|
||||||
|
Context.RewritePath(hPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void Application_AuthenticateRequest(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void Application_Error(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void Session_End(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void Application_End(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>
|
||||||
|
</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{A6C03FE1-142A-4C97-99A9-67FD915836B6}</ProjectGuid>
|
||||||
|
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>KJD_Web</RootNamespace>
|
||||||
|
<AssemblyName>KJD_WebService</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||||
|
<UseIISExpress>true</UseIISExpress>
|
||||||
|
<Use64BitIISExpress />
|
||||||
|
<IISExpressSSLPort>44313</IISExpressSSLPort>
|
||||||
|
<IISExpressAnonymousAuthentication />
|
||||||
|
<IISExpressWindowsAuthentication />
|
||||||
|
<IISExpressUseClassicPipelineMode />
|
||||||
|
<UseGlobalApplicationHostFile />
|
||||||
|
<NuGetPackageImportStamp>
|
||||||
|
</NuGetPackageImportStamp>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="MySql.Data">
|
||||||
|
<HintPath>..\Dll\MySql.Data.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=13.0.1.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\Dll\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="System.Web.DynamicData" />
|
||||||
|
<Reference Include="System.Web.Entity" />
|
||||||
|
<Reference Include="System.Web.ApplicationServices" />
|
||||||
|
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Web" />
|
||||||
|
<Reference Include="System.Web.Extensions" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="System.Configuration" />
|
||||||
|
<Reference Include="System.Web.Services" />
|
||||||
|
<Reference Include="System.EnterpriseServices" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform">
|
||||||
|
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Global.asax" />
|
||||||
|
<Content Include="ShopService.asmx" />
|
||||||
|
<Content Include="UpdateService.asmx" />
|
||||||
|
<Content Include="UserService.asmx" />
|
||||||
|
<Content Include="Web.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="BLL\ShopManage.cs" />
|
||||||
|
<Compile Include="BLL\UpadteManage.cs" />
|
||||||
|
<Compile Include="BLL\UserManage.cs" />
|
||||||
|
<Compile Include="Global.asax.cs">
|
||||||
|
<DependentUpon>Global.asax</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Model\CommentParam.cs" />
|
||||||
|
<Compile Include="Model\OrderParam.cs" />
|
||||||
|
<Compile Include="Model\ShopModel\ShopParam.cs" />
|
||||||
|
<Compile Include="Model\UserLoginResultParam.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="ShopService.asmx.cs">
|
||||||
|
<DependentUpon>ShopService.asmx</DependentUpon>
|
||||||
|
<SubType>Component</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="UpdateService.asmx.cs">
|
||||||
|
<DependentUpon>UpdateService.asmx</DependentUpon>
|
||||||
|
<SubType>Component</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="UserService.asmx.cs">
|
||||||
|
<DependentUpon>UserService.asmx</DependentUpon>
|
||||||
|
<SubType>Component</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Utils\EncrypUtil.cs" />
|
||||||
|
<Compile Include="Utils\HtmlUtils.cs" />
|
||||||
|
<Compile Include="Utils\JsonUtils.cs" />
|
||||||
|
<Compile Include="Utils\MySqlUtils.cs" />
|
||||||
|
<Compile Include="Utils\RegexUtils.cs" />
|
||||||
|
<Compile Include="Utils\TimeUtils.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
<None Include="Web.Debug.config">
|
||||||
|
<DependentUpon>Web.config</DependentUpon>
|
||||||
|
</None>
|
||||||
|
<None Include="Web.Release.config">
|
||||||
|
<DependentUpon>Web.config</DependentUpon>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
|
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
|
||||||
|
<ProjectExtensions>
|
||||||
|
<VisualStudio>
|
||||||
|
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||||
|
<WebProjectProperties>
|
||||||
|
<UseIIS>True</UseIIS>
|
||||||
|
<AutoAssignPort>True</AutoAssignPort>
|
||||||
|
<DevelopmentServerPort>49977</DevelopmentServerPort>
|
||||||
|
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||||
|
<IISUrl>http://localhost:9000/</IISUrl>
|
||||||
|
<NTLMAuthentication>False</NTLMAuthentication>
|
||||||
|
<UseCustomServer>False</UseCustomServer>
|
||||||
|
<CustomServerUrl>
|
||||||
|
</CustomServerUrl>
|
||||||
|
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||||
|
</WebProjectProperties>
|
||||||
|
</FlavorProperties>
|
||||||
|
</VisualStudio>
|
||||||
|
</ProjectExtensions>
|
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
|
||||||
|
</Target>
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<UseIISExpress>true</UseIISExpress>
|
||||||
|
<Use64BitIISExpress />
|
||||||
|
<IISExpressSSLPort>44313</IISExpressSSLPort>
|
||||||
|
<IISExpressAnonymousAuthentication />
|
||||||
|
<IISExpressWindowsAuthentication />
|
||||||
|
<IISExpressUseClassicPipelineMode />
|
||||||
|
<UseGlobalApplicationHostFile />
|
||||||
|
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
|
||||||
|
<ProjectView>ShowAllFiles</ProjectView>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ProjectExtensions>
|
||||||
|
<VisualStudio>
|
||||||
|
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||||
|
<WebProjectProperties>
|
||||||
|
<StartPageUrl>UserService.asmx</StartPageUrl>
|
||||||
|
<StartAction>CurrentPage</StartAction>
|
||||||
|
<AspNetDebugging>True</AspNetDebugging>
|
||||||
|
<SilverlightDebugging>False</SilverlightDebugging>
|
||||||
|
<NativeDebugging>False</NativeDebugging>
|
||||||
|
<SQLDebugging>False</SQLDebugging>
|
||||||
|
<ExternalProgram>
|
||||||
|
</ExternalProgram>
|
||||||
|
<StartExternalURL>
|
||||||
|
</StartExternalURL>
|
||||||
|
<StartCmdLineArguments>
|
||||||
|
</StartCmdLineArguments>
|
||||||
|
<StartWorkingDirectory>
|
||||||
|
</StartWorkingDirectory>
|
||||||
|
<EnableENC>True</EnableENC>
|
||||||
|
<AlwaysStartWebServerOnDebug>False</AlwaysStartWebServerOnDebug>
|
||||||
|
</WebProjectProperties>
|
||||||
|
</FlavorProperties>
|
||||||
|
</VisualStudio>
|
||||||
|
</ProjectExtensions>
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace KJD_Web.Model
|
||||||
|
{
|
||||||
|
public class CommentParam
|
||||||
|
{
|
||||||
|
public int id { get; set; }
|
||||||
|
public string user_id { get; set; }
|
||||||
|
public string comment { get; set; }
|
||||||
|
public DateTime add_time { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace KJD_Web.Model
|
||||||
|
{
|
||||||
|
public class OrderParam
|
||||||
|
{
|
||||||
|
public int id { get; set; }
|
||||||
|
public string order_id { get; set; }
|
||||||
|
public string order_info { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace KJD_Web.Model.ShopModel
|
||||||
|
{
|
||||||
|
public class ShopParam
|
||||||
|
{
|
||||||
|
public int id { get; set; }
|
||||||
|
public string login_name { get; set; }
|
||||||
|
public string login_pass { get; set; }
|
||||||
|
public string cookie { get; set; }
|
||||||
|
public string shop_id { get; set; }
|
||||||
|
public string shop_account { get; set; }
|
||||||
|
public string sub_user_name { get; set; }
|
||||||
|
public string user_name { get; set; }
|
||||||
|
public string company_name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 备注
|
||||||
|
/// </summary>
|
||||||
|
public string notes { get; set; }
|
||||||
|
public string login_status { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace KJD_Web.Model
|
||||||
|
{
|
||||||
|
public class UserLoginResultParam
|
||||||
|
{
|
||||||
|
public int id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户名
|
||||||
|
/// </summary>
|
||||||
|
public string user_name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 父用户名
|
||||||
|
/// </summary>
|
||||||
|
public string parent_user_name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 手机号(真实登录id,与用户名相同)
|
||||||
|
/// </summary>
|
||||||
|
public string mobile { get; set; }
|
||||||
|
|
||||||
|
public string password { get; set; }
|
||||||
|
|
||||||
|
public string nick_name { get; set; }
|
||||||
|
|
||||||
|
public string group_id { get; set; }
|
||||||
|
|
||||||
|
public bool is_import { get; set; }
|
||||||
|
|
||||||
|
public string company_name { get; set; }
|
||||||
|
|
||||||
|
public string card_id { get; set; }
|
||||||
|
|
||||||
|
public DateTime add_time { get; set; }
|
||||||
|
|
||||||
|
public DateTime mdy_time { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 备注
|
||||||
|
/// </summary>
|
||||||
|
public string notes { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// 有关程序集的常规信息通过下列特性集
|
||||||
|
// 控制。更改这些特性值可修改
|
||||||
|
// 与程序集关联的信息。
|
||||||
|
[assembly: AssemblyTitle("KJD_WebService")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("KJD_WebService")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2025")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||||
|
// 对 COM 组件不可见。如果需要
|
||||||
|
// 从 COM 访问此程序集中的某个类型,请针对该类型将 ComVisible 特性设置为 true。
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// 如果此项目向 COM 公开,则下列 GUID 用于 typelib 的 ID
|
||||||
|
[assembly: Guid("a6c03fe1-142a-4c97-99a9-67fd915836b6")]
|
||||||
|
|
||||||
|
// 程序集的版本信息由下列四个值组成:
|
||||||
|
//
|
||||||
|
// 主版本
|
||||||
|
// 次版本
|
||||||
|
// 内部版本号
|
||||||
|
// 修订版本
|
||||||
|
//
|
||||||
|
// 可以指定所有值,也可以使用“修订号”和“内部版本号”的默认值,
|
||||||
|
// 方法是按如下所示使用 "*":
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<%@ WebService Language="C#" CodeBehind="ShopService.asmx.cs" Class="KJD_Web.ShopService" %>
|
||||||
@@ -0,0 +1,172 @@
|
|||||||
|
using KJD_Web.BLL;
|
||||||
|
using KJD_Web.Utils;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Services;
|
||||||
|
|
||||||
|
namespace KJD_Web
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ShopService 的摘要说明
|
||||||
|
/// </summary>
|
||||||
|
[WebService(Namespace = "http://tempuri.org/")]
|
||||||
|
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
|
||||||
|
[System.ComponentModel.ToolboxItem(false)]
|
||||||
|
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。
|
||||||
|
// [System.Web.Script.Services.ScriptService]
|
||||||
|
public class ShopService : System.Web.Services.WebService
|
||||||
|
{
|
||||||
|
private string GetRequestJsonString()
|
||||||
|
{
|
||||||
|
Context.Response.ContentType = "text/html;charset=utf-8";
|
||||||
|
Context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
|
||||||
|
|
||||||
|
using (Stream s = HttpContext.Current.Request.InputStream) // 获得json 字符流
|
||||||
|
{
|
||||||
|
// 还原数据流
|
||||||
|
byte[] b = new byte[s.Length];
|
||||||
|
s.Read(b, 0, (int)s.Length);
|
||||||
|
string jsonText = Encoding.UTF8.GetString(b); // JSON字符串
|
||||||
|
if (string.IsNullOrEmpty(jsonText))
|
||||||
|
{
|
||||||
|
var qs = HttpContext.Current.Request.QueryString;
|
||||||
|
if (qs != null && qs.Keys.Count > 0)
|
||||||
|
{
|
||||||
|
jsonText = "{";
|
||||||
|
foreach (var key in qs.Keys)
|
||||||
|
{
|
||||||
|
jsonText += "\"" + key + "\":" + "\"" + qs[key.ToString()] + "\";";
|
||||||
|
}
|
||||||
|
jsonText = jsonText.TrimEnd(';') + "}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return jsonText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public void get_shop_list()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new ShopManage().GetShop(jsontext);
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public void get_one_login_name_shop()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new ShopManage().GetOneLoginNameShop(jsontext);
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public void add_shop()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new ShopManage().AddShop(jsontext);
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public void del_shop()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new ShopManage().DelShop(jsontext);
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public void mdy_shop()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new ShopManage().MdyShop(jsontext);
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public void mdy_shop_cookie_and_login_status()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new ShopManage().MdyCookieAndLoginStatus(jsontext);
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public void admin_get_shop_list()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new ShopManage().GetShop(jsontext, true);
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public void admin_mdy_shop()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new ShopManage().MdyShop(jsontext, true);
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public void admin_add_shop()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new ShopManage().AddShop(jsontext, true);
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public void admin_del_shop()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new ShopManage().DelShop(jsontext, true);
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<%@ WebService Language="C#" CodeBehind="UpdateService.asmx.cs" Class="KJD_Web.UpdateService" %>
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
using KJD_Web.BLL;
|
||||||
|
using KJD_Web.Utils;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Services;
|
||||||
|
|
||||||
|
namespace KJD_Web
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// UpdateService 的摘要说明
|
||||||
|
/// </summary>
|
||||||
|
[WebService(Namespace = "http://tempuri.org/")]
|
||||||
|
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
|
||||||
|
[System.ComponentModel.ToolboxItem(false)]
|
||||||
|
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。
|
||||||
|
// [System.Web.Script.Services.ScriptService]
|
||||||
|
public class UpdateService : System.Web.Services.WebService
|
||||||
|
{
|
||||||
|
[WebMethod]
|
||||||
|
public string hello_world()
|
||||||
|
{
|
||||||
|
return "Hello World";
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetRequestJsonString()
|
||||||
|
{
|
||||||
|
Context.Response.ContentType = "text/html;charset=utf-8";
|
||||||
|
Context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
|
||||||
|
|
||||||
|
using (Stream s = HttpContext.Current.Request.InputStream) // 获得json 字符流
|
||||||
|
{
|
||||||
|
// 还原数据流
|
||||||
|
byte[] b = new byte[s.Length];
|
||||||
|
s.Read(b, 0, (int)s.Length);
|
||||||
|
string jsonText = Encoding.UTF8.GetString(b); // JSON字符串
|
||||||
|
if (string.IsNullOrEmpty(jsonText))
|
||||||
|
{
|
||||||
|
var qs = HttpContext.Current.Request.QueryString;
|
||||||
|
if (qs != null && qs.Keys.Count > 0)
|
||||||
|
{
|
||||||
|
jsonText = "{";
|
||||||
|
foreach (var key in qs.Keys)
|
||||||
|
{
|
||||||
|
jsonText += "\"" + key + "\":" + "\"" + qs[key.ToString()] + "\";";
|
||||||
|
}
|
||||||
|
jsonText = jsonText.TrimEnd(';') + "}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return jsonText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public void get_update()
|
||||||
|
{
|
||||||
|
var jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new UpadteManage().GetUpdate(jsontext);
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<%@ WebService Language="C#" CodeBehind="UserService.asmx.cs" Class="KJD_Web.UserService" %>
|
||||||
@@ -0,0 +1,359 @@
|
|||||||
|
using KJD_Web.BLL;
|
||||||
|
using KJD_Web.Utils;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Services;
|
||||||
|
|
||||||
|
namespace KJD_Web
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// UserService 的摘要说明
|
||||||
|
/// </summary>
|
||||||
|
[WebService(Namespace = "http://tempuri.org/")]
|
||||||
|
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
|
||||||
|
[System.ComponentModel.ToolboxItem(false)]
|
||||||
|
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。
|
||||||
|
// [System.Web.Script.Services.ScriptService]
|
||||||
|
public class UserService : System.Web.Services.WebService
|
||||||
|
{
|
||||||
|
[WebMethod]
|
||||||
|
public string hello_world()
|
||||||
|
{
|
||||||
|
return "Hello World";
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetRequestJsonString()
|
||||||
|
{
|
||||||
|
Context.Response.ContentType = "text/html;charset=utf-8";
|
||||||
|
Context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
|
||||||
|
|
||||||
|
using (Stream s = HttpContext.Current.Request.InputStream) // 获得json 字符流
|
||||||
|
{
|
||||||
|
// 还原数据流
|
||||||
|
byte[] b = new byte[s.Length];
|
||||||
|
s.Read(b, 0, (int)s.Length);
|
||||||
|
string jsonText = Encoding.UTF8.GetString(b); // JSON字符串
|
||||||
|
if (string.IsNullOrEmpty(jsonText))
|
||||||
|
{
|
||||||
|
var qs = HttpContext.Current.Request.QueryString;
|
||||||
|
if (qs != null && qs.Keys.Count > 0)
|
||||||
|
{
|
||||||
|
jsonText = "{";
|
||||||
|
foreach (var key in qs.Keys)
|
||||||
|
{
|
||||||
|
jsonText += "\"" + key + "\":" + "\"" + qs[key.ToString()] + "\";";
|
||||||
|
}
|
||||||
|
jsonText = jsonText.TrimEnd(';') + "}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return jsonText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public void user_login()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new UserManage().CheckUserLogin(jsontext);
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public void change_password()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new UserManage().ChangePassword(jsontext);
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public void get_sub_user()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new UserManage().GetSubUser(jsontext);
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public void update_sub_user()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new UserManage().UpdateSubUser(jsontext);
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public void add_sub_user()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new UserManage().AddSubUser(jsontext);
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public void delete_user()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new UserManage().DelUser(jsontext);
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public void get_all_user()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new UserManage().GetAllUser(jsontext);
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public void update_user()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new UserManage().UpdateUser(jsontext);
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public void add_user()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new UserManage().AddUser(jsontext);
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region 暂时作废
|
||||||
|
/*
|
||||||
|
[WebMethod]
|
||||||
|
public void GetServer()
|
||||||
|
{
|
||||||
|
var softName = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = "";
|
||||||
|
//result = System.Configuration.ConfigurationManager.ConnectionStrings[softName + "ServerUrl"].ConnectionString;
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public void GetUpdateInfo()
|
||||||
|
{
|
||||||
|
string jsontext = GetRequestJsonString();
|
||||||
|
|
||||||
|
var result = jsontext;
|
||||||
|
result = new UpadteManage().CheckUpdate(jsontext);
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public byte[] DownloadFile()
|
||||||
|
{
|
||||||
|
string file = Server.MapPath("").Substring(0, Server.MapPath("").LastIndexOf("\\")) + "\\bin\\test.txt";
|
||||||
|
|
||||||
|
System.IO.FileStream fs = null;
|
||||||
|
if (System.IO.File.Exists(file))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
fs = System.IO.File.OpenRead(file);
|
||||||
|
int b1;
|
||||||
|
System.IO.MemoryStream tempStream = new System.IO.MemoryStream();
|
||||||
|
while ((b1 = fs.ReadByte()) != -1)
|
||||||
|
{
|
||||||
|
tempStream.WriteByte(((byte)b1));
|
||||||
|
}
|
||||||
|
return tempStream.ToArray();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return new byte[0];
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
fs.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new byte[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///客户端:
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 从服务器上下载文件,未用
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str1">源文件:如“E:\\city.txt”</param>
|
||||||
|
/// <param name="str2">目标文件:如@"d:\city.txt"</param>
|
||||||
|
//public static void DownFile(string str1, string str2)
|
||||||
|
//{
|
||||||
|
// CRMweb.WebService1SoapClient myWeb = new CRMweb.WebService1SoapClient();
|
||||||
|
// byte[] bs = myWeb.DownloadFile(str1);
|
||||||
|
// System.IO.FileStream stream = new System.IO.FileStream(str2, System.IO.FileMode.CreateNew);
|
||||||
|
// stream.Write(bs, 0, bs.Length);
|
||||||
|
// stream.Flush();
|
||||||
|
// stream.Close();
|
||||||
|
//}
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public void AddComment()
|
||||||
|
{
|
||||||
|
string result="";
|
||||||
|
|
||||||
|
//// 输入为querystring
|
||||||
|
//var jsonText = GetRequestJsonString();
|
||||||
|
//try
|
||||||
|
//{
|
||||||
|
// var user_id = RegexUtils.GetStringJson(ref jsonText, "user_id");
|
||||||
|
// var comment = RegexUtils.GetStringJson(ref jsonText, "comment");
|
||||||
|
// if (string.IsNullOrEmpty(user_id))
|
||||||
|
// result = "{\"code\":1,\"msg\":\"未指定用户Id\"}";
|
||||||
|
// else if (string.IsNullOrEmpty(comment))
|
||||||
|
// result = "{\"code\":2,\"msg\":\"未指定留言内容\"}";
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// string sql = "insert into pepdtp.comment ";
|
||||||
|
// string sql1 = "(";
|
||||||
|
// string sql2 = "(";
|
||||||
|
// if (user_id != null) { sql1 += "user_id,"; sql2 += "'" + user_id + "',"; }
|
||||||
|
// if (comment != null) { sql1 += "comment,"; sql2 += "'" + comment + "',"; }
|
||||||
|
// var tTime = "'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',";
|
||||||
|
// sql1 += "add_time,";
|
||||||
|
// sql2 += tTime;
|
||||||
|
// sql1 = sql1.TrimEnd(',') + ")";
|
||||||
|
// sql2 = sql2.TrimEnd(',') + ")";
|
||||||
|
// sql = sql + sql1 + " values " + sql2;
|
||||||
|
|
||||||
|
// string conn = System.Configuration.ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;
|
||||||
|
// MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
|
// bool isSuccess = mySql.ExecuteNonQuery(sql);
|
||||||
|
// if (!isSuccess)
|
||||||
|
// {
|
||||||
|
// result = "{\"code\":10001,\"msg\":\"添加留言入库出错,请稍后重试!\"}";
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// result = "{\"code\":0,\"msg\":\"添加留言成功!\"}";
|
||||||
|
// }
|
||||||
|
// mySql.Close();
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//catch (Exception ex)
|
||||||
|
//{
|
||||||
|
// result = "{\"code\":10001,\"msg\":\"添加留言出错,请稍后重试!\"}";
|
||||||
|
//};
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
|
||||||
|
[WebMethod]
|
||||||
|
public void EditUser()
|
||||||
|
{
|
||||||
|
string result="";
|
||||||
|
|
||||||
|
// 输入为querystring
|
||||||
|
//var jsonText = GetRequestJsonString();
|
||||||
|
//try
|
||||||
|
//{
|
||||||
|
// //var role = RegexUtils.GetStringJson(ref jsonText, "role");
|
||||||
|
// var name = RegexUtils.GetStringJson(ref jsonText, "name");
|
||||||
|
// //var school = RegexUtils.GetStringJson(ref jsonText, "school");
|
||||||
|
// var rkxd = RegexUtils.GetStringJson(ref jsonText, "rkxd");
|
||||||
|
// var zxxkc = RegexUtils.GetStringJson(ref jsonText, "zxxkc");
|
||||||
|
// //var is_import = RegexUtils.GetStringJson(ref jsonText, "is_import");
|
||||||
|
// //var password = RegexUtils.GetStringJson(ref jsonText, "password");
|
||||||
|
// //var order_id = RegexUtils.GetStringJson(ref jsonText, "order_id");
|
||||||
|
// var user_id = RegexUtils.GetStringJson(ref jsonText, "user_id");
|
||||||
|
// if (string.IsNullOrEmpty(user_id))
|
||||||
|
// result = "{\"code\":1,\"msg\":\"未指定用户Id\"}";
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// string sql = "update pepdtp.user set ";
|
||||||
|
// //if (role != null) sql += "role=" + role + ",";
|
||||||
|
// if (name != null) sql += "name='" + name + "',";
|
||||||
|
// //if (school != null) sql += "school='" + school + "',";
|
||||||
|
// if (rkxd != null) sql += "rkxd='" + rkxd + "',";
|
||||||
|
// if (zxxkc != null) sql += "zxxkc='" + zxxkc + "',";
|
||||||
|
// //if (is_import != null) sql += "is_import='" + is_import + "',";
|
||||||
|
// //if (password != null) sql += "password='" + password + "',";
|
||||||
|
// //if (order_id != null) sql += "order_id='" + order_id + "',";
|
||||||
|
// sql += "mdy_time='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "',";
|
||||||
|
// sql = sql.TrimEnd(' ').TrimEnd(',');
|
||||||
|
// if (user_id.Contains(","))
|
||||||
|
// sql += " where user_id in ('" + user_id.Replace(",", "','") + "')";
|
||||||
|
// else
|
||||||
|
// sql += " where user_id='" + user_id + "'";
|
||||||
|
|
||||||
|
// string conn = System.Configuration.ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;
|
||||||
|
// MysqlUtils mySql = new MysqlUtils(conn);
|
||||||
|
// bool isSuccess = mySql.ExecuteNonQuery(sql);
|
||||||
|
// if (!isSuccess)
|
||||||
|
// {
|
||||||
|
// result = "{\"code\":10001,\"msg\":\"修改用户入库出错,请稍后重试!\"}";
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// result = "{\"code\":0,\"msg\":\"修改用户成功!\"}";
|
||||||
|
// }
|
||||||
|
// mySql.Close();
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//catch (Exception ex)
|
||||||
|
//{
|
||||||
|
// result = "{\"code\":19999,\"msg\":\"修改用户出错,请稍后重试!\"}";
|
||||||
|
//};
|
||||||
|
|
||||||
|
Context.Response.Write(result);
|
||||||
|
Context.Response.End();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace KJD_Web.Utils
|
||||||
|
{
|
||||||
|
public class EncrypUtil
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 加密算法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="s">加密字符串</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string Encryption(int s)
|
||||||
|
{
|
||||||
|
string sign = $"{s}sdhewu*/fhAAue48485ew5+5%@3485esGFFHFD";
|
||||||
|
return GetMd5(sign);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// MD5加密
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="instring"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetMd5(string instring)
|
||||||
|
{
|
||||||
|
byte[] result = Encoding.Default.GetBytes(instring.Trim());
|
||||||
|
MD5 md5 = new MD5CryptoServiceProvider();
|
||||||
|
byte[] output = md5.ComputeHash(result);
|
||||||
|
return BitConverter.ToString(output).Replace("-", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取文件MD5值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="FilePath"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetFileMd5(string FilePath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FileStream get_file = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||||
|
System.Security.Cryptography.MD5CryptoServiceProvider get_md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
|
||||||
|
byte[] hash_byte = get_md5.ComputeHash(get_file);
|
||||||
|
string resule = System.BitConverter.ToString(hash_byte);
|
||||||
|
resule = resule.Replace("-", "");
|
||||||
|
get_file.Close();
|
||||||
|
return resule;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return e.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,153 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace KJD_Web.Utils
|
||||||
|
{
|
||||||
|
public class HtmlUtils
|
||||||
|
{
|
||||||
|
static public string UrlDecodeUtf8(string value)
|
||||||
|
{
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Encoding encoding = Encoding.UTF8;//你的编码 也可能是GBK
|
||||||
|
int length = value.Length;
|
||||||
|
UrlDecoder decoder = new UrlDecoder(length, encoding);
|
||||||
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
char ch = value[i];
|
||||||
|
if (ch == '+')
|
||||||
|
{
|
||||||
|
ch = ' ';
|
||||||
|
}
|
||||||
|
else if ((ch == '%') && (i < (length - 2)))
|
||||||
|
{
|
||||||
|
if ((value[i + 1] == 'u') && (i < (length - 5)))
|
||||||
|
{
|
||||||
|
int num3 = HexToInt(value[i + 2]);
|
||||||
|
int num4 = HexToInt(value[i + 3]);
|
||||||
|
int num5 = HexToInt(value[i + 4]);
|
||||||
|
int num6 = HexToInt(value[i + 5]);
|
||||||
|
if (((num3 < 0) || (num4 < 0)) || ((num5 < 0) || (num6 < 0)))
|
||||||
|
{
|
||||||
|
goto Label_010B;
|
||||||
|
}
|
||||||
|
ch = (char)((((num3 << 12) | (num4 << 8)) | (num5 << 4)) | num6);
|
||||||
|
i += 5;
|
||||||
|
decoder.AddChar(ch);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int num7 = HexToInt(value[i + 1]);
|
||||||
|
int num8 = HexToInt(value[i + 2]);
|
||||||
|
if ((num7 >= 0) && (num8 >= 0))
|
||||||
|
{
|
||||||
|
byte b = (byte)((num7 << 4) | num8);
|
||||||
|
i += 2;
|
||||||
|
decoder.AddByte(b);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Label_010B:
|
||||||
|
if ((ch & 0xff80) == 0)
|
||||||
|
{
|
||||||
|
decoder.AddByte((byte)ch);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
decoder.AddChar(ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return decoder.GetString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int HexToInt(char h)
|
||||||
|
{
|
||||||
|
if ((h >= '0') && (h <= '9'))
|
||||||
|
{
|
||||||
|
return (h - '0');
|
||||||
|
}
|
||||||
|
if ((h >= 'a') && (h <= 'f'))
|
||||||
|
{
|
||||||
|
return ((h - 'a') + 10);
|
||||||
|
}
|
||||||
|
if ((h >= 'A') && (h <= 'F'))
|
||||||
|
{
|
||||||
|
return ((h - 'A') + 10);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// class UrlDecoder
|
||||||
|
/// </summary>
|
||||||
|
class UrlDecoder
|
||||||
|
{
|
||||||
|
// Fields
|
||||||
|
private int _bufferSize;
|
||||||
|
private byte[] _byteBuffer;
|
||||||
|
private char[] _charBuffer;
|
||||||
|
private Encoding _encoding;
|
||||||
|
private int _numBytes;
|
||||||
|
private int _numChars;
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
internal UrlDecoder(int bufferSize, Encoding encoding)
|
||||||
|
{
|
||||||
|
this._bufferSize = bufferSize;
|
||||||
|
this._encoding = encoding;
|
||||||
|
this._charBuffer = new char[bufferSize];
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void AddByte(byte b)
|
||||||
|
{
|
||||||
|
if (this._byteBuffer == null)
|
||||||
|
{
|
||||||
|
this._byteBuffer = new byte[this._bufferSize];
|
||||||
|
}
|
||||||
|
this._byteBuffer[this._numBytes++] = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void AddChar(char ch)
|
||||||
|
{
|
||||||
|
if (this._numBytes > 0)
|
||||||
|
{
|
||||||
|
this.FlushBytes();
|
||||||
|
}
|
||||||
|
this._charBuffer[this._numChars++] = ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FlushBytes()
|
||||||
|
{
|
||||||
|
if (this._numBytes > 0)
|
||||||
|
{
|
||||||
|
this._numChars += this._encoding.GetChars(this._byteBuffer, 0, this._numBytes, this._charBuffer, this._numChars);
|
||||||
|
this._numBytes = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal string GetString()
|
||||||
|
{
|
||||||
|
if (this._numBytes > 0)
|
||||||
|
{
|
||||||
|
this.FlushBytes();
|
||||||
|
}
|
||||||
|
if (this._numChars > 0)
|
||||||
|
{
|
||||||
|
return new string(this._charBuffer, 0, this._numChars);
|
||||||
|
}
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace KJD_Web.Utils
|
||||||
|
{
|
||||||
|
public class JsonUtils
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 反序列化Json字符串生成对象实体
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">对象类型</typeparam>
|
||||||
|
/// <param name="jsonStr">json字符串</param>
|
||||||
|
/// <returns>对象实体</returns>
|
||||||
|
public static T DeserializeJsonToObject<T>(string jsonStr) where T : class
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
JsonSerializer serializer = new JsonSerializer();
|
||||||
|
StringReader sr = new StringReader(jsonStr);
|
||||||
|
object obj = serializer.Deserialize(new JsonTextReader(sr), typeof(T));
|
||||||
|
T t = obj as T;
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string SerializerObjectToString(object obj)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string str = JsonConvert.SerializeObject(obj, Formatting.None);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,682 @@
|
|||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace KJD_Web.Utils
|
||||||
|
{
|
||||||
|
public class MysqlUtils
|
||||||
|
{
|
||||||
|
public string Message = "";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据库连接字符串
|
||||||
|
/// </summary>
|
||||||
|
private string ConnString = "";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据库连接
|
||||||
|
/// </summary>
|
||||||
|
private MySqlConnection Conn;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据库读取对象
|
||||||
|
/// </summary>
|
||||||
|
private MySqlDataReader reader;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据库执行对象
|
||||||
|
/// </summary>
|
||||||
|
private MySqlCommand cmd = new MySqlCommand();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 错误信息
|
||||||
|
/// </summary>
|
||||||
|
//public static string ErrorString = "";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 超时(秒)
|
||||||
|
/// </summary>
|
||||||
|
public int TimeOut = 120;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 链接状态
|
||||||
|
/// </summary>
|
||||||
|
public bool Connected
|
||||||
|
{
|
||||||
|
get { return Conn != null && Conn.State == ConnectionState.Open; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否正在执行
|
||||||
|
/// </summary>
|
||||||
|
public bool IsRunning = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化数据库链接
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="connString">数据库链接</param>
|
||||||
|
public MysqlUtils(string connString)
|
||||||
|
{
|
||||||
|
ConnString = connString;
|
||||||
|
ConnTo();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 去掉SQL中的特殊字符
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">字符串</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string ReplaceSql(string value)
|
||||||
|
{
|
||||||
|
return ReplaceSqlSpecial(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 反转字符串,用于mysql反向索引
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="temp"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string ReverseString(string temp)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(temp))
|
||||||
|
return null;
|
||||||
|
char[] l = temp.ToCharArray();
|
||||||
|
Array.Reverse(l);
|
||||||
|
return new string(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 去掉SQL中的特殊字符
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">字符串</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string ReplaceSqlSpecial(string value)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(value))
|
||||||
|
return null;
|
||||||
|
value = value.Replace("\\", "\\\\");
|
||||||
|
value = value.Replace("'", "''");
|
||||||
|
//value = value.Replace("\"", "\\\"");
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 插入数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="table"></param>
|
||||||
|
/// <param name="keys"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int Insert(string table, List<MysqlKeyValue> keys)
|
||||||
|
{
|
||||||
|
string temp = "", tempx = "";
|
||||||
|
for (int i = 0; i < keys.Count; i++)
|
||||||
|
{
|
||||||
|
temp += ",`" + keys[i].Key + "`";
|
||||||
|
tempx += ",'" + keys[i].Value + "'";
|
||||||
|
}
|
||||||
|
temp = temp.Substring(1);
|
||||||
|
tempx = tempx.Substring(1);
|
||||||
|
string sql = "insert into " + table + " (" + temp + ") values (" + tempx + ") ";
|
||||||
|
return (int)ExecuteInsertId(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回执行表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SqlString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public DataTable ExecuteDataTable(string SqlString)
|
||||||
|
{
|
||||||
|
return ExecuteDataTable(SqlString, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 执行sql返回DataTable
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SqlString">SQL语句</param>
|
||||||
|
/// <param name="parms">Sql参数</param>
|
||||||
|
/// <returns>DataTable</returns>
|
||||||
|
public DataTable ExecuteDataTable(string SqlString, MySqlParameter[] parms)
|
||||||
|
{
|
||||||
|
SleepOrGo();
|
||||||
|
bool frist = true;
|
||||||
|
Retry:
|
||||||
|
if (Conn == null || Conn.State != ConnectionState.Open)
|
||||||
|
ConnTo();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CmdIni();
|
||||||
|
cmd.CommandText = SqlString;
|
||||||
|
if (parms != null)
|
||||||
|
foreach (MySqlParameter pram in parms)
|
||||||
|
cmd.Parameters.Add(pram);
|
||||||
|
DataSet ds = new DataSet();
|
||||||
|
MySqlDataAdapter adapter = new MySqlDataAdapter();
|
||||||
|
adapter.SelectCommand = cmd;
|
||||||
|
adapter.Fill(ds);
|
||||||
|
return ds.Tables[0];
|
||||||
|
//DataTable dt = new DataTable();
|
||||||
|
//try
|
||||||
|
//{
|
||||||
|
// reader = cmd.ExecuteReader();
|
||||||
|
// dt.Load(reader);
|
||||||
|
//}
|
||||||
|
//catch
|
||||||
|
//{
|
||||||
|
// reader = cmd.ExecuteReader();
|
||||||
|
// dt = Read(ref reader);
|
||||||
|
//}
|
||||||
|
//return dt;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
if (frist)
|
||||||
|
{
|
||||||
|
frist = false;
|
||||||
|
ErrorDoing(e.Message);
|
||||||
|
goto Retry;
|
||||||
|
}
|
||||||
|
AddError(e.Message, SqlString);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseReader();
|
||||||
|
IsRunning = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 针对不同错误,执行不同的修正
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message"></param>
|
||||||
|
private void ErrorDoing(string message)
|
||||||
|
{
|
||||||
|
Message = message;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(message))
|
||||||
|
return;
|
||||||
|
if (message.Contains("Incorrect string value"))
|
||||||
|
return;
|
||||||
|
if (message.Contains("Connection must be valid and open"))
|
||||||
|
ConnTo();
|
||||||
|
if (message.Contains("There is already an open DataReader"))
|
||||||
|
{
|
||||||
|
Thread.Sleep(500);
|
||||||
|
ConnTo();
|
||||||
|
}
|
||||||
|
if (message.Contains("Fatal error encountered during command execution."))
|
||||||
|
ConnTo();
|
||||||
|
if (message.Contains(" StreamWriter ") || message.Contains("未将对象引用设置到对象的实例") || message.Contains("未将对象"))
|
||||||
|
ConnTo();
|
||||||
|
CloseReader();
|
||||||
|
Random ra = new Random(Guid.NewGuid().GetHashCode());
|
||||||
|
Thread.Sleep(ra.Next(200, 2000));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 关闭读取线程
|
||||||
|
/// </summary>
|
||||||
|
private void CloseReader()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (reader != null && !reader.IsClosed)
|
||||||
|
reader.Close();
|
||||||
|
cmd.Dispose();
|
||||||
|
//reader = null;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回执行行
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SqlString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public DataRow ExecuteDataTableRow(string SqlString)
|
||||||
|
{
|
||||||
|
return ExecuteDataTableRow(SqlString, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回第一行
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SqlString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public DataRow ExecuteDataTableRow(string SqlString, MySqlParameter[] parms)
|
||||||
|
{
|
||||||
|
SleepOrGo();
|
||||||
|
bool frist = true;
|
||||||
|
Retry:
|
||||||
|
if (Conn == null || Conn.State != ConnectionState.Open)
|
||||||
|
ConnTo();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CmdIni();
|
||||||
|
cmd.CommandText = SqlString;
|
||||||
|
if (parms != null)
|
||||||
|
foreach (MySqlParameter pram in parms)
|
||||||
|
cmd.Parameters.Add(pram);
|
||||||
|
DataSet ds = new DataSet();
|
||||||
|
MySqlDataAdapter adapter = new MySqlDataAdapter();
|
||||||
|
adapter.SelectCommand = cmd;
|
||||||
|
adapter.Fill(ds);
|
||||||
|
DataTable dt = ds.Tables[0];
|
||||||
|
if (dt.Rows.Count > 0)
|
||||||
|
return dt.Rows[0];
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
if (frist)
|
||||||
|
{
|
||||||
|
frist = false;
|
||||||
|
ErrorDoing(e.Message);
|
||||||
|
goto Retry;
|
||||||
|
}
|
||||||
|
AddError(e.Message, SqlString);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseReader();
|
||||||
|
IsRunning = false;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回第一个执行结果
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SqlString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int ExecuteRowCount(string SqlString)
|
||||||
|
{
|
||||||
|
string f = ExecuteFirst(SqlString, null);
|
||||||
|
int c;
|
||||||
|
int.TryParse(f, out c);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回第一个执行结果
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SqlString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string ExecuteFirst(string SqlString)
|
||||||
|
{
|
||||||
|
return ExecuteFirst(SqlString, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回第一个执行结果
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SqlString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int ExecuteFirstInt(string SqlString)
|
||||||
|
{
|
||||||
|
string id = ExecuteFirst(SqlString, null);
|
||||||
|
int i;
|
||||||
|
int.TryParse(id, out i);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回第一个值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SqlString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string ExecuteFirst(string SqlString, MySqlParameter[] parms)
|
||||||
|
{
|
||||||
|
SleepOrGo();
|
||||||
|
bool frist = true;
|
||||||
|
Retry:
|
||||||
|
if (Conn == null || Conn.State != ConnectionState.Open)
|
||||||
|
ConnTo();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CmdIni();
|
||||||
|
cmd.CommandText = SqlString;
|
||||||
|
if (parms != null)
|
||||||
|
foreach (MySqlParameter pram in parms)
|
||||||
|
cmd.Parameters.Add(pram);
|
||||||
|
reader = cmd.ExecuteReader();
|
||||||
|
if (reader.Read())
|
||||||
|
return reader[0].ToString();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
if (e.Message.Contains("Illegal mix of collations"))
|
||||||
|
return null;
|
||||||
|
if (frist)
|
||||||
|
{
|
||||||
|
frist = false;
|
||||||
|
ErrorDoing(e.Message);
|
||||||
|
goto Retry;
|
||||||
|
}
|
||||||
|
AddError(e.Message, SqlString);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseReader();
|
||||||
|
IsRunning = false;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回插入ID
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SqlString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public long ExecuteInsertId(string SqlString)
|
||||||
|
{
|
||||||
|
return ExecuteInsertId(SqlString, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回第一个值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SqlString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public long ExecuteInsertId(string SqlString, MySqlParameter[] parms)
|
||||||
|
{
|
||||||
|
SleepOrGo();
|
||||||
|
bool frist = true;
|
||||||
|
Retry:
|
||||||
|
if (Conn == null || Conn.State != ConnectionState.Open)
|
||||||
|
ConnTo();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CmdIni();
|
||||||
|
cmd.CommandText = SqlString;
|
||||||
|
if (parms != null)
|
||||||
|
foreach (MySqlParameter pram in parms)
|
||||||
|
cmd.Parameters.Add(pram);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
long id = cmd.LastInsertedId;
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
if (e.Message.Contains(" for key 'PRIMARY'") && e.Message.Contains("Duplicate entry"))
|
||||||
|
return 0;
|
||||||
|
if (frist)
|
||||||
|
{
|
||||||
|
frist = false;
|
||||||
|
ErrorDoing(e.Message);
|
||||||
|
goto Retry;
|
||||||
|
}
|
||||||
|
AddError(e.Message, SqlString);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseReader();
|
||||||
|
IsRunning = false;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 无返回
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SqlString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool ExecuteNonQuery(string SqlString)
|
||||||
|
{
|
||||||
|
return ExecuteNonQuery(SqlString, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 只保留mysql可识别的字符串
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text"></param>
|
||||||
|
public string JustUtf8Words(string text)
|
||||||
|
{
|
||||||
|
JustUtf8Words(ref text);
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 只保留mysql可识别的字符串
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text"></param>
|
||||||
|
public void JustUtf8Words(ref string text)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(text))
|
||||||
|
return;
|
||||||
|
var cs = text.ToCharArray();
|
||||||
|
List<char> cc = new List<char>();
|
||||||
|
foreach (char c in cs)
|
||||||
|
{
|
||||||
|
if (c > 7814 && c < 8416 || c > 57096 && c < 59501 || c > 63707 && c < 64309 || c > 65505 || c < 0)
|
||||||
|
{
|
||||||
|
if (cc.Contains(c))
|
||||||
|
continue;
|
||||||
|
text = text.Replace(c.ToString(), "");
|
||||||
|
cc.Add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 执行无返回SQL语句
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SqlString">SQL语句</param>
|
||||||
|
/// <param name="parms">Sql参数</param>
|
||||||
|
///<returns>是否执行成功</returns>
|
||||||
|
public bool ExecuteNonQuery(string SqlString, MySqlParameter[] parms)
|
||||||
|
{
|
||||||
|
SleepOrGo();
|
||||||
|
bool frist = true;
|
||||||
|
Retry:
|
||||||
|
if (Conn == null || Conn.State != ConnectionState.Open)
|
||||||
|
ConnTo();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CmdIni();
|
||||||
|
cmd.CommandText = SqlString;
|
||||||
|
if (parms != null)
|
||||||
|
foreach (MySqlParameter pram in parms)
|
||||||
|
cmd.Parameters.Add(pram);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
if (e.Message.Contains("Illegal mix of collations") || e.Message.Contains("Incorrect string value")
|
||||||
|
|| e.Message.Contains(" for key 'PRIMARY'") && e.Message.Contains("Duplicate entry"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (frist)
|
||||||
|
{
|
||||||
|
frist = false;
|
||||||
|
ErrorDoing(e.Message);
|
||||||
|
goto Retry;
|
||||||
|
}
|
||||||
|
AddError(e.Message, SqlString);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseReader();
|
||||||
|
IsRunning = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 判断是否存在
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SqlString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool ExecuteExists(string SqlString)
|
||||||
|
{
|
||||||
|
return ExecuteExists(SqlString, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询是否存在
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="SqlString">SQL语句</param>
|
||||||
|
/// <param name="parms">SQL参数</param>
|
||||||
|
/// <returns>是否存在</returns>
|
||||||
|
public bool ExecuteExists(string SqlString, MySqlParameter[] parms)
|
||||||
|
{
|
||||||
|
SleepOrGo();
|
||||||
|
bool frist = true;
|
||||||
|
Retry:
|
||||||
|
if (Conn == null || Conn.State != ConnectionState.Open)
|
||||||
|
ConnTo();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
CmdIni();
|
||||||
|
cmd.CommandText = SqlString;
|
||||||
|
if (parms != null)
|
||||||
|
foreach (MySqlParameter pram in parms)
|
||||||
|
cmd.Parameters.Add(pram);
|
||||||
|
reader = cmd.ExecuteReader();
|
||||||
|
if (reader.Read())
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
if (frist)
|
||||||
|
{
|
||||||
|
frist = false;
|
||||||
|
ErrorDoing(e.Message);
|
||||||
|
goto Retry;
|
||||||
|
}
|
||||||
|
AddError(e.Message, SqlString);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
CloseReader();
|
||||||
|
IsRunning = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 停止还是前进
|
||||||
|
/// </summary>
|
||||||
|
private void SleepOrGo()
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
while (IsRunning && i < 300)
|
||||||
|
{
|
||||||
|
Thread.Sleep(100);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
IsRunning = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化CMD
|
||||||
|
/// </summary>
|
||||||
|
private void CmdIni()
|
||||||
|
{
|
||||||
|
if (reader != null && !reader.IsClosed)
|
||||||
|
reader.Close();
|
||||||
|
if (cmd != null)
|
||||||
|
cmd.Dispose();
|
||||||
|
cmd = new MySqlCommand();
|
||||||
|
cmd.Connection = Conn;
|
||||||
|
cmd.CommandType = CommandType.Text;
|
||||||
|
cmd.CommandTimeout = TimeOut;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 连接数据库
|
||||||
|
/// </summary>
|
||||||
|
private void ConnTo()
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Conn = new MySqlConnection(ConnString);
|
||||||
|
Conn.Open();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
AddError(e.Message, ConnString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 错误信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message"></param>
|
||||||
|
/// <param name="sql"></param>
|
||||||
|
private void AddError(string message, string sql)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(message) || message.Contains("Illegal mix of collations"))
|
||||||
|
return;
|
||||||
|
ErrorDoing(message);
|
||||||
|
string errStr = "数据库连接错误:" + message + "\r\nSQL语句:" + sql;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!Directory.Exists("Log"))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory("Log");
|
||||||
|
}
|
||||||
|
File.AppendAllText("Log\\log-" + DateTime.Now.ToString("yyyyMMdd") + ".txt", errStr);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 关闭数据库链接
|
||||||
|
/// </summary>
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
IsRunning = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Conn != null && Conn.State == ConnectionState.Open)
|
||||||
|
Conn.Close();
|
||||||
|
Conn = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (reader != null && !reader.IsClosed)
|
||||||
|
reader.Close();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
reader = null;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MysqlKeyValues
|
||||||
|
{
|
||||||
|
public List<MysqlKeyValue> List = new List<MysqlKeyValue>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MysqlKeyValue
|
||||||
|
{
|
||||||
|
public MysqlKeyValue(string key, object value)
|
||||||
|
{
|
||||||
|
Key = key;
|
||||||
|
Value = value == null ? "" : MysqlUtils.ReplaceSqlSpecial(value.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Key = "";
|
||||||
|
public string Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,658 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace KJD_Web.Utils
|
||||||
|
{
|
||||||
|
public static class RegexUtils
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 返回正则对象所有结果
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="HtmlString"></param>
|
||||||
|
/// <param name="RegexString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static MatchCollection GetMatchRegex(string HtmlString, string RegexString)
|
||||||
|
{
|
||||||
|
if (HtmlString == null)
|
||||||
|
{
|
||||||
|
//LogSave.Add("匹配正则发生错误:原始字符串为空,正则:" + RegexString);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Regex.Matches(HtmlString, RegexString, RegexOptions.IgnoreCase);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 返回正则对象所有结果
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="HtmlString"></param>
|
||||||
|
/// <param name="RegexString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static MatchCollection GetMatchRegex(ref string HtmlString, string RegexString)
|
||||||
|
{
|
||||||
|
if (HtmlString == null)
|
||||||
|
{
|
||||||
|
//LogSave.Add("匹配正则发生错误:原始字符串为空,正则:" + RegexString);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Regex.Matches(HtmlString, RegexString, RegexOptions.IgnoreCase);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 返回单个正则分析结果
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="HtmlString"></param>
|
||||||
|
/// <param name="RegexString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetMatchRegexString(ref string HtmlString, string RegexString)
|
||||||
|
{
|
||||||
|
if (HtmlString == null)
|
||||||
|
{
|
||||||
|
//LogSave.Add("匹配正则发生错误:原始字符串为空,正则:" + RegexString);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
MatchCollection mc = Regex.Matches(HtmlString, RegexString, RegexOptions.IgnoreCase);
|
||||||
|
if (mc.Count > 0)
|
||||||
|
{
|
||||||
|
return mc[0].Groups[1].Value.ToString();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 返回单个正则分析结果
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="HtmlString"></param>
|
||||||
|
/// <param name="RegexString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetMatchMaxRegexString(ref string HtmlString, string RegexString)
|
||||||
|
{
|
||||||
|
if (HtmlString == null)
|
||||||
|
{
|
||||||
|
//LogSave.Add("匹配正则发生错误:原始字符串为空,正则:" + RegexString);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
MatchCollection mc = Regex.Matches(HtmlString, RegexString, RegexOptions.IgnoreCase);
|
||||||
|
if (mc.Count > 0)
|
||||||
|
{
|
||||||
|
return mc[mc.Count - 1].Groups[1].Value.ToString();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 返回匹配的数值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="HtmlString"></param>
|
||||||
|
/// <param name="RegexString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static int GetMatchInt(ref string HtmlString, string RegexString)
|
||||||
|
{
|
||||||
|
string id = GetMatchRegexString(ref HtmlString, RegexString);
|
||||||
|
int i;
|
||||||
|
int.TryParse(id, out i);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回单个正则分析结果
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="HtmlString"></param>
|
||||||
|
/// <param name="RegexString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetMatchRegexString(string HtmlString, string RegexString)
|
||||||
|
{
|
||||||
|
if (HtmlString == null)
|
||||||
|
{
|
||||||
|
//LogSave.Add("匹配正则发生错误:原始字符串为空,正则:" + RegexString);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
MatchCollection mc = Regex.Matches(HtmlString, RegexString, RegexOptions.IgnoreCase);
|
||||||
|
if (mc.Count > 0)
|
||||||
|
{
|
||||||
|
return mc[0].Groups[1].ToString();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 是否存在匹配
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="HtmlString"></param>
|
||||||
|
/// <param name="RegexString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool MatchRegex(string HtmlString, string RegexString)
|
||||||
|
{
|
||||||
|
if (HtmlString == null)
|
||||||
|
{
|
||||||
|
//LogSave.Add("匹配正则发生错误:原始字符串为空,正则:" + RegexString);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return Regex.IsMatch(HtmlString, RegexString, RegexOptions.IgnoreCase);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 根据正则删除表达式所匹配的内容
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="HtmlString"></param>
|
||||||
|
/// <param name="RegexString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string Clear(string HtmlString, string RegexString)
|
||||||
|
{
|
||||||
|
if (HtmlString == null)
|
||||||
|
{
|
||||||
|
//LogSave.Add("匹配正则发生错误:原始字符串为空,正则:" + RegexString);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Regex.Replace(HtmlString, RegexString, "", RegexOptions.IgnoreCase);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 清除HTML代码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="HtmlString"></param>
|
||||||
|
/// <returns>返回文字内容</returns>
|
||||||
|
public static string ClearHtml(string HtmlString)
|
||||||
|
{
|
||||||
|
if (HtmlString == null)
|
||||||
|
{
|
||||||
|
//LogSave.Add("匹配正则发生错误:原始字符串为空");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Regex.Replace(Regex.Replace(HtmlString,
|
||||||
|
@"(<head[\w\W]*?</head>|<script[\w\W]*?</script>|<style[\w\W]*?</style>|<!--[\w\W]*?-->)", ""), "(<[^>]*?>)", "").Trim();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 清除HTML代码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="HtmlString"></param>
|
||||||
|
/// <returns>返回文字内容</returns>
|
||||||
|
public static string ClearHtml(ref string HtmlString)
|
||||||
|
{
|
||||||
|
if (HtmlString == null)
|
||||||
|
{
|
||||||
|
//LogSave.Add("匹配正则发生错误:原始字符串为空");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Regex.Replace(Regex.Replace(HtmlString,
|
||||||
|
@"(<head[\w\W]*?</head>|<script[\w\W]*?</script>|<style[\w\W]*?</style>|<!--[\w\W]*?-->)", ""), "(<[^>]*?>)", "").Trim();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 清除HTML代码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="HtmlString"></param>
|
||||||
|
/// <returns>返回文字内容</returns>
|
||||||
|
public static void ClearHtmlX(ref string HtmlString)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(HtmlString))
|
||||||
|
{
|
||||||
|
//LogSave.Add("匹配正则发生错误:原始字符串为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
HtmlString = Regex.Replace(Regex.Replace(HtmlString,
|
||||||
|
@"(<head[\w\W]*?</head>|<script[\w\W]*?</script>|<style[\w\W]*?</style>|<!--[\w\W]*?-->)", ""), "(<[^>]*?>)", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清除HTML代码A标签
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="HtmlString"></param>
|
||||||
|
/// <returns>返回文字内容</returns>
|
||||||
|
public static string ClearA(string HtmlString)
|
||||||
|
{
|
||||||
|
if (HtmlString == null)
|
||||||
|
{
|
||||||
|
//LogSave.Add("匹配正则发生错误:原始字符串为空");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
HtmlString = Regex.Replace(HtmlString, "(</?a[^>]*>)", "", RegexOptions.IgnoreCase);
|
||||||
|
return HtmlString.Trim();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 去除空格和特殊空白
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string Trim(string text)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(text))
|
||||||
|
return "";
|
||||||
|
return text.Replace("\t", " ").Replace("\r\n", " ").Replace("\r", " ").Replace("\n", " ").Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清除HTML代码A标签
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="HtmlString"></param>
|
||||||
|
/// <returns>返回文字内容</returns>
|
||||||
|
public static string ClearTitle(string HtmlString)
|
||||||
|
{
|
||||||
|
if (HtmlString == null)
|
||||||
|
{
|
||||||
|
//LogSave.Add("匹配正则发生错误:原始字符串为空");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
HtmlString = Regex.Replace(HtmlString, "(title=\"[^\"]*\")", "");
|
||||||
|
return HtmlString.Trim();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="html"></param>
|
||||||
|
/// <param name="reg"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetValue(string html, string reg)
|
||||||
|
{
|
||||||
|
return GetMatchRegexString(html, "<" + reg + ">([^<]+)</" + reg + ">");
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 清理多余的HTML元素
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="html"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string ClearNone(string html)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(html))
|
||||||
|
return null;
|
||||||
|
if (html.Contains("\0") && html.IndexOf("\0") > 0)
|
||||||
|
html = html.Substring(0, html.IndexOf("\0"));
|
||||||
|
string h = Clear(html, @"(<\!doctype[^>]*?>)");
|
||||||
|
h = Clear(h, @"(<html[^>]*?>)");
|
||||||
|
h = Clear(h, @"(<head[\w\W]*?</head>)");
|
||||||
|
h = Clear(h, @"(<script[\w\W]*?</script>)");
|
||||||
|
h = Clear(h, @"(<style[\w\W]*?</style>)");
|
||||||
|
h = Clear(h, @"(<input[^>]*?>)");
|
||||||
|
h = Clear(h, @"(<!--[\w\W]*?-->)");
|
||||||
|
h = Clear(h, @"(<link[^>]*?>)");
|
||||||
|
h = Clear(h, @"(\s*alt\s*=[""'\s]*[^>]*?['""]+)");
|
||||||
|
h = Clear(h, @"(\s*style\s*=[""'\s]*[^>]*?['""]+)");
|
||||||
|
h = Clear(h, @"(\s*title\s*=[""'\s]*[^>]*?['""]+)");
|
||||||
|
h = Clear(h, @"(\s*id\s*=[""'\s]*[^>]*?['""]+)");
|
||||||
|
h = Clear(h, @"(\s*class\s*=[""'\s]*[^>]*?['""]+)");
|
||||||
|
h = Clear(h, @"(\s*align\s*=[""'\s]*[^>]*?['""]+)");
|
||||||
|
h = h.Replace("\r\n", " ");
|
||||||
|
h = h.Replace("\n", " ").Replace("\r", " ").Replace("\t", " ");
|
||||||
|
h = h.Replace(" ", " ");
|
||||||
|
h = h.Replace(" ", " ");
|
||||||
|
h = h.Replace(" ", " ");
|
||||||
|
h = h.Replace(" ", " ");
|
||||||
|
return h.Replace(" ", " ").Replace(" ", " ");
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 返回执行结果数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="html"></param>
|
||||||
|
/// <param name="regex"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static int GetRegexCount(string html, string regex)
|
||||||
|
{
|
||||||
|
if (html == null)
|
||||||
|
{
|
||||||
|
//LogSave.Add("匹配正则发生错误:原始字符串为空,正则:" + regex);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return Regex.Matches(html, regex, RegexOptions.IgnoreCase).Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据正则删除表达式所匹配的内容
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="HtmlString"></param>
|
||||||
|
/// <param name="RegexString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string Relpace(string HtmlString, string RegexString, string NewString)
|
||||||
|
{
|
||||||
|
if (HtmlString == null)
|
||||||
|
return null;
|
||||||
|
return Regex.Replace(HtmlString, RegexString, NewString, RegexOptions.IgnoreCase);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 根据正则删除表达式所匹配的内容
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="HtmlString"></param>
|
||||||
|
/// <param name="RegexString"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static void Relpace(ref string HtmlString, string RegexString, string NewString)
|
||||||
|
{
|
||||||
|
if (HtmlString == null)
|
||||||
|
return;
|
||||||
|
HtmlString = Regex.Replace(HtmlString, RegexString, NewString, RegexOptions.IgnoreCase);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 关键词在文本中出现的次数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="b"></param>
|
||||||
|
/// <param name="keyword"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static int GetStringCount(ref byte[] b, string keyword)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(keyword))
|
||||||
|
return 0;
|
||||||
|
int c = 0;
|
||||||
|
bool had;
|
||||||
|
byte[] b1 = Encoding.UTF8.GetBytes(keyword);
|
||||||
|
for (int i = 0; i < b.Length - b1.Length; i++)
|
||||||
|
{
|
||||||
|
had = false;
|
||||||
|
for (int j = 0; j < b1.Length; j++)
|
||||||
|
{
|
||||||
|
if (b[i + j] != b1[j])
|
||||||
|
{
|
||||||
|
had = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (had)
|
||||||
|
{
|
||||||
|
c++;
|
||||||
|
i += b1.Length - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 是否存在
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="html"></param>
|
||||||
|
/// <param name="reg"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool Exists(string html, string reg)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(html) || string.IsNullOrEmpty(reg))
|
||||||
|
return false;
|
||||||
|
return new Regex(reg).IsMatch(html);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 是否是数字
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool IsNumber(string str)
|
||||||
|
{
|
||||||
|
System.Text.RegularExpressions.Regex reg1 = new System.Text.RegularExpressions.Regex(@"^[0-9\.]+$");
|
||||||
|
return reg1.IsMatch(str);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 是否是字母
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool IsChar(string str)
|
||||||
|
{
|
||||||
|
System.Text.RegularExpressions.Regex reg1 = new System.Text.RegularExpressions.Regex(@"^[A-Za-z]+$");
|
||||||
|
return reg1.IsMatch(str);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 是否是字母
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool IsCharOrNumber(string str)
|
||||||
|
{
|
||||||
|
System.Text.RegularExpressions.Regex reg1 = new System.Text.RegularExpressions.Regex(@"^[A-Za-z0-9]+$");
|
||||||
|
return reg1.IsMatch(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否是中文字符串列
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="word"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool IsWordList(string word)
|
||||||
|
{
|
||||||
|
char[] xj = word.ToCharArray();
|
||||||
|
for (int j = 0; j < xj.Length; j++)
|
||||||
|
if (!IsWord(xj[j]))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 是否是字符
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ascii"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static bool IsWord(int ascii)
|
||||||
|
{
|
||||||
|
if (ascii == 32 || ascii == 35) //空格
|
||||||
|
return true;
|
||||||
|
if (ascii < 58 && ascii > 47) //数字
|
||||||
|
return true;
|
||||||
|
if (ascii < 48 && ascii > 31) //符号
|
||||||
|
return true;
|
||||||
|
if (ascii < 91 && ascii > 64) //小写字母
|
||||||
|
return true;
|
||||||
|
if (ascii < 123 && ascii > 96) //大写字母
|
||||||
|
return true;
|
||||||
|
if (ascii < 40892 && ascii > 13311) //中文字符串
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="html"></param>
|
||||||
|
/// <param name="reg"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool GetBoolValue(string html, string reg)
|
||||||
|
{
|
||||||
|
string temp = GetMatchRegexString(html, "<" + reg + ">([^<]+)</" + reg + ">");
|
||||||
|
if (!string.IsNullOrEmpty(temp) && (temp.ToLower() == "true" || temp == "1"))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="html"></param>
|
||||||
|
/// <param name="reg"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static int GetIntValue(string html, string reg)
|
||||||
|
{
|
||||||
|
string temp = GetMatchRegexString(html, "<" + reg + ">([^<]+)</" + reg + ">");
|
||||||
|
int i;
|
||||||
|
if (int.TryParse(temp, out i))
|
||||||
|
return i;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="html"></param>
|
||||||
|
/// <param name="reg"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static long GetLongValue(string html, string reg)
|
||||||
|
{
|
||||||
|
string temp = GetMatchRegexString(html, "<" + reg + ">([^<]+)</" + reg + ">");
|
||||||
|
long i;
|
||||||
|
if (long.TryParse(temp, out i))
|
||||||
|
return i;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="html"></param>
|
||||||
|
/// <param name="reg"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static double GetDoubleValue(string html, string reg)
|
||||||
|
{
|
||||||
|
string temp = GetMatchRegexString(html, "<" + reg + ">([^<]+)</" + reg + ">");
|
||||||
|
double i;
|
||||||
|
if (double.TryParse(temp, out i))
|
||||||
|
return i;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="html"></param>
|
||||||
|
/// <param name="reg"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DateTime GetDateValue(string html, string reg)
|
||||||
|
{
|
||||||
|
string temp = GetMatchRegexString(html, "<" + reg + ">([^<]+)</" + reg + ">");
|
||||||
|
DateTime i;
|
||||||
|
if (DateTime.TryParse(temp, out i))
|
||||||
|
return i;
|
||||||
|
return DateTime.MinValue;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="html"></param>
|
||||||
|
/// <param name="reg"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static decimal GetDecimalValue(string html, string reg)
|
||||||
|
{
|
||||||
|
string temp = GetMatchRegexString(html, "<" + reg + ">([^<]+)</" + reg + ">");
|
||||||
|
decimal i = 0;
|
||||||
|
if (decimal.TryParse(temp, out i))
|
||||||
|
return i;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="html"></param>
|
||||||
|
/// <param name="reg"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static decimal GetDecimalJson(ref string html, string reg)
|
||||||
|
{
|
||||||
|
string temp = GetMatchRegexString(html, @"['""]" + reg + @"['""][\s]*:[\s]*['""]([^']+?)['""]");
|
||||||
|
if (string.IsNullOrEmpty(temp))
|
||||||
|
temp = GetMatchRegexString(html, @"['""]" + reg + @"['""][\s]*:[\s]*([\d-\.]+)");
|
||||||
|
decimal i = 0;
|
||||||
|
if (decimal.TryParse(temp, out i))
|
||||||
|
return i;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="html"></param>
|
||||||
|
/// <param name="reg"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static int GetIntJson(ref string html, string reg)
|
||||||
|
{
|
||||||
|
string temp = GetMatchRegexString(html, @"['""]" + reg + @"['""][\s]*:[\s]*['""]([^']+?)['""]");
|
||||||
|
if (string.IsNullOrEmpty(temp))
|
||||||
|
temp = GetMatchRegexString(html, @"['""]" + reg + @"['""][\s]*:[\s]*([\d-]+)");
|
||||||
|
int i;
|
||||||
|
if (int.TryParse(temp, out i))
|
||||||
|
return i;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 时间戳转字符串时间
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="html"></param>
|
||||||
|
/// <param name="reg"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetIntTimeToString(ref string html, string reg)
|
||||||
|
{
|
||||||
|
return GetIntTimeToString(ref html, reg, 0);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 时间戳转字符串时间
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="html"></param>
|
||||||
|
/// <param name="reg"></param>
|
||||||
|
/// <param name="addTime">添加时间</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetIntTimeToString(ref string html, string reg, int addTime)
|
||||||
|
{
|
||||||
|
int time = GetIntJson(ref html, reg) + addTime;
|
||||||
|
DateTime dt = TimeUtils.StampToDateTime(time);
|
||||||
|
return dt.ToString("yyyy-MM-dd HH:mm:ss");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="html"></param>
|
||||||
|
/// <param name="reg"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static long GetLongJson(ref string html, string reg)
|
||||||
|
{
|
||||||
|
string temp = GetMatchRegexString(html, @"['""]" + reg + @"['""][\s]*:[\s]*['""]([^']+?)['""]");
|
||||||
|
if (string.IsNullOrEmpty(temp))
|
||||||
|
temp = GetMatchRegexString(html, @"['""]" + reg + @"['""][\s]*:[\s]*([\d]+)");
|
||||||
|
long i;
|
||||||
|
if (long.TryParse(temp, out i))
|
||||||
|
return i;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="html"></param>
|
||||||
|
/// <param name="reg"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetStringJson(ref string html, string reg)
|
||||||
|
{
|
||||||
|
string temp = GetMatchRegexString(html, @"[""]" + reg + @"[""][\s]*:[\s]*[""]([^""]+?)[""]");
|
||||||
|
if (temp == null)
|
||||||
|
temp = GetMatchRegexString(html, @"[""]" + reg + @"[""][\s]*:[\s]*[""]([^""]*?)[""]");
|
||||||
|
if (temp == null)
|
||||||
|
temp = GetMatchRegexString(html, @"[']" + reg + @"['][\s]*:[\s]*[']([^']*?)[']");
|
||||||
|
if (temp == null)
|
||||||
|
temp = GetMatchRegexString(html, @"['""]" + reg + @"['""][\s]*:[\s]*([\d]+)");
|
||||||
|
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="html"></param>
|
||||||
|
/// <param name="reg"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetStringInput(ref string html, string reg)
|
||||||
|
{
|
||||||
|
string temp = GetMatchRegexString(html, @"<input [^>]*?name=['""]" + reg + @"[""'][^>]+?value=[""']([^>]+)[""'][^>]*>");
|
||||||
|
if (string.IsNullOrEmpty(temp))
|
||||||
|
temp = GetMatchRegexString(html, @"<input [^>]*?value=[""']([^>]+)[""'][^>]+?name=['""]" + reg + @"[""'][^>]*>");
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="html"></param>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetStringQuery(ref string queryString, string key)
|
||||||
|
{
|
||||||
|
queryString = "&" + queryString;
|
||||||
|
int nIndex = queryString.IndexOf("&" + key + "=");
|
||||||
|
if (nIndex == -1)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
string temp = queryString.Substring(nIndex).Replace("&" + key + "=", "");
|
||||||
|
nIndex = temp.IndexOf('&');
|
||||||
|
if (nIndex > -1)
|
||||||
|
temp = temp.Substring(0, nIndex);
|
||||||
|
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string FliterHtmlTag(string htmlStr)
|
||||||
|
{
|
||||||
|
if (String.IsNullOrEmpty(htmlStr))
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
string regEx_style = "<style[^>]*?>[\\s\\S]*?<\\/style>"; //定义style的正则表达式
|
||||||
|
string regEx_script = "<script[^>]*?>[\\s\\S]*?<\\/script>"; //定义script的正则表达式
|
||||||
|
string regEx_html = "<[^>]+>"; //定义HTML标签的正则表达式
|
||||||
|
htmlStr = Regex.Replace(htmlStr, regEx_style, "");//删除css
|
||||||
|
htmlStr = Regex.Replace(htmlStr, regEx_script, "");//删除js
|
||||||
|
htmlStr = Regex.Replace(htmlStr, regEx_html, "");//删除html标记
|
||||||
|
htmlStr = Regex.Replace(htmlStr, "\\s*|\t|\r|\n", "");//去除tab、空格、空行
|
||||||
|
htmlStr = htmlStr.Replace("\"", "");//去除异常的引号
|
||||||
|
|
||||||
|
return htmlStr.Trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace KJD_Web.Utils
|
||||||
|
{
|
||||||
|
public class TimeUtils
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 时间戳转为C#格式时间
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="timeStamp"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DateTime StampToDateTime(int timeStamp)
|
||||||
|
{
|
||||||
|
DateTime dateTimeStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
|
||||||
|
long lTime = long.Parse(timeStamp + "0000000");
|
||||||
|
TimeSpan toNow = new TimeSpan(lTime);
|
||||||
|
return dateTimeStart.Add(toNow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!-- 有关使用 web.config 转换的详细信息,请访问 https://go.microsoft.com/fwlink/?LinkId=125889 -->
|
||||||
|
|
||||||
|
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
|
||||||
|
<!--
|
||||||
|
在下例中,“SetAttributes”转换将更改
|
||||||
|
“connectionString”的值,以仅在“Match”定位器
|
||||||
|
找到值为“MyDB”的特性“name”时使用“ReleaseSQLServer”。
|
||||||
|
|
||||||
|
<connectionStrings>
|
||||||
|
<add name="MyDB"
|
||||||
|
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
|
||||||
|
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
|
||||||
|
</connectionStrings>
|
||||||
|
-->
|
||||||
|
<system.web>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
在下例中,“Replace”转换将替换
|
||||||
|
web.config 文件的整个 <customErrors> 节。
|
||||||
|
请注意,由于
|
||||||
|
在 <system.web> 节点下仅有一个 customErrors 节,因此不需要使用“xdt:Locator”特性。
|
||||||
|
|
||||||
|
<customErrors defaultRedirect="GenericError.htm"
|
||||||
|
mode="RemoteOnly" xdt:Transform="Replace">
|
||||||
|
<error statusCode="500" redirect="InternalError.htm"/>
|
||||||
|
</customErrors>
|
||||||
|
-->
|
||||||
|
</system.web>
|
||||||
|
</configuration>
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!-- 有关使用 web.config 转换的详细信息,请访问 https://go.microsoft.com/fwlink/?LinkId=125889 -->
|
||||||
|
|
||||||
|
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
|
||||||
|
<!--
|
||||||
|
在下例中,“SetAttributes”转换将更改
|
||||||
|
“connectionString”的值,以仅在“Match”定位器
|
||||||
|
找到值为“MyDB”的特性“name”时使用“ReleaseSQLServer”。
|
||||||
|
|
||||||
|
<connectionStrings>
|
||||||
|
<add name="MyDB"
|
||||||
|
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
|
||||||
|
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
|
||||||
|
</connectionStrings>
|
||||||
|
-->
|
||||||
|
<system.web>
|
||||||
|
<compilation xdt:Transform="RemoveAttributes(debug)" />
|
||||||
|
<!--
|
||||||
|
|
||||||
|
在下例中,“Replace”转换将替换
|
||||||
|
web.config 文件的整个 <customErrors> 节。
|
||||||
|
请注意,由于
|
||||||
|
在 <system.web> 节点下仅有一个 customErrors 节,因此不需要使用“xdt:Locator”特性。
|
||||||
|
|
||||||
|
<customErrors defaultRedirect="GenericError.htm"
|
||||||
|
mode="RemoteOnly" xdt:Transform="Replace">
|
||||||
|
<error statusCode="500" redirect="InternalError.htm"/>
|
||||||
|
</customErrors>
|
||||||
|
-->
|
||||||
|
</system.web>
|
||||||
|
</configuration>
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
有关如何配置 ASP.NET 应用程序的详细信息,请访问
|
||||||
|
https://go.microsoft.com/fwlink/?LinkId=169433
|
||||||
|
-->
|
||||||
|
<configuration>
|
||||||
|
<connectionStrings>
|
||||||
|
<add name="ConnKJD" connectionString="Max Pool Size=512;Database='kjd';Data Source='nj-cynosdbmysql-grp-hl51pkfr.sql.tencentcdb.com';Port=27660;User Id='kjd';Password='Temukjd0625';Charset=utf8mb4;" />
|
||||||
|
<add name="UpdateVersion" connectionString="100"/>
|
||||||
|
<add name="UpdateExe" connectionString="http://1.13.195.131:9000/Download/Update.exe"/>
|
||||||
|
<add name="UpdateFiles" connectionString="http://1.13.195.131:9000/Download/Update.zip"/>
|
||||||
|
<add name="UpdateExeChk" connectionString="2CDEA1FB"/>
|
||||||
|
</connectionStrings>
|
||||||
|
<!--
|
||||||
|
有关 web.config 更改的说明,请参见 http://go.microsoft.com/fwlink/?LinkId=235367。
|
||||||
|
|
||||||
|
可在 <httpRuntime> 标记上设置以下特性。
|
||||||
|
<system.Web>
|
||||||
|
<httpRuntime targetFramework="4.5.2" />
|
||||||
|
</system.Web>
|
||||||
|
-->
|
||||||
|
<system.web>
|
||||||
|
<compilation debug="true" targetFramework="4.5.2" />
|
||||||
|
<httpRuntime targetFramework="4.5.2" />
|
||||||
|
<webServices>
|
||||||
|
<protocols>
|
||||||
|
<add name="HttpGet" />
|
||||||
|
<add name="HttpPost" />
|
||||||
|
<add name="Documentation" />
|
||||||
|
</protocols>
|
||||||
|
</webServices>
|
||||||
|
<pages controlRenderingCompatibilityVersion="4.0" />
|
||||||
|
</system.web>
|
||||||
|
<runtime>
|
||||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="9.0.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
</assemblyBinding>
|
||||||
|
</runtime>
|
||||||
|
<system.webServer>
|
||||||
|
<directoryBrowse enabled="true" />
|
||||||
|
<staticContent>
|
||||||
|
<mimeMap fileExtension=".asmx" mimeType="application/octet-stream" />
|
||||||
|
</staticContent>
|
||||||
|
</system.webServer>
|
||||||
|
</configuration>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.1" targetFramework="net452" />
|
||||||
|
</packages>
|
||||||
Reference in new issue
Block a user