工程驗收管理電腦化作業...

157
一般 台灣電力股份有限公司 101 年度 研究計畫 546-2107-9906 工程驗收管理電腦化作業 期末報告 台灣電力股份有限公司 中華民國 101 1

Upload: others

Post on 27-Sep-2019

10 views

Category:

Documents


0 download

TRANSCRIPT

一般

台灣電力股份有限公司101年度

研究計畫 546-2107-9906

工程驗收管理電腦化作業

期末報告

台灣電力股份有限公司

中華民國 101年 1月

※ ※ ※ ※ ※ ※ ※ ※ ※ ※ ※ ※ ※ ※ ※ ※

本報告書僅供

政府機關參考

請勿轉載

※ ※

※ ※ ※ ※ ※ ※ ※ ※ ※ ※ ※ ※ ※ ※ ※ ※

工程驗收管理電腦化作業

期末報告

研 究 方 式 :委託研究

執 行 期 間 :99年 8月 1日至 101年 1月 31日

計畫主持人:陳俊良

研 究 人 員 :劉志放、楊金石、王金財、陳啟仲、吳旭

耕、陳劭宗、王名威、馬奕葳、卓威廷、吳

永仁

執 行 單 位 :國立臺灣科技大學

委 託 單 位 :台灣電力股份有限公司

I

一、 摘要

綜觀全球發展之趨勢,各國紛紛揭櫫科技創新能力為國家競爭力之根本,

而資通軟體和網際服務已成為實現科技創新價值的主要平台。為達到企業資源

的有效管理,企業內部運作流程作業自動化及網路化儼然已成為一種趨勢,透

過企業內部之區域網路,即能連結各個部門取得所需資源,以節省人力進而提

高工作效率。可運用在工程驗收作業文書處理、會計帳務及資料存檔管理

(Engineering Management Information Systems,EMIS)等,提升專案運作之效率。

台灣電力股份有限公司工程驗收管理方式,目前尚採用紙本陳核作業,各

工程採購經辦單位以紙本填報工程竣工「工程驗收通知單」之方式,洽請「營

建處檢驗組」核定指派工程驗收之主驗及相關驗收人員。而上述「工程驗收通

知單」之「驗收日期」,需預先經由電話與該組洽妥並排定前往驗收日期,然

而此作業過程未盡資訊公開透明化。

台灣電力股份有限公司啟用「工程驗收管理資訊系統」,各單位透過此系

統,可使工程驗收管理電腦化,由統一窗口彙總辦理各工程驗收作業制度,工

程驗收作業資訊系統以透明化的方式呈現,確保資料安全性,進而提升驗收作

業之時效性,並符合 ISO 作業規定,簡化原有工程驗收作業紙本陳核流程。透

過「網際應用系統」線上即時作業方式處理,以利統一工程驗收資訊傳達(輸)

及資料儲存。藉由本案所建置的工程驗收電腦化系統,可大幅度節省人力上之

成本,提升驗收作業之效率,且透過電腦化之機制,更可省下不少紙張之耗費,

以達到節能減碳之功效。

關鍵字:工程驗收管理資訊系統、電腦化、統一窗口、ISO、節能減碳

II

二、 Abstract

Countries worldwide strengthen national competitiveness by closely following global

trends in technological innovation and their practical implications. Software and

Internet services have become conventional tools for realizing technological

innovations. Enterprises can avoid waste and save considerable time and effort by

using automation, networking and computerization to carry out administrative,

accounting and engineering management information systems (EMIS) processes. This

type of implementation allows an enterprise to link all departments in order to

conserve human resources and increase work productivity.

EMIS are often still operated manually. For example, the procurement department

relies on paper forms filled in by engineering when receiving letter requests. Or, the

construction department uses paper forms to assign daily staff tasks, and to process

project approvals. Or, departmental staff receives project approvals and daily

assignments by telephone. However, communicating with staff for daily

administrative tasks in these ways is private, not in public and transparency.

This project focuses on establishing an EMIS at TaiPower, with each departmental

unit linked to this system via a unified platform that facilitates project-management

tasks. Given its transparency, the proposed EMIS will be a viable replacement for the

current manual system. It will reduce the complexity of operational processes, and

will ensure data security, thus streamlining inspection procedures and enabling

compliance with ISO operational standards. The Internet applications system will log

processes online in real-time to integrate information communications with

management project approvals. This computerized system will utilize human

resources more efficiently, eliminate paper waste, conserve energy, and reduce carbon

emissions.

Keywords: EMIS, Facilitates, Unified Platform, ISO, Reducing Carbon, Emissions

1

目次

一、 摘要 ............................................................................................................................... I

二、 Abstract ....................................................................................................................... II

三、 緒論 .............................................................................................................................. 1

1. 研究背景 ......................................................................................................... 1

2. 研究目的 ......................................................................................................... 1

3. 研究內容與方法 ............................................................................................. 1

4. 系統功能 ......................................................................................................... 2

四、 系統定義 ...................................................................................................................... 5

1. 開發新系統的必要性分析 ............................................................................. 5

2. 新系統的效益分析 ......................................................................................... 5

3. 操作系統的可行性分析 ................................................................................. 6

4. 技術可行性分析 ............................................................................................. 7

5. 時程可行性分析 ............................................................................................. 8

五、 軟體需求規格(Software Requirement Specification) .............................................. 9

1. 前言 ................................................................................................................. 9

2. 文件目的與系統描述 ..................................................................................... 9

3. 分項功能需求分析 ....................................................................................... 14

六、 軟體設計規格 ............................................................................................................ 22

1. 系統描述 ....................................................................................................... 22

2. 系統設計規格 ............................................................................................... 22

3. 操作介面規格設計 ....................................................................................... 26

4. 資料庫設計規格 ........................................................................................... 37

5. 使用者權責劃分 ........................................................................................... 41

七、 結論 ............................................................................................................................ 45

八、 參考文獻 .................................................................................................................... 46

2

九、 附錄(Source Code) .................................................................................................... 47

1. Default.aspx ..................................................................................................................... 47

2. About.aspx ....................................................................................................................... 48

3. MyWork.aspx .................................................................................................................. 49

4. PAFormQuery.aspx ......................................................................................................... 51

5. ProfileSetting.aspx .......................................................................................................... 57

6. ProxyGroupForm.aspx .................................................................................................... 60

7. ProxySettingForm.aspx ................................................................................................... 62

8. ProxyWorkChoose.aspx .................................................................................................. 64

9. QueryForm.aspx .............................................................................................................. 66

10. Web.config .................................................................................................................... 67

11. ChangePassword.aspx ................................................................................................... 71

12. ChangePasswordSuccess.aspx ....................................................................................... 74

13. Login.aspx ..................................................................................................................... 75

14. Register.aspx ................................................................................................................. 77

15. PAPIFileDownload.ashx ............................................................................................... 80

16. AssignmentDateTime.vb ............................................................................................... 82

17. CalDate.vb ..................................................................................................................... 84

18. DataSourceProvider.vb .................................................................................................. 86

19. Entity.vb ........................................................................................................................ 88

20. ErrorIdentity.vb ............................................................................................................. 91

21. GenericEnumTable.vb ................................................................................................... 93

22. GlobalResourceHelper.vb ............................................................................................. 99

23. RoleIdentity.vb ............................................................................................................ 102

24. SectionClassIdentity.vb ............................................................................................... 104

25. SessionManager.vb ...................................................................................................... 107

26. UserRoleClassRelation.vb ........................................................................................... 110

3

27. UserRoleEntity.vb ....................................................................................................... 115

28. ViewStateBundle.vb .................................................................................................... 118

29. MyWorkPage.vb .......................................................................................................... 120

30. PAAssignment.vb ........................................................................................................ 122

31. PACertification.vb ....................................................................................................... 125

32. PAIRFileDownloadLinkInjector.vb ............................................................................ 128

33. ProjectAcceptance.vb .................................................................................................. 130

34. RoleActions.vb ............................................................................................................ 131

35. WorkPageRouter.vb .................................................................................................... 135

36. AssigmtedProjectInfoDM.vb ....................................................................................... 136

37. PAInspectorSimpleRelDM.vb ..................................................................................... 140

38. PAIRTaskStateDM.vb ................................................................................................. 141

39. PAPreparedItem.vb ..................................................................................................... 143

40. PASuperintendentInspectorRelDM.vb ........................................................................ 146

1

表目錄

表一、計畫時程規劃表................................................................................................ 8

表二、定義與縮寫符號................................................................................................ 9

表三、軟體需求規格表.............................................................................................. 20

1

圖目錄

圖一、工程驗收工作流程與其角色.......................................................................... 13

圖二、系統環境架構圖.............................................................................................. 23

圖三、系統功能流程圖.............................................................................................. 25

圖四、網頁架構圖...................................................................................................... 27

圖五、系統主畫面...................................................................................................... 27

圖六、登入畫面.......................................................................................................... 28

圖七、工程主辦單位登入後畫面.............................................................................. 28

圖八、工程主辦單位新增工程驗收通知單.............................................................. 29

圖九、工程主辦單位驗收文件上傳.......................................................................... 30

圖十、驗收文件上未上傳前無法完成遞交.............................................................. 31

圖十一、主管登入畫面.............................................................................................. 31

圖十二、主管指派驗收人員工作天.......................................................................... 32

圖十三、主管指派主驗員外派驗收時間.................................................................. 33

圖十四、主管指派驗收員與時間.............................................................................. 34

圖十五、組長審定工程.............................................................................................. 35

圖十六、組長查閱各主管審查回覆情形.................................................................. 36

圖十七、系統使用者資料庫關聯圖.......................................................................... 37

圖十八、AssigmtMessage資料表 ............................................................................. 38

圖十九、InspectorAssigmtTime資料表 .................................................................... 38

圖二十、PAAssigmtMem資料表 .............................................................................. 38

圖二十一、PAAssigmtMessage資料表 .................................................................... 39

圖二十二、PAAssigmtTime資料表 .......................................................................... 39

圖二十三、PALeaderRel資料表 ............................................................................... 39

圖二十四、PAPreparedData資料表 .......................................................................... 39

圖二十五、PASuperintendentRel資料表 .................................................................. 40

圖二十六、ProjectAcceptanceState資料表............................................................... 40

圖二十七、SectionClass資料表 ................................................................................ 40

圖二十八、UserInfos資料表 ..................................................................................... 40

圖二十九、承辦單位權責劃分.................................................................................. 41

圖三十、主管權責劃分.............................................................................................. 41

圖三十一、組長權責劃分.......................................................................................... 42

圖三十二、副處長權責劃分...................................................................................... 42

圖三十三、處長權責劃分.......................................................................................... 42

圖三十四、主驗員權責劃分...................................................................................... 43

圖三十五、系統管理員權責劃分.............................................................................. 43

圖三十六、非特定角色權責劃分.............................................................................. 44

2

圖三十七、驗收查詢權責.......................................................................................... 44

1

三、 緒論

1. 研究背景

台灣電力股份有限公司工程驗收管理方式,目前尚採用紙本陳核作業,各工

程採購經辦單位透過紙本填報工程竣工「工程驗收通知單」之方式,洽請「營建

處檢驗組」核定指派工程驗收之主驗人員。而上述「工程驗收通知單」之「驗收

日期」,需預先經由電話與該組洽妥並排定前往驗收日期,此作業過程未盡資訊

公開透明化與流程自動化。

本案基於上述原因,希望藉由改善現行工程驗收紙本開單及陳核派驗人員作

業,透過導入資訊與電腦化,提供統一窗口彙總辦理各工程驗收作業,提升工程

驗收作業資訊透明化及確保驗收紀錄資料儲存安全性,達到最佳工程驗收資訊傳

達作業時效性。因此本計畫案針對台灣電力股份有限公司,進行「工程驗收管理

資訊系統」研發,各單位透過「工程驗收管理資訊系統」可使工程驗收管理電腦

化,由統一窗口彙總辦理各工程驗收作業制度,工程驗收作業資訊系統以透明化

的方式呈現,確保資料安全性,進而提升驗收作業之時效性,簡化原有工程驗收

作業紙本陳核流程。並透過「網際應用系統」線上即時作業方式處理,以利統一

工程驗收資訊傳達(輸)及資料儲存。藉由本案所建置的工程驗收電腦化系統,可

大幅度節省人力上之成本,提升驗收作業之效率。

2. 研究目的

(1) 改善現行工程驗收紙本開單及陳核派驗人員作業,導入電腦化作業。

(2) 提供統一窗口彙總辦理各工程驗收作業制度。

(3) 工程驗收作業資訊透明化及確保驗收紀錄資料儲存安全性。

(4) 提升工程驗收作業時效性。

3. 研究內容與方法

本計畫依循台灣電力股份有限公司工程驗收作業相關程序,開發「工程驗收

管理資訊系統」。系統相關功能需求步驟如下所述:

(1) 第一步驟:開單作業

輸入作業

查詢作業

輸出工程驗收通知單

(2) 第二步驟:主驗人員指派作業

2

機器處理作業

指派及核定作業

驗收工作通知作業

派工後查詢作業

派工後列印作業

(3) 第三步驟:驗收結果作業

輸入作業

查詢作業

輸出表單

4. 系統功能

本計畫開發「工程驗收管理資訊系統」,主要功能如下所述:

(1) 基本功能作業

員工基本資料: 本功能係建立員工基本資料,供審校、查詢及登錄

之用。

單位基本資料:本功能係建立工程採購經辦單位基本資料,供審校、

查詢及選擇之用。

特例代碼資料: 本功能係建立工程驗收案件發現之特例資料,供查

詢及選擇之用。

(2) 開單功能作業

開單作業

I. 各單位經辦部門負責輸入「工程驗收通知單」填表內容。

II. 「工程驗收通知單」編輯及開單輸入陳核作業。

III. 「工程驗收通知單」等相關檔案,以 WORD、EXCEL 及 PDF

等檔案格式進行文件存檔,以利承辦開單單位將相關檔案資料,

以「附件」形式經由電子公文系統發文通知營建處檢驗組,辦理

工程驗收作業。

查詢作業

I. 各單位經辦部門負責查詢「工程驗收通知單」輸入內容。

II. 查詢「工程驗收通知單」開單輸入作業內容之正確性。

審校陳核「工程驗收通知單」作業

I. 各單位經辦部門負責審校陳核通過之「工程驗收通知單」資料。

II. 「工程驗收通知單」併竣工結算資料,會送「營建處 檢驗組」。

(3) 指派主驗人員作業

3

機器處理作業

I. 本功能係建立「工程驗收通知單」之歸類與整理資料,提供負責主

管進行派工及查詢用。

派工及核定作業

I. 建立「主驗人員工作分派表」。

II. 「主驗人員工作分派表」核定作業。

III. 產生「主驗人員工作動態表」資料。

主驗人員工作通知作業

I. 本功能係將己核定指派工作之「工程驗收通知單」,由系統自動

(含 E-mail)通知被指派主驗人員(會計及各經辦單位) 。

派工後查詢作業

I. 各單位工程驗收通知單案件之查詢與過程追蹤。

II. 各主驗人員案件之查詢與過程追蹤。

III. 各主驗人員工作動態之查詢。

(4) 派工後列印作業

本功能為列印各單位與各主驗人員或個人主辦案件之資料。

(5) 工程驗收結果作業

工程驗收結果輸入作業。

本功能為各單位工程驗收過程與結果資料之編輯與內容輸入。

(6) 工程驗收結果查詢作業

本功能為各派員 (會驗、協驗、監辦) 單位過程與結果資料之查

詢。

(7) 工程驗收結果列印作業

本功能為各派員 (會驗、協驗、監辦) 單位結果資料之輸出。

(8) 工程驗收通知單變更作業

本功能為單位要求工程驗收通知單內容更改,包含更改日期、案件

取消及延長監辦日期之處理。

本功能為工程驗收工作指派作業人員與工程驗收方式、工程驗收日

期異動之處理。

工程驗收結果資料內容之變更處理。

(9) 異常工程驗收案件作業

專案簽辦處理之工程驗收案件作業。

4

機器當機或其他系統故障案件後補作業之處理。

(10) 工程驗收通知單編號作業

各單位開單作業之編號功能。

本組編號處理作業(流水號)。

專案簽辦處理工作之編號作業。

異常案件人工編號方式。

(11) 例行報表列印作業

列印 「工程驗收通知單」。

列印 「工程驗收通知單」回聯。

列印「工程驗收通知單結果報告」。

列印「工程驗收工作發現異常情形報告表」。

列印「工程驗收紀錄(含澄清待辦事項、補修改善事項)等」。

列印「各單位採購案件工程驗收內容資料表」。

列印「各工程驗收案件資料統計表」。

(12) 系統管理者人員設定

使用者角色設定

使用者角色修改

檔案上傳

訊息發佈

(13) 其他作業

為確保保密與核定層級之有效控制之目的,建立作業授權資通安全

管控。

必要之審校功能。

稽催作業。

系統開發後之教育訓練及維護。

因應各單位不同資料需求,建立一份可由各單位或稽核部門自行擷

取所需之資料內容(如:表頭設計、期間、招標別,採購金額,採

購案號、工作項目等)之彈性需求報表。

其他依實務需要之功能需求。

依規範進行需求分析、系統分析及專案規劃,加以客製化的規劃設

計及調整建置系統,經由實際驗證來確保系統之可行性。

代理人設定(包含設定代理人及解除代理人)

5

四、 系統定義

1. 開發新系統的必要性分析

目前台灣電力股份有限公司工程驗收管理係採用人工紙本做為主要作業方

式,各工程採購經辦單位係以紙本填報工程竣工「工程驗收通知單」,洽請「營

建處檢驗組」核定指派工程驗收之主驗及相關驗收人員。而上述「工程驗收通知

單」之「驗收日期」,需預先經由電話與該組洽妥、排定前往驗收日期。為了作

業過程資訊公開透明化達到企業有效資源管理,企業流程作業自動化及網路化儼

然已是當前作業流程提升的必要項目,僅需透過企業內部之區域網路,就能連結

各個部門以節省人力進而提高工作效率。

本計畫針對上述問題提出幾點提升作業流程必要之目標:

(1) 改善現行人工工程驗收業務,並導入電腦化作業。

(2) 提供統一窗口彙總辦理各工程驗收作業制度。

(3) 工程驗收作業資訊透明化及確保資料安全性。

(4) 提升工程驗收作業時效性。

(5) 提升企業人力及資源管理效能。

2. 新系統的效益分析

針對工程驗收管理流程進行電腦化,不論在減少人事成本、降低開銷雜支、

提升作業時效性及明確性等都有顯著成果,本計畫所建立之「工程驗收管理資訊

系統」帶來的效益進行之分析如下:

(1) 電腦化

將工程驗收管理作業流程電腦化,達到企業有效資源管理及縮短組織之間的

溝通時效。透過電腦化之機制,能更有效利用人事資源,降低紙張及其他耗材等

開銷費用,並大幅提升驗收作業進行之效率。

(2) 統一窗口彙總

「工程驗收管理資訊系統」為各工程採購經辦單位及各參與驗收之作業人員

提供統一窗口進行工程驗收管理作業,可有效提升作業流程之明確性及效率。

6

(3) 透明化

工程驗收管理作業流程透明化,使各工程採購經辦單位及各參與驗收之作業

人員均了解驗收運作流程,明白各單位職責所在,於專案發展過程中產生問題時

能有效快速解決。

(4) 時效性

「工程驗收管理資訊系統」透過「網際應用系統」線上即時作業方式處理,

以便統一工程驗收資訊傳達(輸)及儲存,相較過去經由人工聯絡及紙本簽呈之方

式,將大幅提升驗收作業流程時效。

(5) ISO作業規定

工程驗收作業資訊系統以透明化的方式呈現,並確保資料安全性,進而提升

驗收作業之時效性,並符合 ISO作業規定。

(6) 節省人力

經由工程驗收管理作業流程電腦化,可提升企業有效資源利用,過去各工程

採購經辦單位採用人工方式以紙本填報工程竣工「工程驗收通知單」,然而工程

驗收及主驗人員指派方式,係需預先經由電話與該組洽妥、排定前往驗收日期,

過程需消耗大量人事成本,透過電腦化機制可大幅減少驗收流程的人力使用,進

而使企業達到更有效的人力資源運用。

(7) 降低成本

「工程驗收管理資訊系統」針對原驗收作業流程進行電腦化,透過驗收流程

電腦化可降低人事費用開銷,減少紙本及相關耗材之費用,並大幅提升驗收流程

之效率,針對驗收流程之時間成本有顯著改善。

3. 操作系統的可行性分析

系統的操作性對於各驗收人員來說極為重要,本計畫著重於作業人員操作的

