private void OnSpamIconButtonClick(object sender, EventArgs e) { if (!App.isNetworkAvailable()) { Exception connErr = new NoConnectionException(); this.HandleException(connErr); return; } string prompt = _localizedStrings.Prompts.ConfirmMarkSpamComment; MessageBoxResult result = MessageBox.Show(prompt, _localizedStrings.Prompts.Confirm, MessageBoxButton.OKCancel); if (result == MessageBoxResult.OK) { Comment comment = DataContext as Comment; comment.CommentStatus = eCommentStatus.spam; EditCommentRPC rpc = new EditCommentRPC(this._currentBlog, comment); rpc.Completed += OnEditCommentRPCCompleted; rpc.ExecuteAsync(); _currentConnection = rpc; ApplicationBar.IsVisible = false; App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.MarkingAsSpam); } else { return; } }
public void NoConnectionExceptionConstructorTest1() { string message = "Testmessage"; NoConnectionException target = new NoConnectionException(message); Assert.IsNotNull(target, "NoConnectionException Object created."); Assert.AreEqual(message, target.ExceptionMessage, "Messages are equal."); }
public void NoConnectionExceptionConstructorTest2() { string message = "Testmessage"; Exception innnerException = new Exception("Inner exception"); NoConnectionException target = new NoConnectionException(message, innnerException); Assert.IsNotNull(target, "NoConnectionException Object created."); Assert.AreEqual(message, target.Message, "Messages are equal."); Assert.AreSame(innnerException, target.InnerException, "Inner exception equal."); }
private void OnAddAccountIconButtonClick(object sender, EventArgs e) { if (!App.isNetworkAvailable()) { Exception connErr = new NoConnectionException(); this.HandleException(connErr); return; } NavigationService.Navigate(new Uri("/LocateBlogPage.xaml", UriKind.Relative)); }
public void NoConnectionExceptionSerializeTest() { string message = "Error Serial test NoConnectionException"; NoConnectionException testException = new NoConnectionException(message); string fileName = "Exception.test"; Assert.IsTrue(Serializer.Serialize(fileName, testException), "Serialized"); NoConnectionException result = (Serializer.Deserialize <NoConnectionException>(fileName)); Assert.IsInstanceOfType(result, typeof(NoConnectionException), "Deserialized"); Assert.IsTrue(message.Equals(result.ExceptionMessage), "Exception message equal"); }
private void OnReplyIconButtonClick(object sender, EventArgs e) { if (!App.isNetworkAvailable()) { Exception connErr = new NoConnectionException(); this.HandleException(connErr); return; } replyEditTextBox.Text = ""; ShowReplyEditPanel(false); }
private void OnEditCommentMenuItemClick(object sender, EventArgs e) { if (!App.isNetworkAvailable()) { Exception connErr = new NoConnectionException(); this.HandleException(connErr); return; } // Set the textbox text here and not in ShowReplyEditPanel so // changes are not overwritten when resuming from the background. Comment comment = DataContext as Comment; replyEditTextBox.Text = comment.Content; ShowReplyEditPanel(true); }
public UserInfo FindSystemUser() { using (_svc = new SimpleClient<IAdministrationService>()) { try { _svc.Open(); } catch (Exception /*ex*/) { NoConnectionException error = new NoConnectionException(); throw error; } return _svc.Channel.FindSystemUser(); } }
private void ReplyToComment() { if (string.IsNullOrEmpty(replyEditTextBox.Text)) { if (_messageBoxIsShown) { return; } _messageBoxIsShown = true; MessageBox.Show(_localizedStrings.Messages.MissingReply); _messageBoxIsShown = false; replyEditTextBox.Focus(); return; } if (!App.isNetworkAvailable()) { Exception connErr = new NoConnectionException(); this.HandleException(connErr); return; } Blog currentBlog = App.MasterViewModel.CurrentBlog; Comment comment = DataContext as Comment; Comment reply = new Comment() { Author = currentBlog.Username, Parent = comment.CommentId, Content = replyEditTextBox.Text }; NewCommentRPC rpc = new NewCommentRPC(currentBlog, comment, reply); rpc.Completed += new XMLRPCCompletedEventHandler <Comment>(OnNewCommentRPCCompleted); rpc.ExecuteAsync(); _currentConnection = rpc; ApplicationBar.IsVisible = false; App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.ReplyingToComment); }
private void OnApproveIconButtonClick(object sender, EventArgs e) { if (!App.isNetworkAvailable()) { Exception connErr = new NoConnectionException(); this.HandleException(connErr); return; } Comment comment = DataContext as Comment; comment.CommentStatus = eCommentStatus.approve; EditCommentRPC rpc = new EditCommentRPC(App.MasterViewModel.CurrentBlog, comment); rpc.Completed += OnEditCommentRPCCompleted; rpc.ExecuteAsync(); _currentConnection = rpc; ApplicationBar.IsVisible = false; App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.ApprovingComment); }
private void OnUnapproveIconButtonClick(object sender, EventArgs e) { if (!App.isNetworkAvailable()) { Exception connErr = new NoConnectionException(); this.HandleException(connErr); return; } Comment comment = DataContext as Comment; comment.CommentStatus = eCommentStatus.hold; EditCommentRPC rpc = new EditCommentRPC(App.MasterViewModel.CurrentBlog, comment); rpc.Completed += OnEditCommentRPCCompleted; rpc.ExecuteAsync(); _currentConnection = rpc; ApplicationBar.IsVisible = false; App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.UnapprovingComment); }
private void OnSpamIconButtonClick(object sender, EventArgs e) { if (!App.isNetworkAvailable()) { Exception connErr = new NoConnectionException(); this.HandleException(connErr); return; } string prompt = _localizedStrings.Prompts.ConfirmMarkSpamComment; if (_messageBoxIsShown) return; _messageBoxIsShown = true; MessageBoxResult result = MessageBox.Show(prompt, _localizedStrings.Prompts.Confirm, MessageBoxButton.OKCancel); _messageBoxIsShown = false; if (result == MessageBoxResult.OK) { Comment comment = DataContext as Comment; comment.CommentStatus = eCommentStatus.spam; EditCommentRPC rpc = new EditCommentRPC(App.MasterViewModel.CurrentBlog, comment); rpc.Completed += OnEditCommentRPCCompleted; rpc.ExecuteAsync(); _currentConnection = rpc; ApplicationBar.IsVisible = false; App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.MarkingAsSpam); } else { return; } }
private UserError UserHandler(string proc, UserInfo userInfo) { using (_svc = new SimpleClient<IAdministrationService>()) { try { _svc.Open(); } catch (Exception /*ex*/) { NoConnectionException error = new NoConnectionException(); throw error; } Type channel = typeof(IUserService); MethodInfo method = channel.GetMethod(proc, new Type[] { typeof(UserInfo)}); object[] parameters ={userInfo}; return (UserError)method.Invoke(_svc.Channel, parameters); } }
private void OnViewSiteButtonClick(object sender, RoutedEventArgs e) { if (!App.isNetworkAvailable()) { Exception connErr = new NoConnectionException(); this.HandleException(connErr); return; } string dashboardURL = App.MasterViewModel.CurrentBlog.homeURL(); string queryStringFormat = "?{0}={1}&{2}={3}"; //check if the login is necessary string requireLogParamenter = "0"; if (App.MasterViewModel.CurrentBlog.isWPcom() && App.MasterViewModel.CurrentBlog.isPrivate()) requireLogParamenter = "1"; string queryString = string.Format(queryStringFormat, BrowserShellPage.TARGET_URL, dashboardURL, BrowserShellPage.REQUIRE_LOGIN, requireLogParamenter); NavigationService.Navigate(new Uri("/BrowserShellPage.xaml" + queryString, UriKind.Relative)); }
private void OnRefreshIconButtonClick(object sender, EventArgs e) { if (!App.isNetworkAvailable()) { Exception connErr = new NoConnectionException(); this.HandleException(connErr); return; } if (blogPanorama.SelectedItem == commentsPanoramaItem) { FetchComments(false); } else if (blogPanorama.SelectedItem == postsPanoramaItem) { //The blog is already loading posts. if (App.MasterViewModel.CurrentBlog.IsLoadingPosts == true) return; //syncs postFormats, options (and maybe other stuff in the future) after the refresh of the posts list DataService.Current.FetchComplete += OnFetchCurrentBlogPostsComplete; DataService.Current.ExceptionOccurred += OnDataStoreFetchExceptionOccurred; DataService.Current.FetchCurrentBlogPostsAsync(false); } else if (blogPanorama.SelectedItem == pagesPanoramaItem) { //The blog is already loading pages. if (App.MasterViewModel.CurrentBlog.IsLoadingPages == true) return; if (DataService.Current.FetchCurrentBlogPagesAsync(false)) DataService.Current.ExceptionOccurred += OnDataStoreFetchExceptionOccurred; } }
private void OnModerateCommentsButtonClick(object sender, RoutedEventArgs e) { if (!App.isNetworkAvailable()) { Exception connErr = new NoConnectionException(); this.HandleException(connErr); return; } NavigationService.Navigate(new Uri("/ModerateCommentsPage.xaml", UriKind.Relative)); }
private void OnDashboardButtonClick(object sender, RoutedEventArgs e) { if (!App.isNetworkAvailable()) { Exception connErr = new NoConnectionException(); this.HandleException(connErr); return; } string dashboardURL = App.MasterViewModel.CurrentBlog.dashboardURL(); string queryStringFormat = "?{0}={1}&{2}={3}"; string queryString = string.Format(queryStringFormat, BrowserShellPage.TARGET_URL, dashboardURL, BrowserShellPage.REQUIRE_LOGIN, "1"); NavigationService.Navigate(new Uri("/BrowserShellPage.xaml" + queryString, UriKind.Relative)); }
public void SaveSystemParameters(ISystemParameters systemParameters) { using (_svc = new SimpleClient<IAdministrationService>()) { try { _svc.Open(); } catch (Exception /*ex*/) { NoConnectionException error = new NoConnectionException(); throw error; } try { _svc.Channel.SaveSystemParameters(systemParameters); } catch (FaultException Ex) { throw new SystemParametersSaveException(Ex.Message); } } }
public PresentationInfoExt[] LoadPresentationWithOneSlide() { using (_svc = new SimpleClient<IAdministrationService>()) { try { _svc.Open(); } catch (Exception /*ex*/) { NoConnectionException error = new NoConnectionException(); throw error; } return _svc.Channel.LoadPresentationWithOneSlide(); } }
public ISystemParameters LoadSystemParameters() { using (_svc = new SimpleClient<IAdministrationService>()) { try { _svc.Open(); } catch (Exception /*ex*/) { NoConnectionException error = new NoConnectionException(); throw error; } return _svc.Channel.LoadSystemParameters(); } }
private LabelError LabelHandler(string proc, Label labelInfo) { using (_svc = new SimpleClient<IAdministrationService>()) { try { _svc.Open(); } catch (Exception /*ex*/) { NoConnectionException error = new NoConnectionException(); throw error; } Type channel = typeof(ILabelService); MethodInfo method = channel.GetMethod(proc, new Type[] { typeof(Label) }); object[] parameters = {labelInfo}; try { return (LabelError)method.Invoke(_svc.Channel, parameters); } catch (TargetInvocationException tiEx) { if (tiEx.InnerException is FaultException<LabelUsedInPresentationException>) { throw new LabelUsedInPresentationException(((FaultException<LabelUsedInPresentationException>)tiEx.InnerException).Detail.Message); } throw tiEx; } } }
public Label[] GetLabelStorage() { using (_svc = new SimpleClient<IAdministrationService>()) { try { _svc.Open(); } catch (Exception /*ex*/) { NoConnectionException error = new NoConnectionException(); throw error; } return _svc.Channel.GetLabelStorage(); } }
private void ReplyToComment() { if (string.IsNullOrEmpty(replyEditTextBox.Text)) { if (_messageBoxIsShown) return; _messageBoxIsShown = true; MessageBox.Show(_localizedStrings.Messages.MissingReply); _messageBoxIsShown = false; replyEditTextBox.Focus(); return; } if (!App.isNetworkAvailable()) { Exception connErr = new NoConnectionException(); this.HandleException(connErr); return; } Blog currentBlog = App.MasterViewModel.CurrentBlog; Comment comment = DataContext as Comment; Comment reply = new Comment() { Author = currentBlog.Username, Parent = comment.CommentId, Content = replyEditTextBox.Text }; NewCommentRPC rpc = new NewCommentRPC(currentBlog, comment, reply); rpc.Completed += new XMLRPCCompletedEventHandler<Comment>(OnNewCommentRPCCompleted); rpc.ExecuteAsync(); _currentConnection = rpc; ApplicationBar.IsVisible = false; App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.ReplyingToComment); }
protected override IEnumerator Routine() { string url = Material.Url; if (Material.Parameters != null) { foreach (string param in Material.Parameters) { url += "/" + param; } } Debug.Log(url); WWW www; if (Material.Fields != null) { WWWForm form = new WWWForm(); foreach (string key in Material.Fields.Keys) { form.AddField(key, Material.Fields[key]); } www = new WWW(url, form); } else { www = new WWW(url); } yield return(www); Debug.Log(www.text); if (www.error != null) { Exception ex = null; if (www.error.Contains("java.net.UnknownHostException")) { ex = new NoConnectionException(); } else if (www.error.Contains("Failed to connect to")) { ex = new ServerException(); } else if (www.error.Contains("Recv failure: Connection was reset")) { ex = new ConnectionDropException(); } else { try { string status = www.responseHeaders["STATUS"]; if (status.Contains("404 Not Found")) { ex = new NotFoundException(); } else if (status.Contains("500 Internal Server Error")) { ex = new InternalServerException(); } } catch (Exception) { ex = new Exception(www.error); Debug.LogAssertion(www.error); } } if (OnFail != null) { OnFail(ex); } else { Events.Exception(ex); } } else { try { if (www.text == "not recognized") { OnFail(new InstanceException()); } else { OnSuccess(www); } } catch (Exception ex) { if (OnFail != null) { OnFail(ex); } else { Events.Exception(ex); } } } Dispose(); }
public void NoConnectionExceptionConstructorTest() { NoConnectionException target = new NoConnectionException(); Assert.IsNotNull(target, "NoConnectionException Object created."); }
protected override IEnumerator Routine() { string url = Material.Url; if (Material.Parameters != null) { foreach (string param in Material.Parameters) { url += "/" + param; } } WWW www = new WWW(url); if (Material.UI_Text != null) { MonoBridge.StartCoroutine(Progress(www)); } yield return(www); while (!www.isDone) { } if (Material.UI_Text != null) { Material.UI_Text.text = ""; } if (www.error != null) { Exception ex = null; if (www.error.Contains("java.net.UnknownHostException")) { ex = new NoConnectionException(); } else if (www.error.Contains("Failed to connect to")) { ex = new ServerException(); } else if (www.error.Contains("Recv failure: Connection was reset")) { ex = new ConnectionDropException(); } else { try { string status = www.responseHeaders["STATUS"]; if (status.Contains("404 Not Found")) { ex = new NotFoundException(); } else if (status.Contains("500 Internal Server Error")) { ex = new InternalServerException(); } } catch (Exception) { ex = new Exception(www.error); Debug.LogAssertion(www.error); } } if (OnFail != null) { OnFail(ex); } else { Events.Exception(ex); } } else { try { OnSuccess(www); } catch (Exception ex) { if (OnFail != null) { OnFail(ex); } else { Events.Exception(ex); } } } Dispose(); }
private void PresentPostOptions(bool isLocalDraft) { App.PopupSelectionService.Title = _localizedStrings.Prompts.PostActions; if (isLocalDraft) { App.PopupSelectionService.ItemsSource = _draftListOptions; _popupServiceSelectionChangedHandler = OnDraftOptionSelected; App.PopupSelectionService.SelectionChanged += OnDraftOptionSelected; } else { //No local draft, check the connection status first if (!App.isNetworkAvailable()) { Exception connErr = new NoConnectionException(); this.HandleException(connErr); return; } PostListItem postListItem = postsListBox.SelectedItem as PostListItem; if (null == postListItem) return; List<string> optionsList = new List<string>(_postListOptions); if (postListItem.Status != "draft" && postListItem.Status != "private") optionsList.Add(_localizedStrings.Options.PostOptions_SharePost); App.PopupSelectionService.ItemsSource = optionsList; _popupServiceSelectionChangedHandler = OnPostOptionSelected; App.PopupSelectionService.SelectionChanged += OnPostOptionSelected; } App.PopupSelectionService.ShowPopup(); }
private void EditComment() { if (string.IsNullOrEmpty(replyEditTextBox.Text)) { if (_messageBoxIsShown) return; _messageBoxIsShown = true; MessageBox.Show(_localizedStrings.Messages.MissingFields); _messageBoxIsShown = false; replyEditTextBox.Focus(); return; } if (!App.isNetworkAvailable()) { Exception connErr = new NoConnectionException(); this.HandleException(connErr); return; } Comment comment = DataContext as Comment; comment.Content = replyEditTextBox.Text; EditCommentRPC rpc = new EditCommentRPC(App.MasterViewModel.CurrentBlog, comment); rpc.Completed += OnEditCommentRPCCompleted; rpc.ExecuteAsync(); _currentConnection = rpc; ApplicationBar.IsVisible = false; App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.EditingComment); }
private void OnStatsButtonClick(object sender, RoutedEventArgs e) { if (!App.isNetworkAvailable()) { Exception connErr = new NoConnectionException(); this.HandleException(connErr); return; } else { if (App.MasterViewModel.CurrentBlog.isWPcom() || App.MasterViewModel.CurrentBlog.hasJetpack()) { NavigationService.Navigate(new Uri("/ViewStatsPage.xaml", UriKind.Relative)); return; } //Not a WPCOM blog and JetPack 1.8.2 or higher is installed on the site. Show the error message. if (!App.MasterViewModel.CurrentBlog.hasJetpack()) { MessageBoxResult result = MessageBox.Show(_localizedStrings.Prompts.JetpackNotAvailable, _localizedStrings.PageTitles.Error, MessageBoxButton.OKCancel); if (MessageBoxResult.OK == result) //start the browser { LaunchWebBrowserCommand command = new LaunchWebBrowserCommand(); command.Execute(Constants.JETPACK_SITE_URL); } } } }
private void OnEditCommentMenuItemClick(object sender, EventArgs e) { if (!App.isNetworkAvailable()) { Exception connErr = new NoConnectionException(); this.HandleException(connErr); return; } // Set the textbox text here and not in ShowReplyEditPanel so // changes are not overwritten when resuming from the background. Comment comment = DataContext as Comment; replyEditTextBox.Text = comment.Content; ShowReplyEditPanel(true); }
private void OnPostOptionSelected(object sender, SelectionChangedEventArgs args) { App.PopupSelectionService.SelectionChanged -= OnPostOptionSelected; _popupServiceSelectionChangedHandler = null; //recheck the connection status if (!App.isNetworkAvailable()) { Exception connErr = new NoConnectionException(); this.HandleException(connErr); return; } int index = 0; string selectedMenuLabel = args.AddedItems[0] as string; foreach (string value in App.PopupSelectionService.ItemsSource) { if (value == selectedMenuLabel) break; else index++; } switch (index) { case 0: //view post GetPostPermaLink(0); break; case 1: //view post comments ViewPostComments(); break; case 2: //edit post EditPost(); break; case 3: //delete post DeletePost(); break; case 4: //share post GetPostPermaLink(1); break; } //reset selected index so we can re-select the original list item if we want to postsListBox.SelectedIndex = -1; }
private void OnReplyIconButtonClick(object sender, EventArgs e) { if (!App.isNetworkAvailable()) { Exception connErr = new NoConnectionException(); this.HandleException(connErr); return; } replyEditTextBox.Text = ""; ShowReplyEditPanel(false); }
private void OnDeleteIconButtonClick(object sender, EventArgs e) { if (!App.isNetworkAvailable()) { Exception connErr = new NoConnectionException(); this.HandleException(connErr); return; } string prompt = _localizedStrings.Prompts.ConfirmDeleteComment; MessageBoxResult result = MessageBox.Show(prompt, _localizedStrings.Prompts.Confirm, MessageBoxButton.OKCancel); if (result == MessageBoxResult.OK) { Comment comment = DataContext as Comment; DeleteCommentRPC rpc = new DeleteCommentRPC(this._currentBlog, comment); rpc.Completed += OnDeleteCommentRPCCompleted; rpc.ExecuteAsync(); _currentConnection = rpc; ApplicationBar.IsVisible = false; App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.DeletingComment); } else { return; } }
private void OnAddAccountIconButtonClick(object sender, EventArgs e) { if (!App.isNetworkAvailable()) { Exception connErr = new NoConnectionException(); this.HandleException(connErr); return; } NavigationService.Navigate(new Uri("/LocateBlogPage.xaml", UriKind.Relative)); }