public void DownloadTest() { string url = "https://community.workday.com/sites/default/files/file-hosting/productionapi/index.html"; Dictionary <string, string> results = WDWebService.Download(url); Assert.AreEqual(true, results.ContainsValue("Absence_Management")); }
protected void LoadData() { WDWebService service = new WDWebService(); service.Url = SiteConfigs.GetConfig().WebGroupServiceUrl; WebSite = service.GetWebSiteTree(SiteID, ShowChildren); }
WDWebService GetWDWebService() { WDWebService client = new WDWebService(); client.Url = CDHelper.SiteConfig.WebGroupServiceUrl; return(client); }
private void btnTest_Click(object sender, EventArgs e) { try { string url = WDWebService.GetServiceURL(((WDURLItem)cboConnEnv.SelectedItem).Key, txtTenant.Text, txtUsername.Text, txtPassword.Text); if (url.Length > 4 && url.Substring(0, 4) == "http") { lnkConnURL.Text = String.Concat(url, "/", txtTenant.Text, "/"); MessageBox.Show("Success", "Connection Test", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (url.Length > 30) { url = url.Substring(0, 30) + "..."; } throw new Exception("Data returned: " + url); } } catch (Exception ex) { MessageBox.Show("Test failed. " + ex.Message, "Connection Test", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnSave_Click(object sender, EventArgs e) { try { if (txtName.Text.Length == 0) { throw new Exception("Name is required."); } if (cboConnEnv.SelectedIndex == ListBox.NoMatches) { throw new Exception("An environment URL must be selected."); } txtName.Enabled = false; string conn = txtName.Text; string tenant = txtTenant.Text; string username = txtUsername.Text; string password = Crypto.Protect(txtPassword.Text); string envText = ((WDURLItem)cboConnEnv.SelectedItem).Value; string envURL = ((WDURLItem)cboConnEnv.SelectedItem).Key; bool savePassword = chkSavePassword.Checked; this.Password = password; string url = ""; // New Item if (lstConnections.FindStringExact(txtName.Text) == ListBox.NoMatches) { if (lstConnections.ValuesToString(txtName.Text).Length + conn.Length <= 500) { lstConnections.Items.Add(txtName.Text); string conns = lstConnections.ValuesToString(); Settings.Set(IniSection.Connections, IniKey.Names, conns); } else { throw new Exception("List of all names cannot exceed 500 characters."); } } Settings.Set(IniSection.Connection, conn, IniKey.Environment, envText); Settings.Set(IniSection.Connection, conn, IniKey.Tenant, tenant); Settings.Set(IniSection.Connection, conn, IniKey.Username, username); Settings.Set(IniSection.Connection, conn, IniKey.SavePassword, savePassword.ToString()); if (cboConnEnv.SelectedIndex != ListBox.NoMatches && txtTenant.Text.Length > 0 && txtUsername.Text.Length > 0 && txtPassword.Text.Length > 0) { url = WDWebService.GetServiceURL(((WDURLItem)cboConnEnv.SelectedItem).Key, txtTenant.Text, txtUsername.Text, txtPassword.Text); url = String.Concat(url, "/", tenant, "/"); Settings.Set(IniSection.Connection, conn, IniKey.URL, url); lnkConnURL.Text = url; } if (chkSavePassword.Checked) { Settings.Set(IniSection.Connection, conn, IniKey.Password, password); } else { if (txtPassword.Text.Length == 0) { Settings.Set(IniSection.Connection, conn, IniKey.Password, ""); } } MessageBox.Show("Saved", "Connection Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); DirtySet(false); } catch (Exception ex) { MessageBox.Show("Error saving connection. " + Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void WrapSOAPTest() { string results = WDWebService.WrapSOAP("dummy", "dummy", Resources.WDWebServiceTest_WrapSOAPTestInput); Assert.AreEqual(Resources.WDWebServiceTest_WrapSOAPTestOutput, results); }
private void Initilize() { try { WebEngine2007.WebServices.ID.SitePartnership[] sps; System.Text.StringBuilder sb; string siteID = CDHelper.GetSiteID(); #region 绑定共享站点数据源 //查找当前站群下所有可共享站点 WDWebService wws = GetWDWebService(); WebSite[] sites = wws.GetWebSites(); //Tips:使用泛型集合类,可以避免检查数组越界 IList <WebSite> sitesCopy = new List <WebSite>(); foreach (WebSite item in sites) { if (item.ID != siteID) { if (item.IpOrDomain == 1 && item.ZoneName.ToLower().Equals("localhost")) { item.Url = item.ZoneName + ":" + item.Port.ToString(); } sitesCopy.Add(item); } } SiteListSharing.DataSource = sitesCopy; SiteListSharing.DataBind(); //查找已创建共享站点 object objEnum = (object)EnumLibrary.SitePartnership.Sharing; sps = null; sps = IDHelper.GetSharingSites(siteID, objEnum); sb = new System.Text.StringBuilder(); EnumLibrary.SiteValidateStyle svs = EnumLibrary.SiteValidateStyle.NoMustReceived; if (sps != null) { foreach (WebEngine2007.WebServices.ID.SitePartnership sp in sps) { svs = (EnumLibrary.SiteValidateStyle) StateMgr.GetStateValueEnum(sp.EnumState, EnumLibrary.Business.SiteValidateStyle); if (sb.Length > 0) { sb.Append(";"); } sb.Append(sp.ToSiteID + "," + sp.ToSiteName); } } //站点生效方式仅共享存在此值,且一个站点唯一 switch (svs) { case EnumLibrary.SiteValidateStyle.MustReceived: ValidateStyle.Checked = true; break; case EnumLibrary.SiteValidateStyle.NoMustReceived: ValidateStyle.Checked = false; break; default: break; } SiteSharingAddsTextBox.Text = sb.ToString(); SiteSharingDelsTextBox.Text = string.Empty; #endregion #region 绑定接收站点数据源 //从SitePartnership查找所有可接收站点 objEnum = (object)EnumLibrary.SitePartnership.Sharing; sps = null; sps = IDHelper.GetReceivingSites(siteID, objEnum); SiteListReceive.DataSource = sps; SiteListReceive.DataBind(); objEnum = (object)EnumLibrary.SitePartnership.Receiving; sps = null; sps = IDHelper.GetReceivingSites(siteID, objEnum); sb = new System.Text.StringBuilder(); if (sps != null) { foreach (WebEngine2007.WebServices.ID.SitePartnership sp in sps) { if (sb.Length > 0) { sb.Append(";"); } sb.Append(sp.FromSiteID + "," + sp.FromSiteName); } } SiteReceiveAddsTextBox.Text = sb.ToString(); SiteReceiveDelsTextBox.Text = string.Empty; #endregion //并获取已经设定好的数据范围,并直接赋值给 //SiteReceiveTextBox、SiteSharingTextBox由前台分解而后对已选站点进行打勾 //当然需要注册启动脚本 Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>onDocumentLoad();</script>"); } catch (Exception ex) { Messages.ShowMessage("页面初始化出错!出错原因:" + ex.Message); } }