主頁 > .NET開發 > C#中word匯出功能騷操作

C#中word匯出功能騷操作

2021-02-11 06:03:25 .NET開發

馬上過牛年了,先祝大家新年好,身體好,心情好!!!

年前最后寫一篇之前專案開發的一個功能,自己根據系統業務,想到的一個解決辦法,效率還是不錯的,廢話不多說,開整!!!

需求:企業填報自己的企業資訊到系統中,最后需要將資料以給定word模板形式匯出,功能簡單,就是要開發快,趕及

分析:主要費時間的作業是設計企業填報表單設計實作,以及根據提供的word模板匯出資料這塊兒,因為涉及到的表單比較多,一個表單最少也有差不多150多個欄位,一個一個對,頭發也得一把一把的掉

想到的解決法案:在匯出word這個功能模塊兒,寫一些通用的方法,減少一些作業量,

        word資料匯出功能,思路就是在word模板中每一個需要填資料的地方命名一個標簽,代碼中找到對應命名的標簽,插入數值

                             傳統做法,第一步:在word模板中填寫標簽  第二步:程式中每個插入欄位資料和word模板標簽對應,最后插值,這樣做有一個問題就是比較耗時間,而且很容易出錯

        我的做法,第一步:給資料欄位一個自定義特性,在自定定義特性中寫上對應的標簽地址,應用反射的方法將資料最終插入到word模板中,這樣就省去了第一步在word中寫標簽這樣繁雜的操作,這樣做的問題就是性能比較差,但是可以忽略不計

大體思路就這樣,我就單獨寫一個demo供大家參考,之后能用就用,重在思路和想法的分享和討論

開寫:

新建一個專案:ExportWordModel

 

最終專案簡易結構:

 

 

 

 

 

 將沒用的東西全部去掉,修改Index.cshtml頁面成這樣:

1 @{
2     ViewBag.Title = "Home Page";
3 }
4 <div class="jumbotron" style="text-align: center">
5     @*<h1>ASP.NET</h1>*@
6     <input type="button" value=https://www.cnblogs.com/19930521zhang/archive/2021/02/10/"匯出" onclick="location.href = 'https://www.cnblogs.com/19930521zhang/archive/2021/02/10/@Url.Action("GetExport","Home")'" />
7 </div>

在 HomeController 中創建:GetExport

創建一個類ExportFileOperator(所有的word操作),此類需要繼承Controller,因為有回傳File操作方法

 

 

  1、 在GetExport中首先命名一個匯出word標題就叫:測驗匯出Word檔案

string title = "測驗匯出Word檔案";

創建doc:

 var doc = ExportFileOperator.CreateBuilder("GroupForm.doc");
2、CreateBuilder方法實作為(此處操作需要Aspose.Word組件,是操作word的,這個需要大家自己去找一下,或者網上找個破解的):
1 private static string _tempPath = AppDomain.CurrentDomain.BaseDirectory;
2 public static (Document doc, DocumentBuilder builder) CreateBuilder(string tempFileName)
3 {
4    string tempPath = $"{_tempPath}{tempFileName}";
5    Document doc = new Document(tempPath);
6    return (doc, new DocumentBuilder(doc));
7 }

  3、插入標題(需要在word中寫一個標簽,作為標題插入的地址):

 

 

 最終可以顯示結果為這樣:

 

 

 方法:

  ExportFileOperator.InsertTitle(ref doc.Item2, title);//插入標題 

public static void InsertTitle(ref DocumentBuilder builder, string fileName, string tempBookMarkName = "title")
{
     builder.MoveToBookmark(tempBookMarkName);
     builder.Write(fileName);
}

 4、根據業務物體,將物體資料寫入到word中,也是核心所在