適應性與習慣性、系統的穩定性與可擴充性進行整體評估,進而規劃「工程驗收

管理資訊系統」之系統操作遵循以下準則進行開發:

(1) 可維護性

7

「工程驗收管理資訊系統」之開發經由研發團隊審慎評估測試,系統穩定度

極高,日後系統若有運行問題也可快速排除解決。

(2) 方便性

透過企業內部之區域網路,即能連結各個部門取得所需資源,以節省人力進

而提高工作效率,操作人員僅需連上網路、登入帳號密碼,即可使用「工程驗收

管理資訊系統」進行驗收作業。

(3) 正確性

「工程驗收管理資訊系統」提供統一窗口彙總辦理各工程驗收作業制度,工

程驗收作業資訊系統以透明化的方式呈現,大幅提高系統資料之正確性。

(4) 安全性

「工程驗收管理資訊系統」提供帳號確認機制並要求定期更換帳密碼組,大

幅提升資料的安全性。

4. 技術可行性分析

本計畫針對「工程驗收管理資訊系統」開發過程中,可能遭遇之技術性問題

進而提出歸納並進行分析,分析結果及可能之解決方案如下:

(1) 系統與資料之整合

因工程驗收管理業務內容不盡相同,系統設計之初,無法完全媒合各單位之

業務需求,極可能發生內部資料與系統衝突之情勢 。

解決方案說明:統一各單位工程驗收管理之格式。

(2) 各功能模組整合

本系統採模組化研發模式,各模組可獨立完工負責之功能,模組化研發將有

利於日後維修及升級部分。唯系統整合時,模組間可能造成不相容之情形發生。

解決方案說明:模組研發時,須詳加考量各模組之屬性,系統整合

之初,需考量並模擬各種資料處理情境,避免模組衝突造成系統不

正常之運作。

8

5. 時程可行性分析

本研究計畫全程工作項目涵蓋有:平台分析與規劃、系統發展與程式撰寫(1)、

期中報告、系統發展與程式撰寫(2)、系統整合與測試分析、期末報告,其詳細

時程規劃如表一所示。

表一、計畫時程規劃表

工作項目

2010年 2011年 201

2年

平台分析與規劃 ▲ ▲ ▲

系統發展與程式撰

寫(1) ▲ ▲ ▲

期中報告 ▲ ▲ ▲

系統發展與程式撰

寫(2) ▲ ▲ ▲

系統整合與測試分

析 ▲ ▲ ▲ ▲

期末報告 ▲ ▲ ▲

9

五、 軟體需求規格(Software Requirement Specification)

1. 前言

本軟體需求規格書(Software Requirement Specification)主要目的為用來闡述

台灣電力股份有限公司「工程驗收管理資訊系統」之軟體架構、專案原始使用者

及規格需求,透過本軟體需求規格書,在工程驗收管理資訊系統軟體專案開發的

流程中作為最高的指導方向。透過本軟體需求規格書可以運用於評估工程驗收管

理資訊系統、專案是否達成當初訂定之使用者需求,且可作為後續軟體測試驗收

時的依據。

本軟體需求規格書其應用範圍涵蓋工程驗收管理資訊系統的軟體,本章節中

包含前言介紹、系統描述、分項功能需求、需求規格表四個大綱項目。本軟體需

求規格書適用於全程工程驗收管理資訊系統發展工作。

(1) 標的軟體系統摘述

本工程驗收管理資訊系統主要建立電子化作業流程,使各單位透過此系統,

提供統一窗口彙總辦理各工程驗收作業制度,工程驗收作業資訊系統以透明化的

方式呈現,進而提升驗收作業之時效性,藉此取代原本作業繁複之紙本流程。透

過「網際應用系統」線上即時作業方式處理,以便統一工程驗收資訊傳達(輸)及

儲存。如此一來,可大幅度節省人力上之成本,提升驗收作業之效率,且透過電

腦化之機制,更可省下不少紙張之耗費,以達到節能減碳之功效。

(2) 定義與縮寫符號

表二定義工程驗收管理電腦化作業(EMIS)之縮寫。

表二、定義與縮寫符號

中文名稱 英文名稱 縮寫

工程驗收管理電腦化作業 Engineering

Management

Information System

EMIS

2. 文件目的與系統描述

10

本工程驗收管理資訊系統主要涵蓋開單作業、主驗人員指派作業與驗收結果

作業,系統人員包含有系統管理人員、內部使用者與外部使用者,詳細系統涵蓋

範圍與系統的使用者說明如下:

(1) 系統功能目的

本工程驗收管理資訊系統功能目的涵蓋基本功能作業、開單功能作業、指派

主驗人員作業、派工後列印作業、工程驗收結果作業、工程驗收結果查詢作業、

工程驗收結果列印作業、工程驗收通知單變更作業、異常工程驗收案件作業、工

程驗收通知單編號作業、例行報表列印作業與其他作業,各功能詳細說明如下:

基本功能作業

I. 員工基本資料: 本功能係建立員工基本資料,供審校、查詢及登錄

之用。

II. 單位基本資料: 本功能係建立工程採購經辦單位基本資料,供審校、

查詢及選擇之用。

III. 特例代碼資料: 本功能係建立工程驗收案件發現之特例資料,供查

詢及選擇之用。

開單功能作業

I. 開單作業

– 各單位經辦部門負責輸入「工程驗收通知單」填表內容。

– 「工程驗收通知單」編輯及開單輸入作業。

– 「工程驗收通知單」等相關檔案,以 WORD、EXCEL 及 PDF 等

檔案格式進行文件存檔,以利承辦單位將相關檔案資料,以附件形式

經由電子公文系統發文通知營建處檢驗組,辦理工程驗收作業。

II. 查詢作業

– 各單位經辦部門負責查詢「工程驗收通知單」輸入內容。

– 查詢「工程驗收通知單」開單輸入作業內容之正確性。

III. 列印及 E-mail「工程驗收通知單」作業

– 各單位經辦部門負責列印已審校通過之「工程驗收通知單」資料

11

– 「工程驗收通知單」併竣工結算資料,傳送「營建處 檢驗組」。

指派主驗人員作業

I. 機器處理作業

– 本功能係建立「工程驗收通知單」之歸類與整理資料,供派工及查

詢之用。

II. 派工及核定作業

– 建立「主驗人員工作分派表」。

– 「主驗人員工作分派表」核定作業。

– 產生「主驗人員工作動態表」資料。

III. 主驗人員工作通知作業

– 本功能係將己核定指派工作之「工程驗收通知單」,由系統自動透

過 E-mail通知各被指派主驗人員(含被指派會計課及各經辦單

位) 。

IV. 派工後查詢作業

– 各單位工程驗收通知單案件之查詢與過程追蹤。

– 各主驗人員案件之查詢與過程追蹤。

– 各主驗人員工作動態之查詢。

派工後列印作業

I. 本功能為列印各單位與各主驗人員於本單位或個人主辦案件之資

料。

工程驗收結果作業

I. 工程驗收結果輸入作業。

II. 本功能為各單位工程驗收過程與結果資料之編輯與內容輸入。

工程驗收結果查詢作業

12

I. 本功能為各派員單位過程與結果資料之查詢。

工程驗收結果列印作業

I. 本功能為各派員單位結果資料之輸出。

工程驗收通知單變更作業

I. 本功能為單位要求更改工程驗收通知單內容,包含更改日期、案件

取消及延長監辦日期之處理。

II. 本功能為工程驗收工作指派作業人員與工程驗收方式、工程驗收日

期異動之處理。

III. 工程驗收結果資料內容之變更處理。

異常工程驗收案件作業

I. 專案簽辦處理之工程驗收案件作業。

II. 機器當機或其他系統故障案件後補作業之處理。

工程驗收通知單編號作業

I. 各單位開單作業之編號功能。

II. 本組編號處理作業。

III. 專案簽辦處理工作之編號作業。

IV. 異常案件人工編號方式。

其他作業

I. 為確保安全與核定層級之有效控制,建立作業授權資通安全管控。

II. 必要之審校功能。

III. 系統開發後之教育訓練及維護。

IV. 因應各單位不同資料需求,建立一份可由各單位或稽核部門自行擷

取所需之資料內容(如:表頭設計、期間、招標別,採購金額,採

購案號、工作項目等)之彈性需求報表。

V. 其他依實務需要之功能需求。

VI. 依規範進行需求分析、系統分析及專案規劃,加以客製化的規劃設

計及調整建置系統,經由實際驗證來確保系統之可行性。

13

(2) 系統用戶種類特性

本工程驗收管理資訊系統未來用戶之總類,為根據終端用戶(End User)實際

使用之不同特性進行區分如圖一所示。分為一般使用者、管理階層使用者與系統

管理者,以便於未來作為功能測試之考量。其詳細使用者角色與說明如下。.

圖一、工程驗收工作流程與其角色

工程主辦單位

本角色主要為提供予營建處外部使用者,可至系統進行工程驗收開單作

業。

主驗員

本角色主要為提供予營建處內部使用者,可至系統進行工程驗收資料填

寫。

主管

本角色主要為提供予營建處內部使用者,可至系統進行工程驗收時程排

定與資料審核。

14

組長

本角色主要為提供予營建處內部使用者,可至系統進行工程驗收資料審

核。

副處長

本角色主要為提供予營建處內部使用者,可至系統工程驗收資料審核。

處長

本角色主要為提供予營建處內部使用者,可至系統工程驗收資料審核。

系統管理者

本角色主要為提供予營建處內部使用者,可至系統進行系統管理。

帳號的功能僅在於登入的認證,該帳號所擁有之權限係由其角色所決定, 所

以一個未設定角色的帳號無法進行何任工作操作。

帳號和角色之間的對應是一對一,也就是一個帳號只能擁有一個角色。如果

擁有兩個角色時,該帳號進入工作頁時會因為多個角色的關係而無法決定其工作

選項,接著將頁面導向錯誤頁。

3. 分項功能需求分析

(1) 功能需求

本項為界定工程驗收管理資訊系統功能性需求定義與描述,其詳細說明如下:

申請驗收功能

I. 此功能為提供工程主辦單位進行使用,進行案件驗收申請。

II. 需輸入工程主辦單位與工程總金額,做為授權金額表驗收權責單位判定,

若金額不達標準,系統前端即進行退件。

上傳驗收資料

15

I. 此功能為提供工程主辦單位進行使用,進行驗收所需資料上傳。

II. 需上傳下列資料

– 分項工程驗收圖表種類及份數表。

– 工程竣工驗收圖表種類及份數表。

– 工程結算驗收證明書。

– 結算明細表。

– 供借機具材料清單。

– 供給器材清單。

– 工程實作數量計算書。

– 竣工圖並附上封面。

– 工作天統計表。

– 工期計算。

– 分項工程驗收資料表。

勾選委託複驗

I. 此功能為提供工程主辦單位,進行工程複驗時使用。

II. 若當工程主驗員提出補修通知單時,工程主辦單位需勾選是否委託複驗,

若需委託複驗,則工程主驗單位需派員進行再次驗收。

填寫驗收證明書

I. 此功能為提供工程主辦單位進行使用,若工程已完成驗收,工程主辦單位

需填寫驗收證明書。

驗收判斷

I. 此功能為提供主管進行使用,提供主管進行工程驗收案件並進行決策。

II. 若為可驗收此項資訊會送至下一層級,在此為主管送至組長,組長送至副

處長。

III. 若此項選項為勾選可驗收,則主管可進行派員及安排時間動作。

IV. 若此項選項為勾選不可驗收,則主管不必進行派員及安排時間動作,此資

訊將直接送至下一層級,在此為送至組長。

派員及安排時間

I. 此功能為提供主管進行使用,提供主管進行工程驗收案件派遣課員及安排

16

時間使用。

II. 此項功能其選擇課員為根據其課內員工數量進行派遣。

III. 派遣時間使用半天為最小單位。

員工時間指定

I. 此功能為提供主管進行使用,提供主管進行其課內員工時間調控,主管可

以針對某課員指定驗收時間等事項。

II. 指定時間使用半天為最小單位。

審定報告書

I. 此功能為提供主管、組長、副處長及處長進行使用,進行主驗員所繳交驗

收報告書之審定。

II. 此為針對個別主驗員,當其完成則進行此項審定。

III. 若審定通過,則往下一層級遞送,進行審定。例如:組長審定通過,則送

往副處長審定。

IV. 若審定不通過,則往上一層級遞送,進行修訂。例如:組長審定不通過,

則送往主管進行修訂。

審定會承辦單位文件及實作實標數量核算

I. 此功能為提供主管、組長及副處長進行主驗員所繳交會承辦單位文件及實

作實標數量核算之審定。

II. 若審定通過,則往下一層級遞送,進行審定。例如:組長審定通過,則送

往副處長審定。

III. 若審定不通過,則往上一層級遞送,進行修訂。例如:組長審定不通過,

則送往主管進行修訂。

驗收判斷

I. 此功能為提供組長進行使用,提供組長進行工程驗收案件決策。

II. 若為可驗收此項資訊會送至下一層級,在此為主管送至組長,組長送至副

處長。

III. 若為不可驗收,則需選擇是否可歸咎於工程主辦單位,若非歸咎於工程主

辦單位,則需選擇是否退回下一層級單位。例如:若為主管勾選錯誤選項,

則組長可退回給主管進行重新勾選。

IV. 若此項選項為勾選可驗收,則組長可進行審定派員及安排時間動作。

17

審定派員及安排時間

I. 此功能為提供組長進行使用,提供組長進行各主管(機、電、土、建)所勾

選的派員及時間進行審定。

II. 此功能提供組長做驗收時間安排。

驗收判斷

I. 此功能為提供副處長進行工程驗收案件之決策。

II. 若為不可驗收,則需選擇是否可歸咎於工程主辦單位,若非歸咎於工程主

辦單位,則需選擇是否退回下一層級單位。例如:若為主管勾選錯誤選項,

則組長可退回給主管進行重新勾選。

III. 若為不可驗收,其歸咎於工程主辦單位,則此案件會退回給工程主辦單

位。

IV. 若此項選項為勾選可驗收,則副處長可進行核定派員及安排時間動作。

核定派員及安排時間

I. 此功能為提供副處長進行使用,提供副處長進行組長所勾選的派員及時間

進行核定。

II. 此功能提供副處長做最後的驗收時間安排。

核定驗收報告書

I. 此功能為提供處長進行主驗員所繳交驗收報告書之核定。

II. 若核定通過,則完成。

III. 若核定不通過,則往上一層級遞送,進行修訂。例如:處長核定不通過,

則送回副處長進行修訂。

核定會承辦單位文件及實作實標數量核算

I. 此功能為提供處長進行主驗員所繳交會承辦單位文件及實作實標數量核

算之核定。

II. 若核定通過,則完成。

III. 若核定不通過,則往上一層級遞送,進行修訂。例如: 處長審定不通過,

則送往副處長進行修訂。

18

填寫驗收報告書

I. 此功能為提供主驗員進行繳交驗收報告書。

填寫複驗收記錄簽認補修通知單

I. 此功能提供主驗員進行上傳複驗收記錄簽認補修通知單。

填寫會承辦單位簽辦文件及實作實標數量核算

I. 此功能提供主驗員進行上傳承辦單位簽辦文件及實作實標數量核算。

核對驗收證明書

I. 此功能為提供主驗員進行核對驗收證明書是否正確。

II. 若此選項為正確,則提供印出此檔案功能。

III. 若此選項為不正確,則退回給工程主辦單位。

上傳已核章驗收證明書

I. 此功能為提供主驗員進行使用,提供主驗員進行上傳已核章驗收證明書。

II. 若完成此項,代表本案完成驗收。

驗收單查詢

I. 此功能為提供工程主辦單位、主驗員、主管、組長、副處長及處長進行驗

收單資料查詢使用。

II. 工程主辦單位僅能查詢其本身所遞交之工程驗收申請資料。

III. 主驗員僅能查詢其本身被派送之驗收資料。

IV. 主管、組長、副處長及處長可查詢所有工程驗收申請資料。

V. 查詢可根據時間範圍、工程主辦單位、工程性質、工程主旨、工程案號及

金額等進行查詢。

檔案下載

I. 此功能為提供所有角色進行使用,不需經過驗證。

II. 此功能可提供檔案下載使用。

19

各單位時間顯示

I. 此功能為提供所有角色進行使用,不需經過驗證。

II. 此功能可提供顯示各單位目前可使用時間。

各項公告資訊顯示

I. 此功能為提供所有角色進行使用,不需經過驗證。

II. 此功能可提供顯示各項公告資訊顯示。

管理使用者帳號

I. 此功能為提供系統管理者使用。

II. 此功能為管理工程驗收系統使用者帳號。

新增使用者角色

I. 此功能為提供系統管理者使用。

II. 此功能為設定帳號使用者其使用者角色。

刪除使用者角色

I. 此功能為提供系統管理者使用。

II. 此功能為刪除帳號使用者其使用者角色。

修改使用者角色

I. 此功能為提供系統管理者使用。

II. 此功能為修改帳號使用者其使用者角色。

檔案上傳

I. 此功能為提供系統管理者使用。

II. 此功能為提供檔案上傳,作為首頁檔案下載區檔案使用。

訊息發佈

I. 此功能為提供系統管理者使用。

20

II. 此功能為提供訊息作為發佈,作為首頁公告訊息發佈使用。

(2) 非功能需求

本項為描述工程驗收管理資訊系統的非功能性需求,其詳細描述如下:

可靠度

本項工程驗收管理資訊系統須確保 90%以上運行率,若系統發生異常,需有

備援系統可即時進行服務轉向處理。

可維護度

本項工程驗收管理資訊系統於交付使用者後,將附上系統發展原始碼,使用

者可依需求進行修訂,若須由發展者進行維護,可依據需求訂定維護合約。

安全需求

本項工程驗收管理資訊系統需要提供安全的資料存取環境。

需求規格表

本項軟體需求規格表旨在說明台灣電力公司使用者對工程驗收管理資訊系

統的功能需求、效能需求、介面需求、作業程序需求、安全性需求、品質需求等

需求,詳細說明如表三所示。

表三、軟體需求規格表

項目編號 項目需求

1 基本功能

1.1 員工基本資料登錄

1.2 單位基本資料登錄

1.3 特例代碼資料查訊

2 開單功能

2.1 開單作業登錄

21

2.2 開單作業查詢

2.3 開單作業資料列印及 E-mail通知

3 指派主驗人員

3.1 機器處理

3.2 派工及核定

3.3 主驗人員工作通知

3.4 派工後查詢作業

4 派工後列印作業

5 工程驗收結果

5.1 工程驗收結果輸入

5.2 工程驗收結果資料編輯

6 工程驗收結果查詢

7 工程驗收結果列印

8 工程驗收通知單變更

8.1 工程驗收通知單編輯

9 異常工程驗收案件

10 工程驗收通知單編號

11 例行報表列印

12 系統管理者人員設定

12.1 使用者角色設定

12.2 使用者角色修改

12.3 檔案上傳

12.4 訊息發佈

13 其他作業

22

六、 軟體設計規格

1. 系統描述

「工程驗收管理電腦化作業」系統以 ASP.NET 程式語言來建構,配合

Microsoft SQL Server,透過資訊化與電腦化方式進行建置。本工程驗收系統可提

供統一窗口彙總辦理各工程驗收作業制度,可有效提升作業系統程之明確性及作

業效率,且彈性的由驗收人員排定休息日,當驗收主管派員驗收時可達到人性化

的管理。本系統作業流程符合 ISO 作業規定,使各工程採購經辦單位及各參與

驗收之作業人員均了解驗收運作流程,安全機制上提供了帳號確認機制並要求定

期更換帳號密碼組,大幅提升資料的安全性。藉由電腦化驗收系統,可達到人力

成本之降低,提升企業之競爭力。

(1) 系統名稱

本計畫全名為「工程驗收管理電腦化作業」,簡稱為「驗收管理」,系統名稱

訂為「工程驗收管理電腦化作業系統」,契約編號為「TPC-546-2107-9906」。

(2) 系統簡述

本系統為建立台灣電力股份有限公司所使用之「工程驗收管理資訊系統」,

可使工程驗收管理電腦化,提供統一窗口辦理各工程驗收作業制度,工程驗收作

業資訊透明化並確保資料安全性,並符合 ISO 作業規定,能有效提升工程驗收

作業時效性及減少紙本消耗,達到節能減碳之功效。

2. 系統設計規格

(1) 系統架構

帳號角色系統

I. 帳號管理

II. 角色的管理(包含對應到公司組織的角色限制)。

III. 使用者資訊管理,主要用來處理課別問題(僅主管與驗收員需要)。

認證系統

I. 帳號與角色的認證。

II. 頁面操作認證。

