Complete Feedback Hub (without credentials)
This commit is contained in:
+133
-1
@@ -13,6 +13,12 @@ using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
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
|
||||
|
||||
@@ -27,7 +33,133 @@ namespace FoxTube
|
||||
public Feedback()
|
||||
{
|
||||
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); }
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user