wzp
2021-07-28 864986e4cad03f6b9bba9a7e65379db496b62a6a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
namespace AsiaINFO.SMS.APPCMPP2.MyThread.CMPPThread
{
    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 SubmitOKThread : ThreadBase
    {
        private Queue<SubmitInfo> _submitOKQueue;
        private Queue<SubmitInfo> _submitQueue;
 
        public SubmitOKThread(SyncEvents syncEvents, Queue<SubmitInfo> submitQueue, Queue<SubmitInfo> submitOKQueue) : base(syncEvents)
        {
            if ((submitQueue == null) || (submitOKQueue == null))
            {
                throw new Exception("SubmitOKThread参数不能为空!");
            }
            this._submitQueue = submitQueue;
            this._submitOKQueue = submitOKQueue;
        }
 
        private void DealData(SubmitInfo submit)
        {
            try
            {
                MTBusiness.UpdateMTInfo(submit);
                MTBusiness.DeleteMTWait(submit.MTWait, ShareData.CurrentISMG);
            }
            catch (Exception exception)
            {
                this._submitData = submit;
                base.OnMsg("[记录SUBMIT数据错误] " + exception.Message, MsgLevel.Err);
            }
        }
 
        protected override void Run()
        {
            SubmitInfo submit = null;
            while (WaitHandle.WaitAny(base._syncEvents.EventArray) != 1)
            {
                object obj2;
            Label_0004:
                Monitor.Enter(obj2 = base._syncSuspendLogLockObject);
                try
                {
                    submit = this._submitOKData;
                    if (submit != null)
                    {
                        this.DealData(submit);
                        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 SubmitInfo _submitData
        {
            get
            {
                lock (((ICollection) this._submitQueue).SyncRoot)
                {
                    if (this._submitQueue.Count > 0)
                    {
                        return this._submitQueue.Dequeue();
                    }
                }
                return null;
            }
            set
            {
                lock (((ICollection) this._submitQueue).SyncRoot)
                {
                    this._submitQueue.Enqueue(value);
                }
            }
        }
 
        private SubmitInfo _submitOKData
        {
            get
            {
                lock (((ICollection) this._submitOKQueue).SyncRoot)
                {
                    if (this._submitOKQueue.Count > 0)
                    {
                        return this._submitOKQueue.Dequeue();
                    }
                }
                return null;
            }
            set
            {
                lock (((ICollection) this._submitOKQueue).SyncRoot)
                {
                    this._submitOKQueue.Enqueue(value);
                }
            }
        }
    }
}