錯誤處理系統

23

I. 錯誤處理機制。

工作系統

I. 工作項定義。

II. 工作項與角色的關係。

III. 工作項之間的關係與流程。

(2) 系統環境

圖二為本工程驗收之系統環境架構圖,於台灣電力公司建置工程驗收伺服器,

所屬人員皆需經本工程驗收系統才可執行驗收作業,其伺服器硬體架構規格如

下:

硬體:Intel X86 Compatible Server Platform。

OS:Microsoft Windows 7。

Web Server:Internet Information Services 7.0。

網頁應用程式:由 ASP.NET Framework 4.0版本。

Database:Microsoft SQL Server 2008 R2。

圖二、系統環境架構圖

(3) 系統流程

24

本節係說明本工程驗收管理電腦化作業系統的功能模組運作與設計流程,並

以設計概念流程圖(Sequence Diagram),展示各功能的系統運作邏輯與流程,提

供本案系統開發人員做為各功能模組程式設計與測試的依據。以下就各功能模組

分別說明系統運作流程。

工程驗收通知單狀態

I. 未遞交

– 參與角色:承辦單位。

– 描述:為通知單的起始狀態,當承辦單位新增通知單後,在

遞送出表單前的狀態。

II. 已遞交

– 參與角色:承辦單位。

– 描述:工程驗收通知單遞送給各課主管後之狀態。

III. 工程驗收人員與時間指派中

– 參與角色:各課主管。

– 描述:當各課主管指派驗收員與驗收時間之期間的狀態。

IV. 工程驗收時程審定中

– 參與角色:組長。

– 描述:組長統整各課主管所指派的時程之狀態。

V. 工程驗收通知單核定中

– 參與角色:副處長。

– 描述:決定是否開始進行驗收之狀態。

VI. 工程驗收中

– 參與角色:主驗員。

– 描述:各驗收員進行驗收工作與相關文件準備之狀態。

VII. 工程驗收完成

– 參與角色:主驗員。

– 描述:每位驗收員都已完成驗收工作。

VIII. 各課指派時程無法整合

– 參與角色:主管。

– 描述:各課主管指派之工程驗收時間無法配合,需通知各課

主管重新排定時程。

IX. 副處長要求組長修定資料

– 參與角色:組長。

– 描述:工程驗收通知單資料有問題, 承辦單位需要修改通知

單資料,修改完重新遞交給主管。

X. 工程驗收通知單申請拒絕

– 參與角色:副處長。

25

– 描述:工程驗收通知單核定結果為不通過,承辦單位需要重

新新增工程驗收通知單。

圖三為系統功能流程圖,在流程圖中描述系統的決策判斷,及決策後的狀態

圖,從新增工程驗收單至工程驗收結束,經由 10個有限狀態機進行決定,經過

兩個分支指令來構成,分別為組長核定派員成功與否、驗收通過與否,此為系統

之主要流程圖。

圖三、系統功能流程圖

承辦單位新增完一筆驗收單

I. 新增一筆資料到 ProjectAcceptanceState, PAState=1。

II. 承辦單位遞交後,更新 PAState=2,檢查驗收單的課別後,插入多

筆驗收通知到 PASuperintendentRel (多課別時, 會有多筆驗收通

知) 。

主管檢視工作時,檢查 PASuperintendentRel是否有自己的 ID,且 PAState

為 Delivery,AssigmtState = NoProcessing,即表示該筆驗收通知需要處理

I. 若審查資料不通過則更新 AssigmtState 為不可驗,更新 PAState=

MemDateAssignment(3) ,遞交給組長 。

II. 若審查資料通過則更新 AssigmtState為可驗,並開始指派,嘗試更

新 PAState= MemDateAssignment(3) 。

– 指派時間,新增資料到 PAAssigmtTime 。

– 指派人員,新增資料到 PAAssigmtMem。

III. 若檢查到 AssigmtState 為退回(DateMismatch),則重新審查資料或

指派人員時間. 。

26

IV. 若檢查到 PAState=8,則需要重新指派人員和時間。

組 長 檢 視 工 作 時 , 搜 尋 PAState=3 的 工 程 驗 收 單 並 檢 查

PASuperintendentRel中的主管指派資料是否全審定完成,如果完成就交給

組長審定資料和確定時程。

I. 如果某課的指派資料有問題就回絕並更新 AssigmtState。

II. 若審查資料通過,需要檢查指派時間。

– 如果指派時間有交集則更新 PALeaderRel 之 ValidState

為通過,完成後更新 PAState=4。

– 如果所有的指派時間沒有交集(系統自行檢查)就更新

PAState=8來回絕給所有主管。

III. 若審查資料不通過,則寫入擬辦訊息,更新 PALeaderRel 之

ValidState為不通過,更新 PAState=4。

副處長檢視工作時,搜尋 PAState=4的驗收通知並核定資料,核定行為受

PALeaderRel之 ValidState影響。

I. 如果 ValidState為通過,則副處長僅能進行核定通過與不通過。

– 核定通過則更新 PAState=5。

– 核定不通過,更新 PAState=10,結束此案,承辦單位需

要重新填單。

II. 如果 ValidState為不通過,則副處長僅能進行不通過與退回。

– 審定資料有誤,則 PAState=9退回給組長重新處理。

– 核定不通過,更新 PAState=10,結束此案,承辦單位需

要重新填單。

驗收員檢視工作時,系統搜尋 PAAssigmtMem 裡是否有該驗收員的 UID

並檢查該工程的 PAState是否為 5,若為 5則表示驗收員需要處理這些資

料。

I. 開始驗收與上傳文件,驗收完成後更新 PAAssigmtMem 的

SAState。

II. 當所有驗收員完成驗收後去更新 SAState時,也會檢查其他驗收員

是否已完成驗收,如果完成就會更新 PAState=7。

3. 操作介面規格設計

(1) 網頁架構圖

27

圖四為系統網頁設計架構圖,圖中將各個人員及其所對應的工作項目分類成

樹狀圖結構,並分成三層結構。

圖四、網頁架構圖

(2) 網頁設計

圖五為台灣電力公司工程驗收系統的主畫面,它含有「我的工作」、「行事曆」、

「檔案下載」、「查詢」及「關於」五種功能選項。我的工作需要透過登入使用者

帳號密碼,才能查閱點選使用者目前的工作排程。行事曆可查詢目前各課派員情

形。檔案下載則提供本案所屬人員下載相關文件之用。查詢為提供查詢各項資料

使用。關於則是此驗收系統的定義及其功能解釋。

圖五、系統主畫面

圖六為此系統之登入畫面。

28

圖六、登入畫面

圖七為工程主辦單位登入後所能看到之畫面,可觀看目前的驗收情況,是否

驗收完成,驗收文件是否繳交完整,其有新增及查詢之功能。

圖七、工程主辦單位登入後畫面

29

圖八為工程主辦單位新增工程驗收通知單時所需要填寫之表格。

圖八、工程主辦單位新增工程驗收通知單

30

圖九為確認工程主辦單位是否將驗收文件完整上傳,檢查其文件是否有所缺

少,通過自我檢測後才可進入工程驗收程序,其中驗收通知單紙本封面掃描檔與

完工欲驗收項目之目錄或摘要為必繳交檔案,其餘為根據需要自行決定是否上傳

繳交。

圖九、工程主辦單位驗收文件上傳

31

圖十為當上傳文件尚未齊全時,系統是無法進入驗收主程序。會退回至主辦

單位驗收文件上傳的畫面。

圖十、驗收文件上未上傳前無法完成遞交

圖十一為台灣電力公司之主管登入系統之畫面,其可以查詢目前其驗收員的

工作排程,統計驗收員之工作天,及指派驗收員之功能。

圖十一、主管登入畫面

32

圖十二為主管指派驗收人員其工作天之選擇畫面。

圖十二、主管指派驗收人員工作天

33

圖十三為主管指派主驗員外派驗收時間畫面。

圖十三、主管指派主驗員外派驗收時間

34

圖十四為主管指派工程驗收案件其驗收主驗員及指定之時間畫面。

圖十四、主管指派驗收員與時間

35

圖十五為主管派員後,需經組長審定後才可決定派員,若組長否定派員則需

退回主管重新派員。

圖十五、組長審定工程

36

圖十六為組長查閱各主管審查回覆情形,由此畫面可詳細了解目前審查之情

況。

圖十六、組長查閱各主管審查回覆情形

37

4. 資料庫設計規格

(1) 實體關係圖(Entity Relationship Diagrams)

圖十七為工程驗收電腦化作業之資料庫 UML關聯圖。

圖十七、系統使用者資料庫關聯圖

(2) 表格欄位定義(Table Definition)

圖十八為 AssigmtMessage資料表,MsgID為擬辦訊息 ID,AssigmtID為工

程案件指派 ID,主管針對某指派案件所留下的擬辦訊息,MsgContent為擬辦訊

息內容,Time為訊息儲存時間。

38

圖十八、AssigmtMessage資料表

圖十九為 InspectorAssigmtTime資料表,UID為驗收員的使用者識別子,

TStart為被佔據的日期,DayState為被佔據的時段。

圖十九、InspectorAssigmtTime資料表

圖二十為 PAAssigmtMem資料表,SAssigmtID為相對應的工程案件驗收指

派識別子,UID為被指派的驗收員使用者識別子,SAState為驗收員的驗收狀態。

圖二十、PAAssigmtMem資料表

圖二十一為 PAAssigmtMessage 資料表,MsgID 為擬辦訊息識別子,Giver

傳遞訊息者,Receiver 接收訊息者,Time 為訊息儲存時間,MsgContent 為擬辦

訊息內容,State 訊息狀態,有擴充,多樣化和特殊用途之功能,目前用於識別

工作狀態。

39

圖二十一、PAAssigmtMessage資料表

圖二十二為 PAAssigmtTime 資料表,SAssigmtID 為相對應的工程案件驗收

指派識別子,TStart為指派驗收日期,DayState為指派驗收日期之時段。

圖二十二、PAAssigmtTime資料表

圖二十三為 PALeaderRel資料表,PID為工程案件識別子,UID為組長使用

者識別子,VaildState為組長審定該案件之狀態。

圖二十三、PALeaderRel資料表

圖二十四為 PAPreparedData資料表,SAssigmtID為相對應的工程案件識別

子,TStart為指派驗收日期,DayState為指派驗收日期之時段。

圖二十四、PAPreparedData資料表

40

圖二十五為 PASuperintendentRel資料表,PID工程案件識別子,UID為主管

使用者識別子,SAssigmtID為表單驗收指派識別子,AssigmtState為指派狀態。

圖二十五、PASuperintendentRel資料表

圖二十六為 ProjectAcceptanceState資料表,PID為工程案件識別子,PAState

為目前表單的處理狀態,UID為遞交驗收表單的承辦單位使用者識別子。

圖二十六、ProjectAcceptanceState資料表

圖二十七為 SectionClass資料表,ClassID為課別識別子,ClassName為課別

名稱。

圖二十七、SectionClass資料表

圖二十八為 UserInfos資料表,UserID為相對應的主管或驗收員使用者識別

子,SectionClassID為該使用者所屬的課別識別子,UserName為使用者名稱。

圖二十八、UserInfos資料表

41

5. 使用者權責劃分

圖二十九為承辦單位權則劃分,包含申請驗收、驗收單查詢、填寫驗收資料

與上傳驗收資料之權責功能。

圖二十九、承辦單位權責劃分

圖三十為主管權責劃分,包含員工時間指定、驗收判斷、驗收單查詢、派員

與驗收時間之權責功能。

圖三十、主管權責劃分

圖三十一為組長權責劃分,包含驗收判斷、驗收單查詢、審定派員與驗收時

間之權責功能。

42

圖三十一、組長權責劃分

圖三十二為副處長權責劃分,其包含驗收判斷、驗收單查詢、指定派員與驗

收時間之權責功能。

圖三十二、副處長權責劃分

圖三十三為處長權責劃分,包含驗收單查詢之權責功能。

圖三十三、處長權責劃分

43

圖三十四為主驗員權責劃分,包含填寫驗收報告(含驗收紀錄)、驗收單查詢

之權責功能。

圖三十四、主驗員權責劃分

圖三十五為系統管理員權責劃分,包含管理使用者帳號、新增使用者角色、

刪除使用者角色、修改使用者角色、檔案上傳、訊息發佈之權責功能。

圖三十五、系統管理員權責劃分

44

圖三十六為非特定角色權責劃分,包含檔案下載、行事曆顯示、各項公告資

訊顯示之權責功能。

圖三十六、非特定角色權責劃分

圖三十七為驗收查詢權責,此項功能為主管、組長、處長,三個單位可以使

用之權責功能。

圖三十七、驗收查詢權責

45

七、 結論

本研究計畫為建立台灣電力股份有限公司所使用之「工程驗收管理資訊系

統」,透過系統資訊化與電腦化,提供單一窗口彙總辦理各工程驗收作業制度,

讓工程驗收作業資訊得以透明化,並確保資訊可永久保存,進而提升驗收作業之

時效性,簡化現有繁雜紙本作業流程。另透過線上即時作業方式處理,以便統一

工程驗收資訊傳達(輸)及儲存。如此一來,可大幅度節省人力上之成本,提升驗

收作業之效率,且透過電腦化之機制,更可省下不少紙張之耗費,以達到節能減

碳之功效。研究主要成果如下:

系統定義

本研究計畫案透過資訊系統定義進行分析,針對系統開發的必要性、效

益分析、操作系統的可行性、技術可行性與時程可行性進行分析研究,確保

本研究計畫案符合台灣電力股份有限公司發展需求。

軟體需求規格制定

本研究計畫透過軟體需求規格制定,描述台灣電力股份有限公司「工程

驗收管理資訊系統」之軟體產品、專案之原始使用者、規格需求,透過本軟

體需求規格書,在工程驗收管理資訊系統軟體專案開發的流程中作為最高的

指導方向。本軟體需求規格書可以運用在評估工程驗收管理資訊系統軟體產

品、專案是否達成當初訂定之使用者需求,且可作為後續軟體測試驗收時的

依據。

軟體設計規格制定

本研究計畫透過軟體設計規格制定,進行系統描述、系統設計、操作介

面規格設計與資料庫設計規格制訂,確保本研究計畫案於發展過程中可供參

考的設計作業程序,加速進行研發作業,並提升本案發展品質。

系統開發

本研究案透過上述系統定義、軟體需求規格、軟體設計規格進行台灣電

力股份有限公司之工程驗收管理資訊系統開發,本計畫已完成工程驗收管理

資訊系統並佈署於台灣電力公司營建處進行系統營運使用,讓工程驗收作業

資訊得以透明化與資訊化。

46

八、 參考文獻

1. AppServ Open Project http://www.appservnetwork.com

2. XOOPS Official Site http://www.xoops.org

3. R. Bryce, Power Hungry: The Myths of ”Green” Energy and the Real Fuels of the

Future, PublicAffairs, 2010.

4. A. Keyhani, M.N. Marwali and M. Dai, Integration of Green and Renewable

Energy in Electric Power Systems.” John Wiley 及 Sons Inc, December 2009.

5. L. Welling and L. Thomson, Php And Mysql Developer’s Projects, Macmillan

Computer, 2010.

6. P.B. MacIntyre, PHP: The Good Parts, Oreilly 及 Associates Inc, 2010.

7. G.K. Andersen, C. Klumpner, S.B. Kjaer and F. Blaabjerg, “A New Green Power

Inverter for Fuel Cells,” Procedings of the IEEE PESC, vol.2, no.11, pp.727-733,

2002.

8. S. Rahman, “Green Power: In Harmony with OurHhome,” EE Times, India, May

16, 2009.

9. J. Kanjilal, I. Novakm A. Hajdrik, M. Sellers, S. Mitchel, V. Peter, H. Andras and G.

Hillar, Visual Studio 2010 and .net 4.0 Six-in-one, John Wiley 及 Sons Inc, 2009.

10. 台電 ERP專案變革溝通小組(99年 5月),「ERP有效推動中國企業轉型」,台

電月刊,569期,34-36頁。

11.沈德振(99年 2月),「我們的 ERP專案」,台電月刊,566期,26-29頁。

12.中華顧問工程(96 年 4 月),「Smart PMIS」,營建管理智慧化技術之研發及應

用,74期,58-68頁。

