| | |
| | |
|
| | | public class ProcessEvent
|
| | | {
|
| | | private static Logger logger = LogManager.GetCurrentClassLogger();
|
| | | private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
| | |
|
| | | private readonly OracleConnection _connectionTpc;
|
| | | private readonly CcsRecord _mCcsRecord;
|
| | |
|
| | | private EventRecord _mEventRecord;
|
| | | private readonly RecordLog _pLog;
|
| | | private readonly string _traceConnectionString = string.Empty;
|
| | | private OracleTransaction _trx;
|
| | |
|
| | |
| | | _mCcsRecord = record;
|
| | | _connectionTpc = conn;
|
| | | _traceConnectionString = traceConnection;
|
| | | _pLog = new RecordLog(GlobalVariable.CcsListPath + record.CcsId + ".txt");
|
| | | }
|
| | |
|
| | | public event ThreadEndEventHandler ThreadFinish;
|
| | |
| | | */
|
| | | if (InitialEventRecord(_mCcsRecord.CcsId))
|
| | | {
|
| | | var mLeach = new Leach(_connectionTpc, _trx, _traceConnectionString, _pLog); // 案件過濾與合併
|
| | | _pLog.Info("過濾案件...");
|
| | | var mLeach = new Leach(_connectionTpc, _trx, _traceConnectionString); // 案件過濾與合併
|
| | | Logger.Info("過濾案件...");
|
| | | var returnStatus = mLeach.LeachCase(_mEventRecord);
|
| | |
|
| | | switch (returnStatus)
|
| | | {
|
| | | case GlobalVariable.Success:
|
| | | _pLog.Info("案件過濾完畢....");
|
| | | Logger.Info("案件過濾完畢....");
|
| | | Process(GlobalVariable.Success);
|
| | | break;
|
| | |
|
| | | case GlobalVariable.NoMeter:
|
| | | _pLog.Info("案件過濾完畢,用戶無電號....");
|
| | | Logger.Info("案件過濾完畢,用戶無電號....");
|
| | | _mEventRecord.TraceFinish = GlobalVariable.TraceFinish;
|
| | | Process(GlobalVariable.NoMeter);
|
| | | break;
|
| | |
|
| | | case GlobalVariable.SameCustomer:
|
| | | _pLog.Info("相同用戶重複來電....");
|
| | | Logger.Info("相同用戶重複來電....");
|
| | | ProcessSameCustomer(_mCcsRecord, _mEventRecord);
|
| | | break;
|
| | |
|
| | | case GlobalVariable.NoSupplyElc:
|
| | | _pLog.Warn("該饋線未供電,無法作事故案件追蹤合併....");
|
| | | Logger.Warn("該饋線未供電,無法作事故案件追蹤合併....");
|
| | | _mEventRecord.TraceFinish = GlobalVariable.TraceFinish;
|
| | | Process(GlobalVariable.NoMeter);
|
| | | break;
|
| | |
|
| | | case GlobalVariable.NoSxfmr:
|
| | | _pLog.Warn("該案件無變壓器....");
|
| | | Logger.Warn("該案件無變壓器....");
|
| | | _mEventRecord.TraceFinish = GlobalVariable.TraceFinish;
|
| | | Process(GlobalVariable.NoMeter);
|
| | | break;
|
| | |
|
| | | case GlobalVariable.CaseTypeChanged:
|
| | | _pLog.Info("變更案件狀態....");
|
| | | Logger.Info("變更案件狀態....");
|
| | | Process(GlobalVariable.CaseTypeChanged);
|
| | | break;
|
| | |
|
| | | case GlobalVariable.TraceFailure:
|
| | | _pLog.Error("故障追蹤錯誤,以一般無電號案件方式受理....");
|
| | | Logger.Error("故障追蹤錯誤,以一般無電號案件方式受理....");
|
| | | _mEventRecord.TraceFinish = GlobalVariable.TraceFinish;
|
| | | Process(GlobalVariable.NoMeter);
|
| | | break;
|
| | |
| | | _trx.Dispose();
|
| | |
|
| | | if (returnStatus == GlobalVariable.CaseTransfer)
|
| | | _pLog.Error("案件已移轉,此事故案件暫不被受理....");
|
| | | Logger.Error("案件已移轉,此事故案件暫不被受理....");
|
| | | else if (returnStatus == GlobalVariable.FailureByDb)
|
| | | _pLog.Error("資料庫錯誤,此事故案件暫不被受理....");
|
| | | Logger.Error("資料庫錯誤,此事故案件暫不被受理....");
|
| | | else if (returnStatus == GlobalVariable.FdrLocked)
|
| | | _pLog.Error("饋線被鎖定,此事故案件暫不被受理....");
|
| | | Logger.Error("饋線被鎖定,此事故案件暫不被受理....");
|
| | | else
|
| | | _pLog.Error("發生非預期錯誤,此事故案件暫不被受理....");
|
| | | Logger.Error("發生非預期錯誤,此事故案件暫不被受理....");
|
| | |
|
| | | if (traceCount == 0)
|
| | | UpdateTraceCount(_mCcsRecord.CcsId, true);
|
| | |
| | | if (returnStatus == GlobalVariable.TraceCounts3)
|
| | | _mEventRecord.Note = _mEventRecord.Note+ "(本案用戶供電資料追蹤失敗)";
|
| | |
|
| | | _pLog.Error("事故案件處理次數3次,仍無法正常處理,以一般無電號案件方式受理....");
|
| | | Logger.Error("事故案件處理次數3次,仍無法正常處理,以一般無電號案件方式受理....");
|
| | | _mEventRecord.TraceFinish = GlobalVariable.TraceFinish;
|
| | | Process(GlobalVariable.NoMeter);
|
| | | sendMail = true;
|
| | |
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine("Error = " + e.Message + ". CCSID = " + _mCcsRecord.CcsId);
|
| | | _pLog.Error("Error = " + e.Message + ". CCSID = " + _mCcsRecord.CcsId);
|
| | | Logger.Error(e, e.Message + ". CCSID = " + _mCcsRecord.CcsId);
|
| | |
|
| | | if (_trx != null)
|
| | | {
|
| | |
| | | }
|
| | | finally
|
| | | {
|
| | | _pLog.Close();
|
| | | CcsMain.ProcessCases.Remove(_mCcsRecord.CcsId);
|
| | | OnThreadFinish(new ThreadEndEvent(_connectionTpc));
|
| | | }
|
| | |
| | |
|
| | | try
|
| | | {
|
| | | if (finishEvent.Finish(kind, _mEventRecord, _connectionTpc, _trx, _pLog))
|
| | | if (finishEvent.Finish(kind, _mEventRecord, _connectionTpc, _trx))
|
| | | {
|
| | | _pLog.Info("OMS資料更新成功!");
|
| | | Logger.Info("OMS資料更新成功!");
|
| | | if (UpdateCcsData(_mEventRecord, _mCcsRecord, (int) CCSCaseState.WaitForDespatch))
|
| | | {
|
| | | _pLog.Info("CCS資料更新成功!");
|
| | | Logger.Info("CCS資料更新成功!");
|
| | | }
|
| | | else
|
| | | {
|
| | |
| | | _trx.Rollback();
|
| | |
|
| | | _trx.Dispose();
|
| | | _pLog.Error("CCS資料更新程序發生錯誤!");
|
| | | Logger.Error("CCS資料更新程序發生錯誤!");
|
| | | return;
|
| | | }
|
| | |
|
| | |
| | | _trx.Commit();
|
| | | _trx.Dispose();
|
| | | ;
|
| | | var alarmClient = new AlarmData(_connectionTpc, _trx, _pLog);
|
| | | var alarmClient = new AlarmData(_connectionTpc, _trx);
|
| | | alarmClient.Alarm(_mEventRecord.AcceptNum, _mEventRecord.Dept);
|
| | | }
|
| | | else
|
| | |
| | |
|
| | | _trx.Dispose();
|
| | | ;
|
| | | _pLog.Error("OMS資料更新程序發生錯誤!");
|
| | | Logger.Error("OMS資料更新程序發生錯誤!");
|
| | | }
|
| | | _pLog.Info("CCS 案件受理程序結束.");
|
| | | Logger.Info("CCS 案件受理程序結束.");
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | |
| | |
|
| | | private bool UpdateCcsData(EventRecord mRecord, CcsRecord mCcsRecord, int caseStatus)
|
| | | {
|
| | | _pLog.Info("進行CCS資料更新程序...");
|
| | | Logger.Info("進行CCS資料更新程序...");
|
| | | var eventQuery = new EventQuery();
|
| | | var status = caseStatus;
|
| | | // 設定CCSID
|
| | |
| | | }
|
| | | eventQuery.CaseStatus = status;
|
| | | // 更新CCS.EventQuery
|
| | | if (!eventQuery.Update(_pLog, _connectionTpc, _trx))
|
| | | if (!eventQuery.Update(_connectionTpc, _trx))
|
| | | {
|
| | | _pLog.Error("更新ccs.eventquery失敗!");
|
| | | Logger.Error("更新ccs.eventquery失敗!");
|
| | | return false;
|
| | | }
|
| | | _pLog.Info("更新ccs.eventquery成功!");
|
| | | Logger.Info("更新ccs.eventquery成功!");
|
| | | var numberContrast = new NumberContrast();
|
| | | numberContrast.SetAcceptNum(mRecord.AcceptNum);
|
| | | numberContrast.SetCaseId(mRecord.CaseId);
|
| | |
| | | // 更新CCS.Num_Contrast
|
| | | if (!numberContrast.Update(_connectionTpc, _trx))
|
| | | {
|
| | | _pLog.Error("更新ccs.num_contrast失敗!");
|
| | | Logger.Error("更新ccs.num_contrast失敗!");
|
| | | return false;
|
| | | }
|
| | | _pLog.Info("更新ccs.num_contrast成功!");
|
| | | Logger.Info("更新ccs.num_contrast成功!");
|
| | | return true;
|
| | | }
|
| | |
|
| | | private bool InitialEventRecord(string ccsid)
|
| | | {
|
| | | var initialData = new InitialEventData(_connectionTpc, _pLog);
|
| | | var initialData = new InitialEventData(_connectionTpc);
|
| | | var mContrast = new NumberContrast();
|
| | | DeptContrast deptContrast = null;
|
| | |
|
| | |
| | |
|
| | | if (!mContrast.Insert(_connectionTpc, _trx))
|
| | | {
|
| | | _pLog.Error("初始化寫入CCS.Num_Contrast時發生錯誤!");
|
| | | Logger.Error("初始化寫入CCS.Num_Contrast時發生錯誤!");
|
| | |
|
| | | if (_trx.Connection.State.ToString().Equals("Open"))
|
| | | _trx.Rollback();
|
| | |
| | |
|
| | | if (mAddr.Trim().Length == 0)
|
| | | {
|
| | | _pLog.Error("CCS 案件受理程序初始化失敗...地址為空白");
|
| | | Logger.Error("CCS 案件受理程序初始化失敗...地址為空白");
|
| | |
|
| | | if (_trx.Connection.State.ToString().Equals("Open"))
|
| | | _trx.Rollback();
|
| | |
| | | _mEventRecord.IsReCall = GlobalVariable.NotReCall;
|
| | | }
|
| | |
|
| | | _pLog.Info("初始化EOS.EVENTRECORD成功!");
|
| | | Logger.Info("初始化EOS.EVENTRECORD成功!");
|
| | | return true;
|
| | | }
|
| | |
|
| | |
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | _pLog.Warn("Problems occur during checking process: " + ex.Message);
|
| | | Logger.Warn(ex, "Problems occur during checking process: " + ex.Message);
|
| | | }
|
| | | finally
|
| | | {
|
| | |
| | |
|
| | | private int FindoutDeptByAddr(CcsRecord ccsRecord, OracleTransaction trx)
|
| | | {
|
| | | var addrContrast = new AddrContrast(_connectionTpc, trx, _pLog);
|
| | | var addrContrast = new AddrContrast(_connectionTpc, trx);
|
| | | return addrContrast.FindDeptId(ccsRecord.AddressCity, ccsRecord.AddressTown, ccsRecord.AddressRoad);
|
| | | }
|
| | |
|
| | |
| | | status = Convert.ToInt32(reader["CaseStatus"].ToString());
|
| | | }
|
| | | }
|
| | | catch (Exception)
|
| | | catch (Exception e)
|
| | | {
|
| | | _pLog.Warn("無法取得正確之母案件狀態.");
|
| | | Logger.Error(e, e.Message);
|
| | | Logger.Warn("無法取得正確之母案件狀態.");
|
| | | }
|
| | | finally
|
| | | {
|
| | |
| | | mEventQry.EventLocation = reader["eventlocation"].ToString();
|
| | | }
|
| | | }
|
| | | catch (Exception)
|
| | | catch (Exception e)
|
| | | {
|
| | | _pLog.Warn("無法取得母案件派工資訊.");
|
| | | Logger.Error(e, e.Message);
|
| | | Logger.Warn("無法取得母案件派工資訊.");
|
| | | }
|
| | | finally
|
| | | {
|
| | |
| | |
|
| | | private void ProcessSameCustomer(CcsRecord mCcsRecord, EventRecord mEventRec)
|
| | | {
|
| | | _pLog.Info("處理相同用戶重複來電...");
|
| | | Logger.Info("處理相同用戶重複來電...");
|
| | | StringBuilder note = null;
|
| | |
|
| | | var sqlStmt = "select note from eos.eventrecord where caseid = " + mEventRec.TmpCaseId;
|
| | |
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | Logger.Error(e, e.Message);
|
| | | }
|
| | | finally
|
| | | {
|
| | |
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine(e.Message);
|
| | | Logger.Error(e, e.Message);
|
| | | }
|
| | | finally
|
| | | {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | var updEosEventRecord = "update eos.eventrecord set note = '" + TrimToLimit(note.ToString(), 127)
|
| | | var updEosEventRecord = "UPDATE EOS.EVENTRECORD SET NOTE = '" + TrimToLimit(note.ToString(), 127)
|
| | | + "' where caseid = " + _mEventRecord.TmpCaseId;
|
| | | var updCcsNumContrast = "update ccs.num_contrast set(acceptnum,caseid) = (select acceptnum," +
|
| | | mEventRec.TmpCaseId + " from eos.eventrecord where caseid = " + mEventRec.TmpCaseId+
|
| | | var updCcsNumContrast = "UPDATE CCS.NUM_CONTRAST SET(acceptnum,caseid) = (SELECT acceptnum," +
|
| | | mEventRec.TmpCaseId + " FROM eos.eventrecord WHERE caseid = " + mEventRec.TmpCaseId+
|
| | | ") where ccsid='" + mCcsRecord.CcsId + "'";
|
| | |
|
| | | var exeCommand = new OracleCommand(updCcsEventQuery, _connectionTpc, _trx);
|
| | |
| | | _trx.Rollback();
|
| | |
|
| | | _trx.Dispose();
|
| | | _pLog.Error("Fail in write back to ccs.eventquery");
|
| | | Logger.Error("Fail in write back to ccs.eventquery");
|
| | | return;
|
| | | }
|
| | |
|
| | |
| | | _trx.Rollback();
|
| | |
|
| | | _trx.Dispose();
|
| | | _pLog.Error("Fail in update eos.eventquery");
|
| | | Logger.Error("Fail in update eos.eventquery");
|
| | | return;
|
| | | }
|
| | |
|
| | |
| | | _trx.Rollback();
|
| | |
|
| | | _trx.Dispose();
|
| | | _pLog.Error("Fail in insert into ccs.num_contrast");
|
| | | Logger.Error("Fail in insert into ccs.num_contrast");
|
| | | return;
|
| | | }
|
| | |
|
| | | exeCommand.Dispose();
|
| | | _trx.Commit();
|
| | | _trx.Dispose();
|
| | | _pLog.Info("CCS 案件受理程序結束");
|
| | | Logger.Info("CCS 案件受理程序結束");
|
| | | }
|
| | |
|
| | | private string TrimToLimit(string msg, int maxLen)
|
| | |
| | | {
|
| | | return msg;
|
| | | }
|
| | | msg = msg.Substring(msg.IndexOf("|") + 1);
|
| | | msg = msg.Substring(msg.IndexOf("|", StringComparison.Ordinal) + 1);
|
| | | return TrimToLimit(msg, maxLen);
|
| | | }
|
| | | catch (Exception ex)
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine(ex.StackTrace);
|
| | | Logger.Error(e, e.Message);
|
| | | return "";
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | Logger.Error(e, e.Message);
|
| | | }
|
| | | finally
|
| | | {
|
| | |
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | Logger.Error(e, e.Message);
|
| | | }
|
| | | finally
|
| | | {
|
| | |
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | Logger.Error(e, e.Message);
|
| | | }
|
| | | finally
|
| | | {
|
| | |
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | Console.WriteLine(e.Message);
|
| | | Console.WriteLine(e.StackTrace);
|
| | | Logger.Error(e, e.Message);
|
| | | }
|
| | | finally
|
| | | {
|