| | |
| | | using System;
|
| | | using System.Data.OracleClient;
|
| | | using CCSTrace.CCS.Domain;
|
| | | using CCSTrace.CCS.Object;
|
| | | using NLog;
|
| | |
|
| | | namespace CCSTrace.CCS
|
| | |
| | | public class FinishEvent
|
| | | {
|
| | | private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
| | | private int _originCaseStatus;
|
| | |
|
| | | private bool _upLevel;
|
| | | private int _originCaseStatus = 0;
|
| | | private Object.EOSEventRecord _eosEventRecord = null;
|
| | | private OracleConnection _connectionTpc;
|
| | | private OracleTransaction _transaction;
|
| | |
|
| | | public FinishEvent()
|
| | | public bool Finish(OracleConnection conn, OracleTransaction trx, EOSEventRecord eosEventRecord, int mKind)
|
| | | {
|
| | | }
|
| | |
|
| | | public bool Finish(int mKind, Object.EOSEventRecord eosEventRecord, OracleConnection conn, OracleTransaction trx)
|
| | | {
|
| | | _eosEventRecord = eosEventRecord;
|
| | | _connectionTpc = conn;
|
| | | _transaction = trx;
|
| | |
|
| | | Logger.Info("進行OMS資料更新程序...");
|
| | | if (eosEventRecord.ParentId == 0)
|
| | | {
|
| | | // Original Case
|
| | | if (!(ProcessSingalCase(eosEventRecord)))
|
| | | if (!ProcessSingalCase(conn, trx, eosEventRecord))
|
| | | {
|
| | | return false;
|
| | | }
|
| | |
| | | else
|
| | | {
|
| | | // Child Case
|
| | | if (!(ProcessMergeCase(eosEventRecord)))
|
| | | if (!ProcessMergeCase(conn, trx, eosEventRecord))
|
| | | {
|
| | | return false;
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | // inert into eos.eventrecord && eos.eventrecord_ex
|
| | | OracleCommand command = new OracleCommand(eosEventRecord.GetInsertSqlStmt(), _connectionTpc, _transaction);
|
| | | var command = new OracleCommand(eosEventRecord.GetInsertSqlStmt(), conn, trx);
|
| | | OracleCommand command1 = null;
|
| | |
|
| | | try
|
| | |
| | | /* 當饋線全停時不需注意影響虛擬用戶,影響用戶資料會由實際切開關產生 */
|
| | | if (eosEventRecord.Fsc != GlobalVariable.Breaker)
|
| | | {
|
| | | if (!SetVisualCustomer(eosEventRecord))
|
| | | if (!SetVisualCustomer(conn, trx, eosEventRecord))
|
| | | {
|
| | | Logger.Error("新增影響用戶資料錯誤.");
|
| | | return false;
|
| | |
| | | Logger.Info("新增影響用戶成功!");
|
| | | }
|
| | |
|
| | | _upLevel = false; /* 判斷交辦案件是否升級為母案件 */
|
| | | var upLevel = false;
|
| | |
|
| | | if (!(UpdateImportCase(eosEventRecord)))
|
| | | if (!UpdateImportCase(conn, trx, eosEventRecord, upLevel))
|
| | | {
|
| | | Logger.Error("處理案件等級變更時發生錯誤.");
|
| | | return false;
|
| | | }
|
| | | Logger.Info("處理案件等級變更成功!");
|
| | |
|
| | | if (!(UpdateRecuseOrder(eosEventRecord)))
|
| | | if (!UpdateRecuseOrder(conn, trx, eosEventRecord, upLevel))
|
| | | {
|
| | | Logger.Error("新增搶修順序資料時發生錯誤.");
|
| | | return false;
|
| | |
| | |
|
| | | if (mKind == GlobalVariable.CaseTypeChanged)
|
| | | {
|
| | | if (!DeleteOldCase(eosEventRecord))
|
| | | if (!DeleteOldCase(conn, trx, eosEventRecord))
|
| | | {
|
| | | Logger.Error("案件轉換發生錯誤");
|
| | | return false;
|
| | |
| | | Logger.Info("案件轉換成功!");
|
| | | }
|
| | |
|
| | | if (!SaveCustomerTel(eosEventRecord))
|
| | | if (!SaveCustomerTel(conn, trx, eosEventRecord))
|
| | | {
|
| | | Logger.Error("無法將用戶電話回存回資料庫.");
|
| | | return false;
|
| | |
| | | }
|
| | | else if (mKind == GlobalVariable.NoMeter)
|
| | | {
|
| | | var sqlStmt = "INSERT INTO EOS.RESCUE_ORDER SELECT " + eosEventRecord.CaseId + ",999,COUNT(*) + 1,'',"
|
| | | var sqlStmt = "INSERT INTO EOS.RESCUE_ORDER SELECT " + eosEventRecord.CaseId +
|
| | | ",999,COUNT(*) + 1,'',"
|
| | | + eosEventRecord.LocateEquipment.DsUfid + " FROM EOS.RESCUE_ORDER WHERE DSUFID = "
|
| | | + eosEventRecord.LocateEquipment.DsUfid;
|
| | |
|
| | | command1 = new OracleCommand(sqlStmt, _connectionTpc, _transaction);
|
| | | command1 = new OracleCommand(sqlStmt, conn, trx);
|
| | | if (command1.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | Logger.Error("新增搶修順序資料時發生錯誤.");
|
| | |
| | |
|
| | | if (eosEventRecord.ParentId == 0)
|
| | | {
|
| | | if (!InsertIntoSri(eosEventRecord))
|
| | | if (!InsertIntoSri(conn, trx, eosEventRecord))
|
| | | {
|
| | | Logger.Error("新增資料庫(OCSDB.SRI)錯誤.");
|
| | | return false;
|
| | |
| | | return true;
|
| | | }
|
| | |
|
| | | private bool ProcessSingalCase(Object.EOSEventRecord eosEventRecord)
|
| | | private bool ProcessSingalCase(OracleConnection conn, OracleTransaction trx, EOSEventRecord eosEventRecord)
|
| | | {
|
| | | var result = false;
|
| | | var sqlStmt = "INSERT INTO EOS.EVENTS VALUES(" + eosEventRecord.CaseId + "," + CCSCaseState.WaitForDespatch + ",1,"
|
| | | var sqlStmt = "INSERT INTO EOS.EVENTS VALUES(" + eosEventRecord.CaseId + "," + CCSCaseState.WaitForDespatch +
|
| | | ",1,"
|
| | | + GlobalVariable.OriginalCase + ",0)";
|
| | |
|
| | | OracleCommand command = new OracleCommand(sqlStmt, _connectionTpc, _transaction);
|
| | | var command = new OracleCommand(sqlStmt, conn, trx);
|
| | |
|
| | | try
|
| | | {
|
| | |
| | | return result;
|
| | | }
|
| | |
|
| | | private bool ProcessMergeCase(Object.EOSEventRecord eosEventRecord)
|
| | | private bool ProcessMergeCase(OracleConnection conn, OracleTransaction trx, EOSEventRecord eosEventRecord)
|
| | | {
|
| | | // insert eos.events
|
| | | var sqlStmt = "INSERT INTO EOS.EVENTS VALUES(" + eosEventRecord.CaseId + "," + CCSCaseState.WaitForDespatch + ",1,"
|
| | | var sqlStmt = "INSERT INTO EOS.EVENTS VALUES(" + eosEventRecord.CaseId + "," + CCSCaseState.WaitForDespatch +
|
| | | ",1,"
|
| | | + GlobalVariable.ChildCase + ",0)";
|
| | |
|
| | | OracleCommand command = new OracleCommand(sqlStmt, _connectionTpc, _transaction);
|
| | | var command = new OracleCommand(sqlStmt, conn, trx);
|
| | |
|
| | | try
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | // insert into eos.mergecase
|
| | | sqlStmt = "INSERT INTO EOS.MERGECASE VALUES(" + eosEventRecord.CaseId + ",'" + eosEventRecord.AcceptNum + "'," +
|
| | | sqlStmt = "INSERT INTO EOS.MERGECASE VALUES(" + eosEventRecord.CaseId + ",'" + eosEventRecord.AcceptNum +
|
| | | "'," +
|
| | | eosEventRecord.ParentId + ")";
|
| | |
|
| | | command.CommandText = sqlStmt;
|
| | |
| | |
|
| | | // update parent case data(EOS.EVENTRECORD)
|
| | | sqlStmt = "UPDATE EOS.EVENTRECORD SET FSC = " + eosEventRecord.Fsc + ",UFID = " + eosEventRecord.Ufid +
|
| | | " WHERE CASEID in (SELECT CASEID FROM EOS.MERGECASE WHERE PARENTID = " + eosEventRecord.ParentId +
|
| | | " WHERE CASEID in (SELECT CASEID FROM EOS.MERGECASE WHERE PARENTID = " +
|
| | | eosEventRecord.ParentId +
|
| | | ") OR CASEID = "
|
| | | + eosEventRecord.ParentId;
|
| | |
|
| | |
| | | return true;
|
| | | }
|
| | |
|
| | | private bool SetVisualCustomer(Object.EOSEventRecord eosEventRecord)
|
| | | private bool SetVisualCustomer(OracleConnection conn, OracleTransaction trx, EOSEventRecord eosEventRecord)
|
| | | {
|
| | | var sqlStmt = "";
|
| | | var customerKind = "C"; // 高壓用戶or一般用戶
|
| | |
|
| | | sqlStmt = "SELECT COUNT(*) as COUNT FROM BASEDB.HICUSTOMER WHERE METR_NUMB = '" + eosEventRecord.Meter + "'";
|
| | | OracleCommand command = new OracleCommand(sqlStmt, _connectionTpc, _transaction);
|
| | | OracleDataReader reader = command.ExecuteReader();
|
| | | var sqlStmt = "SELECT COUNT(*) as COUNT FROM BASEDB.HICUSTOMER WHERE METR_NUMB = '" + eosEventRecord.Meter +
|
| | | "'";
|
| | | var command = new OracleCommand(sqlStmt, conn, trx);
|
| | | var reader = command.ExecuteReader();
|
| | |
|
| | | try
|
| | | {
|
| | |
| | | "FROM BASEDB.METER M,BASEDB.MSTADDR A WHERE M.METR_NUMB = A.M_CUST_NO(+) AND M.METR_NUMB = '" +
|
| | | eosEventRecord.Meter + "'";
|
| | |
|
| | | OracleCommand command1 = new OracleCommand(sqlStmt, _connectionTpc, _transaction);
|
| | | var command1 = new OracleCommand(sqlStmt, conn, trx);
|
| | | if (command1.ExecuteNonQuery() >= 0)
|
| | | {
|
| | | command1.Dispose();
|
| | |
| | | command1.Dispose();
|
| | | return false;
|
| | | }
|
| | | else
|
| | | {
|
| | | return InsertMutilCustomer(customerKind, eosEventRecord);
|
| | | }
|
| | | return InsertMutilCustomer(conn, trx, customerKind, eosEventRecord);
|
| | | }
|
| | |
|
| | | private bool InsertMutilCustomer(string customerKind, Object.EOSEventRecord eosEventRecord)
|
| | | private bool InsertMutilCustomer(OracleConnection conn, OracleTransaction trx, string customerKind,
|
| | | EOSEventRecord eosEventRecord)
|
| | | {
|
| | | string sqlStmt = "";
|
| | | bool updateCustomer = false;
|
| | | string mTpclidGroupId = "";
|
| | | string mCustomerKind = "C";
|
| | | var sqlStmt = "";
|
| | | var updateCustomer = false;
|
| | | var mTpclidGroupId = "";
|
| | | var mCustomerKind = "C";
|
| | |
|
| | | sqlStmt = "SELECT COUNT(*) as COUNT FROM EOS.TMPAFFECTCUSTMS WHERE CASEID = " + eosEventRecord.ParentId +
|
| | | " OR CASEID IN (SELECT CASEID FROM EOS.MERGECASE WHERE PARENTID = " + eosEventRecord.ParentId + ")";
|
| | | " OR CASEID IN (SELECT CASEID FROM EOS.MERGECASE WHERE PARENTID = " + eosEventRecord.ParentId +
|
| | | ")";
|
| | |
|
| | | OracleCommand command = new OracleCommand(sqlStmt, _connectionTpc, _transaction);
|
| | | OracleDataReader reader = command.ExecuteReader();
|
| | | var command = new OracleCommand(sqlStmt, conn, trx);
|
| | | var reader = command.ExecuteReader();
|
| | |
|
| | | try
|
| | | {
|
| | |
| | |
|
| | | try
|
| | | {
|
| | | command1 = new OracleCommand(sqlStmt, _connectionTpc, _transaction);
|
| | | command1 = new OracleCommand(sqlStmt, conn, trx);
|
| | | reader = command1.ExecuteReader();
|
| | |
|
| | | if (reader.Read())
|
| | |
| | | sqlStmt = "INSERT INTO EOS.TMPAFFECTCUSTMS SELECT " + eosEventRecord.CaseId + ",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 = '" + eosEventRecord.Meter +
|
| | | + "WHERE TRAN_CORD = (SELECT TRAN_CORD FROM BASEDB.METER WHERE METR_NUMB = '" +
|
| | | eosEventRecord.Meter +
|
| | | "')) M,BASEDB.MSTADDR A WHERE M.METR_NUMB = A.M_CUST_NO(+) ";
|
| | |
|
| | | OracleCommand command2 = new OracleCommand(sqlStmt, _connectionTpc, _transaction);
|
| | | var command2 = new OracleCommand(sqlStmt, conn, trx);
|
| | | if (command2.ExecuteNonQuery() < 0)
|
| | | {
|
| | | Logger.Error("無法新增新受理案件的影響用戶資料.");
|
| | |
| | | return true;
|
| | | }
|
| | |
|
| | | private bool UpdateImportCase(Object.EOSEventRecord eosEventRecord)
|
| | | private bool UpdateImportCase(OracleConnection conn, OracleTransaction trx, EOSEventRecord eosEventRecord, bool upLevel)
|
| | | {
|
| | | /* 該案件不為交辦案件 */
|
| | | if (eosEventRecord.ImportCase != GlobalVariable.IsImportCase)
|
| | |
| | |
|
| | | /* 若母案件已為交辦案件,則不需再作任何更動 */
|
| | | var sqlStmt = "SELECT IMPORTCASE FROM EOS.EVENTRECORD WHERE CASEID = " + eosEventRecord.ParentId;
|
| | | OracleCommand command = new OracleCommand(sqlStmt, _connectionTpc, _transaction);
|
| | | OracleDataReader reader = command.ExecuteReader();
|
| | | var command = new OracleCommand(sqlStmt, conn, trx);
|
| | | var reader = command.ExecuteReader();
|
| | |
|
| | | try
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | /* 開始進行交辦案件升級動作 */
|
| | | _upLevel = true;
|
| | | upLevel = true;
|
| | |
|
| | | /* 將交辦案件改為母案件 */
|
| | | sqlStmt = "UPDATE EOS.EVENTS SET CASETYPE = " + GlobalVariable.ParentCase + ",MERGECASECOUNT = "
|
| | | + "(SELECT MERGECASECOUNT FROM EOS.EVENTS WHERE CASEID = " + eosEventRecord.ParentId +
|
| | | ") WHERE CASEID = " + eosEventRecord.CaseId;
|
| | |
|
| | | OracleCommand command1 = new OracleCommand(sqlStmt, _connectionTpc, _transaction);
|
| | | var command1 = new OracleCommand(sqlStmt, conn, trx);
|
| | | if (command1.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | Logger.Error("無法將交辦案件改為母案件.");
|
| | |
| | | }
|
| | |
|
| | | // 將EOS.MERGECASE內的資料修正 1.將原先該母案件下的子案件都改掛在交辦案件下 2.將已INSERT入EOS.MERGECASE內的交辦案件資料改為原先母案件的資料(CaseID,AcceptNum)
|
| | | sqlStmt = "UPDATE EOS.MERGECASE SET PARENTID = " + eosEventRecord.CaseId + " WHERE PARENTID = " + eosEventRecord.ParentId;
|
| | | sqlStmt = "UPDATE EOS.MERGECASE SET PARENTID = " + eosEventRecord.CaseId + " WHERE PARENTID = " +
|
| | | eosEventRecord.ParentId;
|
| | |
|
| | | command1.CommandText = sqlStmt;
|
| | | if (command1.ExecuteNonQuery() <= 0)
|
| | |
| | | }
|
| | | command1.Dispose();
|
| | |
|
| | | return UpdateOtherTable(eosEventRecord.ParentId, eosEventRecord.CaseId, eosEventRecord.AcceptNum);
|
| | | return UpdateOtherTable(conn, trx, eosEventRecord);
|
| | | }
|
| | |
|
| | | private bool UpdateOtherTable(int oldCaseId, int newCaseId, string newAcceptNum)
|
| | | private bool UpdateOtherTable(OracleConnection conn, OracleTransaction trx, EOSEventRecord eosEventRecord)
|
| | | {
|
| | | var sqlStmt = "SELECT CASESTATUS FROM EOS.EVENTS WHERE CASEID = " + oldCaseId;
|
| | | OracleCommand command = new OracleCommand(sqlStmt, _connectionTpc, _transaction);
|
| | | OracleDataReader reader = command.ExecuteReader();
|
| | | var sqlStmt = "SELECT CASESTATUS FROM EOS.EVENTS WHERE CASEID = " + eosEventRecord.ParentId;
|
| | | var command = new OracleCommand(sqlStmt, conn, trx);
|
| | | var reader = command.ExecuteReader();
|
| | |
|
| | | try
|
| | | {
|
| | |
| | | break;
|
| | |
|
| | | case (int) CCSCaseState.WaitForSponsor:
|
| | | sqlStmt = "UPDATE EOS.EVENTDESPATCH SET CASEID = " + newCaseId + " WHERE CASEID = " + oldCaseId;
|
| | | sqlStmt = "UPDATE EOS.EVENTDESPATCH SET CASEID = " + eosEventRecord.CaseId + " WHERE CASEID = " +
|
| | | eosEventRecord.ParentId;
|
| | |
|
| | | command.CommandText = sqlStmt;
|
| | | if (command.ExecuteNonQuery() < 0)
|
| | |
| | | }
|
| | |
|
| | | sqlStmt = "update eos.events set casestatus=" + CCSCaseState.WaitForSponsor + " where caseid=" +
|
| | | newCaseId;
|
| | | eosEventRecord.CaseId;
|
| | | command.CommandText = sqlStmt;
|
| | | if (command.ExecuteNonQuery() < 0)
|
| | | {
|
| | |
| | | return false;
|
| | | }
|
| | |
|
| | | _eosEventRecord.IsDespatched = true;
|
| | | eosEventRecord.IsDespatched = true;
|
| | | break;
|
| | | }
|
| | |
|
| | | sqlStmt = "UPDATE EOS.EVENTS SET CASESTATUS = " + CCSCaseState.WaitForDespatch + " WHERE CASEID = " +
|
| | | oldCaseId;
|
| | | eosEventRecord.ParentId;
|
| | |
|
| | | command.CommandText = sqlStmt;
|
| | | if (command.ExecuteNonQuery() <= 0)
|
| | |
| | | return false;
|
| | | }
|
| | |
|
| | | sqlStmt = "UPDATE OCSDB.SRI SET SCENENAME = '" + newAcceptNum +
|
| | | sqlStmt = "UPDATE OCSDB.SRI SET SCENENAME = '" + eosEventRecord.AcceptNum +
|
| | | "' WHERE SCENENAME = (SELECT ACCEPTNUM FROM "
|
| | | + "EOS.EVENTRECORD WHERE CASEID = " + oldCaseId + ")";
|
| | | + "EOS.EVENTRECORD WHERE CASEID = " + eosEventRecord.ParentId + ")";
|
| | |
|
| | | command.CommandText = sqlStmt;
|
| | | if (command.ExecuteNonQuery() < 0)
|
| | |
| | | return false;
|
| | | }
|
| | |
|
| | | sqlStmt = "SELECT COUNT(*) as COUNT FROM EOS.CRTAPOLOGY WHERE CASEID = " + oldCaseId;
|
| | | sqlStmt = "SELECT COUNT(*) as COUNT FROM EOS.CRTAPOLOGY WHERE CASEID = " + eosEventRecord.ParentId;
|
| | |
|
| | | command.CommandText = sqlStmt;
|
| | | reader = command.ExecuteReader();
|
| | | int count = 0;
|
| | | var count = 0;
|
| | |
|
| | | if (reader.Read())
|
| | | {
|
| | |
| | | // 已有切過開關
|
| | | if (count > 0)
|
| | | {
|
| | | sqlStmt = "UPDATE EOS.EVENTFACILITY SET CASEID = " + newCaseId + " WHERE CASEID = " + oldCaseId;
|
| | | sqlStmt = "UPDATE EOS.EVENTFACILITY SET CASEID = " + eosEventRecord.CaseId + " WHERE CASEID = " +
|
| | | eosEventRecord.ParentId;
|
| | |
|
| | | command.CommandText = sqlStmt;
|
| | | if (command.ExecuteNonQuery() < 0)
|
| | |
| | | return false;
|
| | | }
|
| | |
|
| | | sqlStmt = "UPDATE EOS.CRTAPOLOGY SET CASEID = " + newCaseId + " WHERE CASEID = " + oldCaseId;
|
| | | sqlStmt = "UPDATE EOS.CRTAPOLOGY SET CASEID = " + eosEventRecord.CaseId + " WHERE CASEID = " +
|
| | | eosEventRecord.ParentId;
|
| | |
|
| | | command.CommandText = sqlStmt;
|
| | | if (command.ExecuteNonQuery() < 0)
|
| | |
| | | return false;
|
| | | }
|
| | |
|
| | | sqlStmt = "UPDATE EOS.EVENTAFFECT SET CASEID = " + newCaseId + " WHERE CASEID = " + oldCaseId;
|
| | | sqlStmt = "UPDATE EOS.EVENTAFFECT SET CASEID = " + eosEventRecord.CaseId + " WHERE CASEID = " +
|
| | | eosEventRecord.ParentId;
|
| | |
|
| | | command.CommandText = sqlStmt;
|
| | | if (command.ExecuteNonQuery() < 0)
|
| | |
| | | // return false;
|
| | | // }
|
| | |
|
| | | sqlStmt = "UPDATE OCSDB.LOCKFEATURE SET DESCRIPTION = '" + newAcceptNum +
|
| | | sqlStmt = "UPDATE OCSDB.LOCKFEATURE SET DESCRIPTION = '" + eosEventRecord.AcceptNum +
|
| | | "' WHERE DESCRIPTION = (SELECT ACCEPTNUM FROM "
|
| | | + "EOS.EVENTRECORD WHERE CASEID = " + oldCaseId + ")";
|
| | | + "EOS.EVENTRECORD WHERE CASEID = " + eosEventRecord.ParentId + ")";
|
| | |
|
| | | command.CommandText = sqlStmt;
|
| | | if (command.ExecuteNonQuery() < 0)
|
| | |
| | | return true;
|
| | | }
|
| | |
|
| | | private bool UpdateRecuseOrder(Object.EOSEventRecord eosEventRecord)
|
| | | private bool UpdateRecuseOrder(OracleConnection conn, OracleTransaction trx, EOSEventRecord eosEventRecord, bool upLevel)
|
| | | {
|
| | | int rank = 999;
|
| | | int priority = 1;
|
| | | var rank = 999;
|
| | | var priority = 1;
|
| | | OracleCommand command = null;
|
| | |
|
| | | /* 單純的子案件或不需升級的交辦案件,不需要更新EOS.RESCUE_ORDER */
|
| | | if ((eosEventRecord.ParentId != 0) && !(_upLevel))
|
| | | if ((eosEventRecord.ParentId != 0) && !upLevel)
|
| | | {
|
| | | return true;
|
| | | }
|
| | |
| | | try
|
| | | {
|
| | | string sqlStmt;
|
| | | if (_upLevel)
|
| | | if (upLevel)
|
| | | {
|
| | | /* 將原先母案件的編號改為新的母案件編號 */
|
| | | sqlStmt = "UPDATE EOS.RESCUE_ORDER SET CASEID = " + eosEventRecord.CaseId + " WHERE CASEID = " +
|
| | | eosEventRecord.ParentId +
|
| | | " AND DSUFID = " + eosEventRecord.LocateEquipment.DsUfid;
|
| | |
|
| | | command = new OracleCommand(sqlStmt, _connectionTpc, _transaction);
|
| | | command = new OracleCommand(sqlStmt, conn, trx);
|
| | | if (command.ExecuteNonQuery() <= 0)
|
| | | {
|
| | | Logger.Error("無法更新EOS.RESCUE_ORDER: 無法將原先母案件的編號改為新的母案件編號.");
|
| | |
| | | /* 找出該饋線的等級 */
|
| | | sqlStmt = "SELECT RANK FROM EOS.IMP_FEEDER WHERE FEEDERID = " + eosEventRecord.FdrId;
|
| | |
|
| | | command = new OracleCommand(sqlStmt, _connectionTpc, _transaction);
|
| | | OracleDataReader reader = command.ExecuteReader();
|
| | | command = new OracleCommand(sqlStmt, conn, trx);
|
| | | var reader = command.ExecuteReader();
|
| | |
|
| | | if (reader.Read())
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | /* 將本身資料存入資料庫內 */
|
| | | sqlStmt = "INSERT INTO EOS.RESCUE_ORDER (CASEID,RANK,PRIORITY,DSUFID) VALUES (" + eosEventRecord.CaseId +
|
| | | sqlStmt = "INSERT INTO EOS.RESCUE_ORDER (CASEID,RANK,PRIORITY,DSUFID) VALUES (" +
|
| | | eosEventRecord.CaseId +
|
| | | "," + rank + ","
|
| | | + (priority + 1) + "," + eosEventRecord.LocateEquipment.DsUfid + ")";
|
| | |
|
| | |
| | | }
|
| | |
|
| | | // 當原先同一用戶在事故受理後又報案,不過從一般案件轉為交辦案件所需作的轉換工作
|
| | | private bool DeleteOldCase(Object.EOSEventRecord eosEventRecord)
|
| | | private bool DeleteOldCase(OracleConnection conn, OracleTransaction trx, EOSEventRecord eosEventRecord)
|
| | | {
|
| | | string sqlStmt;
|
| | | int caseId = 0; // 原先的事故號碼
|
| | | int caseType = GlobalVariable.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 = '" +
|
| | | eosEventRecord.Meter + "' AND R.CASEID <> "
|
| | | + eosEventRecord.CaseId + " AND E.CASESTATUS <= " + CCSCaseState.WaitForSponsor;
|
| | | var 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 = '" +
|
| | | eosEventRecord.Meter + "' AND R.CASEID <> "
|
| | | + eosEventRecord.CaseId + " AND E.CASESTATUS <= " + CCSCaseState.WaitForSponsor;
|
| | |
|
| | | try
|
| | | {
|
| | | command = new OracleCommand(sqlStmt, _connectionTpc, _transaction);
|
| | | OracleDataReader reader = command.ExecuteReader();
|
| | | command = new OracleCommand(sqlStmt, conn, trx);
|
| | | var reader = command.ExecuteReader();
|
| | |
|
| | | var caseId = 0; // 原先的事故號碼
|
| | | var count = 0; // 原先的來電次數
|
| | | 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();
|
| | | }
|
| | |
| | | catch (Exception e)
|
| | | {
|
| | | Logger.Error(e, e.Message);
|
| | |
|
| | | if (command != null)
|
| | | command.Dispose();
|
| | |
|
| | | command?.Dispose();
|
| | | return false;
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | private bool InsertIntoSri(Object.EOSEventRecord eosEventRecord)
|
| | | private bool InsertIntoSri(OracleConnection conn, OracleTransaction trx, EOSEventRecord eosEventRecord)
|
| | | {
|
| | | int count = 0;
|
| | | OracleCommand command = null;
|
| | | var count = 0;
|
| | | OracleCommand command;
|
| | | OracleDataReader reader = null;
|
| | |
|
| | | var sqlStmt = "SELECT COUNT(*) AS COUNT FROM OCSDB.SRI WHERE SCENENAME = '" + eosEventRecord.AcceptNum + "'";
|
| | |
|
| | | try
|
| | | {
|
| | | command = new OracleCommand(sqlStmt, _connectionTpc, _transaction);
|
| | | command = new OracleCommand(sqlStmt, conn, trx);
|
| | | reader = command.ExecuteReader();
|
| | |
|
| | | if (reader.Read())
|
| | |
| | | return true;
|
| | | }
|
| | |
|
| | | private bool SaveCustomerTel(Object.EOSEventRecord eosEventRecord)
|
| | | private bool SaveCustomerTel(OracleConnection conn, OracleTransaction trx, EOSEventRecord eosEventRecord)
|
| | | {
|
| | | // 無電號資料
|
| | | /*
|
| | |
| | | var sqlStmt = "UPDATE BASEDB.METER SET TELE_NUMB = '" + eosEventRecord.Tel.Trim() + "' WHERE METR_NUMB = '" +
|
| | | eosEventRecord.Meter + "'";
|
| | |
|
| | | OracleCommand command = new OracleCommand(sqlStmt, _connectionTpc, _transaction);
|
| | | var command = new OracleCommand(sqlStmt, conn, trx);
|
| | |
|
| | | try
|
| | | {
|