WinIndexController.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using Central.Control.Domain;
  7. using MES.Production.Service.IService;
  8. using Ant.Service.Common;
  9. using Ant.Service.Common.Enums;
  10. using ChangFa.Machinery.WebPage.Controllers;
  11. namespace ChangFa.Machinery.WebPage.Areas.ComManage.Controllers
  12. {
  13. /// <summary>
  14. /// 快速导航控制器
  15. /// </summary>
  16. public class WinIndexController : BaseController
  17. {
  18. #region 声明容器
  19. /// <summary>
  20. /// 快速导航
  21. /// </summary>
  22. IWinIndexManage WinIndexManage { get; set; }
  23. #endregion
  24. #region 公共变量
  25. #endregion
  26. #region 基本视图
  27. /// <summary>
  28. /// 快速导航列表
  29. /// </summary>
  30. public ActionResult Index()
  31. {
  32. var result = this.WinIndexManage.LoadAll(null).OrderBy(p => p.SHOWORDER).ToList();
  33. return View(result);
  34. }
  35. /// <summary>
  36. /// 详情
  37. /// </summary>
  38. public ActionResult Detail(string id)
  39. {
  40. var entity = this.WinIndexManage.Get(p => p.ID == id) ?? new COM_INDEX();
  41. return View(entity);
  42. }
  43. /// <summary>
  44. /// 保存
  45. /// </summary>
  46. public ActionResult Save(COM_INDEX entity)
  47. {
  48. var json = new JsonHelper() { Status = "n", Msg = "保存成功" };
  49. bool isEdit = true;
  50. if (entity != null)
  51. {
  52. entity.COLOR = Request["COLOR"] ?? "";
  53. entity.BACKGROUNDCOLOR = Request["BACKGROUNDCOLOR"] ?? "";
  54. var _entity = new COM_INDEX();
  55. _entity = entity;
  56. //添加
  57. if (string.IsNullOrEmpty(entity.ID))
  58. {
  59. _entity.ID = Guid.NewGuid().ToString();
  60. isEdit = false;
  61. }
  62. //判断是否重名
  63. if (!this.WinIndexManage.IsExist(p => p.TITLE == _entity.TITLE && p.ID != _entity.ID))
  64. {
  65. if (this.WinIndexManage.SaveOrUpdate(entity, isEdit))
  66. {
  67. json.Status = "y";
  68. }
  69. else
  70. {
  71. json.Msg = "保存失败";
  72. }
  73. }
  74. else
  75. {
  76. json.Msg = "导航" + _entity.TITLE + "已存在,不能重复添加";
  77. }
  78. }
  79. else
  80. {
  81. json.Msg = "未找到需要保存的记录";
  82. }
  83. return Json(json);
  84. }
  85. /// <summary>
  86. /// 移除
  87. /// </summary>
  88. public ActionResult Delete(string idlist)
  89. {
  90. var json = new JsonHelper() { Msg = "删除成功", Status = "n" };
  91. try
  92. {
  93. if (!string.IsNullOrEmpty(idlist))
  94. {
  95. var idlist1 = idlist.Trim(',').Split(',').ToList();
  96. this.WinIndexManage.Delete(p => idlist1.Contains(p.ID));
  97. json.Status = "y";
  98. }
  99. else
  100. {
  101. json.Msg = "未找到要删除的记录";
  102. }
  103. WriteLog(enumOperator.Remove, "删除快速导航,结果:" + json.Msg,enumLog4net.WARN);
  104. }
  105. catch (Exception e) { WriteLog(enumOperator.Remove, "删除快速导航出现异常", e); }
  106. return Json(json);
  107. }
  108. #endregion
  109. #region 其他调用
  110. /// <summary>
  111. /// 首页快速导航按钮
  112. /// </summary>
  113. public ActionResult GetCenterIndex()
  114. {
  115. var json = new JsonHelper() { Status = "n" };
  116. var num = (Request["num"] ?? "") == "" ? 5 : int.Parse(Request["num"].ToString());
  117. try
  118. {
  119. json.Data = this.WinIndexManage.LoadAll(null).OrderBy(p => p.SHOWORDER).Take(num).ToList();
  120. json.Status = "y";
  121. }
  122. catch { }
  123. return Json(json);
  124. }
  125. #endregion
  126. #region 帮助方法
  127. #endregion
  128. }
  129. }