using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Web;
|
using System.Web.Mvc;
|
using PalGain.Core;
|
using BatchService.Framework.Utility;
|
using sbcLabSystem.Service.Account;
|
using sbcLabSystem.Framework;
|
using sbcLabSystem.Models;
|
using sbcLabSystem.Data.Domain.Account;
|
using sbcLabSystem.Models.Home;
|
using sbcLabSystem.Data.Domain.Backstage;
|
using sbcLabSystem.Service;
|
using sbcLabSystem.Service.QC;
|
using sbcLabSystem.Models.Backstage;
|
using sbcLabSystem.App_Start.Attribute;
|
using Newtonsoft.Json;
|
|
namespace sbcLabSystem.Controllers
|
{
|
public class HomeController : Controller
|
{
|
//
|
// GET: /Home/
|
|
private AccountService m_AccountService;
|
private QCService _qcService;
|
|
public HomeController(AccountService l_AccountService,
|
QCService i_qcService)
|
{
|
_qcService = i_qcService;
|
this.m_AccountService = l_AccountService;
|
}
|
|
public ActionResult Index()
|
{
|
|
HomePageViewModel viewModel = new HomePageViewModel();
|
viewModel.RequestInfo = new UserRequestInfo();
|
return View(viewModel);
|
}
|
public ActionResult GetValidateCode()
|
{
|
VerifyCode vCode = new VerifyCode();
|
string code = vCode.CreateValidateCode(4);
|
Session["ValidateCode"] = code;
|
byte[] bytes = vCode.CreateValidateGraphic(code);
|
return File(bytes, @"image/jpeg");
|
}
|
|
public ActionResult submitRequest(HomePageViewModel viewModel, string verityCode)
|
{
|
if (m_AccountService.GetUserRequestInfoQueryable().FirstOrDefault(p => p.OperatorEmail == viewModel.RequestInfo.OperatorEmail ||
|
p.ManagerEmail == viewModel.RequestInfo.ManagerEmail) != null)
|
{
|
return Json("duplicate");
|
}
|
if (viewModel.RequestInfo != null)
|
{
|
if (Session["ValidateCode"].ToString() != verityCode)
|
{
|
return Json("verifycodeerror");
|
}
|
viewModel.RequestInfo.RequestTime = DateTime.Now;
|
viewModel.RequestInfo.UpdateTime = DateTime.Now;
|
m_AccountService.InsertUserRequestInfo(viewModel.RequestInfo);
|
_qcService.SendMail(viewModel.RequestInfo.Id, 11);
|
}
|
else
|
{
|
return Json("error");
|
}
|
return Json("ok");
|
}
|
|
public ActionResult introduce()
|
{
|
MenuinfoViewModel viewModel = new MenuinfoViewModel();
|
viewModel.Menuinfo = m_AccountService.MenusId(1);
|
return View(viewModel);
|
}
|
public ActionResult process()
|
{
|
MenuinfoViewModel viewModel = new MenuinfoViewModel();
|
viewModel.Menuinfo = m_AccountService.MenusId(2);
|
return View(viewModel);
|
}
|
public ActionResult ChargeStandard()
|
{
|
MenuinfoViewModel viewModel = new MenuinfoViewModel();
|
viewModel.ChargeData = new List<ChargedDetile>();
|
viewModel.Menuinfo = m_AccountService.MenusId(3);
|
string userId = Cookie.GetValue("login_user").ToString();
|
var list = _qcService.GetQcDistributionRegisters().Where(p => p.LabId.ToString() == userId).ToList();
|
if (list != null && list.Count > 0)
|
{
|
list.ForEach(info =>
|
{
|
ChargedDetile data = new ChargedDetile();
|
data.isCharged = info.IsCharged;
|
data.ChargedRemark = info.ChargeRemark;
|
data.ChargedTime = info.ChargeTime.GetValueOrDefault().ToString("yyyy-MM-dd HH:mm:ss");
|
data.QCDistributionDistNo = info.QCDistributionInfo.DistNo;
|
viewModel.ChargeData.Add(data);
|
});
|
}
|
return View(viewModel);
|
}
|
public ActionResult Login()
|
{
|
|
UserRequestInfoModel viewModel = new UserRequestInfoModel()
|
{
|
LabCode = "",
|
LabLoginName = "",
|
LabPassword = ""
|
};
|
return View(viewModel);
|
}
|
public ActionResult SeveUpdatePwd(UserRequestInfoModel info)
|
{
|
try
|
{
|
UserRequestInfo User = m_AccountService.GetUserRequestInfoQueryable()
|
.FirstOrDefault(p => p.LabCode.ToLower() == info.LabCode.ToLower() && p.ManagerEmail == info.ManagerEmail);
|
if (User != null)
|
{
|
_qcService.SendMail(User.Id, 17);
|
return Json("ok");
|
}
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Error(ex.ToString());
|
}
|
return Json("no");
|
}
|
|
public ActionResult unionPassword()
|
{
|
try
|
{
|
var userList = m_AccountService.GetUserRequestInfoQueryable().ToList();
|
userList.ForEach(x =>
|
{
|
if (string.IsNullOrEmpty(x.LabPassword))
|
{
|
return;
|
}
|
var md5 = MD5Helper.MD5Encrypt3(x.LabPassword);
|
x.LabPassword = md5;
|
LogHelper.Info(md5);
|
m_AccountService.UpdateUserRequestInfo(x);
|
});
|
}
|
catch(Exception ex)
|
{
|
LogHelper.Error(ex.ToString());
|
}
|
return Json("ok");
|
}
|
|
|
public ActionResult SeveLogin(UserRequestInfoModel info)
|
{
|
try
|
{
|
if (info.LabLoginName != Session["ValidateCode"].ToString())
|
{
|
return Json("yzm");
|
}
|
//if (!string.IsNullOrEmpty(Cookie.GetValue("userLogin_num")) && int.Parse(Cookie.GetValue("userLogin_num")) > 3)
|
//{
|
// return Json("3");
|
//}
|
//if (string.IsNullOrEmpty(Cookie.GetValue("userLogin_num")) || Cookie.GetValue("userLogin_num") == "")
|
//{
|
// Cookie.Save("userLogin_num", "1", 1);
|
//}
|
//else
|
//{
|
// string number = (int.Parse(Cookie.GetValue("userLogin_num")) + 1).ToString();
|
// Cookie.Save("userLogin_num", number, 1);
|
//}
|
if (info != null)
|
{
|
UserRequestInfo User = null;
|
try
|
{
|
string md5_password = MD5Helper.MD5Encrypt3(info.LabPassword);
|
User = m_AccountService.GetUserRequestInfoQueryable()
|
.FirstOrDefault(p => p.LabCode.ToLower() == info.LabCode.ToLower()
|
&& (p.LabPassword == info.LabPassword)
|
|| p.LabPassword == md5_password);
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Error(ex.ToString());
|
}
|
if (User != null)
|
{
|
Cookie.Save("login_user", User.Id.ToString(), 120);
|
Cookie.isValidUser(User.Id.ToString(), true);
|
LogHelper.Debug(User.LabCode + "用户请求登录成功");
|
Cookie.Save("userLogin_num", "1", 1);
|
return Json("ok");
|
}
|
}
|
else
|
{
|
LogHelper.Info("未查到用户信息:" + JsonConvert.SerializeObject(info));
|
}
|
}
|
catch (Exception ex)
|
{
|
LogHelper.Error(ex.ToString());
|
}
|
LogHelper.Debug(info.LabCode + "用户请求登录失败");
|
return Json("no");
|
}
|
public ActionResult Contact()
|
{
|
EmeilInfoModel viewModel = new EmeilInfoModel();
|
return View(viewModel);
|
}
|
public ActionResult SeveContact(EmeilInfoModel info)
|
{
|
info.SendOutDatetime = DateTime.Now;
|
EmileInfo entity = EmeilInfoModel.FormEntity(info);
|
entity.EmileName = "eqas@sbc.org.cn ";
|
m_AccountService.InserEmilinfo(entity);
|
return Json("ok");
|
}
|
|
}
|
}
|