using System;
|
using System.Configuration;
|
using System.Web.Mvc;
|
using System.Web.Script.Serialization;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using HH.AutoBom.Core;
|
using HH.WMS.WebUI;
|
using HH.WMS.WebUI.AppCode;
|
using HH.WMS.Common;
|
using HH.WMS.Entitys.Func;
|
using System.Collections.Generic;
|
using HH.WMS.Common.External;
|
|
namespace HH.WMS.WebUI.Controllers
|
{
|
[MvcMenuFilter(false)]
|
public class HomeController : BaseController
|
{
|
public ActionResult Index()
|
{
|
var loginer = FormsAuth.GetUserData<LoginerBase>();
|
ViewBag.Title = HH.WMS.Common.Constants.appCode;//应用编码
|
ViewBag.UserCode = loginer.UserCode; //用户登录名
|
ViewBag.UserName = loginer.UserName; //用户真实名
|
ViewBag.Settings = new sys_userService().GetDefaultUserSetttins();
|
ViewBag.isDisplayTechnicalSupport = ProjectConfigs.isDisplayTechnicalSupport;
|
ViewBag.isDisplaySystemIcon = ProjectConfigs.isDisplaySystemIcon;
|
ViewBag.projectCode = Constants.SysConfig.PROJECT_CODE;
|
return View();
|
}
|
|
public ActionResult Error()
|
{
|
return View();
|
}
|
|
public void Download()
|
{
|
Exporter.Instance().Download();
|
}
|
|
#region 修改密码页面
|
/// <summary>
|
/// 修改密码页面
|
/// </summary>
|
/// <returns></returns>
|
public ActionResult UpdatePwd()
|
{
|
return View();
|
}
|
#endregion
|
|
#region 用户详情页
|
/// <summary>
|
/// 用户详情页
|
/// </summary>
|
/// <returns></returns>
|
public ActionResult UserDetail()
|
{
|
return View();
|
}
|
#endregion
|
|
#region 退出系统 清除redis和cookie
|
/// <summary>
|
/// 退出系统 清楚redis和cookie
|
/// </summary>
|
/// <param name="endType"></param>
|
/// <returns></returns>
|
public AccountEntity Exit(string endType)
|
{
|
AccountEntity acEntity = new AccountEntity();
|
try
|
{
|
var loginer = FormsAuth.GetUserData<LoginerBase>();
|
string appCode = Constants.appCode;
|
string userName = loginer.UserCode;
|
string flag = loginer.Flag;
|
|
string ip = System.Web.HttpContext.Current.Request.UserHostAddress;
|
|
var entity = new
|
{
|
userName = userName,
|
appCode = appCode,
|
flag = flag,
|
endType = endType,
|
ip = ip
|
};
|
|
string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(entity);
|
string result = HH.WMS.Common.WebApiManager.HttpAutoBom_Post("api/Account/CloseApp", jsonString);
|
|
acEntity = Newtonsoft.Json.JsonConvert.DeserializeObject<AccountEntity>(result);
|
|
//清除所有cookie
|
for (int i = 0; i < Request.Cookies.Count; i++)
|
{
|
Response.Cookies[Request.Cookies[i].Name].Expires = DateTime.Now.AddDays(-1);
|
}
|
}
|
catch (Exception ex)
|
{
|
acEntity.Code = "1";
|
acEntity.Data = ex.Message;
|
}
|
return acEntity;
|
}
|
#endregion
|
|
#region 切换APP
|
/// <summary>
|
/// 切换APP
|
/// </summary>
|
/// <param name="after_appCode"></param>
|
/// <returns></returns>
|
public ActionResult ChangeApp(string after_appCode)
|
{
|
var loginer = FormsAuth.GetUserData<LoginerBase>();
|
string front_appCode = Constants.appCode;
|
string userName = loginer.UserCode;
|
string old_flag = loginer.Flag;
|
|
var entity = new
|
{
|
userName = userName,
|
front_appCode = front_appCode,
|
after_appCode = after_appCode,
|
old_flag = old_flag
|
};
|
string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(entity);
|
string result = HH.WMS.Common.WebApiManager.HttpAutoBom_Post("api/Account/ChangeApp", jsonString);
|
//清除所有cookie
|
for (int i = 0; i < Request.Cookies.Count; i++)
|
{
|
Response.Cookies[Request.Cookies[i].Name].Expires = DateTime.Now.AddDays(-1);
|
}
|
return Content(result);
|
}
|
#endregion
|
|
#region 静态脚本数据 获取文件服务器访问地址
|
/// <summary>
|
/// 静态脚本数据 获取文件服务器访问地址
|
/// </summary>
|
public JavaScriptResult FileServerData()
|
{
|
var webServiceURL = ConfigurationManager.AppSettings["FileServer"] != null ? ConfigurationManager.AppSettings["FileServer"].ToString() : "";
|
var data = new
|
{
|
WebServiceURL = webServiceURL
|
};
|
var js = "var FileServerData = " + new JavaScriptSerializer().Serialize(data);
|
return JavaScript(js);
|
}
|
#endregion
|
|
#region 修改密码
|
/// <summary>
|
/// 修改密码
|
/// </summary>
|
/// <param name="userName"></param>
|
/// <param name="oldPwd"></param>
|
/// <param name="newPwd"></param>
|
/// <param name="appCode"></param>
|
/// <returns></returns>
|
public ActionResult PwdEdit(string oldPwd, string newPwd)
|
{
|
var loginer = FormsAuth.GetUserData<LoginerBase>();
|
string userName = loginer.UserCode;
|
string ip = System.Web.HttpContext.Current.Request.UserHostAddress;
|
var entity = new
|
{
|
userName = userName,
|
oldPwd = oldPwd,
|
newPwd = newPwd,
|
appCode = HH.WMS.Common.Constants.appCode,
|
ip = ip
|
};
|
string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(entity);
|
string result = HH.WMS.Common.WebApiManager.HttpAutoBom_Post("api/User/ChangePwd", jsonString);
|
return Content(result);
|
}
|
#endregion
|
|
public ActionResult UpdatePassword()
|
{
|
return View();
|
}
|
|
[HttpPost]
|
public string UpdatePassword(string currentPwd, string newPwd)
|
{
|
var loginer = FormsAuth.GetUserData<LoginerBase>();
|
string userName = loginer.UserCode;
|
string ip = System.Web.HttpContext.Current.Request.UserHostAddress;
|
var sendData = new
|
{
|
userName = userName,
|
oldPwd = currentPwd,
|
newPwd = newPwd,
|
appCode = Constants.appCode,
|
ip = ip
|
};
|
string result = HttpAutobom_Post("api/User/ChangePwd", JsonConvert.SerializeObject(sendData));
|
return result;
|
}
|
|
public ActionResult Main()
|
{
|
return View();
|
}
|
public ActionResult GetBussLine(int day)
|
{
|
string result = HttpWMS_Get("api/Inventory/GetBussLine?day=" + day);
|
return Content(result);
|
}
|
|
public string GetLocationState()
|
{
|
//todo
|
//根据用户获取仓库
|
string result = HttpWMS_Get("api/LocationExt/GetLocationState?stockCode=");
|
return result;
|
}
|
|
public string GetVersionLog()
|
{
|
string result = HttpWMS_Get("api/Inventory/GetVersionLog");
|
return result;
|
}
|
}
|
}
|