contactinfocardaction.cs

来自「破解的飞信源代码」· CS 代码 · 共 104 行

CS
104
字号
namespace Imps.Client.Core
{
    using Imps.Client.Core.Login;
    using System;
    using System.Threading;

    public sealed class ContactInfoCardAction : LoginAction
    {
        private const int ContactInfoTimeOut = 0x493e0;
        private const string errorMessage = "获取联系人详细信息出现错误";
        private bool result;
        private AutoResetEvent waitContactInfo;

        public ContactInfoCardAction(User user, ILoginListner listner) : base(user, listner)
        {
        }

        public override void Cancel()
        {
        }

        public override void Clear()
        {
        }

        public override void Dispose()
        {
        }

        public override bool Execute()
        {
            try
            {
                base.NotifyMessage("开始获取联系人详细信息");
                AsyncBizOperation op = new AsyncBizOperation(base.User);
                op.ImpsError += new EventHandler<ImpsErrorEventArgs>(this, (IntPtr) this.op_ImpsError);
                op.Successed += new EventHandler(this.op_Successed);
                if (this.waitContactInfo == null)
                {
                    this.waitContactInfo = new AutoResetEvent(false);
                }
                base.User.ContactList.AsyncGetContactsInfoBatchAll(op);
                if (!this.waitContactInfo.WaitOne(this.TimeOut, false))
                {
                    base.NotifyLoginFailed("获取联系人详细信息出现错误", ExceptionType.CommonException, null);
                }
                base.NotifyMessage("获取联系人详细信息结束");
            }
            catch (ThreadAbortException exception)
            {
                base.NotifyWarning("获取联系人详细信息出现错误", exception);
            }
            catch (Exception)
            {
                base.NotifyLoginFailed("获取联系人详细信息出现错误", ExceptionType.CommonException, null);
            }
            return this.result;
        }

        private void op_ImpsError(object sender, ImpsErrorEventArgs e)
        {
            base.NotifyLoginFailed("获取联系人详细信息出现错误", ExceptionType.CommonException, null);
            this.result = false;
            this.waitContactInfo.Set();
        }

        private void op_Successed(object sender, EventArgs e)
        {
            this.result = true;
            this.waitContactInfo.Set();
        }

        public override void Retry(RetryResult result)
        {
            base.User.ContactList.RetryGetContactsInfo(result);
        }

        public override bool LocalCacheHit
        {
            get
            {
                return true;
            }
        }

        public override Imps.Client.Core.LoginStage LoginStage
        {
            get
            {
                return Imps.Client.Core.LoginStage.GetContactsInfo;
            }
        }

        public override int TimeOut
        {
            get
            {
                return 0x493e0;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?