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());
        }
 public ActionResult GetMetadata()
 {
     ReportProvider provider = new ReportProvider();
     string ProceName = WebUtil.GetFormValue<string>("ProceName", string.Empty);
     List<ReportParamsEntity> list = provider.GetProceMetadata(ProceName);
     if (!list.IsNullOrEmpty())
     {
         Session[CacheKey.JOOSHOW_REPORTPARAM_CACHE] = list;
     }
     return Content(this.ReturnJson.ToString());
 }
 /// <summary>
 /// 批量删除
 /// </summary>
 /// <returns></returns>
 public ActionResult DeleteBatch()
 {
     List<string> list = WebUtil.GetFormObject<List<string>>("list", null);
     ReportProvider provider = new ReportProvider();
     int line = provider.Delete(list);
     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());
 }
 public ActionResult GetList()
 {
     int status = WebUtil.GetFormValue<int>("Status", 0);
     int ReportType = WebUtil.GetFormValue<int>("ReportType", -1);
     string ReportName = WebUtil.GetFormValue<string>("ReportName", string.Empty);
     int pageSize = WebUtil.GetFormValue<int>("PageSize", 10);
     int pageIndex = WebUtil.GetFormValue<int>("PageIndex", 1);
     PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize };
     ReportsEntity entity = new ReportsEntity();
     ReportProvider provider = new ReportProvider();
     if (status > -1)
     {
         entity.Where(a => a.Status == status);
     }
     if (!ReportName.IsEmpty())
     {
         entity.Where("ReportName", ECondition.Like, "%" + ReportName + "%");
     }
     if (ReportType > 0)
     {
         entity.Where(a => a.ReportType == ReportType);
     }
     List<ReportsEntity> listResult = provider.GetList(entity, ref pageInfo);
     listResult = listResult == null ? new List<ReportsEntity>() : listResult;
     string json = JsonConvert.SerializeObject(listResult);
     this.ReturnJson.AddProperty("Data", json);
     this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount);
     return Content(this.ReturnJson.ToString());
 }
 /// <summary>
 /// 删除报表
 /// </summary>
 /// <returns></returns>
 public ActionResult Delete()
 {
     string ReportNum = WebUtil.GetFormValue<string>("ReportNum", string.Empty);
     ReportProvider provider = new ReportProvider();
     int line = provider.Delete(ReportNum);
     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());
 }
Esempio n. 6
0
        public ActionResult Designer()
        {
            string ReportNum = WebUtil.GetQueryStringValue<string>("SnNum", string.Empty);
            ReportProvider provider = new ReportProvider();
            if (ReportNum.IsEmpty())
            {
                return Redirect("/Report/Manager/List");
            }
            ReportsEntity entity = provider.GetReport(ReportNum);
            if (entity.IsNull())
            {
                return Redirect("/Report/Manager/List");
            }
            List<ReportParamsEntity> list = provider.GetParams(ReportNum);

            WebReport webReport = new WebReport();
            webReport.Width = Unit.Percentage(100);
            webReport.Height = 600;
            webReport.ToolbarIconsStyle = ToolbarIconsStyle.Black;
            webReport.ToolbarIconsStyle = ToolbarIconsStyle.Black;
            webReport.PrintInBrowser = true;
            webReport.PrintInPdf = true;
            webReport.ShowExports = true;
            webReport.ShowPrint = true;
            webReport.SinglePage = true;
            DataSet ds = null;
            int orderType = 0;
            if (ReportNum == ResourceManager.GetSettingEntity("InOrder_Template").Value)
            {
                orderType = (int)EOrder.InOrder;
            }
            else if (ReportNum == ResourceManager.GetSettingEntity("OutOrder_Template").Value)
            {
                orderType = (int)EOrder.OutOrder;
            }
            ds = new ReportProvider().GetDataSource(entity, list, orderType, "");
            string path = Server.MapPath("~" + entity.FileName);
            if (!FileManager.FileExists(path))
            {
                string template = Server.MapPath("~/Theme/content/report/temp/Report.frx");
                System.IO.File.Copy(template, path, true);
            }
            webReport.Report.Load(path);
            if (ds != null && ds.Tables != null && ds.Tables.Count > 0)
            {
                webReport.Report.RegisterData(ds);
                for (int i = 0; i < ds.Tables.Count; i++)
                {
                    webReport.Report.GetDataSource(ds.Tables[i].TableName).Enabled = true;
                }
            }
            webReport.DesignerPath = "~/WebReportDesigner/index.html";
            webReport.DesignReport = true;
            webReport.DesignScriptCode = true;
            webReport.DesignerSavePath = "~/Theme/content/report/temp/";
            webReport.DesignerSaveCallBack = "~/Report/Manager/SaveDesignedReport";
            webReport.ID = ReportNum;

            ViewBag.WebReport = webReport;
            return View();
        }
