📄 modifypassword.cs
字号:
namespace Imps.Client.Core.Password
{
using Imps.Client.Base;
using Imps.Client.Core;
using Imps.Client.Utils;
using Imps.Utils;
using System;
using System.IO;
using System.Net;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Xml;
public class ModifyPassword
{
private const string BasicServiceEnum = "Imps";
private const string externalOrderFlag = "0";
private const string FeeText = "FeeText";
private const string NoExisitMobileNo = "13910000000";
private const string RequestSource = "Client.Pc.RichClient.";
private const int SendSuccssNotify = 1;
private const string SizeValue = "L";
private const string SvcAgreement = "SvcAgreement";
public static event EventHandler<CertPicEventArgs> OnCertPicRecived;
public static event EventHandler<CertSmsEventArgs> OnSmsCertCodeRequestSended;
public static event EventHandler<HttpAppEventArgs> OnSubmit;
public static event EventHandler<SysCfgEventArgs> OnSysCfgRecived;
public static void GetCertPic(PasswordData args)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(ModifyPassword.InnerGetCertPic), args);
}
public static void GetSmsCertCode(PasswordData args)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(ModifyPassword.InnerGetSmsCertCode), args);
}
public static void GetSysCfg(PasswordData args)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(ModifyPassword.InnerGetSysCfg), args);
}
internal static void InnerGetCertPic(object args)
{
Thread.CurrentThread.Name = "[ModifyPassword]--[GetCertPic]";
PasswordData data = args as PasswordData;
CertPicEventArgs e = new CertPicEventArgs();
if ((data != null) && (data.UriGetPic.Length > 0))
{
int statusCode = 0;
string xml = string.Empty;
try
{
using (HttpWebResponse response = ((HttpWebResponse) ConnectionFactory.CreateHttpWebRequest(data.UriGetPic, null, false, false).GetResponse()))
{
statusCode = Convert.ToInt32(response.StatusCode);
using (Stream stream = response.GetResponseStream())
{
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
{
xml = reader.ReadToEnd();
}
}
}
}
catch (WebException exception)
{
using (HttpWebResponse response2 = (exception.Response as HttpWebResponse))
{
if (response2 != null)
{
statusCode = (int) response2.StatusCode;
using (Stream stream2 = response2.GetResponseStream())
{
using (StreamReader reader2 = new StreamReader(stream2, Encoding.UTF8))
{
xml = reader2.ReadToEnd();
}
goto Label_0129;
}
}
e.ErrorMessage = "无法连接服务器,请检查您电脑的网络环境!";
}
Label_0129:
e.WebException = exception;
ClientLogger.WriteBizOperation("修改密码——获取图片验证码", exception.ToString(), 20);
}
catch (Exception exception2)
{
e.ErrorMessage = "未知错误!";
ClientLogger.WriteBizOperation("修改密码——获取图片验证码", exception2.ToString(), 20);
}
finally
{
e.HttpStautsCode = statusCode;
e.ResponseBody = xml;
}
if (xml.Length > 0)
{
XmlDocument document = new XmlDocument();
try
{
document.LoadXml(xml);
XmlNode node = document.DocumentElement.SelectSingleNode("pic-certificate");
XmlNode node2 = document.DocumentElement.SelectSingleNode("error");
if (node != null)
{
e.SessionID = node.Attributes["id"].Value;
e.CertPic = ImageHelper.Base64ToImage(node.Attributes["pic"].Value);
}
if (node2 != null)
{
int num2 = 0;
int.TryParse(node2.Attributes["code"].Value, ref num2);
e.ProvisionErrorCode = num2;
e.ErrorMessage = "获取图片验证码失败!";
e.CertPic = null;
}
}
catch (Exception exception3)
{
e.ErrorMessage = "未知错误!";
ClientLogger.WriteBizOperation("修改密码——获取图片验证码", exception3.ToString(), 20);
}
}
}
FuncDispatcher.InvokeEventHandlerInUiThread<CertPicEventArgs>(null, OnCertPicRecived, e);
}
internal static void InnerGetSmsCertCode(object args)
{
Thread.CurrentThread.Name = "[ModifyPassword]--[Get SMS]";
PasswordData data = args as PasswordData;
CertSmsEventArgs e = new CertSmsEventArgs();
if ((data != null) && (data.UriGetSms.Length > 0))
{
string xml = string.Empty;
string s = string.Format("PicCertSessionId={0}&PicCertCode={1}&MobileNo={2}", data.PicCertSessionId, data.CertPicCode, data.MobileNo);
byte[] bytes = Encoding.UTF8.GetBytes(s);
try
{
HttpWebRequest request = ConnectionFactory.CreateHttpWebRequest(data.UriGetSms, null, true, false);
request.ContentType = "application/x-www-form-urlencoded; charset=utf-8";
request.ContentLength = bytes.Length;
using (Stream stream = request.GetRequestStream())
{
stream.Write(bytes, 0, bytes.Length);
}
using (HttpWebResponse response = ((HttpWebResponse) request.GetResponse()))
{
e.HttpStautsCode = Convert.ToInt32(response.StatusCode);
using (Stream stream2 = response.GetResponseStream())
{
using (StreamReader reader = new StreamReader(stream2, Encoding.UTF8))
{
xml = reader.ReadToEnd();
}
}
}
}
catch (WebException exception)
{
using (HttpWebResponse response2 = (exception.Response as HttpWebResponse))
{
if (response2 != null)
{
e.HttpStautsCode = Convert.ToInt32(response2.StatusCode);
using (Stream stream3 = response2.GetResponseStream())
{
using (StreamReader reader2 = new StreamReader(stream3, Encoding.UTF8))
{
xml = reader2.ReadToEnd();
}
}
}
}
e.WebException = exception;
e.ErrorMessage = string.Format("获取短信验证码过程中出现错误,错误码:{0}", ModifyPasswordBizCode.GetErrorCode(0x44f, exception));
ClientLogger.WriteBizOperation("修改密码——获取短信验证码", exception.ToString(), 20);
}
catch (Exception exception2)
{
ClientLogger.WriteBizOperation("修改密码——获取短信验证码", exception2.ToString(), 20);
}
finally
{
e.ResponseBody = xml;
}
if (!string.IsNullOrEmpty(xml))
{
XmlDocument document = new XmlDocument();
try
{
document.LoadXml(xml);
XmlNode node = document.DocumentElement.SelectSingleNode("error");
if (node != null)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -