using CommonHelper; using GasolineBlend.BLL; using GasolineBlend.Entity; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Web; using System.Web.Mvc; namespace GasolineBlend.Controllers { public class TreeDiagramRecordController : BaseController { private TreeDiagramRecordBLL _acc = new TreeDiagramRecordBLL(); /// ///获取查询历史数据 /// /// /// [HttpPost] public ActionResult GetTreeDiagramRecordIsName(string CompanyName) { try { if (OperatorProvider.Instance?.Current?.UserId != null) { var list = _acc.GetTreeDiagramRecordIsName(CompanyName, OperatorProvider.Instance.Current.UserId); if (list != null && list.Count > 0) { return SuccessNoShow(data: list); } return SuccessNoShow(data: null); } return SuccessNoShow(data: null); } catch (Exception e) { LogHelper.Write(Level.Error, "获取树状图数据 GetTreeDiagramRecordIsId", e, OperatorProvider.Instance.Current == null ? "GuestEx" : OperatorProvider.Instance.Current.LoginName); return Error(); } } /// ///添加历史数据 /// /// /// [HttpPost] public ActionResult AddTreeDiagramRecord(TreeDiagramRecord treeDiagramRecord) { try { if (OperatorProvider.Instance?.Current?.UserId != null) { treeDiagramRecord.UserId = OperatorProvider.Instance.Current.UserId; var list = _acc.GetTreeDiagramRecordIsName(treeDiagramRecord.CompanyName, treeDiagramRecord.UserId); if (list.Count == 0) { bool isAdd = _acc.AddTreeDiagramRecord(treeDiagramRecord); return isAdd ? SuccessNoShow() : Error(); } return SuccessNoShow(data: null); } return SuccessNoShow(data: null); } catch (Exception e) { LogHelper.Write(Level.Error, "添加树状图数据 AddTreeDiagramRecord" + "" + "", e, OperatorProvider.Instance.Current == null ? "GuestEx" : OperatorProvider.Instance.Current.LoginName); return Error(); } } /// ///修改历史数据 /// /// /// [HttpPost] public ActionResult UpdateTreeDiagramRecord(TreeDiagramRecord treeDiagramRecord) { try { if (OperatorProvider.Instance?.Current?.UserId != null) { treeDiagramRecord.UserId = OperatorProvider.Instance.Current.UserId; var list = _acc.GetTreeDiagramRecordIsName(treeDiagramRecord.CompanyName, treeDiagramRecord.UserId); if (list != null && list.Count != 0) { bool isUpdata = _acc.UpdateTreeDiagramRecord(treeDiagramRecord); return isUpdata ? SuccessNoShow() : Error(); } else { bool isUpdata = _acc.AddTreeDiagramRecord(treeDiagramRecord); } return SuccessNoShow(data: null); } return SuccessNoShow(data: null); } catch (Exception e) { LogHelper.Write(Level.Error, "修改树状图数据 UpdateTreeDiagramRecord" + "" + "", e, OperatorProvider.Instance.Current == null ? "GuestEx" : OperatorProvider.Instance.Current.LoginName); return Error(); } } } }