patrick
2019-10-18 4e8bf084f8a04617a9f542099183b8d829fa7c4b
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
//using BroCComn.PubSub;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Bro.Common.Helper.EnumHelper;
 
namespace Bro.Common.Helper
{
    public class ProcessException : Exception
    {
        public static Action<DateTime, string, string> OnExceptionNotice;
 
        //PubSubCenter pubSub = PubSubCenter.GetInstance();
 
        /// <summary>
        /// 站点编码
        /// </summary>
        public string StationId { get; set; }
 
        /// <summary>
        /// 工位索引
        /// </summary>
        public int PositionIndex { get; set; }
 
        /// <summary>
        /// 原生异常
        /// </summary>
        public Exception OriginalException { get; set; }
 
        /// <summary>
        /// 异常编码
        /// </summary>
        public string ErrorCode { get; set; }
 
        public ProcessException()
        {
        }
 
        public ProcessException(Exception ex)
        {
            OriginalException = ex;
            ExceptionNotice();
        }
 
        //public ProcessException(string stationCode, int positionIndex)
        //{
        //    StationId = stationCode;
        //    PositionIndex = positionIndex;
        //}
 
        public ProcessException(string error, Exception ex = null) : base(error, ex)
        {
            ErrorCode = error;
            OriginalException = ex;
 
            ExceptionNotice();
        }
 
        //public ProcessException(string stationId, int positionIndex, string error, Exception ex)
        //{
        //    StationId = stationId;
        //    PositionIndex = positionIndex;
 
        //    ErrorCode = error;
        //    OriginalException = ex;
 
        //    ExceptionNotice();
        //}
 
        public void ExceptionNotice()
        {
            //pubSub.Publish(PubTag.ExceptionUpdate.ToString(), ErrorCode, OriginalException, true);
            OnExceptionNotice?.Invoke(DateTime.Now, ErrorCode, OriginalException?.GetExceptionMessage());
        }
    }
 
    public class Level3Exception : ProcessException
    {
        public Level3Exception() : base() { }
 
        public Level3Exception(string error, Exception ex) : base(error, ex) { }
    }
 
    /// <summary>
    /// 来料检测异常
    /// </summary>
    public class IncomingMaterialException : ProcessException
    {
        public IncomingMaterialException() : base() { }
 
        public IncomingMaterialException(string error, Exception ex) : base(error, ex) { }
    }
 
    public class BarcodeScanFailureException : ProcessException
    {
        public BarcodeScanFailureException() : base() { }
 
        public BarcodeScanFailureException(string msg, Exception ex) : base(msg, ex) { }
    }
}