using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Web; using System.Web.Mvc; using DSWeb.SoftMng.BLL; using DSWeb.SoftMng.Model; namespace DSWeb.SoftMng.Controllers { public class EmailConfigController : Controller { #region View /// /// 首页 /// /// //[ModuleAuthFilter(Name = "secRegist")]//过滤器 public ActionResult Index() { if (Session["CODENAME"] == null) Response.Redirect("/login.aspx"); return View(); } #endregion #region Handler public JsonResult GetList() { EmailConfigBLL bll = new EmailConfigBLL(); var list = bll.GetModelList(""); return Json(list); } /// /// 保存主实例 /// /// /// public JsonResult Save(EmailConfig model) { EmailConfigBLL bll = new EmailConfigBLL(); bool result; var nowDate = DateTime.Now; //获取原数据 var oldModel = bll.GetModel(); if (oldModel==null) { result = bll.Add(model) > 0; } //新增 else { //类反射 Type type = typeof(EmailConfig); PropertyInfo[] piArr = type.GetProperties(); foreach (var pi in piArr) { if (Array.IndexOf(Request.Params.AllKeys, pi.Name) < 0) pi.SetValue(model, pi.GetValue(oldModel, null), null); } result = bll.Update(model) > 0; } //修改 return Json(new { success = result, message = result ? "操作成功" : "操作失败" }); } #endregion } }