|  |  |  | @ -1,4 +1,7 @@ | 
			
		
	
		
			
				
					|  |  |  |  | using System; | 
			
		
	
		
			
				
					|  |  |  |  | using System.Collections.Generic; | 
			
		
	
		
			
				
					|  |  |  |  | using System.Data; | 
			
		
	
		
			
				
					|  |  |  |  | using System.IO; | 
			
		
	
		
			
				
					|  |  |  |  | using System.Web.Http; | 
			
		
	
		
			
				
					|  |  |  |  | using FactorySystemBll; | 
			
		
	
		
			
				
					|  |  |  |  | using FactorySystemCommon; | 
			
		
	
	
		
			
				
					|  |  |  | @ -87,5 +90,36 @@ namespace FactorySystemApi.Controllers | 
			
		
	
		
			
				
					|  |  |  |  |             }, apiResult, Request); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         /// <summary> | 
			
		
	
		
			
				
					|  |  |  |  |         /// 导出操作日志 | 
			
		
	
		
			
				
					|  |  |  |  |         /// </summary> | 
			
		
	
		
			
				
					|  |  |  |  |         [HttpPost] | 
			
		
	
		
			
				
					|  |  |  |  |         public ApiResult DownloadLogs(Dictionary<string, object> inParams) | 
			
		
	
		
			
				
					|  |  |  |  |         { | 
			
		
	
		
			
				
					|  |  |  |  |             ApiResult apiResult = new ApiResult(); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             return ExceptionHelper.TryReturnException(() => | 
			
		
	
		
			
				
					|  |  |  |  |             { | 
			
		
	
		
			
				
					|  |  |  |  |                 string basePath = AppDomain.CurrentDomain.BaseDirectory.Trim('\\'); | 
			
		
	
		
			
				
					|  |  |  |  |                 string savePath = basePath + string.Format("\\File\\Temp\\logs\\"); | 
			
		
	
		
			
				
					|  |  |  |  |                 string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx"; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                 int limit = inParams.ContainsKey("limit") ? int.Parse(inParams["limit"].ToString()) : 1000; | 
			
		
	
		
			
				
					|  |  |  |  |                 if (!Directory.Exists(savePath)) Directory.CreateDirectory(savePath); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                 CreateExeclFileLogs(fileName, savePath, limit); | 
			
		
	
		
			
				
					|  |  |  |  |                 string url = Request.RequestUri.AbsoluteUri.Replace(Request.RequestUri.AbsolutePath, "") + savePath.Replace(basePath, "").Replace("\\", "/") + fileName; | 
			
		
	
		
			
				
					|  |  |  |  |                 apiResult.Data = url; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             }, apiResult, Request); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         private void CreateExeclFileLogs(string fName, string savePath, int limit) | 
			
		
	
		
			
				
					|  |  |  |  |         { | 
			
		
	
		
			
				
					|  |  |  |  |             DataTable dataList = new DataTable(); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             dataList = OperateLogBll.GetLogs(limit); | 
			
		
	
		
			
				
					|  |  |  |  |             NPOIHelper.ExportDTtoExcel(dataList, "Sheet1", savePath + fName); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
	
		
			
				
					|  |  |  | 
 |