📄 loginexception.cs
字号:
namespace Imps.Client.Core
{
using Imps.Client.Resource;
using System;
using System.Net;
using System.Runtime.Serialization;
[Serializable]
public class LoginException : Exception
{
private int bizCode;
private int errorCode;
private ExceptionType exType;
private const int httpOk = 200;
private string plainText;
private LoginStage stage;
public LoginException()
{
this.exType = ExceptionType.WebException;
}
public LoginException(string message) : base(message)
{
this.exType = ExceptionType.WebException;
}
protected LoginException(SerializationInfo info, StreamingContext context) : base(info, context)
{
this.exType = ExceptionType.WebException;
}
public LoginException(string message, Exception inner) : base(message, inner)
{
this.exType = ExceptionType.WebException;
}
private string GetErrorExplain(int _bizCode, int _errorCode)
{
string text = string.Format("{0}{1}。", _bizCode, _errorCode);
switch (_errorCode)
{
case 0x578:
case 0x579:
case 0x57a:
case 0x57b:
case 0x57c:
case 0x57d:
case 0x57e:
text = text + "您可能遇到了网络问题或服务器故障,";
break;
case 0x57f:
text = text + "由于网络问题,无法链接服务器,";
break;
case 0x580:
text = text + "您遇到了临时性网络故障,请稍候重试,";
break;
case 0x581:
case 0x582:
case 0x583:
case 0x584:
case 0x585:
case 0x586:
case 0x587:
case 0x588:
case 0x589:
case 0x5dc:
case 0x5dd:
text = text + "您可能遇到了网络问题或服务器故障,";
break;
case 0x5de:
text = text + "您的计算机网络连接出现问题,导致连接服务器错误,";
break;
case 0x5df:
text = text + "您可能遇到了网络问题或服务器故障,";
break;
case 0x5e0:
text = text + "您的计算机网络连接出现问题,客户端没有响应服务器的请求,";
break;
case 0x5e1:
text = text + "您可能遇到了网络问题或服务器故障,";
break;
case 0x641:
text = text + "您可能遇到了网络问题或服务器故障,";
break;
case 0x642:
text = text + "您的网络环境或防火墙限制了访问服务器的请求,";
break;
case 0x643:
text = text + "您的计算机网络连接出现问题,无法连接代理服务器域名,";
break;
case 0x644:
text = text + "您可能遇到了临时性的网络故障,";
break;
case 0x645:
text = text + "您的网络环境对链接进行了特殊的限制。或者代理服务器不允许https(安全通道)访问外部网页,";
break;
case 0x646:
case 0x647:
text = text + "您可能遇到了网络问题或服务器故障,";
break;
case 0x648:
text = text + "您遇到了数据传输错误,";
break;
case 0x649:
text = text + "您使用的代理服务器/路由器/防火墙上限制了网络数据包的大小,";
break;
case 0x64a:
text = text + "您的网络繁忙,导致请求失败,";
break;
case 0x64b:
text = text + "您和服务器之间无法建立链接,";
break;
case 0x64c:
text = text + "您的联网设置或代理错误,导致协议错误,";
break;
case 0x64d:
text = text + "您的计算机网络连接出现问题,客户端没有接收到完整的信息,";
break;
case 0x64e:
text = text + "您遇到了异常错误,客户端取消了服务器的请求,";
break;
case 0x650:
text = text + "您的计算机网络连接出现问题,无法连接服务器并运行客户端请求,";
break;
case 0x651:
case 0x652:
text = text + "您可能遇到了网络问题或服务器故障,";
break;
case 0x653:
text = text + "您遇到了一般性网络故障,";
break;
case 0x654:
case 0x655:
case 0x70d:
text = text + "您的计算机网络连接出现问题,";
break;
case 0xb54:
text = text + "您可能遇到了短暂网络错误,";
break;
case 0xb55:
text = text + "您遇到了短暂的网络错误或服务器故障,";
break;
case 0x708:
text = text + "您当时可能遇到了网络设备(网卡、网线、无线网络)故障,";
break;
}
int num2 = _bizCode;
if (num2 <= 0x3f9)
{
switch (num2)
{
case 0x3e8:
case 0x3e9:
case 0x3ea:
case 0x3eb:
case 0x3ec:
case 0x3ed:
return (text + "请您检查网络设置后再次尝试。如需帮助,请拨打客服电话10086。");
case 0x3ee:
case 0x3ef:
case 0x3f0:
case 0x3f1:
return text;
case 0x3f2:
return (text + "无法获取您的注册信息。请您检查网络设置后再次尝试。如需帮助,请拨打客服电话10086。");
case 0x3f7:
case 0x3f9:
goto Label_037E;
case 0x3f8:
return text;
}
return text;
}
switch (num2)
{
case 0x3fc:
case 0x401:
goto Label_037E;
case 0x406:
return (text + "无法获取您的个人信息。请您检查网络设置后再次尝试。如需帮助,请拨打客服电话10086。");
default:
return text;
}
Label_037E:
return (text + "无法获取您的联系人列表。请您检查网络设置后再次尝试。如需帮助,请拨打客服电话10086。");
}
private void HandleSipCException()
{
this.bizCode = (int) this.Stage;
SipCException exception = base.InnerException as SipCException;
if (exception != null)
{
switch (exception.SipCStatusCode)
{
case 0x194:
this.errorCode = 0x194;
this.plainText = StringTable.MsgLoginServiceClosed;
goto Label_0092;
case 0x20a:
this.errorCode = 0x20a;
this.plainText = StringTable.MsgLoginNotIicUser;
goto Label_0092;
}
int.TryParse(string.Format("2{0}", exception.SipCStatusCode), ref this.errorCode);
}
else
{
this.errorCode = 0xbb7;
}
Label_0092:
if (string.IsNullOrEmpty(this.plainText))
{
this.plainText = string.Format(StringTable.MsgLoginFailedWithCode, this.GetErrorExplain(this.bizCode, this.errorCode));
}
}
private void HandleWebException()
{
this.bizCode = (int) this.Stage;
WebException wEx = base.InnerException as WebException;
if (wEx == null)
{
this.errorCode = 0x7cf;
}
else
{
this.errorCode = ExceptionHandler.HandleWebException(wEx);
int statusCode = 200;
HttpWebResponse response = wEx.Response as HttpWebResponse;
if (response != null)
{
statusCode = (int) response.StatusCode;
}
switch (this.Stage)
{
case LoginStage.LoginToSSIPortal:
switch (statusCode)
{
case 0x191:
this.plainText = StringTable.User.MsgUnauthorization;
goto Label_00B2;
case 0x194:
this.plainText = StringTable.MsgLoginNotIicUser;
break;
}
goto Label_00B2;
case LoginStage.RetriveUri:
if (statusCode == 0x194)
{
this.plainText = StringTable.MsgLoginServiceClosed;
}
goto Label_00B2;
}
}
Label_00B2:
if (string.IsNullOrEmpty(this.plainText))
{
this.plainText = string.Format(StringTable.MsgLoginFailedWithCode, this.GetErrorExplain(this.bizCode, this.errorCode));
}
}
public int BizCode
{
get
{
return this.bizCode;
}
}
public int ErrorCode
{
get
{
return this.errorCode;
}
}
public ExceptionType ExType
{
get
{
return this.exType;
}
set
{
this.exType = value;
}
}
public string PlainText
{
get
{
switch (this.ExType)
{
case ExceptionType.WebException:
this.HandleWebException();
goto Label_00CE;
case ExceptionType.XmlException:
case ExceptionType.XPathException:
this.bizCode = (int) this.Stage;
this.errorCode = (int) this.ExType;
if (this.errorCode < 0x3e8)
{
int.TryParse(string.Format("1{0}", this.errorCode), ref this.errorCode);
}
this.plainText = string.Format(StringTable.MsgLoginFailedWithCode, this.GetErrorExplain(this.bizCode, this.errorCode));
goto Label_00CE;
case ExceptionType.SSIAuthException:
this.plainText = StringTable.User.MsgUnauthorization;
break;
case ExceptionType.SipCException:
this.HandleSipCException();
break;
}
Label_00CE:
if (string.IsNullOrEmpty(this.plainText))
{
this.plainText = StringTable.MsgLoginFailed;
}
return this.plainText;
}
}
public LoginStage Stage
{
get
{
return this.stage;
}
set
{
this.stage = value;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -