之前經常有朋友問我一些常用的工具,比如我的架構圖是用什么工具做的?我的數據庫是用什么工具設計的?今天給大家介紹下我用的順手的工具!
業界公認最好的Java開發工具,平時用的最多。可以安裝大量插件豐富功能,開發前端應用也不在話下!
一款強大的安全終端模擬軟件,可以用來連接和管理遠程Linux服務器。
API接口調試工具,平時用來測試開發好的接口,有時也用來格式化下JSON字符串。
數據庫設計工具,平時用來設計數據庫表,設計完成之后可以直接導出數據庫表。
數據庫可視化工具,支持多種數據庫,平時用來連接并管理數據庫,項目上線的時候可以用來同步表結構。
Redis可視化工具,平時用來查看和管理Redis緩存中的數據,有時候需要清空緩存的時候就用到它了。
MongoDB可視化工具,平時用來查看和管理MongoDB中的數據。
平時用來寫文章的Markdown編輯器,編輯與預覽二合一,界面簡潔且功能強大!
作圖工具,可以用來制作思維導圖和流程圖,mall項目的架構圖就是用這個畫的!
好用的思維導圖制作工具,設計功能的時候可以用來整理下思路。
一款好用的截屏工具,文章中很多圖片都是用這個截的。
用來制作Gif的工具,mall項目功能演示的Gif就是用這個做的。
nline Designer用戶面臨的首要問題之一是如何組織從本地計算機下載報告? 今天,我們將考慮從本地計算機上傳到Online Designer,并使用ASP.Net MVC應用程序的示例下載已修改的報告。
創建一個ASP.Net MVC項目。 我們將需要以下庫:
打開控制器HomeController.cs。 將缺少的庫添加到uses部分:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.UI; using System.Runtime.Caching; using System.Text; using System.IO; using FastReport; using FastReport.Web; using FastReport.Utils; using System.Web.UI.WebControls; using FastReport.Export.Html; using FastReport.Data; using System.Net.Http.Headers; using FastReport.Export.Image; using System.Net.Http;
我們將在Index方法中顯示OnlineDesigner。 不過,首先我們要創建一個Web報表對象和一個用于存儲報表文件的緩存。 我使用緩存是為了避免將文件保存在服務器上:
private WebReport webReport=new WebReport; //Report object MemoryCache cache=MemoryCache.Default; //Cache public ActionResult Index(HttpPostedFileBase upload) { webReport.Width=Unit.Percentage(100); webReport.Height=Unit.Percentage(100); string report_path=GetReportPath; // The path to the folder with reports System.Data.DataSet dataSet=new System.Data.DataSet; dataSet.ReadXml(report_path + "nwind.xml"); //Read database webReport.Report.RegisterData(dataSet, "NorthWind"); // Register the data in the report // If you do not use the cache, then load the report from the server if (System.IO.File.Exists(report_path + "report.frx")) { webReport.Report.Load(report_path + "report.frx"); } // If you are using a cache, then load a report from it if (cache.Contains("1")) { webReport.Report.Load(cache["1"] as Stream); } // Online-Designer settings webReport.DesignReport=true; webReport.DesignScriptCode=false; webReport.Debug=true; webReport.DesignerPath="~/WebReportDesigner/index.html"; webReport.DesignerSaveCallBack="~/Home/SaveDesignedReport"; webReport.ID="DesignReport"; ViewBag.WebReport=webReport; //Pass the report to View return View; }
獲取報告路徑的方法:
private string GetReportPath { return this.Server.MapPath("~/App_Data/"); }
接下來,我們添加上傳文件的方法:
[HttpPost] // Attribute indicates that the method is processing the Post request public ActionResult Upload(HttpPostedFileBase upload) { if (upload !=null) { // Get file name string fileName=System.IO.Path.GetFileName(upload.FileName); // Save report in cache cache.Add("1", upload.InputStream, DateTimeOffset.Now.AddMinutes(1)); // If you save to a file on the server upload.SaveAs(Server.MapPath("~/App_Data/report.frx")); } return RedirectToAction("Index"); }
請注意DateTimeOffset.Now.AddMinutes(1)參數。 它指定緩存的有效期。
現在我們需要一個在線設計器中保存報告的方法:
[HttpPost] // call-back for save the designed report public ActionResult SaveDesignedReport(string reportID, string reportUUID) { ViewBag.Message=String.Format("Confirmed {0} {1}", reportID, reportUUID); if (reportID=="DesignReport") { //Save report in cache cache.Set("1", Request.InputStream, DateTimeOffset.Now.AddMinutes(10)); // If the report is saved to the server /*************************************/ Stream reportForSave=Request.InputStream; string pathToSave=Server.MapPath("~/App_Data/DesignedReports/test.frx"); using (FileStream file=new FileStream(pathToSave, FileMode.Create)) { reportForSave.CopyTo(file); } /*************************************/ } return View; }
我們為這個方法創建一個單獨的視圖SaveDesignedReport.cshtml:
@ViewBag.Message
它仍然是實現下載報告文件的方法:
public FileResult GetFile { Stream str=cache["1"] as Stream; // Prepare a file for download from the cache return File(str, "application/octet-stream","test.frx"); // If you used saving report to the file on the server return File(Server.MapPath("~/App_Data/DesignedReports/test.frx"), "application/octet-stream", "test.frx"); }
現在考慮索引頁面的視圖(Home-> Index.cshtml):
@{ ViewBag.Title="Home Page"; }Select file
@using (Html.BeginForm("Upload", "Home", FormMethod.Post, new { enctype="multipart/form-data" })) { }@using (Html.BeginForm("GetFile", "Home", FormMethod.Get)) { }
@ViewBag.WebReport.GetHtml
在頂部我們顯示頁面的標題。 接下來,使用BeginForm助手來創建一個帶有文件選擇按鈕的表單。 參數指定處理器方法的名稱 - “Upload”,控制器名稱為“Home”,處理方法為FormMethod.Post,數據編碼方式為 - enctype=“multipart / form-data”。
接下來,插入文件下載字段和按鈕。
在頁面的右側,我們將放置一個按鈕,用其上傳/下載編輯后的報告。 對于它,我們也使用BeginForm助手創建一個表單。
在最后一行代碼中,我們顯示從控制器收到的報告。
有必要連接文件_Layout.cshtml中的腳本:
@WebReportGlobals.Scripts @WebReportGlobals.Styles
現在您需要對兩個Web配置進行更改。 這些文件被稱為相同,但它們位于不同的文件夾中。 第一個位于Views文件夾中。 我們加入:
第二個文件位于項目的根目錄下。 在其中我們添加一個處理程序:
運行我們的應用。
我們看到一個空的報告OnlineDesigner。 使用“選擇文件”按鈕從本地計算機下載報告。 從對話框中選擇文件并點擊上傳按鈕:
報告模板已加載。 讓我們改變數據帶中的背景顏色。 在“報告”標簽上,我們點擊“保存”按鈕:
SaveDesignedReport方法起作用,我們看到右邊的綠色警報:
現在點擊“Download designed report”按鈕:
瀏覽器下載我們的報告 使用報表設計器打開它:
這樣就得到了我們的報告,接下來可以用Online Designer進行編輯。
之前經常有朋友問我一些常用的工具,比如我的架構圖是用什么工具做的?我的數據庫是用什么工具設計的?今天給大家介紹下我用的順手的工具!
業界公認最好的Java開發工具,平時用的最多。可以安裝大量插件豐富功能,開發前端應用也不在話下!
一款強大的安全終端模擬軟件,可以用來連接和管理遠程Linux服務器。
API接口調試工具,平時用來測試開發好的接口,有時也用來格式化下JSON字符串。
數據庫設計工具,平時用來設計數據庫表,設計完成之后可以直接導出數據庫表。
數據庫可視化工具,支持多種數據庫,平時用來連接并管理數據庫,項目上線的時候可以用來同步表結構。
Redis可視化工具,平時用來查看和管理Redis緩存中的數據,有時候需要清空緩存的時候就用到它了。
MongoDB可視化工具,平時用來查看和管理MongoDB中的數據。
平時用來寫文章的Markdown編輯器,編輯與預覽二合一,界面簡潔且功能強大!
作圖工具,可以用來制作思維導圖和流程圖,mall項目的架構圖就是用這個畫的!
好用的思維導圖制作工具,設計功能的時候可以用來整理下思路。
一款好用的截屏工具,文章中很多圖片都是用這個截的。
用來制作Gif的工具,mall項目功能演示的Gif就是用這個做的。
以上內容都是我自己的一些感想,分享出來歡迎大家指正,順便求一波關注,有想法的伙伴可以評論或者私信我哦~
*請認真填寫需求信息,我們會在24小時內與您取得聯系。