Esempio n. 1
0
        public HtmlOption[] GetOptions(string type, string curValue)
        {
            if (string.IsNullOrEmpty(curValue))
            {
                return(GetOptions(type));
            }

            IList itemList = this.optionItemDao.FindAll(type);

            if (null == itemList || itemList.Count == 0)
            {
                return(HtmlOption.GetBlankHtmlOption());
            }

            IList optionsList = new ArrayList();
            bool  isHave      = false;

            for (int i = 0; i < itemList.Count; i++)
            {
                OptionItem optionItem = (OptionItem)itemList[i];
                if (!isHave && curValue.Equals(optionItem.Code, StringComparison.OrdinalIgnoreCase))
                {
                    isHave = true;
                }
                optionsList.Add(new HtmlOption(optionItem.Name, optionItem.Code));
            }
            if (!isHave)
            {
                optionsList.Add(new HtmlOption(curValue, curValue));
            }

            HtmlOption[] options = new HtmlOption[optionsList.Count];
            optionsList.CopyTo(options, 0);
            return(options);
        }
Esempio n. 2
0
        // 绑定人员列表
        private void BindAllUserInfo()
        {
            IList userInfos = this.userInfoService.FindByOU(rootOUUnid, userType);

            HtmlOption[] userInfoOptions = new HtmlOption[userInfos.Count];
            User         userInfo;

            for (int i = 0; i < userInfos.Count; i++)
            {
                userInfo           = userInfos[i] as User;
                userInfoOptions[i] = new HtmlOption(userInfo.Name + " [" + userInfo.OUFullName + "]", userInfo.Unid);
            }
            this.Options.DataSource     = userInfoOptions;
            this.Options.DataTextField  = "OptionName";
            this.Options.DataValueField = "OptionValue";
            this.Options.DataBind();

            // 创建人员列表的json字符串
            JavaScriptArray  jsonArray = new JavaScriptArray();
            JavaScriptObject jsonObject;

            foreach (User userInfo1 in userInfos)
            {
                jsonObject = JsonUtils.CreateJsonObject(userInfo1);
                jsonArray.Add(jsonObject);
            }
            this.userInfosJson = JavaScriptConvert.SerializeObject(jsonArray);
        }
Esempio n. 3
0
        // 绑定岗位列表
        private void BindAllGroup()
        {
            IList groups = this.groupService.FindByOU(rootOUUnid, false, groupType, true);

            HtmlOption[] groupOptions = new HtmlOption[groups.Count];
            Group        group;

            for (int i = 0; i < groups.Count; i++)
            {
                group           = groups[i] as Group;
                groupOptions[i] = new HtmlOption(group.Name + " [" + group.OUFullName + "]", group.Unid);
            }
            this.Options.DataSource     = groupOptions;
            this.Options.DataTextField  = "OptionName";
            this.Options.DataValueField = "OptionValue";
            this.Options.DataBind();

            // 创建岗位列表的json字符串
            JavaScriptArray  jsonArray = new JavaScriptArray();
            JavaScriptObject jsonObject;

            foreach (Group group1 in groups)
            {
                jsonObject = JsonUtils.CreateJsonObject(group1);
                jsonArray.Add(jsonObject);
            }
            this.groupsJson = JavaScriptConvert.SerializeObject(jsonArray);
        }