首先命名一個資料類:

 public class EnterpriseEntity
    {
         #region 物體成員
        /// <summary>
        /// id
        /// </summary>
        public string id { get; set; }
        /// <summary>
        /// 團隊名
        /// </summary>
        [Description("企業名稱")]
        public string v1 { get; set; }
        /// <summary>
        /// 統一社會信用代碼
        /// </summary>
        [Description("統一社會信用代碼")]
        public string v3 { get; set; }
        /// <summary>
        /// 成立日期
        /// </summary>
        [Description("成立日期")]
        public string v4 { get; set; }

        /// <summary>
        /// 參賽行業領域
        /// </summary>
        [Description("參賽行業領域")]
        public string v5 { get; set; }
        /// <summary>
        /// 行政區域
        /// </summary>
        [Description("行政區域")]
        public string v6 { get; set; }
        /// <summary>
        /// 是否屬于國家高新區內的企業
        /// </summary>
        [Description("屬于國家高新區內的企業")]
        public string v7 { get; set; }
        /// <summary>
        /// 是否屬于國家級經濟開發區內的企業
        /// </summary>
        [Description("屬于國家級經濟開發區內的企業")]
        public string v9 { get; set; }
        /// <summary>
        /// 是否屬于國家級科技企業范訓器內的企業
        /// </summary>
        [Description("屬于國家級科技企業范訓器內的企業")]
        public string v11 { get; set; }
        /// <summary>
        /// 是否屬于國家大學科技園內的企業
        /// </summary>
        [Description("屬于國家大學")]
        public string v13 { get; set; }
        /// <summary>
        /// 是否國家備案的眾創空間內的企業
        /// </summary>
        [Description("國家備案的眾創空間內的企業")]
        public string v20 { get; set; }
        /// <summary>
        /// 企業注冊型別
        /// </summary>
        [Description("企業注冊型別")]
        public string v22 { get; set; }
        /// <summary>
        /// 注冊資本
        /// </summary>
        [Description("注冊資本")]
        public string v24 { get; set; }
        /// <summary>
        /// 實收資本(萬元人民幣)
        /// </summary>
        [Description("實收資本")]
        public string v25 { get; set; }
        /// <summary>
        /// 企業注冊地址
        /// </summary>
         [Description("企業注冊地址")]
        public string v26 { get; set; }
        /// <summary>
        /// 郵政編碼
        /// </summary>
        [Description("注冊地郵政編碼")]
        public string v27 { get; set; }
        /// <summary>
        /// 通信地址
        /// </summary>
          [Description("通信地址")]
        public string v28 { get; set; }
        /// <summary>
        /// 郵政編碼
        /// </summary>
         [Description("通訊地郵政編碼")]
        public string v29 { get; set; }
        /// <summary>
        /// 企業網址
        /// </summary>
        [Description("企業網址")]
        public string v30 { get; set; }
        /// <summary>
        /// 企業官方微信
        /// </summary>
        [Description("企業官方微信")]
        public string v31 { get; set; }
        /// <summary>
        /// 職工總數
        /// </summary>
         [Description("職工總數")]
        public string v32 { get; set; }
        /// <summary>
        /// 博   士人數
        /// </summary>
        [Description("博   士")]
        public string v33 { get; set; }
        /// <summary>
        /// 碩   士人數
        /// </summary>
        [Description("碩   士")]
        public string v34 { get; set; }
        /// <summary>
        /// 本   科人數
        /// </summary>
        [Description("本   科")]
        public string v35 { get; set; }
        /// <summary>
        /// 大專及以下人數
        /// </summary>
        [Description("大專及以下")]
        public string v36 { get; set; }
        /// <summary>
        /// 高級職稱人數
        /// </summary>
        [Description("高級職稱")]
        public string v37 { get; set; }
        /// <summary>
        /// 中級職稱人數
        /// </summary>
        [Description("中級職稱")]
        public string v38 { get; set; }
        /// <summary>
        /// 初級職稱人數
        /// </summary>
        [Description("初級職稱")]
        public string v39 { get; set; }
        /// <summary>
        /// 高級技工人數
        /// </summary>
        [Description("高級技工")]
        public string v40 { get; set; }
        /// <summary>
        /// 上市公司控股企業是否
        /// </summary>
        [Description("上市公司控股企業")]
        public string v41 { get; set; }
        /// <summary>
        /// 新三板企業是否
        /// </summary>
        [Description("新三板企業")]
        public string v42 { get; set; }
        /// <summary>
        /// 高新技術企業是否
        /// </summary>
        [Description("高新技術企業")]
        public string v43 { get; set; }
        /// <summary>
        /// 獲得時間
        /// </summary>
        [Description("獲得時間")]
        public string v44 { get; set; }
        /// <summary>
        /// 登記入庫的科技型中小企業是否
        /// </summary>
        [Description("登記入庫的科技型中小企業")]
        public string v45 { get; set; }
        /// <summary>
        /// 企業概要(不超1000字)
        /// </summary>
        [Description("企業概要")]
        public string v46 { get; set; }
        /// <summary>
        /// 關 鍵 詞
        /// </summary>
        [Description("關 鍵 詞")]
        public string v47 { get; set; }
        /// <summary>
        /// 現融資階段
        /// </summary>
        [Description("現融資階段")]
        public string v48 { get; set; }
        /// <summary>
        /// 參賽專案產品圖片
        /// </summary>
        public string v49 { get; set; }
        /// <summary>
        /// 參賽專案收入占去年企業營業收入比例
        /// </summary>
        [Description("參賽專案收入占去年企業營業收入比例")]
        public string v50 { get; set; }
        /// <summary>
        /// 參賽專案介紹(1000字以內)
        /// </summary>
        [Description("參賽專案介紹(1000字以內)")]
        public string v51 { get; set; }
        /// <summary>
        /// 當前五大客戶
        /// </summary>
        [Description("當前五大客戶")]
        public string v52 { get; set; }
        /// <summary>
        /// 當前五大供應商
        /// </summary>
        [Description("當前五大供應商")]
        public string v53 { get; set; }
        /// <summary>
        /// 國內市場地位排名
        /// </summary>
        [Description("國內市場地位排名")]
        public string v54 { get; set; }
        /// <summary>
        /// 商業模式及業務拓展計劃
        /// </summary>
        [Description("商業模式及業務拓展計劃")]
        public string v56 { get; set; }
        /// <summary>
        /// 經營風險與對策
        /// </summary>
        [Description("經營風險與對策")]
        public string v57 { get; set; }
        /// <summary>
        /// 企業管理模式
        /// </summary>
        [Description("企業管理模式")]
        public string v58 { get; set; }
        /// <summary>
        /// 公司對管理層及關鍵人員是否已采取激勵措施是否
        /// </summary>
        [Description("公司對管理層及關鍵人員是否已采取激勵措施")]
        public string v59 { get; set; }
        /// <summary>
        /// 公司是否考慮員工持股問題?是否
        /// </summary>
        [Description("公司是否考慮員工持股問題")]
        public string v60 { get; set; }
        /// <summary>
        /// 企業其他技術、產品及服務(1000字以內)
        /// </summary>
        [Description("企業其他技術、產品及服務(1000字以內)")]
        public string v61 { get; set; }
        /// <summary>
        /// 參賽目的
        /// </summary>
        [Description("參賽目的")]
        public string v62 { get; set; }
        /// <summary>
        /// 并購需求
        /// </summary>
        [Description("并購需求")]
        public string v63 { get; set; }
        /// <summary>
        /// 申請大賽組織的大企業對接活動是否
        /// </summary>
        [Description("申請大賽組織的大企業對接活動")]
        public string v64 { get; set; }
        /// <summary>
        /// 資金使用計劃
        /// </summary>
        [Description("債權融資資金使用計劃")]
        public string v65 { get; set; }
        /// <summary>
        /// 股權融資需求是否  
        /// </summary>
        [Description("直接從事研發科技人員數")]
        public string v66 { get; set; }
        /// <summary>
        /// 融資金額(萬元¥)
        /// </summary>
        [Description("上年度吸納高校應屆畢業生人數")]
        public string v67 { get; set; }
        /// <summary>
        /// 擬出讓股權比例
        /// </summary>
        [Description("參賽專案名稱")]
        public string v68 { get; set; }
        /// <summary>
        /// 融資時間
        /// </summary>
        [Description("產品市場分析及競爭優勢")]
        public string v69 { get; set; }
        /// <summary>
        /// 資金使用計劃
        /// </summary>
        [Description("股權融資資金使用計劃")]
        public string v70 { get; set; }
        /// <summary>
        /// 申請大賽推薦投資機構是否  (修改 申請大賽推薦信貸機構)
        /// </summary>
        [Description("申請大賽推薦信貸機構")]
        public string v71 { get; set; }
        /// <summary>
        /// 申請大賽組織的融資路演是否 (修改 申請大賽推薦投資機構)
        /// </summary>
        [Description("申請大賽推薦投資機構")]
        public string v72 { get; set; }
        /// <summary>
        /// 申請國家科技成果轉化引導基金設立的子基金推薦 (修改 申請大賽組織的融資路演)
        /// </summary>
        [Description("申請大賽組織的融資路演")]
        public string v73 { get; set; }
        #endregion

        public List<string> GetThisDescriptionName()
        {
            var result = new List<string>();
            GetType().GetProperties().ToList().ForEach(f =>
           {
               var descriptionObj = (DescriptionAttribute[])f.GetCustomAttributes(typeof(DescriptionAttribute), false);
               if (descriptionObj.Length > 0 && !string.IsNullOrWhiteSpace(descriptionObj[0].Description))
               {
                   result.Add(descriptionObj[0].Description);
               }
           });
            return result;
        }
    }
