📄 blexception.cs
字号:
using System;
namespace DingHaokai.BussinessLogic
{
public enum ExceptionType {None, Normal, Serious, Fatal, DataLoadFailed, DataValidateFailed, RecordNotFound, UpdateFailed, FieldLengthUnmatched, BillStateUnmatched}
/// <summary>
/// BLException 的摘要说明。
/// </summary>
public class BLException : Exception
{
private ExceptionType exceptionType;
private string message;
public BLException(ExceptionType exType, string message)
{
this.exceptionType = exType;
this.message = message;
}
public BLException(ExceptionType exType): this(exType, null)
{
}
public override string Message
{
get
{
string typeText = "";
if (exceptionType != ExceptionType.None)
typeText = /*CDMS.Utility.*/MessagesFactory.ExceptionMessages[exceptionType.ToString()]+":\r\n";
return typeText+message;
}
}
}
public class MessagesFactory
{
public static ExceptionMessages ExceptionMessages
{
get
{
return ExceptionMessages.Instance;
}
}
}
public class ExceptionMessages
{
private static ExceptionMessages msg;
private ExceptionMessages()
{
}
public static ExceptionMessages Instance
{
get
{
if (msg==null)
msg = new ExceptionMessages();
return msg;
}
}
public string this[string msgID]
{
get { return GetMessageText(msgID); }
set { SetMessageText(msgID, value); }
}
public string GetMessageText(string msgID)
{
string text=null;
switch (msgID)
{
case "None":
text = "";
break;
case "Normal":
text = "一般性错误";
break;
case "Serious":
text = "严重错误";
break;
case "Fatal":
text = "致命性错误";
break;
case "DataLoadFailed":
text = "加载数据失败";
break;
case "DataValidateFailed":
text = "数据验证失败";
break;
case "RecordNotFound":
text = "记录未找到";
break;
case "UpdateFailed":
text = "数据更新失败";
break;
case "FieldLengthUnmatched":
text = "在字段[{0}]中输入的值超出该字段最大长度:{1}";
break;
case "BillStateUnmatched":
text = "单据状态不符";
break;
default:
text = "未知错误";
break;
}
return text;
}
public void SetMessageText(string msgID, string msgText)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -