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; } }
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)); } }
public S1UserException(string msg, UserErrorTypes type = UserErrorTypes.Unknown) : base(msg) { ErrorType = type; }
public S1UserException(UserErrorTypes type) : base(type.ToString()) { ErrorType = type; }