领胜LDS 键盘AOI检测项目
xcd
2020-06-30 aaae1139f2bb3a55910fff0aa907b3ba6395deea
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
using Bro.Common.Helper;
using System;
 
namespace Bro.Common.Model
{
    public class ResponseMessage
    {
        public ResponseMessage() { }
 
        public int Code { get; set; }
 
        public bool Result { get; set; } = true;
 
        public Info Info { get; set; } = new Info();
 
        public string DataJson { get; set; }
 
        public void GetMessageFromException(Exception ex)
        {
            //if (ex is ICustomizdException)
            //{
            //    ICustomizdException ie = ex as ICustomizdException;
            //    Code = (int)ie.Level;
            //    Info = ie.Info;
            //}
            //else if (ex is DbEntityValidationException)
            //{
            //    DbEntityValidationException deve = ex as DbEntityValidationException;
            //    Code = 9992;
            //    deve.EntityValidationErrors.ToList().ForEach(error =>
            //    {
            //        DbEntityValidationResult temp = error as DbEntityValidationResult;
            //        temp.ValidationErrors.ToList().ForEach(err =>
            //        {
            //            Info.Title += (err.ErrorMessage + ";");
            //        });
            //    });
 
            //    Info.Title.TrimEnd(';');
            //    Info.Detail = ex.GetExceptionMessage();
            //}
            //else
            {
                Code = 9999;
                Info = new Info("系统未处理异常,请联系管理员", ex.GetExceptionMessage());
            }
 
            Result = false;
        }
    }
 
    public class Info
    {
        public Info() { }
 
        public Info(string _title, string _detail = "")
        {
            Title = _title;
            Detail = _detail;
        }
        public string Title { get; set; }
 
        public string Detail { get; set; }
    }
}