using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Ant.Service.Common.Enums; using MES.Production.Service.IService; using System.Text; using System.Collections; using System.Net; using Ant.Service.Common; using Central.Control.Domain; using System.IO; using Ant.ORM; using Ant.Data; using MES.Production.Entity; namespace ChangFa.Machinery.WebPage.Areas.SysManage.Controllers { /// /// 主页面 /// add 作者: 季健国 QQ:181589805 by 2016-05-23 /// public class HomeController : WebPage.Controllers.BaseController { #region 注入容器 IModuleManage ModuleManage { get; set; } #endregion static string urlPath = string.Empty; public HomeController() { //string url = Request.Url.ToString(); //var applicationPath = VirtualPathUtility.ToAbsolute("~") == "/" ? "" : VirtualPathUtility.ToAbsolute("~"); } /// /// 加载主页面 /// public ActionResult Index() { try { ViewData["CurrentUser"] = this.CurrentUser; //获取当前用户所展示的模块 var Module = new List(); ViewData["menu"] = GetMenu(out Module); ViewData["parentMenu"] = Module.FindAll(p => p.LEVELS == 0 && p.ISSHOW == 1).OrderBy(p => p.SHOWORDER).ToList(); return View(); } catch (Exception e) { WriteLog(enumOperator.Select, "系统主页面:", e); throw e.InnerException; } } public ActionResult UpLoadProcess(string id, string name, string type, string lastModifiedDate, int size, HttpPostedFileBase file) { string filePathName = string.Empty; var applicationPath = "http://" + Request.Url.Authority.ToString(); urlPath = "/Upload/"; var fileid = Guid.NewGuid().ToString("N"); string localPath = Path.Combine(HttpRuntime.AppDomainAppPath, "Upload"); if (Request.Files.Count == 0) { return Json(new { jsonrpc = 2.0, error = new { code = 102, message = "保存失败" }, id = id }); } string ex = Path.GetExtension(file.FileName); filePathName = fileid + ex; if (!System.IO.Directory.Exists(localPath)) { System.IO.Directory.CreateDirectory(localPath); } var filePath = urlPath + filePathName; file.SaveAs(Path.Combine(localPath, filePathName)); var _result = "{\"jsonrpc\" : \"2.0\", \"result\" : null, \"id\" : \"" + filePath + "\"}"; return Json(new { jsonrpc = "2.0", id = id, fileid = fileid, filePath = filePath }); } /// /// /// /// [HttpGet] public string UpdateAlarmInfo() { string reslut = ""; using (AntORM orm = new AntORM()) { orm.db = DataAccessFactory.CreateDataConnection("CyclingItem"); RequestModel request = new RequestModel(); request.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "查询菜单的单个实体方法" }; var updatereslut = orm.UpdateByLambda(p => new YW_AlarmInformation { IsRead = true }, p => p.IsRead == false, request); if (updatereslut.IsSuccess) { } } return reslut; } /// /// 获取故障报警信息 /// /// [HttpGet] public string GetAlarmInfo() { string HTMLSTR = ""; int count = 1;// dc_popwin.getCount(userdpet); int ShareCount = 1;// dc_popwin.getSharCount(usercode); int SPCount = 1;//dc_popwin.getSPCount(usercode); int ShareUrgentCount = 1;//dc_popwin.getUrgentShare(usercode); int SPUrgentCount = 1;// dc_popwin.getUrgentSP(usercode); using (AntORM orm = new AntORM()) { orm.db = DataAccessFactory.CreateDataConnection("CyclingItem"); RequestModel request = new RequestModel(); request.newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "查询菜单的单个实体方法" }; var reslut = orm.Queryable().Where(p => p.IsRead == false).Top(10).OrderByDesc(p => p.Add_Time).ToList(); if (reslut.IsSuccess) { HTMLSTR += "
农机报警信息"; foreach (YW_AlarmInformation mod in reslut.ResultModel) { HTMLSTR += "
  • " + mod.Content + "
  • ";// } } } //if (count != 0 || ShareCount != 0 || SPCount != 0 || ShareUrgentCount != 0 || SPUrgentCount != 0) //{ // HTMLSTR += "
    其他待处理信息"; // if (ShareCount != 0) // { // HTMLSTR += "
  • 您有" + ShareCount + "条目录文件没有完成共享,XXXXXXXXXXXXXXXXXXXdddddddddddddddddddXXXXXXXXXXXXXXXXXXXXXXX请注意查看  
  • "; // } // if (ShareUrgentCount != 0) // { // HTMLSTR += "
  • 您有" + ShareUrgentCount + "条紧急目录文件没有完成共享,请注意查看  
  • "; // } // if (SPCount != 0) // { // HTMLSTR += "
  • 您有" + SPCount + "条目录文件没有审批,请注意查看  
  • "; // } // if (SPUrgentCount != 0) // { // HTMLSTR += "
  • 您有" + SPUrgentCount + "条紧急目录文件没有审批,请注意查看  
  • "; // } // HTMLSTR += "
    "; //} return HTMLSTR; } /// /// 构造导航栏目JSON包 /// string GetMenu(out List Module) { StringBuilder sbmenu = new StringBuilder(); Module = ModuleManage.GetModule(this.CurrentUser.Id, this.CurrentUser.Permissions, this.siteId); sbmenu.Append("["); //一级栏目 var firstModule = Module.FindAll(p => p.LEVELS == 0 && p.ISSHOW == 1); if (firstModule.Count > 0) { for (int i = 0; i < firstModule.Count; i++) { sbmenu.Append("{\"id\":\"" + firstModule[i].ALIAS + "\","); //默认打开模块为二级目的的第一个三级栏目 var defaultModule = string.Empty; var has = Module.FindAll(c => c.PARENTID == firstModule[i].ID && c.LEVELS == 1 && c.ISSHOW == 1); if (has.Count > 0) { var nhas = Module.FindAll(c => c.LEVELS == 2 && c.PARENTID == has.First().ID); if (nhas.Count > 0) { defaultModule = nhas.First().ALIAS; } } sbmenu.Append("\"homePage\":\"" + defaultModule + "\","); sbmenu.Append("\"menu\":["); //二级栏目 var secondModule = Module.FindAll(p => p.LEVELS == 1 && p.PARENTID == firstModule[i].ID && p.ISSHOW == 1); if (secondModule.Count > 0) { for (var j = 0; j < secondModule.Count; j++) { sbmenu.Append("{"); sbmenu.Append("\"text\":\"" + secondModule[j].NAME + "\","); sbmenu.Append("\"icon\":\"" + secondModule[j].ICON + "\","); if (j > 0) { sbmenu.Append("\"collapsed\":true,"); } sbmenu.Append("\"items\":["); //三级栏目 var threeModule = Module.FindAll(p => p.LEVELS == 2 && p.PARENTID == secondModule[j].ID && p.ISSHOW == 1); if (threeModule.Count > 0) { for (int k = 0; k < threeModule.Count; k++) { sbmenu.Append("{"); sbmenu.Append("\"id\": \"" + threeModule[k].ALIAS + "\","); sbmenu.Append("\"text\": \"" + threeModule[k].NAME + "\","); sbmenu.Append("\"href\":\"" + threeModule[k].MODULEPATH + "\","); if (threeModule[k].ALIAS.ToLower() == "center") { sbmenu.Append("\"closeable\":false,"); } sbmenu.Append("\"icon\": \"" + threeModule[k].ICON + "\""); sbmenu.Append("},"); } sbmenu.Length -= 1; } sbmenu.Append("]},"); } sbmenu.Length -= 1; } sbmenu.Append("]},"); } sbmenu.Length -= 1; } sbmenu.Append("]"); return sbmenu.ToString(); } /// /// 管理中心 /// public ActionResult Center() { return View(); } /// /// 局部页 /// public ActionResult Refresh() { //保存online表 return View(); } } }