コード例 #1
0
        void postCommentWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            VM_Trakt_CommentPost comment = e.Argument as VM_Trakt_CommentPost;

            string msg = "";

            try
            {
                CL_Response <bool> resp = VM_ShokoServer.Instance.ShokoServices.PostTraktCommentShow(comment.TraktID, comment.CommentText, comment.Spoiler);
                msg = resp.ErrorMessage;
            }
            catch (Exception ex)
            {
                e.Result = ex.Message;
                return;
            }

            e.Result = msg;
        }
コード例 #2
0
        void btnSubmitComment_Click(object sender, RoutedEventArgs e)
        {
            if (!VM_ShokoServer.Instance.Trakt_IsEnabled)
            {
                Utils.ShowErrorMessage("You have not enabled Trakt, for more info go to 'Settings - Community Sites - Trakt TV'");
                txtCommentNew.Focus();
                return;
            }

            if (string.IsNullOrEmpty(VM_ShokoServer.Instance.Trakt_AuthToken))
            {
                Utils.ShowErrorMessage("You have not authorized JMM to use your Trakt account, for more info go to 'Settings - Community Sites - Trakt TV'");
                txtCommentNew.Focus();
                return;
            }

            VM_AnimeSeries_User animeSeries = (VM_AnimeSeries_User)DataContext;

            if (animeSeries == null)
            {
                Utils.ShowErrorMessage("Anime series info not found");
                txtCommentNew.Focus();
                return;
            }

            string commentText = txtCommentNew.Text.Trim();

            if (string.IsNullOrEmpty(commentText))
            {
                Utils.ShowErrorMessage("Please enter text for your Comment");
                txtCommentNew.Focus();
                return;
            }

            if (commentText.Length > 2000)
            {
                Utils.ShowErrorMessage($"Comment text must be less than 2000 characters ({commentText.Length})");
                txtCommentNew.Focus();
                return;
            }

            btnRefresh.IsEnabled       = false;
            btnSubmitComment.IsEnabled = false;

            if (animeSeries.AniDBAnime.AniDBAnime.traktSummary != null)
            {
                string traktID = string.Empty;

                // check to  see if this series is linked to more than one Trakt series
                if (animeSeries.AniDBAnime.AniDBAnime.traktSummary.traktDetails == null ||
                    animeSeries.AniDBAnime.AniDBAnime.traktSummary.traktDetails.Count == 0)
                {
                    Utils.ShowErrorMessage(string.Format("Cannot Comment where a series does not have a Trakt show linked"));
                    txtCommentNew.Focus();
                    return;
                }

                // check to  see if this series is linked to more than one Trakt series
                if (animeSeries.AniDBAnime.AniDBAnime.traktSummary.traktDetails != null &&
                    animeSeries.AniDBAnime.AniDBAnime.traktSummary.traktDetails.Count > 1)
                {
                    Utils.ShowErrorMessage(string.Format("Cannot Comment where a series has more than one Trakt show linked"));
                    txtCommentNew.Focus();
                    return;
                }

                if (animeSeries.AniDBAnime.AniDBAnime.traktSummary.traktDetails != null &&
                    animeSeries.AniDBAnime.AniDBAnime.traktSummary.traktDetails.Count == 1)
                {
                    Cursor    = Cursors.Wait;
                    IsLoading = true;

                    foreach (KeyValuePair <string, VM_TraktDetails> kvp in animeSeries.AniDBAnime.AniDBAnime.traktSummary.traktDetails)
                    {
                        traktID = kvp.Key;
                    }

                    VM_Trakt_CommentPost comment = new VM_Trakt_CommentPost();
                    comment.TraktID     = traktID;
                    comment.AnimeID     = animeSeries.AniDB_ID;
                    comment.CommentText = commentText;
                    comment.Spoiler     = chkSpoiler.IsChecked.Value;

                    postCommentWorker.RunWorkerAsync(comment);
                }
            }
            else
            {
                Utils.ShowErrorMessage(string.Format("Cannot Comment where a series does not have a Trakt show linked"));
                txtCommentNew.Focus();
            }
        }