View Code

其中重要的地方是:需要給每個欄位一個Description,這里面的值對應的就是word模板中的名稱,如下:

 

 

 這里因為資料是保密的,我就將一些欄位洗掉了,包括word模板中的一些也洗掉了,就拿出一部分,

和資料庫互動的部分我也沒寫,就將查出來的資料先命名一個_enterpriseStr,最后用Newtonsoft轉換成物體這樣操作了哈:

 EnterpriseEntity enterprise = JsonConvert.DeserializeObject<EnterpriseEntity>(_enterpriseStr); 

 

 

  5、將查出來的資料,插入到word中,完成最終的匯出:

1 ExportFileOperator.InsertFormData(enterprise, ref doc.Item1);//物體資料插入
2 return new ExportFileOperator().FileResult(title, doc.Item1);

其中最重要的方法就是InsertFormData這個,他的實作如下:

 1 public static void InsertFormData<T>(T objFormData, ref Document document)
 2 {
 3             NodeCollection allTables = document.GetChildNodes(NodeType.Table, true);
 4             List<string> headDescribeNameList = GetObjectHeadDescription<T>();//獲取物體中每個Description中的值
 5             foreach (Table tableFirst in allTables)
 6             {
 7                 for (int headIndex = 0; headIndex < headDescribeNameList.Count; headIndex++)//回圈物體中的每個DescribeName
 8                 {
 9                     for (int rowIndex = 0; rowIndex < tableFirst.Rows.Count; rowIndex++)//遍歷word模板中所有的table
10                     {
11                         for (int cellIndex = 0; cellIndex < tableFirst.Rows[rowIndex].Cells.Count; cellIndex++)//遍歷模板中所有的table每行的列數
12                         {
13                             if (tableFirst.Rows[rowIndex].Cells[cellIndex].GetText() != null && tableFirst.Rows[rowIndex].Cells[cellIndex].GetText().Contains(headDescribeNameList[headIndex]) &&
14                                   ((tableFirst.Rows[rowIndex].Cells.Count > cellIndex && tableFirst.Rows[rowIndex].Cells[cellIndex + 1] != null && tableFirst.Rows[rowIndex].Cells[cellIndex + 1].GetText().Equals("\a")) || (tableFirst.Rows.Count > rowIndex && tableFirst.Rows[rowIndex + 1] != null && tableFirst.Rows[rowIndex + 1].Cells[cellIndex] != null && tableFirst.Rows[rowIndex + 1].Cells[cellIndex].GetText().Equals("\a"))))//如果遍歷的cell不為空、其中的值能和DescribeName匹配上,并且這個單元的右邊的cell或者下邊cell有占位,而且是空,就在此處插入值
15                             {
16                                 var objValue = https://www.cnblogs.com/19930521zhang/archive/2021/02/10/GetObjectValueByPropName(objFormData, headDescribeNameList[headIndex]);//根據DescribeName獲取對應的值
17                                 if (tableFirst.Rows[rowIndex].Cells.Count > cellIndex && tableFirst.Rows[rowIndex].Cells[cellIndex + 1] != null && tableFirst.Rows[rowIndex].Cells[cellIndex + 1].GetText().Equals("\a"))
18                                 {
19                                     InsertCell(objValue, document, tableFirst.Rows[rowIndex].Cells[cellIndex + 1]);//優先在右變空位插入值
20                                     break;
21                                 }
22                                 InsertCell(objValue, document, tableFirst.Rows[rowIndex + 1].Cells[cellIndex]);//右側如果沒有就在下邊空位插入值
23                                 break;
24                             }
25                         }
26                     }
27                 }
28             }
29  }
1 public static List<string> GetObjectHeadDescription<T>()
2 {
3    var obj = Activator.CreateInstance<T>();
4    MethodInfo method = obj.GetType().GetMethod("GetThisDescriptionName", new Type[] { });//每個物體需要有GetThisDescriptionName這個方法
5    return (List<string>)(method?.Invoke(obj, null));
6  }

