📄 provisioning.cs
字号:
request.ContentLength = bytes.Length;
using (Stream stream = request.GetRequestStream())
{
stream.Write(bytes, 0, bytes.Length);
}
using (HttpWebResponse response = ((HttpWebResponse) request.GetResponse()))
{
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})。\r\n您可以选择继续重试,或者跳过此步骤。", ProvisionBizCode.GetErrorCode(0x455, exception));
ClientLogger.WriteBizOperation("开通服务——设置个人信息", exception.ToString(), 20);
}
catch (Exception exception2)
{
ClientLogger.WriteBizOperation("开通服务——设置个人信息", exception2.ToString(), 20);
}
finally
{
e.ResponseBody = xml;
}
if (xml.Length > 0)
{
try
{
new XmlDocument().LoadXml(xml);
goto Label_029E;
}
catch (Exception exception3)
{
if (string.IsNullOrEmpty(e.ErrorMessage))
{
e.ErrorMessage = "保存您的个人资料的时候发生错误。\r\n您可以选择继续重试,或者跳过此步骤。!";
}
ClientLogger.WriteBizOperation("开通服务——设置个人信息", exception3.ToString(), 20);
goto Label_029E;
}
}
if (string.IsNullOrEmpty(e.ErrorMessage))
{
e.ErrorMessage = "保存您的个人资料的时候发生错误。\r\n您可以选择继续重试,或者跳过此步骤。!";
}
}
Label_029E:
FuncDispatcher.InvokeEventHandlerInUiThread<HttpAppEventArgs>(null, OnPorfileUpdated, e);
}
internal static void InnerSubscribe(object data)
{
Thread.CurrentThread.Name = "[Provsion]--[Subscribe]";
ProvsionData data2 = data as ProvsionData;
SubscribeEventArgs e = new SubscribeEventArgs();
if (data2 != null)
{
int num = 0;
string xml = string.Empty;
if ((data2 != null) && (data2.ProvsionUrl.UriSubSvc.Length > 0))
{
string s = string.Format("MobileNo={0}&Password={1}&ValidateCode={2}&RequestSource={3}&ExternalOrderFlag={4}&SendSuccessNotifySms={5}&OemTag={6}", new object[] { data2.MobileNo, HttpWebRequestHelper.UrlEncode(data2.Password), data2.SmsValiCode, "Client.Pc.RichClient.", "0", 1, Configuration.FixedClientSetting.OemSetting.OemTag });
byte[] bytes = Encoding.UTF8.GetBytes(s);
try
{
HttpWebRequest request = ConnectionFactory.CreateHttpWebRequest(data2.ProvsionUrl.UriSubSvc, 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()))
{
num = 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)
{
num = Convert.ToInt32(response2.StatusCode);
using (Stream stream3 = response2.GetResponseStream())
{
using (StreamReader reader2 = new StreamReader(stream3, Encoding.UTF8))
{
xml = reader2.ReadToEnd();
}
}
}
}
e.ErrorMessage = string.Format("开通服务过程中发生错误(错误码:{0})!", ProvisionBizCode.GetErrorCode(0x451, exception));
e.WebException = exception;
ClientLogger.WriteBizOperation("开通服务——开通基础服务", exception.ToString(), 20);
}
catch (Exception exception2)
{
ClientLogger.WriteBizOperation("开通服务——开通基础服务", exception2.ToString(), 20);
}
e.HttpStautsCode = num;
if (xml.Length > 0)
{
XmlDocument document = new XmlDocument();
try
{
document.LoadXml(xml);
XmlNode node = document.DocumentElement.SelectSingleNode("user");
XmlNode node2 = document.DocumentElement.SelectSingleNode("error");
if (node != null)
{
e.Sid = node.Attributes["sid"].Value;
e.Uri = node.Attributes["uri"].Value;
bool flag = false;
bool.TryParse(node.Attributes["is-fresh-user"].Value, ref flag);
e.IsFreshUser = flag;
bool flag2 = false;
bool.TryParse(node.Attributes["is-free-user"].Value, ref flag2);
e.IsFreeUser = flag2;
data2.CurrentUser.PersonalInfo.MobileNo = data2.MobileNo;
if (!FuncLimitedSetting.SSIEncryptLoginLimited)
{
data2.CurrentUser.Password = data2.CurrentUser.HashPassword(Encoding.UTF8.GetBytes(data2.Password));
}
else
{
data2.CurrentUser.Password = data2.Password;
}
e.FreeEndMonth = node.Attributes["free-end-month"].Value;
}
if (node2 != null)
{
int num2 = 0;
int.TryParse(node2.Attributes["code"].Value, ref num2);
e.ProvisionErrorCode = num2;
}
}
catch (Exception exception3)
{
e.ErrorMessage = "开通服务过程中出现未知错误,请重试!";
ClientLogger.WriteBizOperation("开通服务——开通基础服务", exception3.ToString(), 20);
}
}
}
}
FuncDispatcher.InvokeEventHandlerInUiThread<SubscribeEventArgs>(null, OnSubscribe, e);
}
private static void LoadPersonalXmlNode(XmlNode personalNode, ProfileRetrivedEventArgs pea)
{
foreach (XmlAttribute attribute in personalNode.Attributes)
{
switch (attribute.Name)
{
case "nickname":
{
pea.Nickname = attribute.Value;
continue;
}
case "name":
{
pea.Name = attribute.Value;
continue;
}
case "portrait-crc":
{
pea.PortraitCrc = attribute.Value;
continue;
}
case "gender":
{
pea.Gender = EnumHelper.IntStrToEnum<Gender>(attribute.Value);
continue;
}
case "birthday-valid":
{
pea.BirthDateValid = attribute.Value == "1";
continue;
}
case "birth-date":
{
DateTime time;
try
{
if (!DateTime.TryParse(attribute.Value, ref time))
{
time = new DateTime(0x76c, 1, 1);
}
}
catch
{
time = new DateTime(0x76c, 1, 1);
}
pea.BirthDate = new DateTime?(time);
continue;
}
case "profile":
{
pea.Notes = attribute.Value;
continue;
}
case "blood-type":
{
pea.BloodType = EnumHelper.IntStrToEnum<BloodType>(attribute.Value);
continue;
}
case "job-title":
{
pea.JobTitle = attribute.Value;
continue;
}
case "home-phone":
{
pea.HomePhone = attribute.Value;
continue;
}
case "work-phone":
{
pea.WorkPhone = attribute.Value;
continue;
}
case "other-phone":
{
pea.OtherPhone = attribute.Value;
continue;
}
case "work-email":
{
pea.WorkEmail = attribute.Value;
continue;
}
case "personal-email":
{
pea.PersonalEmail = attribute.Value;
continue;
}
case "other-email":
{
pea.OtherEmail = attribute.Value;
continue;
}
case "primary-email":
{
int num = 0;
int.TryParse(attribute.Value, ref num);
pea.PrimaryEmail = EnumHelper.IntStrToEnum<EmailUseType>(num.ToString());
continue;
}
case "company":
{
pea.Company = attribute.Value;
continue;
}
case "company-website":
{
pea.CompanyWebsite = attribute.Value;
continue;
}
}
}
}
public static void RetriveProfile(ProvsionData args)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(Provisioning.InnerRetriveProfile), args);
}
public static void SetProfile(ProvsionData args)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(Provisioning.InnerSetProfile), args);
}
public static void Subscribe(ProvsionData args)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(Provisioning.InnerSubscribe), args);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -