301 lines
12 KiB
C#
301 lines
12 KiB
C#
using NGTools.Tools;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using Aliyun.Acs.Core;
|
|
using Aliyun.Acs.Core.Profile;
|
|
using Aliyun.Acs.Core.Exceptions;
|
|
using Aliyun.Acs.Core.Http;
|
|
using ServerException = Aliyun.Acs.Core.Exceptions.ServerException;
|
|
|
|
namespace NGTools
|
|
{
|
|
public partial class frmLoginMobile : System.Web.UI.Page
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
if (Request["action"] == "login")
|
|
{
|
|
_Login();
|
|
}
|
|
|
|
if (Request["action"] == "modPass")
|
|
{
|
|
_modPass();
|
|
}
|
|
if (Request["action"] == "ZC")
|
|
{
|
|
_ZC();
|
|
}
|
|
if (Request["action"] == "YANZHENG")
|
|
{
|
|
_YANZHENG();
|
|
}
|
|
}
|
|
|
|
|
|
private void _YANZHENG()
|
|
{
|
|
Response.ContentType = "text/plain";
|
|
// string strUrl = "";
|
|
string strPhoneNO = Request["phoneNo"];
|
|
string strCode = Request["code"];
|
|
|
|
String accessKeyId = "LTAI4Fvps6yvL7PupRtHirCT";
|
|
String accessKeySecret = "ArXySxkAhT3gitqeePAkSGPeHKpBhO";
|
|
|
|
IClientProfile profile = DefaultProfile.GetProfile("cn-hangzhou", accessKeyId, accessKeySecret);
|
|
DefaultAcsClient client = new DefaultAcsClient(profile);
|
|
CommonRequest request = new CommonRequest();
|
|
request.Method = MethodType.POST;
|
|
request.Domain = "dysmsapi.aliyuncs.com";
|
|
request.Version = "2017-05-25";
|
|
request.Action = "SendSms";
|
|
// request.Protocol = ProtocolType.HTTP;
|
|
request.AddQueryParameters("PhoneNumbers", strPhoneNO);
|
|
request.AddQueryParameters("SignName", "NGTools");
|
|
request.AddQueryParameters("TemplateCode", "SMS_177543713");
|
|
request.AddQueryParameters("TemplateParam", "{\"code\":\"" + strCode + "\"}");
|
|
// IClientProfile profile = DefaultProfile.GetProfile("ap-southeast-1", accessKeyId, accessKeySecret);
|
|
//DefaultAcsClient client = new DefaultAcsClient(profile);
|
|
//CommonRequest request = new CommonRequest
|
|
//{
|
|
// Method = MethodType.POST,
|
|
// Domain = "dysmsapi.ap-southeast-1.aliyuncs.com",
|
|
// Version = "2018-05-01",
|
|
// Action = "SendMessageWithTemplate"
|
|
//};
|
|
//// request.Protocol = ProtocolType.HTTPS;
|
|
//request.AddQueryParameters("To", strPhoneNO);
|
|
//request.AddQueryParameters("From", "NGTools");
|
|
//request.AddQueryParameters("TemplateCode", "SMS_177543713");
|
|
//request.AddQueryParameters("TemplateParam", "{\"code\":\"" + strCode + "\"}");
|
|
|
|
try
|
|
{
|
|
CommonResponse response = client.GetCommonResponse(request);
|
|
Console.WriteLine(response.Data);
|
|
}
|
|
catch (ServerException e)
|
|
{
|
|
Console.WriteLine(e);
|
|
}
|
|
catch (ClientException e)
|
|
{
|
|
Console.WriteLine(e);
|
|
}
|
|
|
|
Response.Write("");
|
|
Response.End();
|
|
|
|
}
|
|
|
|
|
|
private void _ZC()
|
|
{
|
|
Response.ContentType = "text/plain";
|
|
|
|
JsEncryptHelper jsHelper = new JsEncryptHelper();
|
|
string a = Request["userAccount"] + "";
|
|
string b = Request["userName"] + "";
|
|
string c = Request["passwd"] + "";
|
|
string d = Request["phoneNo"] + "";
|
|
|
|
string userAccount = jsHelper.Decrypt(a);
|
|
string userName = jsHelper.Decrypt(b);
|
|
string passwd = jsHelper.Decrypt(c);
|
|
string phoneNo = jsHelper.Decrypt(d);
|
|
|
|
DataTable dtUser = MySQLHelper.ExecuteDataTable(stringSQL.strSQL_User + userName + "' or user_account='" + userAccount + "' or phoneNo='" + phoneNo + "'");
|
|
if (dtUser.Rows.Count == 0)
|
|
{
|
|
string strSQL = "insert into user (";
|
|
strSQL += "user_account,";
|
|
strSQL += "user_name,";
|
|
strSQL += "pswd,";
|
|
strSQL += "ORG_ID,";
|
|
strSQL += "regDateTime,";
|
|
strSQL += "phoneNo) values(";
|
|
strSQL += "'" + userAccount + "',";
|
|
strSQL += "'" + userName + "',";
|
|
strSQL += "'" + passwd + "',";
|
|
strSQL += "'" + userAccount + "00',";
|
|
strSQL += "'" + DateTime.Now + "',";
|
|
strSQL += "'" + phoneNo + "')";
|
|
int intState = 0;
|
|
intState = MySQLHelper.ExecuteNonQuery(strSQL);
|
|
if (intState >= 0)
|
|
{
|
|
|
|
strSQL = "insert into organization (";
|
|
strSQL += "ORG_ID,";
|
|
strSQL += "ORG_Name,";
|
|
strSQL += "ORG_PARENT_ID,";
|
|
strSQL += "ORG_TYPE) values(";
|
|
strSQL += "'" + userAccount + "00',";
|
|
strSQL += "'" + userName + "00',";
|
|
strSQL += "'" + "MS00" + "',";
|
|
strSQL += "'" + "公司" + "')";
|
|
intState = 0;
|
|
intState = MySQLHelper.ExecuteNonQuery(strSQL);
|
|
|
|
Response.Write("ok");
|
|
Response.End();
|
|
}
|
|
|
|
else
|
|
{
|
|
Response.Write("注册失败");
|
|
Response.End();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Response.Write("账户、电话号码或姓名已被注册,请重新输入!");
|
|
Response.End();
|
|
}
|
|
}
|
|
|
|
private void _modPass()
|
|
{
|
|
Response.ContentType = "text/plain";
|
|
|
|
//string userName = Request.Form["username"];
|
|
//string oldpasswd = Request.Form["oldpasswd"];
|
|
//string newpasswd = Request.Form["newpasswd"];
|
|
|
|
|
|
JsEncryptHelper jsHelper = new JsEncryptHelper();
|
|
string a = Request["username"] + "";
|
|
string b = Request["oldpasswd"] + "";
|
|
string c = Request["newpasswd"] + "";
|
|
string userName = jsHelper.Decrypt(a);
|
|
string oldpasswd = jsHelper.Decrypt(b);
|
|
string newpasswd = jsHelper.Decrypt(c);
|
|
|
|
DataTable dtUser = MySQLHelper.ExecuteDataTable(stringSQL.strSQL_User + userName + "' or user_account='" + userName + "' or phoneNo='" + userName + "'");
|
|
if (dtUser.Rows.Count > 0)
|
|
{
|
|
if (dtUser.Rows[0]["pswd"].ToString() == oldpasswd)
|
|
{
|
|
string strSQL = "update user set pswd='" + newpasswd + "' where user_name='" + userName + "' or user_account='" + userName + "' or phoneNo='" + userName + "'";
|
|
int intState = 0;
|
|
intState = MySQLHelper.ExecuteNonQuery(strSQL);
|
|
if (intState >= 0)
|
|
{
|
|
Response.Write("ok");
|
|
Response.End();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Response.Write("用户名或密码有误,请仔细想想....");
|
|
Response.End();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Response.Write("没有这个用户!");
|
|
Response.End();
|
|
}
|
|
}
|
|
|
|
|
|
private void _Login()
|
|
{
|
|
Response.ContentType = "text/plain";
|
|
|
|
|
|
JsEncryptHelper jsHelper = new JsEncryptHelper();
|
|
string a = Request["username"] + "";
|
|
string b = Request["passwd"] + "";
|
|
string userName = jsHelper.Decrypt(a);
|
|
string passWord = jsHelper.Decrypt(b);
|
|
|
|
DataTable dtUser = MySQLHelper.ExecuteDataTable(stringSQL.strSQL_User + userName + "' or user_account='" + userName + "' or phoneNo='" + userName + "'");
|
|
if (dtUser.Rows.Count > 0)
|
|
{
|
|
if (dtUser.Rows[0]["loginflag"].ToString() == "0" || dtUser.Rows[0]["loginflag"].ToString() == "")
|
|
{
|
|
|
|
|
|
if (dtUser.Rows[0]["pswd"].ToString() == passWord)
|
|
{
|
|
Session["userName"] = dtUser.Rows[0]["user_name"].ToString(); ; //用户名
|
|
Session["userAccount"] = dtUser.Rows[0]["user_account"].ToString(); //用户账号
|
|
Session["userOrgID"] = dtUser.Rows[0]["ORG_ID"].ToString(); ;//所属单位ID
|
|
Session["userRole"] = dtUser.Rows[0]["role"].ToString(); ;//用户角色
|
|
Session["userAuthority"] = dtUser.Rows[0]["authority"].ToString(); //用户权限
|
|
Session["phoneNo"] = dtUser.Rows[0]["phoneNo"].ToString(); //用户电话
|
|
Session["regDateTime"] = dtUser.Rows[0]["regDateTime"].ToString(); //用户电话
|
|
|
|
string strSQL = "update user set loginflag='1' ,logintime='" + DateTime.Now + "' where user_name='" + userName + "' or user_account='" + userName + "' or phoneNo='" + userName + "'";
|
|
int num = MySQLHelper.ExecuteNonQuery(strSQL);
|
|
Session.Timeout = 5;
|
|
|
|
strSQL = "insert into loginrecord (user_id,login_DateTime) values (" + "'" + dtUser.Rows[0]["user_account"].ToString() + "','" + DateTime.Now + "')";
|
|
num = MySQLHelper.ExecuteNonQuery(strSQL);
|
|
|
|
//string Json = "[{";
|
|
//Json += "\"statue\":\"OK\"," + "\"userName\":\"" + dtUser.Rows[0]["user_name"].ToString() + "\",";
|
|
//Json += "\"userAccount\":\"" + dtUser.Rows[0]["user_account"].ToString() + "\",";
|
|
//Json += "\"userOrgID\":\"" + dtUser.Rows[0]["ORG_ID"].ToString() + "\",";
|
|
//Json += "\"regDateTime\":\"" + dtUser.Rows[0]["regDateTime"].ToString() + "\"}]";
|
|
|
|
Response.Write("OK");
|
|
Response.End();
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
Response.Write("密码错误,请仔细想想....");
|
|
Response.End();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Response.Write("这个账户在别的客户端已登录");
|
|
Response.End();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Response.Write("没有这个用户,请仔细想想你注册时用名字....");
|
|
Response.End();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Base64解密
|
|
/// </summary>
|
|
/// <param name="codeName">解密采用的编码方式,注意和加密时采用的方式一致</param>
|
|
/// <param name="result">待解密的密文</param>
|
|
/// <returns>解密后的字符串</returns>
|
|
public static string DecodeBase64(Encoding encode, string result)
|
|
{
|
|
string decode = "";
|
|
byte[] bytes = Convert.FromBase64String(result);
|
|
try
|
|
{
|
|
decode = encode.GetString(bytes);
|
|
}
|
|
catch
|
|
{
|
|
decode = result;
|
|
}
|
|
return decode;
|
|
}
|
|
|
|
|
|
}
|
|
} |