其中GetThisDescriptionName方法需求在每個物體類中有實作:

 

 

 根據descriptionName獲取物體中的值:

 1 private static string GetObjectValueByPropName<T>(T objFormData, string descriptionName)
 2 {
 3             try
 4             {
 5                 var properties = objFormData.GetType().GetProperties();
 6                 foreach (var propertyInfo in properties)
 7                 {
 8                     var descriptionAttributes = (DescriptionAttribute[])propertyInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);
 9                     if (descriptionAttributes.Length > 0 && !string.IsNullOrWhiteSpace(descriptionAttributes[0].Description) && descriptionAttributes[0].Description.Equals(descriptionName))
10                     {
11                         return propertyInfo.GetValue(objFormData) == null ? "" : propertyInfo.GetValue(objFormData).ToString();
12                     }
13                 }
14                 return "";
15             }
16             catch (Exception e)
17             {
18                 Console.WriteLine(e);
19                 throw;
20             }
21 }

cell中插入值:

 1  private static void InsertCell(string value, Document doc, Cell cell)
 2  {
 3             Cell insertCell = cell;
 4             insertCell.FirstParagraph.Remove();
 5             Paragraph p = new Paragraph(doc);
 6             p.AppendChild(new Run(doc, (value =https://www.cnblogs.com/19930521zhang/archive/2021/02/10/= null ? "" : value)));
 7             p.ParagraphFormat.Alignment = ParagraphAlignment.Center;
 8             insertCell.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
 9             insertCell.AppendChild(p);
10  }

最后一個方法FileResult

1 public FileResult FileResult(string fileName, Document doc)
2 {
3             var filePathName = $"{fileName}.doc";
4             doc.Save(Path.Combine(_tempPath, "temp", filePathName), SaveFormat.Doc); //保存word
5             filePathName = Path.Combine(_tempPath, "temp", filePathName);
6             return File(filePathName, "application/doc", $"{fileName}.Doc");
7 }

最終效果:

 

 

 

 

 

 最后說一下,其中有一些細節的地方還是需要做一些處理,暫時沒時間寫,后期有時間補,先就這樣了

大家有什么好的想法或者更好的實作方式,盡管提出來,共同進步

git地址:https://github.com/Binzm/ExportWorkdModel.git

轉載請註明出處,本文鏈接:https://www.uj5u.com/net/258595.html

標籤:.NET技术

上一篇:Dotnet中Span, Memory和ReadOnlySequence之淺見

下一篇:c#記兩個變數進行值交換

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • WebAPI簡介

    Web體系結構: 有三個核心:資源(resource),URL(統一資源識別符號)和表示 他們的關系是這樣的:一個資源由一個URL進行標識,HTTP客戶端使用URL定位資源,表示是從資源回傳資料,媒體型別是資源回傳的資料格式。 接下來我們說下HTTP. HTTP協議的系統是一種無狀態的方式,使用請求/ ......

    uj5u.com 2020-09-09 22:07:47 more
  • asp.net core 3.1 入口:Program.cs中的Main函式

    本文分析Program.cs 中Main()函式中代碼的運行順序分析asp.net core程式的啟動,重點不是剖析原始碼,而是理清程式開始時執行的順序。到呼叫了哪些實體,哪些法方。asp.net core 3.1 的程式入口在專案Program.cs檔案里,如下。ususing System; us ......

    uj5u.com 2020-09-09 22:07:49 more
  • asp.net網站作為websocket服務端的應用該如何寫

    最近被websocket的一個問題困擾了很久,有一個需求是在web網站中搭建websocket服務。客戶端通過網頁與服務器建立連接,然后服務器根據ip給客戶端網頁發送資訊。 其實,這個需求并不難,只是剛開始對websocket的內容不太了解。上網搜索了一下,有通過asp.net core 實作的、有 ......

    uj5u.com 2020-09-09 22:08:02 more
  • ASP.NET 開源匯入匯出庫Magicodes.IE Docker中使用

    Magicodes.IE在Docker中使用 更新歷史 2019.02.13 【Nuget】版本更新到2.0.2 【匯入】修復單列匯入的Bug,單元測驗“OneColumnImporter_Test”。問題見(https://github.com/dotnetcore/Magicodes.IE/is ......

    uj5u.com 2020-09-09 22:08:05 more
  • 在webform中使用ajax

    如果你用過Asp.net webform, 說明你也算是.NET 開發的老兵了。WEBform應該是2011 2013左右,當時還用visual studio 2005、 visual studio 2008。后來基本都用的是MVC。 如果是新開發的專案,估計沒人會用webform技術。但是有些舊版 ......

    uj5u.com 2020-09-09 22:08:50 more
  • iis添加asp.net網站,訪問提示:由于擴展配置問題而無法提供您請求的

    今天在iis服務器配置asp.net網站,遇到一個問題,記錄一下: 問題:由于擴展配置問題而無法提供您請求的頁面。如果該頁面是腳本,請添加處理程式。如果應下載檔案,請添加 MIME 映射。 WindowServer2012服務器,添加角色安裝完.netframework和iis之后,運行aspx頁面 ......

    uj5u.com 2020-09-09 22:10:00 more
  • WebAPI-處理架構

    帶著問題去思考,大家好! 問題1:HTTP請求和回傳相應的HTTP回應資訊之間發生了什么? 1:首先是最底層,托管層,位于WebAPI和底層HTTP堆疊之間 2:其次是 訊息處理程式管道層,這里比如日志和快取。OWIN的參考是將訊息處理程式管道的一些功能下移到堆疊下端的OWIN中間件了。 3:控制器處理 ......

    uj5u.com 2020-09-09 22:11:13 more
  • 微信門戶開發框架-使用指導說明書

    微信門戶應用管理系統,采用基于 MVC + Bootstrap + Ajax + Enterprise Library的技術路線,界面層采用Boostrap + Metronic組合的前端框架,資料訪問層支持Oracle、SQLServer、MySQL、PostgreSQL等資料庫。框架以MVC5,... ......

    uj5u.com 2020-09-09 22:15:18 more
  • WebAPI-HTTP編程模型

    帶著問題去思考,大家好!它是什么?它包含什么?它能干什么? 訊息 HTTP編程模型的核心就是訊息抽象,表示為:HttPRequestMessage,HttpResponseMessage.用于客戶端和服務端之間交換請求和回應訊息。 HttpMethod類包含了一組靜態屬性: private stat ......

    uj5u.com 2020-09-09 22:15:23 more
  • 部署WebApi隨筆

    一、跨域 NuGet參考Microsoft.AspNet.WebApi.Cors WebApiConfig.cs中配置: // Web API 配置和服務 config.EnableCors(new EnableCorsAttribute("*", "*", "*")); 二、清除默認回傳XML格式 ......

    uj5u.com 2020-09-09 22:15:48 more
最新发布
  • C#多執行緒學習(二) 如何操縱一個執行緒

    <a href="https://www.cnblogs.com/x-zhi/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/2943582/20220801082530.png" alt="" /></...

    uj5u.com 2023-04-19 09:17:20 more
  • C#多執行緒學習(二) 如何操縱一個執行緒

    C#多執行緒學習(二) 如何操縱一個執行緒 執行緒學習第一篇:C#多執行緒學習(一) 多執行緒的相關概念 下面我們就動手來創建一個執行緒,使用Thread類創建執行緒時,只需提供執行緒入口即可。(執行緒入口使程式知道該讓這個執行緒干什么事) 在C#中,執行緒入口是通過ThreadStart代理(delegate)來提供的 ......

    uj5u.com 2023-04-19 09:16:49 more
  • 記一次 .NET某醫療器械清洗系統 卡死分析

    <a href="https://www.cnblogs.com/huangxincheng/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/214741/20200614104537.png" alt="" /&g...

    uj5u.com 2023-04-18 08:39:04 more
  • 記一次 .NET某醫療器械清洗系統 卡死分析

    一:背景 1. 講故事 前段時間協助訓練營里的一位朋友分析了一個程式卡死的問題,回過頭來看這個案例比較經典,這篇稍微整理一下供后來者少踩坑吧。 二:WinDbg 分析 1. 為什么會卡死 因為是表單程式,理所當然就是看主執行緒此時正在做什么? 可以用 ~0s ; k 看一下便知。 0:000> k # ......

    uj5u.com 2023-04-18 08:33:10 more
  • SignalR, No Connection with that ID,IIS

    <a href="https://www.cnblogs.com/smartstar/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/u36196.jpg" alt="" /></a>...

    uj5u.com 2023-03-30 17:21:52 more
  • 一次對pool的誤用導致的.net頻繁gc的診斷分析

    <a href="https://www.cnblogs.com/dotnet-diagnostic/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/3115652/20230225090434.png" alt=""...

    uj5u.com 2023-03-28 10:15:33 more
  • 一次對pool的誤用導致的.net頻繁gc的診斷分析

    <a href="https://www.cnblogs.com/dotnet-diagnostic/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/3115652/20230225090434.png" alt=""...

    uj5u.com 2023-03-28 10:13:31 more
  • C#遍歷指定檔案夾中所有檔案的3種方法

    <a href="https://www.cnblogs.com/xbhp/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/957602/20230310105611.png" alt="" /></a&...

    uj5u.com 2023-03-27 14:46:55 more
  • C#/VB.NET:如何將PDF轉為PDF/A

    <a href="https://www.cnblogs.com/Carina-baby/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/2859233/20220427162558.png" alt="" />...

    uj5u.com 2023-03-27 14:46:35 more
  • 武裝你的WEBAPI-OData聚合查詢

    <a href="https://www.cnblogs.com/podolski/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/616093/20140323000327.png" alt="" /><...

    uj5u.com 2023-03-27 14:46:16 more