服务端相关代码也合并到仓库
This commit is contained in:
1 parent
fef54e1f0f
commit
879b72e21a
32 files changed
+3626
-1
No files matched your search
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user