using System; using System.ComponentModel.DataAnnotations; using System.Text; using ChangkeTec.SDMS.Model.Enums; using CK.SCP.Utils; namespace ChangkeTec.SDMS.Model { [Serializable] //声明为可序列化的 因为要写入文件中 public class CktException : ApplicationException //由用户程序引发,用于派生自定义的异常类型 { private const string SP = ";"; /// /// 默认构造函数 /// public CktException() { } public CktException(EnumErrorCode code, string indexString = null, string message = null, Exception inner = null) : base(message, inner) { Code = code; IndexString = indexString; Ex = inner; } // private ResultCode _code; // private string _indexString; public EnumErrorCode Code { get; set; } [StringLength(50)] public string IndexString { get; set; } public Exception Ex { get; set; } // public WmsException(System.Runtime.Serialization.SerializationInfo info, // System.Runtime.Serialization.StreamingContext context) : base(info, context) // { // _indexString = info.GetString(IndexString); // } public override string ToString() { var sb = new StringBuilder(); sb.Append(EnumHelper.GetDesc(Code) + SP); sb.Append(IndexString ?? "" + SP); if (!string.IsNullOrEmpty(Message)) sb.Append(Message ?? "" + SP); if (Ex != null) sb.Append(Ex); return sb.ToString(); } } }