Archived
1
0

Complete Feedback Hub (without credentials)

This commit is contained in:
Michael Gordeev
2018-04-20 19:28:39 +03:00
parent d957f908e6
commit 8750df528f
3 changed files with 143 additions and 4 deletions
+9 -2
View File
@@ -25,7 +25,7 @@
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="30"/> <ColumnDefinition Width="30"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBox Name="subject" Grid.Column="0" HorizontalAlignment="Stretch"/> <TextBox Name="subject" Grid.Column="0" HorizontalAlignment="Stretch" GotFocus="subject_GotFocus"/>
<TextBlock Name="subjectMissed" Grid.Column="1" FontFamily="Segoe MDL2 Assets" Text="&#xE814;" Foreground="Red" FontSize="30" Visibility="Collapsed"/> <TextBlock Name="subjectMissed" Grid.Column="1" FontFamily="Segoe MDL2 Assets" Text="&#xE814;" Foreground="Red" FontSize="30" Visibility="Collapsed"/>
</Grid> </Grid>
<TextBlock Text="Give us more detail (optional)" Margin="0,10,0,0"/> <TextBlock Text="Give us more detail (optional)" Margin="0,10,0,0"/>
@@ -37,8 +37,15 @@
<TextBlock Text="Thank you! It's very imortant for us. Thank your for helping us making the app better" Foreground="Green"/> <TextBlock Text="Thank you! It's very imortant for us. Thank your for helping us making the app better" Foreground="Green"/>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" BorderBrush="OrangeRed" BorderThickness="5" Margin="0,10,30,0" Visibility="Collapsed" Name="cooldown">
<TextBlock FontFamily="Segoe MDL2 Assets" Text="&#xE7BA;" FontSize="40" Foreground="OrangeRed" Margin="5"/>
<StackPanel>
<TextBlock Text="You reached your daily feedback limit" Foreground="OrangeRed" FontWeight="Bold" FontSize="20"/>
<TextBlock Text="To prevent spaming our mailbox we allow our users to send 1 feedback per day. Come back later to leave additional feedback." Foreground="OrangeRed"/>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Button Content="Submit feedback" Name="submit" Margin="0,10,10,10"/> <Button Content="Submit feedback" Name="submit" Margin="0,10,10,10" Click="submit_Click"/>
<ProgressRing VerticalAlignment="Center" Name="ring" Foreground="Red"/> <ProgressRing VerticalAlignment="Center" Name="ring" Foreground="Red"/>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
+133 -1
View File
@@ -13,6 +13,12 @@ using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation; using Windows.UI.Xaml.Navigation;
using Windows.Storage; using Windows.Storage;
using System.Net.Mail;
using System.Net;
using Windows.UI.Popups;
using Windows.UI;
using System.Threading.Tasks;
using System.Diagnostics;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
@@ -27,7 +33,133 @@ namespace FoxTube
public Feedback() public Feedback()
{ {
this.InitializeComponent(); this.InitializeComponent();
settings.Values["feedbackRecord"] = null; if (settings.Values["feedbackRecord"] == null)
settings.Values.Add("feedbackRecord", DateTimeToString(DateTime.Now - new TimeSpan(2, 0, 0, 0)));
TimeSpan interval = new TimeSpan(1, 0, 0, 0);
if(DateTime.Now - StringDateTime(settings.Values["feedbackRecord"].ToString()) < interval)
{
subject.IsEnabled = false;
details.IsEnabled = false;
promblemRadio.IsEnabled = suggestionRadio.IsEnabled = false;
submit.IsEnabled = false;
cooldown.Visibility = Visibility.Visible;
}
} }
string DateTimeToString(DateTime dateTime)
{
string value = string.Format("{0} {1} {2} {3} {4} {5}", dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second);
Debug.WriteLine("Debag " + value);
return value;
}
DateTime StringDateTime(string value)
{
string[] t = value.Split(' ');
List<int> i = new List<int>();
foreach (string s in t)
i.Add(Convert.ToInt32(s));
return new DateTime(i[0], i[1], i[2], i[3], i[4], i[5]);
}
private async void submit_Click(object sender, RoutedEventArgs e)
{
//subject.Text = "This is test feedback";
//details.Text = "This is test for FoxTube Feedback System (FTFS)\nAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz 0123456789";
if (subject.Text == "")
{
subjectMissed.Visibility = Visibility.Visible;
subject.Background = new SolidColorBrush(Colors.Pink);
}
else
{
string Type()
{
if ((bool)suggestionRadio.IsChecked) return "Suggestion";
else return "Problem";
}
MailMessage msg = new MailMessage();
msg.To.Add("foxgameofficial+foxtube@gmail.com");
msg.From = new MailAddress("foxgameofficial+foxtube@gmail.com");
msg.Subject = "FoxTube feedback";
msg.Body = string.Format("Type: {0}\nTime: {1}\n\nTitle:\n{2}\n\nDetails:\n{3}", Type(), DateTime.Now, subject.Text, details.Text);
subject.IsEnabled = false;
details.IsEnabled = false;
promblemRadio.IsEnabled = suggestionRadio.IsEnabled = false;
submit.IsEnabled = false;
ring.IsActive = true;
await Task.Delay(1000);
Submit(msg);
}
}
async void Submit(MailMessage mes)
{
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
client.EnableSsl = true;
client.Credentials = new NetworkCredential("youwillneverknowthisadress@gmail.com", "thisisthepassword12345");
try
{
client.Send(mes);
greenResult.Visibility = Visibility.Visible;
settings.Values["feedbackRecord"] = DateTimeToString(DateTime.Now);
}
catch
{
MessageDialog message = new MessageDialog("We was unable to send your feedback due to connection problems or internal server error. Please, try again later.", "Failed to send your feedback");
await message.ShowAsync();
subject.IsEnabled = true;
details.IsEnabled = true;
promblemRadio.IsEnabled = suggestionRadio.IsEnabled = true;
submit.IsEnabled = true;
}
ring.IsActive = false;
}
private void subject_GotFocus(object sender, RoutedEventArgs e)
{
subjectMissed.Visibility = Visibility.Collapsed;
subject.Background = new SolidColorBrush();
}
/*
private void feedbackSubmit_Click(object sender, EventArgs e)
{
if (feedbackTitle.Text == "") MessageBox.Show("Please, fill the first field before submitting.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
else
{
string type()
{
if (feedbackSuggestion.Checked) return "Suggestion";
else return "Problem";
}
try
{
MailMessage msg = new MailMessage();
msg.To.Add("foxgameofficial@gmail.com");
msg.From = new MailAddress("sender@gmail.com");
msg.Subject = "Stream2String feedback";
msg.Body = "Type: " + type() + "\n\nTitle: " + feedbackTitle.Text + "\nDetails: " + feedbackDetails.Text + "\n\n" + feedbackMail.Text;
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
client.EnableSsl = true;
client.Credentials = new NetworkCredential("sender@gmail.com", "Thisisthepassword07734");
//Send the msg
client.Send(msg);
MessageBox.Show("Thank you for your feedback. You've just helped us to make our program better!", "Congratulations!", MessageBoxButtons.OK, MessageBoxIcon.Information);
proceedFeedback();
Properties.Settings.Default.feedback = true;
Properties.Settings.Default.Save();
}
catch { MessageBox.Show("Unfortunately, we can't send your feedback now. Please, try again later.", "Server connection error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
}
}*/
} }
} }
+1 -1
View File
@@ -47,7 +47,7 @@ namespace FoxTube
titleBar.BackgroundColor = titleBar.ButtonBackgroundColor = Colors.Red; titleBar.BackgroundColor = titleBar.ButtonBackgroundColor = Colors.Red;
titleBar.ForegroundColor = titleBar.ButtonForegroundColor = Colors.White; titleBar.ForegroundColor = titleBar.ButtonForegroundColor = Colors.White;
titleBar.ButtonHoverBackgroundColor = Colors.OrangeRed; titleBar.ButtonHoverBackgroundColor = Colors.IndianRed;
titleBar.ButtonPressedBackgroundColor = Colors.DarkRed; titleBar.ButtonPressedBackgroundColor = Colors.DarkRed;
} }