Ejemplo n.º 1
0
        public OpenSiteWindow(RecentSite recentSite)
            : this()
        {
            var authenticationModes = (List<AuthenticationModeComboBoxItem>) AuthenticationModeComboBox.ItemsSource;

            if (recentSite != null)
            {
                SiteUrl = SiteUrlTextBox.Text = recentSite.Url;
                UserName = UserNameTextBox.Text = recentSite.UserName;
                UseCurrentUserCredentialsCheckBox.IsChecked = recentSite.UseCurrentUserCredentials;

                AuthenticationModeComboBox.SelectedIndex =
                    authenticationModes.Select(auth => auth.Type).ToList().IndexOf(recentSite.Authentication);
                UserPasswordTextBox.Focus();
            }
            else
            {
                SiteUrl = SiteUrlTextBox.Text = "https://sharepoint";
            }
        }
Ejemplo n.º 2
0
        private void LoadSite(RecentSite recentSite = null)
        {
            if (recentSite == null)
            {
                recentSite = Globals.Configuration.RecentSites.LastOrDefault();
            }

            var openSiteWindow = new OpenSiteWindow(recentSite)
            {
                Owner = this
            };

            if (openSiteWindow.ShowDialog() == true)
            {
                var clientContext = openSiteWindow.ClientContext;
                if (clientContext != null)
                {
                    _logger.Info("Connected to {0}", clientContext.Url);
                    ClientTreeView.Fill(clientContext, _logger);
                }
                LoadMenu();
            }
        }
Ejemplo n.º 3
0
        private void OK_OnClick(object sender, RoutedEventArgs e)
        {
            var authType = ((AuthenticationModeComboBoxItem) AuthenticationModeComboBox.SelectedValue).Type;
            var site = new RecentSite
            {
                Url = SiteUrlTextBox.Text,
                UserName = UserNameTextBox.Text,
                UseCurrentUserCredentials = UseCurrentUserCredentialsCheckBox.IsChecked ?? false,
                Authentication = authType
            };

            MessageLabel.Content = string.Format("Connecting to {0} ...", site.Url);

            try
            {
                ClientContext = new SPClientContext(
                    site.Url,
                    site.Authentication,
                    site.UserName,
                    UserPasswordTextBox.Password);
            }
            catch (Exception ex)
            {
                MessageLabel.Content = ex.Message;
                return;
            }

            OKButton.IsEnabled = false;
            CancelButton.IsEnabled = false;
            SiteUrlTextBox.IsEnabled = false;
            AuthenticationModeComboBox.IsEnabled = false;
            UseCurrentUserCredentialsCheckBox.IsEnabled = false;
            UserNameTextBox.IsEnabled = false;
            UserPasswordTextBox.IsEnabled = false;

            var promise = Utility.ExecuteAsync(ClientContext.ConnectAsync());
            promise.Done(() =>
            {
                MessageLabel.Content = "Done";
                Globals.Configuration.Add(ClientContext);
                Globals.Configuration.Save();

                CloseDialog();
            });

            promise.Fail(ex => { MessageLabel.Content = ex.Message; });

            promise.Always(() =>
            {
                OKButton.IsEnabled = true;
                CancelButton.IsEnabled = true;
                SiteUrlTextBox.IsEnabled = true;
                AuthenticationModeComboBox.IsEnabled = true;
                SetVisiblility();
            });
        }