New file |
| | |
| | | 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.Xml;
|
| | | using System.Runtime.CompilerServices;
|
| | | using System.Threading;
|
| | |
|
| | |
|
| | | namespace CCSTrace.CCS
|
| | | {
|
| | | public class CCSMain
|
| | | {
|
| | | private static CCSMain _instance;
|
| | | public static CCS.Object.CCSCodelist CCSCodelist;
|
| | | public static CCS.Object.EOSCodelist EOSCodelist;
|
| | | public static System.Collections.ArrayList DBConnList = new System.Collections.ArrayList();
|
| | | public static System.Collections.ArrayList ProcessCases = new System.Collections.ArrayList();
|
| | |
|
| | | private string LoadFilename = "DBConfig.xml";
|
| | | private string ConnectionString = "";
|
| | | private int ConnectionCount = 1;
|
| | | public static System.Data.OracleClient.OracleConnection MainConn = null;
|
| | | static SEventLog _MainLog = null;
|
| | |
|
| | | public static System.Collections.Hashtable ProcessFDR = new System.Collections.Hashtable();//Record the processing FDR
|
| | | public static System.Collections.ArrayList WaitingCases = new System.Collections.ArrayList();//Record the case when the case's FDR processed by another
|
| | |
|
| | | public CCSMain()
|
| | | {
|
| | | Initial();
|
| | | }
|
| | |
|
| | | public static CCSMain Instance()
|
| | | {
|
| | |
|
| | | // Uses lazy initialization.
|
| | |
|
| | | // Note: this is not thread safe.
|
| | |
|
| | | if (_instance == null)
|
| | | {
|
| | | _instance = new CCSMain();
|
| | |
|
| | | }
|
| | | return _instance;
|
| | |
|
| | | }
|
| | |
|
| | | private void Initial()
|
| | | {
|
| | | _MainLog = new SEventLog();
|
| | |
|
| | | try
|
| | | {
|
| | | ReadXML();
|
| | |
|
| | | if (MainConn == null)
|
| | | MainConn = CreateConnection();
|
| | | //MainConn = CreateMainConnection();
|
| | |
|
| | | CCSCodelist = new CCSTrace.CCS.Object.CCSCodelist(MainConn);
|
| | | EOSCodelist = new CCSTrace.CCS.Object.EOSCodelist(MainConn);
|
| | |
|
| | | for (int i = 0; i < ConnectionCount; i++)
|
| | | DBConnList.Add(CreateConnection());
|
| | | }
|
| | | catch(Exception e)
|
| | | {
|
| | | Console.WriteLine(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | _MainLog.Error(e.Message);
|
| | |
|
| | | if (LocalVariable.ShowError)
|
| | | _MainLog.Error(e.StackTrace);
|
| | |
|
| | | throw e;
|
| | | }
|
| | | finally
|
| | | {
|
| | | _MainLog.Close();
|
| | | }
|
| | |
|
| | | Object.CCSRecord m_Record = getWaitRecord();
|
| | |
|
| | | if (m_Record != null)
|
| | | {
|
| | | System.Data.OracleClient.OracleConnection _Conn = (System.Data.OracleClient.OracleConnection)DBConnList[0];
|
| | | DBConnList.Remove(_Conn);
|
| | |
|
| | | ProcessCase(m_Record, _Conn);
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public void AcceptEvent(Object.CCSRecord _Record)
|
| | | {
|
| | | int i = 0;
|
| | | int ReConnectCount = 1;
|
| | |
|
| | |
|
| | | while ( i <= ReConnectCount )
|
| | | {
|
| | | try
|
| | | {
|
| | | if (InsertEventRecord(_Record))
|
| | | {
|
| | | if (DBConnList.Count > 0)
|
| | | {
|
| | |
|
| | | //將EVETNQUERY的案件狀態改為開始處理
|
| | | Object.CCSRecord m_Record = getWaitRecord();
|
| | |
|
| | | if (m_Record != null)
|
| | | {
|
| | | System.Data.OracleClient.OracleConnection _Conn = (System.Data.OracleClient.OracleConnection)DBConnList[0];
|
| | | DBConnList.Remove(_Conn);
|
| | |
|
| | | ProcessCase(m_Record, _Conn);
|
| | | }
|
| | | }
|
| | |
|
| | | break;
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | if (MainConn.State.ToString().Equals("Closed"))
|
| | | {
|
| | | i++;
|
| | | if (i > ReConnectCount)
|
| | | throw ex;
|
| | | }
|
| | | else
|
| | | throw ex;
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | }
|
| | |
|
| | | private void ReadXML()
|
| | | {
|
| | | XmlReader reader = null;
|
| | |
|
| | | try
|
| | | {
|
| | | // 建立 XML 讀取器
|
| | | XmlReaderSettings settings = new XmlReaderSettings();
|
| | | settings.IgnoreComments = true; // 不處理註解
|
| | | settings.IgnoreWhitespace = true; // 跳過空白
|
| | | settings.ValidationType = ValidationType.None; // 不驗證任何資料
|
| | | reader = XmlTextReader.Create(System.AppDomain.CurrentDomain.BaseDirectory + "\\" + LoadFilename, settings);
|
| | |
|
| | | // 進入讀取主要部分
|
| | | while (reader.Read())
|
| | | {
|
| | | switch (reader.NodeType)
|
| | | {
|
| | | case XmlNodeType.Element:
|
| | | string LocalName = reader.LocalName; // 取得標籤名稱
|
| | |
|
| | | // Step 3: 讀取 FileInfo 標籤的屬性
|
| | | if (LocalName.Equals("DBSetting"))
|
| | | {
|
| | | ConnectionString = reader["ConnectionString"];
|
| | | ConnectionCount = Int32.Parse(reader["ConnectionCount"]);
|
| | | LocalVariable.ShowError = bool.Parse(reader["ShowError"]);
|
| | | }
|
| | |
|
| | | break;
|
| | | }
|
| | | }
|
| | | reader.Close();
|
| | |
|
| | | }
|
| | | catch (System.Xml.XmlException xe)
|
| | | {
|
| | | Console.WriteLine(xe.StackTrace);
|
| | | reader.Close();
|
| | | }
|
| | | }
|
| | |
|
| | | private System.Data.OracleClient.OracleConnection CreateConnection()
|
| | | {
|
| | | System.Data.OracleClient.OracleConnection DBConn = new System.Data.OracleClient.OracleConnection(ConnectionString);
|
| | | |
| | | DBConn.Open();
|
| | |
|
| | | return DBConn;
|
| | | }
|
| | |
|
| | | [MethodImpl(MethodImplOptions.Synchronized)]
|
| | | private bool InsertEventRecord(Object.CCSRecord _Record)
|
| | | {
|
| | | Object.EventQuery _EventQuery = null;
|
| | | System.Data.OracleClient.OracleTransaction _Transaction = null;
|
| | |
|
| | | try
|
| | | {
|
| | | _MainLog = new SEventLog();
|
| | |
|
| | | if (MainConn.State.ToString().Equals("Closed"))
|
| | | MainConn.Open();
|
| | |
|
| | | _Transaction = MainConn.BeginTransaction();
|
| | |
|
| | | if (_Record.InsertDB(MainConn, _Transaction, _MainLog))
|
| | | {
|
| | | _EventQuery = new CCSTrace.CCS.Object.EventQuery();
|
| | |
|
| | | _EventQuery.setCCSID(_Record.getCCSID());
|
| | | _EventQuery.setMeter(_Record.getMeter());
|
| | | _EventQuery.setCaseStatus(LocalVariable.EventInitial);
|
| | | _EventQuery.setChangeTime(_Record.getAcceptTime());
|
| | |
|
| | | if (_EventQuery.Insert(_MainLog, MainConn, _Transaction))
|
| | | _Transaction.Commit();
|
| | | else
|
| | | {
|
| | | if (_Transaction.Connection.State.ToString().Equals("Open"))
|
| | | _Transaction.Rollback();
|
| | | |
| | | throw new Exception("案件未受理成功。");
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | if (_Transaction.Connection.State.ToString().Equals("Open"))
|
| | | _Transaction.Rollback();
|
| | | |
| | | throw new Exception("案件未受理成功。");
|
| | | }
|
| | |
|
| | | }
|
| | | catch (System.Data.OracleClient.OracleException e)
|
| | | {
|
| | | Console.WriteLine(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | _MainLog.Error(e.Message);
|
| | |
|
| | | if (LocalVariable.ShowError)
|
| | | _MainLog.Error(e.StackTrace);
|
| | |
|
| | | if (_Transaction != null && _Transaction.Connection.State.ToString().Equals("Open") )
|
| | | _Transaction.Rollback();
|
| | |
|
| | | throw e;
|
| | | }
|
| | | catch(Exception ex)
|
| | | {
|
| | | Console.WriteLine(ex.Message);
|
| | | Console.WriteLine(ex.StackTrace);
|
| | | _MainLog.Error(ex.Message);
|
| | |
|
| | | if (LocalVariable.ShowError)
|
| | | _MainLog.Error(ex.StackTrace);
|
| | |
|
| | | if (_Transaction != null && _Transaction.Connection.State.ToString().Equals("Open") )
|
| | | _Transaction.Rollback();
|
| | |
|
| | | throw ex;
|
| | | }
|
| | | finally
|
| | | {
|
| | | _MainLog.Close();
|
| | | }
|
| | |
|
| | | return true;
|
| | | }
|
| | |
|
| | | delegate void WorkerThreadHandler();
|
| | |
|
| | | private void ProcessCase(Object.CCSRecord _Record, System.Data.OracleClient.OracleConnection _Conn)
|
| | | {
|
| | | try
|
| | | {
|
| | | if (_Conn.State.ToString().Equals("Closed"))
|
| | | _Conn.Open();
|
| | |
|
| | | ProcessEvent _ProcessEvent = new ProcessEvent(_Record,_Conn);
|
| | | _ProcessEvent.ThreadFinish += new ThreadEndEventHandler(ThreadEndEventProcess);
|
| | |
|
| | | System.Threading.ThreadStart _ThreadStart = new System.Threading.ThreadStart(_ProcessEvent.Run);
|
| | | System.Threading.Thread _Thread = new System.Threading.Thread(_ThreadStart);
|
| | | _Thread.Start();
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | DBConnList.Add(_Conn);
|
| | | }
|
| | |
|
| | |
|
| | | }
|
| | |
|
| | | private void ThreadEndEventProcess(object sender, ThreadEndEvent e)
|
| | | {
|
| | | //將EVETNQUERY的案件狀態改為開始處理
|
| | | Object.CCSRecord m_Record = getWaitRecord();
|
| | |
|
| | | try
|
| | | {
|
| | | if (m_Record != null)
|
| | | ProcessCase(m_Record, e.getConnection());
|
| | | else
|
| | | DBConnList.Add(e.getConnection());
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | DBConnList.Add(e.getConnection());
|
| | | }
|
| | | } |
| | |
|
| | | [MethodImpl(MethodImplOptions.Synchronized)]
|
| | | private Object.CCSRecord getWaitRecord() |
| | | {
|
| | | String ProcessCCSID = "";
|
| | | String CCSID = "";
|
| | | Object.CCSRecord _Record = null;
|
| | |
|
| | | foreach (String[] Obj in WaitingCases)
|
| | | {
|
| | | String _CCSID = Obj[0];
|
| | | String _FDRID = Obj[1];
|
| | |
|
| | | if (ProcessFDR.ContainsKey(_FDRID)) //該條饋線仍有案件在處理中
|
| | | ProcessCCSID = ProcessCCSID + "'" + _CCSID + "',";
|
| | | else
|
| | | {
|
| | | CCSID = _CCSID;
|
| | | WaitingCases.Remove(Obj);
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | if (CCSID.Length == 0) //沒有因同饋線而在等候中的案件
|
| | | {
|
| | | String SqlStmt = "SELECT Q.CCSID AS CCSID FROM CCS.EVENTQUERY Q,CCS.EVENTRECORD R WHERE Q.CASESTATUS IN (" + LocalVariable.EventInitial + "," + LocalVariable.EventProcess + ")";
|
| | | System.Collections.IEnumerator Enum = ProcessCases.GetEnumerator();
|
| | |
|
| | | while (Enum.MoveNext())
|
| | | ProcessCCSID = ProcessCCSID + "'" + Enum.Current.ToString() + "',";
|
| | |
|
| | | if (ProcessCCSID.Length != 0)
|
| | | SqlStmt = SqlStmt + " AND Q.CCSID NOT IN (" + ProcessCCSID.Substring(0, ProcessCCSID.Length - 1) + ")";
|
| | |
|
| | | SqlStmt = SqlStmt + " AND Q.CCSID = R.CCSID AND ROWNUM < 2 ORDER BY Q.ChangeTime";
|
| | | System.Data.OracleClient.OracleCommand Command = new System.Data.OracleClient.OracleCommand(SqlStmt, MainConn);
|
| | | System.Data.OracleClient.OracleDataReader reader = Command.ExecuteReader();
|
| | |
|
| | | try
|
| | | {
|
| | | if (reader.Read())
|
| | | CCSID = reader["CCSID"].ToString();
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Log(e.Message);
|
| | | _MainLog.Error("無法取得等候處理CCS案件資料。錯誤訊息 = " + e.Message);
|
| | |
|
| | | if (LocalVariable.ShowError)
|
| | | _MainLog.Error(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | {
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | | }
|
| | |
|
| | | if (CCSID.Length != 0)
|
| | | _Record = new Object.CCSRecord(CCSID, MainConn, _MainLog);
|
| | |
|
| | | if (_Record != null)
|
| | | {
|
| | | CCS.Object.EventQuery EventQuery = new CCSTrace.CCS.Object.EventQuery();
|
| | | //先將EVETNQUERY的案件狀態改為開始處理
|
| | | EventQuery.setCCSID(_Record.getCCSID());
|
| | | EventQuery.setCaseStatus(LocalVariable.EventProcess);
|
| | |
|
| | | System.Data.OracleClient.OracleTransaction _Transaction = MainConn.BeginTransaction();
|
| | |
|
| | | try
|
| | | {
|
| | |
|
| | | if (EventQuery.UpdateCaseStatus(_MainLog, MainConn, _Transaction))
|
| | | {
|
| | | _MainLog.Info("更新EVENTQUERY的案件狀態為處理中.(CCSID = " + _Record.getCCSID() + ")");
|
| | | _Transaction.Commit();
|
| | | ProcessCases.Add(_Record.getCCSID());
|
| | | }
|
| | | else
|
| | | {
|
| | | _MainLog.Error("無法更新EVENTQUERY的案件狀態.(CCSID = " + _Record.getCCSID() + ")");
|
| | |
|
| | | if (_Transaction.Connection.State.ToString().Equals("Open"))
|
| | | _Transaction.Rollback();
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | if (_Transaction.Connection.State.ToString().Equals("Open"))
|
| | | _Transaction.Rollback();
|
| | |
|
| | | Log(e.Message);
|
| | | _Record = null;
|
| | | }
|
| | | }
|
| | |
|
| | | return _Record;
|
| | | }
|
| | |
|
| | | RecordLog _PLog = new RecordLog(CCS.LocalVariable.CCS_ListPath + "MAIN.txt");
|
| | | private void Log(String message)
|
| | | {
|
| | | _PLog.Error(message);
|
| | | _PLog.Close();
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
New file |
| | |
| | | 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;
|
| | |
|
| | | namespace CCSTrace.CCS.EventAI
|
| | | {
|
| | | public class Equipment
|
| | | {
|
| | | int FSC;
|
| | | int UFID;
|
| | |
|
| | | public Equipment(int m_Fsc, int m_Ufid)
|
| | | {
|
| | | this.FSC = m_Fsc;
|
| | | this.UFID = m_Ufid;
|
| | | }
|
| | |
|
| | | public int getFSC()
|
| | | {
|
| | | return FSC;
|
| | | }
|
| | |
|
| | | public int getUFID()
|
| | | {
|
| | | return UFID;
|
| | | }
|
| | | }
|
| | | }
|
New file |
| | |
| | | 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.Collections;
|
| | | using System.Data.OracleClient;
|
| | |
|
| | | namespace CCSTrace.CCS.EventAI
|
| | | {
|
| | | public class JudgeCase
|
| | | {
|
| | | TraceSubject m_TraceSubject;
|
| | | System.Collections.ArrayList m_Case = new System.Collections.ArrayList();
|
| | | int Damage_FdrID;
|
| | | int Damage_Fsc; // 新案件的損壞設備種類
|
| | | int Damage_Ufid; // 新案件的損壞設備編號
|
| | | int New_CaseID;
|
| | | String AcceptDate;
|
| | | System.Collections.ArrayList New_Case;
|
| | | System.Collections.Hashtable Old_Case;
|
| | | int Infer_Fsc; // 推測出可能受損的設備種類
|
| | | int Infer_Ufid; // 推測出可能受損的設備編號
|
| | | int Parent_CaseID = 0;
|
| | | CCS.EventAI.Equipment m_Equip;
|
| | |
|
| | | private OracleConnection _ConnectionTPC;
|
| | | private OracleTransaction _Transaction;
|
| | | private RecordLog _PLog;
|
| | |
|
| | | // int Range = 360; //比事故案件還早多久時間內的案件才作合併 單位:分
|
| | |
|
| | | public JudgeCase(int m_FdrID, int m_fsc, int m_ufid, int m_CaseID, String m_AcceptDate, OracleConnection _Connection, OracleTransaction _Trx, RecordLog _Log)
|
| | | {
|
| | | this.Damage_FdrID = m_FdrID;
|
| | | this.Damage_Fsc = m_fsc;
|
| | | this.Damage_Ufid = m_ufid;
|
| | | this.New_CaseID = m_CaseID;
|
| | | this.AcceptDate = m_AcceptDate;
|
| | |
|
| | | _ConnectionTPC = _Connection;
|
| | | _Transaction = _Trx;
|
| | | _PLog = _Log;
|
| | | }
|
| | |
|
| | | public void AIBegin() {
|
| | | _PLog.Info("進行案件追蹤合併.");
|
| | | String SqlStmt;
|
| | | // String ToTime = AcceptDate;
|
| | |
|
| | | SqlStmt = "SELECT R.ACCEPTNUM,R.CASEID as CASEID,R.FDRID as FDRID,R.FSC as FSC,R.UFID as UFID,E.CASESTATUS as CASESTATUS,R.EVENTBRIEF as BRIEF "
|
| | | + "FROM EOS.EVENTRECORD R,EOS.EVENTS E WHERE E.CASEID = R.CASEID AND R.TRACE_FINISH = " + CCS.LocalVariable.Trace_Still
|
| | | + " AND E.CASETYPE <> " + CCS.LocalVariable.ChildCase + " AND R.FDRID = " + this.Damage_FdrID;
|
| | |
|
| | | OracleCommand Command = null;
|
| | | OracleDataReader reader = null;
|
| | |
|
| | | try
|
| | | {
|
| | | _PLog.Info("搜尋同一饋線上可供合併之母案件.");
|
| | | Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | reader = Command.ExecuteReader();
|
| | |
|
| | | // 找出同一饋線上處理中的母案件(可作合併的)
|
| | | // 該饋線上有可能有二件或兩件以上的母案件
|
| | | while (reader.Read())
|
| | | {
|
| | | System.Collections.ArrayList Record = new System.Collections.ArrayList();
|
| | | Record.Add(Convert.ToInt32(reader["CASEID"].ToString()));
|
| | | Record.Add(Convert.ToInt32(reader["FDRID"].ToString()));
|
| | | Record.Add(Convert.ToInt32(reader["FSC"].ToString()));
|
| | | Record.Add(Convert.ToInt32(reader["UFID"].ToString()));
|
| | | Record.Add(Convert.ToInt32(reader["CASESTATUS"].ToString()));
|
| | | CCS.EventAI.Equipment Tmp = new CCS.EventAI.Equipment(Convert.ToInt32(reader["FSC"].ToString()), Convert.ToInt32(reader["UFID"].ToString()));
|
| | | Record.Add(Tmp);
|
| | | Record.Add(reader["BRIEF"].ToString());
|
| | | Record.Add(reader["ACCEPTNUM"].ToString());
|
| | | m_Case.Add(Record);
|
| | | _PLog.Info(Record[7].ToString() + ", " + Record[0]);
|
| | | }
|
| | | reader.Close();
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | _PLog.Error("尋找母案件時發生錯誤.");
|
| | | throw e;
|
| | | }
|
| | | finally
|
| | | {
|
| | | if (Command != null)
|
| | | Command.Dispose();
|
| | |
|
| | | if (reader != null)
|
| | | reader.Close();
|
| | | }
|
| | |
|
| | | // 若事故案件為該饋線上的第一件事故案件時,無須再作追蹤比較
|
| | | if (m_Case.Count == 0) {
|
| | | Infer_Fsc = this.Damage_Fsc;
|
| | | Infer_Ufid = this.Damage_Ufid;
|
| | | _PLog.Info("此案件為饋線上第一件案件");
|
| | | _PLog.Info("追蹤合併結束.");
|
| | | return;
|
| | | }
|
| | |
|
| | | // 判斷是否為同一變壓器,如果是就不必作追蹤
|
| | | try {
|
| | | for (int i = 0; i < m_Case.Count; i++) {
|
| | | if ( (Convert.ToInt32(((ArrayList) m_Case[i])[2].ToString()) == Damage_Fsc) && |
| | | (Convert.ToInt32(((ArrayList) m_Case[i])[3].ToString()) == Damage_Ufid)) |
| | | {
|
| | | if (((ArrayList) m_Case[i])[6].ToString().StartsWith("A")) // 若母案件事故原因為A類才做合併
|
| | | { |
| | | Parent_CaseID = Convert.ToInt32(((ArrayList) m_Case[i])[0].ToString());
|
| | | Infer_Fsc = Convert.ToInt32(((ArrayList) m_Case[i])[2].ToString());
|
| | | Infer_Ufid = Convert.ToInt32(((ArrayList) m_Case[i])[3].ToString());
|
| | | _PLog.Info("相同變壓器");
|
| | | _PLog.Info("與案件"+((ArrayList) m_Case[i])[7]+"合併,故障點Fsc: "+Infer_Fsc+" Ufid: "+Infer_Ufid);
|
| | | return;
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | _PLog.Error(ex.Message);
|
| | | throw ex;
|
| | | }
|
| | | _PLog.Info("不同變壓器,開始追蹤(New Version)...");
|
| | |
|
| | | this.TraceCase();
|
| | | _PLog.Warn("追蹤合併結束");
|
| | | }
|
| | |
|
| | | private void TraceCase() {
|
| | | int m_Key;
|
| | |
|
| | | try {
|
| | | this.m_TraceSubject = new CCS.EventAI.TraceSubject(_ConnectionTPC, _Transaction,_PLog);
|
| | | _PLog.Info("TraceSubject Initial....");
|
| | | }
|
| | | catch (Exception ex) {
|
| | | _PLog.Error("TraceObject.dll無法初始化,請確認該元件是否存在或jre是否為 1.4 版,並確認是否註冊.");
|
| | | throw ex;
|
| | | }
|
| | |
|
| | | try {
|
| | | this.m_TraceSubject.startTrace(Damage_Fsc, Damage_Ufid, true);
|
| | | New_Case = this.m_TraceSubject.getNewResult(); // 新案件所建出來的linkedlist(往上追到breaker)
|
| | | _PLog.Info("追蹤新案件完成");
|
| | |
|
| | | for (int i = 0; i < m_Case.Count; i++) {
|
| | | if (this.AlreadyFinishCase(Convert.ToInt32(((ArrayList) m_Case[i])[0].ToString()))) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | ArrayList FacilitySet = this.RealDamageEquipment(Convert.ToInt32(((ArrayList)m_Case[i])[0].ToString())); // 切開的設備
|
| | |
|
| | | if (FacilitySet.Count == 0) {
|
| | | this.m_TraceSubject.startTrace(Convert.ToInt32(((ArrayList)m_Case[i])[2].ToString()),
|
| | | Convert.ToInt32(((ArrayList)m_Case[i])[3].ToString()), false);
|
| | | Old_Case = this.m_TraceSubject.getOldResult(); // 母案件所建出來的TreeMap(往上追到breaker)
|
| | | _PLog.Info("追蹤母案件完成");
|
| | |
|
| | | for (int j = 0; j < New_Case.Count; j++) {
|
| | | m_Key = ((Equipment) New_Case[j]).getUFID();
|
| | |
|
| | | if (Old_Case.ContainsKey(m_Key)) |
| | | {
|
| | | if (((ArrayList)m_Case[i])[6].ToString().StartsWith("A")) // 若母案件事故原因為A類才做合併
|
| | | {
|
| | | this.Parent_CaseID = Convert.ToInt32(((ArrayList)m_Case[i])[0].ToString());
|
| | | Infer_Fsc = ((Equipment) New_Case[j]).getFSC();
|
| | | Infer_Ufid = ((Equipment) New_Case[j]).getUFID();
|
| | | this.m_Equip = (CCS.EventAI.Equipment) ((ArrayList) m_Case[i])[5];
|
| | | _PLog.Info("與案件"+((ArrayList) m_Case[i])[7]+"合併,故障點Fsc: "+Infer_Fsc+" Ufid: "+Infer_Ufid);
|
| | | return;
|
| | | }
|
| | | }
|
| | | }
|
| | | } else {
|
| | | for (int k = 0; k < FacilitySet.Count; k++) |
| | | {
|
| | | bool Merge = false; // 損壞設備是否在所切開的設備下游
|
| | | Equipment DamageEquipment = (Equipment) FacilitySet[k]; // 切開的設備
|
| | | |
| | | for (int z = 0; z < New_Case.Count; z++) |
| | | {
|
| | | if ( (((Equipment) New_Case[z]).getFSC() == DamageEquipment.getFSC()) && |
| | | (((Equipment) New_Case[z]).getUFID() == DamageEquipment.getUFID())) |
| | | {
|
| | | Merge = true;
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | // 當發現在所切開開關的下游,就將損壞設備指向切開的設備並return
|
| | | if (Merge) |
| | | {
|
| | | if (((ArrayList)m_Case[i])[6].ToString().StartsWith("A")) // 若母案件事故原因為A類才做合併
|
| | | {
|
| | | this.Parent_CaseID = Convert.ToInt32(((ArrayList)m_Case[i])[0].ToString());
|
| | | Infer_Fsc = DamageEquipment.getFSC();
|
| | | Infer_Ufid = DamageEquipment.getUFID();
|
| | | this.m_Equip = (CCS.EventAI.Equipment) ((ArrayList) m_Case[i])[5];
|
| | | _PLog.Info("與案件"+((ArrayList) m_Case[i])[7]+"合併,故障點Fsc: "+Infer_Fsc+" Ufid: "+Infer_Ufid);
|
| | | return;
|
| | | }
|
| | |
|
| | | }
|
| | | } // for loop(k)
|
| | | } // else
|
| | | } // for loop(i)
|
| | | } catch (Exception ex) {
|
| | | _PLog.Error(ex.Message);
|
| | | _PLog.Error("追蹤時發生錯誤.");
|
| | | throw ex;
|
| | | }
|
| | | finally
|
| | | {
|
| | | this.m_TraceSubject.discardEngine();
|
| | | }
|
| | |
|
| | | Infer_Fsc = this.Damage_Fsc;
|
| | | Infer_Ufid = this.Damage_Ufid;
|
| | | this.m_TraceSubject.discardEngine();
|
| | | return;
|
| | | }
|
| | |
|
| | | public Equipment getInferEquipment() {
|
| | | Equipment Equip = new Equipment(this.Infer_Fsc, this.Infer_Ufid);
|
| | | return Equip;
|
| | | }
|
| | |
|
| | | public Equipment getOldrEquipment() {
|
| | | return m_Equip;
|
| | | }
|
| | |
|
| | | public int getParentCaseID() {
|
| | | return Parent_CaseID;
|
| | | }
|
| | |
|
| | | private bool AlreadyFinishCase(int CaseID) {
|
| | | String SqlStmt;
|
| | | bool Result = false;
|
| | |
|
| | | SqlStmt = "SELECT TO_CHAR(CLOSETIME,'YYYY/MM/DD HH24:MI:SS') as CLOSETIME,COUNT(*) as COUNT FROM EOS.EVENTFACILITY " + "WHERE CASEID = "
|
| | | + CaseID + " GROUP BY CLOSETIME ORDER BY CLOSETIME DESC";
|
| | |
|
| | | OracleCommand Command = null;
|
| | | OracleDataReader reader = null;
|
| | |
|
| | | try
|
| | | {
|
| | | Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | reader = Command.ExecuteReader();
|
| | |
|
| | | if (reader.Read())
|
| | | {
|
| | | if (Convert.ToString(reader["CLOSETIME"]).Equals("null") || Convert.ToString(reader["CLOSETIME"]).Length == 0 )
|
| | | Result = false; // 有切開開關未恢復(Case in Process)
|
| | | else
|
| | | Result = true; // 有切開關但全都恢復(Case Finish)
|
| | |
|
| | | }
|
| | | else
|
| | | Result = false; // 未切過開關
|
| | |
|
| | | reader.Close();
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error("Problems occur: " + e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | {
|
| | | if (Command != null)
|
| | | Command.Dispose();
|
| | |
|
| | | if (reader != null)
|
| | | reader.Close();
|
| | | }
|
| | | return Result;
|
| | | }
|
| | |
|
| | | private System.Collections.ArrayList RealDamageEquipment(int CaseID) {
|
| | | System.Collections.ArrayList Result = new System.Collections.ArrayList();
|
| | | String SqlStmt;
|
| | |
|
| | | SqlStmt = "SELECT FSC,UFID FROM EOS.EVENTFACILITY WHERE CASEID = " + CaseID + " AND CLOSETIME IS NULL";
|
| | |
|
| | | OracleCommand Command = null;
|
| | | OracleDataReader reader = null;
|
| | |
|
| | | try
|
| | | {
|
| | | Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | reader = Command.ExecuteReader();
|
| | |
|
| | | while (reader.Read())
|
| | | {
|
| | | Equipment Tmp = new Equipment(Convert.ToInt32(reader["FSC"]), Convert.ToInt32(reader["UFID"]));
|
| | | Result.Add(Tmp);
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | // CCS.LocalVariable.ErrorLog.setErrorLog("Error in JudgeCase(RealDamageEquipment) :" + e.getMessage());
|
| | | _PLog.Error("Problems occur: " + e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | { |
| | | if (reader != null )
|
| | | reader.Close();
|
| | |
|
| | | if (Command != null )
|
| | | Command.Dispose();
|
| | | }
|
| | | return Result;
|
| | | }
|
| | | }
|
| | | }
|
New file |
| | |
| | | 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.Collections;
|
| | | using TRACEROBJECTLib;
|
| | | using System.Data.OracleClient;
|
| | |
|
| | | namespace CCSTrace.CCS.EventAI
|
| | | {
|
| | | public class TraceSubject
|
| | | {
|
| | | static String DEFAULTDBSTR;
|
| | | static bool IsNewCase;
|
| | | static ArrayList m_LinkList; // store the switch of the new case path
|
| | | static TraceEngine m_tEngine;
|
| | | static Hashtable m_TreeMap; // store the switch of the old case path
|
| | | static int s_Fsc;
|
| | | static int s_Ufid;
|
| | | private RecordLog _Plogger;
|
| | | private ArrayList m_Tmp = new ArrayList();
|
| | | private NetworkContext m_pContext;
|
| | |
|
| | | private OracleConnection _ConnectionTPC = null;
|
| | | private OracleTransaction _Transaction;
|
| | |
|
| | | public TraceSubject(OracleConnection _Conn, OracleTransaction _Trx, RecordLog _Log) |
| | | {
|
| | | _ConnectionTPC = _Conn;
|
| | | _Transaction = _Trx;
|
| | | _Plogger = _Log;
|
| | |
|
| | | try |
| | | {
|
| | | if (m_tEngine == null) {
|
| | | m_tEngine = new TraceEngine();
|
| | | }
|
| | | }
|
| | | catch (Exception ex) {
|
| | | _Plogger.Error(ex.Message);
|
| | | throw ex;
|
| | | }
|
| | | }
|
| | |
|
| | | public void discardEngine() {
|
| | | if (m_tEngine != null) {
|
| | | m_tEngine = null;
|
| | | }
|
| | | }
|
| | |
|
| | | public ArrayList getNewResult() {
|
| | | return m_LinkList;
|
| | | }
|
| | |
|
| | | public Hashtable getOldResult() {
|
| | | return m_TreeMap;
|
| | | }
|
| | |
|
| | | // for EOS(only get the reverse tree)
|
| | | public void startTrace(int Start_Fsc, int Start_Ufid, bool m_IsNew) {
|
| | | s_Fsc = Start_Fsc;
|
| | | s_Ufid = Start_Ufid;
|
| | | IsNewCase = m_IsNew;
|
| | | m_TreeMap = new Hashtable();
|
| | | m_LinkList = new ArrayList();
|
| | |
|
| | | try
|
| | | {
|
| | | this.setReverseTree(Trace(true));
|
| | | }
|
| | | catch (Exception e) {
|
| | | _Plogger.Error(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | throw e;
|
| | | }
|
| | | }
|
| | |
|
| | | private bool getSwitchOn(int UFID) {
|
| | | String SqlStmt;
|
| | |
|
| | | SqlStmt = "SELECT M.OSTATUS as OSTATUS FROM (SELECT UFID,OSTATUS FROM BASEDB.CONNECTIVITY WHERE FSC = 114) M,"
|
| | | + "BASEDB.SWITCH S WHERE M.UFID = S.UFID AND S.NSTATUS <> 0 AND M.UFID = " + UFID;
|
| | |
|
| | | OracleCommand Command = null;
|
| | | OracleDataReader reader = null;
|
| | |
|
| | | try
|
| | | {
|
| | | Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | reader = Command.ExecuteReader();
|
| | |
|
| | | if (reader.Read())
|
| | | {
|
| | | if (Convert.ToInt32(reader["OSTATUS"]) == 1)
|
| | | return true;
|
| | | }
|
| | | reader.Close();
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _Plogger.Error(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | {
|
| | | if (Command != null)
|
| | | Command.Dispose();
|
| | |
|
| | | if (reader != null)
|
| | | reader.Close();
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | private bool getJumperOn(int UFID) {
|
| | | String SqlStmt;
|
| | |
|
| | | SqlStmt = "SELECT OSTATUS FROM BASEDB.CONNECTIVITY WHERE FSC = 109 AND UFID = " + UFID;
|
| | |
|
| | | OracleCommand Command = null;
|
| | | OracleDataReader reader = null;
|
| | |
|
| | | try
|
| | | {
|
| | | Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | reader = Command.ExecuteReader();
|
| | |
|
| | | if (reader.Read())
|
| | | {
|
| | | if (Convert.ToInt32(reader["OSTATUS"]) == 1)
|
| | | return true;
|
| | | }
|
| | | reader.Close();
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _Plogger.Error(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | {
|
| | | if (Command != null)
|
| | | Command.Dispose();
|
| | |
|
| | | if (reader != null)
|
| | | reader.Close();
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | private Hashtable TraceCounts = new Hashtable();
|
| | |
|
| | | private void setReverseTree(ResultTree tree) {
|
| | | int i = 0;
|
| | | TreeIterator iti = null;
|
| | | bool ostatus = true;
|
| | |
|
| | | if (tree != null) {
|
| | | i = 0;
|
| | | iti = tree.CreateTreeIterator();
|
| | | bool isNotEnd = true;
|
| | |
|
| | | while (isNotEnd) {
|
| | |
|
| | | if (getTraceCount(iti.Value.ClassID, iti.Value.ObjectID) > 5)
|
| | | throw new TraceLoopException("追蹤產生迴圈狀況。(Fsc,Ufid) = (" + iti.Value.ClassID + "," + iti.Value.ObjectID + ")");
|
| | | else
|
| | | AddTraceCount(iti.Value.ClassID, iti.Value.ObjectID);
|
| | |
|
| | | while (iti.IsLeaf == 0)
|
| | | {
|
| | | TRACEROBJECTLib.TreeNode node = iti.Value;
|
| | |
|
| | | if ((node.ClassID == 114) || (node.ClassID == 108) || (node.ClassID == 109))
|
| | | {
|
| | | Equipment Equip = new Equipment(node.ClassID, node.ObjectID);
|
| | |
|
| | | if (IsNewCase)
|
| | | m_LinkList.Add(Equip);
|
| | | else {
|
| | | m_TreeMap.Add(node.ObjectID, Equip);
|
| | | m_Tmp.Add(Equip);
|
| | | }
|
| | | i++;
|
| | |
|
| | | /* if (getTraceCount(node.ClassID, node.ObjectID) > 2)
|
| | | throw new Exception("追蹤產生迴圈狀況。(Fsc,Ufid) = (" + node.ClassID + "," + node.ObjectID + ")");
|
| | | else
|
| | | AddTraceCount(node.ClassID, node.ObjectID);
|
| | | */ }
|
| | |
|
| | | Console.WriteLine(node.ClassID + "----->" + node.ObjectID);
|
| | | _Plogger.Info(node.ClassID + "----->" + node.ObjectID);
|
| | |
|
| | | iti.MoveDescent((short) 0);
|
| | | }
|
| | |
|
| | | // 當從breaker出來的導線不只一條時,breaker可能會不被add(因為breaker是leaf但其parent的DescentCount > 1,所以被忽略)
|
| | | /*
|
| | | * if ( ((com.origo.TraceModel.ITreeNode)iti.get_Value()).get_ClassID() == EOS.LocalVariable.Breaker ) {
|
| | | * com.origo.TraceModel.ITreeNode node = iti.get_Value(); Equipment Equip = new Equipment(node.get_ClassID(),node.get_ObjectID()); if (
|
| | | * IsNewCase ) m_LinkList.add(i,Equip); else { m_TreeMap.put(new Integer(node.get_ObjectID()),Equip); m_Tmp.add(Equip); }
|
| | | * System.out.println(node.get_ClassID() + "----->" + node.get_ObjectID()); System.out.println("Trace Finish...."); i++; break; }
|
| | | */
|
| | |
|
| | | if ((iti.Value).ClassID == CCS.LocalVariable.Breaker) {
|
| | | TRACEROBJECTLib.TreeNode node = iti.Value;
|
| | | Equipment Equip = new Equipment(node.ClassID, node.ObjectID);
|
| | |
|
| | | if (IsNewCase)
|
| | | m_LinkList.Add(Equip);
|
| | | else |
| | | {
|
| | | m_TreeMap.Add(node.ObjectID, Equip);
|
| | | m_Tmp.Add(Equip);
|
| | | }
|
| | | i++; //後面直接就FINISH,所以就不用判斷tracecount
|
| | |
|
| | | Console.WriteLine(node.ClassID + "----->" + node.ObjectID);
|
| | | _Plogger.Info(node.ClassID + "----->" + node.ObjectID);
|
| | | Console.WriteLine("Trace Finish....");
|
| | | _Plogger.Info("Trace Finish....");
|
| | | break;
|
| | | }
|
| | | // 當追蹤到被切開的開關且該上一層設備只有該開關一個child)
|
| | | else if (iti.Value.ClassID == CCS.LocalVariable.Switch || iti.Value.ClassID == CCS.LocalVariable.Jumper ) {
|
| | | TRACEROBJECTLib.TreeNode node = iti.Value;
|
| | | iti.MoveAscent();
|
| | |
|
| | | Equipment Equip = new Equipment(node.ClassID, node.ObjectID);
|
| | |
|
| | | if (isEndEquip(Equip))
|
| | | {
|
| | | if (IsNewCase)
|
| | | m_LinkList.Add(Equip);
|
| | | else
|
| | | {
|
| | | m_TreeMap.Add(node.ObjectID, Equip);
|
| | | m_Tmp.Add(Equip);
|
| | | }
|
| | | i++; //後面直接就FINISH,所以就不用判斷tracecount
|
| | |
|
| | | Console.WriteLine(node.ClassID + "----->" + node.ObjectID);
|
| | | _Plogger.Info(node.ClassID + "----->" + node.ObjectID);
|
| | | Console.WriteLine("Trace Finish....");
|
| | | _Plogger.Info("Trace Finish....");
|
| | | break;
|
| | | }
|
| | |
|
| | | //switch (node.ClassID)
|
| | | //{
|
| | | // case 114:
|
| | | // ostatus = getSwitchOn(node.ObjectID);
|
| | | // break;
|
| | | // case 109:
|
| | | // ostatus = getJumperOn(node.ObjectID);
|
| | | // break;
|
| | | //}
|
| | |
|
| | | //if (!ostatus && (iti.DescentCount == 1)) {
|
| | | // Equipment Equip = new Equipment(node.ClassID, node.ObjectID);
|
| | |
|
| | | // if (IsNewCase)
|
| | | // m_LinkList.Add(Equip);
|
| | | // else {
|
| | | // m_TreeMap.Add(node.ObjectID, Equip);
|
| | | // m_Tmp.Add(Equip);
|
| | | // }
|
| | | // i++;
|
| | |
|
| | | // Console.WriteLine(node.ClassID + "----->" + node.ObjectID);
|
| | | // _Plogger.Info(node.ClassID + "----->" + node.ObjectID);
|
| | | // Console.WriteLine("Trace Finish....");
|
| | | // _Plogger.Info("Trace Finish....");
|
| | | // break;
|
| | | //}
|
| | | } |
| | | else
|
| | | {
|
| | | TRACEROBJECTLib.TreeNode node = iti.Value;
|
| | | iti.MoveAscent();
|
| | |
|
| | | if (iti.DescentCount == 1)
|
| | | throw new Exception("追蹤到非開關類斷開之設備(Fsc = " + node.ClassID + ",Ufid = " + node.ObjectID);
|
| | | }
|
| | |
|
| | | for (int j = 1; j < iti.DescentCount; j++) {
|
| | | iti.MoveDescent((short) j);
|
| | |
|
| | | if (iti.IsLeaf == 1) {
|
| | | TRACEROBJECTLib.TreeNode node = iti.Value;
|
| | | Equipment Equip = new Equipment(node.ClassID, node.ObjectID);
|
| | |
|
| | | switch (node.ClassID) {
|
| | | case 108:
|
| | | if (IsNewCase)
|
| | | m_LinkList.Add(Equip);
|
| | | else |
| | | {
|
| | | m_TreeMap.Add(node.ObjectID, Equip);
|
| | | m_Tmp.Add(Equip);
|
| | | }
|
| | | |
| | | Console.WriteLine(node.ClassID + "----->" + node.ObjectID);
|
| | | _Plogger.Info(node.ClassID + "----->" + node.ObjectID);
|
| | | i++;
|
| | |
|
| | | /* if (getTraceCount(node.ClassID, node.ObjectID) > 2)
|
| | | throw new Exception("追蹤產生迴圈狀況。(Fsc,Ufid) = (" + node.ClassID + "," + node.ObjectID + ")");
|
| | | else
|
| | | AddTraceCount(node.ClassID, node.ObjectID);
|
| | | */
|
| | | break;
|
| | | case 109:
|
| | | case 114:
|
| | | switch (node.ClassID) |
| | | {
|
| | | case 114:
|
| | | ostatus = getSwitchOn(node.ObjectID);
|
| | | break;
|
| | | case 109:
|
| | | ostatus = getJumperOn(node.ObjectID);
|
| | | break;
|
| | | }
|
| | |
|
| | | // Only for switch because the breaker only has one node to descent
|
| | | if (!ostatus) {
|
| | | if (IsNewCase)
|
| | | m_LinkList.Add(Equip);
|
| | | else {
|
| | | m_TreeMap.Add(node.ObjectID, Equip);
|
| | | m_Tmp.Add(Equip);
|
| | | }
|
| | | |
| | | Console.WriteLine(node.ClassID + "----->" + node.ObjectID);
|
| | | _Plogger.Info(node.ClassID + "----->" + node.ObjectID);
|
| | | i++;
|
| | |
|
| | | /* if (getTraceCount(node.ClassID, node.ObjectID) > 2)
|
| | | throw new Exception("追蹤產生迴圈狀況。(Fsc,Ufid) = (" + node.ClassID + "," + node.ObjectID + ")");
|
| | | else
|
| | | AddTraceCount(node.ClassID, node.ObjectID);
|
| | | */
|
| | | }
|
| | | break;
|
| | | default:
|
| | | break;
|
| | | } // switch
|
| | |
|
| | | iti.MoveAscent();
|
| | | isNotEnd = false;
|
| | | } else {
|
| | | isNotEnd = true;
|
| | | break;
|
| | | }
|
| | | } // for
|
| | | } // while
|
| | | Console.WriteLine("Tree Node Count = " + i);
|
| | | _Plogger.Info("Tree Node Count = " + i);
|
| | | } else
|
| | | {
|
| | | Console.WriteLine("Tree is null");
|
| | | _Plogger.Info("Tree is null");
|
| | | throw new Exception("無法追蹤到任何設備,可能是該用戶所在變壓器設備連結性有問題。");
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | private ResultTree Trace(bool Reverse) {
|
| | | ResultTree tree = null;
|
| | |
|
| | | try {
|
| | | configTrace();
|
| | | _Plogger.Info("configTrace OK.");
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _Plogger.Error(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | return tree;
|
| | | }
|
| | |
|
| | | try {
|
| | | tree = ModeTrace(Reverse);
|
| | | }
|
| | | catch (Exception e) {
|
| | | _Plogger.Error(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | |
|
| | | return tree;
|
| | | }
|
| | |
|
| | | void configTrace() {
|
| | | if (DEFAULTDBSTR == null) {
|
| | | DEFAULTDBSTR = "basedb/basedb000@nntpc";
|
| | | }
|
| | | try {
|
| | | if (m_pContext == null) m_pContext = m_tEngine.teoCreateContext();
|
| | |
|
| | | if (m_pContext.IsConnected == 0) {
|
| | | m_pContext.Connect("", DEFAULTDBSTR);
|
| | | }
|
| | | }
|
| | | catch (Exception ex) {
|
| | | _Plogger.Error(ex.Message);
|
| | | }
|
| | | }
|
| | |
|
| | | private ResultTree ModeTrace(bool Reverse) {
|
| | | TravelContext tContext = new TravelContext();
|
| | | TravelStartCriterion sCriterion = new TravelStartCriterion();
|
| | | TravelTerminateCriterion eCriterion = new TravelTerminateCriterion();
|
| | |
|
| | | sCriterion.ClsID = (short) s_Fsc;
|
| | | sCriterion.ObjID = s_Ufid;
|
| | |
|
| | | if (Reverse) // 反向上追
|
| | | {
|
| | | sCriterion.StartMode = (TRAVELSTARTCRITERIONTYPE)(Convert.ToInt32(TRAVELSTARTCRITERIONTYPE.TRAVELBYNEGDIR) + Convert.ToInt32(TRAVELSTARTCRITERIONTYPE.TRAVELWITHFOLLOW));
|
| | |
|
| | | eCriterion.ClsID = (short)CCS.LocalVariable.Breaker;
|
| | | eCriterion.EndMode = TRAVELTERMCRITERIONTYPE.TRAVELTOTHISCLASS;
|
| | | } else // 順向追蹤
|
| | | {
|
| | | sCriterion.StartMode = TRAVELSTARTCRITERIONTYPE.TRAVELBYCURDIR;
|
| | |
|
| | | eCriterion.EndMode = TRAVELTERMCRITERIONTYPE.TRAVELTOTHISCLASS;
|
| | | }
|
| | |
|
| | | tContext.addCriterion(sCriterion);
|
| | | tContext.addCriterion(eCriterion);
|
| | |
|
| | | m_pContext.ResetContext();
|
| | |
|
| | | _Plogger.Info("Set ModeTrace OK.");
|
| | | ResultTreeBuilder trBuilder = m_pContext.CreateTreeBuilder();
|
| | | if (!trBuilder.constructResultTree(tContext, TRAVELTHREADMODE.CONMODE_SYNCHRONOUS)) { return null; }
|
| | | _Plogger.Info("ConstructResultTree OK.");
|
| | | ResultTree result = trBuilder.ResultTree;
|
| | |
|
| | | _Plogger.Info("getResultTree OK.");
|
| | | return result;
|
| | | }
|
| | |
|
| | | //判斷是否為最終設備(逆向追到已經無child的設備時,檢查該設備是否為最終設備(查驗該設備的同層設備,是否仍有可繼續逆向追蹤的設備,若無,則該設備為最終設備 |
| | | private bool isEndEquip(Equipment SelfEquip)
|
| | | {
|
| | | String SqlStmt;
|
| | | OracleCommand Command = null;
|
| | | OracleDataReader reader = null;
|
| | | long N_Value = 0;
|
| | |
|
| | | SqlStmt = "SELECT DIR,OSTATUS,N1,N2 FROM BASEDB.CONNECTIVITY WHERE FSC = " + SelfEquip.getFSC() + " AND UFID = " + SelfEquip.getUFID();
|
| | |
|
| | | try
|
| | | {
|
| | | Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | reader = Command.ExecuteReader();
|
| | |
|
| | | if (reader.Read())
|
| | | {
|
| | | if (Convert.ToInt32(reader["OSTATUS"]) == 1) //如果設備本身為非切開的設備,那應該繼續往逆向追
|
| | | return false;
|
| | | else
|
| | | {
|
| | | if (Convert.ToInt32(reader["DIR"]) == 3) //順向無電 N1-->N2,所以逆向的上游N值抓N2
|
| | | N_Value = Convert.ToInt32(reader["N2"]);
|
| | | else
|
| | | N_Value = Convert.ToInt32(reader["N1"]);
|
| | | }
|
| | | }
|
| | | reader.Close();
|
| | |
|
| | | SqlStmt = "SELECT FSC,UFID,DIR,OSTATUS,N1,N2 FROM BASEDB.CONNECTIVITY WHERE N1 <> N2 AND ( N1 = " + N_Value + " OR N2 = " + N_Value + ")";
|
| | | Command.CommandText = SqlStmt;
|
| | |
|
| | | reader = Command.ExecuteReader();
|
| | |
|
| | | while (reader.Read())
|
| | | {
|
| | | if (Convert.ToInt32(reader["FSC"]) == SelfEquip.getFSC() && Convert.ToInt32(reader["UFID"]) == SelfEquip.getUFID())
|
| | | continue;
|
| | |
|
| | | if (Convert.ToInt32(reader["OSTATUS"]) == 0) //切開的設備不可能為逆向的上游
|
| | | continue;
|
| | |
|
| | | if (Convert.ToInt32(reader["N1"]) == N_Value)
|
| | | {
|
| | | switch (Convert.ToInt32(reader["DIR"]))
|
| | | {
|
| | | case 1:
|
| | | case 3:
|
| | | break;
|
| | | case 2:
|
| | | case 4:
|
| | | return false; //如果逆向的上游連接點為N1,一定要N2-->N1才可能還有需要逆向追蹤設備
|
| | | case 99:
|
| | | break; //未供電設備不可能是逆向上游
|
| | | }
|
| | | }
|
| | | else if (Convert.ToInt32(reader["N2"]) == N_Value)
|
| | | {
|
| | | switch (Convert.ToInt32(reader["DIR"]))
|
| | | {
|
| | | case 1:
|
| | | case 3:
|
| | | return false; //如果逆向的上游連接點為N2,一定要N1-->N2才可能還有需要逆向追蹤設備
|
| | | case 2:
|
| | | case 4:
|
| | | break;
|
| | | case 99:
|
| | | return false; //未供電設備不可能是逆向上游
|
| | | }
|
| | | }
|
| | | }
|
| | | reader.Close();
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _Plogger.Error(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | return false;
|
| | | }
|
| | | finally
|
| | | {
|
| | | if (Command != null)
|
| | | Command.Dispose();
|
| | |
|
| | | if (reader != null)
|
| | | reader.Close();
|
| | | }
|
| | |
|
| | |
|
| | | return true;
|
| | | }
|
| | |
|
| | | private int getTraceCount(int Fsc, int Ufid)
|
| | | {
|
| | | if (TraceCounts.ContainsKey(Fsc + "|" + Ufid))
|
| | | return Int32.Parse(TraceCounts[Fsc + "|" + Ufid].ToString());
|
| | | else
|
| | | return 0;
|
| | | }
|
| | |
|
| | | private void AddTraceCount(int Fsc, int Ufid)
|
| | | {
|
| | | int Count = 1;
|
| | |
|
| | | if (TraceCounts.ContainsKey(Fsc + "|" + Ufid))
|
| | | {
|
| | | Count = Int32.Parse(TraceCounts[Fsc + "|" + Ufid].ToString());
|
| | | Count++;
|
| | | TraceCounts.Remove(Fsc + "|" + Ufid);
|
| | | }
|
| | |
|
| | | TraceCounts.Add(Fsc + "|" + Ufid, Count.ToString());
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public class TraceLoopException : Exception
|
| | | {
|
| | | public String Message = "";
|
| | |
|
| | | public TraceLoopException(String _Message)
|
| | | {
|
| | | Message = _Message;
|
| | | }
|
| | | }
|
| | | }
|
New file |
| | |
| | | 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
|
| | | {
|
| | | public class FinishEvent
|
| | | {
|
| | | private bool upLevel;
|
| | | private int OriginCaseStatus = 0;
|
| | | private CCS.Object.EventRecord m_EventRec = null;
|
| | | private RecordLog _PLog;
|
| | | private OracleConnection _ConnectionTPC;
|
| | | private OracleTransaction _Transaction;
|
| | |
|
| | | public FinishEvent()
|
| | | {
|
| | | }
|
| | |
|
| | | public bool Finish(int m_Kind, CCS.Object.EventRecord m_Record, OracleConnection _Conn, OracleTransaction _Trx, RecordLog _Log)
|
| | | {
|
| | | this.m_EventRec = m_Record;
|
| | | _PLog = _Log;
|
| | | _ConnectionTPC = _Conn;
|
| | | _Transaction = _Trx;
|
| | |
|
| | | _PLog.Info("進行OMS資料更新程序...");
|
| | | if (m_Record.getParentID() == 0)
|
| | | { // Original Case
|
| | | if (!(this.ProcessSingalCase(m_Record)))
|
| | | {
|
| | | return false;
|
| | | }
|
| | | _PLog.Info("更新eos.events成功!");
|
| | | }
|
| | | else
|
| | | { // Child Case
|
| | | if (!(this.ProcessMergeCase(m_Record)))
|
| | | {
|
| | | return false;
|
| | | }
|
| | | _PLog.Info("更新eos.events成功!");
|
| | | }
|
| | |
|
| | | // inert into eos.eventrecord && eos.eventrecord_ex
|
| | | OracleCommand Command = new OracleCommand(m_Record.getSqlStmt(), _ConnectionTPC,_Transaction);
|
| | | OracleCommand Command1 = null;
|
| | |
|
| | | try
|
| | | {
|
| | | if (Command.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | _PLog.Error("儲存資料時發生錯誤: 無法更新eos.eventrecord");
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | Command.CommandText = m_Record.getLocateEquipment().getSqlStmt();
|
| | | if (Command.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | _PLog.Error("儲存資料時發生錯誤: 無法更新eos.eventrecord_ex");
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | | Command.Dispose();
|
| | |
|
| | | if ((m_Kind == CCS.LocalVariable.Success) || (m_Kind == CCS.LocalVariable.CaseTypeChanged))
|
| | | {
|
| | | /* 當饋線全停時不需注意影響虛擬用戶,影響用戶資料會由實際切開關產生 */
|
| | | if (m_Record.getFsc() != CCS.LocalVariable.Breaker)
|
| | | {
|
| | | if (!SetVisualCustomer(m_Record))
|
| | | {
|
| | | _PLog.Error("新增影響用戶資料錯誤.");
|
| | | return false;
|
| | | }
|
| | | _PLog.Info("新增影響用戶成功!");
|
| | | }
|
| | |
|
| | | upLevel = false; /* 判斷交辦案件是否升級為母案件 */
|
| | |
|
| | | if (!(UpdateImportCase(m_Record)))
|
| | | {
|
| | | _PLog.Error("處理案件等級變更時發生錯誤.");
|
| | | return false;
|
| | | }
|
| | | _PLog.Info("處理案件等級變更成功!");
|
| | |
|
| | | if (!(UpdateRecuseOrder(m_Record)))
|
| | | {
|
| | | _PLog.Error("新增搶修順序資料時發生錯誤.");
|
| | | return false;
|
| | | }
|
| | | _PLog.Info("新增搶修順序成功!");
|
| | |
|
| | | if (m_Kind == CCS.LocalVariable.CaseTypeChanged)
|
| | | {
|
| | | if (!DeleteOldCase(m_Record))
|
| | | {
|
| | | _PLog.Error("案件轉換發生錯誤");
|
| | | return false;
|
| | | }
|
| | | _PLog.Info("案件轉換成功!");
|
| | | }
|
| | |
|
| | | if (!this.SaveCustomerTel(m_Record))
|
| | | {
|
| | | _PLog.Error("無法將用戶電話回存回資料庫.");
|
| | | return false;
|
| | | }
|
| | | _PLog.Info("將用戶電話回存回資料庫成功!");
|
| | |
|
| | | }
|
| | | else if (m_Kind == CCS.LocalVariable.NoMeter)
|
| | | {
|
| | | String SqlStmt;
|
| | | SqlStmt = "INSERT INTO EOS.RESCUE_ORDER SELECT " + m_Record.getCaseID() + ",999,COUNT(*) + 1,'',"
|
| | | + m_Record.getLocateEquipment().getDSUFID() + " FROM EOS.RESCUE_ORDER WHERE DSUFID = "
|
| | | + m_Record.getLocateEquipment().getDSUFID();
|
| | |
|
| | | Command1 = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | if (Command1.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | _PLog.Error("新增搶修順序資料時發生錯誤.");
|
| | | Command1.Dispose();
|
| | | return false;
|
| | | }
|
| | | Command1.Dispose();
|
| | | _PLog.Info("新增搶修順序成功!");
|
| | | }
|
| | |
|
| | | if (m_Record.getParentID() == 0)
|
| | | {
|
| | | if (!InsertIntoSri(m_Record))
|
| | | {
|
| | | _PLog.Error("新增資料庫(OCSDB.SRI)錯誤.");
|
| | | return false;
|
| | | }
|
| | | _PLog.Info("新增資料庫(OCSDB.SRI)成功!");
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Command.Dispose();
|
| | |
|
| | | if (Command1 != null)
|
| | | Command1.Dispose();
|
| | |
|
| | | throw e;
|
| | | }
|
| | |
|
| | | /** COMMIT的動作須連外面CCS的資料都正確輸入完才作 */
|
| | | return true;
|
| | | |
| | |
|
| | | }
|
| | |
|
| | | private bool ProcessSingalCase(CCS.Object.EventRecord m_Record)
|
| | | {
|
| | | String SqlStmt;
|
| | | bool Result = false;
|
| | | SqlStmt = "INSERT INTO EOS.EVENTS VALUES(" + m_Record.getCaseID() + "," + CCS.LocalVariable.WaitForDespatch + ",1,"
|
| | | + CCS.LocalVariable.OriginalCase + ",0)";
|
| | |
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | |
|
| | | try
|
| | | {
|
| | | if (Command.ExecuteNonQuery() > 0)
|
| | | Result = true;
|
| | | else
|
| | | _PLog.Error("儲存資料時發生錯誤: 無法insert eos.events");
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error("儲存資料時發生錯誤: 無法insert eos.events. Error = " + e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | {
|
| | | Command.Dispose();
|
| | | }
|
| | | return Result;
|
| | | }
|
| | |
|
| | | private bool ProcessMergeCase(CCS.Object.EventRecord m_Record)
|
| | | {
|
| | | String SqlStmt;
|
| | | // insert eos.events
|
| | | SqlStmt = "INSERT INTO EOS.EVENTS VALUES(" + m_Record.getCaseID() + "," + CCS.LocalVariable.WaitForDespatch + ",1,"
|
| | | + CCS.LocalVariable.ChildCase + ",0)";
|
| | |
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | |
|
| | | try
|
| | | {
|
| | | if (Command.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | _PLog.Error("儲存資料時發生錯誤: 無法insert eos.events");
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | // insert into eos.mergecase
|
| | | SqlStmt = "INSERT INTO EOS.MERGECASE VALUES(" + m_Record.getCaseID() + ",'" + m_Record.getAcceptNum() + "'," + m_Record.getParentID() + ")";
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | if (Command.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | _PLog.Error("儲存資料時發生錯誤: 無法insert eos.mergecase");
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | // update parent case data(EOS.EVENTS)
|
| | | SqlStmt = "UPDATE EOS.EVENTS SET CASETYPE = " + CCS.LocalVariable.ParentCase + ",MERGECASECOUNT = MERGECASECOUNT + 1 " + "WHERE CASEID = "
|
| | | + m_Record.getParentID();
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | if (Command.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | _PLog.Error("儲存資料時發生錯誤: 無法更改母案件資料");
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | // update parent case data(EOS.EVENTRECORD)
|
| | | SqlStmt = "UPDATE EOS.EVENTRECORD SET FSC = " + m_Record.getFsc() + ",UFID = " + m_Record.getUfid()
|
| | | + " WHERE CASEID in (SELECT CASEID FROM EOS.MERGECASE WHERE PARENTID = " + m_Record.getParentID() + ") OR CASEID = "
|
| | | + m_Record.getParentID();
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | if (Command.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | _PLog.Error("儲存資料時發生錯誤: 無法update eos.eventrecord(FSC,UFID)");
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | | Command.Dispose();
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error("儲存資料時發生錯誤: " + e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | return true;
|
| | | }
|
| | |
|
| | | private bool SetVisualCustomer(CCS.Object.EventRecord m_Record)
|
| | | {
|
| | | String SqlStmt = "";
|
| | | String CustomerKind = "C"; // 高壓用戶or一般用戶
|
| | |
|
| | | SqlStmt = "SELECT COUNT(*) as COUNT FROM BASEDB.HICUSTOMER WHERE METR_NUMB = '" + m_Record.getMeter() + "'";
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | |
|
| | | try
|
| | | {
|
| | |
|
| | | if (reader.Read())
|
| | | {
|
| | | if (Convert.ToInt32(reader["COUNT"].ToString()) > 0)
|
| | | {
|
| | | CustomerKind = "H";
|
| | | }
|
| | | }
|
| | | }
|
| | | catch (Exception)
|
| | | {
|
| | | _PLog.Error("無法判斷用戶種類.");
|
| | | return false;
|
| | | }
|
| | | finally
|
| | | { |
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | |
|
| | | if (m_Record.getParentID() == 0)
|
| | | {
|
| | | SqlStmt = "INSERT INTO EOS.TMPAFFECTCUSTMS SELECT " + m_Record.getCaseID() + ",A.M_NAME,"
|
| | | + "M.TELE_NUMB,M.METR_NUMB,A.M_ADDR,M.TRAN_CORD,M.CUST_TYPE,'" + CustomerKind + "' "
|
| | | + "FROM BASEDB.METER M,BASEDB.MSTADDR A WHERE M.METR_NUMB = A.M_CUST_NO(+) AND M.METR_NUMB = '" + m_Record.getMeter() + "'";
|
| | |
|
| | | OracleCommand Command1 = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | if (Command1.ExecuteNonQuery() >= 0)
|
| | | {
|
| | | Command1.Dispose();
|
| | | return true;
|
| | | }
|
| | | Command1.Dispose();
|
| | | return false;
|
| | | }
|
| | | else
|
| | | {
|
| | | return InsertMutilCustomer(CustomerKind, m_Record);
|
| | | }
|
| | | }
|
| | |
|
| | | private bool InsertMutilCustomer(String CustomerKind, CCS.Object.EventRecord m_Record)
|
| | | {
|
| | | String SqlStmt = "";
|
| | | bool updateCustomer = false;
|
| | | String m_TpclidGroupID = "";
|
| | | String m_CustomerKind = "C";
|
| | |
|
| | | SqlStmt = "SELECT COUNT(*) as COUNT FROM EOS.TMPAFFECTCUSTMS WHERE CASEID = " + m_Record.getParentID()
|
| | | + " OR CASEID IN (SELECT CASEID FROM EOS.MERGECASE WHERE PARENTID = " + m_Record.getParentID() + ")";
|
| | |
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | |
|
| | | try
|
| | | {
|
| | | if (reader.Read())
|
| | | {
|
| | | if (Convert.ToInt32(reader["COUNT"].ToString()) == 1)
|
| | | {
|
| | | updateCustomer = true; // 需重新修改影響用戶資料(原始母案件的影響用戶數)
|
| | | }
|
| | | }
|
| | | }
|
| | | catch (Exception)
|
| | | {
|
| | | _PLog.Error("無法確認是否需重新修改原始母案件之影響用戶資料.");
|
| | | return false;
|
| | | }
|
| | | finally
|
| | | { |
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | |
|
| | | OracleCommand Command1 = null;
|
| | |
|
| | | if (updateCustomer)
|
| | | {
|
| | | /* 找出原始案件的影響用戶資料 */
|
| | | SqlStmt = "SELECT TPCLIDGROUPID,CUSTOMERKIND FROM EOS.TMPAFFECTCUSTMS WHERE CASEID = " + m_Record.getParentID();
|
| | |
|
| | | try
|
| | | {
|
| | | Command1 = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | reader = Command1.ExecuteReader();
|
| | | |
| | | if (reader.Read())
|
| | | {
|
| | | m_TpclidGroupID = reader["TPCLIDGROUPID"].ToString().Trim();
|
| | | m_CustomerKind = reader["CUSTOMERKIND"].ToString();
|
| | | }
|
| | | reader.Close();
|
| | |
|
| | | /* 若為高壓用戶,用戶數本來就為1人..無須再作修正 */
|
| | | if (m_CustomerKind.Equals("C"))
|
| | | {
|
| | | /* 刪除原始案件的既有用戶資料 */
|
| | | SqlStmt = "DELETE EOS.TMPAFFECTCUSTMS WHERE CASEID = " + m_Record.getParentID();
|
| | |
|
| | | Command1.CommandText = SqlStmt;
|
| | | if (Command1.ExecuteNonQuery() < 0)
|
| | | {
|
| | | _PLog.Error("無法刪除原始案件的既有用戶資料.");
|
| | | Command1.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | /* 將原始案件的影響用戶數改為變壓器的全部用戶 */
|
| | | SqlStmt = "INSERT INTO EOS.TMPAFFECTCUSTMS SELECT " + m_Record.getParentID() + ",A.M_NAME,"
|
| | | + "M.TELE_NUMB,M.METR_NUMB,A.M_ADDR,M.TPCLIDGROUPID,M.CUST_TYPE,'" + m_CustomerKind + "' "
|
| | | + "FROM (SELECT TELE_NUMB,METR_NUMB,TRAN_CORD as TPCLIDGROUPID,CUST_TYPE FROM BASEDB.METER " + "WHERE TRAN_CORD = '"
|
| | | + m_TpclidGroupID + "') M,BASEDB.MSTADDR A WHERE M.METR_NUMB = A.M_CUST_NO(+) ";
|
| | |
|
| | | Command1.CommandText = SqlStmt;
|
| | | if (Command1.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | _PLog.Error("無法將原始案件的影響用戶數改為變壓器的全部用戶.");
|
| | | Command1.Dispose();
|
| | | return false;
|
| | | }
|
| | | }
|
| | | Command1.Dispose();
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error("無法更新原始案件影響用戶資料: " + e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | Command1.Dispose();
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | /* 新受理案件的影響用戶資料 */
|
| | | SqlStmt = "INSERT INTO EOS.TMPAFFECTCUSTMS SELECT " + m_Record.getCaseID() + ",A.M_NAME,"
|
| | | + "M.TELE_NUMB,M.METR_NUMB,A.M_ADDR,M.TPCLIDGROUPID,M.CUST_TYPE,'" + CustomerKind + "' "
|
| | | + "FROM (SELECT TELE_NUMB,METR_NUMB,TRAN_CORD as TPCLIDGROUPID,CUST_TYPE FROM BASEDB.METER "
|
| | | + "WHERE TRAN_CORD = (SELECT TRAN_CORD FROM BASEDB.METER WHERE METR_NUMB = '" + m_Record.getMeter()
|
| | | + "')) M,BASEDB.MSTADDR A WHERE M.METR_NUMB = A.M_CUST_NO(+) ";
|
| | |
|
| | | OracleCommand Command2 = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | if (Command2.ExecuteNonQuery() < 0)
|
| | | {
|
| | | _PLog.Error("無法新增新受理案件的影響用戶資料.");
|
| | | Command2.Dispose();
|
| | | return false;
|
| | | }
|
| | | Command2.Dispose();
|
| | | return true;
|
| | | }
|
| | |
|
| | | private bool UpdateImportCase(CCS.Object.EventRecord m_Record)
|
| | | {
|
| | | String SqlStmt;
|
| | |
|
| | | /* 該案件不為交辦案件 */
|
| | | if (m_Record.getImportCase() != CCS.LocalVariable.isImportCase)
|
| | | {
|
| | | return true;
|
| | | }
|
| | |
|
| | | /* 該交辦案件為原始案件 */
|
| | | if (m_Record.getParentID() == 0)
|
| | | {
|
| | | return true;
|
| | | }
|
| | |
|
| | | /* 若母案件已為交辦案件,則不需再作任何更動 */
|
| | | SqlStmt = "SELECT IMPORTCASE FROM EOS.EVENTRECORD WHERE CASEID = " + m_Record.getParentID();
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | |
|
| | | try
|
| | | {
|
| | | if (reader.Read())
|
| | | {
|
| | | if (Convert.ToInt32(reader["IMPORTCASE"].ToString()) == CCS.LocalVariable.isImportCase)
|
| | | return true;
|
| | | }
|
| | | }
|
| | | catch (Exception)
|
| | | {
|
| | | _PLog.Error("無法取得母案件之等級.");
|
| | | return false;
|
| | | }
|
| | | finally
|
| | | { |
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | |
|
| | | /* 開始進行交辦案件升級動作 */
|
| | | upLevel = true;
|
| | |
|
| | | /* 將交辦案件改為母案件 */
|
| | | SqlStmt = "UPDATE EOS.EVENTS SET CASETYPE = " + CCS.LocalVariable.ParentCase + ",MERGECASECOUNT = "
|
| | | + "(SELECT MERGECASECOUNT FROM EOS.EVENTS WHERE CASEID = " + m_Record.getParentID() + ") WHERE CASEID = " + m_Record.getCaseID();
|
| | |
|
| | | OracleCommand Command1 = new OracleCommand(SqlStmt, _ConnectionTPC,_Transaction);
|
| | | if (Command1.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | _PLog.Error("無法將交辦案件改為母案件.");
|
| | | Command1.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | /* 將母案件改為子案件 */
|
| | | SqlStmt = "UPDATE EOS.EVENTS SET CASETYPE = " + CCS.LocalVariable.ChildCase + ",MERGECASECOUNT = 0 WHERE CASEID = " + m_Record.getParentID();
|
| | |
|
| | | Command1.CommandText = SqlStmt;
|
| | | if (Command1.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | _PLog.Error("無法將母案件改為子案件.");
|
| | | Command1.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | // 將EOS.MERGECASE內的資料修正 1.將原先該母案件下的子案件都改掛在交辦案件下 2.將已INSERT入EOS.MERGECASE內的交辦案件資料改為原先母案件的資料(CaseID,AcceptNum)
|
| | | SqlStmt = "UPDATE EOS.MERGECASE SET PARENTID = " + m_Record.getCaseID() + " WHERE PARENTID = " + m_Record.getParentID();
|
| | |
|
| | | Command1.CommandText = SqlStmt;
|
| | | if (Command1.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | _PLog.Error("無法將原先該母案件下的子案件都改掛在交辦案件下.");
|
| | | Command1.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | SqlStmt = "UPDATE EOS.MERGECASE SET (CASEID,ACCEPTNUM) = (SELECT CASEID,ACCEPTNUM FROM EOS.EVENTRECORD WHERE CASEID = "
|
| | | + m_Record.getParentID() + ") WHERE CASEID = " + m_Record.getCaseID();
|
| | |
|
| | | Command1.CommandText = SqlStmt;
|
| | | if (Command1.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | _PLog.Error("無法將已INSERT入EOS.MERGECASE內的交辦案件資料改為原先母案件的資料(CaseID,AcceptNum).");
|
| | | Command1.Dispose();
|
| | | return false;
|
| | | }
|
| | | Command1.Dispose();
|
| | |
|
| | | return UpdateOtherTable(m_Record.getParentID(), m_Record.getCaseID(), m_Record.getAcceptNum());
|
| | | }
|
| | |
|
| | | private bool UpdateOtherTable(int OldCaseID, int NewCaseID, String NewAcceptNum)
|
| | | {
|
| | | String SqlStmt;
|
| | |
|
| | | SqlStmt = "SELECT CASESTATUS FROM EOS.EVENTS WHERE CASEID = " + OldCaseID;
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC,_Transaction);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | |
|
| | | try
|
| | | {
|
| | |
|
| | | if (reader.Read())
|
| | | {
|
| | | OriginCaseStatus = Convert.ToInt32(reader["CASESTATUS"].ToString());
|
| | | }
|
| | | reader.Close();
|
| | |
|
| | | switch (OriginCaseStatus)
|
| | | {
|
| | | case 0:
|
| | | _PLog.Error("找不到原始母案件之案件狀態.");
|
| | | Command.Dispose();
|
| | | return false;
|
| | | case CCS.LocalVariable.WaitForDespatch:
|
| | | break;
|
| | | case CCS.LocalVariable.WaitForSponsor:
|
| | | SqlStmt = "UPDATE EOS.EVENTDESPATCH SET CASEID = " + NewCaseID + " WHERE CASEID = " + OldCaseID;
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | if (Command.ExecuteNonQuery() < 0)
|
| | | {
|
| | | _PLog.Error("無法更新EOS.EVENTDESPATCH.");
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | SqlStmt = "update eos.events set casestatus=" + CCS.LocalVariable.WaitForSponsor + " where caseid=" + NewCaseID;
|
| | | Command.CommandText = SqlStmt;
|
| | | if (Command.ExecuteNonQuery() < 0)
|
| | | {
|
| | | _PLog.Error("無法更新EOS.EVENTS.");
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | this.m_EventRec.setDespatched(true);
|
| | | break;
|
| | | }
|
| | |
|
| | | SqlStmt = "UPDATE EOS.EVENTS SET CASESTATUS = " + CCS.LocalVariable.WaitForDespatch + " WHERE CASEID = " + OldCaseID;
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | if (Command.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | _PLog.Error("無法更新EOS.Events的CaseStatus.");
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | SqlStmt = "UPDATE OCSDB.SRI SET SCENENAME = '" + NewAcceptNum + "' WHERE SCENENAME = (SELECT ACCEPTNUM FROM "
|
| | | + "EOS.EVENTRECORD WHERE CASEID = " + OldCaseID + ")";
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | if (Command.ExecuteNonQuery() < 0)
|
| | | {
|
| | | _PLog.Error("無法更新OCSDB.SRI.");
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | SqlStmt = "SELECT COUNT(*) as COUNT FROM EOS.CRTAPOLOGY WHERE CASEID = " + OldCaseID;
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | reader = Command.ExecuteReader();
|
| | | int Count = 0;
|
| | |
|
| | | if (reader.Read())
|
| | | {
|
| | | Count = Convert.ToInt32(reader["COUNT"].ToString());
|
| | | }
|
| | | reader.Close();
|
| | |
|
| | | // 已有切過開關
|
| | | if (Count > 0)
|
| | | {
|
| | | SqlStmt = "UPDATE EOS.EVENTFACILITY SET CASEID = " + NewCaseID + " WHERE CASEID = " + OldCaseID;
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | if (Command.ExecuteNonQuery() < 0)
|
| | | {
|
| | | _PLog.Error("無法更新EOS.EVENTFACILITY.");
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | SqlStmt = "UPDATE EOS.CRTAPOLOGY SET CASEID = " + NewCaseID + " WHERE CASEID = " + OldCaseID;
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | if (Command.ExecuteNonQuery() < 0)
|
| | | {
|
| | | _PLog.Error("無法更新EOS.CRTAPOLOGY.");
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | SqlStmt = "UPDATE EOS.EVENTAFFECT SET CASEID = " + NewCaseID + " WHERE CASEID = " + OldCaseID;
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | if (Command.ExecuteNonQuery() < 0)
|
| | | {
|
| | | _PLog.Error("無法更新EOS.EVENTAFFECT.");
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | // SqlStmt = "UPDATE EOS.VOICE SET CASEID = " + NewCaseID + " WHERE CASEID = " + OldCaseID;
|
| | |
|
| | | // if (CCS.LocalVariable.Conn.UpdateDB(SqlStmt) < 0) {
|
| | | // _PLog.error("無法更新EOS.VOICE.");
|
| | | // return false;
|
| | | // }
|
| | |
|
| | | SqlStmt = "UPDATE OCSDB.LOCKFEATURE SET DESCRIPTION = '" + NewAcceptNum + "' WHERE DESCRIPTION = (SELECT ACCEPTNUM FROM "
|
| | | + "EOS.EVENTRECORD WHERE CASEID = " + OldCaseID + ")";
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | if (Command.ExecuteNonQuery() < 0)
|
| | | {
|
| | | _PLog.Error("無法更新OCSDB.LOCKFEATURE");
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | | }
|
| | | Command.Dispose();
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | private bool UpdateRecuseOrder(CCS.Object.EventRecord m_Record)
|
| | | {
|
| | | String SqlStmt;
|
| | | int Rank = 999;
|
| | | int Priority = 1;
|
| | | OracleCommand Command = null;
|
| | |
|
| | | /* 單純的子案件或不需升級的交辦案件,不需要更新EOS.RESCUE_ORDER */
|
| | | if ((m_Record.getParentID() != 0) && !(upLevel))
|
| | | {
|
| | | return true;
|
| | | }
|
| | |
|
| | | /* 該母案件已派工,無搶修順序紀錄 */
|
| | | if (OriginCaseStatus > CCS.LocalVariable.WaitForDespatch)
|
| | | {
|
| | | return true;
|
| | | }
|
| | |
|
| | | try
|
| | | {
|
| | | if (upLevel)
|
| | | {
|
| | | /* 將原先母案件的編號改為新的母案件編號 */
|
| | | SqlStmt = "UPDATE EOS.RESCUE_ORDER SET CASEID = " + m_Record.getCaseID() + " WHERE CASEID = " + m_Record.getParentID()
|
| | | + " AND DSUFID = " + m_Record.getLocateEquipment().getDSUFID();
|
| | |
|
| | | Command = new OracleCommand(SqlStmt, _ConnectionTPC,_Transaction);
|
| | | if (Command.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | _PLog.Error("無法更新EOS.RESCUE_ORDER: 無法將原先母案件的編號改為新的母案件編號.");
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | /* 找出該饋線的等級 */
|
| | | SqlStmt = "SELECT RANK FROM EOS.IMP_FEEDER WHERE FEEDERID = " + m_Record.getFdrID();
|
| | |
|
| | | Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | | |
| | | if (reader.Read())
|
| | | {
|
| | | Rank = Convert.ToInt32(reader["RANK"].ToString());
|
| | | }
|
| | | reader.Close();
|
| | |
|
| | | /* 找出同等級饋線中的最大搶修順序號碼 */
|
| | | SqlStmt = "SELECT MAX(PRIORITY) as PRIORITY FROM EOS.RESCUE_ORDER WHERE RANK = " + Rank + " AND DSUFID = "
|
| | | + m_Record.getLocateEquipment().getDSUFID();
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | reader = Command.ExecuteReader();
|
| | | if (reader.Read())
|
| | | {
|
| | | if ( reader["PRIORITY"].ToString().Length != 0 )
|
| | | Priority = Convert.ToInt32(reader["PRIORITY"].ToString());
|
| | | }
|
| | | reader.Close();
|
| | |
|
| | | /* 如果沒找到,找前一RANK的最大的Priority */
|
| | | if (Priority == 0 && Rank > 0)
|
| | | {
|
| | | SqlStmt = "SELECT MAX(PRIORITY) as PRIORITY FROM EOS.RESCUE_ORDER WHERE RANK = "
|
| | | + "(SELECT MAX(RANK) FROM EOS.RESCUE_ORDER WHERE RANK < " + Rank + " AND DSUFID = "
|
| | | + m_Record.getLocateEquipment().getDSUFID() + ")";
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | reader = Command.ExecuteReader();
|
| | |
|
| | | if (reader.Read())
|
| | | {
|
| | | if ( reader["PRIORITY"].ToString().Length != 0 )
|
| | | Priority = Convert.ToInt32(reader["PRIORITY"].ToString());
|
| | | }
|
| | | reader.Close();
|
| | | }
|
| | |
|
| | | /* 如果還是沒找到,就設Priority = 0 (只有當新增案件的Rank為最小時或第一筆案件才可能發生) */
|
| | | if (Priority == 0)
|
| | | { // 若不寫清楚會看不懂
|
| | | Priority = 0;
|
| | |
|
| | | /* 將搶修順序號碼大於等於找出來號碼的都加1 */
|
| | | }
|
| | | SqlStmt = "UPDATE EOS.RESCUE_ORDER SET PRIORITY = PRIORITY + 1 WHERE PRIORITY > " + Priority + " AND DSUFID = "
|
| | | + m_Record.getLocateEquipment().getDSUFID();
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | if (Command.ExecuteNonQuery() < 0)
|
| | | {
|
| | | _PLog.Error("無法更新EOS.RESCUE_ORDER舊的搶修號碼.");
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | /* 將本身資料存入資料庫內 */
|
| | | SqlStmt = "INSERT INTO EOS.RESCUE_ORDER (CASEID,RANK,PRIORITY,DSUFID) VALUES (" + m_Record.getCaseID() + "," + Rank + ","
|
| | | + (Priority + 1) + "," + m_Record.getLocateEquipment().getDSUFID() + ")";
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | if (Command.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | _PLog.Error("無法新增EOS.RESCUE_ORDER的資料");
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | Command.Dispose();
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error("Problems occue during updating eos.rescue_order: " + e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | |
|
| | | if ( Command != null)
|
| | | Command.Dispose();
|
| | |
|
| | | return false;
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | // 當原先同一用戶在事故受理後又報案,不過從一般案件轉為交辦案件所需作的轉換工作
|
| | | private bool DeleteOldCase(CCS.Object.EventRecord m_Record)
|
| | | {
|
| | | String SqlStmt;
|
| | | int CaseID = 0; // 原先的事故號碼
|
| | | int CaseType = CCS.LocalVariable.ChildCase; // 原先的種類
|
| | | int Count = 0; // 原先的來電次數
|
| | | int CaseStatus = 0; // 原先的案件狀態
|
| | | OracleCommand Command = null;
|
| | |
|
| | | SqlStmt = "SELECT R.CASEID as CASEID,E.CASETYPE as CASETYPE,E.CASESTATUS as CASESTATUS,E.COUNT as COUNT FROM "
|
| | | + "EOS.EVENTRECORD R,EOS.EVENTS E WHERE R.CASEID = E.CASEID AND R.CUSTOMERMETER = '" + m_Record.getMeter() + "' AND R.CASEID <> "
|
| | | + m_Record.getCaseID() + " AND E.CASESTATUS <= " + CCS.LocalVariable.WaitForSponsor;
|
| | |
|
| | | try
|
| | | {
|
| | | Command = new OracleCommand(SqlStmt, _ConnectionTPC,_Transaction);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | |
|
| | | if (reader.Read())
|
| | | {
|
| | | CaseID = Convert.ToInt32(reader["CASEID"].ToString());
|
| | | CaseType = Convert.ToInt32(reader["CASETYPE"].ToString());
|
| | | CaseStatus = Convert.ToInt32(reader["CASESTATUS"].ToString());
|
| | | Count = Convert.ToInt32(reader["COUNT"].ToString());
|
| | | reader.Close();
|
| | | }
|
| | | else
|
| | | {
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | _PLog.Error("無法找到原先舊的案件.");
|
| | | return false;
|
| | | }
|
| | |
|
| | | SqlStmt = "DELETE EOS.EVENTS WHERE CASEID = " + CaseID;
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | if (Command.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | _PLog.Error("刪除原先舊的案件的EOS.EVENTS發生錯誤.");
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | SqlStmt = "DELETE EOS.EVENTRECORD WHERE CASEID = " + CaseID;
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | if (Command.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | _PLog.Error("刪除原先舊的案件的EOS.EVENTRECORD發生錯誤.");
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | SqlStmt = "DELETE EOS.EVENTRECORD_EX WHERE CASEID = " + CaseID;
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | if (Command.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | _PLog.Error("刪除原先舊的案件的EOS.EVENTRECORD_EX發生錯誤.");
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | SqlStmt = "DELETE EOS.TMPAFFECTCUSTMS WHERE CASEID = " + CaseID;
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | if (Command.ExecuteNonQuery() < 0)
|
| | | {
|
| | | _PLog.Error("刪除原先舊的案件的EOS.TMPAFFECTCUSTMS發生錯誤.");
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | if (m_Record.getParentID() == CaseID)
|
| | | { // 原本舊案件為母案件
|
| | | SqlStmt = "SELECT COUNT(*) as COUNT FROM EOS.MERGECASE WHERE PARENTID = " + m_Record.getCaseID();
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | reader = Command.ExecuteReader();
|
| | |
|
| | | if (reader.Read())
|
| | | {
|
| | | switch (Convert.ToInt32(reader["COUNT"].ToString()))
|
| | | {
|
| | | case 0:
|
| | | _PLog.Error("無法找到原先母案件下掛的子案件.");
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | return false;
|
| | | case 1: // 子案件為之前受理的同一事故案件
|
| | | SqlStmt = "UPDATE EOS.EVENTS SET CASETYPE = " + CCS.LocalVariable.OriginalCase + ",COUNT = " + (Count + 1)
|
| | | + ",MERGECASECOUNT = 0 WHERE CASEID = " + m_Record.getCaseID();
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | if (Command.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | _PLog.Error("無法更新原先子案件(要提升為母案件)的資料.");
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | SqlStmt = "DELETE EOS.TMPAFFECTCUSTMS WHERE CUSTOMERMETER <> '" + m_Record.getMeter() + "' AND CASEID = "
|
| | | + m_Record.getCaseID();
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | if (Command.ExecuteNonQuery() < 0)
|
| | | {
|
| | | _PLog.Error("無法刪除原先子案件(要提升為母案件)EOS.TMPAFFECTYCUSTMS的資料.");
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | | break;
|
| | | default:
|
| | | SqlStmt = "UPDATE EOS.EVENTS SET MERGECASECOUNT = MERGECASECOUNT - 1,COUNT = " + (Count + 1) + " WHERE CASEID = "
|
| | | + m_Record.getCaseID();
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | if (Command.ExecuteNonQuery() < 0)
|
| | | {
|
| | | _PLog.Error("無法更新EOS.EVENTS的資料.");
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | | break;
|
| | | }
|
| | | reader.Close();
|
| | | }
|
| | | else
|
| | | {
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | _PLog.Error("無法找到原先母案件下掛的子案件.");
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | SqlStmt = "DELETE EOS.MERGECASE WHERE CASEID = " + CaseID;
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | if (Command.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | _PLog.Error("刪除EOS.MERGECASE發生錯誤");
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | Command.Dispose();
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | |
|
| | | if (Command != null)
|
| | | Command.Dispose();
|
| | |
|
| | | return false;
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | private bool InsertIntoSri(CCS.Object.EventRecord m_Record)
|
| | | {
|
| | | String SqlStmt;
|
| | | int Count = 0;
|
| | | OracleCommand Command = null;
|
| | | OracleDataReader reader = null;
|
| | |
|
| | | SqlStmt = "SELECT COUNT(*) as COUNT FROM OCSDB.SRI WHERE SCENENAME = '" + m_Record.getAcceptNum() + "'";
|
| | |
|
| | | try
|
| | | {
|
| | | Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | reader = Command.ExecuteReader();
|
| | |
|
| | | if (reader.Read())
|
| | | Count = Convert.ToInt32(reader["COUNT"].ToString());
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error("Problems occur when checking SCENE Data: " + e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | return false;
|
| | | }
|
| | | finally
|
| | | { |
| | | if ( reader != null )
|
| | | reader.Close();
|
| | | }
|
| | |
|
| | | if (Count > 0)
|
| | | {
|
| | | Command.Dispose();
|
| | | return true;
|
| | | }
|
| | |
|
| | | SqlStmt = "INSERT INTO OCSDB.SRI VALUES('" + m_Record.getAcceptNum() + "',2,-1)";
|
| | |
|
| | | try
|
| | | {
|
| | | Command.CommandText = SqlStmt;
|
| | | |
| | | if (Command.ExecuteNonQuery() <= 0)
|
| | | return false;
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | {
|
| | | Command.Dispose();
|
| | | }
|
| | | |
| | | return true;
|
| | | }
|
| | |
|
| | | private bool SaveCustomerTel(CCS.Object.EventRecord m_Record)
|
| | | {
|
| | | String SqlStmt;
|
| | |
|
| | | // 無電號資料
|
| | | /*
|
| | | * if (m_Record.getisReCall() == CCS.LocalVariable.NotReCall) { return true; }
|
| | | */
|
| | |
|
| | | // 沒有回覆電話可供回存
|
| | | if (m_Record.getTel() == null || m_Record.getTel().Trim().Length == 0 )
|
| | | {
|
| | | return true;
|
| | | }
|
| | |
|
| | | // 電話資料過長
|
| | | if (m_Record.getTel().Trim().Length > 24)
|
| | | {
|
| | | _PLog.Warn("電話過長號碼,無法回存資料庫.");
|
| | | return true;
|
| | | }
|
| | |
|
| | | SqlStmt = "UPDATE BASEDB.METER SET TELE_NUMB = '" + m_Record.getTel().Trim() + "' WHERE METR_NUMB = '" + m_Record.getMeter() + "'";
|
| | |
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC,_Transaction);
|
| | |
|
| | | try
|
| | | {
|
| | | if (Command.ExecuteNonQuery() <= 0)
|
| | | _PLog.Warn("無法將用戶電話回存回資料庫.");
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | {
|
| | | Command.Dispose();
|
| | | }
|
| | |
|
| | | return true;
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
New file |
| | |
| | | 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.Runtime.CompilerServices;
|
| | | using System.Data.OracleClient;
|
| | | |
| | | namespace CCSTrace.CCS.Function
|
| | | {
|
| | | public class InitialEventData
|
| | | {
|
| | | private String m_AcceptNum = "";
|
| | | private int m_CaseID = 0;
|
| | | private int m_Year = 0;
|
| | | private bool m_ChangeYear = false;
|
| | | private String m_AcceptTime = "";
|
| | | private RecordLog _PLog;
|
| | | private OracleConnection _ConnectionTPC;
|
| | |
|
| | | //New CaseID and New AcceptNum must be seen by others,so it need not controled by transaction
|
| | | [MethodImpl(MethodImplOptions.Synchronized)]
|
| | | public InitialEventData(OracleConnection _Conn, RecordLog _Log) |
| | | {
|
| | | _ConnectionTPC = _Conn;
|
| | | _PLog = _Log;
|
| | |
|
| | | String SqlStmt = "SELECT ACCEPTNUM,CASEID,YEAR,TO_CHAR(SYSDATE,'YYYY/MM/DD') as ACCEPTTIME FROM EOS.EVENTNUM";
|
| | |
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | |
|
| | | try
|
| | | {
|
| | | if (reader.Read())
|
| | | {
|
| | | m_AcceptNum = reader["ACCEPTNUM"].ToString();
|
| | | m_CaseID = Convert.ToInt32(reader["CASEID"].ToString());
|
| | | m_Year = Convert.ToInt32(reader["YEAR"].ToString());
|
| | | m_AcceptTime = reader["ACCEPTTIME"].ToString();
|
| | | }
|
| | | else
|
| | | {
|
| | | _PLog.Error("起始號碼資料遺失!");
|
| | | return;
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error("Problems occur when Initializing EventData: " + e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | return;
|
| | | }
|
| | | finally
|
| | | {
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | |
|
| | | CheckAcceptNum();
|
| | |
|
| | | while (!UpdateDataBase(m_ChangeYear)) {
|
| | | this.RegetNumber();
|
| | | CheckAcceptNum();
|
| | | }
|
| | | }
|
| | |
|
| | | public int getNewCaseID() {
|
| | | return this.m_CaseID;
|
| | | }
|
| | |
|
| | | public String getNewAcceptNum() {
|
| | | return this.m_AcceptNum;
|
| | | }
|
| | |
|
| | | private bool UpdateDataBase(bool m_ChangeYear) {
|
| | | String SqlStmt;
|
| | | bool m_Result = false;
|
| | |
|
| | | if (m_ChangeYear)
|
| | | SqlStmt = "UPDATE EOS.EVENTNUM SET ACCEPTNUM = '" + (Convert.ToInt32(m_AcceptNum) + 1).ToString() + "',CASEID = "
|
| | | + (m_CaseID + 1) + ",YEAR = " + (m_Year + 1) + " WHERE CASEID = " + this.m_CaseID;
|
| | | else
|
| | | SqlStmt = "UPDATE EOS.EVENTNUM SET ACCEPTNUM = '" + (Convert.ToInt32(m_AcceptNum) + 1).ToString() + "',CASEID = "
|
| | | + (m_CaseID + 1) + " WHERE CASEID = " + this.m_CaseID;
|
| | |
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC);
|
| | | |
| | | try
|
| | | {
|
| | | if (Command.ExecuteNonQuery() > 0)
|
| | | m_Result = true;
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error("Problems occur during EventNumCreating: " + e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | throw e;
|
| | | }
|
| | | finally
|
| | | { |
| | | Command.Dispose();
|
| | | }
|
| | |
|
| | | return m_Result;
|
| | | }
|
| | |
|
| | | private void CheckAcceptNum() {
|
| | | int NowYear = Convert.ToInt32(m_AcceptTime.Substring(0, 4)) - 1911;
|
| | | int NowMonth = Convert.ToInt32(m_AcceptTime.Substring(5, 2));
|
| | | String Tmp = this.m_AcceptNum;
|
| | |
|
| | | if (Convert.ToInt32(Tmp.Substring(0, 3)) == NowYear)
|
| | | {
|
| | | if (Convert.ToInt32(Tmp.Substring(3, 2)) != NowMonth)
|
| | | {
|
| | | // 新月份
|
| | | if (NowMonth < 10)
|
| | | m_AcceptNum = NowYear.ToString() + "0" + NowMonth.ToString() + "0001";
|
| | | else
|
| | | m_AcceptNum = NowYear.ToString() + NowMonth.ToString() + "0001";
|
| | | }
|
| | | } else {
|
| | | m_AcceptNum = NowYear.ToString() + "010001"; // 新年度
|
| | | this.m_ChangeYear = true;
|
| | | }
|
| | |
|
| | | if ( !m_ChangeYear)
|
| | | { |
| | | }
|
| | | }
|
| | |
|
| | | private void RegetNumber() |
| | | {
|
| | | String SqlStmt = "SELECT ACCEPTNUM,CASEID,YEAR FROM EOS.EVENTNUM";
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | |
|
| | | try
|
| | | {
|
| | | if (reader.Read())
|
| | | {
|
| | | m_AcceptNum = reader["ACCEPTNUM"].ToString();
|
| | | m_CaseID = Convert.ToInt32(reader["CASEID"].ToString());
|
| | | m_Year = Convert.ToInt32(reader["YEAR"].ToString());
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | { |
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
New file |
| | |
| | | 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.Function
|
| | | {
|
| | | public class Leach
|
| | | {
|
| | | private CCS.Function.MergeCase MergeCase = new CCS.Function.MergeCase();
|
| | | private RecordLog _PLog;
|
| | | private OracleConnection _ConnectionTPC;
|
| | | private OracleTransaction _Transaction;
|
| | |
|
| | | public Leach(OracleConnection _Conn, OracleTransaction _Trx, RecordLog _Log)
|
| | | {
|
| | | _ConnectionTPC = _Conn;
|
| | | _Transaction = _Trx;
|
| | | _PLog = _Log;
|
| | | }
|
| | |
|
| | | public int LeachCase(CCS.Object.EventRecord m_NewRec)
|
| | | {
|
| | |
|
| | | switch (SameCase(m_NewRec))
|
| | | {
|
| | | case CCS.LocalVariable.Success:
|
| | | return this.Judge(m_NewRec, false);
|
| | | case CCS.LocalVariable.CaseTypeChanged:
|
| | | return this.Judge(m_NewRec, true);
|
| | | case CCS.LocalVariable.SameCustomer:
|
| | | return CCS.LocalVariable.SameCustomer;
|
| | | case CCS.LocalVariable.Failure_By_DB:
|
| | | return CCS.LocalVariable.Failure_By_DB;
|
| | | case CCS.LocalVariable.CaseTransfer:
|
| | | return CCS.LocalVariable.CaseTransfer;
|
| | | default:
|
| | | return CCS.LocalVariable.Failure_By_DB;
|
| | | }
|
| | | }
|
| | |
|
| | | public CCS.EventAI.Equipment getOldEquipment()
|
| | | {
|
| | | return this.MergeCase.getOldEquipment();
|
| | | }
|
| | |
|
| | | private int SameCase(CCS.Object.EventRecord m_NewRec)
|
| | | {
|
| | | String SqlStmt = "SELECT R.ACCEPTNUM,R.CASEID as CASEID,R.IMPORTCASE as IMPORTCASE,E.CASETYPE as CASETYPE FROM EOS.EVENTRECORD R,"
|
| | | + "EOS.EVENTS E WHERE ";
|
| | | int m_Result = -1;
|
| | | int ImportCase = -1;
|
| | | int TmpCaseID = 0;
|
| | | int CaseType = -1;
|
| | | _PLog.Info("利用電號或地址檢查是否有已成立之案件.");
|
| | | // 檢查資料庫中此電號或地址是否已成立案件
|
| | | |
| | | if (m_NewRec.getMeter().Trim().Length != 0)
|
| | | {
|
| | | SqlStmt = SqlStmt + "R.CUSTOMERMETER = '" + m_NewRec.getMeter() + "' AND E.CASEID = R.CASEID AND E.CASESTATUS <= "
|
| | | + CCS.LocalVariable.WaitForSponsor;
|
| | | }
|
| | | else if (m_NewRec.getAddr().Trim().Length != 0)
|
| | | {
|
| | | SqlStmt = SqlStmt + "R.CUSTOMERADDR = '" + m_NewRec.getAddr() + "' AND E.CASEID = R.CASEID AND E.CASESTATUS <= "
|
| | | + CCS.LocalVariable.WaitForSponsor;
|
| | | }
|
| | |
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | |
|
| | | try
|
| | | {
|
| | | if (reader.Read())
|
| | | {
|
| | | ImportCase = Convert.ToInt32(reader["IMPORTCASE"].ToString());
|
| | | TmpCaseID = Convert.ToInt32(reader["CASEID"].ToString());
|
| | | CaseType = Convert.ToInt32(reader["CASETYPE"].ToString());
|
| | | m_NewRec.setTmpCaseID(TmpCaseID);
|
| | | _PLog.Info("案件已成立:" + reader["ACCEPTNUM"].ToString() + " " + TmpCaseID + " " + CaseType);
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | return CCS.LocalVariable.Failure_By_DB;
|
| | | }
|
| | | finally
|
| | | { |
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | |
|
| | | // 非同一用戶重複來電
|
| | | if (TmpCaseID == 0)
|
| | | {
|
| | | return CCS.LocalVariable.Success;
|
| | | }
|
| | | switch (CaseType)
|
| | | {
|
| | | case CCS.LocalVariable.OriginalCase:
|
| | | case CCS.LocalVariable.ParentCase:
|
| | | SqlStmt = "SELECT TO_CHAR(CLOSETIME,'YYYY/MM/DD HH24:MI:SS') as CLOSETIME,COUNT(*) as COUNT FROM EOS.EVENTFACILITY " + "WHERE CASEID = "
|
| | | + TmpCaseID + " GROUP BY CLOSETIME ORDER BY CLOSETIME DESC";
|
| | | break;
|
| | | case CCS.LocalVariable.ChildCase:
|
| | | SqlStmt = "SELECT TO_CHAR(CLOSETIME,'YYYY/MM/DD HH24:MI:SS') as CLOSETIME,COUNT(*) as COUNT FROM EOS.EVENTFACILITY "
|
| | | + "WHERE CASEID = (SELECT PARENTID FROM EOS.MERGECASE WHERE CASEID = " + TmpCaseID + ") GROUP BY CLOSETIME "
|
| | | + "ORDER BY CLOSETIME DESC";
|
| | | break;
|
| | | default:
|
| | | _PLog.Error("無法辨別案件種類.");
|
| | | return CCS.LocalVariable.Failure_By_DB;
|
| | | }
|
| | | _PLog.Info("檢查該案件有無切開關紀錄.");
|
| | |
|
| | | try
|
| | | {
|
| | | Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | reader = Command.ExecuteReader();
|
| | |
|
| | | if (reader.Read())
|
| | | {
|
| | | // 有開關尚未恢復
|
| | | if (reader["CLOSETIME"] == null)
|
| | | {
|
| | | _PLog.Info("有切開關且尚未恢復.");
|
| | | if ((m_NewRec.getImportCase() == ImportCase) || (ImportCase == CCS.LocalVariable.isImportCase))
|
| | | {
|
| | | m_Result = this.AddCount(TmpCaseID);
|
| | | }
|
| | | else
|
| | | {
|
| | | m_Result = CCS.LocalVariable.CaseTypeChanged;
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | // 開關都已恢復(同用戶須重新受理)
|
| | | _PLog.Info("有切開關且已經恢復.");
|
| | | int CaseID;
|
| | |
|
| | | // 找出案件編號需以母案件編號或該案件編號去找casestatus
|
| | | if (TmpCaseID == 0)
|
| | | {
|
| | | CaseID = m_NewRec.getCaseID();
|
| | | }
|
| | | else
|
| | | {
|
| | | CaseID = TmpCaseID;
|
| | | }
|
| | | // 判斷該案件或母案件是否移轉作後續處理
|
| | | if (this.getCastStatus(CaseID) == CCS.LocalVariable.EventTrasnfer)
|
| | | {
|
| | | return CCS.LocalVariable.CaseTransfer;
|
| | | }
|
| | | else
|
| | | {
|
| | | m_Result = CCS.LocalVariable.Success;
|
| | | }
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | // 未切過開關
|
| | | _PLog.Info("無切開關紀錄.");
|
| | | if ((m_NewRec.getImportCase() == ImportCase) || (ImportCase == CCS.LocalVariable.isImportCase))
|
| | | {
|
| | | m_Result = this.AddCount(TmpCaseID);
|
| | | }
|
| | | else
|
| | | {
|
| | | int CaseID;
|
| | | // 找出案件編號需以母案件編號或該案件編號去找casestatus
|
| | | if (TmpCaseID == 0)
|
| | | {
|
| | | CaseID = m_NewRec.getCaseID();
|
| | | }
|
| | | else
|
| | | {
|
| | | CaseID = TmpCaseID;
|
| | |
|
| | | // 判斷該案件或母案件是否移轉作後續處理
|
| | | }
|
| | | if (this.getCastStatus(CaseID) == CCS.LocalVariable.EventTrasnfer)
|
| | | {
|
| | | return CCS.LocalVariable.CaseTransfer;
|
| | | }
|
| | | else
|
| | | {
|
| | | m_Result = CCS.LocalVariable.CaseTypeChanged;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | return CCS.LocalVariable.Failure_By_DB;
|
| | | }
|
| | | finally
|
| | | { |
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | | return m_Result;
|
| | | }
|
| | |
|
| | | private int AddCount(int m_CaseID)
|
| | | {
|
| | | String sqlStmt = "UPDATE EOS.EVENTS SET COUNT = COUNT + 1 WHERE CASEID = " + m_CaseID;
|
| | | OracleCommand Command = new OracleCommand(sqlStmt, _ConnectionTPC, _Transaction);
|
| | |
|
| | | try
|
| | | {
|
| | | if (Command.ExecuteNonQuery() > 0)
|
| | | return CCS.LocalVariable.SameCustomer;
|
| | | else
|
| | | return CCS.LocalVariable.Failure_By_DB;
|
| | | }
|
| | | catch (Exception)
|
| | | {
|
| | | return CCS.LocalVariable.Failure_By_DB;
|
| | | }
|
| | | finally
|
| | | { |
| | | Command.Dispose();
|
| | | }
|
| | | }
|
| | |
|
| | | private int getCastStatus(int CaseID)
|
| | | {
|
| | | String SqlStmt;
|
| | | int Status = 0;
|
| | |
|
| | | SqlStmt = "SELECT CASESTATUS FROM CCS.EVENTQUERY WHERE CCSID IN (SELECT CCSID FROM CCS.NUM_CONTRAST " + "WHERE CASEID = " + CaseID + ")";
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | OracleDataReader reader = null;
|
| | |
|
| | |
|
| | | try
|
| | | {
|
| | | reader = Command.ExecuteReader();
|
| | |
|
| | | if (reader.Read())
|
| | | Status = Convert.ToInt32(reader["CASESTATUS"].ToString());
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | { |
| | | if ( reader != null )
|
| | | reader.Close();
|
| | |
|
| | | Command.Dispose();
|
| | | }
|
| | | return Status;
|
| | | }
|
| | |
|
| | | private int Judge(CCS.Object.EventRecord m_NewRec, bool ChangeCaseType)
|
| | | {
|
| | | int m_Result = CCS.LocalVariable.Failure_By_DB;
|
| | |
|
| | | if ((m_NewRec.getMeter().Trim().Length == 0))
|
| | | {
|
| | | return CCS.LocalVariable.NoMeter;
|
| | | }
|
| | |
|
| | | /* 已知損壞設備(ONLY FOR 饋線全停才知道損壞設備的FSC) */
|
| | | try
|
| | | {
|
| | | if (m_NewRec.getFsc() != 0)
|
| | | {
|
| | | m_NewRec.getLocateEquipment().setFSC(CCS.LocalVariable.Breaker);
|
| | | m_NewRec.getLocateEquipment().setUFID(m_NewRec.getUfid());
|
| | | _PLog.Info("饋線全停:" + m_NewRec.getFsc() + ", " + m_NewRec.getUfid());
|
| | | MergeCase.Merge(m_NewRec, _ConnectionTPC, _Transaction, _PLog);
|
| | | return CCS.LocalVariable.Success;
|
| | | }
|
| | | }
|
| | | catch (CCS.EventAI.TraceLoopException)
|
| | | {
|
| | | return CCS.LocalVariable.Trace_Counts_3;
|
| | | }
|
| | | catch (TraceException)
|
| | | {
|
| | | return CCS.LocalVariable.Trace_Failure;
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | _PLog.Error(ex.Message);
|
| | | return CCS.LocalVariable.Failure_By_DB;
|
| | | }
|
| | |
|
| | | try
|
| | | {
|
| | | _PLog.Info("定位損壞設備!");
|
| | | int result = getEquipment(m_NewRec);
|
| | | _PLog.Info("FSC:" + m_NewRec.getFsc() + ", Ufid:" + m_NewRec.getUfid() + ", Tpclid:" + m_NewRec.getTpclid() + ", FeederID:" + m_NewRec.getFdrID());
|
| | |
|
| | | switch (result)
|
| | | { // get fsc,ufid,fdrid of sxfmr by meter
|
| | | case CCS.LocalVariable.Success:
|
| | | if (m_NewRec.getFdrID() == 0)
|
| | | {
|
| | | m_Result = CCS.LocalVariable.NoSupplyElc;
|
| | | }
|
| | | else
|
| | | {
|
| | | // 需在未併案前作土木設備設定
|
| | | this.getLocateEquipment(m_NewRec);
|
| | |
|
| | | if (m_NewRec.getBrief().Length !=0 && m_NewRec.getBrief().Substring(0,1).Equals("A"))
|
| | | { // A類事故原因,做追蹤合併
|
| | | _PLog.Info("<A類案件>");
|
| | | MergeCase.Merge(m_NewRec,_ConnectionTPC,_Transaction,_PLog);
|
| | | }
|
| | | else
|
| | | {
|
| | | _PLog.Info("<非A類案件>");
|
| | | }
|
| | |
|
| | | if (ChangeCaseType)
|
| | | {
|
| | | m_Result = CCS.LocalVariable.CaseTypeChanged;
|
| | | }
|
| | | else
|
| | | {
|
| | | m_Result = CCS.LocalVariable.Success;
|
| | | }
|
| | | }
|
| | | break;
|
| | | case CCS.LocalVariable.No_Sxfmr:
|
| | | m_Result = CCS.LocalVariable.No_Sxfmr;
|
| | | break;
|
| | | case CCS.LocalVariable.Failure_By_DB:
|
| | | m_Result = CCS.LocalVariable.Failure_By_DB;
|
| | | break;
|
| | | }
|
| | | }
|
| | | catch (CCS.EventAI.TraceLoopException)
|
| | | {
|
| | | return CCS.LocalVariable.Trace_Counts_3;
|
| | | }
|
| | | catch (TraceException)
|
| | | {
|
| | | m_Result = CCS.LocalVariable.Trace_Failure;
|
| | | }
|
| | | catch (Exception ex1)
|
| | | {
|
| | | _PLog.Error(ex1.Message);
|
| | | m_Result = CCS.LocalVariable.Failure_By_DB;
|
| | | }
|
| | | return m_Result;
|
| | | }
|
| | |
|
| | | private int getEquipment(CCS.Object.EventRecord m_NewRec)
|
| | | {
|
| | | String Temp;
|
| | | String m_OwnerTpclid;
|
| | | String m_Group;
|
| | | String SqlStmt = "select tran_cord from basedb.meter where metr_numb = '" + m_NewRec.getMeter() + "'";
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC,_Transaction);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | |
|
| | | try
|
| | | {
|
| | | if (reader.Read())
|
| | | {
|
| | | Temp = reader["tran_cord"].ToString().Trim();
|
| | | if ((Temp.Length == 9) || (Temp.Length == 11)) /* 架空變壓器 */
|
| | | {
|
| | | m_OwnerTpclid = Temp;
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | m_NewRec.setTpclid(m_OwnerTpclid);
|
| | | return getSxfmr(m_OwnerTpclid, null, m_NewRec); /* Find the Sxfmr */
|
| | | }
|
| | | else
|
| | | {
|
| | | m_OwnerTpclid = Temp.Substring(0, 11).Trim(); /* 地下變壓器 */
|
| | | m_Group = Temp.Substring(14);
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | m_NewRec.setTpclid(m_OwnerTpclid + " " + m_Group);
|
| | | return getSxfmr(m_OwnerTpclid, m_Group, m_NewRec);
|
| | | /* Find the Sxfmr */
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | return CCS.LocalVariable.No_Sxfmr;
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | return CCS.LocalVariable.Failure_By_DB;
|
| | | }
|
| | | finally
|
| | | { |
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | | }
|
| | |
|
| | | private int getSxfmr(String m_Tpclid, String m_Group, CCS.Object.EventRecord m_NewRec)
|
| | | {
|
| | | String SqlStmt;
|
| | | int m_Status = CCS.LocalVariable.Failure_By_DB;
|
| | |
|
| | | if (m_Group == null)
|
| | | {
|
| | | SqlStmt = "SELECT UFID,FDR1 FROM BASEDB.CONNECTIVITY WHERE FSC = " + CCS.LocalVariable.Sxfmr + " AND UFID IN "
|
| | | + "(SELECT UFID FROM BASEDB.SXFMR WHERE OWNERTPCLID = '" + m_Tpclid + "')";
|
| | | }
|
| | | else
|
| | | {
|
| | | SqlStmt = "SELECT UFID,FDR1 FROM BASEDB.CONNECTIVITY WHERE FSC = " + CCS.LocalVariable.Sxfmr + " AND UFID IN "
|
| | | + "(SELECT UFID FROM BASEDB.SXFMR WHERE OWNERTPCLID = '" + m_Tpclid + "' AND GROUP1 = '" + m_Group + "')";
|
| | |
|
| | | }
|
| | |
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | |
|
| | | try
|
| | | {
|
| | | if (reader.Read())
|
| | | {
|
| | | m_NewRec.setFsc(CCS.LocalVariable.Sxfmr);
|
| | | m_NewRec.setUfid(Convert.ToInt32(reader["ufid"].ToString()));
|
| | | m_NewRec.setFdrID(Convert.ToInt32(reader["fdr1"].ToString()));
|
| | | m_Status = CCS.LocalVariable.Success;
|
| | | }
|
| | | else
|
| | | m_Status = getHicustomer(m_Tpclid, m_Group, m_NewRec);
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | _PLog.Error(ex.Message);
|
| | | }
|
| | | finally
|
| | | { |
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | | return m_Status;
|
| | | }
|
| | |
|
| | |
|
| | | private int getHicustomer(String m_Tpclid, String m_Group, CCS.Object.EventRecord m_NewRec)
|
| | | {
|
| | | String SqlStmt;
|
| | |
|
| | | if (m_Group == null)
|
| | | {
|
| | | SqlStmt = "SELECT UFID,FDR1 FROM BASEDB.CONNECTIVITY WHERE FSC = " + CCS.LocalVariable.Hicustomer + " AND UFID IN "
|
| | | + "(SELECT UFID FROM BASEDB.HICUSTOMER WHERE OWNERTPCLID = '" + m_Tpclid + "')";
|
| | | }
|
| | | else
|
| | | {
|
| | | SqlStmt = "SELECT UFID,FDR1 FROM BASEDB.CONNECTIVITY WHERE FSC = " + CCS.LocalVariable.Hicustomer + " AND UFID IN "
|
| | | + "(SELECT UFID FROM BASEDB.HICUSTOMER WHERE OWNERTPCLID = '" + m_Tpclid + "' AND GROUP1 = '" + m_Group + "')";
|
| | |
|
| | | }
|
| | |
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | |
|
| | | try
|
| | | {
|
| | | if (reader.Read())
|
| | | {
|
| | | m_NewRec.setFsc(CCS.LocalVariable.Hicustomer);
|
| | | m_NewRec.setUfid(Convert.ToInt32(reader["ufid"].ToString()));
|
| | | m_NewRec.setFdrID(Convert.ToInt32(reader["fdr1"].ToString()));
|
| | | return CCS.LocalVariable.Success;
|
| | | }
|
| | | else
|
| | | return CCS.LocalVariable.No_Sxfmr;
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | _PLog.Error(ex.Message);
|
| | | return CCS.LocalVariable.Failure_By_DB;
|
| | | }
|
| | | finally
|
| | | { |
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | | }
|
| | |
|
| | | private void getLocateEquipment(CCS.Object.EventRecord m_NewRec)
|
| | | {
|
| | | String SqlStmt;
|
| | |
|
| | | SqlStmt = "SELECT OWNERFSC as FSC,OWNERUFID as UFID,OWNERTPCLID as TPCLID FROM ";
|
| | | switch (m_NewRec.getFsc())
|
| | | {
|
| | | case CCS.LocalVariable.Sxfmr:
|
| | | SqlStmt = SqlStmt + "BASEDB.SXFMR WHERE UFID = " + m_NewRec.getUfid();
|
| | | break;
|
| | | case CCS.LocalVariable.Hicustomer:
|
| | | SqlStmt = SqlStmt + "BASEDB.HICUSTOMER WHERE UFID = " + m_NewRec.getUfid();
|
| | | break;
|
| | | }
|
| | |
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | |
|
| | | try
|
| | | {
|
| | | if (reader.Read())
|
| | | {
|
| | | m_NewRec.getLocateEquipment().setFSC(Convert.ToInt32(reader["FSC"].ToString()));
|
| | | m_NewRec.getLocateEquipment().setUFID(Convert.ToInt32(reader["UFID"].ToString()));
|
| | | m_NewRec.getLocateEquipment().setTPCLID(reader["TPCLID"].ToString());
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | { |
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | using System;
|
| | | using System.Data.OracleClient;
|
| | | using System.Net.Mail;
|
| | |
|
| | | namespace CCSTrace.CCS.Function
|
| | | {
|
| | | public class MailService
|
| | | {
|
| | | private SmtpClient smtpClient = null;
|
| | | private string SMTP_IP;
|
| | | private int SMTP_Port;
|
| | | private string EMailAddr;
|
| | | private string EMailPass;
|
| | | private string ToEMail;
|
| | |
|
| | | public MailService(OracleConnection _Conn)
|
| | | {
|
| | | InitialSmtpClient(_Conn);
|
| | | }
|
| | |
|
| | | public void InitialSmtpClient(OracleConnection _Conn)
|
| | | {
|
| | | getMailSetting(_Conn);
|
| | | smtpClient = new SmtpClient(SMTP_IP, SMTP_Port);
|
| | | smtpClient.Credentials = new System.Net.NetworkCredential(EMailAddr, EMailPass);
|
| | | smtpClient.EnableSsl = false;
|
| | | }
|
| | |
|
| | | public bool SendMail(String CCSID)
|
| | | {
|
| | | Attachment objAttFle = new Attachment(CCS.LocalVariable.CCS_ListPath + CCSID + ".txt");
|
| | | MailMessage objMail = new MailMessage();
|
| | |
|
| | | try
|
| | | {
|
| | | objMail.From = new MailAddress(EMailAddr);
|
| | | objMail.To.Add(ToEMail);
|
| | |
|
| | | objMail.BodyEncoding = System.Text.Encoding.UTF8;
|
| | | objMail.Subject = "CCS事故案件追蹤失敗";
|
| | | //objMail.Body = "測試收件者"; |
| | | objMail.IsBodyHtml = true;
|
| | |
|
| | | if ( objAttFle != null )
|
| | | objMail.Attachments.Add(objAttFle);
|
| | |
|
| | | smtpClient.Send(objMail);
|
| | | return true;
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | private void getMailSetting(OracleConnection _Conn)
|
| | | {
|
| | | String SqlStmt;
|
| | |
|
| | | SqlStmt = "SELECT MAIL_ACCOUNT,MAIL_PASSWORD,MAIL_HOST,MAIL_PORT,WOS_MAIL FROM USRADMIN.SYS_MAIL";
|
| | |
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _Conn);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | | |
| | | try
|
| | | {
|
| | | if (reader.Read())
|
| | | {
|
| | | SMTP_IP = reader["MAIL_HOST"].ToString();
|
| | | SMTP_Port = Convert.ToInt32(reader["MAIL_PORT"].ToString());
|
| | | EMailAddr = reader["MAIL_ACCOUNT"].ToString();
|
| | | EMailPass = reader["MAIL_PASSWORD"].ToString();
|
| | | ToEMail = reader["CCS_MAIL"].ToString();
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | {
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | | |
| | | }
|
| | |
|
| | | }
|
| | | } |
New file |
| | |
| | | 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.Function
|
| | | {
|
| | | public class MergeCase
|
| | | {
|
| | | private CCS.Object.EventRecord l_Eventrecord;
|
| | | private CCS.EventAI.JudgeCase m_JudgeCase;
|
| | |
|
| | | public MergeCase() |
| | | {
|
| | | }
|
| | |
|
| | | public void Merge(CCS.Object.EventRecord m_Eventrecord, OracleConnection _Conn,OracleTransaction _Trx, RecordLog _Log) |
| | | {
|
| | | try
|
| | | {
|
| | | m_JudgeCase = new CCS.EventAI.JudgeCase(m_Eventrecord.getFdrID(), m_Eventrecord.getFsc(), m_Eventrecord.getUfid(),
|
| | | m_Eventrecord.getCaseID(), m_Eventrecord.getAcceptDate(), _Conn, _Trx, _Log);
|
| | | l_Eventrecord = m_Eventrecord;
|
| | | m_JudgeCase.AIBegin();
|
| | | l_Eventrecord.setParentID(m_JudgeCase.getParentCaseID());
|
| | | l_Eventrecord.setFsc(m_JudgeCase.getInferEquipment().getFSC());
|
| | | l_Eventrecord.setUfid(m_JudgeCase.getInferEquipment().getUFID());
|
| | | }
|
| | | catch (CCS.EventAI.TraceLoopException tle) {
|
| | | _Log.Error(tle.Message);
|
| | | throw tle;
|
| | | }
|
| | | catch (Exception e) {
|
| | | _Log.Error(e.Message);
|
| | | throw e;
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public CCS.EventAI.Equipment getOldEquipment() {
|
| | | return m_JudgeCase.getOldrEquipment();
|
| | | }
|
| | | }
|
| | |
|
| | | class TraceException : Exception
|
| | | {
|
| | | public TraceException()
|
| | | {
|
| | | }
|
| | | }
|
| | | }
|
New file |
| | |
| | |
|
| | | namespace CCSTrace.CCS
|
| | | {
|
| | | public class LocalVariable
|
| | | {
|
| | | public static int EventInitial = 1000;// Create new event
|
| | | public static int EventProcess = 1001;// Trace and process event in CCS WebService
|
| | | public const int WaitForDespatch = 1002; // create DesRec
|
| | | public static int EventDespatched = 1003;
|
| | | public const int WaitForSponsor = 1005; // create SponRec
|
| | | public static int WaitForRepair = 1006; // create RepairRec
|
| | | public static int EventFinsh = 1007; // with no RepairRecord
|
| | | public static int EventComplete = 1008; // with RepairRecord
|
| | | public static int EventOver = 1009; // with RepairRecord but not upload
|
| | |
|
| | | public static int EventReturn = 2001; // Return the EventRecord
|
| | | public static int AlarmFailure = 2002; // EventRecord AlarmFailure
|
| | | public static int EventTrasnfer = 2003; // EventRecord Transfer to Process
|
| | |
|
| | | public static int Dept = 31; /* 受理部門 */
|
| | |
|
| | | public static int CCSEventBrief = 11; /* 事故原因(FOR CCS) */
|
| | | public static int CCSDept = 12; /* 部門(FOR CCS) */
|
| | |
|
| | | // 是否颱風案件
|
| | | public static int isDisaster = 1;
|
| | | public static int NotDisaster = 0;
|
| | |
|
| | | /* Event Type */
|
| | | public static int NotImportCase = 0;
|
| | | public static int isImportCase = 1;
|
| | |
|
| | | /* Level Type */
|
| | | public static int No_Level = 0;
|
| | | public static int A_Level = 1;
|
| | | public static int B_Level = 2;
|
| | | public static int C_Level = 3;
|
| | |
|
| | | /* Recall Type */
|
| | | public static int NotReCall = 0;
|
| | | public static int isReCall = 1;
|
| | |
|
| | | /* Trace_Finish */
|
| | | public static int Trace_Still = 0;
|
| | | public static int Trace_Finish = 1;
|
| | |
|
| | | /* CaseType */
|
| | | public const int OriginalCase = 0;
|
| | | public const int ParentCase = 1;
|
| | | public const int ChildCase = 2;
|
| | |
|
| | | /* Equipment */
|
| | | public const int Breaker = 108;
|
| | | public const int Jumper = 109;
|
| | | public const int Switch = 114;
|
| | | public const int Sxfmr = 115;
|
| | | public const int Hicustomer = 107;
|
| | |
|
| | | /* Tracer Return Status */
|
| | | public const int Trace_Failure = 0;
|
| | | public const int Success = 1;
|
| | | public const int Failure_By_DB = 2;
|
| | | public const int No_Sxfmr = 3;
|
| | | public const int CaseTypeChanged = 4;
|
| | | public const int CaseTransfer = 5;
|
| | | public const int FDRLocked = 6;
|
| | | public const int Trace_Counts_3 = 7;
|
| | |
|
| | | /* Error Message */
|
| | | public const int SameCustomer = 5001; /* 重複來電 */
|
| | | public const int NoMeter = 5002; /* 找不到電號 */
|
| | | public const int Debt = 5003; /* 欠費停電 */
|
| | | public const int NoSupplyElc = 5004; /* 未供電線段 */
|
| | |
|
| | | /* Alerm */
|
| | | public static int AlermPort = 3000;
|
| | |
|
| | | //private static string m_OracleThinConn = "jdbc:oracle:thin:";
|
| | | //private static string m_OracleThinUser = "";
|
| | | //private static string m_OracleThinPass = "";
|
| | | //private static string m_strThinConnRegPath = "SOFTWARE\\Origo\\OMS\\Login";
|
| | | //private static string m_strThinConnRegName = "thin";
|
| | | //private static string m_strThinConnRegUser = "DBUser";
|
| | | //private static string m_strThinConnRegPassWord = "DBPassWord";
|
| | |
|
| | | public static string CCS_ListPath = "c:\\OMS\\BIN\\CCS\\";
|
| | |
|
| | | public static bool ShowError = false;
|
| | |
|
| | | // Date Converter
|
| | | //public static CCS.Function.TransferDate Convert = new CCS.Function.TransferDate();
|
| | | |
| | | }
|
| | | }
|
New file |
| | |
| | | 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.Collections;
|
| | | using System.Data.OracleClient;
|
| | |
|
| | | namespace CCSTrace.CCS.Object
|
| | | {
|
| | | public class Addr_Contrast
|
| | | {
|
| | | public static Hashtable m_TotalData = null;
|
| | | public static String DefaultDept = "市區巡修課";
|
| | | private OracleConnection _ConnectionTPC;
|
| | | private RecordLog _PLog;
|
| | |
|
| | | public Addr_Contrast(OracleConnection _Conn, OracleTransaction _Trx, RecordLog _Log)
|
| | | {
|
| | | _ConnectionTPC = _Conn;
|
| | | _PLog = _Log;
|
| | |
|
| | | String SqlStmt;
|
| | | String City;
|
| | | ArrayList m_Data = new ArrayList();
|
| | | String Tmp = "";
|
| | |
|
| | | if (m_TotalData != null)
|
| | | return;
|
| | |
|
| | | m_TotalData = new Hashtable();
|
| | | SqlStmt = "SELECT DEPTID,CITY,TOWN,ROAD FROM CCS.ADDR_CONTRAST ORDER BY CITY,TOWN,ROAD";
|
| | |
|
| | | OracleCommand Command = null;
|
| | | OracleDataReader reader = null;
|
| | | try
|
| | | {
|
| | | Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Trx);
|
| | | reader = Command.ExecuteReader();
|
| | |
|
| | | while (reader.Read())
|
| | | {
|
| | | ArrayList m_Record = new ArrayList();
|
| | | City = reader["CITY"].ToString();
|
| | | m_Record.Add(City);
|
| | | m_Record.Add(reader["TOWN"].ToString());
|
| | | m_Record.Add(reader["ROAD"].ToString());
|
| | | m_Record.Add(Convert.ToInt32(reader["DEPTID"].ToString()));
|
| | |
|
| | | if (Tmp.Equals(City))
|
| | | m_Data.Add(m_Record);
|
| | | else
|
| | | {
|
| | | m_TotalData.Add(Tmp, m_Data);
|
| | | Tmp = City;
|
| | | m_Data = new ArrayList();
|
| | | m_Data.Add(m_Record);
|
| | | }
|
| | | }
|
| | | m_TotalData.Add(Tmp, m_Data);
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine(e.StackTrace);
|
| | | m_TotalData = null;
|
| | | }
|
| | | finally
|
| | | {
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public int findDeptID(String City, String Region, String Road)
|
| | | {
|
| | | int Dept = 0;
|
| | | ArrayList m_Data = (ArrayList)m_TotalData[City];
|
| | |
|
| | | try
|
| | | {
|
| | | for (int i = 0; i < m_Data.Count; i++)
|
| | | {
|
| | | ArrayList Tmp = (ArrayList)m_Data[i];
|
| | | String m_Region = Tmp[1].ToString().Trim();
|
| | | String m_Road = Tmp[2].ToString().Trim();
|
| | | int DeptID = Convert.ToInt32(Tmp[3].ToString());
|
| | |
|
| | | if ((Region.Trim().Equals(m_Region)) && (Road.Trim().Equals(m_Road)))
|
| | | return DeptID;
|
| | | }
|
| | | }
|
| | | catch (Exception)
|
| | | {
|
| | | _PLog.Warn("無法取得所屬巡修部門代號,預設案件所屬巡修部門為市區巡修課!");
|
| | | }
|
| | | // 當找不到部門別時,Default 設定為市巡
|
| | | Dept = CCS.CCSMain.EOSCodelist.getKeyID(CCS.LocalVariable.Dept, DefaultDept);
|
| | | return Dept;
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
New file |
| | |
| | | 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.Collections;
|
| | | using System.Data.OracleClient;
|
| | | using System.Net;
|
| | | using System.Net.Sockets;
|
| | | using System.IO;
|
| | |
|
| | | namespace CCSTrace.CCS.Object
|
| | | {
|
| | | public class AlarmData
|
| | | {
|
| | | private Hashtable m_TotalData = new Hashtable();
|
| | | private RecordLog _PLog;
|
| | | private OracleConnection _ConnectionTPC;
|
| | | private OracleTransaction _Transaction;
|
| | |
|
| | | public AlarmData(OracleConnection _Conn,OracleTransaction _Trx, RecordLog _Log)
|
| | | {
|
| | | _ConnectionTPC = _Conn;
|
| | | _Transaction = _Trx;
|
| | | _PLog = _Log;
|
| | |
|
| | | String SqlStmt;
|
| | |
|
| | | SqlStmt = "SELECT DEPTID,IP1,IP2,IP_PATROL FROM CCS.ALARM_IP";
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | |
|
| | | try
|
| | | {
|
| | | while (reader.Read())
|
| | | {
|
| | | ArrayList Tmp = new ArrayList();
|
| | | Tmp.Add(Convert.ToInt32(reader["DEPTID"].ToString()));
|
| | | Tmp.Add(reader["IP1"].ToString());
|
| | | Tmp.Add(reader["IP2"].ToString());
|
| | | Tmp.Add(reader["IP_Patrol"].ToString());
|
| | |
|
| | | m_TotalData.Add(Convert.ToInt32(reader["DeptID"].ToString()), Tmp);
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error("Problems occur when fetch alarm data: (" + e.Message + ")");
|
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | { |
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | | }
|
| | |
|
| | | private int getSSCCode(int m_SCCode, int m_Week) {
|
| | | int ssccode = m_SCCode;
|
| | |
|
| | | /* DateTime stime = DateTime.Now;
|
| | |
|
| | | DateTime endtime = DateTime.Now;
|
| | |
|
| | | String SqlStmt = "select g.ssc_code as SSCCODE,t.begintime as BEGINTIME,t.endtime as ENDTIME,t.week as WEEK from ccs.scgroup g,ccs.scgrouptime t where g.groupid=t.groupid and g.sc_code="
|
| | | + m_SCCode + " and t.week=" + m_Week;
|
| | | |
| | | try {
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | | |
| | | while (reader.Read())
|
| | | {
|
| | | stime.set(Calendar.DAY_OF_WEEK, Rs.getInt("WEEK"));
|
| | | endtime.set(Calendar.DAY_OF_WEEK, Rs.getInt("WEEK"));
|
| | | stime.set(Calendar.HOUR_OF_DAY, Rs.getInt("BEGINTIME"));
|
| | | endtime.set(Calendar.HOUR_OF_DAY, Rs.getInt("ENDTIME"));
|
| | |
|
| | | if (stime.after(endtime)) |
| | | endtime.roll(Calendar.DAY_OF_WEEK, 1);
|
| | | |
| | | if (stime.before(nowtime) && (endtime.after(nowtime))) |
| | | ssccode = Rs.getInt("SSCCODE");
|
| | | |
| | | }
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | } catch (Exception ex) {
|
| | | _PLog.warn("無法取得SSCCode,以該案件所屬SCCode代替: (" + ex.Message + ")");
|
| | | }*/
|
| | | return ssccode;
|
| | | }
|
| | |
|
| | | private ArrayList getIPAddress(int DeptCode) {
|
| | | return (ArrayList) m_TotalData[Convert.ToInt32(DeptCode)];
|
| | | }
|
| | |
|
| | | public bool alarm(String AcceptNum, int Dept) |
| | | {
|
| | | |
| | | _PLog.Info("開始Alarm...");
|
| | | System.Net.Sockets.Socket m_Client;
|
| | | ArrayList IPAddressSet = this.getIPAddress(this.getSSCCode(Dept, Convert.ToInt32(DateTime.Now.DayOfWeek)));
|
| | | String IP1;
|
| | | String IP2;
|
| | | String IP_Patrol;
|
| | | System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
|
| | |
|
| | | if (IPAddressSet != null)
|
| | | {
|
| | | _PLog.Info("已取得該部門所需通知的IP Address.");
|
| | | IP1 = IPAddressSet[1].ToString();
|
| | | IP2 = IPAddressSet[2].ToString();
|
| | | IP_Patrol = IPAddressSet[3].ToString();
|
| | | } else {
|
| | | _PLog.Warn("無法取得該部門所需通知的IP Address!");
|
| | | return false;
|
| | | }
|
| | |
|
| | | try {
|
| | | IPAddress serverIp = IPAddress.Parse(IP1);
|
| | | int serverPort = Convert.ToInt32(CCS.LocalVariable.AlermPort);
|
| | | IPEndPoint iep = new IPEndPoint(serverIp, serverPort);
|
| | |
|
| | | m_Client = new System.Net.Sockets.Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
| | | m_Client.Connect(iep);
|
| | |
|
| | | byte[] byteMessage = encoding.GetBytes(AcceptNum);
|
| | |
|
| | | m_Client.Send(byteMessage);
|
| | | m_Client.Shutdown(SocketShutdown.Both);
|
| | | m_Client.Close();
|
| | | this.recordAlarmIP(AcceptNum, IP1);
|
| | | _PLog.Info("已成功通知" + IP1 + " !");
|
| | | return true;
|
| | |
|
| | | } catch (Exception e) {
|
| | | _PLog.Warn("無法通知" + IP1 + ": " + e.Message);
|
| | | }
|
| | |
|
| | | try {
|
| | | IPAddress serverIp = IPAddress.Parse(IP2);
|
| | | int serverPort = Convert.ToInt32(CCS.LocalVariable.AlermPort);
|
| | | IPEndPoint iep = new IPEndPoint(serverIp, serverPort);
|
| | |
|
| | | m_Client = new System.Net.Sockets.Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
| | | m_Client.Connect(iep);
|
| | |
|
| | | byte[] byteMessage = encoding.GetBytes(AcceptNum);
|
| | |
|
| | | m_Client.Send(byteMessage);
|
| | | m_Client.Shutdown(SocketShutdown.Both);
|
| | | m_Client.Close();
|
| | | this.recordAlarmIP(AcceptNum, IP2);
|
| | | _PLog.Info("已成功通知" + IP2 + " !");
|
| | | return true;
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Warn("無法通知" + IP2 + ": " + e.Message);
|
| | | }
|
| | |
|
| | | try {
|
| | | IPAddress serverIp = IPAddress.Parse(IP_Patrol);
|
| | | int serverPort = Convert.ToInt32(CCS.LocalVariable.AlermPort);
|
| | | IPEndPoint iep = new IPEndPoint(serverIp, serverPort);
|
| | |
|
| | | m_Client = new System.Net.Sockets.Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
| | | m_Client.Connect(iep);
|
| | |
|
| | | byte[] byteMessage = encoding.GetBytes(AcceptNum);
|
| | |
|
| | | m_Client.Send(byteMessage);
|
| | | m_Client.Shutdown(SocketShutdown.Both);
|
| | | m_Client.Close();
|
| | | this.recordAlarmIP(AcceptNum, IP_Patrol);
|
| | | _PLog.Info("已成功通知" + IP_Patrol + " !");
|
| | | return true;
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Warn("無法通知" + IP_Patrol + ": " + e.Message);
|
| | | _PLog.Warn("三個IP均無法通知到!");
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | private void recordAlarmIP(String AccNum, String IP) {
|
| | | String SqlStmt = "insert into eos.case_dispatch (acceptnum,alarmip) values('" + AccNum + "','" + IP + "')";
|
| | |
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | |
|
| | | try
|
| | | {
|
| | |
|
| | | if (Command.ExecuteNonQuery() <= 0)
|
| | | _PLog.Warn("無法紀錄Alarm IP!");
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error("recordAlarmIP Error." + e.Message);
|
| | | return;
|
| | | }
|
| | | finally
|
| | | {
|
| | | Command.Dispose();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
New file |
| | |
| | | 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.Collections;
|
| | | using System.Data.OracleClient;
|
| | |
|
| | | namespace CCSTrace.CCS.Object
|
| | | {
|
| | | public class CCSCodelist
|
| | | {
|
| | | private Hashtable m_TotalData = new Hashtable();
|
| | | private int KeyID = 1;
|
| | | private int Item = 2;
|
| | | private int Content = 3;
|
| | |
|
| | | public CCSCodelist(OracleConnection _ConnectionTPC)
|
| | | {
|
| | | String SqlStmt;
|
| | | ArrayList m_Data = new ArrayList();
|
| | | int Tmp = 0;
|
| | | int IndexID; |
| | |
|
| | | SqlStmt = "SELECT INDEXID,KEYID,ITEM,CONTENT FROM CCS.CODELIST ORDER BY INDEXID,KEYID";
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | |
|
| | | try
|
| | | {
|
| | |
|
| | | while (reader.Read())
|
| | | {
|
| | | ArrayList m_Record = new ArrayList();
|
| | | IndexID = Convert.ToInt32(reader["INDEXID"].ToString());
|
| | | m_Record.Add(IndexID);
|
| | | m_Record.Add(Convert.ToInt32(reader["KEYID"].ToString()));
|
| | | m_Record.Add(reader["ITEM"].ToString());
|
| | | m_Record.Add(reader["CONTENT"].ToString());
|
| | |
|
| | | if (Tmp == IndexID)
|
| | | {
|
| | | m_Data.Add(m_Record);
|
| | | }
|
| | | else
|
| | | {
|
| | | m_TotalData.Add(Tmp, m_Data);
|
| | | Tmp = IndexID;
|
| | | m_Data = new ArrayList();
|
| | | m_Data.Add(m_Record);
|
| | | }
|
| | | }
|
| | | m_TotalData.Add(Tmp, m_Data);
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine("Error on Initial EOSCodelist: " + e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | { |
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | | }
|
| | |
|
| | | public ArrayList getAllContent(int m_IndexID)
|
| | | {
|
| | | return ((ArrayList)m_TotalData[m_IndexID]);
|
| | | }
|
| | |
|
| | | public String getContent(int m_IndexID, int m_KeyID)
|
| | | {
|
| | | ArrayList m_Tmp = (ArrayList)m_TotalData[m_IndexID];
|
| | | String m_Result = "";
|
| | |
|
| | | try
|
| | | {
|
| | | for (int i = 0; i < m_Tmp.Count; i++)
|
| | | {
|
| | | if (Convert.ToInt32(((ArrayList)m_Tmp[i])[KeyID].ToString()) == m_KeyID)
|
| | | {
|
| | | m_Result = ((ArrayList)m_Tmp[i])[Content].ToString();
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | Console.WriteLine("Error in get CCSCodelist(getContent(int m_IndexID, int m_KeyID)): " + ex.Message);
|
| | | }
|
| | | return m_Result;
|
| | | }
|
| | |
|
| | | public String getContent(int m_IndexID, String m_Item)
|
| | | {
|
| | | ArrayList m_Tmp = (ArrayList)m_TotalData[m_IndexID];
|
| | | String m_Result = "";
|
| | |
|
| | | try
|
| | | {
|
| | | for (int i = 0; i < m_Tmp.Count; i++)
|
| | | {
|
| | | if ( ((ArrayList)m_Tmp[i])[Item].ToString().Trim().Equals(m_Item.Trim()))
|
| | | {
|
| | | m_Result = ((ArrayList)m_Tmp[i])[Content].ToString();
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | Console.WriteLine("Error in get CCSCodelist(getContent(int m_IndexID, String m_Item)): " + ex.Message);
|
| | | }
|
| | | return m_Result;
|
| | | }
|
| | |
|
| | | public int getKeyID(int m_IndexID, String m_Content)
|
| | | {
|
| | | ArrayList m_Tmp = (ArrayList)m_TotalData[m_IndexID];
|
| | | int m_Result = 0;
|
| | |
|
| | | for (int i = 0; i < m_Tmp.Count; i++)
|
| | | {
|
| | | if (((ArrayList)m_Tmp[i])[Content].ToString().Equals(m_Content))
|
| | | {
|
| | | m_Result = Convert.ToInt32(((ArrayList)m_Tmp[i])[KeyID].ToString());
|
| | | break;
|
| | | }
|
| | | }
|
| | | return m_Result;
|
| | | }
|
| | |
|
| | | public String getItem(int m_IndexID, String m_Content)
|
| | | {
|
| | | ArrayList m_Tmp = (ArrayList)m_TotalData[m_IndexID];
|
| | | String m_Result = "";
|
| | |
|
| | | for (int i = 0; i < m_Tmp.Count; i++)
|
| | | {
|
| | | if (((ArrayList)m_Tmp[i])[Content].ToString().Equals(m_Content))
|
| | | {
|
| | | m_Result = ((ArrayList)m_Tmp[i])[this.Item].ToString();
|
| | | break;
|
| | | }
|
| | | }
|
| | | return m_Result;
|
| | | }
|
| | |
|
| | | public int getContentNumber(int m_IndexID)
|
| | | {
|
| | | return ((ArrayList)m_TotalData[m_IndexID]).Count;
|
| | | }
|
| | | }
|
| | | }
|
New file |
| | |
| | | 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
|
| | | {
|
| | | 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;
|
| | |
|
| | | 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)
|
| | | {
|
| | | 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;
|
| | | }
|
| | |
|
| | | public CCSRecord(String _CCSID, OracleConnection _ConnectionTPC, SEventLog _PLog)
|
| | | {
|
| | | String SqlStmt;
|
| | |
|
| | | 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();
|
| | | |
| | | 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();
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error("無法取得CCS報案資訊!" + e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | |
|
| | | if (LocalVariable.ShowError)
|
| | | _PLog.Error(e.StackTrace);
|
| | |
|
| | | throw e;
|
| | | }
|
| | | finally
|
| | | { |
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | | }
|
| | |
|
| | | public bool InsertDB(OracleConnection _ConnectionTPC, System.Data.OracleClient.OracleTransaction _Transaction, SEventLog _PLog)
|
| | | {
|
| | | String SqlStmt;
|
| | |
|
| | | 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);
|
| | |
|
| | | try
|
| | | {
|
| | | if (Command.ExecuteNonQuery() != 1)
|
| | | {
|
| | | _PLog.Error("CCS 案件受理程序初始化失敗...無法將CCS報案資訊存入資料庫中!");
|
| | |
|
| | | throw new Exception("CCS 案件受理程序初始化失敗...無法將CCS報案資訊存入資料庫中!");
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine(e.StackTrace);
|
| | |
|
| | | if (LocalVariable.ShowError)
|
| | | _PLog.Error(e.StackTrace);
|
| | |
|
| | | _PLog.Error("CCS 案件受理程序初始化失敗...無法將CCS報案資訊存入資料庫中!" + e.Message);
|
| | | //throw new Exception("CCS 案件受理程序初始化失敗...無法將CCS報案資訊存入資料庫中");
|
| | | throw e;
|
| | | }
|
| | | finally
|
| | | {
|
| | | 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;
|
| | | }
|
| | | }
|
| | | }
|
New file |
| | |
| | | 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.Collections;
|
| | | using System.Data.OracleClient;
|
| | |
|
| | | namespace CCSTrace.CCS.Object
|
| | | {
|
| | | public class Dept_Contrast
|
| | | {
|
| | | private ArrayList m_TotalData = null;
|
| | | public static String DefaultDept = "市區巡修課";
|
| | |
|
| | | public Dept_Contrast(OracleConnection _ConnectionTPC,OracleTransaction _Trx)
|
| | | {
|
| | | if (m_TotalData == null)
|
| | | this.Initial(_ConnectionTPC,_Trx);
|
| | | }
|
| | |
|
| | | public int getDept_Code(String m_Meter)
|
| | | {
|
| | | //int Result = CCS.CCSMain.EOSCodelist.getKeyID(CCS.LocalVariable.Dept, DefaultDept);
|
| | | int Result = -1;
|
| | |
|
| | | try
|
| | | {
|
| | | for (int i = 0; i < m_TotalData.Count; i++)
|
| | | {
|
| | | ArrayList TmpData = (ArrayList)m_TotalData[i];
|
| | |
|
| | | if (TmpData[2] == null)
|
| | | {
|
| | | Result = Convert.ToInt32(TmpData[1].ToString());
|
| | | break;
|
| | | }
|
| | | else
|
| | | {// 一對多(需作比對)
|
| | | long MinMeter = Convert.ToInt64(TmpData[3].ToString());
|
| | | long MaxMeter = Convert.ToInt64(TmpData[2].ToString());
|
| | | long CustMeter = Convert.ToInt64(m_Meter);
|
| | |
|
| | | if ((CustMeter > MinMeter) && (CustMeter < MaxMeter))
|
| | | {
|
| | | Result = Convert.ToInt32(TmpData[1].ToString());
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | Console.WriteLine(ex.Message);
|
| | | }
|
| | | return Result;
|
| | | }
|
| | |
|
| | | public int getDept_Code(int SC_Code, String Meter)
|
| | | {
|
| | | int Result = CCS.CCSMain.EOSCodelist.getKeyID(CCS.LocalVariable.Dept, DefaultDept);
|
| | | try
|
| | | {
|
| | | for (int i = 0; i < m_TotalData.Count; i++)
|
| | | {
|
| | | ArrayList TmpData = (ArrayList)m_TotalData[i];
|
| | | int Tmp_Dept = Convert.ToInt32(TmpData[0].ToString());
|
| | |
|
| | | if (Tmp_Dept == SC_Code)
|
| | | {
|
| | | // 一對一(無最大最小電號限制)
|
| | | if (TmpData[2] == null)
|
| | | {
|
| | | Result = Convert.ToInt32(TmpData[1].ToString());
|
| | | break;
|
| | | }
|
| | | else
|
| | | {// 一對多(需作比對)
|
| | | long MinMeter = Convert.ToInt64(TmpData[3].ToString());
|
| | | long MaxMeter = Convert.ToInt64(TmpData[2].ToString());
|
| | | long CustMeter = Convert.ToInt64(Meter);
|
| | |
|
| | | if ((CustMeter > MinMeter) && (CustMeter < MaxMeter))
|
| | | {
|
| | | Result = Convert.ToInt32(TmpData[1].ToString());
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | Console.WriteLine(ex.Message);
|
| | | }
|
| | |
|
| | | return Result;
|
| | | }
|
| | |
|
| | | private void Initial(OracleConnection _ConnectionTPC,OracleTransaction _Trx)
|
| | | {
|
| | | String SqlStmt;
|
| | | m_TotalData = new ArrayList();
|
| | |
|
| | | SqlStmt = "SELECT SC_CODE,DEPT_CODE,MAX_METER,MIN_METER FROM CCS.DEPT_CONTRAST";
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC,_Trx);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | |
|
| | | try
|
| | | {
|
| | |
|
| | | while (reader.Read())
|
| | | {
|
| | | ArrayList Record = new ArrayList();
|
| | | int SC_Code = Convert.ToInt32(reader["SC_CODE"].ToString());
|
| | | Record.Add(SC_Code);
|
| | | Record.Add(Convert.ToInt32(reader["Dept_Code"].ToString()));
|
| | | Record.Add(reader["Max_Meter"].ToString());
|
| | | Record.Add(reader["Min_Meter"].ToString());
|
| | |
|
| | | m_TotalData.Add(Record);
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | { |
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
New file |
| | |
| | | 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.Collections;
|
| | | using System.Data.OracleClient;
|
| | |
|
| | | namespace CCSTrace.CCS.Object
|
| | | {
|
| | | public class EOSCodelist
|
| | | {
|
| | | private Hashtable m_TotalData = new Hashtable();
|
| | | private int KeyID = 1;
|
| | | private int Item = 2;
|
| | | private int Content = 3;
|
| | |
|
| | | public EOSCodelist(OracleConnection _Connection)
|
| | | {
|
| | | String SqlStmt;
|
| | | int IndexID;
|
| | | ArrayList m_Data = new ArrayList();
|
| | | int Tmp = 0;
|
| | |
|
| | | SqlStmt = "SELECT INDEXID,KEYID,ITEM,CONTENT FROM EOS.CODELIST ORDER BY INDEXID,KEYID";
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _Connection);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | |
|
| | | try
|
| | | {
|
| | |
|
| | | while (reader.Read())
|
| | | {
|
| | | ArrayList m_Record = new ArrayList();
|
| | | IndexID = Convert.ToInt32(reader["INDEXID"].ToString());
|
| | | m_Record.Add(IndexID);
|
| | | m_Record.Add(Convert.ToInt32(reader["KEYID"].ToString()));
|
| | | m_Record.Add(reader["ITEM"].ToString());
|
| | | m_Record.Add(reader["CONTENT"].ToString());
|
| | |
|
| | | if (Tmp == IndexID)
|
| | | m_Data.Add(m_Record);
|
| | | else
|
| | | {
|
| | | m_TotalData.Add(Tmp.ToString(), m_Data);
|
| | | Tmp = IndexID;
|
| | | m_Data = new ArrayList();
|
| | | m_Data.Add(m_Record);
|
| | | }
|
| | | }
|
| | | m_TotalData.Add(Tmp.ToString(), m_Data);
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine("Error on Initial EOSCodelist: " + e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | { |
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | | }
|
| | |
|
| | | public ArrayList getAllContent(int m_IndexID)
|
| | | {
|
| | | return (ArrayList)m_TotalData[m_IndexID.ToString()];
|
| | | }
|
| | |
|
| | | public String getContent(int m_IndexID, int m_KeyID)
|
| | | {
|
| | | ArrayList m_Tmp = (ArrayList)m_TotalData[m_IndexID.ToString()];
|
| | | String m_Result = "";
|
| | |
|
| | | for (int i = 0; i < m_Tmp.Count; i++)
|
| | | {
|
| | | if (Convert.ToInt32(((ArrayList)m_Tmp[i])[KeyID].ToString()) == m_KeyID)
|
| | | {
|
| | | m_Result = ((ArrayList)m_Tmp[i])[Content].ToString();
|
| | | break;
|
| | | }
|
| | | }
|
| | | return m_Result;
|
| | | }
|
| | |
|
| | | public String getContent(int m_IndexID, String m_Item)
|
| | | {
|
| | | ArrayList m_Tmp = (ArrayList)m_TotalData[m_IndexID.ToString()];
|
| | | String m_Result = "";
|
| | |
|
| | | for (int i = 0; i < m_Tmp.Count; i++)
|
| | | {
|
| | | if (((ArrayList)m_Tmp[i])[Item].ToString().Equals(m_Item))
|
| | | {
|
| | | m_Result = ((ArrayList)m_Tmp[i])[Content].ToString();
|
| | | break;
|
| | | }
|
| | | }
|
| | | return m_Result;
|
| | | }
|
| | |
|
| | | public int getKeyID(int m_IndexID, String m_Content)
|
| | | {
|
| | | ArrayList m_Tmp = (ArrayList)m_TotalData[m_IndexID.ToString()];
|
| | | int m_Result = 0;
|
| | |
|
| | | for (int i = 0; i < m_Tmp.Count; i++)
|
| | | {
|
| | | if (((ArrayList)m_Tmp[i])[Content].ToString().Equals(m_Content))
|
| | | {
|
| | | m_Result = Convert.ToInt32(((ArrayList)m_Tmp[i])[1].ToString());
|
| | | break;
|
| | | }
|
| | | }
|
| | | return m_Result;
|
| | | }
|
| | |
|
| | | public int getContentNumber(int m_IndexID)
|
| | | {
|
| | | return ((ArrayList)m_TotalData[m_IndexID]).Count;
|
| | | }
|
| | | }
|
| | | }
|
New file |
| | |
| | | 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 EventQuery
|
| | | {
|
| | | private String CCSID;
|
| | | private String Meter;
|
| | | private int CaseStatus;
|
| | | private String ChangeTime;
|
| | | private String HandlingSummary;
|
| | | private String AssumedTime;
|
| | | private String AssumedTime_Nth;
|
| | | private int DelayTimes = 0;
|
| | | private String Reason;
|
| | | private String EventLocation = "";
|
| | | //private CCS.Function.TransferDate convert = new CCS.Function.TransferDate();
|
| | |
|
| | | public EventQuery()
|
| | | {
|
| | | }
|
| | |
|
| | | public void setCCSID(String m_CCSID)
|
| | | {
|
| | | this.CCSID = m_CCSID;
|
| | | }
|
| | |
|
| | | public String getCCSID()
|
| | | {
|
| | | return this.CCSID;
|
| | | }
|
| | |
|
| | | public void setMeter(String m_Meter)
|
| | | {
|
| | | this.Meter = m_Meter;
|
| | | }
|
| | |
|
| | | public String getMeter()
|
| | | {
|
| | | return this.Meter;
|
| | | }
|
| | |
|
| | | /**
|
| | | * @return Returns the eventLocation.
|
| | | */
|
| | | public String getEventLocation()
|
| | | {
|
| | | return EventLocation;
|
| | | }
|
| | |
|
| | | /**
|
| | | * @param m_eventLocation The eventLocation to set.
|
| | | */
|
| | | public void setEventLocation(String m_eventLocation)
|
| | | {
|
| | | EventLocation = m_eventLocation;
|
| | | }
|
| | |
|
| | | public void setCaseStatus(int m_CaseStatus)
|
| | | {
|
| | | this.CaseStatus = m_CaseStatus;
|
| | | }
|
| | |
|
| | | public void setChangeTime(String m_ChangeTime)
|
| | | {
|
| | | this.ChangeTime = m_ChangeTime;
|
| | | }
|
| | |
|
| | | public String getChangeTime()
|
| | | {
|
| | | return this.ChangeTime;
|
| | | }
|
| | |
|
| | | public void setHandlingSummary(String m_HandlingSummary)
|
| | | {
|
| | | this.HandlingSummary = m_HandlingSummary;
|
| | | }
|
| | |
|
| | | public String getHandlingSummary()
|
| | | {
|
| | | return this.HandlingSummary;
|
| | | }
|
| | |
|
| | | public void setAssumedTime(String m_AssumedTime)
|
| | | {
|
| | | this.AssumedTime = m_AssumedTime;
|
| | | }
|
| | |
|
| | | public String getAssumedTime()
|
| | | {
|
| | | return this.AssumedTime;
|
| | | }
|
| | |
|
| | | public void setAssumedTime_Nth(String m_AssumedTime_Nth)
|
| | | {
|
| | | this.AssumedTime_Nth = m_AssumedTime_Nth;
|
| | | }
|
| | |
|
| | | public String getAssumedTime_Nth()
|
| | | {
|
| | | return this.AssumedTime_Nth;
|
| | | }
|
| | |
|
| | | public void setDelayTimes(int m_DelayTimes)
|
| | | {
|
| | | this.DelayTimes = m_DelayTimes;
|
| | | }
|
| | |
|
| | | public int getDelayTimes()
|
| | | {
|
| | | return this.DelayTimes;
|
| | | }
|
| | |
|
| | | public void setReason(String m_Reason)
|
| | | {
|
| | | this.Reason = m_Reason;
|
| | | }
|
| | |
|
| | | public String getReason()
|
| | | {
|
| | | return this.Reason;
|
| | | }
|
| | |
|
| | | public bool Insert(RecordLog _PLog, OracleConnection _Conn, OracleTransaction _Transaction)
|
| | | {
|
| | | String SqlStmt;
|
| | |
|
| | | if (!Check())
|
| | | {
|
| | | return false;
|
| | | }
|
| | |
|
| | | if (Meter == null)
|
| | | {
|
| | | SqlStmt = "INSERT INTO CCS.EVENTQUERY (CCSID,CASESTATUS,CHANGETIME,ASSUMEDTIME,ASSUMEDTIME_NTH,DELAYTIMES,REASON,INPUTTIME) values(" + "'" + CCSID
|
| | | + "'," + CaseStatus + ",to_date('" + ChangeTime + "','yyyy/mm/dd hh24:mi:ss'),to_date('"
|
| | | + AssumedTime + "','yyyy/mm/dd hh24:mi:ss'),to_date('" + AssumedTime_Nth + "','yyyy/mm/dd hh24:mi:ss')," + DelayTimes + ",'" + Reason + "',SYSDATE)";
|
| | | }
|
| | | else
|
| | | {
|
| | | SqlStmt = "INSERT INTO CCS.EVENTQUERY (CCSID,METER,CASESTATUS,CHANGETIME,ASSUMEDTIME,ASSUMEDTIME_NTH,DELAYTIMES,REASON,INPUTTIME) values(" + "'"
|
| | | + CCSID + "','" + Meter + "'," + CaseStatus + ",to_date('" + ChangeTime + "','yyyy/mm/dd hh24:mi:ss'),to_date('" + AssumedTime + "','yyyy/mm/dd hh24:mi:ss'),to_date('"
|
| | | + AssumedTime_Nth + "','yyyy/mm/dd hh24:mi:ss')," + DelayTimes + ",'" + Reason + "',SYSDATE)";
|
| | |
|
| | | }
|
| | |
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _Conn, _Transaction);
|
| | |
|
| | | try
|
| | | {
|
| | | if (Command.ExecuteNonQuery() > 0)
|
| | | return true;
|
| | | else
|
| | | return false;
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | return false;
|
| | | }
|
| | | finally
|
| | | {
|
| | | Command.Dispose();
|
| | | }
|
| | | }
|
| | |
|
| | | public bool Insert(SEventLog _PLog, OracleConnection _Conn, OracleTransaction _Transaction)
|
| | | {
|
| | | String SqlStmt;
|
| | |
|
| | | if (!Check())
|
| | | {
|
| | | return false;
|
| | | }
|
| | |
|
| | | if (Meter == null)
|
| | | {
|
| | | SqlStmt = "INSERT INTO CCS.EVENTQUERY (CCSID,CASESTATUS,CHANGETIME,ASSUMEDTIME,ASSUMEDTIME_NTH,DELAYTIMES,REASON,INPUTTIME) values(" + "'" + CCSID
|
| | | + "'," + CaseStatus + ",to_date('" + ChangeTime + "','yyyy/mm/dd hh24:mi:ss'),to_date('"
|
| | | + AssumedTime + "','yyyy/mm/dd hh24:mi:ss'),to_date('" + AssumedTime_Nth + "','yyyy/mm/dd hh24:mi:ss')," + DelayTimes + ",'" + Reason + "',SYSDATE)";
|
| | | }
|
| | | else
|
| | | {
|
| | | SqlStmt = "INSERT INTO CCS.EVENTQUERY (CCSID,METER,CASESTATUS,CHANGETIME,ASSUMEDTIME,ASSUMEDTIME_NTH,DELAYTIMES,REASON,INPUTTIME) values(" + "'"
|
| | | + CCSID + "','" + Meter + "'," + CaseStatus + ",to_date('" + ChangeTime + "','yyyy/mm/dd hh24:mi:ss'),to_date('" + AssumedTime + "','yyyy/mm/dd hh24:mi:ss'),to_date('"
|
| | | + AssumedTime_Nth + "','yyyy/mm/dd hh24:mi:ss')," + DelayTimes + ",'" + Reason + "',SYSDATE)";
|
| | | }
|
| | |
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _Conn, _Transaction);
|
| | |
|
| | | try
|
| | | {
|
| | | if (Command.ExecuteNonQuery() > 0)
|
| | | return true;
|
| | | else
|
| | | return false;
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | |
|
| | | if (LocalVariable.ShowError)
|
| | | _PLog.Error(e.StackTrace);
|
| | |
|
| | | throw e;
|
| | | }
|
| | | finally
|
| | | {
|
| | | Command.Dispose();
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | public bool Update(RecordLog _PLog, OracleConnection _Conn, OracleTransaction _Transaction)
|
| | | {
|
| | | if (!Check())
|
| | | {
|
| | | return false;
|
| | | }
|
| | |
|
| | | String SqlStmt = "UPDATE CCS.EVENTQUERY SET CASESTATUS=" + this.CaseStatus + ",CHANGETIME=to_date('"
|
| | | + this.ChangeTime + "','yyyy/mm/dd hh24:mi:ss'),ASSUMEDTIME=to_date('"
|
| | | + this.AssumedTime + "','yyyy/mm/dd hh24:mi:ss'),ASSUMEDTIME_NTH=to_date('"
|
| | | + this.AssumedTime_Nth + "','yyyy/mm/dd hh24:mi:ss'),DELAYTIMES=" + this.DelayTimes + ",REASON='"
|
| | | + this.Reason + "',EVENTLOCATION ='" + this.EventLocation + "' WHERE CCSID='" + this.CCSID + "'";
|
| | |
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _Conn, _Transaction);
|
| | |
|
| | | try
|
| | | {
|
| | | if (Command.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | _PLog.Error("更新CCS.EVENTQUERY資料失敗.");
|
| | | return false;
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | return false;
|
| | | }
|
| | | finally
|
| | | {
|
| | | Command.Dispose();
|
| | | }
|
| | |
|
| | | return true;
|
| | | }
|
| | |
|
| | | public bool UpdateCaseStatus(SEventLog _PLog, OracleConnection _Conn, OracleTransaction _Transaction)
|
| | | {
|
| | | String SqlStmt = "UPDATE CCS.EVENTQUERY SET CASESTATUS = " + CaseStatus + " WHERE CCSID = '" + CCSID + "'";
|
| | |
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _Conn, _Transaction);
|
| | |
|
| | | try
|
| | | {
|
| | | if (Command.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | _PLog.Error("更新CCS.EVENTQUERY的CASESTATUS失敗.");
|
| | | return false;
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | |
|
| | | if (LocalVariable.ShowError)
|
| | | _PLog.Error(e.StackTrace);
|
| | |
|
| | | throw e;
|
| | | }
|
| | | finally
|
| | | {
|
| | | Command.Dispose();
|
| | | }
|
| | |
|
| | | return true;
|
| | | }
|
| | |
|
| | | // Not Null Check
|
| | | private bool Check()
|
| | | {
|
| | | if (CCSID == null)
|
| | | {
|
| | | return false;
|
| | | }
|
| | |
|
| | | if (CaseStatus == 0)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | Reason = (Reason == null ? "" : Reason);
|
| | | return true;
|
| | | }
|
| | |
|
| | |
|
| | | }
|
| | | }
|
New file |
| | |
| | | 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;
|
| | |
|
| | | namespace CCSTrace.CCS.Object
|
| | | {
|
| | | public class EventRecord
|
| | | {
|
| | | private int CaseID;
|
| | | private String Name = "";
|
| | | private String Meter = "";
|
| | | private String Tel = "";
|
| | | private String Addr = "";
|
| | | private String Brief = "";
|
| | | private String Log = ""; // default
|
| | | private int Dept = 0; // default
|
| | | private String AcceptNum;
|
| | | private String AcceptDate;
|
| | | private int Fsc = 0;
|
| | | private int Ufid = 0;
|
| | | private int FdrID = 0;
|
| | | private int Trace_Finish = 0;
|
| | | private int ParentID = 0;
|
| | | private int ImportCase;
|
| | | private String Note = "";
|
| | | private int isReCall;
|
| | | private String ReCallTel = "";
|
| | | private String ReCallName = "";
|
| | | private bool despatched = false;// 專案案件升級為母案件時,判斷原先案件是否已派工
|
| | | private int Level = 0;
|
| | | private int TmpCaseID = 0;
|
| | | private String tpclid = "";
|
| | | //private CCS.Function.TransferDate Convert = new CCS.Function.TransferDate();
|
| | | private CCS.Object.LocateEquipment m_Equipment;
|
| | |
|
| | | public EventRecord(int m_CaseID,System.Data.OracleClient.OracleConnection _Conn,System.Data.OracleClient.OracleTransaction _Trx)
|
| | | {
|
| | | this.CaseID = m_CaseID;
|
| | | this.m_Equipment = new CCS.Object.LocateEquipment(CaseID, false,_Conn,_Trx);
|
| | | }
|
| | |
|
| | | public CCS.Object.LocateEquipment getLocateEquipment()
|
| | | {
|
| | | return this.m_Equipment;
|
| | | }
|
| | |
|
| | | public int getCaseID()
|
| | | {
|
| | | return this.CaseID;
|
| | | }
|
| | |
|
| | | public String getName()
|
| | | {
|
| | | return this.Name;
|
| | | }
|
| | |
|
| | | public void setName(String m_Name)
|
| | | {
|
| | | this.Name = m_Name;
|
| | | }
|
| | |
|
| | | public String getMeter()
|
| | | {
|
| | | return this.Meter;
|
| | | }
|
| | |
|
| | | public void setMeter(String m_Meter)
|
| | | {
|
| | | this.Meter = m_Meter;
|
| | | }
|
| | |
|
| | | public String getTel()
|
| | | {
|
| | | return this.Tel;
|
| | | }
|
| | |
|
| | | public void setTel(String m_Tel)
|
| | | {
|
| | | this.Tel = m_Tel;
|
| | | }
|
| | |
|
| | | public String getAddr()
|
| | | {
|
| | | return this.Addr;
|
| | | }
|
| | |
|
| | | public void setAddr(String m_Addr)
|
| | | {
|
| | | this.Addr = m_Addr;
|
| | | }
|
| | |
|
| | | public String getBrief()
|
| | | {
|
| | | return this.Brief;
|
| | | }
|
| | |
|
| | | public void setBrief(String m_Brief)
|
| | | {
|
| | | this.Brief = m_Brief;
|
| | | }
|
| | |
|
| | | public String getLog()
|
| | | {
|
| | | return this.Log;
|
| | | }
|
| | |
|
| | | public void setLog(String m_Log)
|
| | | {
|
| | | this.Log = m_Log;
|
| | | }
|
| | |
|
| | | public int getDept()
|
| | | {
|
| | | return this.Dept;
|
| | | }
|
| | |
|
| | | public void setDept(int m_Dept)
|
| | | {
|
| | | this.Dept = m_Dept;
|
| | | }
|
| | |
|
| | | public String getAcceptNum()
|
| | | {
|
| | | return this.AcceptNum;
|
| | | }
|
| | |
|
| | | public void setAcceptNum(String m_AcceptNum)
|
| | | {
|
| | | this.AcceptNum = m_AcceptNum;
|
| | | }
|
| | |
|
| | | public String getAcceptDate()
|
| | | {
|
| | | return this.AcceptDate;
|
| | | }
|
| | |
|
| | | public void setAcceptDate(String m_AcceptDate)
|
| | | {
|
| | | this.AcceptDate = m_AcceptDate;
|
| | | }
|
| | |
|
| | | public int getTrace_Finish()
|
| | | {
|
| | | return this.Trace_Finish;
|
| | | }
|
| | |
|
| | | public void setFsc(int m_Fsc)
|
| | | {
|
| | | this.Fsc = m_Fsc;
|
| | | }
|
| | |
|
| | | public int getFsc()
|
| | | {
|
| | | return this.Fsc;
|
| | | }
|
| | |
|
| | | public void setUfid(int m_Ufid)
|
| | | {
|
| | | this.Ufid = m_Ufid;
|
| | | }
|
| | |
|
| | | public int getUfid()
|
| | | {
|
| | | return this.Ufid;
|
| | | }
|
| | |
|
| | | public void setFdrID(int m_FdrID)
|
| | | {
|
| | | this.FdrID = m_FdrID;
|
| | | }
|
| | |
|
| | | public int getFdrID()
|
| | | {
|
| | | return this.FdrID;
|
| | | }
|
| | |
|
| | | public void setTrace_Finish(int m_Trace_Finish)
|
| | | {
|
| | | this.Trace_Finish = m_Trace_Finish;
|
| | | }
|
| | |
|
| | | public void setParentID(int m_ParentID)
|
| | | {
|
| | | this.ParentID = m_ParentID;
|
| | | }
|
| | |
|
| | | public int getParentID()
|
| | | {
|
| | | return this.ParentID;
|
| | | }
|
| | |
|
| | | public void setImportCase(int m_ImportCase)
|
| | | {
|
| | | this.ImportCase = m_ImportCase;
|
| | | }
|
| | |
|
| | | public int getImportCase()
|
| | | {
|
| | | return this.ImportCase;
|
| | | }
|
| | |
|
| | | public void setNote(String m_Note)
|
| | | {
|
| | | this.Note = m_Note;
|
| | | }
|
| | |
|
| | | public String getNote()
|
| | | {
|
| | | return this.Note;
|
| | | }
|
| | |
|
| | | public void setisReCall(int m_isReCall)
|
| | | {
|
| | | this.isReCall = m_isReCall;
|
| | | }
|
| | |
|
| | | public int getisReCall()
|
| | | {
|
| | | return this.isReCall;
|
| | | }
|
| | |
|
| | | public void setReCallTel(String m_ReCallTel)
|
| | | {
|
| | | this.ReCallTel = m_ReCallTel;
|
| | | }
|
| | |
|
| | | public String getReCallTel()
|
| | | {
|
| | | return this.ReCallTel;
|
| | | }
|
| | |
|
| | | public void setReCallName(String m_ReCallName)
|
| | | {
|
| | | this.ReCallName = m_ReCallName;
|
| | | }
|
| | |
|
| | | public String getReCallName()
|
| | | {
|
| | | return this.ReCallName;
|
| | | }
|
| | |
|
| | | public void setLevel(int m_Level)
|
| | | {
|
| | | this.Level = m_Level;
|
| | | }
|
| | |
|
| | | public int getLevel()
|
| | | {
|
| | | return this.Level;
|
| | | }
|
| | |
|
| | | public int getTmpCaseID()
|
| | | {
|
| | | return this.TmpCaseID;
|
| | | }
|
| | |
|
| | | public void setTmpCaseID(int CaseID)
|
| | | {
|
| | | this.TmpCaseID = CaseID;
|
| | | }
|
| | |
|
| | | public void setDespatched(bool m_Despatched)
|
| | | {
|
| | | this.despatched = m_Despatched;
|
| | | }
|
| | |
|
| | | public bool isDespatched()
|
| | | {
|
| | | return this.despatched;
|
| | | }
|
| | |
|
| | | public String getSqlStmt()
|
| | | {
|
| | | String SqlStmt;
|
| | |
|
| | | SqlStmt = "insert into eos.eventrecord values (" + getCaseID() + ",'" + getName() + "','" + getMeter() + "','" + getTel() + "','" + getAddr()
|
| | | + "','" + getBrief() + "'," + getDept() + ",'" + getLog() + "','" + getAcceptNum() + "',to_date('"
|
| | | + getAcceptDate() + "','yyyy/mm/dd hh24:mi:ss')," + getFsc() + "," + getUfid()
|
| | | + "," + getFdrID() + "," + getTrace_Finish() + "," + getImportCase() + ",'" + getNote() + "'," + getisReCall() + ",'"
|
| | | + getReCallTel() + "','" + getReCallName() + "'," + getLevel() + ")";
|
| | |
|
| | | return SqlStmt;
|
| | | }
|
| | |
|
| | | //public String getUpdateSqlStmt()
|
| | | //{
|
| | | // String SqlStmt;
|
| | |
|
| | | // SqlStmt = "UPDATE EOS.EVENTRECORD SET CUSTOMERADDR = '" + getAddr() + "',EVENTBRIEF = '" + getBrief() + "',IMPORTCASE = " + getImportCase()
|
| | | // + ",NOTE = '" + getNote() + "',ISRECALL = " + getisReCall() + ",RECALLTEL = '" + getReCallTel() + "',RECALLNAME = '"
|
| | | // + getReCallName() + "',CASELEVEL = " + getLevel() + ",DEPT = " + getDept() + " WHERE CASEID = " + getCaseID();
|
| | | // return SqlStmt;
|
| | | //}
|
| | |
|
| | | public String getTpclid()
|
| | | {
|
| | | return tpclid;
|
| | | }
|
| | |
|
| | | public void setTpclid(String m_tpclid)
|
| | | {
|
| | | tpclid = m_tpclid;
|
| | | }
|
| | | }
|
| | | }
|
New file |
| | |
| | | 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 LocateEquipment
|
| | | {
|
| | | private int CaseID = 0;
|
| | | private int DSUfid = -1;
|
| | | private int Fsc = 0;
|
| | | private int Ufid = 0;
|
| | | private String FDR = "";
|
| | | private String TPCLID = "";
|
| | |
|
| | | public LocateEquipment(int m_CaseID, bool hasData,OracleConnection _Conn, OracleTransaction _Transaction)
|
| | | {
|
| | | String SqlStmt;
|
| | | OracleCommand Command = null;
|
| | | OracleDataReader reader = null;
|
| | |
|
| | | this.setCaseID(m_CaseID);
|
| | |
|
| | | try
|
| | | {
|
| | | if (hasData)
|
| | | {
|
| | | SqlStmt = "SELECT DSUFID,FSC,UFID,FDR,TPCLID FROM EOS.EVENTRECORD_EX WHERE CASEID = " + m_CaseID;
|
| | |
|
| | | Command = new OracleCommand(SqlStmt, _Conn, _Transaction);
|
| | | reader = Command.ExecuteReader();
|
| | |
|
| | | if (reader.Read())
|
| | | {
|
| | | this.setDSUFID(Convert.ToInt32(reader["DSUFID"].ToString()));
|
| | | this.setFSC(Convert.ToInt32(reader["FSC"].ToString()));
|
| | | this.setUFID(Convert.ToInt32(reader["UFID"].ToString()));
|
| | | this.setFDR(reader["FDR"].ToString());
|
| | | this.setTPCLID(reader["TPCLID"].ToString());
|
| | | }
|
| | |
|
| | |
|
| | | }
|
| | | else
|
| | | {
|
| | | SqlStmt = "SELECT UFID FROM EOS.DISASTER_EX WHERE ISDISASTER = " + CCS.LocalVariable.isDisaster;
|
| | |
|
| | | Command = new OracleCommand(SqlStmt, _Conn, _Transaction);
|
| | | reader = Command.ExecuteReader();
|
| | |
|
| | | if (reader.Read())
|
| | | this.setDSUFID(Convert.ToInt32(reader["UFID"].ToString()));
|
| | | }
|
| | |
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | { |
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | | }
|
| | |
|
| | | public int getCaseID()
|
| | | {
|
| | | return this.CaseID;
|
| | | }
|
| | |
|
| | | public void setCaseID(int m_CaseID)
|
| | | {
|
| | | this.CaseID = m_CaseID;
|
| | | }
|
| | |
|
| | | public int getDSUFID()
|
| | | {
|
| | | return this.DSUfid;
|
| | | }
|
| | |
|
| | | public void setDSUFID(int m_DSUfid)
|
| | | {
|
| | | this.DSUfid = m_DSUfid;
|
| | | }
|
| | |
|
| | | public int getFSC()
|
| | | {
|
| | | return this.Fsc;
|
| | | }
|
| | |
|
| | | public void setFSC(int m_FSC)
|
| | | {
|
| | | this.Fsc = m_FSC;
|
| | | }
|
| | |
|
| | | public int getUFID()
|
| | | {
|
| | | return this.Ufid;
|
| | | }
|
| | |
|
| | | public void setUFID(int m_UFID)
|
| | | {
|
| | | this.Ufid = m_UFID;
|
| | | }
|
| | |
|
| | | public String getFDR()
|
| | | {
|
| | | return this.FDR;
|
| | | }
|
| | |
|
| | | public void setFDR(String m_FDR)
|
| | | {
|
| | | this.FDR = m_FDR;
|
| | | }
|
| | |
|
| | | public String getTPCLID()
|
| | | {
|
| | | return this.TPCLID;
|
| | | }
|
| | |
|
| | | public void setTPCLID(String m_TPCLID)
|
| | | {
|
| | | this.TPCLID = m_TPCLID;
|
| | | }
|
| | |
|
| | | public String getSqlStmt()
|
| | | {
|
| | | String SqlStmt;
|
| | |
|
| | | SqlStmt = "INSERT INTO EOS.EVENTRECORD_EX (CASEID,DSUFID,FSC,UFID,TPCLID,FDR) VALUES(" + getCaseID() + "," + getDSUFID() + "," + getFSC()
|
| | | + "," + getUFID() + ",'" + getTPCLID() + "','" + getFDR() + "')";
|
| | | return SqlStmt;
|
| | | }
|
| | |
|
| | | //public String getUpdateSqlStmt()
|
| | | //{
|
| | | // String SqlStmt;
|
| | |
|
| | | // SqlStmt = "UPDATE EOS.EVENTRECORD_EX SET DSUFID = " + getDSUFID() + ",FSC = " + getFSC() + ",UFID = " + getUFID() + ",TPCLID = '"
|
| | | // + getTPCLID() + "',FDR = '" + getFDR() + "' WHERE CASEID = " + getCaseID();
|
| | |
|
| | | // return SqlStmt;
|
| | | //}
|
| | | }
|
| | | }
|
New file |
| | |
| | | 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 NumberContrast
|
| | | {
|
| | | private String CCSID;
|
| | | private String AcceptNum;
|
| | | private int CaseID;
|
| | |
|
| | | public NumberContrast()
|
| | | {
|
| | | }
|
| | |
|
| | | public void setCCSID(String m_CCSID)
|
| | | {
|
| | | this.CCSID = m_CCSID;
|
| | | }
|
| | |
|
| | | public String getCCSID()
|
| | | {
|
| | | return this.CCSID;
|
| | | }
|
| | |
|
| | | public void setAcceptNum(String m_AcceptNum)
|
| | | {
|
| | | this.AcceptNum = m_AcceptNum;
|
| | | }
|
| | |
|
| | | public String getAcceptNum()
|
| | | {
|
| | | return this.AcceptNum;
|
| | | }
|
| | |
|
| | | public void setCaseID(int m_CaseID)
|
| | | {
|
| | | this.CaseID = m_CaseID;
|
| | | }
|
| | |
|
| | | public int getCaseID()
|
| | | {
|
| | | return this.CaseID;
|
| | | }
|
| | |
|
| | | public bool Insert(OracleConnection _Conn,OracleTransaction _Transaction)
|
| | | {
|
| | | String SqlStmt;
|
| | |
|
| | | if (!Check())
|
| | | {
|
| | | return false;
|
| | | }
|
| | |
|
| | | SqlStmt = "INSERT INTO CCS.NUM_CONTRAST (CCSID,ACCEPTNUM,CASEID) VALUES ('" + CCSID + "','" + AcceptNum + "'," + CaseID + ")";
|
| | |
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _Conn, _Transaction);
|
| | |
|
| | | if (Command.ExecuteNonQuery() > 0)
|
| | | {
|
| | | Command.Dispose();
|
| | | return true;
|
| | | }
|
| | |
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | public bool Update(OracleConnection _Conn,OracleTransaction _Transaction)
|
| | | {
|
| | | if (!Check())
|
| | | {
|
| | | return false;
|
| | | }
|
| | | String SqlStmt = "UPDATE CCS.NUM_CONTRAST SET ACCEPTNUM='" + this.AcceptNum + "',CASEID=" + this.CaseID + " WHERE CCSID='" + this.CCSID + "'";
|
| | |
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _Conn, _Transaction);
|
| | |
|
| | | if (Command.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | Command.Dispose();
|
| | | return false;
|
| | | }
|
| | |
|
| | | Command.Dispose();
|
| | | return true;
|
| | | }
|
| | |
|
| | | private bool Check()
|
| | | {
|
| | | if (this.CCSID == null)
|
| | | return false;
|
| | |
|
| | | if (this.AcceptNum == null)
|
| | | return false;
|
| | |
|
| | | if (CaseID == 0)
|
| | | return false;
|
| | |
|
| | | return true;
|
| | | }
|
| | | }
|
| | | }
|
New file |
| | |
| | | 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;
|
| | | using System.Text;
|
| | |
|
| | | namespace CCSTrace.CCS
|
| | | {
|
| | | public delegate void ThreadEndEventHandler(object sender, ThreadEndEvent e);
|
| | | |
| | | public class ProcessEvent |
| | | {
|
| | | public event ThreadEndEventHandler ThreadFinish;
|
| | |
|
| | | private CCS.Object.EventRecord m_EventRecord;
|
| | | private CCS.Object.CCSRecord m_CCSRecord;
|
| | | private RecordLog _PLog;
|
| | | private OracleConnection _ConnectionTPC;
|
| | | private OracleTransaction _Trx;
|
| | |
|
| | | public ProcessEvent(Object.CCSRecord _Record,OracleConnection _Conn)
|
| | | {
|
| | | m_CCSRecord = _Record;
|
| | | _ConnectionTPC = _Conn;
|
| | | _PLog = new RecordLog(CCS.LocalVariable.CCS_ListPath + _Record.getCCSID() + ".txt");
|
| | | }
|
| | |
|
| | | public void Run()
|
| | | {
|
| | | bool SendMail = false;
|
| | | |
| | | try
|
| | | {
|
| | | int FDRID = getFDRID(m_CCSRecord.getMeter());
|
| | |
|
| | | if (FDRID != 0) //有饋線代號資料的案件才需比對同饋線上有無案件正在處理
|
| | | {
|
| | | if (CCSMain.ProcessFDR.ContainsKey(FDRID.ToString()))
|
| | | {
|
| | | CCSMain.WaitingCases.Add(new String[] { m_CCSRecord.getCCSID(), FDRID.ToString() });
|
| | | return;
|
| | | }
|
| | | else
|
| | | CCSMain.ProcessFDR.Add(FDRID.ToString(), null); //將要處理的案件的饋線別加入處理中饋線集合
|
| | | }
|
| | |
|
| | | /* int TraceCount = this.getTraceCount(m_CCSRecord.getCCSID());
|
| | | bool TraceError = false; //追蹤次數超過3次,改為非A類不追蹤合併
|
| | |
|
| | | switch (TraceCount)
|
| | | {
|
| | | case 0:
|
| | | UpdateTraceCount(m_CCSRecord.getCCSID(),true);
|
| | | TraceError = false;
|
| | | break;
|
| | | case 2:
|
| | | UpdateTraceCount(m_CCSRecord.getCCSID(),false);
|
| | | TraceError = true;
|
| | | break;
|
| | | default:
|
| | | UpdateTraceCount(m_CCSRecord.getCCSID(),false);
|
| | | TraceError = false;
|
| | | break;
|
| | | }
|
| | | */
|
| | | if (this.initialEventRecord(m_CCSRecord.getCCSID()))
|
| | | {
|
| | | CCS.Function.Leach m_Leach = new CCS.Function.Leach(_ConnectionTPC, _Trx, _PLog); // 案件過濾與合併
|
| | | _PLog.Info("過濾案件...");
|
| | | int Return_Status = m_Leach.LeachCase(m_EventRecord);
|
| | |
|
| | | switch ( Return_Status )
|
| | | {
|
| | | case CCS.LocalVariable.Success:
|
| | | _PLog.Info("案件過濾完畢....");
|
| | | Process(CCS.LocalVariable.Success);
|
| | | break;
|
| | | case CCS.LocalVariable.NoMeter:
|
| | | _PLog.Info("案件過濾完畢,用戶無電號....");
|
| | | m_EventRecord.setTrace_Finish(CCS.LocalVariable.Trace_Finish);
|
| | | Process(CCS.LocalVariable.NoMeter);
|
| | | break;
|
| | | case CCS.LocalVariable.SameCustomer:
|
| | | _PLog.Info("相同用戶重複來電....");
|
| | | processSameCustomer(this.m_CCSRecord, this.m_EventRecord);
|
| | | break;
|
| | | case CCS.LocalVariable.NoSupplyElc:
|
| | | _PLog.Warn("該饋線未供電,無法作事故案件追蹤合併....");
|
| | | m_EventRecord.setTrace_Finish(CCS.LocalVariable.Trace_Finish);
|
| | | Process(CCS.LocalVariable.NoMeter);
|
| | | break;
|
| | | case CCS.LocalVariable.No_Sxfmr:
|
| | | _PLog.Warn("該案件無變壓器....");
|
| | | m_EventRecord.setTrace_Finish(CCS.LocalVariable.Trace_Finish);
|
| | | Process(CCS.LocalVariable.NoMeter);
|
| | | break;
|
| | | case CCS.LocalVariable.CaseTypeChanged:
|
| | | _PLog.Info("變更案件狀態....");
|
| | | Process(CCS.LocalVariable.CaseTypeChanged);
|
| | | break;
|
| | | case CCS.LocalVariable.Trace_Failure:
|
| | | _PLog.Error("故障追蹤錯誤,以一般無電號案件方式受理....");
|
| | | m_EventRecord.setTrace_Finish(CCS.LocalVariable.Trace_Finish);
|
| | | Process(CCS.LocalVariable.NoMeter);
|
| | | break;
|
| | | default:
|
| | | int TraceCount = this.getTraceCount(m_CCSRecord.getCCSID());
|
| | |
|
| | | if ( TraceCount < 2 )
|
| | | {
|
| | | if (_Trx.Connection.State.ToString().Equals("Open"))
|
| | | _Trx.Rollback();
|
| | |
|
| | | _Trx.Dispose();
|
| | |
|
| | | if (Return_Status == CCS.LocalVariable.CaseTransfer)
|
| | | _PLog.Error("案件已移轉,此事故案件暫不被受理....");
|
| | | else if (Return_Status == CCS.LocalVariable.Failure_By_DB)
|
| | | _PLog.Error("資料庫錯誤,此事故案件暫不被受理....");
|
| | | else if (Return_Status == CCS.LocalVariable.FDRLocked)
|
| | | _PLog.Error("饋線被鎖定,此事故案件暫不被受理....");
|
| | | else
|
| | | _PLog.Error("發生非預期錯誤,此事故案件暫不被受理....");
|
| | |
|
| | | if (TraceCount == 0)
|
| | | UpdateTraceCount(m_CCSRecord.getCCSID(), true);
|
| | | else
|
| | | UpdateTraceCount(m_CCSRecord.getCCSID(), false);
|
| | |
|
| | | }
|
| | | else
|
| | | {
|
| | | UpdateTraceCount(m_CCSRecord.getCCSID(), false);
|
| | | if (Return_Status == CCS.LocalVariable.Trace_Counts_3)
|
| | | m_EventRecord.setNote(m_EventRecord.getNote() + "(本案用戶供電資料追蹤失敗)");
|
| | |
|
| | | _PLog.Error("事故案件處理次數3次,仍無法正常處理,以一般無電號案件方式受理....");
|
| | | m_EventRecord.setTrace_Finish(CCS.LocalVariable.Trace_Finish);
|
| | | Process(CCS.LocalVariable.NoMeter);
|
| | | SendMail = true;
|
| | | }
|
| | | break;
|
| | | /* switch (TraceCount)
|
| | | {
|
| | | case 0:
|
| | | if (_Trx.Connection.State.ToString().Equals("Open"))
|
| | | _Trx.Rollback();
|
| | |
|
| | | _Trx.Dispose();
|
| | |
|
| | | if ( Return_Status == CCS.LocalVariable.CaseTransfer )
|
| | | _PLog.Error("案件已移轉,此事故案件不被受理....");
|
| | | else if ( Return_Status == CCS.LocalVariable.Failure_By_DB )
|
| | | _PLog.Error("資料庫錯誤,此事故案件不被受理....");
|
| | | else if ( Return_Status == CCS.LocalVariable.FDRLocked )
|
| | | _PLog.Error("饋線被鎖定,此事故案件不被受理....");
|
| | | else
|
| | | _PLog.Error("此事故案件不被受理....");
|
| | | |
| | |
|
| | | UpdateTraceCount(m_CCSRecord.getCCSID(), true);
|
| | | break;
|
| | | case 1:
|
| | | if (_Trx.Connection.State.ToString().Equals("Open"))
|
| | | _Trx.Rollback();
|
| | |
|
| | | _Trx.Dispose();
|
| | |
|
| | | UpdateTraceCount(m_CCSRecord.getCCSID(), false);
|
| | |
|
| | | break;
|
| | | default://追蹤次數超過3次,改為非A類不追蹤合併
|
| | | UpdateTraceCount(m_CCSRecord.getCCSID(), false);
|
| | | if (Return_Status == CCS.LocalVariable.Trace_Counts_3)
|
| | | m_EventRecord.setNote(m_EventRecord.getNote() + "(本案用戶供電資料追蹤失敗)");
|
| | |
|
| | | _PLog.Error("追蹤次數3次,無法追蹤到故障設備,以一般無電號案件方式受理....");
|
| | | m_EventRecord.setTrace_Finish(CCS.LocalVariable.Trace_Finish);
|
| | | Process(CCS.LocalVariable.NoMeter);
|
| | | SendMail = true;
|
| | | break;
|
| | | }
|
| | |
|
| | | break;
|
| | | case CCS.LocalVariable.CaseTransfer:
|
| | | if (_Trx.Connection.State.ToString().Equals("Open"))
|
| | | _Trx.Rollback();
|
| | |
|
| | | _Trx.Dispose();
|
| | | _PLog.Error("案件已移轉,此事故案件不被受理....");
|
| | | break;
|
| | | case CCS.LocalVariable.FDRLocked:
|
| | | if (_Trx.Connection.State.ToString().Equals("Open"))
|
| | | _Trx.Rollback();
|
| | |
|
| | | _Trx.Dispose();
|
| | | _PLog.Error("饋線被鎖定,此事故案件不被受理....");
|
| | | break;
|
| | | case CCS.LocalVariable.Failure_By_DB:
|
| | | if (_Trx.Connection.State.ToString().Equals("Open"))
|
| | | _Trx.Rollback();
|
| | |
|
| | | _Trx.Dispose();
|
| | | _PLog.Error("資料庫錯誤,此事故案件不被受理....");
|
| | | break;
|
| | | default:
|
| | | if (_Trx.Connection.State.ToString().Equals("Open"))
|
| | | _Trx.Rollback();
|
| | |
|
| | | _Trx.Dispose();
|
| | | _PLog.Error("此事故案件不被受理....");
|
| | | break;
|
| | | */
|
| | | }
|
| | | }
|
| | |
|
| | | if ( FDRID != 0 )
|
| | | CCSMain.ProcessFDR.Remove(FDRID.ToString());//將處理完的案件的饋線別從處理中饋線集合中移除
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine("Error = " + e.Message + ". CCSID = " + m_CCSRecord.getCCSID());
|
| | | _PLog.Error("Error = " + e.Message + ". CCSID = " + m_CCSRecord.getCCSID());
|
| | |
|
| | | if (_Trx != null)
|
| | | {
|
| | | if (_Trx.Connection.State.ToString().Equals("Open"))
|
| | | _Trx.Rollback();
|
| | |
|
| | | _Trx.Dispose();
|
| | | }
|
| | |
|
| | | if ( m_EventRecord!= null && m_EventRecord.getFdrID() != 0)
|
| | | CCSMain.ProcessFDR.Remove(m_EventRecord.getFdrID().ToString());//將處理完的案件的饋線別從處理中饋線集合中移除
|
| | | //throw e;
|
| | | }
|
| | | finally
|
| | | {
|
| | | _PLog.Close();
|
| | | CCSMain.ProcessCases.Remove(m_CCSRecord.getCCSID());
|
| | | this.OnThreadFinish(new ThreadEndEvent(_ConnectionTPC));
|
| | | }
|
| | |
|
| | | if ( SendMail )
|
| | | new CCS.Function.MailService(_ConnectionTPC).SendMail(m_CCSRecord.getCCSID());
|
| | |
|
| | | }
|
| | |
|
| | | private void Process(int Kind)
|
| | | {
|
| | | CCS.FinishEvent FinishEvent = new CCS.FinishEvent();
|
| | |
|
| | | try
|
| | | {
|
| | | if (FinishEvent.Finish(Kind, m_EventRecord, _ConnectionTPC, _Trx, _PLog))
|
| | | {
|
| | | _PLog.Info("OMS資料更新成功!");
|
| | | if (UpdateCCSData(m_EventRecord, m_CCSRecord, CCS.LocalVariable.WaitForDespatch))
|
| | | {
|
| | | _PLog.Info("CCS資料更新成功!");
|
| | | }
|
| | | else
|
| | | {
|
| | | if (_Trx.Connection.State.ToString().Equals("Open"))
|
| | | _Trx.Rollback();
|
| | |
|
| | | _Trx.Dispose();
|
| | | _PLog.Error("CCS資料更新程序發生錯誤!");
|
| | | return;
|
| | |
|
| | | }
|
| | | |
| | | // 須等全部動作都正確做完才可作commit的動作
|
| | | _Trx.Commit();
|
| | | _Trx.Dispose(); ;
|
| | | CCS.Object.AlarmData alarmClient = new CCS.Object.AlarmData(_ConnectionTPC, _Trx, _PLog);
|
| | | alarmClient.alarm(m_EventRecord.getAcceptNum(), m_EventRecord.getDept());
|
| | | }
|
| | | else
|
| | | {
|
| | | // 有錯誤需要RollBack
|
| | | if (_Trx.Connection.State.ToString().Equals("Open"))
|
| | | _Trx.Rollback();
|
| | |
|
| | | _Trx.Dispose(); ;
|
| | | _PLog.Error("OMS資料更新程序發生錯誤!");
|
| | | }
|
| | | _PLog.Info("CCS 案件受理程序結束.");
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | throw e;
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | protected virtual void OnThreadFinish(ThreadEndEvent e)
|
| | | {
|
| | | if (ThreadFinish != null)
|
| | | {
|
| | | ThreadFinish(this, e);
|
| | | }
|
| | | }
|
| | |
|
| | | private bool UpdateCCSData(CCS.Object.EventRecord m_Record, CCS.Object.CCSRecord m_CCSRecord, int CaseStatus)
|
| | | {
|
| | | _PLog.Info("進行CCS資料更新程序...");
|
| | | CCS.Object.EventQuery EventQuery = new CCS.Object.EventQuery();
|
| | | int Status = CaseStatus;
|
| | | // 設定CCSID
|
| | | EventQuery.setCCSID(m_CCSRecord.getCCSID());
|
| | | // 設定受理時間
|
| | | EventQuery.setChangeTime(m_CCSRecord.getAcceptTime());
|
| | | // 設定用戶電號
|
| | | if (m_CCSRecord.getMeter() != null)
|
| | | {
|
| | | EventQuery.setMeter(m_CCSRecord.getMeter());
|
| | | }
|
| | | // 如果該案件為子案件,需找出母案件的casestatus來insert eos.eventquery
|
| | | // 若母案件已派工,需一併紀錄預計復電時間等資訊
|
| | | if (m_Record.getParentID() != 0)
|
| | | {
|
| | | Status = this.getRealCaseStatus(m_Record.getParentID()) == CCS.LocalVariable.WaitForSponsor ? CCS.LocalVariable.EventDespatched
|
| | | : CCS.LocalVariable.WaitForDespatch;
|
| | | if (Status == CCS.LocalVariable.EventDespatched)
|
| | | {
|
| | | setDespatchInfo(m_Record.getParentID(), EventQuery);
|
| | | }
|
| | | }
|
| | | // 若此案件為專案案件升級為母案件,則必須判斷原先案件是否已經派工
|
| | | if ((m_CCSRecord.getImportCase() == CCS.LocalVariable.isImportCase) && (m_Record.isDespatched()))
|
| | | {
|
| | | Status = CCS.LocalVariable.EventDespatched;
|
| | | setDespatchInfo(m_Record.getCaseID(), EventQuery);
|
| | | }
|
| | | EventQuery.setCaseStatus(Status);
|
| | | // 更新CCS.EventQuery
|
| | | if (!EventQuery.Update(_PLog,_ConnectionTPC,_Trx))
|
| | | {
|
| | | _PLog.Error("更新ccs.eventquery失敗!");
|
| | | return false;
|
| | | }
|
| | | else
|
| | | {
|
| | | _PLog.Info("更新ccs.eventquery成功!");
|
| | | CCS.Object.NumberContrast NumberContrast = new CCS.Object.NumberContrast();
|
| | | NumberContrast.setAcceptNum(m_Record.getAcceptNum());
|
| | | NumberContrast.setCaseID(m_Record.getCaseID());
|
| | | NumberContrast.setCCSID(m_CCSRecord.getCCSID());
|
| | | // 更新CCS.Num_Contrast
|
| | | if (!NumberContrast.Update(_ConnectionTPC,_Trx))
|
| | | {
|
| | | _PLog.Error("更新ccs.num_contrast失敗!");
|
| | | return false;
|
| | | }
|
| | | _PLog.Info("更新ccs.num_contrast成功!");
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | private bool initialEventRecord(String CCSID)
|
| | | {
|
| | | CCS.Function.InitialEventData InitialData = new CCS.Function.InitialEventData(_ConnectionTPC,_PLog);
|
| | | CCS.Object.NumberContrast m_Contrast = new CCS.Object.NumberContrast();
|
| | | CCS.Object.Dept_Contrast Dept_Contrast = null;
|
| | |
|
| | | // Being Transaction
|
| | | _Trx = _ConnectionTPC.BeginTransaction();
|
| | |
|
| | | Dept_Contrast = new CCS.Object.Dept_Contrast(_ConnectionTPC, _Trx);
|
| | | m_EventRecord = new CCS.Object.EventRecord(InitialData.getNewCaseID(), _ConnectionTPC, _Trx);
|
| | | m_EventRecord.setAcceptNum(InitialData.getNewAcceptNum());
|
| | |
|
| | | m_Contrast.setAcceptNum(m_EventRecord.getAcceptNum());
|
| | | m_Contrast.setCaseID(m_EventRecord.getCaseID());
|
| | | m_Contrast.setCCSID(m_CCSRecord.getCCSID());
|
| | | |
| | | if (!m_Contrast.Insert(_ConnectionTPC, _Trx))
|
| | | {
|
| | | _PLog.Error("初始化寫入CCS.Num_Contrast時發生錯誤!");
|
| | |
|
| | | if (_Trx.Connection.State.ToString().Equals("Open")) |
| | | _Trx.Rollback();
|
| | |
|
| | | return false;
|
| | | }
|
| | |
|
| | | // 設定用戶姓名
|
| | | m_EventRecord.setName(m_CCSRecord.getCustomerName());
|
| | |
|
| | | if (m_CCSRecord.getMeter() != null && m_CCSRecord.getMeter().Length != 0 )
|
| | | {
|
| | | // 需先找出部門代號,再找到該部門屬於哪一個巡修單位
|
| | | m_EventRecord.setMeter(m_CCSRecord.getMeter());
|
| | | int Tmp = Dept_Contrast.getDept_Code(m_CCSRecord.getMeter());
|
| | |
|
| | | if ( Tmp == -1 )
|
| | | m_EventRecord.setDept(findoutDeptByAddr(m_CCSRecord, _Trx));
|
| | | else
|
| | | m_EventRecord.setDept(Tmp);
|
| | |
|
| | | m_EventRecord.setFdrID(getFDRID(m_CCSRecord.getMeter()));
|
| | | }
|
| | | else
|
| | | {
|
| | | // 當無用戶電號時,所找出的部門別不需再去找出屬於哪一個巡修股(findoutDeptByAddr會直接找到相對應的巡修股)
|
| | | int Dept = this.findoutDeptByAddr(m_CCSRecord, _Trx);
|
| | | m_EventRecord.setDept(Dept);
|
| | | }
|
| | | // 設定用戶電話號碼
|
| | | if (m_CCSRecord.getCustomerTel() != null)
|
| | | {
|
| | | m_EventRecord.setTel(m_CCSRecord.getCustomerTel());
|
| | | }
|
| | | // 檢查並設定用戶地址
|
| | | String m_Addr = m_CCSRecord.getADDR_City() + m_CCSRecord.getADDR_Town() + m_CCSRecord.getADDR_Road() + m_CCSRecord.getADDR_Other();
|
| | |
|
| | | if (m_Addr.Trim().Length == 0)
|
| | | {
|
| | | _PLog.Error("CCS 案件受理程序初始化失敗...地址為空白");
|
| | |
|
| | | if (_Trx.Connection.State.ToString().Equals("Open"))
|
| | | _Trx.Rollback() ;
|
| | |
|
| | | return false;
|
| | | }
|
| | |
|
| | | m_EventRecord.setAddr(m_Addr);
|
| | | // 設定事故原因
|
| | | m_EventRecord.setBrief(TransferEventBrief(m_CCSRecord.getEventBrief()));
|
| | | try
|
| | | {
|
| | | System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
|
| | | byte[] source = encoding.GetBytes(m_EventRecord.getBrief()); |
| | |
|
| | | if (source.Length > 24)
|
| | | {
|
| | | byte[] dest = new byte[24];
|
| | | for (int i = 0; i < dest.Length; i++)
|
| | | {
|
| | | dest[i] = source[i];
|
| | | }
|
| | |
|
| | | System.Text.Encoding enc = System.Text.Encoding.ASCII;
|
| | | m_EventRecord.setBrief(enc.GetString(dest));
|
| | | source = dest = null;
|
| | | }
|
| | | }
|
| | | catch (Exception)
|
| | | {
|
| | | m_EventRecord.setBrief("其他");
|
| | | }
|
| | |
|
| | | if (m_CCSRecord.getCCSID().StartsWith("A"))
|
| | | m_EventRecord.setLog("APP");
|
| | | else if (m_CCSRecord.getCCSID().StartsWith("W"))
|
| | | m_EventRecord.setLog("WEB");
|
| | | else
|
| | | m_EventRecord.setLog("CCS");
|
| | | |
| | | m_EventRecord.setAcceptDate(m_CCSRecord.getAcceptTime());
|
| | |
|
| | | // 設定用戶種類
|
| | | if (m_CCSRecord.getImportCase() == CCS.LocalVariable.isImportCase)
|
| | | {
|
| | | m_EventRecord.setImportCase(CCS.LocalVariable.isImportCase);
|
| | | m_EventRecord.setLevel(CCS.LocalVariable.A_Level); // default set A level
|
| | | }
|
| | | else
|
| | | {
|
| | | m_EventRecord.setImportCase(CCS.LocalVariable.NotImportCase);
|
| | | m_EventRecord.setLevel(CCS.LocalVariable.No_Level);
|
| | | }
|
| | |
|
| | | // 檢查字串中有無特殊字元' ,若有則取代為"
|
| | | if (m_CCSRecord.getNote() != null)
|
| | | m_EventRecord.setNote(m_CCSRecord.getNote().Replace('\'', '\"'));
|
| | |
|
| | |
|
| | | // 設定回覆姓名及電話
|
| | | if (m_CCSRecord.getRecallName() != null)
|
| | | {
|
| | | m_EventRecord.setisReCall(CCS.LocalVariable.isReCall);
|
| | | m_EventRecord.setReCallName(m_CCSRecord.getRecallName().Replace('\'', '\"'));
|
| | | m_EventRecord.setReCallTel(m_CCSRecord.getRecallTel());
|
| | | }
|
| | | else
|
| | | {
|
| | | m_EventRecord.setisReCall(CCS.LocalVariable.NotReCall);
|
| | | }
|
| | |
|
| | | _PLog.Info("初始化EOS.EVENTRECORD成功!");
|
| | | return true;
|
| | | }
|
| | |
|
| | | //private bool initialCCSInfo(CCS.Object.EventQuery m_EventQuery, CCS.Object.NumberContrast m_Contrast)
|
| | | //{
|
| | | // checkCaseAlreadyExits(m_EventQuery);
|
| | | // if (!m_EventQuery.Insert(_PLog, _ConnectionTPC, _Trx))
|
| | | // {
|
| | | // _PLog.Error("初始化寫入CCS.EventQuery時發生錯誤!");
|
| | | // return false;
|
| | | // }
|
| | | // if (!m_Contrast.Insert(_ConnectionTPC, _Trx))
|
| | | // {
|
| | | // _PLog.Error("初始化寫入CCS.Num_Contrast時發生錯誤!");
|
| | | // return false;
|
| | | // }
|
| | | // return true;
|
| | | //}
|
| | |
|
| | | private void checkCaseAlreadyExits(CCS.Object.EventQuery m_EventQuery)
|
| | | {
|
| | | String SqlStmt = "select ccsid from ccs.eventquery where ccsid='" + m_EventQuery.getCCSID() + "'";
|
| | |
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC,_Trx);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | |
|
| | | try
|
| | | {
|
| | | if (reader.Read())
|
| | | {
|
| | | Command.CommandText = "delete from ccs.eventquery where ccsid='" + m_EventQuery.getCCSID() + "'";
|
| | | Command.ExecuteNonQuery();
|
| | |
|
| | | Command.CommandText = "delete from ccs.num_contrast where ccsid='" + m_EventQuery.getCCSID() + "'";
|
| | | Command.ExecuteNonQuery();
|
| | | }
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | _PLog.Warn("Problems occur during checking process: " + ex.Message);
|
| | | }
|
| | | finally
|
| | | {
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | | }
|
| | |
|
| | | private int findoutDeptByAddr(CCS.Object.CCSRecord CCSRecord, OracleTransaction _Trx)
|
| | | {
|
| | | CCS.Object.Addr_Contrast Addr_Contrast = new CCS.Object.Addr_Contrast(_ConnectionTPC, _Trx, _PLog);
|
| | | return Addr_Contrast.findDeptID(CCSRecord.getADDR_City(), CCSRecord.getADDR_Town(), CCSRecord.getADDR_Road());
|
| | | }
|
| | |
|
| | | private String TransferEventBrief(int Code)
|
| | | {
|
| | | String Result = "";
|
| | | Result = CCS.CCSMain.CCSCodelist.getContent(CCS.LocalVariable.CCSEventBrief, Code);
|
| | |
|
| | | // int MaxLength = this.getFieldLength("EOS", "EVENTRECORD", "EVENTBRIEF");
|
| | |
|
| | | // if ( Result.ToCharArray().Length > MaxLength )
|
| | | // Result.ToCharArray
|
| | |
|
| | | return Result;
|
| | | }
|
| | |
|
| | | private int TransferDept(String DeptCode)
|
| | | {
|
| | | // 傳入部門的英文value(CONTENT),傳回相對應的keyid
|
| | | return CCS.CCSMain.CCSCodelist.getKeyID(CCS.LocalVariable.CCSDept, DeptCode);
|
| | | }
|
| | |
|
| | | private int getRealCaseStatus(int ParentID)
|
| | | {
|
| | | String SqlStmt;
|
| | | int Status = CCS.LocalVariable.WaitForDespatch;
|
| | |
|
| | | SqlStmt = "SELECT CASESTATUS FROM EOS.EVENTS WHERE CASEID = " + ParentID;
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Trx);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | |
|
| | |
|
| | | try
|
| | | {
|
| | | if (reader.Read())
|
| | | {
|
| | | Status = Convert.ToInt32(reader["CaseStatus"].ToString());
|
| | | }
|
| | | }
|
| | | catch (Exception)
|
| | | {
|
| | | _PLog.Warn("無法取得正確之母案件狀態.");
|
| | | }
|
| | | finally
|
| | | { |
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | | return Status;
|
| | | }
|
| | |
|
| | | private void setDespatchInfo(int m_CaseID, CCS.Object.EventQuery m_EventQry)
|
| | | {
|
| | | String SqlStmt = "select despatchtime,assumefixtime,assumedtime_nth,delaytime,reason,eventlocation from eos.eventdespatch where caseid="
|
| | | + m_CaseID;
|
| | |
|
| | | OracleCommand Command = null;
|
| | | OracleDataReader reader = null;
|
| | |
|
| | | try
|
| | | {
|
| | | Command = new OracleCommand(SqlStmt, _ConnectionTPC,_Trx);
|
| | | reader = Command.ExecuteReader();
|
| | |
|
| | | if (reader.Read())
|
| | | {
|
| | | m_EventQry.setChangeTime(Convert.ToDateTime(reader["despatchtime"]).ToString("yyy/MM/dd HH:mm:ss"));
|
| | | m_EventQry.setAssumedTime(Convert.ToDateTime(reader["assumefixtime"]).ToString("yyy/MM/dd HH:mm:ss"));
|
| | | m_EventQry.setAssumedTime_Nth(Convert.ToDateTime(reader["assumedtime_nth"]).ToString("yyy/MM/dd HH:mm:ss"));
|
| | | m_EventQry.setDelayTimes(Convert.ToInt32(reader["delaytime"].ToString()));
|
| | | m_EventQry.setReason(reader["reason"].ToString());
|
| | | m_EventQry.setEventLocation(reader["eventlocation"].ToString());
|
| | | }
|
| | | }
|
| | | catch (Exception)
|
| | | {
|
| | | _PLog.Warn("無法取得母案件派工資訊.");
|
| | | }
|
| | | finally
|
| | | {
|
| | | if (reader != null )
|
| | | reader.Close();
|
| | |
|
| | | if (Command != null)
|
| | | Command.Dispose();
|
| | | }
|
| | | }
|
| | |
|
| | | private void processSameCustomer(CCS.Object.CCSRecord m_CCSRecord, CCS.Object.EventRecord m_EventRec)
|
| | | {
|
| | | _PLog.Info("處理相同用戶重複來電...");
|
| | | StringBuilder note = null;
|
| | |
|
| | | String SqlStmt = "select note from eos.eventrecord where caseid = " + m_EventRec.getTmpCaseID();
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Trx);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | |
|
| | | try
|
| | | {
|
| | | if (reader.Read())
|
| | | note = new StringBuilder(reader["note"] == null ? "" : reader["note"].ToString().Trim());
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | { |
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | |
|
| | | if ((m_EventRec.getNote() != null) && (m_EventRec.getNote().Length != 0))
|
| | | {
|
| | | if ((!note.ToString().EndsWith("|")) && (!note.ToString().Trim().Equals("")))
|
| | | {
|
| | | note.Append(" | ");
|
| | | }
|
| | |
|
| | | note.Append(m_EventRec.getNote());
|
| | | }
|
| | |
|
| | | // 判斷重複來電的用戶最初成立的案件是否是由CCS受理
|
| | | bool acceptByCCS = false;
|
| | |
|
| | | String SqlStmt1 = "select count(*) as count from ccs.num_contrast c,ccs.eventquery q where c.ccsid=q.ccsid and caseid="
|
| | | + m_EventRec.getTmpCaseID();
|
| | | OracleCommand Command1 = new OracleCommand(SqlStmt1, _ConnectionTPC,_Trx);
|
| | | OracleDataReader reader1 = Command1.ExecuteReader();
|
| | |
|
| | | try
|
| | | {
|
| | | if (reader1.Read())
|
| | | {
|
| | | if (Convert.ToInt32(reader1["count"].ToString()) != 0)
|
| | | {
|
| | | acceptByCCS = true;
|
| | | }
|
| | | }
|
| | | }
|
| | | catch (Exception)
|
| | | {
|
| | | }
|
| | | finally
|
| | | {
|
| | | reader1.Close();
|
| | | Command1.Dispose();
|
| | | }
|
| | |
|
| | | String updCCSEventQuery = null;
|
| | | // 若先前案件由CCS受理,則直接從ccs.eventquery取出先前的案件狀態資料寫入
|
| | | if (acceptByCCS)
|
| | | {
|
| | | updCCSEventQuery = "update ccs.eventquery set (casestatus,changetime,handlingsummary,assumedtime,assumedtime_nth,delaytimes,reason,eventlocation) = (select casestatus,changetime,handlingsummary,assumedtime,assumedtime_nth,delaytimes,reason,eventlocation from ccs.eventquery where ccsid=(select ccsid from ccs.num_contrast where caseid="
|
| | | + m_EventRec.getTmpCaseID() + " and rownum<2)) where CCSID='" + m_CCSRecord.getCCSID() + "'";
|
| | | // 若非由CCS受理(OMS,Web)則從EOS的table中尋找先前案件的狀態資料
|
| | | }
|
| | | else
|
| | | {
|
| | | String accepttime = null, despatchtime = null, sponsortime = null, assumefixtime = null, assumedtime_nth = null, changetime = null, handling = null, reason = null, eventlocation = null;
|
| | | int casestatus = 0, delaytime = 0;
|
| | |
|
| | | OracleCommand Command2 = null;
|
| | | OracleDataReader reader2 = null;
|
| | |
|
| | | try
|
| | | {
|
| | |
|
| | | String SqlStmt2 = "select 1,to_char(r.accepttime,'YYYY/MM/DD HH24:MI:SS') as ACCEPTTIME,to_char(d.despatchtime,'YYYY/MM/DD HH24:MI:SS') as DESPATCHTIME,to_char(s.reconditiontime,'YYYY/MM/DD HH24:MI:SS')SPONSORTIME,e.casestatus,s.handling,to_char(d.assumefixtime,'YYYY/MM/DD HH24:MI:SS') as assumefixtime,to_char(d.assumedtime_nth,'YYYY/MM/DD HH24:MI:SS') as assumedtime_nth,d.delaytime,d.reason,d.eventlocation from eos.eventrecord r,eos.events e,eos.eventdespatch d,eos.eventsponsor s where (r.caseid=e.caseid) and (r.caseid=d.caseid(+)) and (r.caseid=s.caseid(+)) and r.caseid="
|
| | | + m_EventRec.getTmpCaseID()
|
| | | + " union "
|
| | | + "select 2,to_char(r.accepttime,'YYYY/MM/DD HH24:MI:SS') as ACCEPTTIME,to_char(d.despatchtime,'YYYY/MM/DD HH24:MI:SS') as DESPATCHTIME,to_char(s.reconditiontime,'YYYY/MM/DD HH24:MI:SS')SPONSORTIME,e.casestatus,s.handling,to_char(d.assumefixtime,'YYYY/MM/DD HH24:MI:SS') as assumefixtime,to_char(d.assumedtime_nth,'YYYY/MM/DD HH24:MI:SS') as assumedtime_nth,d.delaytime,d.reason,d.eventlocation from eos.eventrecord r,eos.events e,eos.eventdespatch d,eos.eventsponsor s where (r.caseid=e.caseid) and (r.caseid=d.caseid(+)) and (r.caseid=s.caseid(+)) and r.caseid= (select parentid from eos.mergecase where caseid="
|
| | | + m_EventRec.getTmpCaseID() + ")";
|
| | |
|
| | | Command2 = new OracleCommand(SqlStmt2, _ConnectionTPC, _Trx);
|
| | | reader2 = Command2.ExecuteReader();
|
| | |
|
| | | while (reader2.Read())
|
| | | {
|
| | | accepttime = reader2["ACCEPTTIME"].ToString();
|
| | | despatchtime = reader2["DESPATCHTIME"].ToString();
|
| | | sponsortime = reader2["SPONSORTIME"].ToString();
|
| | | assumefixtime = reader2["ASSUMEFIXTIME"] == null ? "" : reader2["ASSUMEFIXTIME"].ToString();
|
| | | assumedtime_nth = reader2["ASSUMEDTIME_NTH"] == null ? "" : reader2["ASSUMEDTIME_NTH"].ToString();
|
| | | handling = reader2["HANDLING"] == null ? "" : reader2["HANDLING"].ToString();
|
| | | reason = reader2["REASON"] == null ? "" : reader2["REASON"].ToString();
|
| | | casestatus = Convert.ToInt32(reader2["CASESTATUS"].ToString());
|
| | | delaytime = reader2["DELAYTIME"].ToString().Length == 0 ? 0 : Convert.ToInt32(reader2["DELAYTIME"].ToString());
|
| | | eventlocation = reader2["EVENTLOCATION"] == null ? "" : reader2["EVENTLOCATION"].ToString();
|
| | | }
|
| | |
|
| | | if (accepttime != null)
|
| | | {
|
| | | changetime = accepttime;
|
| | | }
|
| | | if (despatchtime != null && despatchtime.Length != 0)
|
| | | {
|
| | | changetime = despatchtime;
|
| | | }
|
| | | if (sponsortime != null && sponsortime.Length != 0)
|
| | | {
|
| | | changetime = sponsortime;
|
| | | }
|
| | | updCCSEventQuery = "update ccs.eventquery set casestatus=" + casestatus + ",changetime=to_date('" + changetime
|
| | | + "','YYYY/MM/DD HH24:MI:SS'),handlingsummary='" + handling + "',assumedtime=to_date('" + assumefixtime
|
| | | + "','YYYY/MM/DD HH24:MI:SS'),assumedtime_nth=to_date('" + assumedtime_nth + "','YYYY/MM/DD HH24:MI:SS'),delaytimes="
|
| | | + delaytime + ",reason='" + reason + "',eventlocation='" + eventlocation + "' where ccsid='" + m_CCSRecord.getCCSID() + "'";
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine(e.Message);
|
| | | }
|
| | | finally
|
| | | { |
| | | if (reader2 != null)
|
| | | reader2.Close();
|
| | |
|
| | | if (Command2 != null)
|
| | | Command2.Dispose();
|
| | | }
|
| | | }
|
| | |
|
| | | String updEOSEventRecord = "update eos.eventrecord set note = '" + TrimToLimit(note.ToString(), 127)
|
| | | + "' where caseid = " + m_EventRecord.getTmpCaseID();
|
| | | String updCCSNum_Contrast = "update ccs.num_contrast set(acceptnum,caseid) = (select acceptnum," + m_EventRec.getTmpCaseID()
|
| | | + " from eos.eventrecord where caseid = " + m_EventRec.getTmpCaseID() + ") where ccsid='" + m_CCSRecord.getCCSID() + "'";
|
| | |
|
| | | OracleCommand ExeCommand = new OracleCommand(updCCSEventQuery, _ConnectionTPC,_Trx);
|
| | | // 將用戶重複來電案件資料寫回CCS.EventQuery
|
| | | if (ExeCommand.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | ExeCommand.Dispose();
|
| | |
|
| | | if (_Trx.Connection.State.ToString().Equals("Open"))
|
| | | _Trx.Rollback();
|
| | |
|
| | | _Trx.Dispose();
|
| | | _PLog.Error("Fail in write back to ccs.eventquery");
|
| | | return;
|
| | | }
|
| | |
|
| | | ExeCommand.CommandText = updEOSEventRecord;
|
| | | // 將CCS案件備註資料Append到EOS.EventRecord
|
| | | if (ExeCommand.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | ExeCommand.Dispose();
|
| | |
|
| | | if (_Trx.Connection.State.ToString().Equals("Open"))
|
| | | _Trx.Rollback();
|
| | |
|
| | | _Trx.Dispose();
|
| | | _PLog.Error("Fail in update eos.eventquery");
|
| | | return;
|
| | | }
|
| | |
|
| | | ExeCommand.CommandText = updCCSNum_Contrast;
|
| | | // 寫入ccsid <=> caseid 到CCS.Num_Contrast
|
| | | if (ExeCommand.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | ExeCommand.Dispose();
|
| | | if (_Trx.Connection.State.ToString().Equals("Open"))
|
| | | _Trx.Rollback();
|
| | |
|
| | | _Trx.Dispose();
|
| | | _PLog.Error("Fail in insert into ccs.num_contrast");
|
| | | return;
|
| | | }
|
| | |
|
| | | ExeCommand.Dispose();
|
| | | _Trx.Commit();
|
| | | _Trx.Dispose();
|
| | | _PLog.Info("CCS 案件受理程序結束");
|
| | | }
|
| | |
|
| | | private String TrimToLimit(String Msg, int MaxLen)
|
| | | {
|
| | | try
|
| | | {
|
| | | if (Msg.Length <= 1)
|
| | | {
|
| | | return "";
|
| | | }
|
| | | if (Msg.Length <= MaxLen)
|
| | | {
|
| | | return Msg;
|
| | | }
|
| | | Msg = Msg.Substring(Msg.IndexOf("|") + 1);
|
| | | return TrimToLimit(Msg, MaxLen);
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | Console.WriteLine(ex.StackTrace);
|
| | | return "";
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | private int getFieldLength(String Owner, String TableName, String FieldName)
|
| | | {
|
| | | String SqlStmt = "SELECT DATA_LENGTH FROM ALL_TAB_COLUMNS WHERE OWNER = '" + Owner + "' AND TABLE_NAME = '" + TableName + "' AND COLUMN_NAME = '" + FieldName + "'";
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Trx);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | | int MaxLength = -1;
|
| | |
|
| | | try
|
| | | {
|
| | | if (reader.Read())
|
| | | MaxLength = Convert.ToInt32(reader["DATA_LENGTH"].ToString());
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | {
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | |
|
| | | return MaxLength;
|
| | | }
|
| | |
|
| | | private int getFDRID(string Meter)
|
| | | {
|
| | | string SqlStmt = "SELECT TRAN_CORD FROM BASEDB.METER WHERE METR_NUMB = '" + Meter + "'"; |
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Trx);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | | string TPCLID = "";
|
| | | int FDRID = 0;
|
| | | String group = "";
|
| | | try
|
| | | {
|
| | | if (reader.Read())
|
| | | TPCLID = reader["TRAN_CORD"].ToString();
|
| | |
|
| | | if ( TPCLID.Length == 0 )
|
| | | return FDRID;
|
| | |
|
| | | if (TPCLID.Length > 11)
|
| | | {
|
| | | group = TPCLID.Substring(TPCLID.Length - 3);
|
| | | TPCLID = TPCLID.Substring(0, 11).Trim();
|
| | | SqlStmt = "SELECT FDR1 FROM BASEDB.CONNECTIVITY WHERE FSC = 115 AND UFID = (SELECT UFID FROM BASEDB.SXFMR WHERE OWNERTPCLID = '" + TPCLID |
| | | + "' AND GROUP1='" + group + "' AND ROWNUM < 2)";
|
| | | }
|
| | | else
|
| | | {
|
| | | SqlStmt = "SELECT FDR1 FROM BASEDB.CONNECTIVITY WHERE FSC = 115 AND UFID = (SELECT UFID FROM BASEDB.SXFMR WHERE OWNERTPCLID = '" + TPCLID |
| | | + "' AND ROWNUM < 2)";
|
| | | }
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | reader = Command.ExecuteReader();
|
| | |
|
| | | if (reader.Read())
|
| | | FDRID = Convert.ToInt32(reader["FDR1"].ToString());
|
| | | else
|
| | | {
|
| | | SqlStmt = "SELECT FDR1 FROM BASEDB.CONNECTIVITY WHERE FSC = 107 AND UFID = (SELECT UFID FROM BASEDB.HICUSTOMER WHERE OWNERTPCLID = '" + TPCLID + "' AND ROWNUM < 2)";
|
| | |
|
| | | Command.CommandText = SqlStmt;
|
| | | reader = Command.ExecuteReader();
|
| | |
|
| | | if (reader.Read())
|
| | | FDRID = Convert.ToInt32(reader["FDR1"].ToString());
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | {
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | |
|
| | | return FDRID;
|
| | | }
|
| | |
|
| | | private int getTraceCount(String CCSID)
|
| | | {
|
| | | String SqlStmt = "SELECT TRACECOUNT FROM CCS.TRACECOUNTS WHERE CCSID = '" + CCSID + "'";
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Trx);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | | int Count = 0;
|
| | |
|
| | | try
|
| | | {
|
| | | if (reader.Read())
|
| | | Count = Convert.ToInt32(reader["TRACECOUNT"].ToString());
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | {
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | }
|
| | |
|
| | | return Count;
|
| | | }
|
| | |
|
| | | private bool UpdateTraceCount(String CCSID,bool isNew)
|
| | | {
|
| | | String SqlStmt ;
|
| | |
|
| | | if (isNew)
|
| | | SqlStmt = "INSERT INTO CCS.TRACECOUNTS (CCSID,TRACECOUNT) VALUES ('" + CCSID + "',1)";
|
| | | else
|
| | | SqlStmt = "UPDATE CCS.TRACECOUNTS SET TRACECOUNT = TRACECOUNT + 1 WHERE CCSID = '" + CCSID + "'";
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Trx);
|
| | |
|
| | | try
|
| | | {
|
| | | int Result = Command.ExecuteNonQuery();
|
| | |
|
| | | if (Result == 1)
|
| | | return true;
|
| | | |
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | {
|
| | | Command.Dispose();
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | |
|
| | | }
|
| | | }
|
New file |
| | |
| | | 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;
|
| | |
|
| | | namespace CCSTrace.CCS
|
| | | {
|
| | | public class RecordLog |
| | | {
|
| | | private System.IO.StreamWriter _SWriter;
|
| | |
|
| | | public RecordLog(String FilePath)
|
| | | {
|
| | | _SWriter = new System.IO.StreamWriter(FilePath,true);
|
| | | }
|
| | |
|
| | | public void Debug(object message)
|
| | | {
|
| | | _SWriter.WriteLine("[Debug] [" + System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "] : " + message);
|
| | | }
|
| | |
|
| | | public void Error(object message)
|
| | | {
|
| | | _SWriter.WriteLine("[Error] [" + System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "] : " + message);
|
| | | }
|
| | |
|
| | | public void Fatal(object message)
|
| | | {
|
| | | _SWriter.WriteLine("[Fatal] [" + System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "] : " + message);
|
| | | }
|
| | |
|
| | | public void Info(object message)
|
| | | {
|
| | | _SWriter.WriteLine("[Info] [" + System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "] : " + message);
|
| | | }
|
| | |
|
| | | public void Warn(object message)
|
| | | {
|
| | | _SWriter.WriteLine("[Warn] [" + System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "] : " + message);
|
| | | }
|
| | |
|
| | | public void Close()
|
| | | {
|
| | | _SWriter.Close();
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
New file |
| | |
| | | using System;
|
| | | using System.Diagnostics;
|
| | |
|
| | | namespace CCSTrace.CCS
|
| | | {
|
| | | public class SEventLog |
| | | {
|
| | | static string sSource = "CCSTrace";
|
| | | static string sLog = "Application";
|
| | |
|
| | | public SEventLog()
|
| | | {
|
| | | }
|
| | |
|
| | | public void Debug(object message)
|
| | | {
|
| | | if (!EventLog.SourceExists(sSource))
|
| | | EventLog.CreateEventSource(sSource, sLog);
|
| | |
|
| | | //EventLog.WriteEntry(sSource, message.ToString());
|
| | | EventLog.WriteEntry(sSource, message.ToString(), EventLogEntryType.Information, 001);
|
| | | }
|
| | |
|
| | | public void Error(object message)
|
| | | {
|
| | | //if (!EventLog.SourceExists(sSource))
|
| | | // EventLog.CreateEventSource(sSource, sLog);
|
| | |
|
| | | //EventLog.WriteEntry(sSource, message.ToString());
|
| | | //EventLog.WriteEntry(sSource, message.ToString(), EventLogEntryType.Error, 001);
|
| | | }
|
| | |
|
| | | public void Fatal(object message)
|
| | | {
|
| | | if (!EventLog.SourceExists(sSource))
|
| | | EventLog.CreateEventSource(sSource, sLog);
|
| | |
|
| | | //EventLog.WriteEntry(sSource, message.ToString());
|
| | | EventLog.WriteEntry(sSource, message.ToString(), EventLogEntryType.FailureAudit, 001);
|
| | | }
|
| | |
|
| | | public void Info(object message)
|
| | | {
|
| | | //if (!EventLog.SourceExists(sSource))
|
| | | // EventLog.CreateEventSource(sSource, sLog);
|
| | |
|
| | | //EventLog.WriteEntry(sSource, message.ToString());
|
| | | //EventLog.WriteEntry(sSource, message.ToString(), EventLogEntryType.Information, 001);
|
| | | }
|
| | |
|
| | | public void Warn(object message)
|
| | | {
|
| | | if (!EventLog.SourceExists(sSource))
|
| | | EventLog.CreateEventSource(sSource, sLog);
|
| | |
|
| | | //EventLog.WriteEntry(sSource, message.ToString());
|
| | | EventLog.WriteEntry(sSource, message.ToString(), EventLogEntryType.Warning, 001);
|
| | | }
|
| | |
|
| | | public void Close()
|
| | | {
|
| | | }
|
| | | }
|
| | | }
|
New file |
| | |
| | | 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;
|
| | |
|
| | | namespace CCSTrace.CCS
|
| | | {
|
| | | public class ThreadEndEvent
|
| | | {
|
| | | private System.Data.OracleClient.OracleConnection _Conn;
|
| | |
|
| | | internal ThreadEndEvent(System.Data.OracleClient.OracleConnection _ConnectionTPC)
|
| | | {
|
| | | _Conn = _ConnectionTPC;
|
| | | }
|
| | |
|
| | | public System.Data.OracleClient.OracleConnection getConnection()
|
| | | {
|
| | | return _Conn;
|
| | | }
|
| | | }
|
| | | }
|
New file |
| | |
| | | <Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
| | | <PropertyGroup>
|
| | | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
| | | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
| | | <ProductVersion>9.0.21022</ProductVersion>
|
| | | <SchemaVersion>2.0</SchemaVersion>
|
| | | <ProjectGuid>{E56EE563-6708-4448-85C4-9AE3C01E1B86}</ProjectGuid>
|
| | | <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
| | | <OutputType>Library</OutputType>
|
| | | <AppDesignerFolder>Properties</AppDesignerFolder>
|
| | | <RootNamespace>CCSTrace</RootNamespace>
|
| | | <AssemblyName>CCSTrace</AssemblyName>
|
| | | <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
| | | </PropertyGroup>
|
| | | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
| | | <DebugSymbols>true</DebugSymbols>
|
| | | <DebugType>full</DebugType>
|
| | | <Optimize>false</Optimize>
|
| | | <OutputPath>bin\</OutputPath>
|
| | | <DefineConstants>DEBUG;TRACE</DefineConstants>
|
| | | <ErrorReport>prompt</ErrorReport>
|
| | | <WarningLevel>4</WarningLevel>
|
| | | </PropertyGroup>
|
| | | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
| | | <DebugType>pdbonly</DebugType>
|
| | | <Optimize>true</Optimize>
|
| | | <OutputPath>bin\</OutputPath>
|
| | | <DefineConstants>TRACE</DefineConstants>
|
| | | <ErrorReport>prompt</ErrorReport>
|
| | | <WarningLevel>4</WarningLevel>
|
| | | </PropertyGroup>
|
| | | <ItemGroup>
|
| | | <Reference Include="Interop.TRACEROBJECTLib, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
|
| | | <SpecificVersion>False</SpecificVersion>
|
| | | <HintPath>bin\Resources\Lib\Interop.TRACEROBJECTLib.DLL</HintPath>
|
| | | </Reference>
|
| | | <Reference Include="System" />
|
| | | <Reference Include="System.Data" />
|
| | | <Reference Include="System.Data.OracleClient" />
|
| | | <Reference Include="System.Drawing" />
|
| | | <Reference Include="System.Web" />
|
| | | <Reference Include="System.Windows.Forms" />
|
| | | <Reference Include="System.Xml" />
|
| | | <Reference Include="System.Configuration" />
|
| | | <Reference Include="System.Web.Services" />
|
| | | <Reference Include="System.EnterpriseServices" />
|
| | | <Reference Include="System.Web.Mobile" />
|
| | | </ItemGroup>
|
| | | <ItemGroup>
|
| | | <Content Include="Global.asax" />
|
| | | <Content Include="Service1.asmx" />
|
| | | <Content Include="Web.config" />
|
| | | </ItemGroup>
|
| | | <ItemGroup>
|
| | | <Compile Include="CCS\CCSMain.cs" />
|
| | | <Compile Include="CCS\EventAI\Equipment.cs" />
|
| | | <Compile Include="CCS\EventAI\JudgeCase.cs" />
|
| | | <Compile Include="CCS\EventAI\TraceSubject.cs" />
|
| | | <Compile Include="CCS\Function\MailService.cs" />
|
| | | <Compile Include="CCS\SEventLog.cs" />
|
| | | <Compile Include="CCS\FinishEvent.cs" />
|
| | | <Compile Include="CCS\Function\InitialEventData.cs" />
|
| | | <Compile Include="CCS\Function\Leach.cs" />
|
| | | <Compile Include="CCS\Function\MergeCase.cs" />
|
| | | <Compile Include="CCS\LocalVariable.cs" />
|
| | | <Compile Include="CCS\Object\Addr_Contrast.cs" />
|
| | | <Compile Include="CCS\Object\AlarmData.cs" />
|
| | | <Compile Include="CCS\Object\CCSCodelist.cs" />
|
| | | <Compile Include="CCS\Object\CCSRecord.cs" />
|
| | | <Compile Include="CCS\Object\Dept_Contrast.cs" />
|
| | | <Compile Include="CCS\Object\EOSCodelist.cs" />
|
| | | <Compile Include="CCS\Object\EventQuery.cs" />
|
| | | <Compile Include="CCS\Object\EventRecord.cs" />
|
| | | <Compile Include="CCS\Object\LocateEquipment.cs" />
|
| | | <Compile Include="CCS\Object\NumberContrast.cs" />
|
| | | <Compile Include="CCS\ProcessEvent.cs" />
|
| | | <Compile Include="CCS\RecordLog.cs" />
|
| | | <Compile Include="CCS\ThreadEndEvent.cs" />
|
| | | <Compile Include="Global.asax.cs">
|
| | | <DependentUpon>Global.asax</DependentUpon>
|
| | | </Compile>
|
| | | <Compile Include="Service1.asmx.cs">
|
| | | <DependentUpon>Service1.asmx</DependentUpon>
|
| | | <SubType>Component</SubType>
|
| | | </Compile>
|
| | | <Compile Include="Properties\AssemblyInfo.cs" />
|
| | | </ItemGroup>
|
| | | <ItemGroup>
|
| | | <WCFMetadata Include="Service References\" />
|
| | | </ItemGroup>
|
| | | <ItemGroup>
|
| | | <Folder Include="App_Data\" />
|
| | | <Folder Include="Service References\" />
|
| | | </ItemGroup>
|
| | | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
| | | <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
|
| | | <!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
| | | Other similar extension points exist, see Microsoft.Common.targets.
|
| | | <Target Name="BeforeBuild">
|
| | | </Target>
|
| | | <Target Name="AfterBuild">
|
| | | </Target>
|
| | | -->
|
| | | <ProjectExtensions>
|
| | | <VisualStudio>
|
| | | <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
| | | <WebProjectProperties>
|
| | | <UseIIS>False</UseIIS>
|
| | | <AutoAssignPort>True</AutoAssignPort>
|
| | | <DevelopmentServerPort>2853</DevelopmentServerPort>
|
| | | <DevelopmentServerVPath>/</DevelopmentServerVPath>
|
| | | <IISUrl>
|
| | | </IISUrl>
|
| | | <NTLMAuthentication>False</NTLMAuthentication>
|
| | | <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
| | | </WebProjectProperties>
|
| | | </FlavorProperties>
|
| | | </VisualStudio>
|
| | | </ProjectExtensions>
|
| | | </Project> |
New file |
| | |
| | | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
| | | <ProjectExtensions>
|
| | | <VisualStudio>
|
| | | <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
| | | <WebProjectProperties>
|
| | | <StartPageUrl>Service1.asmx</StartPageUrl>
|
| | | <StartAction>SpecificPage</StartAction>
|
| | | <AspNetDebugging>True</AspNetDebugging>
|
| | | <NativeDebugging>False</NativeDebugging>
|
| | | <SQLDebugging>False</SQLDebugging>
|
| | | <PublishCopyOption>RunFiles</PublishCopyOption>
|
| | | <PublishTargetLocation>
|
| | | </PublishTargetLocation>
|
| | | <PublishDeleteAllFiles>False</PublishDeleteAllFiles>
|
| | | <PublishCopyAppData>True</PublishCopyAppData>
|
| | | <ExternalProgram>
|
| | | </ExternalProgram>
|
| | | <StartExternalURL>
|
| | | </StartExternalURL>
|
| | | <StartCmdLineArguments>
|
| | | </StartCmdLineArguments>
|
| | | <StartWorkingDirectory>
|
| | | </StartWorkingDirectory>
|
| | | <EnableENC>False</EnableENC>
|
| | | <AlwaysStartWebServerOnDebug>True</AlwaysStartWebServerOnDebug>
|
| | | </WebProjectProperties>
|
| | | </FlavorProperties>
|
| | | </VisualStudio>
|
| | | </ProjectExtensions>
|
| | | </Project> |
New file |
| | |
| | | <?xml version="1.0" encoding="big5" ?>
|
| | | <CCS>
|
| | | <DBSetting ConnectionString = "Data source=nntpc;User Id=basedb;Password=basedb000;" ConnectionCount = "3" ShowError = "false" />
|
| | | </CCS> |
New file |
| | |
| | | <%@ Application Codebehind="Global.asax.cs" Inherits="CCSTrace.Global" Language="C#" %>
|
New file |
| | |
| | | using System;
|
| | | using System.Collections;
|
| | | using System.Configuration;
|
| | | using System.Data;
|
| | | using System.Web;
|
| | | using System.Web.Security;
|
| | | using System.Web.SessionState;
|
| | |
|
| | | namespace CCSTrace
|
| | | {
|
| | | public class Global : System.Web.HttpApplication
|
| | | {
|
| | |
|
| | | protected void Application_Start(object sender, EventArgs e)
|
| | | {
|
| | | CCSTrace.CCS.CCSMain.Instance();
|
| | | }
|
| | |
|
| | | protected void Session_Start(object sender, EventArgs e)
|
| | | {
|
| | |
|
| | | }
|
| | |
|
| | | protected void Application_BeginRequest(object sender, EventArgs e)
|
| | | {
|
| | |
|
| | | }
|
| | |
|
| | | protected void Application_AuthenticateRequest(object sender, EventArgs e)
|
| | | {
|
| | |
|
| | | }
|
| | |
|
| | | protected void Application_Error(object sender, EventArgs e)
|
| | | {
|
| | |
|
| | | }
|
| | |
|
| | | protected void Session_End(object sender, EventArgs e)
|
| | | {
|
| | |
|
| | | }
|
| | |
|
| | | protected void Application_End(object sender, EventArgs e)
|
| | | {
|
| | |
|
| | | }
|
| | | }
|
| | | } |
New file |
| | |
| | | using System.Reflection;
|
| | | using System.Runtime.CompilerServices;
|
| | | using System.Runtime.InteropServices;
|
| | |
|
| | | // General Information about an assembly is controlled through the following |
| | | // set of attributes. Change these attribute values to modify the information
|
| | | // associated with an assembly.
|
| | | [assembly: AssemblyTitle("CCSTrace")]
|
| | | [assembly: AssemblyDescription("")]
|
| | | [assembly: AssemblyConfiguration("")]
|
| | | [assembly: AssemblyCompany("Ximple")]
|
| | | [assembly: AssemblyProduct("CCSTrace")]
|
| | | [assembly: AssemblyCopyright("Copyright Ximple")]
|
| | | [assembly: AssemblyTrademark("")]
|
| | | [assembly: AssemblyCulture("")]
|
| | |
|
| | | // Setting ComVisible to false makes the types in this assembly not visible |
| | | // to COM components. If you need to access a type in this assembly from |
| | | // COM, set the ComVisible attribute to true on that type.
|
| | | [assembly: ComVisible(false)]
|
| | |
|
| | | // The following GUID is for the ID of the typelib if this project is exposed to COM
|
| | | [assembly: Guid("3d5900ae-111a-45be-96b3-d9e4606ca793")]
|
| | |
|
| | | // Version information for an assembly consists of the following four values:
|
| | | //
|
| | | // Major Version
|
| | | // Minor Version |
| | | // Build Number
|
| | | // Revision
|
| | | //
|
| | | // You can specify all the values or you can default the Revision and Build Numbers |
| | | // by using the '*' as shown below:
|
| | | [assembly: AssemblyVersion("5.1.0.0")]
|
| | | [assembly: AssemblyFileVersion("5.1.0.0")]
|
New file |
| | |
| | | <%@ WebService Language="C#" CodeBehind="Service1.asmx.cs" Class="CCSTrace.Service1" %> |
New file |
| | |
| | | using System;
|
| | | using System.Collections;
|
| | | using System.ComponentModel;
|
| | | using System.Data;
|
| | | using System.Web;
|
| | | using System.Web.Services;
|
| | | using System.Web.Services.Protocols;
|
| | |
|
| | | namespace CCSTrace
|
| | | {
|
| | | /// <summary>
|
| | | /// Summary description for Service1
|
| | | /// </summary>
|
| | | [WebService(Namespace = "http://tempuri.org/")]
|
| | | [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
|
| | | [ToolboxItem(false)]
|
| | | // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. |
| | | // [System.Web.Script.Services.ScriptService]
|
| | | public class Service1 : System.Web.Services.WebService
|
| | | {
|
| | | |
| | | public Service1() |
| | | { |
| | | /*
|
| | | if ( _CCSMain == null )
|
| | | _CCSMain = new CCSTrace.CCS.CCSMain();
|
| | | * */
|
| | | }
|
| | |
|
| | | [WebMethod]
|
| | | public void AcceptCase(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)
|
| | | {
|
| | | CCS.Object.CCSRecord _Record = new CCSTrace.CCS.Object.CCSRecord(_CCSID, _METER, _CUSTOMERNAME, _CUSTOMERTEL, _ADDR_CITY, _ADDR_TOWN, _ADDR_ROAD,
|
| | | _ADDR_OTHER, _RECALLNAME, _RECALLTEL, _EVENTBRIEF, _ACCEPTTIME, _IMPORTCASE, _DEPT,
|
| | | _PartHicustomer, _NOTE);
|
| | | //_CCSMain.AcceptEvent(_Record);
|
| | | CCSTrace.CCS.CCSMain.Instance().AcceptEvent(_Record);
|
| | | }
|
| | |
|
| | |
|
| | | }
|
| | | }
|
New file |
| | |
| | | <?xml version="1.0"?>
|
| | | <configuration>
|
| | | <appSettings/>
|
| | | <connectionStrings/>
|
| | | <system.web>
|
| | | <!-- |
| | | Set compilation debug="true" to insert debugging |
| | | symbols into the compiled page. Because this |
| | | affects performance, set this value to true only |
| | | during development.
|
| | | -->
|
| | | <compilation debug="true">
|
| | | </compilation>
|
| | | <!--
|
| | | The <authentication> section enables configuration |
| | | of the security authentication mode used by |
| | | ASP.NET to identify an incoming user. |
| | | -->
|
| | | <authentication mode="Windows"/>
|
| | | <!--
|
| | | The <customErrors> section enables configuration |
| | | of what to do if/when an unhandled error occurs |
| | | during the execution of a request. Specifically, |
| | | it enables developers to configure html error pages |
| | | to be displayed in place of a error stack trace.
|
| | |
|
| | | <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
|
| | | <error statusCode="403" redirect="NoAccess.htm" />
|
| | | <error statusCode="404" redirect="FileNotFound.htm" />
|
| | | </customErrors>
|
| | | -->
|
| | | </system.web>
|
| | | <system.codedom>
|
| | | </system.codedom>
|
| | | <!-- |
| | | The system.webServer section is required for running ASP.NET AJAX under Internet
|
| | | Information Services 7.0. It is not necessary for previous version of IIS.
|
| | | -->
|
| | | <system.webServer>
|
| | | </system.webServer>
|
| | | </configuration>
|
New file |
| | |
| | | D:\Project\CCSTrace\CCSTrace\obj\Debug\ResolveAssemblyReference.cache
|
| | | D:\Project\CCSTrace\CCSTrace\bin\CCSTrace.dll
|
| | | D:\Project\CCSTrace\CCSTrace\bin\CCSTrace.pdb
|
| | | D:\Project\CCSTrace\CCSTrace\bin\Interop.TRACEROBJECTLib.DLL
|
| | | D:\Project\CCSTrace\CCSTrace\obj\Debug\CCSTrace.dll
|
| | | D:\Project\CCSTrace\CCSTrace\obj\Debug\CCSTrace.pdb
|