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; } } }