13. “The Smart Grid: an Introduction,” (http://www.cooperpowereas.com/)

14. F. Cleveland, IEC TC57 Security Standards for the Power System’s Information

Infrastructure- Beyond Simple Encryption, IEC TC57 WG15 Security Standards,

Ver.11, June 2007.

15. 張立宇(99年 6月),「企業內的雲端運算-ERP」,台電月刊,570期,6-15頁。

16. 沈玉如(100年 6月),「99 年度政府機關電腦作業效率實地查核紀實」,台電

月刊,582期,24-26頁。

17. S.M. Dragojlovic, O.T. Milenkovic and M. Vujicic, “The Information System For

Power Distribution System As Answer On New Demands In Power Distribution

System,” Procedings of the IEEE/PES Transmission and Distribution Conference and

Exhibition: Asia and Pacific, pp.1-4, 2005.

18. K.J. Sohn, W.j. Yoo and C.g. Lee, “The Design and Implementation of

Information System for the MBO of National R&D Projects Cooperated by Industries,

Universities and Government-supported Research Institutes,” Portland International

Center for Management of Engineering and Technology, pp.959-966, 2007.

47

九、 附錄(Source Code)

1. Default.aspx

<%@ Page Title="首頁" Language="vb" MasterPageFile="~/Site.Master"

AutoEventWireup="false"

CodeBehind="Default.aspx.vb" Inherits="Tai_Power._Default" %>

<asp:Content ID="HeaderContent" runat="server"

ContentPlaceHolderID="HeadContent">

</asp:Content>

<asp:Content ID="BodyContent" runat="server"

ContentPlaceHolderID="MainContent">

<h2>

台灣電力公司工程驗收系統首頁!

</h2>

<br />

<asp:LoginView ID="LoginView1" runat="server">

<AnonymousTemplate>

<span>放置 首頁內容與公告</span>

</AnonymousTemplate>

<LoggedInTemplate>

</LoggedInTemplate>

</asp:LoginView>

</asp:Content>

48

2. About.aspx

<%@ Page Title="關於我們" Language="vb" MasterPageFile="~/Site.Master"

AutoEventWireup="false"

CodeBehind="About.aspx.vb" Inherits="Tai_Power.About" %>

<asp:Content ID="HeaderContent" runat="server"

ContentPlaceHolderID="HeadContent">

</asp:Content>

<asp:Content ID="BodyContent" runat="server"

ContentPlaceHolderID="MainContent">

<h2>

關於

</h2>

<p>

將內容放在此處。

</p>

</asp:Content>

49

3. MyWork.aspx

<%@ Page Title="" Language="vb" AutoEventWireup="false"

MasterPageFile="~/MyWorksMasterPage.master" CodeBehind="MyWorks.aspx.vb"

Inherits="Tai_Power.MyWorks" %>

<%@ Register src="UC/Works/HandlingUnitRTTableView.ascx"

tagname="HandlingUnitRTTableView" tagprefix="uc1" %>

<%@ Register src="UC/Works/SuperintendentRTTableView.ascx"

tagname="SuperintendentRTTableView" tagprefix="uc2" %>

<%@ Register src="UC/Works/LeaderRTTableView.ascx"

tagname="LeaderRTTableView" tagprefix="uc3" %>

<%@ Register src="UC/Works/DeputyDirectorRTTableView.ascx"

tagname="DeputyDirectorRTTableView" tagprefix="uc4" %>

<%@ Register src="UC/Works/InspectorRTTableView.ascx"

tagname="InspectorRTTableView" tagprefix="uc5" %>

<%@ Register src="UC/Works/SiteManagerRTTableView.ascx"

tagname="SiteManagerRTTableView" tagprefix="uc6" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MyWorksHeader"

runat="server">

<script src="/Scripts/jquery/jquery-1.5.1.min.js" type="text/javascript"></script>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MyWorksContent"

runat="server">

<%--<asp:MultiView ID="MultiRoleView" runat="server"

ActiveViewIndex="-1">

<asp:View ID="AllView" runat="server">

<asp:Label ID="allv" runat="server" Text=""></asp:Label>

</asp:View>

<asp:View ID="HandlingUnitView" runat="server">

<uc1:HandlingUnitRTTableView ID="HandlingUnitRTTableView1"

runat="server"/>

</asp:View>

<asp:View ID="InspectorView" runat="server">

<uc5:InspectorRTTableView ID="InspectorRTTableView1"

runat="server" />

</asp:View>

<asp:View ID="SuperintendentView" runat="server">

<uc2:SuperintendentRTTableView

ID="SuperintendentRTTableView1" runat="server" />

50

</asp:View>

<asp:View ID="LeaderView" runat="server">

<uc3:LeaderRTTableView ID="LeaderRTTableView1" runat="server"

/>

</asp:View>

<asp:View ID="DeputyDirectorView" runat="server">

<uc4:DeputyDirectorRTTableView

ID="DeputyDirectorRTTableView1" runat="server" />

</asp:View>

<asp:View ID="DirectorView" runat="server">

</asp:View>

<asp:View ID="SiteManager" runat="server">

<uc6:SiteManagerRTTableView ID="SiteManagerRTTableView1"

runat="server" />

</asp:View>

</asp:MultiView>--%>

<asp:Panel ID="UCPanel" runat="server">

<asp:Label Visible="false" ID="NoChildControl" runat="server" Text="目

前沒有可處理此帳號角色的頁面!"></asp:Label>

</asp:Panel>

</asp:Content>

51

4. PAFormQuery.aspx

<%@ Page Title="通知單查詢" Language="vb" AutoEventWireup="false"

MasterPageFile="~/Site.master" CodeBehind="PAFormQuery.aspx.vb"

Inherits="Tai_Power.PAFormQuery" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit"

TagPrefix="asp" %>

<%@ Register src="UC/EngChars.ascx" tagname="EngChars" tagprefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">

<link href="/Styles/PAFormQuery.css" rel="stylesheet" type="text/css" />

<script src="/Scripts/jquery/jquery-1.5.1.min.js" type="text/javascript"></script>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<asp:ScriptManager ID="ScriptManager1"

runat="server"></asp:ScriptManager>

<div id="formSet" class="iSet">

<div class="item">

<span class="iDes">工程主辦單位</span>

<asp:DropDownList ID="ProjHUnit" runat="server"

CssClass="iInput"></asp:DropDownList>

</div>

<div class="item">

<span class="iDes">工程性質</span>

<uc1:EngChars ID="EngCharsProjCate" CssClass="iInput"

runat="server" CB1Text="建築" CB2Text="土木" CB3Text="電機" CB4Text="機械

" />

</div>

<div class="item">

<span class="iDes">工程名稱</span>

<asp:TextBox ID="ProjName" runat="server"

CssClass="iInput"></asp:TextBox>

</div>

<div class="item">

<span class="iDes">工程案號</span>

<asp:TextBox ID="ProjNum" runat="server"

CssClass="iInput"></asp:TextBox>

52

</div>

<div class="item" id="ContEFund">

<span class="iDes">契約總價</span>

<asp:TextBox ID="ContEFundStart" runat="server"

CssClass="iInput"></asp:TextBox>

<span class="iInputDec"> ~ </span>

<asp:TextBox ID="ContEFundEnd" runat="server" CssClass="iInput"

></asp:TextBox>

</div>

</div>

<div id="paSet" class="iSet">

<div class="item">

<span class="iDes">承辦單位</span>

<asp:DropDownList ID="paHandlingUnit" runat="server"

CssClass="iInput"></asp:DropDownList>

</div>

<div class="item">

<span class="iDes">驗收主管</span>

<asp:DropDownList ID="paSuperintendent" runat="server"

CssClass="iInput"></asp:DropDownList>

</div>

<div class="item">

<span class="iDes">驗收員</span>

<asp:DropDownList ID="paInspector" runat="server"

CssClass="iInput"></asp:DropDownList>

</div>

<div class="item" id="paTime">

<span class="iDes">驗收時段</span>

<div class="itemSub">

<span class="iDesSub">開始日期:</span>

<asp:TextBox ID="paTimeStart" runat="server"

CssClass="iInput"></asp:TextBox>

<asp:Image ID="imgCalendar" runat="server" AlternateText="小

日曆" CssClass="ImgCalendar" ImageUrl="~/Image/Common/icon_date.jpg" />

<asp:CalendarExtender ID="paCalendarStart" runat="server"

TargetControlID="paTimeStart" PopupButtonID="imgCalendar"

Format="yyyy/MM/dd"></asp:CalendarExtender>

53

</div>

<div class="itemSub">

<span class="iDesSub">結束日期:</span>

<asp:TextBox ID="paTimeEnd" runat="server"

CssClass="iInput"></asp:TextBox>

<asp:Image ID="imgCalendarE" runat="server" AlternateText="

小日曆" CssClass="ImgCalendar" ImageUrl="~/Image/Common/icon_date.jpg" />

<asp:CalendarExtender ID="paCalendarEnd" runat="server"

TargetControlID="paTimeEnd" PopupButtonID="imgCalendarE"

Format="yyyy/MM/dd"></asp:CalendarExtender>

</div>

</div>

<div class="item">

<span class="iDes">驗收狀態</span>

<asp:DropDownList ID="paSAState" runat="server"

CssClass="iInput"></asp:DropDownList>

</div>

<div class="item">

<span class="iDes">驗收進度</span>

<asp:DropDownList ID="paOPState" runat="server"

CssClass="iInput"></asp:DropDownList>

</div>

</div>

<div id="queryForm">

<asp:Button ID="btSubmit" runat="server" Text="查詢" />

</div>

<div>

<asp:GridView ID="gvPAQuery" runat="server" AllowPaging="True"

AutoGenerateColumns="False" AllowSorting="True">

<EmptyDataTemplate>

沒有符合查詢條件的資料!

</EmptyDataTemplate>

<Columns>

<asp:TemplateField HeaderText="工程案號">

<ItemTemplate>

<asp:LinkButton ID="lkbProjCaseNum" runat="server"

54

Text='<%# Eval("projCaseNum") %>' CommandName="View"

CommandArgument='<%# Eval("EID") %>'></asp:LinkButton>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="工程主辦單位">

<ItemTemplate>

<asp:Label ID="lbUnit" runat="server" Text='<%#

Eval("PHUName") %>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="工程名稱">

<ItemTemplate>

<asp:Label ID="lbEngName" runat="server"

Text='<%# Eval("engName") %>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="工程性質">

<ItemTemplate>

<asp:Label ID="lbEngProt" runat="server" Text='<%#

transProjProt(Eval("prot")) %>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="契約總價">

<ItemTemplate>

<asp:Label ID="lbCEFund" runat="server" Text='<%#

Eval("contractEFund") %>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="承辦單位">

<ItemTemplate>

<asp:Label ID="lbHandlingUnit" runat="server"

Text='<%# transUserName(Eval("HandlingUnit")) %>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="驗收主管">

<ItemTemplate>

<asp:Label ID="lbSuperintendent" runat="server"

Text='<%# transUserName(Eval("Superintendent")) %>'></asp:Label>

55

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="驗收員">

<ItemTemplate>

<asp:Label ID="lbInspector" runat="server" Text='<%#

transUserName(Eval("Inspector")) %>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="驗收狀態">

<ItemTemplate>

<asp:Label ID="lbSAState" runat="server" Text='<%#

transSAState(Eval("SAState")) %>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="驗收進度">

<ItemTemplate>

<asp:Label ID="lbOPState" runat="server" Text='<%#

transOPState(Eval("OPState")) %>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="驗收時段">

<ItemTemplate>

<asp:Label ID="lbTime" runat="server" Text='<%#

Eval("TStart", "{0:yyyy/MM/dd}") %>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>

</Columns>

</asp:GridView>

</div>

<script type="text/javascript">

$(function () {

function formatCurrency(num) {

num = num.toString().replace(/\$|\,/g, '');

if (isNaN(num))

num = "0";

sign = (num == (num = Math.abs(num)));

56

num = Math.floor(num * 100 + 0.50000000001);

cents = num % 100;

num = Math.floor(num / 100).toString();

if (cents < 10)

cents = "0" + cents;

for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)

num = num.substring(0, num.length - (4 * i + 3)) + ',' +

num.substring(num.length - (4 * i + 3));

return (((sign) ? '' : '-') + '' + num + '.' + cents);

}

function isNumber(n) {

return !isNaN(parseFloat(n)) && isFinite(n);

}

var ids = {

ContEFundStart: '#<%= ContEFundStart.ClientID %>',

ContEFundEnd: '#<%= ContEFundEnd.ClientID %>'

};

var ContEFundBinder = function () {

var me = $(this);

var menoy = me.val();

if (menoy) {

var m = menoy.replace(/,/gi, "");

me.val((isNumber(m) && m > 0) ? formatCurrency(m) : '');

}

};

$(ids.ContEFundStart).focusout(ContEFundBinder);

$(ids.ContEFundEnd).focusout(ContEFundBinder);

});

</script>

</asp:Content>

57

5. ProfileSetting.aspx

<%@ Page Title="" Language="vb" AutoEventWireup="false"

MasterPageFile="~/Site.Master" CodeBehind="ProfileSetting.aspx.vb"

Inherits="Tai_Power.ProfileSetting" %>

<%@ Register src="UC/BinaryToggleView.ascx" tagname="BinaryToggleView"

tagprefix="uc1" %>

<%@ Import Namespace="Tai_Power" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">

<link href="/Styles/ProfileSetting.css" rel="stylesheet" type="text/css" />

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<div id="ProxyContent">

<div class="subTitle">

個人設定

</div>

<div class="subPanel">

<uc1:BinaryToggleView ID="BTVRealName" runat="server" >

<OpenViewTemplate>

<div class="fItem BTVDes">

<span class="fLabel">Name:</span>

<span class="fDes"><%# CType(Container,

ProfileRealNameContainer).RealName%></span>

<asp:LinkButton CommandName="Edit" ID="lbOpen"

runat="server" OnClick="EditRealName_Click"

CssClass="edit">Edit</asp:LinkButton>

</div>

</OpenViewTemplate>

<CloseViewTemplate>

<div class="fItem BTVInfos BTVRName">

<span class="fLabel">Name:</span>

<asp:TextBox ID="tbRealName"

CssClass="BTVRNameInput" runat="server" Text='<%# CType(Container,

ProfileRealNameContainer).RealName%>'></asp:TextBox>

<asp:LinkButton CommandName="Update"

ID="lbUpdate" runat="server"

OnClick="EditRealName_Click">Update</asp:LinkButton>

<asp:LinkButton CommandName="Cancel"

58

ID="lbCancel" runat="server"

OnClick="EditRealName_Click">Cancel</asp:LinkButton>

</div>

</CloseViewTemplate>

</uc1:BinaryToggleView>

</div>

<div class="subPanel">

<uc1:BinaryToggleView ID="BTVPassword" runat="server">

<OpenViewTemplate>

<div class="fItem BTVDes">

<span class="fLabel">Password:</span>

<asp:LinkButton CommandName="Edit" ID="lbOpen"

runat="server" OnClick="EditPwdButton_Click"

CssClass="edit">Edit</asp:LinkButton>

</div>

</OpenViewTemplate>

<CloseViewTemplate>

<div class="fItem BTVInfos BTVPwdInfo">

<span class="fLabel">Password:</span>

<asp:ChangePassword ID="ChangePassword1"

runat="server" ContinueButtonType="Link" CancelButtonType="Link"

ChangePasswordButtonType="Link" CssClass="CPwdTable"

OnContinueButtonClick="EditPwdContinueButton_Click"

OnChangedPassword="EditPwdChangedPasswordButton_Click">

<TextBoxStyle CssClass="BTVPwdInput" />

<TitleTextStyle CssClass="TitleText" />

<LabelStyle CssClass="InputLabel" />

<ChangePasswordButtonStyle

CssClass="ChangePasswordButton" />

<CancelButtonStyle CssClass="CancelButton" />

<ContinueButtonStyle

CssClass="ContinueButton"/>

</asp:ChangePassword>

</div>

</CloseViewTemplate>

</uc1:BinaryToggleView>

</div>

<div class="subPanel">

59

<uc1:BinaryToggleView ID="BTVChangeEMail" runat="server" >

<OpenViewTemplate>

<div class="fItem BTVDes">

<span class="fLabel">E-Mail:</span>

<span class="fDes"><%# CType(Container,

OVCUserEmail).EMail%></span>

<asp:LinkButton CommandName="Edit" ID="lbOpen"

runat="server" OnClick="EditEMailButton_Click"

CssClass="edit">Edit</asp:LinkButton>

</div>

</OpenViewTemplate>

<CloseViewTemplate>

<div class="fItem BTVInfos BTVEMailInfo">

<span class="fLabel">E-Mail:</span>

<asp:TextBox ID="tbEMail"

CssClass="BTVEMailInput" runat="server" Text='<%# CType(Container,

OVCUserEmail).EMail%>'></asp:TextBox>

<asp:LinkButton CommandName="Update"

ID="lbUpdate" runat="server"

OnClick="EditEMailButton_Click">Update</asp:LinkButton>

<asp:LinkButton CommandName="Cancel"

ID="lbCancel" runat="server"

OnClick="EditEMailButton_Click">Cancel</asp:LinkButton>

</div>

</CloseViewTemplate>

</uc1:BinaryToggleView>

</div>

</div>

</asp:Content>

60

6. ProxyGroupForm.aspx

<%@ Page Title="" Language="vb" AutoEventWireup="false"

MasterPageFile="~/MyWorksMasterPage.master"

CodeBehind="ProxyGroupForm.aspx.vb" Inherits="Tai_Power.ProxyGroupForm"

%>

<asp:Content ID="Content1" ContentPlaceHolderID="MyWorksHeader"

runat="server">

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MyWorksContent"

runat="server">

<asp:Label ID="Label1" runat="server" Text="選擇代理人"></asp:Label>

&nbsp;<asp:DropDownList ID="proxyCombo" runat="server"

DataTextField="UserName"

DataValueField="UserId">

<asp:ListItem Selected="True">請選擇</asp:ListItem>

</asp:DropDownList>

<asp:Button ID="btnAddProxy" runat="server" Text="加入" Height="21px" />

&nbsp;&nbsp;&nbsp;

<br />

<asp:GridView ID="proxyGroupResult" runat="server" CellPadding="4"

ForeColor="#333333" GridLines="None" AutoGenerateColumns="False"

DataSourceID="proxyGroupDS" AllowPaging="True">

<AlternatingRowStyle BackColor="White" />

<Columns>

<asp:TemplateField HeaderText="刪除" InsertVisible="False"

SortExpression="proxy_group_id">

<EditItemTemplate>

<asp:Label ID="Label1" runat="server" Text='<%#

Eval("proxy_group_id") %>'></asp:Label>

</EditItemTemplate>

<ItemTemplate>

<asp:Label ID="LabelA1" Visible="false" runat="server"

Text='<%# Eval("proxy_group_id") %>'></asp:Label>

<asp:LinkButton ID="LinkButton1" runat="server"

OnClientClick="return confirm('確認要刪除嗎?');" CommandName="Delete">刪

除</asp:LinkButton>

</ItemTemplate>

</asp:TemplateField>

61

<asp:BoundField DataField="proxy_user_name" HeaderText="代理人

姓名"

SortExpression="proxy_user_name" />

<asp:BoundField DataField="Column1" HeaderText="是否為代理人"

ReadOnly="True"

SortExpression="Column1" />

</Columns>

<EditRowStyle BackColor="#2461BF" />

<FooterStyle BackColor="#507CD1" Font-Bold="True"

ForeColor="White" />

<HeaderStyle BackColor="#507CD1" Font-Bold="True"

ForeColor="White" />

<PagerStyle BackColor="#2461BF" ForeColor="White"

HorizontalAlign="Center" />

<RowStyle BackColor="#EFF3FB" />

<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True"

ForeColor="#333333" />

<SortedAscendingCellStyle BackColor="#F5F7FB" />

<SortedAscendingHeaderStyle BackColor="#6D95E1" />

<SortedDescendingCellStyle BackColor="#E9EBEF" />

<SortedDescendingHeaderStyle BackColor="#4870BE" />

</asp:GridView>

<asp:SqlDataSource ID="proxyGroupDS" runat="server"

ConnectionString="<%$ ConnectionStrings:TestDataConnectionString %>"

SelectCommand="select proxy_group_id,proxy_user_name,case when

is_proxy = 'Y' then '是' else '否' end from proxy_usr_group where user_id=@uid"

DeleteCommand="delete proxy_usr_group where proxy_group_id =

@gid">

<DeleteParameters>

<asp:Parameter Name="gid" />

</DeleteParameters>

<SelectParameters>

<asp:Parameter Name="uid" />

</SelectParameters>

</asp:SqlDataSource>

</asp:Content>

62

7. ProxySettingForm.aspx

<%@ Page Title="" Language="vb" AutoEventWireup="false"

MasterPageFile="~/MyWorksMasterPage.master"

CodeBehind="ProxySettingForm.aspx.vb" Inherits="Tai_Power.setProxyForm" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MyWorksHeader"

runat="server">

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MyWorksContent"

runat="server">

<asp:GridView ID="proxyResult" runat="server" AllowPaging="True"

AutoGenerateColumns="False" DataSourceID="proxyUsrGroupDS"

CellPadding="4"

ForeColor="#333333" GridLines="None">

<AlternatingRowStyle BackColor="White" />

<Columns>

<asp:TemplateField HeaderText="選擇" InsertVisible="False"

SortExpression="proxy_group_id">

<EditItemTemplate>

<asp:Label ID="Label1" runat="server" Text='<%#

Eval("proxy_group_id") %>'></asp:Label>

</EditItemTemplate>

<ItemTemplate>

<input name="rowSelected" type="checkbox" value="<%#

Eval("proxy_group_id") %>" />

</ItemTemplate>

</asp:TemplateField>

<asp:BoundField DataField="proxy_user_name" HeaderText="代理人

姓名"

SortExpression="proxy_user_name" />

<asp:BoundField DataField="Column1" HeaderText="是否為代理人"

ReadOnly="True"

SortExpression="Column1" />

</Columns>

<EditRowStyle BackColor="#2461BF" />

<FooterStyle BackColor="#507CD1" Font-Bold="True"

ForeColor="White" />

<HeaderStyle BackColor="#507CD1" Font-Bold="True"

ForeColor="White" />

63

<PagerStyle BackColor="#2461BF" ForeColor="White"

HorizontalAlign="Center" />

<RowStyle BackColor="#EFF3FB" />

<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True"

ForeColor="#333333" />

<SortedAscendingCellStyle BackColor="#F5F7FB" />

<SortedAscendingHeaderStyle BackColor="#6D95E1" />

<SortedDescendingCellStyle BackColor="#E9EBEF" />

<SortedDescendingHeaderStyle BackColor="#4870BE" />

</asp:GridView>

<asp:SqlDataSource ID="proxyUsrGroupDS" runat="server"

ConnectionString="<%$ ConnectionStrings:TestDataConnectionString %>"

SelectCommand="select proxy_group_id,proxy_user_name,case when

is_proxy = 'Y' then '是' else '否' end from proxy_usr_group where user_id=@uid">

<SelectParameters>

<asp:Parameter Name="uid" />

</SelectParameters>

</asp:SqlDataSource>

<asp:Button ID="btnSetProxy" runat="server" Text="設定代理人" />

<asp:Button ID="btnResetProxy" runat="server" Text="解除代理人" />

</asp:Content>

64

8. ProxyWorkChoose.aspx

<%@ Page Title="" Language="vb" AutoEventWireup="false"

MasterPageFile="~/MyWorksMasterPage.master"

CodeBehind="ProxyWorkChoose.aspx.vb" Inherits="Tai_Power.ProxyWorkChoose"

%>

<asp:Content ID="Content1" ContentPlaceHolderID="MyWorksHeader"

runat="server">

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MyWorksContent"

runat="server">

<asp:GridView ID="ProxyWorkView" runat="server"

AutoGenerateColumns="False"

DataSourceID="SqlDataSource1" CellPadding="4" ForeColor="#333333"

GridLines="None">

<AlternatingRowStyle BackColor="White" />

<Columns>

<asp:TemplateField HeaderText="請選擇" SortExpression="UserId">

<EditItemTemplate>

<asp:TextBox ID="TextBox1" runat="server" Text='<%#

Bind("UserName") %>'></asp:TextBox>

</EditItemTemplate>

<ItemTemplate>

<input name="rowSelected" type="radio" value="<%#

Eval("UserName") %>" />

</ItemTemplate>

</asp:TemplateField>

<asp:BoundField DataField="UserName" HeaderText="被代理人姓

名"

SortExpression="UserName" />

</Columns>

<EditRowStyle BackColor="#2461BF" />

<FooterStyle BackColor="#507CD1" Font-Bold="True"

ForeColor="White" />

<HeaderStyle BackColor="#507CD1" Font-Bold="True"

ForeColor="White" />

<PagerStyle BackColor="#2461BF" ForeColor="White"

HorizontalAlign="Center" />

<RowStyle BackColor="#EFF3FB" />

65

<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True"

