| | |
| | | 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 CCSTrace.CCS.Domain;
|
| | |
|
| | | 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;
|
| | | private String _traceConnectionString = String.Empty;
|
| | | private readonly MergeCase _mergeCase = new MergeCase();
|
| | | private readonly RecordLog _pLog;
|
| | | private readonly OracleConnection _connectionTpc;
|
| | | private readonly OracleTransaction _transaction;
|
| | | private readonly string _traceConnectionString;
|
| | |
|
| | | public Leach(OracleConnection _Conn, OracleTransaction _Trx, String _traceConnection, RecordLog _Log)
|
| | | public Leach(OracleConnection conn, OracleTransaction trx, string traceConnection, RecordLog log)
|
| | | {
|
| | | _ConnectionTPC = _Conn;
|
| | | _Transaction = _Trx;
|
| | | _traceConnectionString = _traceConnection;
|
| | | _PLog = _Log;
|
| | | _connectionTpc = conn;
|
| | | _transaction = trx;
|
| | | _traceConnectionString = traceConnection;
|
| | | _pLog = log;
|
| | | }
|
| | |
|
| | | public int LeachCase(CCS.Object.EventRecord m_NewRec)
|
| | | public int LeachCase(Object.EventRecord mNewRec)
|
| | | {
|
| | |
|
| | | switch (SameCase(m_NewRec))
|
| | | switch (SameCase(mNewRec))
|
| | | {
|
| | | 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;
|
| | | case GlobalVariable.Success:
|
| | | return Judge(mNewRec, false);
|
| | |
|
| | | case GlobalVariable.CaseTypeChanged:
|
| | | return Judge(mNewRec, true);
|
| | |
|
| | | case GlobalVariable.SameCustomer:
|
| | | return GlobalVariable.SameCustomer;
|
| | |
|
| | | case GlobalVariable.FailureByDb:
|
| | | return GlobalVariable.FailureByDb;
|
| | |
|
| | | case GlobalVariable.CaseTransfer:
|
| | | return GlobalVariable.CaseTransfer;
|
| | |
|
| | | default:
|
| | | return CCS.LocalVariable.Failure_By_DB;
|
| | | return GlobalVariable.FailureByDb;
|
| | | }
|
| | | }
|
| | |
|
| | | public CCS.EventAI.Equipment getOldEquipment()
|
| | | public EventAI.Equipment GetOldEquipment()
|
| | | {
|
| | | return this.MergeCase.getOldEquipment();
|
| | | return _mergeCase.GetOldEquipment();
|
| | | }
|
| | |
|
| | | private int SameCase(CCS.Object.EventRecord m_NewRec)
|
| | | private int SameCase(Object.EventRecord mNewRec)
|
| | | {
|
| | | String SqlStmt = "SELECT R.ACCEPTNUM,R.CASEID as CASEID,R.IMPORTCASE as IMPORTCASE,E.CASETYPE as CASETYPE FROM EOS.EVENTRECORD R,"
|
| | | 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("利用電號或地址檢查是否有已成立之案件.");
|
| | | int mResult = -1;
|
| | | int importCase = -1;
|
| | | int tmpCaseId = 0;
|
| | | int caseType = -1;
|
| | | _pLog.Info("利用電號或地址檢查是否有已成立之案件.");
|
| | | // 檢查資料庫中此電號或地址是否已成立案件
|
| | | |
| | | if (m_NewRec.getMeter().Trim().Length != 0)
|
| | |
|
| | | if (mNewRec.Meter.Trim().Length != 0)
|
| | | {
|
| | | SqlStmt = SqlStmt + "R.CUSTOMERMETER = '" + m_NewRec.getMeter() + "' AND E.CASEID = R.CASEID AND E.CASESTATUS <= "
|
| | | + CCS.LocalVariable.WaitForSponsor;
|
| | | sqlStmt = sqlStmt + "R.CUSTOMERMETER = '" + mNewRec.Meter+ "' AND E.CASEID = R.CASEID AND E.CASESTATUS <= "
|
| | | + CCSCaseState.WaitForSponsor;
|
| | | }
|
| | | else if (m_NewRec.getAddr().Trim().Length != 0)
|
| | | else if (mNewRec.Addr.Trim().Length != 0)
|
| | | {
|
| | | SqlStmt = SqlStmt + "R.CUSTOMERADDR = '" + m_NewRec.getAddr() + "' AND E.CASEID = R.CASEID AND E.CASESTATUS <= "
|
| | | + CCS.LocalVariable.WaitForSponsor;
|
| | | sqlStmt = sqlStmt + "R.CUSTOMERADDR = '" + mNewRec.Addr+ "' AND E.CASEID = R.CASEID AND E.CASESTATUS <= "
|
| | | + CCSCaseState.WaitForSponsor;
|
| | | }
|
| | |
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | | 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);
|
| | | importCase = Convert.ToInt32(reader["IMPORTCASE"].ToString());
|
| | | tmpCaseId = Convert.ToInt32(reader["CASEID"].ToString());
|
| | | caseType = Convert.ToInt32(reader["CASETYPE"].ToString());
|
| | | mNewRec.TmpCaseId = tmpCaseId;
|
| | | _pLog.Info("案件已成立:" + reader["ACCEPTNUM"].ToString() + " " + tmpCaseId + " " + caseType);
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error(e.Message);
|
| | | _pLog.Error(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | return CCS.LocalVariable.Failure_By_DB;
|
| | | return GlobalVariable.FailureByDb;
|
| | | }
|
| | | finally
|
| | | { |
| | | {
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | command.Dispose();
|
| | | }
|
| | |
|
| | | // 非同一用戶重複來電
|
| | | if (TmpCaseID == 0)
|
| | | if (tmpCaseId == 0)
|
| | | {
|
| | | return CCS.LocalVariable.Success;
|
| | | return GlobalVariable.Success;
|
| | | }
|
| | | switch (CaseType)
|
| | | 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";
|
| | | case GlobalVariable.OriginalCase:
|
| | | case GlobalVariable.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 "
|
| | |
|
| | | case GlobalVariable.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.Error("無法辨別案件種類.");
|
| | | return GlobalVariable.FailureByDb;
|
| | | }
|
| | | _PLog.Info("檢查該案件有無切開關紀錄.");
|
| | | _pLog.Info("檢查該案件有無切開關紀錄.");
|
| | |
|
| | | try
|
| | | {
|
| | | Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | reader = Command.ExecuteReader();
|
| | | 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))
|
| | | _pLog.Info("有切開關且尚未恢復.");
|
| | | if ((mNewRec.ImportCase== importCase) || (importCase == GlobalVariable.IsImportCase))
|
| | | {
|
| | | m_Result = this.AddCount(TmpCaseID);
|
| | | mResult = AddCount(tmpCaseId);
|
| | | }
|
| | | else
|
| | | {
|
| | | m_Result = CCS.LocalVariable.CaseTypeChanged;
|
| | | mResult = GlobalVariable.CaseTypeChanged;
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | // 開關都已恢復(同用戶須重新受理)
|
| | | _PLog.Info("有切開關且已經恢復.");
|
| | | int CaseID;
|
| | | _pLog.Info("有切開關且已經恢復.");
|
| | | int caseId;
|
| | |
|
| | | // 找出案件編號需以母案件編號或該案件編號去找casestatus
|
| | | if (TmpCaseID == 0)
|
| | | if (tmpCaseId == 0)
|
| | | {
|
| | | CaseID = m_NewRec.getCaseID();
|
| | | caseId = mNewRec.CaseId;
|
| | | }
|
| | | else
|
| | | {
|
| | | CaseID = TmpCaseID;
|
| | | caseId = tmpCaseId;
|
| | | }
|
| | | // 判斷該案件或母案件是否移轉作後續處理
|
| | | if (this.getCastStatus(CaseID) == CCS.LocalVariable.EventTrasnfer)
|
| | | if (GetCastStatus(caseId) == (int) CCSCaseState.EventTrasnfer)
|
| | | {
|
| | | return CCS.LocalVariable.CaseTransfer;
|
| | | return GlobalVariable.CaseTransfer;
|
| | | }
|
| | | else
|
| | | {
|
| | | m_Result = CCS.LocalVariable.Success;
|
| | | mResult = GlobalVariable.Success;
|
| | | }
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | // 未切過開關
|
| | | _PLog.Info("無切開關紀錄.");
|
| | | if ((m_NewRec.getImportCase() == ImportCase) || (ImportCase == CCS.LocalVariable.isImportCase))
|
| | | _pLog.Info("無切開關紀錄.");
|
| | | if ((mNewRec.ImportCase== importCase) || (importCase == GlobalVariable.IsImportCase))
|
| | | {
|
| | | m_Result = this.AddCount(TmpCaseID);
|
| | | mResult = AddCount(tmpCaseId);
|
| | | }
|
| | | else
|
| | | {
|
| | | int CaseID;
|
| | | int caseId;
|
| | | // 找出案件編號需以母案件編號或該案件編號去找casestatus
|
| | | if (TmpCaseID == 0)
|
| | | if (tmpCaseId == 0)
|
| | | {
|
| | | CaseID = m_NewRec.getCaseID();
|
| | | caseId = mNewRec.CaseId;
|
| | | }
|
| | | else
|
| | | {
|
| | | CaseID = TmpCaseID;
|
| | | caseId = tmpCaseId;
|
| | |
|
| | | // 判斷該案件或母案件是否移轉作後續處理
|
| | | }
|
| | | if (this.getCastStatus(CaseID) == CCS.LocalVariable.EventTrasnfer)
|
| | | if (GetCastStatus(caseId) == (int) CCSCaseState.EventTrasnfer)
|
| | | {
|
| | | return CCS.LocalVariable.CaseTransfer;
|
| | | return GlobalVariable.CaseTransfer;
|
| | | }
|
| | | else
|
| | | {
|
| | | m_Result = CCS.LocalVariable.CaseTypeChanged;
|
| | | mResult = GlobalVariable.CaseTypeChanged;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error(e.Message);
|
| | | _pLog.Error(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | return CCS.LocalVariable.Failure_By_DB;
|
| | | return GlobalVariable.FailureByDb;
|
| | | }
|
| | | finally
|
| | | { |
| | | {
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | command.Dispose();
|
| | | }
|
| | | return m_Result;
|
| | | return mResult;
|
| | | }
|
| | |
|
| | | private int AddCount(int m_CaseID)
|
| | | private int AddCount(int mCaseId)
|
| | | {
|
| | | String sqlStmt = "UPDATE EOS.EVENTS SET COUNT = COUNT + 1 WHERE CASEID = " + m_CaseID;
|
| | | OracleCommand Command = new OracleCommand(sqlStmt, _ConnectionTPC, _Transaction);
|
| | | string sqlStmt = "UPDATE EOS.EVENTS SET COUNT = COUNT + 1 WHERE CASEID = " + mCaseId;
|
| | | OracleCommand command = new OracleCommand(sqlStmt, _connectionTpc, _transaction);
|
| | |
|
| | | try
|
| | | {
|
| | | if (Command.ExecuteNonQuery() > 0)
|
| | | return CCS.LocalVariable.SameCustomer;
|
| | | if (command.ExecuteNonQuery() > 0)
|
| | | return GlobalVariable.SameCustomer;
|
| | | else
|
| | | return CCS.LocalVariable.Failure_By_DB;
|
| | | return GlobalVariable.FailureByDb;
|
| | | }
|
| | | catch (Exception)
|
| | | {
|
| | | return CCS.LocalVariable.Failure_By_DB;
|
| | | return GlobalVariable.FailureByDb;
|
| | | }
|
| | | finally
|
| | | { |
| | | Command.Dispose();
|
| | | {
|
| | | command.Dispose();
|
| | | }
|
| | | }
|
| | |
|
| | | private int getCastStatus(int CaseID)
|
| | | private int GetCastStatus(int caseId)
|
| | | {
|
| | | String SqlStmt;
|
| | | int Status = 0;
|
| | | 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);
|
| | | 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();
|
| | | reader = command.ExecuteReader();
|
| | |
|
| | | if (reader.Read())
|
| | | Status = Convert.ToInt32(reader["CASESTATUS"].ToString());
|
| | | status = Convert.ToInt32(reader["CASESTATUS"].ToString());
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | |
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | { |
| | | if ( reader != null )
|
| | | {
|
| | | if (reader != null)
|
| | | reader.Close();
|
| | |
|
| | | Command.Dispose();
|
| | | command.Dispose();
|
| | | }
|
| | | return Status;
|
| | | return status;
|
| | | }
|
| | |
|
| | | private int Judge(CCS.Object.EventRecord m_NewRec, bool ChangeCaseType)
|
| | | private int Judge(Object.EventRecord mNewRec, bool changeCaseType)
|
| | | {
|
| | | int m_Result = CCS.LocalVariable.Failure_By_DB;
|
| | | int mResult = GlobalVariable.FailureByDb;
|
| | |
|
| | | if ((m_NewRec.getMeter().Trim().Length == 0))
|
| | | if ((mNewRec.Meter.Trim().Length == 0))
|
| | | {
|
| | | return CCS.LocalVariable.NoMeter;
|
| | | return GlobalVariable.NoMeter;
|
| | | }
|
| | |
|
| | | /* 已知損壞設備(ONLY FOR 饋線全停才知道損壞設備的FSC) */
|
| | | try
|
| | | {
|
| | | if (m_NewRec.getFsc() != 0)
|
| | | if (mNewRec.Fsc!= 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, _traceConnectionString, _PLog);
|
| | | return CCS.LocalVariable.Success;
|
| | | mNewRec.LocateEquipment.SetFsc(GlobalVariable.Breaker);
|
| | | mNewRec.LocateEquipment.SetUfid(mNewRec.Ufid);
|
| | | _pLog.Info("饋線全停:" + mNewRec.Fsc+ ", " + mNewRec.Ufid);
|
| | | _mergeCase.Merge(mNewRec, _connectionTpc, _transaction, _traceConnectionString, _pLog);
|
| | | return GlobalVariable.Success;
|
| | | }
|
| | | }
|
| | | catch (CCS.EventAI.TraceLoopException)
|
| | | catch (EventAI.TraceLoopException)
|
| | | {
|
| | | return CCS.LocalVariable.Trace_Counts_3;
|
| | | return GlobalVariable.TraceCounts3;
|
| | | }
|
| | | catch (TraceException)
|
| | | {
|
| | | return CCS.LocalVariable.Trace_Failure;
|
| | | return GlobalVariable.TraceFailure;
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | _PLog.Error(ex.Message);
|
| | | return CCS.LocalVariable.Failure_By_DB;
|
| | | _pLog.Error(ex.Message);
|
| | | return GlobalVariable.FailureByDb;
|
| | | }
|
| | |
|
| | | 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());
|
| | | _pLog.Info("定位損壞設備!");
|
| | | int result = GetEquipment(mNewRec);
|
| | | _pLog.Info("FSC:" + mNewRec.Fsc+ ", Ufid:" + mNewRec.Ufid+ ", Tpclid:" + mNewRec.Tpclid+ ", FeederID:" + mNewRec.FdrId);
|
| | |
|
| | | switch (result)
|
| | | { // get fsc,ufid,fdrid of sxfmr by meter
|
| | | case CCS.LocalVariable.Success:
|
| | | if (m_NewRec.getFdrID() == 0)
|
| | | case GlobalVariable.Success:
|
| | | if (mNewRec.FdrId== 0)
|
| | | {
|
| | | m_Result = CCS.LocalVariable.NoSupplyElc;
|
| | | mResult = GlobalVariable.NoSupplyElc;
|
| | | }
|
| | | else
|
| | | {
|
| | | // 需在未併案前作土木設備設定
|
| | | this.getLocateEquipment(m_NewRec);
|
| | | GetLocateEquipment(mNewRec);
|
| | |
|
| | | if (m_NewRec.getBrief().Length !=0 && m_NewRec.getBrief().Substring(0,1).Equals("A"))
|
| | | if (mNewRec.Brief.Length != 0 && mNewRec.Brief.Substring(0, 1).Equals("A"))
|
| | | { // A類事故原因,做追蹤合併
|
| | | _PLog.Info("<A類案件>");
|
| | | MergeCase.Merge(m_NewRec, _ConnectionTPC, _Transaction, _traceConnectionString, _PLog);
|
| | | _pLog.Info("<A類案件>");
|
| | | _mergeCase.Merge(mNewRec, _connectionTpc, _transaction, _traceConnectionString, _pLog);
|
| | | }
|
| | | else
|
| | | {
|
| | | _PLog.Info("<非A類案件>");
|
| | | _pLog.Info("<非A類案件>");
|
| | | }
|
| | |
|
| | | if (ChangeCaseType)
|
| | | if (changeCaseType)
|
| | | {
|
| | | m_Result = CCS.LocalVariable.CaseTypeChanged;
|
| | | mResult = GlobalVariable.CaseTypeChanged;
|
| | | }
|
| | | else
|
| | | {
|
| | | m_Result = CCS.LocalVariable.Success;
|
| | | mResult = GlobalVariable.Success;
|
| | | }
|
| | | }
|
| | | break;
|
| | | case CCS.LocalVariable.No_Sxfmr:
|
| | | m_Result = CCS.LocalVariable.No_Sxfmr;
|
| | |
|
| | | case GlobalVariable.NoSxfmr:
|
| | | mResult = GlobalVariable.NoSxfmr;
|
| | | break;
|
| | | case CCS.LocalVariable.Failure_By_DB:
|
| | | m_Result = CCS.LocalVariable.Failure_By_DB;
|
| | |
|
| | | case GlobalVariable.FailureByDb:
|
| | | mResult = GlobalVariable.FailureByDb;
|
| | | break;
|
| | | }
|
| | | }
|
| | | catch (CCS.EventAI.TraceLoopException)
|
| | | catch (EventAI.TraceLoopException)
|
| | | {
|
| | | return CCS.LocalVariable.Trace_Counts_3;
|
| | | return GlobalVariable.TraceCounts3;
|
| | | }
|
| | | catch (TraceException)
|
| | | {
|
| | | m_Result = CCS.LocalVariable.Trace_Failure;
|
| | | mResult = GlobalVariable.TraceFailure;
|
| | | }
|
| | | catch (Exception ex1)
|
| | | {
|
| | | _PLog.Error(ex1.Message);
|
| | | m_Result = CCS.LocalVariable.Failure_By_DB;
|
| | | _pLog.Error(ex1.Message);
|
| | | mResult = GlobalVariable.FailureByDb;
|
| | | }
|
| | | return m_Result;
|
| | | return mResult;
|
| | | }
|
| | |
|
| | | private int getEquipment(CCS.Object.EventRecord m_NewRec)
|
| | | private int GetEquipment(Object.EventRecord mNewRec)
|
| | | {
|
| | | 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();
|
| | | string temp;
|
| | | string mOwnerTpclid;
|
| | | string mGroup;
|
| | | string sqlStmt = "select tran_cord from basedb.meter where metr_numb = '" + mNewRec.Meter+ "'";
|
| | | 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)) /* 架空變壓器 */
|
| | | temp = reader["tran_cord"].ToString().Trim();
|
| | | if ((temp.Length == 9) || (temp.Length == 11)) /* 架空變壓器 */
|
| | | {
|
| | | m_OwnerTpclid = Temp;
|
| | | mOwnerTpclid = temp;
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | m_NewRec.setTpclid(m_OwnerTpclid);
|
| | | return getSxfmr(m_OwnerTpclid, null, m_NewRec); /* Find the Sxfmr */
|
| | | command.Dispose();
|
| | | mNewRec.Tpclid = mOwnerTpclid;
|
| | | return GetSxfmr(mOwnerTpclid, null, mNewRec); /* Find the Sxfmr */
|
| | | }
|
| | | else
|
| | | {
|
| | | m_OwnerTpclid = Temp.Substring(0, 11).Trim(); /* 地下變壓器 */
|
| | | m_Group = Temp.Substring(14);
|
| | | mOwnerTpclid = temp.Substring(0, 11).Trim(); /* 地下變壓器 */
|
| | | mGroup = temp.Substring(14);
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | m_NewRec.setTpclid(m_OwnerTpclid + " " + m_Group);
|
| | | return getSxfmr(m_OwnerTpclid, m_Group, m_NewRec);
|
| | | command.Dispose();
|
| | | mNewRec.Tpclid = mOwnerTpclid + " " + mGroup;
|
| | | return GetSxfmr(mOwnerTpclid, mGroup, mNewRec);
|
| | | /* Find the Sxfmr */
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | return CCS.LocalVariable.No_Sxfmr;
|
| | | return GlobalVariable.NoSxfmr;
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error(e.Message);
|
| | | _pLog.Error(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | return CCS.LocalVariable.Failure_By_DB;
|
| | | return GlobalVariable.FailureByDb;
|
| | | }
|
| | | finally
|
| | | { |
| | | {
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | command.Dispose();
|
| | | }
|
| | | }
|
| | |
|
| | | private int getSxfmr(String m_Tpclid, String m_Group, CCS.Object.EventRecord m_NewRec)
|
| | | private int GetSxfmr(string mTpclid, string mGroup, Object.EventRecord mNewRec)
|
| | | {
|
| | | String SqlStmt;
|
| | | int m_Status = CCS.LocalVariable.Failure_By_DB;
|
| | | string sqlStmt;
|
| | | int mStatus = GlobalVariable.FailureByDb;
|
| | |
|
| | | if (m_Group == null)
|
| | | if (mGroup == 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 + "')";
|
| | | sqlStmt = "SELECT UFID,FDR1 FROM BASEDB.CONNECTIVITY WHERE FSC = " + GlobalVariable.Sxfmr + " AND UFID IN "
|
| | | + "(SELECT UFID FROM BASEDB.SXFMR WHERE OWNERTPCLID = '" + mTpclid + "')";
|
| | | }
|
| | | 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 + "')";
|
| | |
|
| | | sqlStmt = "SELECT UFID,FDR1 FROM BASEDB.CONNECTIVITY WHERE FSC = " + GlobalVariable.Sxfmr + " AND UFID IN "
|
| | | + "(SELECT UFID FROM BASEDB.SXFMR WHERE OWNERTPCLID = '" + mTpclid + "' AND GROUP1 = '" + mGroup + "')";
|
| | | }
|
| | |
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | | 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;
|
| | | mNewRec.Fsc = GlobalVariable.Sxfmr;
|
| | | mNewRec.Ufid = Convert.ToInt32(reader["ufid"].ToString());
|
| | | mNewRec.FdrId = Convert.ToInt32(reader["fdr1"].ToString());
|
| | | mStatus = GlobalVariable.Success;
|
| | | }
|
| | | else
|
| | | m_Status = getHicustomer(m_Tpclid, m_Group, m_NewRec);
|
| | | mStatus = GetHicustomer(mTpclid, mGroup, mNewRec);
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | _PLog.Error(ex.Message);
|
| | | _pLog.Error(ex.Message);
|
| | | }
|
| | | finally
|
| | | { |
| | | {
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | command.Dispose();
|
| | | }
|
| | | return m_Status;
|
| | | return mStatus;
|
| | | }
|
| | |
|
| | |
|
| | | private int getHicustomer(String m_Tpclid, String m_Group, CCS.Object.EventRecord m_NewRec)
|
| | | private int GetHicustomer(string mTpclid, string mGroup, Object.EventRecord mNewRec)
|
| | | {
|
| | | String SqlStmt;
|
| | | string sqlStmt;
|
| | |
|
| | | if (m_Group == null)
|
| | | if (mGroup == 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 + "')";
|
| | | sqlStmt = "SELECT UFID,FDR1 FROM BASEDB.CONNECTIVITY WHERE FSC = " + GlobalVariable.Hicustomer + " AND UFID IN "
|
| | | + "(SELECT UFID FROM BASEDB.HICUSTOMER WHERE OWNERTPCLID = '" + mTpclid + "')";
|
| | | }
|
| | | 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 + "')";
|
| | |
|
| | | sqlStmt = "SELECT UFID,FDR1 FROM BASEDB.CONNECTIVITY WHERE FSC = " + GlobalVariable.Hicustomer + " AND UFID IN "
|
| | | + "(SELECT UFID FROM BASEDB.HICUSTOMER WHERE OWNERTPCLID = '" + mTpclid + "' AND GROUP1 = '" + mGroup + "')";
|
| | | }
|
| | |
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | | 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;
|
| | | mNewRec.Fsc = GlobalVariable.Hicustomer;
|
| | | mNewRec.Ufid = Convert.ToInt32(reader["ufid"].ToString());
|
| | | mNewRec.FdrId = Convert.ToInt32(reader["fdr1"].ToString());
|
| | | return GlobalVariable.Success;
|
| | | }
|
| | | else
|
| | | return CCS.LocalVariable.No_Sxfmr;
|
| | | return GlobalVariable.NoSxfmr;
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | _PLog.Error(ex.Message);
|
| | | return CCS.LocalVariable.Failure_By_DB;
|
| | | _pLog.Error(ex.Message);
|
| | | return GlobalVariable.FailureByDb;
|
| | | }
|
| | | finally
|
| | | { |
| | | {
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | command.Dispose();
|
| | | }
|
| | | }
|
| | |
|
| | | private void getLocateEquipment(CCS.Object.EventRecord m_NewRec)
|
| | | private void GetLocateEquipment(Object.EventRecord mNewRec)
|
| | | {
|
| | | String SqlStmt;
|
| | |
|
| | | SqlStmt = "SELECT OWNERFSC as FSC,OWNERUFID as UFID,OWNERTPCLID as TPCLID FROM ";
|
| | | switch (m_NewRec.getFsc())
|
| | | var sqlStmt = "SELECT OWNERFSC as FSC,OWNERUFID as UFID,OWNERTPCLID as TPCLID FROM ";
|
| | | switch (mNewRec.Fsc)
|
| | | {
|
| | | case CCS.LocalVariable.Sxfmr:
|
| | | SqlStmt = SqlStmt + "BASEDB.SXFMR WHERE UFID = " + m_NewRec.getUfid();
|
| | | case GlobalVariable.Sxfmr:
|
| | | sqlStmt = sqlStmt + "BASEDB.SXFMR WHERE UFID = " + mNewRec.Ufid;
|
| | | break;
|
| | | case CCS.LocalVariable.Hicustomer:
|
| | | SqlStmt = SqlStmt + "BASEDB.HICUSTOMER WHERE UFID = " + m_NewRec.getUfid();
|
| | |
|
| | | case GlobalVariable.Hicustomer:
|
| | | sqlStmt = sqlStmt + "BASEDB.HICUSTOMER WHERE UFID = " + mNewRec.Ufid;
|
| | | break;
|
| | | }
|
| | |
|
| | | OracleCommand Command = new OracleCommand(SqlStmt, _ConnectionTPC, _Transaction);
|
| | | OracleDataReader reader = Command.ExecuteReader();
|
| | | 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());
|
| | | mNewRec.LocateEquipment.SetFsc(Convert.ToInt32(reader["FSC"].ToString()));
|
| | | mNewRec.LocateEquipment.SetUfid(Convert.ToInt32(reader["UFID"].ToString()));
|
| | | mNewRec.LocateEquipment.SetTpclid(reader["TPCLID"].ToString());
|
| | | }
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | _PLog.Error(e.Message);
|
| | | _pLog.Error(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | }
|
| | | finally
|
| | | { |
| | | {
|
| | | reader.Close();
|
| | | Command.Dispose();
|
| | | command.Dispose();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | } |