123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267 |
- 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
- {
- /// <summary>
- /// 主页面
- /// add 作者: 季健国 QQ:181589805 by 2016-05-23
- /// </summary>
- 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("~");
- }
- /// <summary>
- /// 加载主页面
- /// </summary>
- public ActionResult Index()
- {
- try
- {
- ViewData["CurrentUser"] = this.CurrentUser;
- //获取当前用户所展示的模块
- var Module = new List<SYS_MODULE>();
- 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
- });
- }
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- [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<YW_AlarmInformation>(p => new YW_AlarmInformation { IsRead = true }, p => p.IsRead == false, request);
- if (updatereslut.IsSuccess)
- {
- }
- }
- return reslut;
- }
- /// <summary>
- /// 获取故障报警信息
- /// </summary>
- /// <returns></returns>
- [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<YW_AlarmInformation>().Where(p => p.IsRead == false).Top(10).OrderByDesc(p => p.Add_Time).ToList();
- if (reslut.IsSuccess)
- {
- HTMLSTR += "<fieldset><legendname>农机报警信息</legendname>";
- foreach (YW_AlarmInformation mod in reslut.ResultModel)
- {
- HTMLSTR += "<li>" + mod.Content + "</li>";//<button id='popbtn' onclick=\"switchWindow('2|4|1|3|5','/Configuration/zbwd/left_navigation.aspx?tag=spwd',null,null);\">查看</button>
- }
- }
- }
- //if (count != 0 || ShareCount != 0 || SPCount != 0 || ShareUrgentCount != 0 || SPUrgentCount != 0)
- //{
- // HTMLSTR += "<fieldset><legendname>其他待处理信息</legendname>";
- // if (ShareCount != 0)
- // {
- // HTMLSTR += "<li>您有" + ShareCount + "条目录文件没有完成共享,XXXXXXXXXXXXXXXXXXXdddddddddddddddddddXXXXXXXXXXXXXXXXXXXXXXX请注意查看 <button id='popbtn' onclick=\"switchWindow('2|4|1|3|5','/Configuration/zbwd/left_navigation.aspx?tag=gxwd',null,null);\">查看</button></li>";
- // }
- // if (ShareUrgentCount != 0)
- // {
- // HTMLSTR += "<li>您有" + ShareUrgentCount + "条紧急目录文件没有完成共享,请注意查看 <button id='popbtn' onclick=\"switchWindow('2|4|1|3|5','/Configuration/zbwd/left_navigation.aspx?tag=gxwd',null,null);\">查看</button></li>";
- // }
- // if (SPCount != 0)
- // {
- // HTMLSTR += "<li>您有" + SPCount + "条目录文件没有审批,请注意查看 <button id='popbtn' onclick=\"switchWindow('2|4|1|3|5','/Configuration/zbwd/left_navigation.aspx?tag=spwd',null,null);\">查看</button></li>";
- // }
- // if (SPUrgentCount != 0)
- // {
- // HTMLSTR += "<li>您有" + SPUrgentCount + "条紧急目录文件没有审批,请注意查看 <button id='popbtn' onclick=\"switchWindow('2|4|1|3|5','/Configuration/zbwd/left_navigation.aspx?tag=spwd',null,null);\">查看</button></li>";
- // }
- // HTMLSTR += "</fieldset>";
- //}
- return HTMLSTR;
- }
- /// <summary>
- /// 构造导航栏目JSON包
- /// </summary>
- string GetMenu(out List<SYS_MODULE> 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();
- }
- /// <summary>
- /// 管理中心
- /// </summary>
- public ActionResult Center()
- {
- return View();
- }
- /// <summary>
- /// 局部页
- /// </summary>
- public ActionResult Refresh()
- {
- //保存online表
- return View();
- }
- }
- }
|