Пример #1
0
        private async void FeedbackDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            try
            {
                var log = await FileIOHelper.CreateCacheFileAsync(Guid.NewGuid().ToString() + "_Feedback");

                if (!ReportBox.Text.IsNullorEmpty())
                {
                    await FileIO.AppendTextAsync(log, "User Voice = " + ReportBox.Text + Environment.NewLine);

                    if (!EmailBox.Text.IsNullorEmpty())
                    {
                        if (new EmailAddressAttribute().IsValid(EmailBox.Text))
                        {
                            await FileIO.AppendTextAsync(log, "Email = " + EmailBox.Text + Environment.NewLine);

                            var fileBytes = await FileIOHelper.GetBytesAsync(log);

                            WebHelper.UploadFilesToServer(new Uri(Utils.UPLOAD_CRASH), null, log.Name, "application/octet-stream", fileBytes);
                        }
                        else
                        {
                            EmailBox.PlaceholderText = "Invalid Email address!";
                            await FeedbackDialog.ShowAsync();
                        }
                    }
                    else
                    {
                        EmailBox.PlaceholderText = "Invalid Email address!";
                        await FeedbackDialog.ShowAsync();
                    }
                }
                else
                {
                    ReportBox.PlaceholderText = "Input some opinion";
                    await FeedbackDialog.ShowAsync();
                }
            }
            catch (Exception)
            {
                FeedbackDialog.PrimaryButtonText = "Failed";
                await FeedbackDialog.ShowAsync();
            }
        }