public Umbraco6xAPI(string sUrl, Credentials credentials) { _umbracoDocumentApi = new Umbraco6DocumentService.documentService(); _umbracoDocumentApi.Url = sUrl + "/umbraco/webServices/api/DocumentService.asmx"; // _umbracoDocumentApi.PreAuthenticate = true; _umbracoWebService = new Umbraco6xWebService.webService(); _umbracoWebService.Url = sUrl + "/umbraco/webServices/api/DocumentService.asmx"; _credentials = credentials; }
private void ConnectUmbraco6x(TreeView treeView, string sServerUrl, string sSiteType) { LoginForm login = new LoginForm(); login.SiteUrl = sServerUrl; login.SiteType = sSiteType; login.Username = "******"; if (login.ShowDialog(this) == DialogResult.Cancel) return; Credentials credentials = new Credentials(); credentials.UserName = login.loginControl1.Username; credentials.Password = login.loginControl1.Password; Umbraco6xItem item = null; try { Umbraco6xAPI umbracoAPI = new Umbraco6xAPI(sServerUrl, credentials); item = Umbraco6xItem.GetRoot(umbracoAPI, new ConverterOptions()); } catch (Exception ex) { MessageBox.Show("Error logging into site, wrong username or password?\nError message: " + ex.Message); return; } item.Options.LoginName = credentials.UserName; item.Options.LoginPassword = credentials.Password; item.Options.HostName = sServerUrl; treeView.Nodes.Clear(); TreeNode newNode = new TreeNode(item.Name); newNode.Tag = item; treeView.Nodes.Add(newNode); treeView.SelectedNode = newNode; }