private void _connectButton_Click(object sender, EventArgs e)
        {
            _serverSettingsToTry = new SharePoint.SharePointServerSettings();

            _serverSettingsToTry.Uri = _urlTextBox.Text.Trim();

            if (_useCredentialsCheckBox.Checked)
            {
                _serverSettingsToTry.UserName = _userNameTextBox.Text.Trim();
                _serverSettingsToTry.Password = _passwordTextBox.Text;
                _serverSettingsToTry.Domain   = _domainTextBox.Text.Trim();
            }
            else
            {
                _serverSettingsToTry.UserName = null;
                _serverSettingsToTry.Password = null;
                _serverSettingsToTry.Domain   = null;
            }

            if (_useProxyCheckBox.Checked)
            {
                _serverSettingsToTry.ProxyUri = _hostTextBox.Text.Trim();
                int.TryParse(_portTextBox.Text, out _serverSettingsToTry.ProxyPort);
            }
            else
            {
                _serverSettingsToTry.ProxyUri  = null;
                _serverSettingsToTry.ProxyPort = 0;
            }

            // Try to connect
            _mainForm.BeginOperation(new MethodInvoker(TryConnect));
        }
        private void TryConnect()
        {
            _mainForm.SetOperationText("Connecting to SharePoint Server...");
            Exception error = null;

            try
            {
                // To make sure we can connect to this 2010 SharePoint Server, use
                // the helper to get the lists
                SharePoint.SPHelper     helper = new SharePoint.SPHelper(_serverSettingsToTry);
                SharePoint.SPListInfo[] lists  = helper.GetLists();

                if (lists == null || lists.Length == 0)
                {
                    error = new Exception("Could not find any lists in the SharePoint Server.\n\nTry again with a different server.");
                }
                else
                {
                    // We are golden, save the lists and the server properties
                    _lists          = lists;
                    _serverSettings = _serverSettingsToTry;
                }
            }
            catch (Exception ex)
            {
                // Throw our own exception with info
                error = new Exception(string.Format("Error: {0}\n\nReasons might be:\n- Invalid credentials\n- Invalid Proxy settings\n- Server may not be SharePoint 2010. Try again with a valid URL to SharePoint 2010", ex.Message));
            }

            _mainForm.EndOperation(error);
        }
        public void SetServerSettings(SharePoint.SharePointServerSettings serverSettings)
        {
            _serverSettings = serverSettings;

            _urlTextBox.Text = _serverSettings.Uri;
            _useCredentialsCheckBox.Checked = _serverSettings.UserName != null;
            _userNameTextBox.Text           = _serverSettings.UserName;
            _passwordTextBox.Text           = _serverSettings.Password;
            _domainTextBox.Text             = _serverSettings.Domain;
            _useProxyCheckBox.Checked       = _serverSettings.ProxyUri != null;
            _hostTextBox.Text = _serverSettings.ProxyUri;
            _portTextBox.Text = _serverSettings.ProxyPort.ToString();

            UpdateUIState();
        }
Exemplo n.º 4
0
      public void SetProperties(
         SharePoint.SharePointServerSettings serverSettings,
         string imageDocumentFileName,
         string serverDocumentPathAndFileName,
         MyDocumentFormat format)

      {
         _serverSettings = serverSettings;
         _imageDocumentFileName = imageDocumentFileName;
         _serverDocumentPathAndFileName = serverDocumentPathAndFileName;
         _format = format;

         UriBuilder builder = new UriBuilder(_serverSettings.Uri);
         builder.Path = Path.Combine(builder.Path, serverDocumentPathAndFileName);
         _serverDocumentFullUri = builder.Uri;

         _imageDocumentFileNameTextBox.Text = _imageDocumentFileName;
         _serverDocumentNameTextBox.Text = _serverDocumentFullUri.ToString();
      }
Exemplo n.º 5
0
        public void SetSharePointSettings(SharePoint.SharePointServerSettings serverSettings, SharePoint.SPListInfo[] lists)
        {
            _serverSettings = serverSettings;

            _curerntFolderItem  = null;
            _errorLabel.Visible = false;

            // Populate the document libraries, select "Shared Documents" initially if it exists

            _documentLibrariesListBox.BeginUpdate();
            _documentLibrariesListBox.Items.Clear();

            SharePoint.SPListInfo sharedDocumentList = null;

            foreach (SharePoint.SPListInfo list in lists)
            {
                _documentLibrariesListBox.Items.Add(list);

                if (string.Compare(list.Title, "Shared Documents", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    sharedDocumentList = list;
                }
            }
            _documentLibrariesListBox.EndUpdate();

            if (_documentLibrariesListBox.Items.Count > 0)
            {
                if (sharedDocumentList != null)
                {
                    _documentLibrariesListBox.SelectedItem = sharedDocumentList;
                }
                else
                {
                    _documentLibrariesListBox.SelectedIndex = 0;
                }
            }

            UpdateUIState();
        }
Exemplo n.º 6
0
 public SPHelper(SharePointServerSettings serverSettings)
 {
     _serverSettings = serverSettings;
 }