Esempio n. 4
0
        public virtual void Visit(FormOption formOption, HtmlContainer htmlContainer)
        {
            HtmlOption htmlOption = new HtmlOption(formOption.Value);

            htmlOption.Add(new HtmlText(formOption.Text));
            htmlOption.Hidden.Value   = formOption.IsHidden;
            htmlOption.Disabled.Value = formOption.IsDisabled;
            htmlOption.Selected.Value = formOption.IsSelected;

            htmlContainer.Add(htmlOption);
        }
        public void Execute()
        {
            WebClient browser = new WebClient(BrowserVersion.CHROME);

            browser.Options.JavaScriptEnabled = true;
            browser.Options.RedirectEnabled   = true;
            browser.Options.ThrowExceptionOnFailingStatusCode = false;
            browser.Options.ThrowExceptionOnScriptError       = false;
            browser.Options.CssEnabled = false;
            //Login Page
            HtmlForm form = browser.GetHtmlPage("http://usage.lexisnexis.com:80//CounterLogin.jsp").GetFormByName("login");

            browser.WaitForBackgroundJavaScript(1000);
            form.GetInputByName("username").SetValueAttribute(_username);
            form.GetInputByName("password").SetValueAttribute(_password);
            HtmlPage redirect = (HtmlPage)form.GetInputByName("loginBtn").Click();

            browser.WaitForBackgroundJavaScript(1000);

            redirect = (HtmlPage)redirect.GetAnchorByText("COUNTER Reports").Click();

            HtmlSelect YearSelect = ((HtmlSelect)redirect.GetElementByName("year"));
            HtmlOption option     = YearSelect.GetOptionByValue("2015");

            YearSelect.SetSelectedAttribute(option, true);

            redirect = (HtmlPage)((HtmlRadioButtonInput)redirect.GetElementById("CSV")).SetChecked(true);

            IList <INode> input = (redirect.GetElementsByTagName("input"));

            ((HtmlInput)input[3]).Click();
            //redirect = (HtmlPage)input.Click();

            Console.WriteLine();
            //var browser = new ChromeDriver();
            ////browser.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36";
            //browser.Navigate().GoToUrl("http://usage.lexisnexis.com:80//CounterLogin.jsp");
            //var form = browser.FindElement(By.TagName("form"));
            //Console.WriteLine();
            //var usernameTextBox = browser.Find("username");
            //var passwordTextBox = browser.Find("password");
            //var submitButton = browser.Find(ElementType.Button, FindBy.Value, "Submit");
            //usernameTextBox.Value = _username;
            //passwordTextBox.Value = _password;

            //submitButton.Click();

            //var CounterReportsLink = browser.Find(ElementType.Anchor, FindBy.Text, "COUNTER Reports");
            //CounterReportsLink.Click();
            //Console.WriteLine(browser.CurrentHtml);
        }
 public HtmlBuilder BeginOption(HtmlBuilderOptionType type, string key, string value, int size)
 {
     if (key == null)
     {
         throw new ArgumentNullException("key");
     }
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     _option = new HtmlOption {
         Type = type, Key = key, Value = value, Size = size
     };
     return(this);
 }
Esempio n. 7
0
        public HtmlOption[] GetOptions(string type)
        {
            IList itemList = this.optionItemDao.FindAll(type);

            if (null == itemList || itemList.Count == 0)
            {
                return(HtmlOption.GetBlankHtmlOption());
            }

            HtmlOption[] options = new HtmlOption[itemList.Count];
            for (int i = 0; i < itemList.Count; i++)
            {
                OptionItem optionItem = (OptionItem)itemList[i];
                options[i] = new HtmlOption(optionItem.Name, optionItem.Code);
            }
            return(options);
        }
Esempio n. 8
0
 internal static void BindOUStatus(DropDownList ouStatus)
 {
     // 绑定状态列表
     HtmlOption[] options = new HtmlOption[3];
     options[0]              = new HtmlOption();
     options[0].OptionValue  = OUStatuses.Enable.ToString();
     options[0].OptionName   = "活动";
     options[1]              = new HtmlOption();
     options[1].OptionValue  = OUStatuses.Disable.ToString();
     options[1].OptionName   = "禁用";
     options[2]              = new HtmlOption();
     options[2].OptionValue  = OUStatuses.Delete.ToString();
     options[2].OptionName   = "已删除";
     ouStatus.DataSource     = options;
     ouStatus.DataTextField  = "OptionName";
     ouStatus.DataValueField = "OptionValue";
     ouStatus.DataBind();
 }
Esempio n. 9
0
        public HtmlOption[] GetTypeOptions()
        {
            IList typesList = this.optionItemDao.FindAllType();

            if (null == typesList || typesList.Count == 0)
            {
                return(HtmlOption.GetBlankHtmlOption());
            }

            HtmlOption[] options = new HtmlOption[typesList.Count];
            int          index   = 0;

            foreach (object[] typeInfos in typesList)
            {
                options[index++] = new HtmlOption(typeInfos[1].ToString(), typeInfos[0].ToString());
            }
            return(options);
        }
Esempio n. 10
0
        public void Visit(HtmlOption h)
        {
            sb.Append(Tabs(h.Depth));
            sb.Append(string.Format("<{0}", h.Tag));

            foreach (var a in h.Attributes.Where(a => a.IsSet))
            {
                sb.Append(a);
            }

            sb.Append(">");

            foreach (var c in h.Contents)
            {
                Visit(c);
            }

            sb.AppendLine(string.Format("</{0}>", h.Tag));
        }
Esempio n. 11
0
 /// <summary>
 /// Begins the option.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="key">The key.</param>
 /// <param name="value">The value.</param>
 /// <param name="size">The size.</param>
 /// <returns></returns>
 public HtmlBuilder BeginOption(HtmlBuilderOptionType type, string key, string value, int size)
 {
     if (key == null)
         throw new ArgumentNullException("key");
     if (value == null)
         throw new ArgumentNullException("value");
     _option = new HtmlOption { Type = type, Key = key, Value = value, Size = size };
     return this;
 }