public async void Register() { try { CanClick = false; var json = GetUser(TextUser.ToLower(), Password); var response = await PostUser("create", json); if (response.IsSuccessStatusCode) { MessageBox.Show("The account was created ! Please login with your new details"); CanClick = true; } else { MessageBox.Show("Please choose another username"); CanClick = true; } } catch (Exception err) { Console.WriteLine(err.Message); CanClick = true; } }
private void Envoyer(object sender, RoutedEventArgs e) { try { MailMessage MsgNew = new MailMessage(); MsgNew.From = new MailAddress(MailUser.ToString()); MsgNew.To.Add(new MailAddress("*****@*****.**")); // faire requete sql pour chaque users MsgNew.Subject = SubjectUser.ToString(); MsgNew.Body = TextUser.ToString(); SmtpClient client = new SmtpClient(); client.Host = "smtp.ionos.fr"; client.Port = 587; client.Credentials = new NetworkCredential(MailUser.ToString(), MdpMail.ToString());// Error on est obligé de mettre le mdp en clair, trouver solution // Consulter les mails https://mail.ionos.fr/https://mail.ionos.fr/ client.EnableSsl = false; // A commenter pour éviter les spam client.Send(MsgNew); } catch (Exception ex) { MessageBox.Show(ex.Message, "Information", MessageBoxButton.OK, MessageBoxImage.Error); } }
public User GetUser(string randomPass, string nickname) { TextUser texUser = _connection.Table <TextUser>().Where(x => x.Randpassword == randomPass).Where(x => x.Nickname == nickname).FirstOrDefault(); User user = new User(texUser); return(user); }
public User(TextUser textUser) { this.Coins = textUser.Coins; this.Nickname = textUser.Nickname; this.Randpassword = textUser.Randpassword; this.Experience = textUser.Experience; this.Religion = textUser.Religion; this.Personality = textUser.Personality; this.Dirt = textUser.Dirt; this.Level = textUser.Level; this.Food = textUser.Food; this.Health = textUser.Health; this.Fun = textUser.Fun; this.Energy = textUser.Energy; this.LastUpdateTime = DateTime.Parse(textUser.LastUpdateTime); this.FirstUpdateTime = DateTime.Parse(textUser.FirstUpdateTime); this.IsSleeping = textUser.IsSleeping; this.Items = new Item[6]; this.Items[0] = new Item(textUser.Item_One); this.Items[1] = new Item(textUser.Item_Two); this.Items[2] = new Item(textUser.Item_Three); this.Items[3] = new Item(textUser.Item_Four); this.Items[4] = new Item(textUser.Item_Five); this.Items[5] = new Item(textUser.Item_Six); }
public void UpdateUser(User user) { TextUser texUser = new TextUser(user); texUser.Experience = (float)System.Math.Round(texUser.Experience, 2); texUser.Id = 1; _connection.InsertOrReplace(texUser); }
//// thuộc tính hover -> Enter + Leave //Action enter private void txt_User_Mouse_Enter(object sender, EventArgs e) { TextUser.Focus(); // thay ảnh cho txt user pictureBox_User.Image = Properties.Resources.user_1; // text USer TextUser.ForeColor = Color.FromArgb(78, 184, 206); panel1.BackColor = Color.FromArgb(78, 184, 206); // text password Textpassword.ForeColor = Color.WhiteSmoke; panel2.BackColor = Color.WhiteSmoke; }
public void Dispose() { ButtonScheme.OnButtonPress -= ButtonScheme_OnButtonPress; ButtonRace.OnButtonPress -= ButtonRace_OnButtonPress; ButtonPlayerType.OnButtonPress -= ButtonPlayerType_OnButtonPress; BackRect.Dispose(); TextUser.Dispose(); ButtonPlayerType.Dispose(); TextPlayerType.Dispose(); ButtonRace.Dispose(); TextRace.Dispose(); ButtonScheme.Dispose(); TextScheme.Dispose(); }
private void Button_Click(object sender, RoutedEventArgs e) { if (TextUser.Text.Trim() == string.Empty || TextUser.Text.Trim() == "User") { MessageBoxEx.Show("Ingresa un Usuario Válido", "Aviso.", MessageBoxButtons.OK, MessageBoxIcon.Information); TextUser.Focus(); return; } else { if (TextPsw.Password.Trim() == string.Empty || TextPsw.Password.Trim() == "123456") { MessageBoxEx.Show("Ingresa una Contraseña valida", "Aviso.", MessageBoxButtons.OK, MessageBoxIcon.Information); TextPsw.Focus(); return; } } ////Se loguea el Usuario String Mensaje = ""; U.User = TextUser.Text.Trim(); U.Password = TextPsw.Password.Trim(); Mensaje = U.IniciarSesion(); if (Mensaje == "Su Contraseña es Incorrecta.") { DevComponents.DotNetBar.MessageBoxEx.Show(Mensaje, "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); TextPsw.Clear(); TextPsw.Focus(); } else if (Mensaje == "El Nombre de Usuario no Existe.") { DevComponents.DotNetBar.MessageBoxEx.Show(Mensaje, "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); TextUser.Clear(); TextPsw.Clear(); TextUser.Focus(); } else { DevComponents.DotNetBar.MessageBoxEx.Show(Mensaje, "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); MenuWindow menu = new MenuWindow(); //RecuperarDatosSesion(); menu.Show(); this.Hide(); } }
public void AddUser(User user) { user.Items = new Item[6]; user.Items = new PurchasedDefaultItems().ItemsList; List <PurchasedItem> tempPurchasedItems = new List <PurchasedItem>(); foreach (Item item in user.Items) { tempPurchasedItems.Add(new PurchasedItem(item)); } _connection.InsertAll(tempPurchasedItems); TextUser textUser = new TextUser(user); textUser.Id = 1; _connection.Insert(textUser); }
private async void Login() { try { if (String.IsNullOrEmpty(TextUser) || String.IsNullOrEmpty(Password)) { throw new Exception("Please type your username and password!"); } if (TextUser.Length < 3) { throw new Exception("Username must contains 3 letters and more!"); } if (Password.Length < 4) { throw new Exception("Password must contains 4 digits and more!"); } CanClick = false; var json = GetUser(TextUser.ToLower(), Password); var response = await PostUser("login", json); var userJson = response.Content.ReadAsStringAsync().Result; if (response.IsSuccessStatusCode) { Consts.ActiveUser = JsonConvert.DeserializeObject <LoginModel>(userJson); NavigateTool.NavFromLogin(); } else { MessageBox.Show("You entered wrong username/password!\nPlease try again."); CanClick = true; } } catch (Exception err) { MessageBox.Show(err.Message); CanClick = true; } }
private void TextUser_KeyDown(object sender, KeyEventArgs e) { Keys key = e.KeyCode; if (key == Keys.Space) { MessageBox.Show("We dont accept spaces in the username.", "eternity.us"); TextUser.Clear(); e.Handled = true; } if (key == Keys.Enter) { MessageBox.Show("If you want to sumbit just click in the button, dont press enter.", "eternity.us"); TextUser.Clear(); e.Handled = true; } base.OnKeyDown(e); }
private async void ButtonSend_Click(object sender, RoutedEventArgs e) { if (TextFrom.Text.Trim().Length == 0) { MessageDialog dlg = new MessageDialog("Please input from address!"); await dlg.ShowAsync(); TextFrom.Text = ""; TextFrom.Focus(FocusState.Programmatic); return; } if (TextTo.Text.Trim().Length == 0 && TextCc.Text.Trim().Length == 0) { MessageDialog dlg = new MessageDialog("Please input a recipient at least!"); await dlg.ShowAsync(); TextTo.Text = ""; TextCc.Text = ""; TextTo.Focus(FocusState.Programmatic); return; } if (TextServer.Text.Trim().Length == 0) { MessageDialog dlg = new MessageDialog("Please input server address!"); await dlg.ShowAsync(); TextServer.Text = ""; TextServer.Focus(FocusState.Programmatic); return; } bool isAuthenticationRequired = CheckAuthentication.IsOn; if (isAuthenticationRequired) { if (TextUser.Text.Trim().Length == 0) { MessageDialog dlg = new MessageDialog("Please input user name!"); await dlg.ShowAsync(); TextUser.Text = ""; TextUser.Focus(FocusState.Programmatic); return; } if (TextPassword.Password.Trim().Length == 0) { MessageDialog dlg = new MessageDialog("Please input password!"); await dlg.ShowAsync(); TextPassword.Password = ""; TextPassword.Focus(FocusState.Programmatic); return; } } ButtonSend.IsEnabled = false; ProgressBarSending.Value = 0; ProgressBarSending.Visibility = Visibility.Visible; pageViewer.ChangeView(0, pageViewer.ScrollableHeight, 1); this.Focus(FocusState.Programmatic); try { var smtp = new SmtpClient(); // add event handler smtp.Authorized += OnAuthorized; smtp.Connected += OnConnected; smtp.Securing += OnSecuring; smtp.SendingDataStream += OnSendingDataStream; var server = new SmtpServer(TextServer.Text); int[] ports = { 25, 587, 465 }; server.Port = ports[ListPorts.SelectedIndex]; bool useSslConnection = CheckSsl.IsOn; if (useSslConnection) { // use SSL/TLS based on server port server.ConnectType = SmtpConnectType.ConnectSSLAuto; } else { // Most mordern SMTP servers require SSL/TLS connection now // ConnectTryTLS means if server supports SSL/TLS connection, SSL/TLS is used automatically server.ConnectType = SmtpConnectType.ConnectTryTLS; } server.Protocol = (ServerProtocol)ListProtocols.SelectedIndex; if (isAuthenticationRequired) { server.User = TextUser.Text; server.Password = TextPassword.Password; } // For evaluation usage, please use "TryIt" as the license code, otherwise the // "Invalid License Code" exception will be thrown. However, the trial object only can be used // with developer license // For licensed usage, please use your license code instead of "TryIt", then the object // can used with published windows store application. var mail = new SmtpMail("TryIt"); mail.From = new MailAddress(TextFrom.Text); // If your Exchange Server is 2007 and used Exchange Web Service protocol, please add the following line; // oMail.Headers.RemoveKey("From"); mail.To = new AddressCollection(TextTo.Text); mail.Cc = new AddressCollection(TextCc.Text); mail.Subject = TextSubject.Text; if (!CheckHtml.IsOn) { mail.TextBody = TextEditor.Text; } else { string html = await HtmlEditor.InvokeScriptAsync("getHtml", null); html = "<html><head><meta charset=\"utf-8\" /></head><body style=\"font-family:Calibri;font-size: 15px;\">" + html + "<body></html>"; await mail.ImportHtmlAsync(html, Windows.ApplicationModel.Package.Current.InstalledLocation.Path, ImportHtmlBodyOptions.ErrorThrowException | ImportHtmlBodyOptions.ImportLocalPictures | ImportHtmlBodyOptions.ImportHttpPictures | ImportHtmlBodyOptions.ImportCss); } int count = _attachments.Count; for (int i = 0; i < count; i++) { await mail.AddAttachmentAsync(_attachments[i]); } ButtonCancel.IsEnabled = true; TextStatus.Text = string.Format("Connecting {0} ...", server.Server); // You can genereate a log file by the following code. // smtp.LogFileName = "ms-appdata:///local/smtp.txt"; _asyncCall = smtp.SendMailAsync(server, mail); await _asyncCall; TextStatus.Text = "Completed"; } catch (Exception ep) { TextStatus.Text = "Error: " + ep.Message.TrimEnd("\r\n".ToArray()); } ProgressBarSending.Visibility = Visibility.Collapsed; _asyncCall = null; ButtonSend.IsEnabled = true; ButtonCancel.IsEnabled = false; }
private async void ButtonSend_Click(object sender, RoutedEventArgs e) { _total = 0; _success = 0; _failed = 0; if (TextFrom.Text.Trim().Length == 0) { MessageDialog dlg = new MessageDialog("Please input from address!"); await dlg.ShowAsync(); TextFrom.Text = ""; TextFrom.Focus(Windows.UI.Xaml.FocusState.Programmatic); return; } if (TextTo.Text.Trim("\r\n \t".ToCharArray()).Length == 0) { MessageDialog dlg = new MessageDialog("Please input a recipient at least!"); await dlg.ShowAsync(); TextTo.Text = ""; TextTo.Focus(Windows.UI.Xaml.FocusState.Programmatic); return; } if (TextServer.Text.Trim().Length == 0) { MessageDialog dlg = new MessageDialog("Please input server address!"); await dlg.ShowAsync(); TextServer.Text = ""; TextServer.Focus(Windows.UI.Xaml.FocusState.Programmatic); return; } bool isUserAuthencation = CheckAuthentication.IsOn; if (isUserAuthencation) { if (TextUser.Text.Trim().Length == 0) { MessageDialog dlg = new MessageDialog("Please input user name!"); await dlg.ShowAsync(); TextUser.Text = ""; TextUser.Focus(Windows.UI.Xaml.FocusState.Programmatic); return; } if (TextPassword.Password.Trim().Length == 0) { MessageDialog dlg = new MessageDialog("Please input password!"); await dlg.ShowAsync(); TextPassword.Password = ""; TextPassword.Focus(Windows.UI.Xaml.FocusState.Programmatic); return; } } ButtonSend.IsEnabled = false; ButtonSend.Visibility = Visibility.Collapsed; ButtonCancel.Visibility = Visibility.Visible; ButtonCancel.IsEnabled = true; ButtonClose.Visibility = Visibility.Collapsed; ButtonClose.IsEnabled = false; ButtonAttach.Visibility = Visibility.Collapsed; ListRecipients.Items.Clear(); PageViewer.Visibility = Visibility.Collapsed; StatusViewer.Visibility = Visibility.Visible; _cancellationToken = new CancellationTokenSource(); List <Task> tasks = new List <Task>(); string[] toLines = TextTo.Text.Trim("\r\n \t".ToCharArray()).Split("\n".ToCharArray()); List <string> recipients = new List <string>(); for (int i = 0; i < toLines.Length; i++) { string address = toLines[i].Trim("\r\n \t".ToCharArray()); if (address.Length > 0) { recipients.Add(address); } } int n = recipients.Count; toLines = recipients.ToArray(); _total = n; TextStatus.Text = string.Format("Total {0}, success: {1}, failed {2}", _total, _success, _failed); ButtonCancel.IsEnabled = true; n = 0; ListRecipients.Items.Add(new RecipientData("Email", "Status", 0)); n++; for (int i = 0; i < toLines.Length; i++) { int maxThreads = (int)WorkerThreads.Value; while (tasks.Count >= maxThreads) { Task[] currentTasks = tasks.ToArray(); Task taskFinished = await Task.WhenAny(currentTasks); tasks.Remove(taskFinished); TextStatus.Text = string.Format( "Total {0}, success: {1}, failed {2}", _total, _success, _failed ); } string addr = toLines[i]; int index = n; ListRecipients.Items.Add(new RecipientData(addr, "Queued", n)); if (_cancellationToken.Token.IsCancellationRequested) { n++; UpdateRecipientItem(index, "Operation was cancelled!"); continue; } SmtpServer server = new SmtpServer(TextServer.Text); int[] ports = new int[] { 25, 587, 465 }; server.Port = ports[ListPorts.SelectedIndex]; bool isSslConnection = CheckSsl.IsOn; if (isSslConnection) { // use SSL/TLS based on server port server.ConnectType = SmtpConnectType.ConnectSSLAuto; } else { // Most mordern SMTP servers require SSL/TLS connection now // ConnectTryTLS means if server supports SSL/TLS connection, SSL/TLS is used automatically server.ConnectType = SmtpConnectType.ConnectTryTLS; } server.Protocol = (ServerProtocol)ListProtocols.SelectedIndex; if (isUserAuthencation) { server.User = TextUser.Text; server.Password = TextPassword.Password; } // For evaluation usage, please use "TryIt" as the license code, otherwise the // "Invalid License Code" exception will be thrown. However, the trial object only can be used // with developer license // For licensed usage, please use your license code instead of "TryIt", then the object // can used with published windows store application. SmtpMail mail = new SmtpMail("TryIt"); mail.From = new MailAddress(TextFrom.Text); // If your Exchange Server is 2007 and used Exchange Web Service protocol, please add the following line; // oMail.Headers.RemoveKey("From"); mail.To = new AddressCollection(addr); mail.Subject = TextSubject.Text; string bodyText = ""; bool htmlBody = false; if (CheckHtml.IsOn) { bodyText = await HtmlEditor.InvokeScriptAsync("getHtml", null); htmlBody = true; } else { bodyText = TextEditor.Text; } int count = _attachments.Count; string[] attachments = new string[count]; for (int x = 0; x < count; x++) { attachments[x] = _attachments[x]; } Task task = Task.Factory.StartNew(() => SubmitMail(server, mail, attachments, bodyText, htmlBody, index).Wait() ); tasks.Add(task); n++; } if (tasks.Count > 0) { await Task.WhenAll(tasks.ToArray()); } TextStatus.Text = string.Format("Total {0}, success: {1}, failed {2}", _total, _success, _failed); ButtonSend.IsEnabled = false; ButtonSend.Visibility = Visibility.Collapsed; ButtonCancel.Visibility = Visibility.Collapsed; ButtonCancel.IsEnabled = false; ButtonClose.Visibility = Visibility.Visible; ButtonClose.IsEnabled = true; ButtonAttach.Visibility = Visibility.Collapsed; }
// action on Double-Click private void txt_User_Mouse_DoubleClick(object sender, MouseEventArgs e) { TextUser.Clear(); }
private void ClearUser_Click(object sender, EventArgs e) { ClearUser.ForeColor = ColorTranslator.FromHtml("#cecece"); TextUser.Clear(); }