Esempio n. 7
0
        public ActionResult Show()
        {
            string ReportNum = WebUtil.GetQueryStringValue<string>("ReportNum", string.Empty);
            string orderNum = WebUtil.GetQueryStringValue<string>("OrderNum",string.Empty);
            ReportProvider provider = new ReportProvider();
            if (ReportNum.IsEmpty())
            {
                return Redirect("/Report/Manager/List");
            }
            ReportsEntity entity = provider.GetReport(ReportNum);
            if (entity.IsNull())
            {
                return Redirect("/Report/Manager/List");
            }
            List<ReportParamsEntity> list = provider.GetParams(ReportNum);
            list = list.IsNull() ? new List<ReportParamsEntity>() : list;
            string SearchValues = WebUtil.GetQueryStringValue<string>("SearchValues");
            SearchValues = SearchValues.UnEscapge();
            List<ReportParamsEntity> listParams = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ReportParamsEntity>>(SearchValues);
            if (!listParams.IsNullOrEmpty())
            {
                foreach (ReportParamsEntity item in listParams)
                {
                    item.ParamName = item.ParamName.Replace("arg_", "@");
                    if (list.Exists(a => a.ParamName == item.ParamName))
                    {
                        list.First(a => a.ParamName == item.ParamName).DefaultValue = item.DefaultValue;
                    }
                }
            }
            ViewBag.Entity = entity;
            ViewBag.ListParam = list;

            WebReport webReport = new WebReport();
            webReport.Width = Unit.Percentage(100);
            webReport.Height = 600;
            webReport.ToolbarIconsStyle = ToolbarIconsStyle.Black;
            webReport.ToolbarIconsStyle = ToolbarIconsStyle.Black;
            webReport.PrintInBrowser = true;
            webReport.PrintInPdf = true;
            webReport.ShowExports = true;
            webReport.ShowPrint = true;
            webReport.SinglePage = true;

            DataSet ds = null;
            int orderType = 0;
            if (ReportNum == ResourceManager.GetSettingEntity("InOrder_Template").Value)
            {
                orderType = (int)EOrder.InOrder;
            }
            else if (ReportNum == ResourceManager.GetSettingEntity("OutOrder_Template").Value)
            {
                orderType = (int)EOrder.OutOrder;
            }
            ds = new ReportProvider().GetDataSource(entity, list, orderType, orderNum);
            string path = Server.MapPath("~" + entity.FileName);
            if (!FileManager.FileExists(path))
            {
                string template = Server.MapPath("~/Theme/content/report/temp/Report.frx");
                System.IO.File.Copy(template, path, true);
            }
            webReport.Report.Load(path);
            if (ds != null && ds.Tables != null && ds.Tables.Count > 0)
            {
                webReport.Report.RegisterData(ds);
                for (int i = 0; i < ds.Tables.Count; i++)
                {
                    webReport.Report.GetDataSource(ds.Tables[i].TableName).Enabled = true;
                }
            }
            webReport.ID = ReportNum;
            ViewBag.WebReport = webReport;
            return View();
        }
Esempio n. 8
0
 /// <summary>
 /// 保存报表设计回调函数
 /// </summary>
 /// <param name="reportID"></param>
 /// <param name="reportUUID"></param>
 /// <returns></returns>
 public ActionResult SaveDesignedReport(string reportID, string reportUUID)
 {
     ReportProvider provider = new ReportProvider();
     if (reportID.IsEmpty())
     {
         return Redirect("/Report/Manager/List");
     }
     ReportsEntity entity = provider.GetReport(reportID);
     if (entity.IsNull())
     {
         return Redirect("/Report/Manager/List");
     }
     string FileRealPath = Server.MapPath("~" + entity.FileName);
     string FileTempPath = Server.MapPath("~/Theme/content/report/temp/" + reportUUID);
     FileManager.DeleteFile(FileRealPath);
     System.IO.File.Copy(FileTempPath, FileRealPath, true);
     return Content("");
 }
Esempio n. 9
0
        public ActionResult Edit()
        {
            string ReportNum = WebUtil.GetQueryStringValue<string>("ReportNum", string.Empty);
            Session[CacheKey.JOOSHOW_REPORTPARAM_CACHE] = null;
            if (ReportNum.IsEmpty())
            {
                return Redirect("/Report/Manager/List");
            }
            ReportProvider provider = new ReportProvider();
            ReportsEntity entity = provider.GetReport(ReportNum);
            if (entity.IsNull())
            {
                return Redirect("/Report/Manager/List");
            }
            ViewBag.Entity = entity;
            ViewBag.ReportType = EnumHelper.GetOptions<EReportType>(entity.ReportType);
            ViewBag.DataSourceType = EnumHelper.GetOptions<EDataSourceType>(entity.DsType);

            List<ReportParamsEntity> list = provider.GetParams(ReportNum);
            if (!list.IsNullOrEmpty())
            {
                Session[CacheKey.JOOSHOW_REPORTPARAM_CACHE] = list;
            }
            return View();
        }