ForeColor="#333333" />

<SortedAscendingCellStyle BackColor="#F5F7FB" />

<SortedAscendingHeaderStyle BackColor="#6D95E1" />

<SortedDescendingCellStyle BackColor="#E9EBEF" />

<SortedDescendingHeaderStyle BackColor="#4870BE" />

</asp:GridView>

<asp:Button ID="btnProxyWork" runat="server" Text="執行代理工作" />

<asp:SqlDataSource ID="SqlDataSource1" runat="server"

ConnectionString="<%$ ConnectionStrings:UserRoleDBConnectString

%>"

SelectCommand="SELECT [UserId] ,[UserName] FROM

[vw_aspnet_Users]">

</asp:SqlDataSource>

</asp:Content>

66

9. QueryForm.aspx

<%@ Page Title="" Language="vb" AutoEventWireup="false"

MasterPageFile="~/MyWorksMasterPage.master"

CodeBehind="QueryForm.aspx.vb" Inherits="Tai_Power.QueryForm" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MyWorksHeader"

runat="server">

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MyWorksContent"

runat="server">

<asp:GridView ID="queryResultView" runat="server" CellPadding="4"

ForeColor="#333333" GridLines="None"

AllowPaging="True"

AllowSorting="True" >

<AlternatingRowStyle BackColor="White" />

<EditRowStyle BackColor="#2461BF" />

<FooterStyle BackColor="#507CD1" Font-Bold="True"

ForeColor="White" />

<HeaderStyle BackColor="#507CD1" Font-Bold="True"

ForeColor="White" />

<PagerStyle BackColor="#2461BF" ForeColor="White"

HorizontalAlign="Center" />

<RowStyle BackColor="#EFF3FB" />

<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True"

ForeColor="#333333" />

<SortedAscendingCellStyle BackColor="#F5F7FB" />

<SortedAscendingHeaderStyle BackColor="#6D95E1" />

<SortedDescendingCellStyle BackColor="#E9EBEF" />

<SortedDescendingHeaderStyle BackColor="#4870BE" />

</asp:GridView>

<asp:Label ID="noTableData" runat="server" Text="查無資料"></asp:Label>

</asp:Content>

67

10. Web.config

<?xml version="1.0"?>

<!--

如需如何設定 ASP.NET 應用程式的詳細資訊,請造訪

http://go.microsoft.com/fwlink/?LinkId=169433

-->

<configuration>

<!--TP用

<connectionStrings>

<add name="ApplicationServices" connectionString="Data

Source=localhost;Initial Catalog=aspnetdb;Persist Security Info=True;User

ID=tp;Password=qwer1234$$$;" providerName="System.Data.SqlClient"/>

<add name="TestDataConnectionString" connectionString="Data

Source=localhost;Persist Security Info=True;User ID=tp;Password=qwer1234$$$;"

providerName="System.Data.SqlClient"/>

<add name="TestDataEntities" connectionString="Data Source=localhost;Persist

Security Info=True;User ID=tp;Password=qwer1234$$$"

providerName="System.Data.EntityClient"/>

<add name="UserRoleDBConnectString" connectionString="Data

Source=localhost;Initial Catalog=aspnetdb;Persist Security Info=True;User

ID=tp;Password=qwer1234$$$;" providerName="System.Data.SqlClient"/>

</connectionStrings> -->

<!--Server 用

<connectionStrings>

<add name="ApplicationServices" connectionString="Server=localhost;

Database=aspnetdb; User ID=sa; Password=0988008421;

Trusted_Connection=False;"

providerName="System.Data.SqlClient" />

<add name="TestDataConnectionString" connectionString="Server=localhost;

Database=TestData; User ID=sa; Password=0988008421;

Trusted_Connection=False;"

providerName="System.Data.SqlClient" />

<add name="TestDataEntities" connectionString="data Source=localhost; Initial

Catalog=TestData; User ID=sa; Password=0988008421;"

providerName="System.Data.EntityClient" />

<add name="UserRoleDBConnectString" connectionString="Server=localhost;

Database=ASPNETDB; User ID=sa; Password=0988008421;

Trusted_Connection=False;"

providerName="System.Data.SqlClient" />

68

</connectionStrings>

-->

<!--開發用 -->

<connectionStrings>

<add name="ApplicationServices" connectionString="data

source=.\SQLEXPRESS;Integrated

Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"

providerName="System.Data.SqlClient"/>

<add name="TestDataConnectionString" connectionString="Data

Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\TestData.mdf;Integrate

d Security=True;User Instance=True" providerName="System.Data.SqlClient"/>

<add name="TestDataEntities"

connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.

msl;provider=System.Data.SqlClient;provider connection string=&quot;Data

Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\TestData.mdf;Integrate

d Security=True;User Instance=True;MultipleActiveResultSets=True&quot;"

providerName="System.Data.EntityClient"/>

<add name="UserRoleDBConnectString" connectionString="Data

Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Inte

grated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>

</connectionStrings>

<system.web>

<httpRuntime maxRequestLength="1048576" executionTimeout="150"/>

<customErrors defaultRedirect="~/ErrorPage.aspx" mode="Off"/>

<!-- <httpModules>

<add type="System.Web.SessionStateModule" name="Session"/>

</httpModules>-->

<compilation strict="false" explicit="true" targetFramework="4.0"

debug="true">

<assemblies>

<add assembly="System.Transactions, Version=2.0.0.0, Culture=neutral,

PublicKeyToken=b77a5c561934e089"/>

<add assembly="System.Web.Entity, Version=4.0.0.0, Culture=neutral,

PublicKeyToken=B77A5C561934E089"/>

<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral,

PublicKeyToken=b77a5c561934e089"/>

<add assembly="System.Design, Version=4.0.0.0, Culture=neutral,

PublicKeyToken=B03F5F7F11D50A3A"/>

69

<add assembly="System.Web.Extensions.Design, Version=4.0.0.0,

Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral,

PublicKeyToken=B77A5C561934E089"/>

</assemblies>

</compilation>

<authentication mode="Forms">

<forms loginUrl="~/Account/Login.aspx" defaultUrl="~/Default.aspx"

timeout="2880"/>

</authentication>

<membership>

<providers>

<clear/>

<add name="AspNetSqlMembershipProvider"

type="System.Web.Security.SqlMembershipProvider"

connectionStringName="ApplicationServices" enablePasswordRetrieval="false"

enablePasswordReset="true" requiresQuestionAndAnswer="false"

requiresUniqueEmail="false" maxInvalidPasswordAttempts="5"

minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0"

passwordAttemptWindow="10" applicationName="/"/>

</providers>

</membership>

<profile enabled="true" defaultProvider="AspNetSqlProfileProvider"

inherits="Tai_Power.ProfileProxy">

<providers>

<clear/>

<add name="AspNetSqlProfileProvider"

type="System.Web.Profile.SqlProfileProvider"

connectionStringName="ApplicationServices" applicationName="/"/>

</providers>

</profile>

<roleManager enabled="true">

<providers>

<clear/>

<add connectionStringName="ApplicationServices" applicationName="/"

name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider"/>

<add applicationName="/" name="AspNetWindowsTokenRoleProvider"

type="System.Web.Security.WindowsTokenRoleProvider"/>

70

</providers>

</roleManager>

<globalization fileEncoding="utf-8" requestEncoding="utf-8"

responseEncoding="utf-8"/>

</system.web>

<system.webServer>

<modules runAllManagedModulesForAllRequests="true"/>

</system.webServer>

</configuration>

71

11. ChangePassword.aspx

<%@ Page Title="變更密碼" Language="vb" MasterPageFile="~/Site.Master"

AutoEventWireup="false"

CodeBehind="ChangePassword.aspx.vb"

Inherits="Tai_Power.ChangePassword" %>

<asp:Content ID="HeaderContent" runat="server"

ContentPlaceHolderID="HeadContent">

</asp:Content>

<asp:Content ID="BodyContent" runat="server"

ContentPlaceHolderID="MainContent">

<h2>

變更密碼

</h2>

<p>

使用下面的表單變更您的密碼。

</p>

<p>

新密碼長度至少要有 <%= Membership.MinRequiredPasswordLength

%> 個字元。

</p>

<asp:ChangePassword ID="ChangeUserPassword" runat="server"

CancelDestinationPageUrl="~/" EnableViewState="false" RenderOuterTable="false"

SuccessPageUrl="ChangePasswordSuccess.aspx">

<ChangePasswordTemplate>

<span class="failureNotification">

<asp:Literal ID="FailureText" runat="server"></asp:Literal>

</span>

<asp:ValidationSummary

ID="ChangeUserPasswordValidationSummary" runat="server"

CssClass="failureNotification"

ValidationGroup="ChangeUserPasswordValidationGroup"/>

<div class="accountInfo">

<fieldset class="changePassword">

<legend>帳戶資訊</legend>

<p>

<asp:Label ID="CurrentPasswordLabel" runat="server"

AssociatedControlID="CurrentPassword">舊密碼:</asp:Label>

72

<asp:TextBox ID="CurrentPassword" runat="server"

CssClass="passwordEntry" TextMode="Password"></asp:TextBox>

<asp:RequiredFieldValidator

ID="CurrentaPasswordRequired" runat="server"

ControlToValidate="CurrentPassword"

CssClass="failureNotification" ErrorMessage="

必須提供密碼。" ToolTip="必須提供舊密碼。"

ValidationGroup="ChangeUserPasswordValidationGroup">*</asp:RequiredFieldVali

dator>

</p>

<p>

<asp:Label ID="NewPasswordLabel" runat="server"

AssociatedControlID="NewPassword">新密碼:</asp:Label>

<asp:TextBox ID="NewPassword" runat="server"

CssClass="passwordEntry" TextMode="Password"></asp:TextBox>

<asp:RequiredFieldValidator

ID="NewPasswordRequired" runat="server" ControlToValidate="NewPassword"

CssClass="failureNotification" ErrorMessage="

必須提供新密碼。" ToolTip="必須提供新密碼。"

ValidationGroup="ChangeUserPasswordValidationGroup">*</asp:RequiredFieldVali

dator>

</p>

<p>

<asp:Label ID="ConfirmNewPasswordLabel"

runat="server" AssociatedControlID="ConfirmNewPassword">確認新密

碼:</asp:Label>

<asp:TextBox ID="ConfirmNewPassword"

runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox>

<asp:RequiredFieldValidator

ID="ConfirmNewPasswordRequired" runat="server"

ControlToValidate="ConfirmNewPassword"

CssClass="failureNotification"

Display="Dynamic" ErrorMessage="必須確認新密碼。"

ToolTip="必須確認新密碼。"

ValidationGroup="ChangeUserPasswordValidationGroup">*</asp:RequiredFieldVali

dator>

73

<asp:CompareValidator ID="NewPasswordCompare"

runat="server" ControlToCompare="NewPassword"

ControlToValidate="ConfirmNewPassword"

CssClass="failureNotification"

Display="Dynamic" ErrorMessage="確認新密碼必須與新密碼項目相符。"

ValidationGroup="ChangeUserPasswordValidationGroup">*</asp:CompareValidator

>

</p>

</fieldset>

<p class="submitButton">

<asp:Button ID="CancelPushButton" runat="server"

CausesValidation="False" CommandName="Cancel" Text="取消"/>

<asp:Button ID="ChangePasswordPushButton"

runat="server" CommandName="ChangePassword" Text="變更密碼"

ValidationGroup="ChangeUserPasswordValidationGroup"/>

</p>

</div>

</ChangePasswordTemplate>

</asp:ChangePassword>

</asp:Content>

74

12. ChangePasswordSuccess.aspx

<%@ Page Title="變更密碼" Language="vb" MasterPageFile="~/Site.Master"

AutoEventWireup="false"

CodeBehind="ChangePasswordSuccess.aspx.vb"

Inherits="Tai_Power.ChangePasswordSuccess" %>

<asp:Content ID="HeaderContent" runat="server"

ContentPlaceHolderID="HeadContent">

</asp:Content>

<asp:Content ID="BodyContent" runat="server"

ContentPlaceHolderID="MainContent">

<h2>

變更密碼

</h2>

<p>

您的密碼已順利變更。

</p>

</asp:Content>

75

13. Login.aspx

<%@ Page Title="登入" Language="vb" MasterPageFile="~/Site.Master"

AutoEventWireup="false"

CodeBehind="Login.aspx.vb" Inherits="Tai_Power.Login" %>

<asp:Content ID="HeaderContent" runat="server"

ContentPlaceHolderID="HeadContent">

</asp:Content>

<asp:Content ID="BodyContent" runat="server"

ContentPlaceHolderID="MainContent">

<h2>

登入

</h2>

<p>

請輸入您的使用者名稱和密碼。

<asp:HyperLink ID="RegisterHyperLink" runat="server"

EnableViewState="false">註冊</asp:HyperLink> (如果您沒有帳戶)

</p>

<asp:Login ID="LoginUser" runat="server" EnableViewState="false"

RenderOuterTable="false">

<LayoutTemplate>

<span class="failureNotification">

<asp:Literal ID="FailureText" runat="server"></asp:Literal>

</span>

<asp:ValidationSummary ID="LoginUserValidationSummary"

runat="server" CssClass="failureNotification"

ValidationGroup="LoginUserValidationGroup"/>

<div class="accountInfo">

<fieldset class="login">

<legend>帳戶資訊</legend>

<p>

<asp:Label ID="UserNameLabel" runat="server"

AssociatedControlID="UserName">使用者名稱:</asp:Label>

<asp:TextBox ID="UserName" runat="server"

CssClass="textEntry"></asp:TextBox>

<asp:RequiredFieldValidator ID="UserNameRequired"

runat="server" ControlToValidate="UserName"

76

CssClass="failureNotification" ErrorMessage="

必須提供使用者名稱。" ToolTip="必須提供使用者名稱。"

ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>

</p>

<p>

<asp:Label ID="PasswordLabel" runat="server"

AssociatedControlID="Password">密碼:</asp:Label>

<asp:TextBox ID="Password" runat="server"

CssClass="passwordEntry" TextMode="Password"></asp:TextBox>

<asp:RequiredFieldValidator ID="PasswordRequired"

runat="server" ControlToValidate="Password"

CssClass="failureNotification" ErrorMessage="

必須提供密碼。" ToolTip="必須提供密碼。"

ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>

</p>

<p>

<asp:CheckBox ID="RememberMe" runat="server"/>

<asp:Label ID="RememberMeLabel" runat="server"

AssociatedControlID="RememberMe" CssClass="inline">讓我保持登入

</asp:Label>

</p>

</fieldset>

<p class="submitButton">

<asp:Button ID="LoginButton" runat="server"

CommandName="Login" Text="登入"

ValidationGroup="LoginUserValidationGroup"/>

</p>

</div>

</LayoutTemplate>

</asp:Login>

</asp:Content>

77

14. Register.aspx

<%@ Page Title="註冊" Language="vb" MasterPageFile="~/Site.Master"

AutoEventWireup="false"

CodeBehind="Register.aspx.vb" Inherits="Tai_Power.Register" %>

<asp:Content ID="HeaderContent" runat="server"

ContentPlaceHolderID="HeadContent">

</asp:Content>

<asp:Content ID="BodyContent" runat="server"

ContentPlaceHolderID="MainContent">

<asp:CreateUserWizard ID="RegisterUser" runat="server"

EnableViewState="false">

<LayoutTemplate>

<asp:PlaceHolder ID="wizardStepPlaceholder"

runat="server"></asp:PlaceHolder>

<asp:PlaceHolder ID="navigationPlaceholder"

runat="server"></asp:PlaceHolder>

</LayoutTemplate>

<WizardSteps>

<asp:CreateUserWizardStep ID="RegisterUserWizardStep"

runat="server">

<ContentTemplate>

<h2>

建立新帳戶

</h2>

<p>

使用下面的表單建立新帳戶。

</p>

<p>

密碼長度至少要有 <%=

Membership.MinRequiredPasswordLength %> 個字元。

</p>

<span class="failureNotification">

<asp:Literal ID="ErrorMessage"

runat="server"></asp:Literal>

</span>

<asp:ValidationSummary

ID="RegisterUserValidationSummary" runat="server" CssClass="failureNotification"

ValidationGroup="RegisterUserValidationGroup"/>

78

<div class="accountInfo">

<fieldset class="register">

<legend>帳戶資訊</legend>

<p>

<asp:Label ID="UserNameLabel"

runat="server" AssociatedControlID="UserName">使用者名稱:</asp:Label>

<asp:TextBox ID="UserName"

runat="server" CssClass="textEntry"></asp:TextBox>

<asp:RequiredFieldValidator

ID="UserNameRequired" runat="server" ControlToValidate="UserName"

CssClass="failureNotification"

ErrorMessage="必須提供使用者名稱。" ToolTip="必須提供使用者名稱。"

ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>

</p>

<p>

<asp:Label ID="EmailLabel" runat="server"

AssociatedControlID="Email">電子郵件:</asp:Label>

<asp:TextBox ID="Email" runat="server"

CssClass="textEntry"></asp:TextBox>

<asp:RequiredFieldValidator

ID="EmailRequired" runat="server" ControlToValidate="Email"

CssClass="failureNotification"

ErrorMessage="必須提供電子郵件。" ToolTip="必須提供電子郵件。"

ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>

</p>

<p>

<asp:Label ID="PasswordLabel"

runat="server" AssociatedControlID="Password">密碼:</asp:Label>

<asp:TextBox ID="Password" runat="server"

CssClass="passwordEntry" TextMode="Password"></asp:TextBox>

<asp:RequiredFieldValidator

ID="PasswordRequired" runat="server" ControlToValidate="Password"

CssClass="failureNotification"

ErrorMessage="必須提供密碼。" ToolTip="必須提供密碼。"

ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>

79

</p>

<p>

<asp:Label ID="ConfirmPasswordLabel"

runat="server" AssociatedControlID="ConfirmPassword">確認密碼:</asp:Label>

<asp:TextBox ID="ConfirmPassword"

runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox>

<asp:RequiredFieldValidator

ControlToValidate="ConfirmPassword" CssClass="failureNotification"

Display="Dynamic"

ErrorMessage="必須提供確認密碼。"

ID="ConfirmPasswordRequired" runat="server"

ToolTip="必須提供確認密碼。"

ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>

<asp:CompareValidator

ID="PasswordCompare" runat="server" ControlToCompare="Password"

ControlToValidate="ConfirmPassword"

CssClass="failureNotification"

Display="Dynamic" ErrorMessage="密碼和確認密碼必須相符。"

ValidationGroup="RegisterUserValidationGroup">*</asp:CompareValidator>

</p>

</fieldset>

<p class="submitButton">

<asp:Button ID="CreateUserButton"

runat="server" CommandName="MoveNext" Text="建立使用者"

ValidationGroup="RegisterUserValidationGroup"/>

</p>

</div>

</ContentTemplate>

<CustomNavigationTemplate>

</CustomNavigationTemplate>

</asp:CreateUserWizardStep>

</WizardSteps>

</asp:CreateUserWizard>

</asp:Content>

80

15. PAPIFileDownload.ashx

Imports System.Web

Imports System.Web.Services

Imports Tai_Power.UploadFile

Public Class PAPIFileDownload

Implements System.Web.IHttpHandler

Implements IRequiresSessionState

Sub ProcessRequest(ByVal context As HttpContext) Implements

IHttpHandler.ProcessRequest

Dim fbKey As String = context.Request.QueryString("key")

If fbKey IsNot Nothing Then

Dim fb As DownloadFile.FileBundle = context.Session(fbKey)

If fb IsNot Nothing Then

context.Session.Remove(fbKey)

context.Response.ContentType = "application/octet-stream"

context.Response.HeaderEncoding =

System.Text.Encoding.GetEncoding("big5")

context.Response.AppendHeader("Content-Disposition",

"attachment; filename=" + HttpUtility.UrlEncode(fb.FileName) + "." +

fb.FileExt.Name.ToLower)

'Dim fLoc As New PAPIFileLocality(New Guid(fb.ProjectID),

New Guid(fb.FileID))

'context.Response.TransmitFile(context.Server.MapPath(fLoc.FilePath))

context.Response.TransmitFile(context.Server.MapPath(fb.Locality.FilePath))

Exit Sub

End If

End If

