From b0c18d369abd06075c83759b0e19823c2a11d716 Mon Sep 17 00:00:00 2001
From: ulysseskao <ulysseskao@gmail.com>
Date: Fri, 29 Apr 2016 18:45:41 +0800
Subject: [PATCH] update for new model
---
CCSTrace/CCS/Object/CCSRecord.cs | 278 +++++++++++++++++++++---------------------------------
1 files changed, 109 insertions(+), 169 deletions(-)
diff --git a/CCSTrace/CCS/Object/CCSRecord.cs b/CCSTrace/CCS/Object/CCSRecord.cs
index c825bdd..b97ace0 100644
--- a/CCSTrace/CCS/Object/CCSRecord.cs
+++ b/CCSTrace/CCS/Object/CCSRecord.cs
@@ -1,124 +1,144 @@
using System;
-using System.Data;
-using System.Configuration;
-using System.Web;
-using System.Web.Security;
-using System.Web.UI;
-using System.Web.UI.HtmlControls;
-using System.Web.UI.WebControls;
-using System.Web.UI.WebControls.WebParts;
using System.Data.OracleClient;
namespace CCSTrace.CCS.Object
{
- public class CCSRecord
+ public class CcsRecord
{
- private String Meter;
- private String CustomerName;
- private String CustomerTel;
- private String ADDR_City;
- private String ADDR_Town;
- private String ADDR_Road;
- private String ADDR_Other;
- private String RecallName;
- private String RecallTel;
- private int EventBrief;
- private String AcceptTime;
- private String CCSID;
- private int ImportCase;
- private String Dept;
- private int PartHicustomer;
- private String Note;
+ private readonly string _meter;
+ private readonly string _customerName;
+ private readonly string _customerTel;
+ private readonly string _addrCity;
+ private readonly string _addrTown;
+ private readonly string _addrRoad;
+ private readonly string _addrOther;
+ private readonly string _recallName;
+ private readonly string _recallTel;
+ private readonly int _eventBrief;
+ private readonly string _acceptTime;
+ private readonly string _ccsid;
+ private readonly int _importCase;
+ private readonly string _dept;
+ private readonly int _partHicustomer;
+ private readonly string _note;
- public CCSRecord(String _CCSID, String _METER, String _CUSTOMERNAME, String _CUSTOMERTEL, String _ADDR_CITY, String _ADDR_TOWN, String _ADDR_ROAD,
- String _ADDR_OTHER, String _RECALLNAME, String _RECALLTEL, int _EVENTBRIEF, String _ACCEPTTIME, int _IMPORTCASE, String _DEPT,
- int _PartHicustomer,String _NOTE)
+ public CcsRecord(string ccsid, string meter, string customername, string customertel, string addrCity, string addrTown, string addrRoad,
+ string addrOther, string recallname, string recalltel, int eventbrief, string accepttime, int importcase, string dept,
+ int partHicustomer, string note)
{
- this.Meter = _METER;
- this.CustomerName = _CUSTOMERNAME;
- this.CustomerTel = _CUSTOMERTEL;
- this.ADDR_City = _ADDR_CITY;
- this.ADDR_Town = _ADDR_TOWN;
- this.ADDR_Road = _ADDR_ROAD;
- this.ADDR_Other = _ADDR_OTHER;
- this.RecallName = _RECALLNAME;
- this.RecallTel = _RECALLTEL;
- this.EventBrief = _EVENTBRIEF; ;
- this.CCSID = _CCSID;
- this.ImportCase = _IMPORTCASE;
- this.Dept = _DEPT;
- this.Note = _NOTE;
- this.PartHicustomer = _PartHicustomer;
- this.AcceptTime = _ACCEPTTIME;
+ _meter = meter;
+ _customerName = customername;
+ _customerTel = customertel;
+ _addrCity = addrCity;
+ _addrTown = addrTown;
+ _addrRoad = addrRoad;
+ _addrOther = addrOther;
+ _recallName = recallname;
+ _recallTel = recalltel;
+ _eventBrief = eventbrief; ;
+ _ccsid = ccsid;
+ _importCase = importcase;
+ _dept = dept;
+ _note = note;
+ _partHicustomer = partHicustomer;
+ _acceptTime = accepttime;
}
- public CCSRecord(String _CCSID, OracleConnection _ConnectionTPC, SEventLog _PLog)
+ public CcsRecord(string ccsid, OracleConnection connectionTpc, SEventLog pLog)
{
- String SqlStmt;
+ 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 "
+ + "WHERE CCSID = '" + ccsid + "'";
- 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 "
- + "WHERE CCSID = '" + _CCSID + "'";
+ OracleCommand command = new OracleCommand(sqlStmt, connectionTpc);
+ OracleDataReader reader = command.ExecuteReader();
- OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC);
- OracleDataReader reader = Command.ExecuteReader();
-
try
{
while (reader.Read())
{
- Meter = reader["METER"].ToString();
- CustomerName = reader["CUSTOMERNAME"].ToString();
- CustomerTel = reader["CUSTOMERTEL"].ToString();
- ADDR_City = reader["ADDR_CITY"].ToString();
- ADDR_Town = reader["ADDR_TOWN"].ToString();
- ADDR_Road = reader["ADDR_ROAD"].ToString();
- ADDR_Other = reader["ADDR_OTHER"].ToString();
- RecallName = reader["RECALLNAME"].ToString();
- RecallTel = reader["RECALLTEL"].ToString();
- EventBrief = Int32.Parse(reader["EVENTBRIEF"].ToString());
- AcceptTime = reader["ACCEPTTIME"].ToString();
- CCSID = reader["CCSID"].ToString();
- ImportCase = Int32.Parse(reader["IMPORTCASE"].ToString());
- Dept = reader["DEPT"].ToString();
- PartHicustomer = Int32.Parse(reader["PARTHICUSTOMER"].ToString());
- Note = reader["NOTE"].ToString();
+ _meter = reader["METER"].ToString();
+ _customerName = reader["CUSTOMERNAME"].ToString();
+ _customerTel = reader["CUSTOMERTEL"].ToString();
+ _addrCity = reader["ADDR_CITY"].ToString();
+ _addrTown = reader["ADDR_TOWN"].ToString();
+ _addrRoad = reader["ADDR_ROAD"].ToString();
+ _addrOther = reader["ADDR_OTHER"].ToString();
+ _recallName = reader["RECALLNAME"].ToString();
+ _recallTel = reader["RECALLTEL"].ToString();
+ _eventBrief = int.Parse(reader["EVENTBRIEF"].ToString());
+ _acceptTime = reader["ACCEPTTIME"].ToString();
+ _ccsid = reader["CCSID"].ToString();
+ _importCase = int.Parse(reader["IMPORTCASE"].ToString());
+ _dept = reader["DEPT"].ToString();
+ _partHicustomer = int.Parse(reader["PARTHICUSTOMER"].ToString());
+ _note = reader["NOTE"].ToString();
}
}
catch (Exception e)
{
- _PLog.Error("無法取得CCS報案資訊!" + e.Message);
+ pLog.Error("無法取得CCS報案資訊!" + e.Message);
Console.WriteLine(e.StackTrace);
- if (LocalVariable.ShowError)
- _PLog.Error(e.StackTrace);
+ if (GlobalVariable.ShowError)
+ pLog.Error(e.StackTrace);
throw e;
}
finally
- {
+ {
reader.Close();
- Command.Dispose();
+ command.Dispose();
}
}
- public bool InsertDB(OracleConnection _ConnectionTPC, System.Data.OracleClient.OracleTransaction _Transaction, SEventLog _PLog)
+ public string Meter => _meter;
+
+ public string CustomerName => _customerName;
+
+ public string CustomerTel => _customerTel;
+
+ public string AddressCity => _addrCity;
+
+ public string AddressTown => _addrTown;
+
+ public string AddressRoad => _addrRoad;
+
+ public string AddressOther => _addrOther;
+
+ public string RecallTel => _recallTel;
+
+ public string RecallName => _recallName;
+
+ public int EventBrief => _eventBrief;
+
+ public string AcceptTime => _acceptTime;
+
+ public string CcsId => _ccsid;
+
+ public int ImportCase => _importCase;
+
+ public string Detp => _dept;
+
+ public int PartHicustomer => _partHicustomer;
+
+ public string Note => _note;
+
+ public bool InsertDb(OracleConnection connectionTpc, OracleTransaction transaction, SEventLog pLog)
{
- String SqlStmt;
+ var sqlStmt = "INSERT INTO CCS.EVENTRECORD VALUES ('" + _meter + "','" + _customerName + "','" + _customerTel + "','" + _addrCity + "','"
+ + _addrTown + "','" + _addrRoad + "','" + _addrOther + "','" + _recallName + "','" + _recallTel + "',"
+ + _eventBrief + ",TO_DATE('" + _acceptTime + "','YYYY/MM/DD HH24:MI:SS'),'" + _ccsid + "'," + _importCase + ",'" + _dept + "',"
+ + _partHicustomer + ",'" + _note + "')";
- SqlStmt = "INSERT INTO CCS.EVENTRECORD VALUES ('" + this.Meter + "','" + CustomerName + "','" + CustomerTel + "','" + ADDR_City + "','"
- + ADDR_Town + "','" + ADDR_Road + "','" + ADDR_Other + "','" + RecallName + "','" + RecallTel + "',"
- + EventBrief + ",TO_DATE('" + AcceptTime + "','YYYY/MM/DD HH24:MI:SS'),'" + CCSID + "'," + ImportCase + ",'" + Dept + "',"
- + PartHicustomer + ",'" + Note + "')";
-
- OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
+ OracleCommand command = new OracleCommand(sqlStmt, connectionTpc, transaction);
try
{
- if (Command.ExecuteNonQuery() != 1)
+ if (command.ExecuteNonQuery() != 1)
{
- _PLog.Error("CCS 案件受理程序初始化失敗...無法將CCS報案資訊存入資料庫中!");
+ pLog.Error("CCS 案件受理程序初始化失敗...無法將CCS報案資訊存入資料庫中!");
throw new Exception("CCS 案件受理程序初始化失敗...無法將CCS報案資訊存入資料庫中!");
}
@@ -127,98 +147,18 @@
{
Console.WriteLine(e.StackTrace);
- if (LocalVariable.ShowError)
- _PLog.Error(e.StackTrace);
+ if (GlobalVariable.ShowError)
+ pLog.Error(e.StackTrace);
- _PLog.Error("CCS 案件受理程序初始化失敗...無法將CCS報案資訊存入資料庫中!" + e.Message);
+ pLog.Error("CCS 案件受理程序初始化失敗...無法將CCS報案資訊存入資料庫中!" + e.Message);
//throw new Exception("CCS 案件受理程序初始化失敗...無法將CCS報案資訊存入資料庫中");
- throw e;
+ throw;
}
finally
{
- Command.Dispose();
+ command.Dispose();
}
return true;
}
-
- public String getMeter()
- {
- return this.Meter;
- }
-
- public String getCustomerName()
- {
- return this.CustomerName;
- }
-
- public String getCustomerTel()
- {
- return this.CustomerTel;
- }
-
- public String getADDR_City()
- {
- return this.ADDR_City;
- }
-
- public String getADDR_Town()
- {
- return this.ADDR_Town;
- }
-
- public String getADDR_Road()
- {
- return this.ADDR_Road;
- }
-
- public String getADDR_Other()
- {
- return this.ADDR_Other;
- }
-
- public String getRecallName()
- {
- return this.RecallName;
- }
-
- public String getRecallTel()
- {
- return this.RecallTel;
- }
-
- public int getEventBrief()
- {
- return this.EventBrief;
- }
-
- public String getAcceptTime()
- {
- return this.AcceptTime;
- }
-
- public String getCCSID()
- {
- return this.CCSID;
- }
-
- public int getImportCase()
- {
- return this.ImportCase;
- }
-
- public String getDetp()
- {
- return this.Dept;
- }
-
- public int getPartHicustomer()
- {
- return PartHicustomer;
- }
-
- public String getNote()
- {
- return this.Note;
- }
}
-}
+}
\ No newline at end of file
--
Gitblit v0.0.0-SNAPSHOT