private void SendCore(InputData data) { data.Send() .Subscribe(r => { if (r.Succeededs != null) { InputModel.InputCore.LastPostedData = r.Succeededs; BackstageModel.RegisterEvent(new PostSucceededEvent(r.Succeededs)); } if (r.Faileds != null) { var message = this.AnalyzeFailedReason(r.Exceptions) ?? InputAreaResources.MsgTweetFailedReasonUnknown; var ed = r.Exceptions .Guard() .SelectMany(ex => EnumerableEx.Generate( ex, e => e != null, e => e.InnerException, e => e)) .Where(e => e != null) .Select(e => e.ToString()) .JoinString(Environment.NewLine); if (Setting.ShowMessageOnTweetFailed.Value) { var resp = _parent.Messenger.GetResponse(new TaskDialogMessage(new TaskDialogOptions { Title = InputAreaResources.MsgTweetFailedTitle, MainIcon = VistaTaskDialogIcon.Error, MainInstruction = InputAreaResources.MsgTweetFailedInst, Content = InputAreaResources.MsgTweetFailedContentFormat.SafeFormat(message), ExpandedInfo = ed, FooterText = InputAreaResources.MsgTweetFailedFooter, FooterIcon = VistaTaskDialogIcon.Information, VerificationText = Resources.MsgDoNotShowAgain, CommonButtons = TaskDialogCommonButtons.RetryCancel })); Setting.ShowMessageOnTweetFailed.Value = !resp.Response.VerificationChecked.GetValueOrDefault(); if (resp.Response.Result == TaskDialogSimpleResult.Retry) { this.SendCore(r.Faileds); return; } } else { BackstageModel.RegisterEvent(new PostFailedEvent(r.Faileds, message)); } // Send to draft InputModel.InputCore.Drafts.Add(r.Faileds); } }); }
private void SendCore(InputData data) { data.Send() .Subscribe(r => { if (r.Succeededs != null) { InputModel.InputCore.LastPostedData = r.Succeededs; BackstageModel.RegisterEvent(new PostSucceededEvent(r.Succeededs)); } if (r.Faileds != null) { var message = this.AnalyzeFailedReason(r.Exceptions) ?? "原因を特定できませんでした。"; if (Setting.ShowMessageOnTweetFailed.Value) { var resp = _parent.Messenger.GetResponse(new TaskDialogMessage(new TaskDialogOptions { Title = "ツイートの失敗", MainIcon = VistaTaskDialogIcon.Error, MainInstruction = "ツイートに失敗しました。", Content = "エラー: " + message + Environment.NewLine + "もう一度投稿しますか?", FooterText = "再試行しない場合は、ツイートしようとした内容は下書きとして保存されます。", FooterIcon = VistaTaskDialogIcon.Information, VerificationText = "次回から表示しない", CommonButtons = TaskDialogCommonButtons.RetryCancel })); Setting.ShowMessageOnTweetFailed.Value = !resp.Response.VerificationChecked.GetValueOrDefault(); if (resp.Response.Result == TaskDialogSimpleResult.Retry) { this.SendCore(r.Faileds); return; } } else { BackstageModel.RegisterEvent(new PostFailedEvent(r.Faileds, message)); } // Send to draft InputModel.InputCore.Drafts.Add(r.Faileds); } }); }