コード例 #3
0
        void btnSubmitComment_Click(object sender, RoutedEventArgs e)
        {
            if (!VM_ShokoServer.Instance.Trakt_IsEnabled)
            {
                Utils.ShowErrorMessage(Shoko.Commons.Properties.Resources.Anime_TraktNotEnabled);
                txtCommentNew.Focus();
                return;
            }

            if (string.IsNullOrEmpty(VM_ShokoServer.Instance.Trakt_AuthToken))
            {
                Utils.ShowErrorMessage(Shoko.Commons.Properties.Resources.Anime_ShokoAuth);
                txtCommentNew.Focus();
                return;
            }

            VM_AnimeSeries_User animeSeries = (VM_AnimeSeries_User)DataContext;

            if (animeSeries == null)
            {
                Utils.ShowErrorMessage(Shoko.Commons.Properties.Resources.Anime_SeriesNotFound);
                txtCommentNew.Focus();
                return;
            }

            string commentText = txtCommentNew.Text.Trim();

            if (string.IsNullOrEmpty(commentText))
            {
                Utils.ShowErrorMessage(Shoko.Commons.Properties.Resources.Anime_EnterText);
                txtCommentNew.Focus();
                return;
            }

            if (commentText.Length > 2000)
            {
                Utils.ShowErrorMessage(string.Format(Shoko.Commons.Properties.Resources.Anime_CommentText, commentText.Length));
                txtCommentNew.Focus();
                return;
            }

            btnSubmitComment.IsEnabled = false;

            if (animeSeries.AniDBAnime.AniDBAnime.traktSummary != null)
            {
                string traktID = string.Empty;

                // check to  see if this series is linked to more than one Trakt series
                if (animeSeries.AniDBAnime.AniDBAnime.traktSummary.traktDetails == null ||
                    animeSeries.AniDBAnime.AniDBAnime.traktSummary.traktDetails.Count == 0)
                {
                    Utils.ShowErrorMessage(string.Format(Shoko.Commons.Properties.Resources.Anime_NoTrakt));
                    txtCommentNew.Focus();
                    btnSubmitComment.IsEnabled = true;
                    return;
                }

                // check to  see if this series is linked to more than one Trakt series
                if (animeSeries.AniDBAnime.AniDBAnime.traktSummary.traktDetails != null &&
                    animeSeries.AniDBAnime.AniDBAnime.traktSummary.traktDetails.Count > 1)
                {
                    Utils.ShowErrorMessage(string.Format(Shoko.Commons.Properties.Resources.Anime_MultiTrakt));
                    txtCommentNew.Focus();
                    btnSubmitComment.IsEnabled = true;
                    return;
                }

                if (animeSeries.AniDBAnime.AniDBAnime.traktSummary.traktDetails != null &&
                    animeSeries.AniDBAnime.AniDBAnime.traktSummary.traktDetails.Count == 1)
                {
                    Cursor = Cursors.Wait;

                    foreach (KeyValuePair <string, VM_TraktDetails> kvp in animeSeries.AniDBAnime.AniDBAnime.traktSummary.traktDetails)
                    {
                        traktID = kvp.Key;
                    }

                    VM_Trakt_CommentPost comment = new VM_Trakt_CommentPost();
                    comment.TraktID     = traktID;
                    comment.AnimeID     = animeSeries.AniDB_ID;
                    comment.CommentText = commentText;
                    comment.Spoiler     = chkSpoiler.IsChecked.Value;

                    postCommenttWorker.RunWorkerAsync(comment);
                }
            }
            else
            {
                Utils.ShowErrorMessage(string.Format(Shoko.Commons.Properties.Resources.Anime_NoTrakt));
                txtCommentNew.Focus();
                btnSubmitComment.IsEnabled = true;
            }
        }