namespace AsiaINFO.SMS.APPCMPP2.MyThread.DataThread
|
{
|
using AsiaINFO.SMS.APPCMPP2;
|
using AsiaINFO.SMS.APPCMPP2.MyThread;
|
using AsiaINFO.SMS.BusinessFactory;
|
using AsiaINFO.SMS.CMPP2;
|
using AsiaINFO.SMS.Entity;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Threading;
|
|
public class ReportThread : ThreadBase
|
{
|
private SyncEvents _reportEvents;
|
private Queue<ReportInfo> _reportQueue;
|
|
public ReportThread(SyncEvents syncEvents, Queue<ReportInfo> reportQueue) : base(syncEvents)
|
{
|
if (reportQueue == null)
|
{
|
throw new Exception("ReportThread参数不能为空!");
|
}
|
this._reportQueue = reportQueue;
|
}
|
|
private void DealData(ReportInfo report)
|
{
|
try
|
{
|
if (!MTBusiness.UpdateMTInfo(report))
|
{
|
if (report.UpdateRetry < 10)
|
{
|
report.UpdateRetry++;
|
this._reportData = report;
|
Thread.Sleep(500);
|
}
|
else
|
{
|
MTBusiness.AddReportWait(report, ShareData.CurrentISMG);
|
string msg = string.Format("更新Report数据超过最大操作次数,记录Report数据 MsgID={0}", report.MSGID);
|
base.OnMsg(msg, MsgLevel.Debug);
|
}
|
}
|
}
|
catch (Exception exception)
|
{
|
string str2 = string.Format("记录Report数据错误:{0}", exception.Message);
|
if (report.DBRetry < 11)
|
{
|
report.DBRetry++;
|
this._reportData = report;
|
Thread.Sleep(0x3e8);
|
}
|
else
|
{
|
str2 = string.Format("记录Report数据错误:{0},超过最大操作次数,放弃数据", exception.Message);
|
}
|
base.OnMsg(str2, MsgLevel.Err);
|
}
|
}
|
|
protected override void Run()
|
{
|
ReportInfo report = null;
|
while (WaitHandle.WaitAny(base._syncEvents.EventArray) != 1)
|
{
|
object obj2;
|
Label_0004:
|
Monitor.Enter(obj2 = base._syncSuspendLogLockObject);
|
try
|
{
|
report = this._reportData;
|
if (report != null)
|
{
|
this.DealData(report);
|
goto Label_0004;
|
}
|
}
|
finally
|
{
|
Monitor.Exit(obj2);
|
}
|
}
|
base.Stop();
|
}
|
|
public override void Stop()
|
{
|
if ((base._thread != null) && (base._thread.ThreadState == ThreadState.Suspended))
|
{
|
base.Stop();
|
}
|
base._syncEvents.ExitThreadEvent.Set();
|
}
|
|
private ReportInfo _reportData
|
{
|
get
|
{
|
lock (((ICollection) this._reportQueue).SyncRoot)
|
{
|
if (this._reportQueue.Count > 0)
|
{
|
return this._reportQueue.Dequeue();
|
}
|
}
|
return null;
|
}
|
set
|
{
|
lock (((ICollection) this._reportQueue).SyncRoot)
|
{
|
this._reportQueue.Enqueue(value);
|
}
|
}
|
}
|
}
|
}
|