public ActionResult Create() { ReportProvider provider = new ReportProvider(); ReportsEntity oldEntity = null; ReportsEntity entity = WebUtil.GetFormObject <ReportsEntity>("entity", null); entity.CreateTime = DateTime.Now; entity.IsDelete = (int)EIsDelete.NotDelete; entity.Status = (int)EBool.No; //是否被禁用 entity.FileName = entity.FileName.IsEmpty() ? "/Theme/content/report/" + Guid.NewGuid().ToString() + ".frx" : entity.FileName; List <ReportParamsEntity> listSource = Session[CacheKey.JOOSHOW_REPORTPARAM_CACHE] as List <ReportParamsEntity>; if (!entity.ReportNum.IsEmpty()) { oldEntity = provider.GetReport(entity.ReportNum); } if (oldEntity != null) { if (oldEntity.FileName != entity.FileName) { string FileRealPath = Server.MapPath("~" + oldEntity.FileName); string FileTempPath = Server.MapPath("~" + entity.FileName); FileManager.DeleteFile(FileRealPath); System.IO.File.Copy(FileTempPath, FileRealPath, true); entity.FileName = oldEntity.FileName; } } else { FileItem fileItem = FileManager.GetItemInfo(Server.MapPath("~" + entity.FileName)); string FileRealPath = Server.MapPath("~/Theme/content/report/" + fileItem.Name); string FileTempPath = Server.MapPath("~" + entity.FileName); FileManager.MoveFile(FileTempPath, FileRealPath); entity.FileName = "/Theme/content/report/" + fileItem.Name; } int line = provider.Create(entity, listSource); if (line > 0) { this.ReturnJson.AddProperty("Key", "1000"); this.ReturnJson.AddProperty("Value", "操作成功"); } else { this.ReturnJson.AddProperty("Key", "1001"); this.ReturnJson.AddProperty("Value", "操作失败"); } return(Content(this.ReturnJson.ToString())); }
/// <summary> /// 新增自定义报表 /// </summary> /// <returns></returns> public ActionResult Add() { string CompanyID = WebUtil.GetFormValue <string>("CompanyID", string.Empty); ReportsEntity entity = WebUtil.GetFormObject <ReportsEntity>("Entity"); List <ReportParamsEntity> list = WebUtil.GetFormObject <List <ReportParamsEntity> >("List"); ReportProvider provider = new ReportProvider(CompanyID); int line = provider.Create(entity, list); DataResult result = new DataResult(); if (line > 0) { result.Code = (int)EResponseCode.Success; result.Message = "自定义报表新增成功"; } else { result.Code = (int)EResponseCode.Exception; result.Message = "自定义报表新增失败"; } return(Content(JsonHelper.SerializeObject(result))); }