From 8f5c8891aba521570fa63c4baf616e3a3c8d9526 Mon Sep 17 00:00:00 2001
From: ulysseskao <ulysseskao@gmail.com>
Date: Sun, 01 May 2016 01:12:51 +0800
Subject: [PATCH] update for logger

---
 CCSTrace/CCS/Object/CCSRecord.cs |   26 ++++++++------------------
 1 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/CCSTrace/CCS/Object/CCSRecord.cs b/CCSTrace/CCS/Object/CCSRecord.cs
index b97ace0..b46f5d9 100644
--- a/CCSTrace/CCS/Object/CCSRecord.cs
+++ b/CCSTrace/CCS/Object/CCSRecord.cs
@@ -1,11 +1,14 @@
 using System;
 
 using System.Data.OracleClient;
+using NLog;
 
 namespace CCSTrace.CCS.Object
 {
     public class CcsRecord
     {
+        private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
+
         private readonly string _meter;
         private readonly string _customerName;
         private readonly string _customerTel;
@@ -45,7 +48,7 @@
             _acceptTime = accepttime;
         }
 
-        public CcsRecord(string ccsid, OracleConnection connectionTpc, SEventLog pLog)
+        public CcsRecord(string ccsid, OracleConnection connectionTpc)
         {
             var sqlStmt = "SELECT METER,CUSTOMERNAME,CUSTOMERTEL,ADDR_CITY,ADDR_TOWN,ADDR_ROAD,ADDR_OTHER,RECALLNAME,RECALLTEL,EVENTBRIEF,"
                              + "TO_CHAR(ACCEPTTIME,'YYYY/MM/DD HH24:MI:SS') as ACCEPTTIME,CCSID,IMPORTCASE,DEPT,PARTHICUSTOMER,NOTE FROM CCS.EVENTRECORD "
@@ -78,13 +81,8 @@
             }
             catch (Exception e)
             {
-                pLog.Error("無法取得CCS報案資訊!" + e.Message);
-                Console.WriteLine(e.StackTrace);
-
-                if (GlobalVariable.ShowError)
-                    pLog.Error(e.StackTrace);
-
-                throw e;
+                Logger.Error(e, "無法取得CCS報案資訊!" + e.Message);
+                throw;
             }
             finally
             {
@@ -125,7 +123,7 @@
 
         public string Note => _note;
 
-        public bool InsertDb(OracleConnection connectionTpc, OracleTransaction transaction, SEventLog pLog)
+        public bool InsertDb(OracleConnection connectionTpc, OracleTransaction transaction)
         {
             var sqlStmt = "INSERT INTO CCS.EVENTRECORD VALUES ('" + _meter + "','" + _customerName + "','" + _customerTel + "','" + _addrCity + "','"
                              + _addrTown + "','" + _addrRoad + "','" + _addrOther + "','" + _recallName + "','" + _recallTel + "',"
@@ -138,20 +136,12 @@
             {
                 if (command.ExecuteNonQuery() != 1)
                 {
-                    pLog.Error("CCS 案件受理程序初始化失敗...無法將CCS報案資訊存入資料庫中!");
-
                     throw new Exception("CCS 案件受理程序初始化失敗...無法將CCS報案資訊存入資料庫中!");
                 }
             }
             catch (Exception e)
             {
-                Console.WriteLine(e.StackTrace);
-
-                if (GlobalVariable.ShowError)
-                    pLog.Error(e.StackTrace);
-
-                pLog.Error("CCS 案件受理程序初始化失敗...無法將CCS報案資訊存入資料庫中!" + e.Message);
-                //throw new Exception("CCS 案件受理程序初始化失敗...無法將CCS報案資訊存入資料庫中");
+                Logger.Error(e, e.Message);
                 throw;
             }
             finally

--
Gitblit v0.0.0-SNAPSHOT