You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/SysMng/Controllers/USERINFOController.cs

436 lines
14 KiB
C#

2 years ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using DSWeb.Areas.SysMng.DAL.USERINFO;
using DSWeb.Areas.SysMng.Models.USERINFO;
using DSWeb.TruckMng.Comm.Cookie;
using DSWeb.TruckMng.Helper;
using DSWeb.TruckMng.Helper.Repository;
using HcUtility.Comm;
using HcUtility.Core;
using DSWeb.Areas.Mobile.Helper;
using DSWeb.Areas.Dispatch.Models;
using System.Runtime.Caching;
using DSWeb.Areas.Dispatch.Helper;
using Newtonsoft.Json.Linq;
using DSWeb.MvcShipping.DAL.MsSysParamSet;
using DSWeb.Areas.CommMng.DAL;
using Newtonsoft.Json;
2 years ago
using DSWeb.EntityDA;
2 years ago
namespace DSWeb.Areas.SysMng.Controllers
{
[JsonRequestBehavior]
public class USERINFOController : Controller
{
//
// GET: /TruckMng/Enum/
public ActionResult Index()
{
return View();
}
//
// GET: /TruckMng/Enum/Edit
public ActionResult Edit()
{
return View();
}
//
// GET/TruckMng/Enum/GetDataList
public ContentResult GetDataList(int start, int limit, string sort, string condition)
{
var dataList = USERINFODAL.GetDataList(condition);
var list = dataList.Skip(start).Take(limit);
var json =DSWeb.TruckMng.Helper. JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = dataList.Count, data = list.ToList() });
2 years ago
return new ContentResult() { Content = json };
}
//
// GET/TruckMng/Enum/GetData/
public ContentResult GetData()
{
USERmb headData = null;
var _USERID = Session["USERID"].ToString();
var condition = " GID='" + _USERID + "'";
var list = USERINFODAL.GetDataList(condition);
if (list.Count > 0)
headData = list[0];
if (headData == null)
{
headData = new USERmb();
}
var json = DSWeb.TruckMng.Helper.JsonConvert.Serialize(
2 years ago
new { Success = true, Message = "查询成功", data = headData });
return new ContentResult() { Content = json };
}
//
// GET/TruckMng/Enum/Save
1 year ago
bool hasUpperCase(string str)
{
if (string.IsNullOrEmpty(str))
return false;
for (int i = 0; i < str.Length; i++)
{
if (char.IsUpper(str[i]))
return true;
}
return false;
}
bool hasLowerCase(string str)
{
if (string.IsNullOrEmpty(str))
return false;
for (int i = 0; i < str.Length; i++)
{
if (char.IsLower(str[i]))
return true;
}
return false;
}
bool hasIsDigit(string str)
{
if (string.IsNullOrEmpty(str))
return false;
for (int i = 0; i < str.Length; i++)
{
if (char.IsDigit(str[i]))
return true;
}
return false;
}
2 years ago
public ContentResult Save ( string opstatus, string data, string body, string Delbody )
{
var headData = DSWeb.TruckMng.Helper.JsonConvert.Deserialize<USERmb>(data);
var bodyList = DSWeb.TruckMng.Helper.JsonConvert.Deserialize<List<USERINFOmb>>(body);
var DelbodyList = DSWeb.TruckMng.Helper.JsonConvert.Deserialize<List<USERINFOmb>>(Delbody);
2 years ago
var result = new DBResult();
var _USERID = Session["USERID"].ToString();
var condition = " GID='" + _USERID + "'";
string username = headData.USERNAME;
2 years ago
var iscgps = false;
2 years ago
if (!string.IsNullOrEmpty(headData.PASSWORD))
{
var _USER = USERINFODAL.GetData(condition);
if (_USER.PASSWORD != headData.OLDPASSWORD)
{
var jsonRespose2 = new JsonResponse
{
Success = false,
Message = "旧密码填写错误",
Data = ""
};
return new ContentResult() { Content = DSWeb.TruckMng.Helper. JsonConvert.Serialize(jsonRespose2) };
2 years ago
}
else
{
2 years ago
iscgps = true;
2 years ago
}
1 year ago
if (hasUpperCase(headData.PASSWORD) && hasLowerCase(headData.PASSWORD) && hasIsDigit(headData.PASSWORD))
{
//有 大写字母 小写字母 数字
}
else {
var err = new DBResult();
err.SetErrorInfo("密码中必须同时包含 大写字母 小写字母 和 数字。");
return BasicDataRefDAL.GetContentResult(err);
}
2 years ago
}
else {
headData = USERINFODAL.GetData(condition);
headData.USERNAME = username;
}
//if (opstatus == "add")
//{
// headData.DbOperationType = DbOperationType.DbotIns;
// headData.ModelUIStatus = "I";
//}
//else
//{
headData.DbOperationType = DbOperationType.DbotUpd;
headData.ModelUIStatus = "E";
//}
2 years ago
2 years ago
var modb = new ModelObjectRepository();
result = modb.Save(headData,
ModelObjectConvert<USERINFOmb>.ToModelObjectList(bodyList),
ModelObjectConvert<USERINFOmb>.ToModelObjectList(DelbodyList)
);
2 years ago
if (iscgps) {
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var blUpSQL = " update [user] set MODIFYPASSTIME=getdate() WHERE GID='"+headData.GID+"' ";
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
}
2 years ago
var jsonRespose = new JsonResponse
{
Success = result.Success,
Message = result.Message,
Data = ""
};
return new ContentResult() { Content = DSWeb.TruckMng.Helper.JsonConvert.Serialize(jsonRespose) };
2 years ago
}
//
// GET/TruckMng/Enum/Delete
public ContentResult GetUSERINFOBodyList()
2 years ago
{
var _USERID = Session["USERID"].ToString();
var condition = " USERID='" + _USERID + "'";
List<USERINFOmb> list = USERINFODAL.GetUSERINFOList(condition);
var json = DSWeb.TruckMng.Helper.JsonConvert.Serialize(new { Success = true, Message = "查询成功", totalCount = list.Count, data = list.ToList() });
2 years ago
return new ContentResult() { Content = json };
}
public ContentResult GetUSERINFOData()
{
USERINFOmb headData = null;
var _USERID = Session["USERID"].ToString();
var condition = " USERID='" + _USERID + "'";
var list = USERINFODAL.GetUSERINFOList(condition);
if (list.Count > 0)
headData = list[0];
if (headData == null)
{
headData = new USERINFOmb();
}
var json = DSWeb.TruckMng.Helper.JsonConvert.Serialize(
2 years ago
new { Success = true, Message = "查询成功", data = headData });
return new ContentResult() { Content = json };
}
2 years ago
#region 参照部分
#endregion
public ActionResult GetMobileCode()
{
var user = USERINFODAL. GetUserInfo(Convert.ToString(Session["USERID"]));
var mobile = user.MOBILE;
RespCommon resp = new RespCommon();
string key1 = $"REM_{mobile}";
string key2 = $"MC_{mobile}";
var DJYCOMPANYID = MsSysParamSetDAL.GetData("PARAMNAME='DJYCOMPANYID'");
if (string.IsNullOrEmpty(DJYCOMPANYID.PARAMVALUE))
{
resp.Success = false;
resp.Message = "请先配置参数设置【大简云公司代码】";
return Json(resp);
}
if (MemoryCache.Default.Contains(key1))
{
resp.Success = false;
resp.Message = "获取验证码过于频繁";
}
else
{
Random rnd = new Random();
string code = rnd.Next(1000, 10000).ToString();
MemoryCache.Default.Add(new CacheItem(key1, true), new CacheItemPolicy() { AbsoluteExpiration = DateTime.Now.AddSeconds(120) });
MemoryCache.Default.Remove(key2);
MemoryCache.Default.Add(new CacheItem(key2, code), new CacheItemPolicy() { AbsoluteExpiration = DateTime.Now.AddMinutes(5) });
AliMessageTools.SendSignCodeMsg(mobile, code);
resp.Success = true;
resp.Message = "验证码已发送";//LangCommon.MsgMobileCodeSent;
}
return Json(resp);
}
[HttpPost]
public ActionResult DJYReg(string mobilecode)
{
//测试地址 http://123.234.225.158:35000/user/UserUploadDS
var = "http://123.234.225.158:35000/user/UserUploadDS";
RespCommon resp = new RespCommon();
DJYRegInfo dJYRegInfo = new DJYRegInfo();
dJYRegInfo.SetValue(Convert.ToString(Session["USERID"]));
var errormsg = dJYRegInfo.CanSend();
if (errormsg != "") {
resp.Success = false;
resp.Message = errormsg;
return Json(resp);
}
JObject reqObj = dJYRegInfo.keyValuePairs();
string rtn = WebRequestHelper.DoPost(, reqObj.ToString(Formatting.None));
var obj = new { Success = false, Message = "", UserData = "", ShortName = "", LoginName = "" };
var jsonObj = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(rtn, obj);
if (jsonObj.Success)
{
//Session["UserData"] = jsonObj.UserData;
//Session["UserShortName"] = jsonObj.ShortName;
//Session["UserLoginName"] = jsonObj.LoginName;
//if (!string.IsNullOrWhiteSpace(returnUrl))
//{
// return Redirect(returnUrl);
//}
//else
//{
// return RedirectToAction("Index");
//}
return View();
}
else
{
ModelState.AddModelError("Validate", jsonObj.Message);
return View();
}
}
}
public class DJYRegInfo {
public string USERID { get; set; }
public string USERNAME { get; set; }
public string CODENAME { get; set; }
public string PASSWORD { get; set; }
public string SHOWNAME { get; set; }
public string CORPID { get; set; }
public string OFFICEPHONE { get; set; }
public string HOMEPHONE { get; set; }
public string MOBILE { get; set; }
public string FAX { get; set; }
public string EMAIL1 { get; set; }
public string EMAIL2 { get; set; }
public string HOMEADDRESS { get; set; }
public string ERPTYPE { get; set; } = "ERP";
public string UPLOADTIME { get; set; }
public string SIGN { get; set; }
public void SetValue(string USERID) {
var headData = USERINFODAL.GetUser(USERID);
var headInfoData = USERINFODAL.GetUserInfo(USERID);
USERID = headData.GID;
USERNAME = headData.USERNAME;
CODENAME = headData.DJY_CODENAME;
PASSWORD = headData.DJY_PASSWORD;
SHOWNAME = headData.USERNAME;
var DJYCOMPANYID = MsSysParamSetDAL.GetData("PARAMNAME='DJYCOMPANYID'");
CORPID = DJYCOMPANYID.PARAMVALUE;
OFFICEPHONE = headInfoData.OFFICEPHONE;
MOBILE = headInfoData.MOBILE;
FAX = headInfoData.FAX;
EMAIL1 = headInfoData.EMAIL1;
EMAIL2 = headInfoData.EMAIL2;
HOMEADDRESS = headInfoData.HOMEADDRESS;
ERPTYPE = "ERP";
UPLOADTIME = DateTime.Now.ToString("yyyyMMddHHmmss");
getSign();
}
private void getSign() {
var _str = CODENAME + "&" + CORPID + "&" + ERPTYPE + "&" + MOBILE + "&" + SHOWNAME + "&" + UPLOADTIME + "&" + USERID;
var md5 = BasicDataRefDAL.GetMd5Hash(_str).ToLower();
SIGN = md5;
}
public JObject keyValuePairs() {
JObject reqObj = new JObject();
reqObj.Add("USERID", USERID);
reqObj.Add("USERNAME", USERNAME);
reqObj.Add("CODENAME", CODENAME);
reqObj.Add("PASSWORD", PASSWORD);
reqObj.Add("SHOWNAME", SHOWNAME);
reqObj.Add("CORPID", CORPID);
reqObj.Add("OFFICEPHONE", OFFICEPHONE);
reqObj.Add("MOBILE", MOBILE);
reqObj.Add("FAX", FAX);
reqObj.Add("EMAIL1", EMAIL1);
reqObj.Add("EMAIL2", EMAIL2);
reqObj.Add("HOMEADDRESS", HOMEADDRESS);
reqObj.Add("ERPTYPE", ERPTYPE);
reqObj.Add("UPLOADTIME", UPLOADTIME);
reqObj.Add("SIGN", SIGN);
return reqObj;
}
public string CanSend() {
var result = "";
void addmsg(string msg) {
if (result != "") result += ";";
result += msg;
}
if (string.IsNullOrWhiteSpace(PASSWORD) || PASSWORD.Length<6) {
addmsg("大简云密码过短");
}
var DJYCOMPANYID = MsSysParamSetDAL.GetData("PARAMNAME='DJYCOMPANYID'");
if (string.IsNullOrEmpty(DJYCOMPANYID.PARAMVALUE))
{
addmsg("请先配置参数设置【大简云公司代码】");
}
return result;
}
2 years ago
}
}