> For the complete documentation index, see [llms.txt](https://brianwu.gitbook.io/brian/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://brianwu.gitbook.io/brian/brians-za-ji/za-ji.md).

# 雜記

建立一個元素庫，想要元素的傢伙都去裡面拿。

將資料都增加在傢伙裡面，之後想要用傢伙的系統，就去選取想要用的傢伙，並且一併獲得傢伙內的各個元素。

## 分散流量

多個前台去平均分散。

原先應該動態撈取資料庫的資料，形成網頁。為了降低流量，每當資料更新後，形成靜態頁面檔案，需要的直接去撈該檔案。並定期、排程 或手動去刷新該靜態頁面。

## 運算子

?? 運算子

value ?? 0

如果value為null，則回傳0

## 將debug文字print到txt裡

記得設定要修改的檔案路徑、名稱

```
using (StreamWriter outputFile = new StreamWriter(@"D:\\dirName\\fileName.txt", true))
        {
            outputFile.WriteLine("debug");
        }
```

```
using (StreamWriter sw = new StreamWriter("ImportNews_en.txt", true))
                        {
                            sw.WriteLine($"新增，SN={smnd.SN},標題={smnd.Column_2},SiteSN={SiteSN}, CatagoryID={CatagoryID}");
                            sw.Close();
                        }
```

## Debug執行localhost瘋狂轉圈

有可能是瀏覽器卡住，換個瀏覽器試試 \~

## 存取修飾詞

參考資料:(<https://docs.microsoft.com/zh-tw/dotnet/csharp/programming-guide/classes-and-structs/access-modifiers>)

public 類型或成員可由相同組件或參考該組件的另一個組件中的任何其他程式碼存取。

private 類型或成員只能由相同類別或結構中的程式碼進行存取。

protected 類型或成員只可由相同類別或衍生(繼承)自該類別之類別中的程式碼進行存取。 internal 類型或成員可由相同組件(namespace)中的任何程式碼存取，但是不包括其他組件中的程式碼。

protected internal 類型或成員可由宣告程式碼的組件內之任一程式碼存取，或是從另一個組件中的衍生類別內存取。(兩種都可存取)

private protected 類型或成員只可從其宣告組件內存取，或是從衍生自該類別之相同類別或類型的程式碼存取。

## Exception

參考資料:(<https://docs.microsoft.com/zh-tw/dotnet/csharp/programming-guide/exceptions/creating-and-throwing-exceptions>)

```
throw new System.Exception("ErrorMessage");
```

## try .. catch ..

catch 後的問題，要記錄下來 看是用NLOG、資料庫，去把問題、經過記下來
