Ejemplo n.º 1
0
        private void InstantiateService()
        {
            ServerConnection.Configuration config = new ServerConnection.Configuration();
            try
            {
                if (SelectedConfiguration == null)
                {
                    throw new Exception("Please choose a configuration.");
                }

                //Get the Password
                string         password = String.Empty;
                PasswordWindow pw       = new PasswordWindow();
                pw.Owner = Application.Current.MainWindow;
                bool?submitted = pw.ShowDialog();
                if (submitted.Value)
                {
                    password = pw.GetPassword();
                }
                else
                {
                    ErrorWindow needPassword = new ErrorWindow("You need to supply a Password and Submit. Try again.");
                    needPassword.Owner = Application.Current.MainWindow;
                    needPassword.ShowDialog();
                    return;
                }


                _serverConnect = new ConsolelessServerConnection();
                ConsolelessServerConnection.Configuration _config = new ConsolelessServerConnection.Configuration();
                _config = _serverConnect.GetServerConfiguration(
                    SelectedConfiguration.Attribute("server").Value,
                    SelectedConfiguration.Attribute("orgName").Value,
                    SelectedConfiguration.Attribute("userName").Value,
                    password,
                    SelectedConfiguration.Attribute("domain").Value);

                _serviceProxy = ServerConnection.GetOrganizationProxy(config);


                // This statement is required to enable early-bound type support.
                _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors
                .Add(new ProxyTypesBehavior());

                // The OrganizationServiceContext is an object that wraps the service
                // proxy and allows creating/updating multiple records simultaneously.
                _orgContext = new OrganizationServiceContext(_serviceProxy);

                //Set the ActiveConnection
                ActiveConfiguration = SelectedConfiguration;

                //If all worked, retrieve the solutions.
                LoadSolutions();
            }
            catch (Exception e)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(e.Message);
                sb.AppendLine();
                sb.AppendLine("Please fix the Connection information and try again.");
                ErrorWindow errorWindow = new ErrorWindow(sb.ToString());
                errorWindow.Owner = Application.Current.MainWindow;
                var x = errorWindow.ShowDialog();
            }
        }
Ejemplo n.º 2
0
        private void InstantiateService()
        {
            try
            {
                if (SelectedConfiguration == null)
                    throw new Exception("Please choose a configuration.");

                //Get the Password
                string password = String.Empty;
                PasswordWindow pw = new PasswordWindow();
                pw.Owner = Application.Current.MainWindow;
                bool? submitted = pw.ShowDialog();
                if (submitted.Value)
                {
                    password = pw.GetPassword();
                }
                else
                {
                    ErrorWindow needPassword = new ErrorWindow("You need to supply a Password and Submit. Try again.");
                    needPassword.Owner = Application.Current.MainWindow;
                    needPassword.ShowDialog();
                    return;
                }
                

                _serverConnect = new ConsolelessServerConnection();
                ConsolelessServerConnection.Configuration _config = new ConsolelessServerConnection.Configuration();
                _config = _serverConnect.GetServerConfiguration(
                    SelectedConfiguration.Attribute("server").Value,
                    SelectedConfiguration.Attribute("orgName").Value,
                    SelectedConfiguration.Attribute("userName").Value, 
                    password,
                    SelectedConfiguration.Attribute("domain").Value);

                _serviceProxy = new OrganizationServiceProxy(_config.OrganizationUri,
                    _config.HomeRealmUri,
                    _config.Credentials,
                    _config.DeviceCredentials);

                // This statement is required to enable early-bound type support.
                _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors
                    .Add(new ProxyTypesBehavior());

                // The OrganizationServiceContext is an object that wraps the service
                // proxy and allows creating/updating multiple records simultaneously.
                _orgContext = new OrganizationServiceContext(_serviceProxy);

                //Set the ActiveConnection
                ActiveConfiguration = SelectedConfiguration;

                //If all worked, retrieve the solutions.
                LoadSolutions();

            }
            catch (Exception e)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(e.Message);
                sb.AppendLine();
                sb.AppendLine("Please fix the Connection information and try again.");
                ErrorWindow errorWindow = new ErrorWindow(sb.ToString());
                errorWindow.Owner = Application.Current.MainWindow;
                var x = errorWindow.ShowDialog();
            }
        }