📄 userinfo.cs
字号:
namespace Imps.Client.Core
{
using Imps.Base.Sipc;
using Imps.Client;
using Imps.Client.Base;
using Imps.Common;
using Imps.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
public class UserInfo : PersonalInfoBase
{
private string _currentPortraitFileName;
private User _owner;
internal UserInfo(User owner)
{
this._owner = owner;
}
internal bool AsyncDoLogin(AsyncBizOperation op)
{
this.OwnerUser.PersistentManager.LoadUserInfo(new PersistentDelegate(this.LoadPersonalXmlNode));
this.OwnerUser.PersistentManager.LoadSubscribedServiceInfos(new PersistentDelegate(this.OwnerUser.LoadServicesNode));
this.AsyncRetrieve(op);
return true;
}
private void AsyncRetrieve(AsyncBizOperation op)
{
SipRequest req = this.OwnerUser.CreateSipRequest("S");
req.Message.AddHeader(new SipcEventHeader("GetPersonalInfo"));
StringWriter tw = new StringWriter();
XmlHelper.CreateXmlWriterForSipRequest(tw, null, delegate (XmlWriter writer, object context) {
writer.WriteStartElement("personal");
if (base.Version.Length > 0)
{
writer.WriteAttributeString("version", base.Version);
}
writer.WriteAttributeString("attributes", "all");
writer.WriteEndElement();
writer.WriteStartElement("services");
writer.WriteAttributeString("version", this.OwnerUser.ServiceVersion);
writer.WriteAttributeString("attributes", "all");
writer.WriteEndElement();
writer.WriteStartElement("config");
writer.WriteAttributeString("version", this.OwnerUser.Configuration.UserSetting.CfgVersion.ToString());
writer.WriteAttributeString("attributes", "all");
writer.WriteEndElement();
writer.WriteStartElement("mobile-device");
writer.WriteAttributeString("attributes", "all");
writer.WriteEndElement();
});
req.Message.Body = tw.ToString();
ErrorHelper.HandleSendRequestErrorAndTimeout(req);
req.Context = op;
req.FinalResponseReceived += new EventHandler<SipResponseReceivedEventArgs>(this, (IntPtr) this.RetrieveInfo_FinalResponseReceived);
this.OwnerUser.SendSipMessage(req);
}
internal override void CommitProposedProperties(AsyncBizOperation op)
{
SipRequest req;
lock (base.SyncRoot)
{
if (!this.HasProposedProperty())
{
return;
}
if (this.MoodPhrase.HasProposedValue && !string.IsNullOrEmpty(this.MoodPhrase.ProposedValue))
{
this.OwnerUser.Configuration.UserSetting.MoodPhrases.Add(this.MoodPhrase.ProposedValue);
}
req = this.OwnerUser.CreateSipRequest("S");
req.Message.AddHeader(new SipcEventHeader("SetPersonalInfo"));
req.Context = op;
req.Message.Body = this.CommitProposedString();
base.InnerResetProposedProperties();
}
req.FinalResponseReceived += new EventHandler<SipResponseReceivedEventArgs>(this, (IntPtr) this.RetrieveInfo_FinalResponseReceived);
ErrorHelper.HandleSendRequestErrorAndTimeout(req);
this.OwnerUser.SendSipMessage(req);
}
internal string CommitProposedString()
{
StringWriter tw = new StringWriter();
XmlHelper.CreateXmlWriterForSipRequest(tw, null, delegate (XmlWriter writer, object context) {
writer.WriteStartElement("personal");
using (IEnumerator<string> enumerator = base.InnerData.get_Keys().GetEnumerator())
{
while (enumerator.MoveNext())
{
string localName = enumerator.get_Current();
if (!char.IsUpper(localName[0]))
{
object obj2 = base[localName];
if ((obj2 is IDataCanProposed) && ((IDataCanProposed) obj2).HasProposedValue)
{
string text2;
object proposedValue = ((IDataCanProposed) obj2).ProposedValue;
if (proposedValue is Enum)
{
text2 = ((int) proposedValue).ToString();
}
else if (proposedValue is bool)
{
text2 = ((bool) proposedValue) ? "1" : "0";
}
else if (proposedValue is DateTime)
{
text2 = ((DateTime) proposedValue).ToString("yyyy-MM-dd");
}
else
{
text2 = proposedValue.ToString();
}
writer.WriteAttributeString(localName, text2);
}
}
}
}
writer.WriteEndElement();
});
return tw.ToString();
}
internal void LoadPersonalXmlNode(XmlNode personalNode)
{
if ((personalNode != null) && (personalNode.Attributes.Count != 0))
{
lock (base.SyncRoot)
{
Suspender suspender = new Suspender(this);
try
{
foreach (XmlAttribute attribute in personalNode.Attributes)
{
int num;
DateTime nullBirthDate;
switch (attribute.Name)
{
case "mobile-no":
{
if (string.IsNullOrEmpty(base.MobileNo))
{
base.MobileNo = (string) ((ProposedData<string>) attribute.Value);
}
continue;
}
case "impresa":
{
this.MoodPhrase = (ProposedData<string>) StringHelper.ReplaceCrLfToSpace(attribute.Value);
continue;
}
case "nickname":
{
this.Nickname = (ProposedData<string>) attribute.Value;
continue;
}
case "name":
{
this.Name = (ProposedData<string>) attribute.Value;
continue;
}
case "gender":
{
this.Gender = (ProposedData<Imps.Common.Gender>) EnumHelper.IntStrToEnum<Imps.Common.Gender>(attribute.Value);
if (PortraitHelper.IsCrcEmpty(base.PortraitCrc))
{
base.SetPortrait(null, string.Empty);
}
continue;
}
case "birth-date":
{
try
{
if (!DateTime.TryParse(attribute.Value, ref nullBirthDate))
{
nullBirthDate = PersonalInfoBase.NullBirthDate;
}
}
catch
{
nullBirthDate = PersonalInfoBase.NullBirthDate;
}
this.BirthDate = (ProposedData<DateTime>) nullBirthDate;
continue;
}
case "birthday-valid":
{
this.IsBirthdayValid = (ProposedData<bool>) (attribute.Value == "1");
continue;
}
case "nation":
{
this.UserNationality = (ProposedData<string>) attribute.Value;
continue;
}
case "province":
{
this.Province = (ProposedData<string>) attribute.Value;
continue;
}
case "city":
{
int.TryParse(attribute.Value, ref num);
this.City = (ProposedData<int>) num;
continue;
}
case "profile":
{
this.Notes = (ProposedData<string>) attribute.Value;
continue;
}
case "lunar-animal":
{
this.LunarAnimal = (ProposedData<Imps.Common.LunarAnimal>) EnumHelper.IntStrToEnum<Imps.Common.LunarAnimal>(attribute.Value);
continue;
}
case "horoscope":
{
this.Horoscope = (ProposedData<Imps.Common.Horoscope>) EnumHelper.IntStrToEnum<Imps.Common.Horoscope>(attribute.Value);
continue;
}
case "blood-type":
{
this.BloodType = (ProposedData<Imps.Common.BloodType>) EnumHelper.IntStrToEnum<Imps.Common.BloodType>(attribute.Value);
continue;
}
case "occupation":
{
int.TryParse(attribute.Value, ref num);
this.Occupation = (ProposedData<int>) num;
continue;
}
case "portrait-crc":
{
base.PortraitCrc = attribute.Value;
this.OwnerUser.PortraitDownloader.AsyncGetPortrait(this, DownloadPortraitPriority.Max);
continue;
}
case "job-title":
{
this.JobTitle = (ProposedData<string>) attribute.Value;
continue;
}
case "home-phone":
{
this.HomePhone = (ProposedData<string>) attribute.Value;
continue;
}
case "work-phone":
{
this.WorkPhone = (ProposedData<string>) attribute.Value;
continue;
}
case "other-phone":
{
this.OtherPhone = (ProposedData<string>) attribute.Value;
continue;
}
case "work-email":
{
this.WorkEmail = (ProposedData<string>) attribute.Value;
continue;
}
case "personal-email":
{
this.PersonalEmail = (ProposedData<string>) attribute.Value;
continue;
}
case "other-email":
{
this.OtherEmail = (ProposedData<string>) attribute.Value;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -