using System.Web.Mvc;
using HH.AutoBom.Core;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HH.WMS.WebUI.AppCode;
using HH.WMS.Common;
using System.Text;
using HH.WMS.Entitys.Func;
using System.Net;
using System.Configuration;
using Newtonsoft.Json;
using HH.WMS.Entitys;
using HH.WMS.Entitys.Sys;
using HH.WMS.Common.External;
namespace HH.WMS.WebUI.Controllers
{
[AllowAnonymous]
[MvcMenuFilter(false)]
public class LoginController : Controller
{
public ActionResult Index()
{
ViewBag.CnName =Constants.SysConfig.APP_NAME +"-WMS";
ViewBag.EnName = "HanHeIntelligent-WMS";
ViewBag.Company = "合肥汉和智能物流科技有限公司";
ViewBag.isDisplayTechnicalSupport = ProjectConfigs.isDisplayTechnicalSupport;
ViewBag.isDisplaySystemIcon = ProjectConfigs.isDisplaySystemIcon;
ViewBag.projectCode = Constants.SysConfig.PROJECT_CODE;
if (string.IsNullOrEmpty(Constants.SysConfig.WMS_API) ||string.IsNullOrEmpty(Constants.SysConfig.APP_CODE))
{
//ViewData["CN_S_WMS_API"] = Constants.GetConfig("CN_S_WMS_API");
//ViewData["IsNeedConfig"] = 1;
return RedirectToAction("SysConfig", "Sys/SysSet");
return View();
}
else
{
//HttpWebResponse response = null;
//try
//{
// HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://" + Constants.config["CN_S_WMS_API"]);
// response = (HttpWebResponse)myReq.GetResponse();
//}
//catch (Exception ex)
//{
// return View("../../Areas/Sys/Views/SysSet/SysConfig");
//}
//if (response.StatusCode == HttpStatusCode.OK)
//{
// //通
// WebApiManager.HttpWMS_Get("api/Login/InitConfig");
return View("Index");
//}
//else
//{
// //不通
// return View("../../Areas/Sys/Views/SysSet/SysConfig");
//}
}
}
public ActionResult Location()
{
return View("Location");
}
#region 登录接口
///
/// 登录接口
///
///
///
public JsonResult DoAction(JObject request)
{
try
{
string appCode = HH.WMS.Common.Constants.SysConfig.APP_CODE;
var message = new sys_userService().Login(request, appCode);
return Json(message, JsonRequestBehavior.DenyGet);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 验证登录
///
/// 验证登录
///
///
///
///
///
public ActionResult Validator(string userName, string flag, string appCode)
{
var entity = new
{
userName = userName,
flag = flag,
appCode = appCode,
EncryText = ""
};
string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(entity);
string ReturnJson = HH.WMS.Common.WebApiManager.HttpAutoBom_Post("api/Account/Validator", jsonString);
AccountEntity accountEntity = Newtonsoft.Json.JsonConvert.DeserializeObject(ReturnJson);
var message = sys_userService.SaveUserEntity(userName, accountEntity);
HttpCookie tokenCookie = new HttpCookie("UserToken", accountEntity.Flag);
Response.AppendCookie(tokenCookie);
return Json(accountEntity);
}
#endregion
public ActionResult Logout()
{
FormsAuth.SingOut();
return Redirect("~/Login");
}
}
}