ErrorIdentity.RedirectErrorPageWithMessage(context, "檔案下載發生錯

誤!")

End Sub

ReadOnly Property IsReusable() As Boolean Implements

IHttpHandler.IsReusable

Get

81

Return False

End Get

End Property

Public Class FileBundle

Public Property ProjectID As String

Public Property FileID As String

Public Property FileName As String

Public Property FileExt As UploadFileExt

Public Shared Sub saveFileBundle(ByVal p As Page, ByVal key As String,

ByVal bundle As FileBundle)

p.Session.Add(key, bundle)

End Sub

End Class

End Class

82

16. AssignmentDateTime.vb

Namespace AssignmentDateTime

Public Class DayState

Inherits GenericEnumTable(Of DSType)

Public Enum DSType

AM = 1

PM

End Enum

Shared Sub New()

If mEnumTable Is Nothing OrElse mEnumTable.Count < 1 Then

mEnumTable = mCreateDataTable()

End If

End Sub

Private Shared Function mCreateDataTable() As Dictionary(Of DSType,

String)

Dim tab As New Dictionary(Of DSType, String)

tab.Add(DSType.AM, "上午")

tab.Add(DSType.PM, "下午")

Return tab

End Function

Public Shared Function isValid(ByVal ds As Integer) As Boolean

Return (ds > 0 AndAlso ds < 4)

End Function

Public Shared Function parseToStringList(ByVal ds As Integer) As IList(Of

String)

Dim dsList As New List(Of String)

If isValid(ds) Then

Dim dsValue As Integer

Dim eValues As Array = [Enum].GetValues(GetType(DSType))

Array.Reverse(eValues)

For i As Integer = 0 To eValues.Length - 1

dsValue = eValues(i)

83

If ds >= dsValue Then

If mEnumTable.ContainsKey(dsValue) Then

dsList.Add(mEnumTable.Item(dsValue))

ds -= dsValue

End If

Next

End If

If dsList.Count > 1 Then dsList.Reverse()

Return dsList

End Function

End Class

End Namespace

84

17. CalDate.vb

Namespace CalDate

Public Class DateString

Public Property Value As String

Public Sub New(ByVal ds As String)

Value = ds

End Sub

Public Function isValid() As Boolean

Return isValid(Value)

End Function

Public Function toDate() As Date

Return toDate(Value)

End Function

Public Shared Function isValid(ByVal ds As String, Optional ByRef di As

Date = Nothing) As Boolean

Return Not String.IsNullOrEmpty(ds) AndAlso Date.TryParse(ds, di)

End Function

Public Shared Function toDate(ByVal ds As String) As Date

toDate = New Date

If Not isValid(ds, toDate) Then toDate = Nothing

End Function

Public Shared Function getDayList(ByVal ds As String, ByVal de As String)

As List(Of String)

Dim dStart As Date = toDate(ds)

Dim dEnd As Date = toDate(de)

Dim dList As New List(Of String)

Dim days As Integer

If dEnd > dStart Then

days = (dEnd - dStart).Days

For i = 0 To days

85

dList.Add(dStart.AddDays(i).ToShortDateString())

Next

ElseIf dEnd = dStart Then

dList.Add(ds)

End If

Return dList

End Function

End Class

End Namespace

86

18. DataSourceProvider.vb

Imports System.Web.Configuration

Namespace DataSourceProvider

Public Class SqlDataSourceBase

Protected mSqlDataSource As SqlDataSource

Protected mConfigConnectionString As String

Public Property Source As SqlDataSource

Get

Return mSqlDataSource

End Get

Set(ByVal value As SqlDataSource)

mSqlDataSource = value

End Set

End Property

End Class

Public Class WorkDataSource

Inherits SqlDataSourceBase

Public Shared Shadows mConfigConnectionString As String =

"TestDataConnectionString"

Public Shared ConfigConnectionString As String =

WebConfigurationManager.ConnectionStrings(mConfigConnectionString).Connectio

nString()

Protected Sub New()

mSqlDataSource = New SqlDataSource

mSqlDataSource.ConnectionString =

WebConfigurationManager.ConnectionStrings(mConfigConnectionString).Connectio

nString()

End Sub

Public Function selectData() As IEnumerable

Return mSqlDataSource.Select(New DataSourceSelectArguments())

End Function

87

End Class

Public Class WorkDataSourceDataSet

Inherits WorkDataSource

Friend Sub New()

MyBase.New()

mSqlDataSource.DataSourceMode = SqlDataSourceMode.DataSet

End Sub

End Class

Public Class WorkDataSourceReader

Inherits WorkDataSource

Friend Sub New()

MyBase.New()

mSqlDataSource.DataSourceMode = SqlDataSourceMode.DataReader

End Sub

End Class

Public Class WorkDataSourceFactory

Public Shared Function createReader() As WorkDataSource

Return New WorkDataSourceReader

End Function

Public Shared Function createDataSet() As WorkDataSource

Return New WorkDataSourceDataSet

End Function

End Class

End Namespace

88

19. Entity.vb

Imports Tai_Power.SectionClassIdentity

Namespace Entity

Public Class IDNamePair

Protected mID As Guid

Protected mName As String

Public Property ID As Guid

Get

Return mID

End Get

Set(ByVal value As Guid)

mID = value

End Set

End Property

Public Property Name As String

Get

Return mName

End Get

Set(ByVal value As String)

mName = value

End Set

End Property

End Class

Public Class User

Inherits IDNamePair

Public Sub New(ByVal id As String, ByVal name As String)

Guid.TryParse(id, mID)

mName = name

End Sub

Public Sub New(ByVal id As Guid, ByVal name As String)

mID = id

mName = name

89

End Sub

Public Sub New(ByVal ent As User)

mID = ent.ID

mName = ent.Name

End Sub

End Class

Public Class SectionClassUser

Inherits User

Public Property ClassValue As SClass

Public Sub New(ByVal id As Guid, ByVal name As String)

MyBase.New(id, name)

End Sub

Public Sub New(ByVal id As String, ByVal name As String)

MyBase.New(id, name)

End Sub

Public Sub New(ByVal u As User)

MyBase.New(u)

End Sub

End Class

Public Class SectionClass

Inherits IDNamePair

Public Property Value As Integer

Public Sub New(ByVal id As String, ByVal name As String)

Guid.TryParse(id, mID)

mName = name

End Sub

90

Public Sub New(ByVal id As Guid, ByVal name As String)

mID = id

mName = name

End Sub

End Class

End Namespace

91

20. ErrorIdentity.vb

Public Class ErrorIdentity

Public Shared ErrorResourceClass As New String("ErrorDifinition")

Public Shared ErrorFormID As String = Guid.NewGuid().ToString()

Public Shared UserErrorMessageKey As String = "_UserErrorMessageKey"

Public Class ErrorType

Public Shared NoPermission As New String("06021")

Public Shared MultiPermission As New String("06022")

Public Shared ErrorRolePermission As New String("06023")

Public Shared NoRoleExistence As New String("06031")

End Class

Public Shared Sub RedirectErrorPageWithMessage(ByVal p As HttpContext,

ByVal userMsg As String)

Dim msg As String = Trim(userMsg)

If Not String.IsNullOrEmpty(msg) Then

p.Session(UserErrorMessageKey) = msg

p.Response.Redirect("~/ErrorPage.aspx")

End If

End Sub

Public Shared Sub RedirectErrorPageWithMessage(ByVal p As Page, ByVal

userMsg As String)

Dim msg As String = Trim(userMsg)

If Not String.IsNullOrEmpty(msg) Then

p.Session(UserErrorMessageKey) = msg

p.Response.Redirect("~/ErrorPage.aspx")

End If

End Sub

Public Shared Sub RedirectErrorPage(ByVal p As Page)

RedirectErrorPage(p, Nothing)

End Sub

Public Shared Sub RedirectErrorPage(ByVal p As Page, ByVal type As String)

If type IsNot Nothing Then p.Session(ErrorFormID) = "E" + type

p.Response.Redirect("~/ErrorPage.aspx")

92

End Sub

Public Shared ReadOnly Property ErrorID(ByVal p As Page) As String

Get

Return p.Session(ErrorFormID)

End Get

End Property

Public Shared ReadOnly Property UserErrorMessage(ByVal p As Page) As

String

Get

Dim msg As String = p.Session(UserErrorMessageKey)

p.Session.Remove(UserErrorMessageKey)

Return msg

End Get

End Property

End Class

93

21. GenericEnumTable.vb

Imports System.Reflection

Imports System.Runtime.CompilerServices

Imports Tai_Power.ProjectAcceptanceAssignment

Public Class EnumReflector(Of ET)

Public Function parseEnumType(ByVal eStr As String, ByVal eDel As Action(Of

ET), Optional ByVal del As Action(Of String) = Nothing) As ET

Try

If eDel IsNot Nothing Then eDel.Invoke(getEnumType(eStr))

Catch ex As Exception

If del IsNot Nothing Then del.Invoke(eStr)

End Try

End Function

Public Function getEnumType(ByVal eStr As String) As ET

If Not String.IsNullOrEmpty(eStr) Then

Dim eType As Type = GetType(ET)

Dim fInfo As FieldInfo = eType.GetFields.Where(Function(act)

act.Name = eStr).FirstOrDefault()

If Not fInfo Is Nothing Then

Return [Enum].ToObject(eType, fInfo.GetValue(Nothing))

End If

End If

Throw New Exception("Error Enum String")

End Function

End Class

Public Class ReflectingEnumNameTable(Of ET)

Inherits GenericEnumTable(Of String, ET)

Protected Shared mTable As Dictionary(Of String, ET)

Shared Sub New()

If mTable Is Nothing OrElse mTable.Count < 1 Then

mTable = mCreateDataTable()

94

End If

End Sub

Private Shared Function mCreateDataTable() As Dictionary(Of String, ET)

Dim tab As New Dictionary(Of String, ET)

For Each fi As FieldInfo In GetType(ET).GetFields()

If fi.IsLiteral Then

tab.Add(fi.Name, [Enum].ToObject(GetType(ET),

fi.GetValue(Nothing)))

End If

Next

Return tab

End Function

Public Overrides Property DataTable As Dictionary(Of String, ET)

Get

Return mTable

End Get

Set(ByVal value As Dictionary(Of String, ET))

mTable = value

End Set

End Property

End Class

Public Class EnumList

Inherits List(Of [Enum])

Public Const DefaultSpliter As String = ", "

Public DefaultValueStringFilter As Func(Of [Enum], Boolean) = Function(e As

[Enum]) True

Public Sub New(ByVal ParamArray es() As [Enum])

es.ForEach(Sub(e) Me.Add(e))

End Sub

95

Public Function toValueString() As String

Return toValueString(DefaultValueStringFilter, DefaultSpliter)

End Function

Public Function toValueString(ByVal filter As Func(Of [Enum], Boolean), ByVal

spliter As String) As String

Dim tList As New List(Of String)

Dim et As Type = GetType([Enum])

Me.ForEach(Sub(e As [Enum]) If filter.Invoke(e) Then

tList.Add(e.toIntString()))

Return String.Join(spliter, tList)

End Function

Public Overloads Function contains(ev As Integer) As Boolean

For Each e As [Enum] In Me

If e.toIntValue = ev Then Return True

Next

Return False

End Function

Public Function toValueString(Of T)(Optional ByVal spliter As String =

DefaultSpliter) As String

Return toValueString(Function(e As [Enum]) TypeOf e Is T, spliter)

End Function

End Class

Module IndexEnumExtension

Private mIndexEnumTable As New Dictionary(Of String, Object)

<Extension()>

Public Function IndexedName(ByVal e As [Enum]) As String

Return e.GetType().ToString() + "@" + e.Name()

End Function

<Extension()>

Public Sub setIndexValue(ByVal e As [Enum], ByVal value As Object)

Dim id As String = e.IndexedName()

96

If mIndexEnumTable.ContainsKey(id) Then

mIndexEnumTable(id) = value

Else

mIndexEnumTable.Add(id, value)

End If

End Sub

<Extension()>

Public Function IndexValue(ByVal e As [Enum]) As Object

Dim id As String = e.IndexedName()

Return IIf(mIndexEnumTable.ContainsKey(id), mIndexEnumTable(id),

Nothing)

End Function

End Module

Module CommonEnumExtension

<Extension()>

Public Function Name(ByVal e As [Enum]) As String

Return [Enum].GetName(e.GetType(), e)

End Function

<Extension()>

Public Function EnumValue(Of T As {Structure, IConvertible})(ByVal es As

String) As T

Dim eType As Type = GetType(T)

If eType.IsEnum Then

Return [Enum].Parse(eType, es)

End If

Return Nothing

End Function

<Extension()>

Public Function toIntValue(ByVal e As [Enum]) As Integer

Dim name As String = e.Name

If Not String.IsNullOrEmpty(name) Then

Dim fi As FieldInfo = e.GetType().GetField(name)

97

Return CType(fi.GetValue(Nothing), Integer)

End If

Return Nothing

End Function

<Extension()>

Public Function toIntString(ByVal e As [Enum]) As String

Return e.toIntValue.ToString()

End Function

<Extension()>

Public Function Attribute(Of T As Attribute)(ByVal e As [Enum]) As T

Dim fInfo As FieldInfo = e.GetType().GetField(e.Name())

Return fInfo.GetCustomAttributes(GetType(T), False).Cast(Of

T)().FirstOrDefault()

End Function

<Extension()>

Public Function ResString(Of T)(ByVal e As [Enum]) As String

Return e.ResString(Of T)(e.Name)

End Function

<Extension()>

Public Function ResString(Of T)(ByVal e As [Enum], ByVal key As String) As

String

Dim resType As Type = GetType(T)

If resType.Namespace = "Tai_Power.Resources" Then

Return HttpContext.GetGlobalResourceObject(resType.Name,

key).ToString()

End If

Return String.Empty

End Function

End Module

Public MustInherit Class GenericEnumTable(Of E, ET)

98

Public Function isInTable(ByVal e As E) As Boolean

Return DataTable.ContainsKey(e)

End Function

Public Function getEnumType(ByVal e As E) As Object

If DataTable.ContainsKey(e) Then

Return DataTable(e)

End If

Return Nothing

End Function

Public MustOverride Property DataTable As Dictionary(Of E, ET)

End Class

Public MustInherit Class GenericEnumValueTable(Of ET, V)

Inherits GenericEnumTable(Of ET, V)

End Class

Public Class GenericEnumTable(Of ET)

Inherits GenericEnumValueTable(Of ET, String)

Protected Shared mEnumTable As Dictionary(Of ET, String)

Public Overrides Property DataTable As

System.Collections.Generic.Dictionary(Of ET, String)

Get

Return mEnumTable

End Get

Set(ByVal value As System.Collections.Generic.Dictionary(Of ET, String))

mEnumTable = value

End Set

End Property

End Class

99

22. GlobalResourceHelper.vb

Namespace Resource

Public Class GlobalResourceHelper

Private mGlobalResourceType As Type = Nothing

Public Property KeyProvider As IResourceKeyProvider

Public WriteOnly Property GlobalResourceType As Type

Set(ByVal value As Type)

mGlobalResourceType = value

End Set

End Property

Public Function getResourceValue(ByVal kp As IResourceKeyProvider) As

String

KeyProvider = kp

Return getResourceValue()

End Function

Public Function getResourceValue() As String

Return getResourceValue(mGlobalResourceType.Name,

KeyProvider.getKey)

End Function

Public Function getResourceValue(ByVal key As String) As String

Return getResourceValue(mGlobalResourceType.Name, key)

End Function

Public Shared Function getResourceValue(ByVal grt As Type, ByVal kp As

IResourceKeyProvider) As String

Return getResourceValue(grt.Name, kp.getKey)

End Function

Public Shared Function getResourceValue(ByVal grts As String, ByVal key

As String) As String

Try

If Not (grts Is Nothing OrElse key Is Nothing) Then

Return HttpContext.GetGlobalResourceObject(grts,

key).ToString()

100

End If

Catch ex As Exception

End Try

Return Nothing

End Function

End Class

Public Interface IResourceKeyProvider

Function getKey() As String

End Interface

Public Class ResourceKeyProvider

Implements IResourceKeyProvider

Public Property Key As String

Public Function getKey() As String Implements

IResourceKeyProvider.getKey

Return Key

End Function

End Class

Public MustInherit Class EnumResourceKeyProvider(Of T)

Inherits ResourceKeyProvider

Public Sub chooseKey(ByVal keyType As T)

key = createKey(keyType)

End Sub

Public Sub chooseKey(ByVal keyStr As String)

Dim e As T = [Enum].Parse(GetType(T), keyStr)

chooseKey(e)

End Sub

101

Public MustOverride Function createKey(ByVal e As T) As String

End Class

End Namespace

102

23. RoleIdentity.vb

Imports System.Reflection

Public Class RoleIdentity

Public Enum Role As Integer

Anonymous = 0

HandlingUnit = 1

Inspector

Superintendent

Leader

DeputyDirector

Director

SiteManager

All 'include the account with no role

AllRoles

End Enum

Public Shared RoleDictionary As New Dictionary(Of String, Role)

Shared Sub New()

For Each fi As FieldInfo In GetType(Role).GetFields()

If fi.IsLiteral Then

RoleDictionary.Add(fi.Name, [Enum].ToObject(GetType(Role),

fi.GetValue(Nothing)))

End If

Next

End Sub

Public Shared Function filterRoles(ByVal rs As IEnumerable(Of String)) As

IEnumerable(Of String)

Dim ier As IEnumerator(Of String) = rs.GetEnumerator()

Dim ls As New List(Of String)

While ier.MoveNext

If RoleDictionary.ContainsKey(ier.Current) Then

ls.Add(ier.Current)

End If

103

End While

Return ls

End Function

Public Shared Function isInRoles(ByVal r As String) As Boolean

Return RoleDictionary.ContainsKey(r)

End Function

Public Shared Function getRoleType(ByVal r As String) As Role

If RoleDictionary.ContainsKey(r) Then

Return RoleDictionary(r)

End If

Return Role.Anonymous

End Function

End Class

104

24. SectionClassIdentity.vb

Imports Tai_Power.Entity

Imports Tai_Power.SqlCommands

Imports System.Data.SqlClient

Public Class SectionClassIdentity

Inherits GenericEnumValueTable(Of SClass, SectionClass)

Protected Shared mTable As Dictionary(Of SClass, SectionClass)

Public Enum SClass As Integer

Architecture = 1

Civil = 2

Electrical = 4

Mechanical = 8

End Enum

Shared Sub New()

If mTable Is Nothing OrElse mTable.Count < 1 Then

mTable = mCreateDataTable()

End If

End Sub

Private Shared Function mCreateDataTable() As Dictionary(Of SClass,

SectionClass)

Dim cmd As New SqlReaderCommand

Dim helper As New BaseSqlCommandHelper With {.Instance =

cmd, .CommandText = "Select ClassID, ClassName, ClassValue From SectionClass"}

cmd.ReadHandler = Function(reader As SqlDataReader) As Object

If reader IsNot Nothing Then

Dim tab As New Dictionary(Of SClass,

SectionClass)

While reader.Read

tab.Add(reader.GetInt32(2), New

SectionClass(reader.GetGuid(0), reader.GetString(1)))

End While

If tab.Count > 0 Then Return tab

End If

Return Nothing

105

End Function

'tab.Add(SClass.Architecture, "建築")

'tab.Add(SClass.Civil, "土木")

'tab.Add(SClass.Electrical, "電機")

'tab.Add(SClass.Mechanical, "機械")

Return SqlCommandLauncher.exec(helper)

End Function

Public Overrides Property DataTable As Dictionary(Of SClass, SectionClass)

Get

Return mTable

End Get

Set(ByVal value As Dictionary(Of SClass, SectionClass))

mTable = value

End Set

End Property

Public Shared Function isInRange(ByVal v As Integer) As Boolean

Return v > 0 AndAlso v < 16

End Function

Public Shared Function separateClassValue(ByVal cv As Integer) As IList(Of

Integer)

'建築=1, 土木=2, 電機=4, 機械=8

Dim proValues As New List(Of Integer)

If isInRange(cv) Then

Dim classValue As Integer

Dim ary As Array = [Enum].GetValues(GetType(SClass))

Array.Reverse(ary)

For i As Integer = 0 To ary.Length - 1

classValue = ary(i)

If cv >= classValue Then

proValues.Add(classValue)

cv -= classValue

End If

Next

106

End If

Return proValues

End Function

Public Shared Function parseClassFromEngCharsNumber(ByVal cv As Integer)

As IList(Of String)

Dim proStrings As New List(Of String)

For Each v In separateClassValue(cv)

proStrings.Add(mTable.Item(v).Name)

Next

Return proStrings

End Function

Public Shared Function getClassName(ByVal cv As Integer) As String

Dim clz As SClass

If [Enum].TryParse(Of SClass)(cv.ToString, clz) AndAlso

mTable.ContainsKey(clz) Then

Return mTable.Item(clz).Name

End If

Return String.Empty

End Function

Public Shared Function getClassId(cv As Integer) As Guid

Return If(mTable.ContainsKey(cv), mTable(cv).ID, Guid.Empty)

End Function

Public Shared Function getSectionClassByValue(cv As Integer) As SectionClass

Return If(mTable.ContainsKey(cv), mTable(cv), Nothing)

End Function

End Class

107

25. SessionManager.vb

Imports Tai_Power.TableInfo

Namespace SessionManager

Public Class SMActionBase

Protected Shared key As String

Public source, target As String

Public action As Integer

End Class

Public Class CurrentPageSesstion

Public Const CurrentPageName As String = "currentPage"

Public Shared Property setCurrentPage(ByVal p As Page) As String

Get

Return p.Session(CurrentPageName)

End Get

Set(ByVal value As String)

p.Session(CurrentPageName) = value

End Set

End Property

End Class

Public Class FormOperations

Public Const modeName As String = "_Mode"

Public Shared Property operationMode(ByVal p As Page) As Operations

Get

Return p.Session(modeName)

End Get

Set(ByVal value As Operations)

p.Session(modeName) = value

End Set

End Property

End Class

108

Public Class EnCaseTable

Public Const tabName As String = "_ENINFO"

Public Shared Property tableInfo(ByVal p As Page) As EnInfo

Get

Return p.Session(tabName)

End Get

Set(ByVal value As EnInfo)

p.Session(tabName) = value

End Set

End Property

End Class

Public Class ProjCaseReceipt

Public Const CASE_ID_NAME As String = "PCR_PID"

Public Const PAGE_SOURCE As String = "PCR_PageSource"

Public Const PAGE_TARGET As String = "PCR_PageTarget"

Public Const PAGE_ACTION As String = "PCR_PageAction"

Public Shared Property ReceiptID(ByVal p As Page) As Guid

Get

Return p.Session(CASE_ID_NAME)

End Get

Set(ByVal value As Guid)

p.Session(CASE_ID_NAME) = value

End Set

End Property

Public Shared Property PageSource(ByVal p As Page) As String

Get

Return p.Session(PAGE_SOURCE)

End Get

Set(ByVal value As String)

p.Session(PAGE_SOURCE) = value

End Set

End Property

109

Public Shared Property PageTarget(ByVal p As Page) As String

Get

Return p.Session(PAGE_TARGET)

End Get

Set(ByVal value As String)

p.Session(PAGE_TARGET) = value

End Set

End Property

Public Shared Property PageAction(ByVal p As Page) As Integer

Get

Return p.Session(PAGE_ACTION)

End Get

Set(ByVal value As Integer)

p.Session(PAGE_ACTION) = value

End Set

End Property

Public Shared Sub clearAll(ByVal p As Page)

p.Session.Remove(CASE_ID_NAME)

p.Session.Remove(PAGE_SOURCE)

p.Session.Remove(PAGE_TARGET)

p.Session.Remove(PAGE_ACTION)

End Sub

End Class

End Namespace

110

26. UserRoleClassRelation.vb

Imports System.Web.Configuration

Imports System.Data.SqlClient

Imports Tai_Power.DataSourceProvider

Imports Tai_Power.Entity

Imports Tai_Power.SectionClassIdentity

Public Class UserRoleClassRelation

Public Shared Function getSectionCLassByUserID(ByVal uid As String) As

IList(Of Entity.SectionClass)

Dim clz As New List(Of Entity.SectionClass)

Dim wdsReader As New WorkDataSourceReader()

Dim wdsSource As SqlDataSource = wdsReader.Source

'wdsSource.ConnectionString =

WebConfigurationManager.ConnectionStrings("TestDataConnectionString").Connecti

onString

'wdsSource.DataSourceMode = SqlDataSourceMode.DataReader

wdsSource.SelectCommand = "SELECT UserInfos.SectionClassID,

SectionClass.ClassName, SectionClass.ClassValue FROM UserInfos INNER JOIN

SectionClass ON UserInfos.SectionClassID = SectionClass.ClassID WHERE [UserID]

= @UID"

wdsSource.SelectParameters.Add(New Parameter("UID", DbType.Guid,

uid))

Dim reader As SqlDataReader = wdsSource.Select(New

DataSourceSelectArguments())

If reader IsNot Nothing Then

While reader.Read

clz.Add(New Entity.SectionClass(CType(reader.Item(0), Guid),

reader.Item(1).ToString()) With {.Value = reader.GetInt32(2)})

End While

End If

reader.Close()

Return clz

End Function

Public Shared Function getSectionClassUsers(ByVal r As RoleIdentity.Role) As

IEnumerable(Of Entity.SectionClassUser)

111

Return From pair In getUsersOfAllClasses(r)

Let users = pair.Value

From u In users

Select New SectionClassUser(u) With {.ClassValue = pair.Key}

End Function

Public Shared Function getUsers(ByVal clzName As String, ByVal r As

RoleIdentity.Role) As IList(Of Entity.User)

Dim uList As New List(Of Entity.User)

Dim uMap As New Dictionary(Of String, Entity.User)

For Each u As Entity.User In getUsersByClassName(clzName)

uMap.Add(u.ID.ToString(), u)

Next

For Each ue As Entity.User In getUsers(r)

If uMap.ContainsKey(ue.ID.ToString()) Then

uList.Add(ue)

End If

Next

Return uList

End Function

Public Shared Function getUsers(ByVal r As RoleIdentity.Role) As IList(Of

Entity.User)

Dim uList As New List(Of Entity.User)

For Each un As String In getUserNamesByRole(r)

uList.Add(New

Entity.User(CType(Membership.GetUser(un).ProviderUserKey, Guid), un))

Next

Return uList

End Function

Public Shared Function getUsersMapByRole(ByVal r As RoleIdentity.Role) As

SortedDictionary(Of Guid, String)

Dim uMap As New SortedDictionary(Of Guid, String)

For Each un As String In getUserNamesByRole(r)

112

Dim uid As Guid = CType(Membership.GetUser(un).ProviderUserKey,

Guid)

uMap.Add(uid, un)

Next

Return uMap

End Function

Public Shared Function getUserNamesByRole(ByVal r As RoleIdentity.Role) As

String()

Return Roles.GetUsersInRole(r.ToString())

End Function

Public Shared Function getUsersByClassName(ByVal clzName As String) As

IList(Of Entity.User)

Return getUsersByClassNames(New List(Of String)(New String()

{clzName}))

End Function

Public Shared Function getUsersByClassNames(ByVal clzNames As IList(Of

String)) As IList(Of Entity.User)

Dim pnPre As String = "cn"

Dim pn As String

Dim count As Integer = 0

Dim pnList As New List(Of String)

Dim wdsReader As New WorkDataSourceReader()

Dim wdsSource As SqlDataSource = wdsReader.Source

For Each c As String In clzNames

count += 1

pn = pnPre + count.ToString()

pnList.Add("@" + pn)

wdsSource.SelectParameters.Add(New Parameter(pn, DbType.String,

c))

Next

'wdsSource.ConnectionString =

WebConfigurationManager.ConnectionStrings("TestDataConnectionString").Connecti

onString

113

'wdsSource.DataSourceMode = SqlDataSourceMode.DataReader

wdsSource.SelectCommand = "SELECT UserInfos.UserID,

UserInfos.UserName FROM SectionClass INNER JOIN UserInfos ON

SectionClass.ClassID = UserInfos.SectionClassID WHERE (SectionClass.ClassName

IN (" + String.Join(",", pnList) + "))"

Dim users As New List(Of Entity.User)

Dim reader As SqlDataReader = wdsSource.Select(New

DataSourceSelectArguments())

If reader IsNot Nothing Then

While reader.Read

users.Add(New Entity.User(CType(reader.Item(0), Guid),

reader.Item(1).ToString()))

End While

End If

reader.Close()

Return users

End Function

Public Shared Function getUsersOfAllClasses() As SortedList(Of SClass,

IList(Of User))

Dim wds As WorkDataSource = WorkDataSourceFactory.createReader()

Dim source As SqlDataSource = wds.Source

source.SelectCommand = "SELECT UserInfos.UserID,

UserInfos.UserName, SectionClass.ClassValue FROM SectionClass INNER JOIN

UserInfos ON SectionClass.ClassID = UserInfos.SectionClassID"

Dim reader As SqlDataReader = wds.selectData()

Dim uMap As New SortedList(Of SClass, IList(Of User))

If reader IsNot Nothing Then

While reader.Read

Dim clzKey As Integer = reader.GetInt32(2)

Dim uEntity As New User(reader.GetGuid(0),

reader.GetString(1))

If uMap.ContainsKey(clzKey) Then

uMap.Item(clzKey).Add(uEntity)

Else

114

Dim ulist As New List(Of User)

ulist.Add(uEntity)

uMap.Add(clzKey, ulist)

End If

End While

End If

Return uMap

End Function

Public Shared Function getUsersOfAllClasses(ByVal role As RoleIdentity.Role)

As SortedList(Of SClass, IList(Of User))

Dim uMap As SortedList(Of SClass, IList(Of User)) =

getUsersOfAllClasses()

Dim rMap As SortedDictionary(Of Guid, String) =

getUsersMapByRole(role)

Dim urMap As New SortedList(Of SClass, IList(Of User))

For Each key As SClass In uMap.Keys

urMap.Add(key, (uMap(key).Where(Function(ue)

rMap.ContainsKey(ue.ID))).ToList())

Next

Return urMap

End Function

End Class

115

27. UserRoleEntity.vb

Imports Tai_Power.Entity

Public Class UserRoleEntity

Protected mUser As Entity.User

Protected mRole As RoleIdentity.Role

Public Sub New(ByVal role As RoleIdentity.Role, ByVal id As String, ByVal

name As String)

mUser = New User(id, name)

mRole = role

End Sub

Public Sub New(ByVal role As RoleIdentity.Role, ByVal ent As Entity.User)

mUser = New User(ent)

mRole = role

End Sub

Public Sub New()

End Sub

Public Property User As Entity.User

Get

Return mUser

End Get

Set(ByVal value As Entity.User)

mUser = value

End Set

End Property

Public Property Role As RoleIdentity.Role

Get

Return mRole

End Get

Set(ByVal value As RoleIdentity.Role)

mRole = value

End Set

End Property

116

End Class

Public Class RoleEntityManager

Public Shared Function checkPrimitiveRole(ByVal role As RoleIdentity.Role) As

Boolean

Return role > RoleIdentity.Role.HandlingUnit AndAlso role <=

RoleIdentity.Role.SiteManager

End Function

Public Shared Function defaultFactory(ByVal role As RoleIdentity.Role) As

UserRoleEntity

Dim es = factory(role)

Return If(es Is Nothing, Nothing, es.AsEnumerable.FirstOrDefault)

End Function

Public Shared Function factory(ByVal role As RoleIdentity.Role) As IList(Of

UserRoleEntity)

Dim eList As List(Of UserRoleEntity) = Nothing

If checkPrimitiveRole(role) Then

Dim uList As List(Of User) = UserRoleClassRelation.getUsers(role)

If uList.Count > 0 Then

eList = New List(Of UserRoleEntity)

uList.ForEach(Sub(u As User) eList.Add(New

UserRoleEntity(role, u)))

End If

End If

Return eList

End Function

Public Shared Function getID(ByVal role As RoleIdentity.Role) As Guid

Dim entity As UserRoleEntity = defaultFactory(role)

Return If(entity Is Nothing, Nothing, entity.User.ID)

End Function

Public Shared Function getName(ByVal role As RoleIdentity.Role) As String

Dim entity As UserRoleEntity = defaultFactory(role)

117

Return If(entity Is Nothing, Nothing, entity.User.Name)

End Function

End Class

118

28. ViewStateBundle.vb

Imports System.Reflection

Public Class ViewStateBundle

Public Property BaseState As Object

Public Function getStates() As Object()

Dim sList As New List(Of Object)

Me.GetType.GetProperties(BindingFlags.Public Or

BindingFlags.Instance).ForEach(Sub(p As PropertyInfo)

sList.Add(p.GetGetMethod.Invoke(Me, Nothing)))

Return sList.ToArray

End Function

Public Sub setStates(ByVal s As Object)

If s IsNot Nothing Then

Dim states As IEnumerator = CType(s, Object()).GetEnumerator

Me.GetType.GetProperties(BindingFlags.Instance Or

BindingFlags.Public).ForEach(Sub(p As PropertyInfo) If states.MoveNext Then

p.GetSetMethod.Invoke(Me, New Object() {states.Current}))

End If

End Sub

End Class

Public Class ViewStateAccessHelper

Public Property Target As Object

Public Property PropertyNameList As IList(Of String)

Public Function check() As Boolean

Return Not (Target Is Nothing OrElse PropertyNameList Is Nothing)

End Function

Public Function save() As Object()

If check() Then

Dim sList As New List(Of Object)

Dim tType As Type = Target.GetType()

119

PropertyNameList.ForEach(Sub(name As String)

sList.Add(tType.GetProperty(name).GetGetMethod.Invoke(Target, Nothing)))

Return sList.ToArray

End If

Return Nothing

End Function

Public Sub load(ByVal s As Object)

If check() And s IsNot Nothing Then

Dim tType As Type = Target.GetType()

Dim states As IEnumerator = CType(s, Object()).GetEnumerator

PropertyNameList.ForEach(Sub(name As String) If states.MoveNext

Then tType.GetProperty(name).GetSetMethod.Invoke(Target, New Object()

{states.Current}))

End If

End Sub

End Class

120

29. MyWorkPage.vb

Namespace MyWorkPage

Public Delegate Sub DelWorksMenuItemClicked(ByVal sender As Object,

ByVal e As System.Web.UI.WebControls.MenuEventArgs)

Public Interface IWorksPageAccessable

Property UserRoleIDer As UserRoleIdentifier

ReadOnly Property WorksMenuItemClickDel As

DelWorksMenuItemClicked

End Interface

Public Class WorksPageAccessableFactory

Protected Shared mTableViewMap As New Dictionary(Of

RoleIdentity.Role, String)

Shared Sub New()

mTableViewMap.Add(RoleIdentity.Role.HandlingUnit,

"HandlingUnitRTTableView")

mTableViewMap.Add(RoleIdentity.Role.Superintendent,

"SuperintendentRTTableView")

mTableViewMap.Add(RoleIdentity.Role.Leader,

"LeaderRTTableView")

mTableViewMap.Add(RoleIdentity.Role.Inspector,

"InspectorRTTableView")

mTableViewMap.Add(RoleIdentity.Role.DeputyDirector,

"DeputyDirectorRTTableView")

mTableViewMap.Add(RoleIdentity.Role.SiteManager,

"SiteManagerRTTableView")

End Sub

Public Shared Function create(p As Page, ByVal rLevel As

RoleIdentity.Role) As Control

Dim WorksPageAccessor As Control = Nothing

If mTableViewMap.ContainsKey(rLevel) Then

Dim ctrStr As String = mTableViewMap(rLevel)

Try

121

WorksPageAccessor = p.LoadControl("~/UC/Works/" +

mTableViewMap(rLevel) + ".ascx")

Catch ex As Exception

End Try

End If

Return WorksPageAccessor

End Function

End Class

End Namespace

122

30. PAAssignment.vb

Imports System.Runtime.CompilerServices

Imports Tai_Power.Resource

Namespace ProjectAcceptanceAssignment

Public Enum PASuperintendentAssigmtState As Integer

NoProcessing = 0

RollBackToHU = 1

DateMismatch = 3

ProjectApproved = 10

NonApproved = 11

End Enum

Public Enum PALeaderValidationState As Integer

NoProcessing = 0

Validation = 1

NoValidation

End Enum

Public Enum PAAssigmtMemState As Integer

<PAAMSAStateTransitAttribute(Unavailable, ReAccepting, BreakOff,

Completion)>

Unavailable = 0

<PAAMSAStateTransitAttribute(ReAccepting, NonUpdatedChompletion)>

ReAccepting = 5

<PAAMSAStateTransitAttribute(ReAccepting, BreakOff, Completion)>

BreakOff = 10

<PAAMSAStateTransitAttribute(ReAccepting, BreakOff, Completion)>

Completion

<PAAMSAStateTransitAttribute(NonUpdatedChompletion)>

NonUpdatedChompletion

End Enum

Public Enum PAAMOPState As Integer

<PAAMSAStateMappingAttribute(PAAssigmtMemState.Unavailable)>

NoProcessing = 0

123

<PAAMSAStateMappingAttribute(PAAssigmtMemState.ReAccepting,

PAAssigmtMemState.BreakOff, PAAssigmtMemState.Completion,

PAAssigmtMemState.NonUpdatedChompletion)>

StateChosen = 5

<PAAMSAStateMappingAttribute(PAAssigmtMemState.BreakOff,

PAAssigmtMemState.Completion, PAAssigmtMemState.NonUpdatedChompletion)>

PAIRUploaded

<PAAMSAStateMappingAttribute(PAAssigmtMemState.BreakOff,

PAAssigmtMemState.Completion, PAAssigmtMemState.NonUpdatedChompletion)>

PAAccomplished

End Enum

<AttributeUsage(AttributeTargets.Field)>

Class PAAMSAStateTransitAttribute

Inherits Attribute

Public Property Transit As IEnumerable(Of PAAssigmtMemState)

Public Sub New(ByVal ParamArray states() As PAAssigmtMemState)

Transit = states.AsEnumerable

End Sub

End Class

<AttributeUsage(AttributeTargets.Field)>

Class PAAMSAStateMappingAttribute

Inherits Attribute

Public Property MapStates As IEnumerable(Of PAAssigmtMemState)

Public Sub New(ByVal ParamArray states() As PAAssigmtMemState)

MapStates = states.AsEnumerable

End Sub

End Class

Module PAAMOPStateExtension

124

<Extension()>

Public Function Mapping(ByVal ops As PAAMOPState, ByVal ParamArray

states() As PAAssigmtMemState) As IEnumerable(Of PAAssigmtMemState)

If states.Count > 0 Then

'Dim attr As PAAMSAStateMappingAttribute =

ops.GetType.GetField(ops.Name).GetCustomAttributes(GetType(PAAMSAStateMap

pingAttribute), False).Cast(Of PAAMSAStateMappingAttribute)().FirstOrDefault()

Dim attr As PAAMSAStateMappingAttribute = ops.Attribute(Of

PAAMSAStateMappingAttribute)()

If attr IsNot Nothing Then Return states.Where(Function(item)

attr.MapStates.Contains(item))

End If

Return {}

End Function

<Extension()>

Public Function IsMapped(ByVal ops As PAAMOPState, ByVal sas As

PAAssigmtMemState) As Boolean

Dim mapping = ops.Mapping(sas)

Return (mapping.Count = 1 AndAlso mapping.First = sas)

End Function

End Module

End Namespace

125

31. PACertification.vb

Imports System.Runtime.CompilerServices

Imports Tai_Power.Resource

Imports System.Reflection

Namespace PACertification

Public Enum VerifiedState

<PACStateUploadFileAttribute(True, "PACertificate")>

Undelivered = 0

Delivered

<PACStateUploadFileAttribute(True, "PACertificate")>

RollBack

<PACStateUploadFileAttribute(True, "PAVerifiedCertificate")>

Verified

VCDelivered = 10

<PACStateUploadFileAttribute(True, "PAVerifiedCertificate")>

VCRollBack

VCApproved

End Enum

Public Enum PACFileIDName

PACertificate = 1

PAVerifiedCertificate

End Enum

<AttributeUsage(AttributeTargets.Field)>

Class PACStateUploadFileAttribute

Inherits Attribute

Public Property isUploadingFile As Boolean

Public Property PACColName As String

Public Sub New(ByVal uf As Boolean, ByVal colName As String)

isUploadingFile = uf

PACColName = colName

End Sub

126

End Class

Public Class VerifiedStateKeyProvider

Inherits EnumResourceKeyProvider(Of VerifiedState)

Public Overrides Function createKey(ByVal e As VerifiedState) As String

Return "PACS" + e.toIntString

End Function

End Class

Module VerifiedStateExtension

<Extension()>

Public Function KeyProvider(ByVal this As VerifiedState) As

IResourceKeyProvider

Dim kp As New VerifiedStateKeyProvider

kp.chooseKey(this)

Return kp

End Function

<Extension()>

Public Function getPACUploadFileAttribute(ByVal this As VerifiedState)

As PACStateUploadFileAttribute

Dim upeType As Type = this.GetType()

Dim fInfo As FieldInfo = upeType.GetField(this.Name())

Return

fInfo.GetCustomAttributes(GetType(PACStateUploadFileAttribute), False).Cast(Of

PACStateUploadFileAttribute)().FirstOrDefault()

End Function

<Extension()>

Public Function isUploadingFile(ByVal this As VerifiedState) As Boolean

Dim attr As PACStateUploadFileAttribute =

this.getPACUploadFileAttribute

Return If(attr Is Nothing, False, attr.isUploadingFile)

End Function

127

<Extension()>

Public Function getPACUFColName(ByVal this As VerifiedState) As String

Dim attr As PACStateUploadFileAttribute =

this.getPACUploadFileAttribute

Return If(attr Is Nothing, Nothing, attr.PACColName)

End Function

End Module

End Namespace

128

32. PAIRFileDownloadLinkInjector.vb

Imports Tai_Power.Resource

Imports Tai_Power.SharedTaskCommands.SharedReceiver

Imports Tai_Power.SharedTaskCommands.UploadFileInfo

Imports Tai_Power.DSUploadFileInfo

Imports Tai_Power.TaskCommandInvoker

Imports Tai_Power.DownloadFile

Imports Tai_Power.DSPAInspectorRecordsInfo

Public Class PAIRFileDownloadLinkInjector

Public Property UID As Guid

Public Property AssigmtID As Guid

Public Property InjectTarget As WebControl

Private mPACFileNameGRHelper As GlobalResourceHelper

Public Sub New()

mPACFileNameGRHelper = New GlobalResourceHelper With

{.GlobalResourceType = GetType(Resources.PAIRecordName)}

End Sub

Public Overloads Sub inject(ByVal fList As IList(Of FileItem))

If fList IsNot Nothing AndAlso fList.Count > 0 Then

Dim FName As String

For Each item In fList

FName =

mPACFileNameGRHelper.getResourceValue(item.FIDName)

If Not String.IsNullOrEmpty(FName) Then

Dim rec As New FieldIDReceiver With {.FieldID =

item.FID.ToString()}

Invoker.staticInvoke(New

SelectUploadFileInfoByFIDCommand(rec))

Dim fInfo As UploadFileInfoRow = rec.Result

If fInfo IsNot Nothing Then

Dim fb As New PAIRecordFileBundle With

{.ASSigmtID = AssigmtID, .InspectorID = UID, .FileID = fInfo.FID, .FileName =

FName, .FileExt = fInfo.FType}

129

Dim link As FileDownloadLink =

InjectTarget.Page.LoadControl("~/UC/File/FileDownloadLink.ascx")

link.ID = item.FIDName

link.inject(fb)

InjectTarget.Controls.Add(link)

End If

End If

Next

End If

End Sub

Public Overloads Sub inject(ByVal row As PAInspectorRecordsInfoRow)

AssigmtID = row.SAssigmtID

Dim items = (From pInfo In

GetType(PAInspectorRecordsInfoRow).GetProperties.Where(Function(pi)

pi.PropertyType Is GetType(Guid))

Select New FileItem With {.FIDName = pInfo.Name, .FID =

pInfo.GetGetMethod.Invoke(row, Nothing)}).Where(Function(o) Not

FileIdentity.isNullOrNonDeliveryID(o.FID))

inject(items.ToList)

End Sub

Public Class FileItem

Public FIDName As String

Public FID As Guid

End Class

End Class

130

33. ProjectAcceptance.vb

Public Class ProjectAcceptance

Public Enum PAState

NonDelivery = 0

Delivery

MemDateAssignment

ScheduleValidation

ProjectApproved

InAcceptance

AcceptanceCompleted

DRFDateMismatch = 7 'data reject from Leader

DRFDeputyDirector 'data reject from DeputyDirector

NonApproved

RBFSuperintendent = 15 'rollback from Superintendent

End Enum

Public Shared Function getPAStateValueString(ByVal s As PAState) As String

Return CType(s, Integer).ToString()

End Function

Public Shared Function getPAState(ByVal s As String) As PAState?

If Not String.IsNullOrEmpty(s) Then

Dim state As PAState

If [Enum].TryParse(s, state) Then Return state

End If

Return Nothing

End Function

End Class

131

34. RoleActions.vb

Imports System.Reflection

Imports System.Runtime

Imports System.Runtime.Serialization

Namespace RoleRTActions

Public Class SiteManagerRTAT

Inherits ReflectingEnumNameTable(Of Action)

Private Shared instance As SiteManagerRTAT = New SiteManagerRTAT

Private Sub New()

End Sub

Public Shared Function getService() As SiteManagerRTAT

Return instance

End Function

Public Enum Action As Integer

CreateAccount = 1

ManageAccount

End Enum

End Class

Public Class HandlingUnitRTAT

Inherits ReflectingEnumNameTable(Of Action)

Public Enum Action As Integer

View = 0

UploadDoc

PAInsert

PAUpdate

UpdatePreparedItems

ShowPAPIFiles

UploadPAPIFile

132

Deliver

UploadPACertificate = 10

UploadVerifiedPACertificate

End Enum

End Class

Public Class InspectorRTAT

Public Enum Action As Integer

ViewProject = 0

PAPIFileValidation

StateModification

FinishValidation

ShowPAIRecords

End Enum

End Class

Public Class SuperintendentRTAT

Inherits ReflectingEnumNameTable(Of Action)

Public Enum Action As Integer

View = 0

NoValidation

Validation

Deliver

PADateAssigmt

InspectorDateAssigmt

Query

'Report Checking

CheckedValidation

'rollback PA Form to HandlingUnit

PARollback = 10

End Enum

End Class

133

Public Class LeaderRTAT

Inherits ReflectingEnumNameTable(Of Action)

Public Enum Action As Integer

ViewProject = 1

NoValidation

Validation

RollBack

CheckedValidation

End Enum

End Class

Public Class DirectorRTAT

Inherits ReflectingEnumNameTable(Of Action)

Public Enum Action As Integer

CheckedValidation

PAVCertificateValidation

End Enum

End Class

<Serializable()>

Public Class DeputyDirectorRTAT

Inherits ReflectingEnumNameTable(Of Action)

Implements Serialization.ISerializable

Public Sub New()

End Sub

Public Sub New(ByVal info As SerializationInfo, ByVal context As

StreamingContext)

mTable = info.GetValue("table", GetType(Dictionary(Of String,

Action)))

134

End Sub

Public Enum Action As Integer

ViewProject = 1

DoValidation

CheckedValidation

End Enum

Public Sub GetObjectData(ByVal info As

System.Runtime.Serialization.SerializationInfo, ByVal context As

System.Runtime.Serialization.StreamingContext) Implements

System.Runtime.Serialization.ISerializable.GetObjectData

info.AddValue("table", mTable)

End Sub

End Class

End Namespace

135

35. WorkPageRouter.vb

Public Class WorkPageRouter

Public Const MyWorksPath As String = "~/MyWorks.aspx"

Public Shared Sub toMyWorks(ByVal p As HttpContext)

p.Response.RedirectPermanent(MyWorksPath)

End Sub

Public Shared Sub toMyWorks(ByVal p As Page)

route(p, MyWorksPath)

End Sub

Public Shared Sub routeMyWorks(ByVal p As Page, ByVal dPath As String)

route(p, MyWorksPath, dPath)

End Sub

Public Shared Sub route(ByVal p As Page, ByVal v As String)

p.Response.RedirectPermanent(v)

End Sub

Public Shared Sub route(ByVal p As Page, ByVal v As String, ByVal dPath As

String)

If String.IsNullOrEmpty(dPath) Then

p.Response.RedirectPermanent(v)

Else

p.Response.RedirectPermanent(dPath.Trim())

End If

End Sub

End Class

136

36. AssigmtedProjectInfoDM.vb

Imports Tai_Power.ProjectAcceptanceAssignment

Imports System.Data.SqlClient

Public Interface IEventTransferor

Function transString() As String

End Interface

Public Class EventTransferorService

Public Shared Function transEventStrings(Optional ByVal evtStr As String = "")

As String

Return "{""events"":[" + evtStr + "]}"

End Function

Public Shared Function transEventStrings(ByVal ParamArray evts() As

IEventTransferor) As String

Return transEventStrings(String.Join(",", evts.Select(Function(e As

IEventTransferor) e.transString)))

End Function

End Class

Public Class AssigmtedProjectInfoDMWrapper

Inherits Dictionary(Of Guid, AssigmtedProjectInfoDM)

Implements IEventTransferor

Public Sub AddProjectInfo(ByVal reader As SqlDataReader)

Dim pid As Guid = reader.GetGuid(0)

If Not Me.ContainsKey(pid) Then

Dim pdm As New AssigmtedProjectInfoDM With {

.ProjectID = pid,

.ProjectUnit = reader.GetGuid(1),

.ProjectUnitNum = reader.GetInt32(13),

.ProjectCaseNum = reader.GetString(2),

.ProjectEngName = reader.GetString(3),

.PAATTStart = reader.GetDateTime(4),

.PAATDayState = reader.GetInt32(5)}

Me.Add(pid, pdm)

End If

137

Dim assigmtID As Guid = reader.GetGuid(6)

If Not Me(pid).SuperintendentRels.ContainsKey(assigmtID) Then

Dim sdm As New AssigmtedProjSuperintendentInfoDM With {

.ASSigmtID = assigmtID,

.ClassValue = reader.GetInt32(12),

.SuperintendentInfoID = reader.GetGuid(7),

.SuperintendentName =

Membership.GetUser(.SuperintendentInfoID).UserName}

Me(pid).SuperintendentRels.Add(assigmtID, sdm)

End If

Dim iID As Guid = reader.GetGuid(8)

If Not

Me(pid).SuperintendentRels(assigmtID).InspectorInfos.ContainsKey(iID) Then

Dim idm As New InsepctorInfoDM With {

.ID = iID,

.Name = reader.GetString(9),

.SAState = reader.GetInt32(10),

.OPState = reader.GetInt32(11)}

Me(pid).SuperintendentRels(assigmtID).InspectorInfos.Add(iID, idm)

End If

End Sub

Public Function transString() As String Implements IEventTransferor.transString

Dim q = Me.Values.Select(Function(e As IEventTransferor) e.transString)

Dim elist As List(Of String) = q.ToList

Return String.Join(",", q)

End Function

End Class

Public Class AssigmtedProjectInfoDM

Implements IEventTransferor

Public Property ProjectID As Guid

Public Property ProjectUnit As Guid

Public Property ProjectUnitNum As Integer

Public Property ProjectCaseNum As String

138

Public Property ProjectEngName As String

Public Property PAATTStart As Date

Public Property PAATDayState As Integer

Public Property SuperintendentRels As New Dictionary(Of Guid,

AssigmtedProjSuperintendentInfoDM)

Public Function transString() As String Implements IEventTransferor.transString

Dim sdm As String = String.Join(",",

SuperintendentRels.Values.Select(Function(e As IEventTransferor) e.transString))

Return "{""PCN"":""" + ProjectCaseNum + """,""PEN"":""" +

ProjectEngName + """,""PUN"":""" + ProjectUnitNum.ToString + """,""PT"":""" +

PAATTStart.ToString("yyyy/MM/dd") + """,""DS"":" + PAATDayState.ToString + ",

""SDM"":[" + sdm + "]}"

End Function

End Class

Public Class AssigmtedProjSuperintendentInfoDM

Implements IEventTransferor

Public Property ASSigmtID As Guid

Public Property SuperintendentInfoID As Guid

Public Property SuperintendentName As String

Public Property ClassValue As Integer

Public Property InspectorInfos As New Dictionary(Of Guid, InsepctorInfoDM)

Public Function transString() As String Implements IEventTransferor.transString

Dim idm As String = String.Join(",",

InspectorInfos.Values.Select(Function(e As IEventTransferor) e.transString))

Return "{""SN"":""" + SuperintendentName + """, ""CV"":" +

ClassValue.ToString + ", ""IDM"":[" + idm + "]}"

End Function

End Class

Public Class InsepctorInfoDM

139

Implements IEventTransferor

Public Property ID As Guid

Public Property Name As String

Public Property SAState As PAAssigmtMemState

Public Property OPState As PAAMOPState

Public Function transString() As String Implements IEventTransferor.transString

'Return "{""IN"":""" + Name + """, ""SA"":""" + SAState.ResString(Of

Resources.PAAMSAState)() + """, ""OP"":""" + OPState.ResString(Of

Resources.PAAMOPState)() + """}"

Return "{""IN"":""" + Name + """, ""SA"":""" + SAState.toIntString + """,

""OP"":""" + OPState.toIntString + """}"

End Function

End Class

140

37. PAInspectorSimpleRelDM.vb

Imports Tai_Power.ProjectAcceptanceAssignment

Public Class PAInspectorSimpleRelDM

Public Property ProjectID As Guid

Public Property InspectorID As Guid

Public Property PAState As ProjectAcceptance.PAState

'Public Property SAState As PAAssigmtMemState

Public Property ProjectUnit As String

Public Property ProjectCaseNumber As String

Public Property ProjectEngineName As String

Public DataTable As DataTable

Public Sub New(ByVal table As DataTable)

DataTable = table

Dim row As DataRow = table.AsEnumerable.FirstOrDefault

injectRow(row)

End Sub

Public Sub New(ByVal row As DataRow)

injectRow(row)

End Sub

Public Sub injectRow(ByVal row As DataRow)

If row Is Nothing Then Throw New Exception("Null DataRow")

ProjectID = row.Field(Of Guid)("PID")

InspectorID = row.Field(Of Guid)("UID")

PAState = row.Field(Of Integer)("PAState")

'SAState = row.Field(Of Integer)("SAState")

ProjectUnit = row.Field(Of String)("unit")

ProjectCaseNumber = row.Field(Of String)("projCaseNum")

ProjectEngineName = row.Field(Of String)("engName")

End Sub

End Class

141

38. PAIRTaskStateDM.vb

Imports Tai_Power.ProjectAcceptanceAssignment

Public Class PAIRTaskStateDM

Public Property ProjectID As Guid

Public Property InspectorID As Guid

Public Property ASSigmtID As Guid

Public Property PAState As ProjectAcceptance.PAState

Public Property SAState As PAAssigmtMemState

Public Property OPState As PAAMOPState

Public Property ProjectUnit As Guid

Public Property ProjectUnitName As String

Public Property ProjectCaseNum As String

Public Property ProjectEngName As String

Public DataTable As DataTable

Public Sub New(ByVal table As DataTable)

DataTable = table

injectRow(table.AsEnumerable.FirstOrDefault)

End Sub

Public Sub New(ByVal row As DataRow)

injectRow(row)

End Sub

Public Sub injectRow(ByVal row As DataRow)

If row Is Nothing Then Throw New Exception("Null DataRow")

ProjectID = row.Field(Of Guid)("PID")

InspectorID = row.Field(Of Guid)("UID")

ASSigmtID = row.Field(Of Guid)("SAssigmtID")

PAState = row.Field(Of ProjectAcceptance.PAState)("PAState")

SAState = row.Field(Of PAAssigmtMemState)("SAState")

OPState = row.Field(Of PAAMOPState)("OPState")

ProjectUnit = row.Field(Of Guid)("unit")

ProjectUnitName = row.Field(Of String)("PUName")

ProjectCaseNum = row.Field(Of String)("projCaseNum")

ProjectEngName = row.Field(Of String)("engName")

142

End Sub

End Class

143

39. PAPreparedItem.vb

Imports System.Reflection

Imports System.Resources

Public Class PAPreparedItem

Public Property PID As Guid

<PAPIDataAttribute(PAPIDType.File)>

Public Property PACoverScan As Guid '驗收通知單紙本封面掃

描檔

<PAPIDataAttribute(PAPIDType.File)>

Public Property PAPIContentOrAbstract As Guid '完工欲驗收項目之目錄或

摘要

<PAPIDataAttribute(PAPIDType.File)>

Public Property ECompletingReport As Guid '工程竣工報告表

<PAPIDataAttribute(PAPIDType.File)>

Public Property CompletingTable As Guid '竣工圖表

<PAPIDataAttribute(PAPIDType.File)>

Public Property CompletingSettlement As Guid '結算資料

<PAPIDataAttribute(PAPIDType.File)>

Public Property PASettlementCertificate As Guid '工程結算驗收證明書

<PAPIDataAttribute(PAPIDType.File)>

Public Property SettlementList As Guid '結算明細表

<PAPIDataAttribute(PAPIDType.File)>

Public Property LentMMList As Guid '供借機具材料清單

<PAPIDataAttribute(PAPIDType.File)>

Public Property SupplyEquipmentList As Guid '供給器材清單

<PAPIDataAttribute(PAPIDType.File)>

Public Property EImplNumCalcBook As Guid '工程實作數量計算書

<PAPIDataAttribute(PAPIDType.File)>

Public Property ECompletingContent As Guid '竣工圖目錄

Public Property DesignLayoutAsCT As Integer '以設計圖作為竣工圖

Public Property AddedRecoveryFig As Integer '加繪收方圖

Public Property ManuPatternAsCT As Integer '以廠商圖樣作為竣工圖

Public Property ECDrawContent As Integer '竣工圖圖樣袋袋面上,應

附「竣工圖面目錄」

<PAPIDataAttribute(PAPIDType.File)>

Public Property WorkTabular As Guid '工作天統計表

144

Public Property FillWTWithWeather As Integer '凡以工作天計算工期之工

程,均應填「工作天統計表」,並逐日按實記錄施工場所之天候。

Public Property WTWithSignature As Integer '工作天統計表應由承辦單

位簽章並應經承包廠商之簽認

Public Property WDBLeaseContract As Integer '工作天認定應依承攬契

約有關規定辦理

Public Property PDurationCalcs As Integer '工期計算

<PAPIDataAttribute(PAPIDType.File)>

Public Property SubPATable As Guid '分項工程驗收資料表

Public Property CAEPrepared As Integer '施工、檢驗及試驗資料之

準備

Public Property PBeginReport As Integer '工程開工報告表

Public Property CJourAndSRep As Integer '施工日誌及監造報表

Public Property PAItemsRecord As Integer '各項檢驗紀錄

Public Property ExperimentReport As Integer '試驗報告

Public Property WSAndOther As Integer '工務案件及其他相關資

<PAPIDataAttribute(PAPIDType.File)>

Public Property EQPreliminaryRecord As Guid '工程初驗合格紀錄

Public Property ContractorInvite As Integer '函邀承包廠商

Public Property EToolsPrepared As Integer '檢測儀器、工具之準備

Public Property SponsorRepresenter As Integer '承辦單位代表

Public Shared Function getFilePropertyInfo() As List(Of PropertyInfo)

Dim itemType As Type = GetType(PAPreparedItem)

Dim pList As New List(Of PropertyInfo)

For Each pInfo As PropertyInfo In itemType.GetProperties()

Dim attr As PAPIDataAttribute =

pInfo.GetCustomAttributes(GetType(PAPIDataAttribute), False).Cast(Of

PAPIDataAttribute).FirstOrDefault()

If attr IsNot Nothing Then

pList.Add(pInfo)

End If

Next

Return pList

End Function

145

Public Function getNonNullIDPropertyInfo() As List(Of PropertyInfo)

Dim pList As New List(Of PropertyInfo)

For Each pInfo As PropertyInfo In getFilePropertyInfo()

Dim fValue As Guid = pInfo.GetGetMethod.Invoke(Me, New Object()

{})

If Not FileIdentity.isNullID(fValue) Then pList.Add(pInfo)

Next

Return pList

End Function

End Class

Public Enum PAPIDType

File

Field

End Enum

<AttributeUsage(AttributeTargets.Property Or AttributeTargets.Field)>

Class PAPIDataAttribute

Inherits Attribute

Public Property DType As PAPIDType

Public Sub New(ByVal dt As PAPIDType)

DType = dt

End Sub

End Class

146

40. PASuperintendentInspectorRelDM.vb

Imports Tai_Power.ProjectAcceptanceAssignment

Public Class PASuperintendentInspectorRelDM

Public ProjectID As Guid

Public SuperintendentID As Guid

Public SAssigmtID As Guid

Public InspectorID As Guid

Public AssigmtState As PASuperintendentAssigmtState

Public SAState As PAAssigmtMemState

Public OPState As PAAMOPState

Public DataTable As DataTable

Public Sub New(ByVal table As DataTable)

DataTable = table

Dim row As DataRow = table.AsEnumerable.FirstOrDefault

injectRow(row)

End Sub

Public Sub New(ByVal row As DataRow)

injectRow(row)

End Sub

Public Sub injectRow(ByVal row As DataRow)

If row Is Nothing Then

Throw New Exception("Null DataRow")

End If

ProjectID = row.Field(Of Guid)("PID")

SuperintendentID = row.Field(Of Guid)("UID")

InspectorID = row.Field(Of Guid)("InspectorID")

SAssigmtID = row.Field(Of Guid)("SAssigmtID")

AssigmtState = row.Field(Of Integer)("AssigmtState")

SAState = row.Field(Of Integer)("SAState")

OPState = row.Field(Of Integer)("OPState")

End Sub

End Class