public void SetCredentials()
 {
     EncryptedCredentials = PasswordHepler.SetFullString(
         "<Credentails Username=\"" + UserName + "\" Password=\"" + PasswordHepler.ConvertSecureStringToString(Password) + "\" Domain=\"" + Domain + "\" />", Id, emgName);
     if (this.CredentialsChanged != null)
     {
         CredentialsChanged(this, new EventArgs());
     }
 }
Example #2
0
        private void btnTestConnection_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                X1 x = new X1(ConsoleContext.GetConsoleEMG(), new Guid("5a49b80c-4c34-d189-ca94-a591580f1995"), "Project Connector");
                x.CheckLicense();

                credsControl.SetCredentials();

                Type            type        = Type.GetTypeFromProgID("Microsoft.EnterpriseManagement.ServiceManager.ProjectServer.Adapter.ProjectAdapter");
                object          inst        = Activator.CreateInstance(type);
                IProjectAdapter projAdapter = (IProjectAdapter)inst;

                if (data.IsO365)
                {
                    projAdapter.Connect(data.PwaUrl, credsControl.UserName, PasswordHepler.ConvertSecureStringToString(credsControl.Password));
                }
                else
                {
                    projAdapter.Connect(data.PwaUrl, credsControl.UserName, PasswordHepler.ConvertSecureStringToString(credsControl.Password), credsControl.Domain);
                }
                var success = projAdapter.IsConnected();

                using (new WaitCursor())
                {
                    if (success)
                    {
                        MessageBox.Show(ServiceManagerLocalization.GetStringFromManagementPack("strConnectSuccess"), ServiceManagerLocalization.GetStringFromManagementPack("strConnectorTitle"),
                                        MessageBoxButton.OK, MessageBoxImage.Information);
                        this.IsNextButtonEnabled = true;
                    }
                    else
                    {
                        MessageBox.Show(ServiceManagerLocalization.GetStringFromManagementPack("strConnectFailed"), ServiceManagerLocalization.GetStringFromManagementPack("strConnectorTitle"),
                                        MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                ConsoleContextHelper.Instance.ShowErrorDialog(ex, ex.Message, ConsoleFramework.ConsoleJobExceptionSeverity.Error);
            }
        }