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 += "