Exemplo n.º 1
0
        private bool Connect()
        {
            if (Connect(Properties.Settings.Default.CredentialUserName, Properties.Settings.Default.CredentialPassword))
            {
                return(true);
            }

            FormLogin form = new FormLogin();

            form.UserName = Properties.Settings.Default.CredentialUserName;
            form.Password = Properties.Settings.Default.CredentialPassword;
            if (DialogResult.OK == form.ShowDialog())
            {
                string userName = form.UserName;

                // try and convert email to user name
                if (form.UserName.Contains('@'))
                {
                    string email = form.UserName;
                    userName = ClientGuest.EmailToUserName(email);
                    // if userName is null/empty, email does not exist
                    if (string.IsNullOrEmpty(userName))
                    {
                        MessageBox.Show(string.Format(Properties.Resources.ID_EMAILDOESNOTEXIST, email));
                    }
                }
                return(Connect(userName, form.Password));
            }
            else
            {
                _log.Info("User cancelled connection!");
                return(true);
            }
        }
Exemplo n.º 2
0
        protected override void OnClosing(CancelEventArgs e)
        {
            if (DialogResult != DialogResult.Cancel)
            {
                try
                {
                    System.Net.ServicePointManager.ServerCertificateValidationCallback =
                        ((sender, certificate, chain, sslPolicyErrors) => true);

                    PLMPackServiceClient client = WCFClientSingleton.ClientGuest;
                    if (null != client.Connect())
                    {
                        e.Cancel = true;
                    }

                    string userName = client.EmailToUserName(Email);
                    string email    = client.UserNameToEmail(UserName);

                    if (!string.IsNullOrEmpty(userName))
                    {
                        MessageBox.Show(string.Format(Properties.Resources.ID_EMAILALREADYUSED, Email));
                        e.Cancel = true;
                    }
                    else if (!string.IsNullOrEmpty(email))
                    {
                        MessageBox.Show(string.Format(Properties.Resources.ID_USERNAMEALREADYUSED, UserName));
                        e.Cancel = true;
                    }
                    else if (client.CreateUser(UserName, UserPassword, FirstName, LastName, Email, Country, City, PhoneNumber, Company, WebSiteURL))
                    {
                        MessageBox.Show(string.Format(Properties.Resources.ID_USERSUCCESSFULLYCREATED, UserName));
                        e.Cancel = false;
                    }
                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message);
                }
            }
            base.OnClosing(e);
        }