コード例 #1
0
        public async Task SendSticker(StickerSelection stickerSelection)
        {
            var result = new Result();
            if (GroupMembers.Any() && IsNewMessage)
            {
                result =
                    await
                        _messageManager.CreateStickerPostWithNewGroupMessage(GroupMembers.ToArray(),
                            stickerSelection.ManifestUrl,
                            stickerSelection.Number.ToString(), stickerSelection.ImageUrl, stickerSelection.PackageId,
                            stickerSelection.Type, Locator.ViewModels.MainPageVm.CurrentTokens,
                            Locator.ViewModels.MainPageVm.CurrentUser.Region);
            }
            else
            {
                result =
                    await
                        _messageManager.CreateStickerPost(SelectedMessageGroup.MessageGroupId,
                            stickerSelection.ManifestUrl,
                            stickerSelection.Number.ToString(), stickerSelection.ImageUrl, stickerSelection.PackageId,
                            stickerSelection.Type, Locator.ViewModels.MainPageVm.CurrentTokens,
                            Locator.ViewModels.MainPageVm.CurrentUser.Region);
            }

            await AccountAuthHelpers.UpdateTokens(Locator.ViewModels.MainPageVm.CurrentUser, result);
            var resultCheck = await ResultChecker.CheckSuccess(result);
            if (resultCheck)
            {
                SelectedMessageGroup = JsonConvert.DeserializeObject<MessageGroup>(result.ResultJson);
                await GetMessages(SelectedMessageGroup);
                await GetMessageGroups(Locator.ViewModels.MainPageVm.CurrentUser.Username);
                IsNewMessage = false;
            }
        }
コード例 #2
0
        public async Task SendSticker(StickerSelection stickerSelection)
        {
            string error;
            try
            {
                var result = new Result();
                if (GroupMembers.Any() && IsNewMessage)
                {
                    result =
                        await
                            _messageManager.CreateStickerPostWithNewGroupMessage(GroupMembers.ToArray(),
                                stickerSelection.ManifestUrl,
                                stickerSelection.Number.ToString(), stickerSelection.ImageUrl, stickerSelection.PackageId,
                                stickerSelection.Type, Shell.Instance.ViewModel.CurrentTokens,
                                Shell.Instance.ViewModel.CurrentUser.Region);
                }
                else
                {
                    result =
                        await
                            _messageManager.CreateStickerPost(SelectedMessageGroup.MessageGroupId,
                                stickerSelection.ManifestUrl,
                                stickerSelection.Number.ToString(), stickerSelection.ImageUrl, stickerSelection.PackageId,
                                stickerSelection.Type, Shell.Instance.ViewModel.CurrentTokens,
                                Shell.Instance.ViewModel.CurrentUser.Region);
                }

                await AccountAuthHelpers.UpdateTokens(Shell.Instance.ViewModel.CurrentUser, result);
                var resultCheck = await ResultChecker.CheckSuccess(result);
                if (resultCheck)
                {
                    SelectedMessageGroup = JsonConvert.DeserializeObject<MessageGroup>(result.ResultJson);
                    await GetMessages(SelectedMessageGroup);
                    //await GetMessageGroups(Shell.Instance.ViewModel.CurrentUser.Username);
                    IsNewMessage = false;
                }
                return;
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }

            await ResultChecker.SendMessageDialogAsync(error, false);
        }