📄 mobilemailcommandhelper.cs
字号:
return false;
}
bool? isInRunningProvince = user.MobileMailInfo.IsInRunningProvince;
if (!isInRunningProvince.GetValueOrDefault() || !isInRunningProvince.get_HasValue())
{
return false;
}
if (!CheckMailStatus(user))
{
return false;
}
int? nullable4 = user.MobileMailInfo.Binding_Status;
if ((nullable4.GetValueOrDefault() != 0) || !nullable4.get_HasValue())
{
return false;
}
tmpUser = user;
string emailAdapter = user.Configuration.SystemSetting.ServerUriSetting.EmailAdapter;
if (emailAdapter.EndsWith("/"))
{
emailAdapter = emailAdapter.Substring(0, emailAdapter.Length - 1);
}
string url = emailAdapter + "/pc/GetUnReadMailNum.aspx";
try
{
using (HttpWebResponse response = ((HttpWebResponse) ConnectionFactory.CreateHttpWebRequest(url, user, false, true).GetResponse()))
{
using (Stream inStream = response.GetResponseStream())
{
XmlDocument document = new XmlDocument();
document.Load(inStream);
XmlNode node = document.DocumentElement.SelectSingleNode("result");
if (node != null)
{
int? unReadMailCount = user.MobileMailInfo.UnReadMailCount;
int? nullable2 = XmlHelper.ReadXmlAttributeInt32(node, "mail_count");
int? nullable5 = nullable2;
if ((nullable5.GetValueOrDefault() == -1) && nullable5.get_HasValue())
{
int num = XmlHelper.ReadXmlAttributeInt32(node, "interval", 0);
if (num <= 10)
{
num = 10;
}
if (GlobalTimer.IsHandlerRegistered(new EventHandler(MobileMailCommandHelper.RegisterGetUnReadEmail)))
{
GlobalTimer.Unregister(new EventHandler(MobileMailCommandHelper.RegisterGetUnReadEmail));
}
GlobalTimer.Register(new EventHandler(MobileMailCommandHelper.RegisterGetUnReadEmail), (int) (num * 10));
}
else
{
int? nullable6 = unReadMailCount;
int? nullable7 = nullable2;
if ((nullable6.GetValueOrDefault() != nullable7.GetValueOrDefault()) || (nullable6.get_HasValue() != nullable7.get_HasValue()))
{
user.MobileMailInfo.UnReadMailCount = nullable2;
user.MobileMailInfo.OnUnReadMailChanged();
}
if (GlobalTimer.IsHandlerRegistered(new EventHandler(MobileMailCommandHelper.RegisterGetUnReadEmail)))
{
GlobalTimer.Unregister(new EventHandler(MobileMailCommandHelper.RegisterGetUnReadEmail));
}
GlobalTimer.Register(new EventHandler(MobileMailCommandHelper.RegisterGetUnReadEmail), 0x708);
}
}
}
}
return true;
}
catch (Exception exception)
{
ClientLogger.WriteGeneral("获取未读邮件个数", exception.Message + "\r\nUrl: " + url, 10);
return false;
}
}
public static void RegisterGetUnReadEmail(object sender, EventArgs e)
{
ThreadPool.QueueUserWorkItem(delegate {
GetUnReadMailNum(tmpUser);
});
}
public static bool SendBindRequest(User user)
{
if (user == null)
{
return false;
}
bool? isInRunningProvince = user.MobileMailInfo.IsInRunningProvince;
if (!isInRunningProvince.GetValueOrDefault() && isInRunningProvince.get_HasValue())
{
return false;
}
string emailAdapter = user.Configuration.SystemSetting.ServerUriSetting.EmailAdapter;
if (emailAdapter.EndsWith("/"))
{
emailAdapter = emailAdapter.Substring(0, emailAdapter.Length - 1);
}
string url = emailAdapter + "/pc/SendBingRequest.aspx";
try
{
using (HttpWebResponse response = ((HttpWebResponse) ConnectionFactory.CreateHttpWebRequest(url, user, false, true).GetResponse()))
{
if (response.StatusCode == HttpStatusCode.PartialContent)
{
user.MobileMailInfo.IsInRunningProvince = false;
user.MobileMailInfo.OnValueChange();
return false;
}
using (Stream inStream = response.GetResponseStream())
{
XmlDocument document = new XmlDocument();
document.Load(inStream);
XmlNode node = document.DocumentElement.SelectSingleNode("result");
if (node != null)
{
user.MobileMailInfo.Alias = XmlHelper.ReadXmlAttributeString(node, "alias");
if (user.MobileMailInfo.Alias == string.Empty)
{
user.MobileMailInfo.Alias = user.Sid.ToString();
}
user.MobileMailInfo.Binding_Status = 0;
user.MobileMailInfo.OnValueChange();
return true;
}
}
}
}
catch (Exception exception)
{
ClientLogger.WriteGeneral("绑定手机邮箱", exception.Message + "\r\nUrl: " + url, 10);
GetMobileMailBoxBindInfo(user);
throw exception;
}
return true;
}
public static void SendBindRequestAsync(User user)
{
ThreadPool.QueueUserWorkItem(delegate {
MobileEmailOperateEventArgs e = new MobileEmailOperateEventArgs();
try
{
bool flag = SendBindRequest(user);
e.Result = flag;
}
catch (Exception exception)
{
e.InnerException = exception;
}
user.MobileMailInfo.OnOperateReturn(e);
});
}
public static bool SendCancelBindRequest(User user)
{
if (user == null)
{
return false;
}
bool? isInRunningProvince = user.MobileMailInfo.IsInRunningProvince;
if (!isInRunningProvince.GetValueOrDefault() && isInRunningProvince.get_HasValue())
{
return false;
}
string emailAdapter = user.Configuration.SystemSetting.ServerUriSetting.EmailAdapter;
if (emailAdapter.EndsWith("/"))
{
emailAdapter = emailAdapter.Substring(0, emailAdapter.Length - 1);
}
string url = emailAdapter + "/pc/SendCancelBingRequest.aspx";
try
{
using (HttpWebResponse response = ((HttpWebResponse) ConnectionFactory.CreateHttpWebRequest(url, user, false, true).GetResponse()))
{
if (response.StatusCode == HttpStatusCode.OK)
{
user.MobileMailInfo.Binding_Status = 1;
user.MobileMailInfo.OnValueChange();
}
}
}
catch (Exception exception)
{
ClientLogger.WriteGeneral("绑定手机邮箱", exception.Message + "\r\nUrl: " + url, 10);
GetMobileMailBoxBindInfo(user);
throw exception;
}
return true;
}
public static void SendCancelBindRequestAsync(User user)
{
ThreadPool.QueueUserWorkItem(delegate {
MobileEmailOperateEventArgs e = new MobileEmailOperateEventArgs();
try
{
bool flag = SendCancelBindRequest(user);
e.Result = flag;
}
catch (Exception exception)
{
e.InnerException = exception;
}
user.MobileMailInfo.OnOperateReturn(e);
});
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -