예제 #1
0
        private async Task DoPost()
        {
            UserErrorTypes result     = UserErrorTypes.Unknown;
            int            retryTimes = 0;

            try
            {
                IsSending = true;
                while (result != UserErrorTypes.Success)
                {
                    if (retryTimes > 2)
                    {
                        throw new S1UserException("MaxRetry", UserErrorTypes.MaxRetryTime);
                    }
                    if (result == UserErrorTypes.InvalidVerify)
                    {
                        await UserLogin();
                    }

                    await CheckVerify();

                    result = await new S1WebClient().Reply(verify,
                                                           reletivePostUrl: replyLink,
                                                           content: ReplyText + "\r\n" + DateTime.Now.ToShortTimeString(),
                                                           signature: deviceInfo);

                    if (result == UserErrorTypes.Success)
                    {
                        Result = "Success";
                    }
                    retryTimes++;
                }
            }
            catch (Exception ex)
            {
                Result = ex.Message;
            }
            finally
            {
                IsSending = false;
            }
        }
예제 #2
0
        public async Task <string> DoSendPost(string replyLink, string replyText)
        {
            UserErrorTypes result     = UserErrorTypes.Unknown;
            int            retryTimes = 0;

            try
            {
                while (result != UserErrorTypes.Success)
                {
                    if (retryTimes > 2)
                    {
                        throw new S1UserException("MaxRetry", UserErrorTypes.MaxRetryTime);
                    }
                    if (result == UserErrorTypes.InvalidVerify)
                    {
                        Uid = null;
                        var error = await DoLogin(SettingView.CurrentUsername, SettingView.CurrentPassword);

                        if (error != null)
                        {
                            throw new S1UserException(error, UserErrorTypes.LoginFailed);
                        }
                    }

                    result = await new S1WebClient().Reply(_formHash,
                                                           reletivePostUrl: replyLink,
                                                           content: replyText,
                                                           signature: S1Nyan.Views.SettingView.GetSignature());

                    retryTimes++;
                }
                return(null);
            }
            catch (Exception ex)
            {
                return(S1Nyan.Utils.Util.ErrorMsg.GetExceptionMessage(ex));
            }
        }
예제 #3
0
 public S1UserException(string msg, UserErrorTypes type = UserErrorTypes.Unknown)
     : base(msg)
 {
     ErrorType = type;
 }
예제 #4
0
 public S1UserException(UserErrorTypes type)
     : base(type.ToString())
 {
     ErrorType = type;
 }
예제 #5
0
 public S1UserException(string msg, UserErrorTypes type = UserErrorTypes.Unknown)
     : base(msg)
 {
     ErrorType = type;
 }
예제 #6
0
 public S1UserException(UserErrorTypes type)
     : base(type.ToString())
 {
     ErrorType = type;
 }