/// <summary> /// Clone with new option /// </summary> /// <param name="optionTag">New Option</param> /// <returns></returns> public Writer Clone(OptionTag optionTag) { var clone = Clone(); clone.OptionTag = optionTag; return(clone); }
public static void selectValue(Ranorex.SelectTag element, string strValue, string ControlName) { try { for (int i = 0; i < 3; i++) { OptionTag optTag = element.FindSingle(".//option[@innertext='" + strValue + "']"); // optTag.Focus(); // optTag.EnsureVisible(); // element.Click(); // Delay.Seconds(1); // optTag.Click(); optTag.Selected = true; // if(element.Options.IndexOf(strValue).ToString().Equals(element.InnerText.ToString())) // break; } Report.Info(strValue + " is selected in " + ControlName); Delay.Milliseconds(300); } catch (Exception ex) { Report.Screenshot(); Report.Failure(strValue + " is not selected due to " + ex.Message); } }
/// <summary> /// Парсинг элемента (input/select) в FieldPackage /// </summary> /// <param name="label">Классификатор поля</param> /// <param name="element">Элемент для парсинга</param> /// <returns></returns> public override FieldPackage Parse(string label, HtmlElement element) { FieldPackage result = null; DCT.Execute(data => { if (element.TagName.ToLower() == "select" || element.TagName.ToLower() == "input") { var optionList = new List <OptionTag>(); if (element.TagName.ToLower() == "select" && !dynamicSelects.Contains(label)) { var options = element.Children; foreach (HtmlElement o in options) { var oValue = o.GetAttribute("value"); var oText = o.InnerText; optionList.Add(OptionTag.Create(oValue, oText)); } } var id = element.GetAttribute("id"); if (!string.IsNullOrEmpty(id)) { result = FieldPackage.Create(id, element.TagName.ToLower(), true, optionList.ToArray()); } else { var name = element.GetAttribute("name"); result = FieldPackage.Create(name, element.TagName.ToLower(), false, optionList.ToArray()); } } }); return(result); }
/// <summary> /// Create a new writer with the same Class, TriggeringBaseClass and GeneratorAttribute /// </summary> /// <param name="parentWriter"> /// source of properties to be copied /// </param> /// <param name="segCategory"></param> /// <remarks></remarks> public Writer(Writer parentWriter, string segCategory = "") { Class = parentWriter.Class; TriggeringBaseClass = parentWriter.TriggeringBaseClass; //Clone instead of reusing parent's attribute, because they may have different property values OptionTag = (OptionTag)parentWriter.OptionTag.MemberwiseClone(); Category = segCategory; }
private void CopyPropertiesFrom(Writer source) { _manager = source.Manager; Class = source.Class; TriggeringBaseClass = source.TriggeringBaseClass; //Clone instead of reusing parent's attribute, because they may have different property values OptionTag = (OptionTag)source.OptionTag.MemberwiseClone(); }
public void Validate_SecurityMode_5GHz_Primary(string argument1) { //Validate_SecurityMode_5GHz_Primary if (argument1 == "") { argument1 = "WPA-PSK/WPA2-PSK"; } Delay.Seconds(15); WebDocument webDocument = "/dom[@domain='192.168.0.1']"; //Ranorex.SelectTag securityTag = webDocument.FindSingle("/dom[@domain='192.168.0.1']//div[#'tr_SecurityModeGrp']/select[#'SecurityModeGrp']"); Ranorex.SelectTag securityTag = webDocument.FindSingle("/dom[@domain='192.168.0.1']//div[#'tr_SecurityModeGrp50']/select[#'SecurityModeGrp50']"); // Ranorex.SelectTag securityTag = webDocument.FindSingle("/dom[@domain='192.168.0.1']//div[#'tr_SecurityMode50']/select[#'SecurityMode50']"); // Ranorex.SelectTag securityTag = webDocument.FindSingle("dom[@domain='192.168.0.1']//select[#'SecurityMode50']"); Report.Info(securityTag.GetInnerHtml().ToString()); foreach (Ranorex.OptionTag optTag in securityTag.Find(".//option")) { //TO SELECT THE SecurityMode //Console.WriteLine(optTag.InnerText); Report.Info(optTag.InnerText); //get the currently selected item name and check if it is Disable /* * Report.Info(optTag.Element.GetAttributeValueText("selected")); * if(optTag.Element.GetAttributeValueText("selected").Equals("Disable")){ * Report.Info("security mode cannot be Disable "); * } */ if (optTag.Element.GetAttributeValueText("selected").Equals("Disable")) { // security mode cannot be Disable, so need to change the mode OptionTag optionTag = argument1; optionTag.Selected = true; } else if (optTag.InnerText == argument1) { Report.Info("argument2 matching:: " + argument1); // OptionTag option = "//rxpath/to/option"; //option.Selected = true; optTag.Selected = true; Report.Success("Security Mode changed successfully !"); // Report.Screenshot("Security Mode",securityTag.Element,true); Report.Screenshot(); break; } } // end of for-loop Report.Screenshot(); }
public bool IsOutdated(OptionTag option) { if (RegenMode != option.RegenMode) { return(true); } switch (RegenMode) { case RegenModes.Always: return(true); default: return(Version != option.Version); } }
public static void SelectOptionsTagsInTable(SelectTag ObjSelectTag, string strValue, string strControlName) { try { OptionTag opt1 = ObjSelectTag.FindSingle(".//option[@text='" + strValue + "']"); opt1.EnsureVisible(); opt1.Focus(); opt1.Selected = true; opt1.PerformClick(); Report.Info(strValue + " is selected in " + strControlName); } catch (Exception ex) { Report.Failure("Exception Occurred " + ex.Message); } }
public override void HandleEvent(OptionTag oType) { base.HandleEvent(oType); switch (oType) { case (OptionTag.Land): if (characters[0].getStat("Piloting") + Random.Range(0, 3) > 6) { LogEntry(characters[0].Name + " has successfully landed on " + subject + " allowing the party to scavange for resources."); EventActions.gainRandomResource(this); EventActions.gainRandomResource(this); GameControllerScript.instance.locationState = LocationState.Land; } else { LogEntry("As " + characters[0].Name + " descends into the atmosphere, an electrical storm knocks out the " + GameControllerScript.instance.party.ship.Name + "'s engines, causing it to crash."); GameControllerScript.instance.party.ship.Damage(5); EventActions.loseResource(this, "Fuel"); GameControllerScript.instance.locationState = LocationState.Land; } break; case (OptionTag.Scan): if (Random.Range(0, 100) > 60) { LogEntry(characters[1].Name + " scans " + subject + " and determines it is rich with minerals."); EventActions.gainRandomResource(this); } else { LogEntry("The atmosphere of " + subject + " is creating too much interference to properly scan."); } EventActions.loseResource(this, "Fuel"); break; case (OptionTag.Bypass): LogEntry(characters[2].Name + " guides the ship around the planet."); EventActions.loseResource(this, "Fuel"); GameControllerScript.instance.LightYearsToEOU -= 2; break; } GameControllerScript.instance.currentSituation = null; }
public override void HandleEvent(OptionTag oType) { base.HandleEvent(oType); switch (oType) { case (OptionTag.Recruit): if (characters[1].getStat("Mind") + Random.Range(0, 10) > 6) { LogEntry(characters[1].Name + " convices " + characters[0].Name + " to join the party with a triumphant speech."); GameControllerScript.instance.party.addPartyMember(characters[0]); LogEntry(characters[0].Name + " joins the party!"); } else { LogEntry("AWKWARD! " + characters[0].Name + " rejects the invitation from " + characters[1].Name + " to join the party."); } break; case (OptionTag.Gossip): LogEntry(characters[2].Name + " learns about a nearby planet rich with resources from " + characters[0].Name); EventActions.gainRandomResource(this); GameControllerScript.instance.LightYearsToEOU -= 2; break; case (OptionTag.Intimidate): if (characters[3].getStat("Strength") > Random.Range(0, 10)) { LogEntry(characters[0].Name + " backs away as " + characters[3].Name + " threatens them into giving up supplies."); EventActions.gainRandomResource(this); } else { LogEntry(characters[0].Name + " stands up to " + characters[3].Name + ", causing them to give up supplies in embarassment."); EventActions.loseRandomResource(this); } break; } LogEntry("The crew fires up the ship and heads back into space."); GameControllerScript.instance.locationState = LocationState.Space; GameControllerScript.instance.currentSituation = null; }
/// <summary> /// Select the item from the OptionTag / Drop List /// </summary> /// <param name="DropButton">DropButton Object</param> /// <param name="selectBox">Select Tag / List</param> /// <param name="itemName">Option Tag / List Item</param> public static void SelectOption(ButtonTag DropButton, SelectTag selectBox, string itemName) { try { Delay.Milliseconds(200); DropButton.PressKeys("{Enter}"); Delay.Milliseconds(200); Report.Info("Selecting item '" + itemName + "' in " + selectBox); // ignore case regex string itemRegex = "^(?i)" + Regex.Escape(itemName) + "$"; selectBox.EnsureVisible(); OptionTag option = selectBox.FindSingle <OptionTag>("option[@InnerText~'" + itemName + "']"); option.Selected = true; Delay.Milliseconds(200); option.PressKeys("{Enter}"); } catch (Exception ex) { Report.Info("INFO", "Fail SelectOption : " + ex.Message); } }
public static Dictionary <string, FieldPackage> GetAccessFields(Guid instanceId) { Dictionary <string, FieldPackage> result = new Dictionary <string, FieldPackage>(); BCT.Execute(d => { var dbInstance = d.BulletinDb.BulletinInstances.FirstOrDefault(q => q.Id == instanceId); var groupId = dbInstance.GroupId; var groupedFields = d.BulletinDb.GroupedFields.Where(q => q.GroupId == groupId).ToArray(); foreach (var gf in groupedFields) { var accessId = gf.HtmlId; var fieldId = gf.FieldId; var dbField = d.BulletinDb.FieldTemplates.FirstOrDefault(q => q.Id == fieldId); var name = dbField.Name; var tag = dbField.Tag; var hasId = dbField.Attribute == "id"; var options = d.BulletinDb.SelectOptions.Where(q => q.GroupedFieldId == gf.Id).ToArray(); var optionTags = new List <OptionTag>(); foreach (var o in options) { var optionTag = OptionTag.Create(o.Code, o.Name); optionTags.Add(optionTag); } if (!result.ContainsKey(name)) { result.Add(name, FieldPackage.Create(accessId, tag, hasId, optionTags.ToArray())); } } }); return(result); }
protected override IList ExecuteCrawl(bool crawlAll) { IList list = new List <InviteInfo>(); string html = string.Empty; string cookiestr = string.Empty; string viewState = string.Empty; int pageInt = 1; string eventValidation = string.Empty; try { html = this.ToolWebSite.GetHtmlByUrl(this.SiteUrl, Encoding.UTF8); } catch { return(list); } Parser parser = new Parser(new Lexer(html)); NodeList pageNode = parser.ExtractAllNodesThatMatch(new AndFilter(new HasParentFilter(new AndFilter(new TagNameFilter("select"), new HasAttributeFilter("name", "__ec_pages")), true), new TagNameFilter("option"))); if (pageNode != null && pageNode.Count > 0) { try { OptionTag selectTag = pageNode[pageNode.Count - 1] as OptionTag; pageInt = int.Parse(selectTag.Value); } catch { } } for (int i = 1; i <= pageInt; i++) { if (i > 1) { try { NameValueCollection nvc = this.ToolWebSite.GetNameValueCollection(new string[] { "ec_i", "topicChrList_20070702_crd", "topicChrList_20070702_f_a", "topicChrList_20070702_p", "topicChrList_20070702_s_name", "id", "method", "__ec_pages", "topicChrList_20070702_rd", "topicChrList_20070702_f_name", "topicChrList_20070702_f_ldate" }, new string[] { "topicChrList_20070702", "20", string.Empty, i.ToString(), string.Empty, "1660", "view", (i - 1).ToString(), "20", string.Empty, string.Empty }); html = this.ToolWebSite.GetHtmlByUrl(SiteUrl, nvc, Encoding.UTF8, ref cookiestr); } catch { continue; } } parser = new Parser(new Lexer(html.Replace("tbody", "table"))); NodeList tdNodes = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("class", "tableBody"))); if (tdNodes != null && tdNodes.Count > 0) { TableTag table = tdNodes[0] as TableTag; for (int j = 1; j < table.RowCount; j++) { string code = string.Empty, buildUnit = string.Empty, prjName = string.Empty, prjAddress = string.Empty, inviteCtx = string.Empty, inviteType = string.Empty, specType = string.Empty, beginDate = string.Empty, endDate = string.Empty, remark = string.Empty, inviteCon = string.Empty, InfoUrl = string.Empty, CreateTime = string.Empty, msgType = string.Empty, otherType = string.Empty, HtmlTxt = string.Empty; TableRow tr = table.Rows[j]; prjName = tr.Columns[1].ToPlainTextString().Trim(); beginDate = tr.Columns[3].ToPlainTextString().Trim(); InfoUrl = "http://ps.szzfcg.cn" + tr.Columns[1].GetATagHref(); string htmldetail = string.Empty; try { htmldetail = this.ToolWebSite.GetHtmlByUrl(InfoUrl, Encoding.UTF8).GetJsString(); } catch { continue; } parser = new Parser(new Lexer(htmldetail)); NodeList dtlNode = parser.ExtractAllNodesThatMatch(new TagNameFilter("body")); if (dtlNode != null && dtlNode.Count > 0) { HtmlTxt = dtlNode.AsHtml(); inviteCtx = HtmlTxt.ToCtxString(); code = inviteCtx.GetCodeRegex().Replace(")", ""); buildUnit = inviteCtx.GetBuildRegex(); prjAddress = inviteCtx.GetAddressRegex(); prjAddress = prjAddress.Replace("&rdquo", "").Replace("&ldquo", ""); msgType = "深圳市坪山新区政府采购中心"; specType = "政府采购"; code = code.Replace("(", "").Replace("(", "").Replace(")", "").Replace(")", "").GetChina(); inviteType = ToolHtml.GetInviteTypes(prjName); InviteInfo info = ToolDb.GenInviteInfo("广东省", "深圳政府采购", "坪山新区", string.Empty, code, prjName, prjAddress, buildUnit, beginDate, endDate, inviteCtx, remark, msgType, inviteType, specType, string.Empty, InfoUrl, HtmlTxt); list.Add(info); if (!crawlAll && list.Count >= this.MaxCount) { return(list); } } } } } return(list); }
protected override IList ExecuteCrawl(bool crawlAll) { IList list = new List <BidInfo>(); string html = string.Empty; string cookiestr = string.Empty; string viewState = string.Empty; int pageInt = 1; string eventValidation = string.Empty; try { html = ToolWeb.GetHtmlByUrl(SiteUrl, Encoding.UTF8); } catch { return(list); } Parser parser = new Parser(new Lexer(html)); NodeList pageList = parser.ExtractAllNodesThatMatch(new AndFilter(new HasParentFilter(new AndFilter(new TagNameFilter("select"), new HasAttributeFilter("id", "myPages_input")), true), new TagNameFilter("option"))); if (pageList != null && pageList.Count > 0) { try { OptionTag opt = pageList[pageList.Count - 1] as OptionTag; string temp = opt.GetAttribute("value"); pageInt = int.Parse(temp); } catch { pageInt = 1; } } for (int i = 1; i <= pageInt; i++) { if (i > 1) { try { html = ToolWeb.GetHtmlByUrl(this.SiteUrl + "&pageNo=" + i.ToString(), Encoding.UTF8); } catch { continue; } } parser = new Parser(new Lexer(html)); NodeList nodeList = parser.ExtractAllNodesThatMatch(new AndFilter(new HasParentFilter(new AndFilter(new TagNameFilter("dl"), new HasAttributeFilter("class", "i-news")), true), new TagNameFilter("dd"))); if (nodeList != null && nodeList.Count > 0) { for (int j = 0; j < nodeList.Count; j++) { string prjName = string.Empty, buildUnit = string.Empty, bidUnit = string.Empty, bidMoney = string.Empty, code = string.Empty, bidDate = string.Empty, beginDate = string.Empty, endDate = string.Empty, bidType = string.Empty, specType = string.Empty, InfoUrl = string.Empty, msgType = string.Empty, bidCtx = string.Empty, prjAddress = string.Empty, remark = string.Empty, prjMgr = string.Empty, otherType = string.Empty, HtmlTxt = string.Empty; beginDate = nodeList[j].ToPlainTextString().GetDateRegex(); if (!string.IsNullOrEmpty(beginDate)) { prjName = nodeList[j].ToNodePlainString().Replace(beginDate, "").Replace("[", "").Replace("]", ""); } else { prjName = nodeList[j].ToNodePlainString().Replace("[", "").Replace("]", ""); } prjName = prjName.GetBidPrjName(); bidType = prjName.GetInviteBidType(); InfoUrl = "http://www.chinapsp.cn/cn/info.aspx" + nodeList[j].GetATagHref(); string htldtl = string.Empty; try { htldtl = ToolWeb.GetHtmlByUrl(InfoUrl, Encoding.UTF8); } catch { continue; } parser = new Parser(new Lexer(htldtl)); NodeList dtList = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("id", "dbDetailFV"))); if (dtList != null && dtList.Count > 0) { HtmlTxt = dtList.AsHtml(); bidCtx = HtmlTxt.ToLower().Replace("<tr>", "\r\n").Replace("</tr>", "\r\n").ToCtxString(); if (prjName.Contains("招标编号") || prjName.Contains("项目编号")) { if (prjName.IndexOf("(") != -1) { prjName = prjName.Remove(prjName.IndexOf("(")); } else if (prjName.IndexOf("(") != -1) { prjName = prjName.Remove(prjName.IndexOf("(")); } else if (prjName.Contains("招标编号")) { prjName = prjName.Remove(prjName.IndexOf("招标编号")); } else if (prjName.Contains("项目编号")) { prjName = prjName.Remove(prjName.IndexOf("项目编号")); } } buildUnit = bidCtx.GetBuildRegex(); prjAddress = bidCtx.Replace(" ", "").GetAddressRegex(); bidUnit = bidCtx.GetBidRegex(); bidMoney = bidCtx.GetMoneyRegex(); if (!string.IsNullOrEmpty(bidMoney)) { decimal money = Convert.ToDecimal(bidMoney); if (money > 10000) { bidMoney = Convert.ToString(money / 10000); } } if (bidMoney == "0") { bidMoney = bidCtx.GetMoneyRegex(null, true); if (string.IsNullOrEmpty(bidMoney)) { bidMoney = "0"; } } if (!string.IsNullOrEmpty(bidMoney)) { decimal money = Convert.ToDecimal(bidMoney); if (money > 10000) { bidMoney = Convert.ToString(money / 10000); } } if (bidMoney == "0") { bidMoney = bidCtx.ToLower().GetMoneyRegex(new string[] { "rmb" }); } if (string.IsNullOrEmpty(bidUnit) && bidMoney == "0") { if (bidCtx.Contains("采购失败") || bidCtx.Contains("本项目招标失败")) { bidUnit = "没有中标商"; bidMoney = "0"; } } code = bidCtx.GetCodeRegex().GetChina(); specType = "其他"; msgType = "广东采联采购招标有限公司"; prjName = prjName.GetBidPrjName(); BidInfo info = ToolDb.GenBidInfo("广东省", "深圳社会招标", "", string.Empty, code, prjName, buildUnit, beginDate, bidUnit, beginDate, endDate, bidCtx, string.Empty, msgType, bidType, specType, otherType, bidMoney, InfoUrl, prjMgr, HtmlTxt); ToolDb.SaveEntity(info, this.ExistCompareFields, this.ExistsUpdate, this.ExistsHtlCtx, " and LastModifier ='00000000000000000000000000000000'"); } } } } return(list); }
public void Validate_SecurityMode(string argument1) { //validate and find the selected item name // Report.Log(ReportLevel.Info, "Validation", "Validating AttributeEqual (Text='yourtext') on item 'WebDocument19216801.FmSelSecurityModeGrp.SomeSpanTag4'.", repo.WebDocument19216801.FmSelSecurityModeGrp.SomeSpanTag4Info); // Validate.Attribute(repo.WebDocument19216801.FmSelSecurityModeGrp.SomeSpanTag4Info, "Text", "yourtext"); /* * bool boolVal = Validate.IsTrue(repo.WebDocument19216801.FmSelSecurityModeGrp.SomeSpanTag4Info, "Text","Disable"); * if(boolVal == true){ * //string rstStr = "The Password : "******" : is : " + repo.WebDocument19216801.PasstextWifi.InnerText ; * Report.Log(ReportLevel.Info, "Validation","Disable"); * }else{ * // string rstStr = "The Password : "******" : is : " + repo.WebDocument19216801.PasstextWifi.InnerText ; * Report.Log(ReportLevel.Info, "Validation","other than Disable"); * } */ // Report.Log(ReportLevel.Info,repo.WebDocument19216801.FmSelSecurityModeGrp); Report.Info(" Inside Validate_SecurityMode " + "argument1 : " + argument1); if (argument1 == "") { argument1 = "WPA-PSK/WPA2-PSK"; Report.Info(" argument1 is blank so assigned the security mode - WPA-PSK/WPA2-PSK"); } Delay.Seconds(60); WebDocument webDocument = "/dom[@domain='192.168.0.1']"; webDocument.WaitForDocumentLoaded(); // Ranorex.SelectTag securityTag = webDocument.FindSingle("/dom[@domain='192.168.0.1']//select[#'Protocol']"); // Ranorex.SelectTag enableTag = webDocument.FindSingle("/dom[@domain='192.168.0.1']//div[#'tr_Enabled']/select[@id='Enabled']"); // Ranorex.SelectTag securityTag = webDocument.FindSingle("dom[@domain='192.168.0.1']//select[#'SecurityModeGrp']"); Ranorex.SelectTag securityTag = webDocument.FindSingle("/dom[@domain='192.168.0.1']//div[#'tr_SecurityModeGrp']/select[#'SecurityModeGrp']"); Report.Info(securityTag.GetInnerHtml().ToString()); foreach (Ranorex.OptionTag optTag in securityTag.Find(".//option")) { //TO SELECT THE SecurityMode //Console.WriteLine(optTag.InnerText); Report.Info(optTag.InnerText); //get the currently selected item name and check if it is Disable /* * Report.Info(optTag.Element.GetAttributeValueText("selected")); * if(optTag.Element.GetAttributeValueText("selected").Equals("Disable")){ * Report.Info("security mode cannot be Disable "); * } */ if (optTag.Element.GetAttributeValueText("selected").Equals("Disable")) { // security mode cannot be Disable, so need to change the mode OptionTag optionTag = argument1; optionTag.Selected = true; } else if (optTag.InnerText == argument1) { Report.Info("argument2 matching:: " + argument1); // OptionTag option = "//rxpath/to/option"; //option.Selected = true; optTag.Selected = true; Report.Success("Security Mode changed successfully !"); //Delay.Seconds(1); //Report.Screenshot("Security Mode",securityTag.Element,false); //FmSelSecurityModeGrp //Report.Screenshot("Security Mode",repo.WebDocument19216801.SecurityMode.Element,true); Delay.Seconds(1); Report.Screenshot(); break; } } // end of for-loop Report.Screenshot(); }
protected override IList ExecuteCrawl(bool crawlAll) { string html = string.Empty; string cookiestr = string.Empty; string viewState = string.Empty; int pageInt = 1; string eventValidation = string.Empty; try { html = ToolWeb.GetHtmlByUrl(SiteUrl, Encoding.UTF8, ref cookiestr); } catch { return(null); } string opValue = string.Empty, leveVlaue = string.Empty; string[] levelNode = new string[] { "特级", "特级(旧标准)", "一级", "一级(旧标准)", "二级", "二级(旧标准)", "三级", "三级(旧标准)", "暂定三级(旧标准)", "不分等级" }; Parser parser = new Parser(new Lexer(html)); NodeList typeNode = parser.ExtractAllNodesThatMatch(new AndFilter(new HasParentFilter(new AndFilter(new TagNameFilter("select"), new HasAttributeFilter("id", "ctl00_ContentPlaceHolder1_ddlENT_SORT_ID")), true), new TagNameFilter("option"))); if (typeNode != null && typeNode.Count > 0) { for (int t = 1; t < typeNode.Count; t++) { for (int l = 1; l < levelNode.Length; l++) { leveVlaue = levelNode[l]; OptionTag opTag = typeNode[t] as OptionTag; opValue = opTag.GetAttribute("value"); parser = new Parser(new Lexer(html)); NodeList inputNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("input"), new HasAttributeFilter("id", "ctl00_ContentPlaceHolder1_ValidateCode1_txtRanNum"))); string valiCode = string.Empty; if (inputNode != null && inputNode.Count > 0) { valiCode = (inputNode[0] as InputTag).GetAttribute("value"); } viewState = ToolWeb.GetAspNetViewState(html); NameValueCollection typeNvc = ToolWeb.GetNameValueCollection( new string[] { "ctl00_ContentPlaceHolder1_toolkitScriptManager1_HiddenField", "__EVENTTARGET", "__EVENTARGUMENT", "__LASTFOCUS", "__VIEWSTATE", "ctl00$ContentPlaceHolder1$ddlENT_SORT_ID", "ctl00$ContentPlaceHolder1$ddlRank", "ctl00$ContentPlaceHolder1$txtEnt_name", "ctl00$ContentPlaceHolder1$ValidateCode1$txtValidateCode", "ctl00$ContentPlaceHolder1$ValidateCode1$txtRanNum", "ctl00$ContentPlaceHolder1$btnsearch" }, new string[] { "", "", "", "", viewState, opValue, leveVlaue, "", valiCode, valiCode, "搜 索" }); try { html = ToolWeb.GetHtmlByUrl(SiteUrl, typeNvc, Encoding.UTF8, ref cookiestr); } catch { continue; } parser = new Parser(new Lexer(html)); NodeList pageList = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("id", "ctl00_ContentPlaceHolder1_AspNetPager1"))); if (pageList != null && pageList.Count > 0) { try { string temp = pageList[0].ToPlainTextString().GetRegexBegEnd("共", "条"); int page = int.Parse(temp); int result = page / 15; if (page % 15 != 0) { pageInt = result + 1; } else { pageInt = result; } } catch { pageInt = 1; } } for (int i = 1; i <= pageInt; i++) { if (i > 20) { break; } if (i > 1) { try { parser = new Parser(new Lexer(html)); NodeList pageInputNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("input"), new HasAttributeFilter("id", "ctl00_ContentPlaceHolder1_ValidateCode1_txtRanNum"))); string pageValiCode = string.Empty; if (pageInputNode != null && pageInputNode.Count > 0) { pageValiCode = (pageInputNode[0] as InputTag).GetAttribute("value"); } viewState = ToolWeb.GetAspNetViewState(html); NameValueCollection nvc = ToolWeb.GetNameValueCollection( new string[] { "ctl00$ContentPlaceHolder1$ddlENT_SORT_ID", "ctl00$ContentPlaceHolder1$ddlRank", "ctl00$ContentPlaceHolder1$txtEnt_name", "ctl00$ContentPlaceHolder1$ValidateCode1$txtRanNum", "ctl00$ContentPlaceHolder1$ValidateCode1$txtValidateCode", "ctl00_ContentPlaceHolder1_toolkitScriptManager1_HiddenField", "__EVENTARGUMENT", "__EVENTTARGET", "__LASTFOCUS", "__VIEWSTATE" }, new string[] { opValue, leveVlaue, "", pageValiCode, "", "", i.ToString(), "ctl00$ContentPlaceHolder1$AspNetPager1", "", viewState } ); html = ToolWeb.GetHtmlByUrl(SiteUrl, nvc, Encoding.UTF8, ref cookiestr); } catch { continue; } } parser = new Parser(new Lexer(html)); NodeList nodeList = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("id", "tab_ent"))); if (nodeList != null && nodeList.Count > 0) { #region 循环列表 TableTag table = nodeList[0] as TableTag; for (int j = 1; j < table.RowCount; j++) { string CorpName = string.Empty, CorpCode = string.Empty, CorpAddress = string.Empty, RegDate = string.Empty, RegFund = string.Empty, BusinessCode = string.Empty, BusinessType = string.Empty, LinkMan = string.Empty, LinkPhone = string.Empty, Fax = string.Empty, Email = string.Empty, CorpSite = string.Empty, cUrl = string.Empty, ISOQualNum = string.Empty, ISOEnvironNum = string.Empty, corpType = string.Empty, qualCode = string.Empty, corpMgr = string.Empty, businessMgr = string.Empty, tecMgr = string.Empty; string htlCtx = string.Empty, QualType = string.Empty, CorpLevey = string.Empty; TableRow tr = table.Rows[j]; string qualStr = tr.Columns[2].ToHtml(); CorpName = tr.Columns[1].ToNodePlainString(); QualType = tr.Columns[2].ToPlainTextString(); CorpLevey = tr.Columns[3].ToNodePlainString(); qualCode = tr.Columns[4].ToNodePlainString(); if (QualType == "--") { QualType = ""; } cUrl = "http://113.108.219.40/PlatForm/SearchCenter/" + tr.Columns[1].GetATagHref(); List <string> quaList = new List <string>(); parser = new Parser(new Lexer(tr.Columns[4].ToHtml())); NodeList quaNodeList = parser.ExtractAllNodesThatMatch(new TagNameFilter("a")); if (quaNodeList != null && quaNodeList.Count > 0) { for (int q = 0; q < quaNodeList.Count; q++) { quaList.Add("http://113.108.219.40/PlatForm/SearchCenter/" + quaNodeList[q].GetATagHref()); } } string quaUrl = "http://113.108.219.40/PlatForm/SearchCenter/" + tr.Columns[4].GetATagHref(); string htldtl = string.Empty; try { htldtl = ToolWeb.GetHtmlByUrl(cUrl, Encoding.UTF8); } catch { continue; } parser = new Parser(new Lexer(htldtl)); NodeList dtlList = parser.ExtractAllNodesThatMatch(new TagNameFilter("table")); if (dtlList != null && dtlList.Count > 0) { TableTag tab = dtlList[0] as TableTag; string ctx = string.Empty; for (int k = 0; k < tab.RowCount; k++) { for (int d = 0; d < tab.Rows[k].ColumnCount; d++) { if ((d + 1) % 2 == 0) { ctx += tab.Rows[k].Columns[d].ToNodePlainString() + "\r\n"; } else { ctx += tab.Rows[k].Columns[d].ToNodePlainString().Replace(":", "").Replace(":", "") + ":"; } } } corpType = ctx.GetRegex(new string[] { "企业类型", "类型" }); CorpAddress = ctx.GetRegex(new string[] { "企业注册地址", "地址" }); BusinessCode = ctx.GetRegex(new string[] { "营业执照注册号", "注册号" }); RegDate = ctx.GetRegex(new string[] { "成立时间", "成立日期", "时间", "日期" }).GetDateRegex(); LinkMan = ctx.GetRegex(new string[] { "企业法定代表人", "法定代表人" }); RegFund = ctx.GetRegex(new string[] { "注册资金", "资金" }); if (!RegFund.Contains("万")) { RegFund += "万"; } corpMgr = ctx.GetRegex(new string[] { "企业经理" }); if (corpMgr.Contains("暂无")) { corpMgr = string.Empty; } businessMgr = ctx.GetRegex(new string[] { "经营负责人" }); if (businessMgr.Contains("暂无")) { businessMgr = string.Empty; } tecMgr = ctx.GetRegex(new string[] { "技术负责人" }); if (tecMgr.Contains("暂无")) { tecMgr = string.Empty; } CorpInfo info = ToolDb.GenCorpInfo(CorpName, CorpCode, CorpAddress, RegDate, RegFund, BusinessCode, BusinessType, LinkMan, LinkPhone, Fax, Email, CorpSite, corpType, "广东省", "广东地区", "广东省住房和城乡建设厅", cUrl, ISOQualNum, ISOEnvironNum, string.Empty); string strSql = string.Format("select Id from CorpInfo where CorpName='{0}' and Url='{1}'", info.CorpName, info.Url); object obj = ToolDb.ExecuteScalar(strSql); if (obj != null && obj.ToString() != "") { StringBuilder delCorpQual = new System.Text.StringBuilder(); StringBuilder delCorpLeader = new System.Text.StringBuilder(); delCorpQual.AppendFormat("delete from CorpQual where CorpId='{0}'", obj); delCorpLeader.AppendFormat("delete from CorpLeader where CorpId='{0}'", obj); ToolDb.ExecuteSql(delCorpQual.ToString()); ToolDb.ExecuteSql(delCorpLeader.ToString()); string corpSql = string.Format("delete from CorpInfo where Id='{0}'", obj); ToolCoreDb.ExecuteSql(corpSql); } if (ToolDb.SaveEntity(info, string.Empty)) { if (!string.IsNullOrEmpty(LinkMan)) { CorpLeader leader = ToolDb.GenCorpLeader(info.Id, LinkMan, "", "企业法定代表人", cUrl); ToolDb.SaveEntity(leader, string.Empty); } if (!string.IsNullOrEmpty(corpMgr)) { CorpLeader leader = ToolDb.GenCorpLeader(info.Id, corpMgr, "", "企业经理", cUrl); ToolDb.SaveEntity(leader, string.Empty); } if (!string.IsNullOrEmpty(businessMgr)) { CorpLeader leader = ToolDb.GenCorpLeader(info.Id, businessMgr, "", "经营负责人", cUrl); ToolDb.SaveEntity(leader, string.Empty); } if (!string.IsNullOrEmpty(tecMgr)) { CorpLeader leader = ToolDb.GenCorpLeader(info.Id, tecMgr, "", "技术负责人", cUrl); ToolDb.SaveEntity(leader, string.Empty); } if (!string.IsNullOrEmpty(qualStr)) { List <CorpQual> corpQuals = new List <CorpQual>(); string quaCtx = string.Empty; for (int c = 0; c < quaList.Count; c++) { string quaHtl = string.Empty; try { quaHtl = ToolWeb.GetHtmlByUrl(quaList[c], Encoding.UTF8); } catch { } parser = new Parser(new Lexer(quaHtl)); NodeList quaNode = parser.ExtractAllNodesThatMatch(new TagNameFilter("table")); if (quaNode != null && quaNode.Count > 0) { TableTag quaTable = quaNode[0] as TableTag; for (int k = 0; k < quaTable.RowCount; k++) { for (int d = 0; d < quaTable.Rows[k].ColumnCount; d++) { string temp = quaTable.Rows[k].Columns[d].ToNodePlainString(); //string quatemp = quaTable.Rows[k].ToNodePlainString(); if ((d + 1) % 2 == 0) { quaCtx += temp + "\r\n"; } else { quaCtx += temp.Replace(":", "").Replace(":", "") + ":"; } } } } string qualctx = string.Empty; parser.Reset(); NodeList spanNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("span"), new HasAttributeFilter("id", "lblQuaInfo"))); if (spanNode != null && spanNode.Count > 0) { qualctx = spanNode.ToHtml().GetReplace("<br/>,<br />,<br>,</br>", "∈").ToCtxString(); } string str = qualctx.ToLower().Replace("<br/>", "∈").Replace("</br>", "∈").Replace("<br>", "∈"); str = Regex.Replace(str, "<[^>]*>", ""); string[] qual = str.Split('∈'); for (int q = 0; q < qual.Length; q++) { if (string.IsNullOrEmpty(qual[q]) || qual[q] == "--") { continue; } string CorpId = string.Empty, QualName = string.Empty, quaCode = string.Empty, QualSeq = string.Empty, qualNum = string.Empty, QualLevel = string.Empty, ValidDate = string.Empty, LicDate = string.Empty, LicUnit = string.Empty, quaType = string.Empty; LicDate = quaCtx.GetRegex("发证日期,发证时间").GetDateRegex(); LicUnit = quaCtx.GetRegex("发证机关,发证机构"); ValidDate = quaCtx.GetRegex("证书有效期").GetDateRegex(); quaType = quaCtx.GetRegex("证书类型"); string value = qual[q]; int len = value.IndexOf("/"); if (len != -1) { QualLevel = value.Substring(len, value.Length - len).Replace("/", ""); value = value.Remove(len); } else { QualLevel = CorpLevey; } string[] dtl = value.Split(' '); CorpId = info.Id; QualName = dtl[0].Trim(); if (string.IsNullOrEmpty(QualName)) { QualName = dtl[dtl.Length - 1]; } quaCode = quaCtx.GetRegex("证书编号");//qualCode; for (int ty = 1; ty < dtl.Length; ty++) { quaType += dtl[ty].Trim() + ","; } if (!string.IsNullOrEmpty(quaType) && quaType.Contains(",")) { quaType = quaType.Substring(0, quaType.Length - 1); if (quaType[0] == ',' || quaType[0] == ',') { quaType = quaType.Substring(1, quaType.Length - 1); } } qualNum = QualLevel.GetLevel(); CorpQual corpQual = null; corpQual = ToolDb.GenCorpQual(info.Id, QualName, quaCode, QualSeq, quaType, QualLevel, ValidDate, LicDate, LicUnit, quaUrl, qualNum, "广东省", "广东地区"); ToolDb.SaveEntity(corpQual, string.Empty); } } } } } } #endregion } } } } } ToolCoreDb.ExecuteProcedure(); return(null); }
///------------------------------------------------------------------------------------------------- /// <summary> Получаем пакет группы с полям </summary> /// /// <remarks> SV Milovanov, 02.02.2018. </remarks> /// /// <param name="hash"> Хэш группы </param> /// /// <returns> Пакет группы (сигнатура + словарь полей) </returns> ///------------------------------------------------------------------------------------------------- public override GroupPackage GetGroupPackage(string hash) { GroupPackage result = null; DCT.Execute(data => { var dbGroup = data.Db1.Groups.FirstOrDefault(q => q.Hash == hash); if (dbGroup != null) { var groupSignature = GetGroupSignature(hash); var groupedFields = data.Db1.GroupedFields.Where(q => q.GroupId == dbGroup.Id).AsEnumerable(); var fieldTemplates = data.Db1.FieldTemplates.Where(q => groupedFields.Select(qq => qq.FieldId).Contains(q.Id)).AsEnumerable() .Select(q => new { htmlId = groupedFields.FirstOrDefault(qq => qq.FieldId == q.Id).HtmlId, package = q, groupedId = groupedFields.FirstOrDefault(qq => qq.FieldId == q.Id).Id }).ToArray(); var optionTags = data.Db1.SelectOptions.Where(q => groupedFields.Select(qq => qq.Id).Contains(q.GroupedFieldId)).AsEnumerable(); result = new GroupPackage { Fields = fieldTemplates.ToDictionary(q1 => q1.package.Name, q2 => FieldPackage.Create(q2.htmlId, q2.package.Tag, q2.package.Attribute == "id", optionTags.Where(q => q.GroupedFieldId == q2.groupedId).Select(q => OptionTag.Create(q)).ToArray())), Categories = groupSignature.GetCategories(), }; } }); return(result); }
public override void HandleEvent(OptionTag oType) { base.HandleEvent(oType); switch (oType) { case (OptionTag.Flee): if (characters[0].getStat("Piloting") + Random.Range(0, 3) > 6) { LogEntry("It's about to get spicy as " + characters[0].Name + " churns up the engines to the MAX. " + ship.Name + "'s thrusters f****n' RIP OUT OF THERE."); GameControllerScript.instance.LightYearsToEOU -= 3; EventActions.loseResource(this, "Fuel"); enemyShip = null; } else { LogEntry("Maybe " + ship.Name + " isn't as nimble as we thought, maybe " + characters[0].Name + " is just a shit pilot, only time will tell..."); GameControllerScript.instance.party.ship.Damage(5); GameControllerScript.instance.LightYearsToEOU -= 1; EventActions.loseResource(this, "Fuel"); } break; case (OptionTag.Blast): if (characters[1].getStat("Piloting") + Random.Range(0, 3) > 6) { LogEntry(ship.Name + " fires at full power, blasting " + subject + " to bits."); enemyShip = null; EventActions.gainRandomResource(this); GameControllerScript.instance.LightYearsToEOU -= 1; } else { LogEntry(characters[1].Name + " misjudges the shot an leaves " + ship.Name + " vulnerable to counter fire."); GameControllerScript.instance.party.ship.Damage(Random.Range(1, 10)); } break; case (OptionTag.Board): if (characters[2].getStat("Piloting") + Random.Range(0, 3) > 6) { LogEntry(characters[2].Name + " boarded the enemy ship with ease! After a fierce battle on board you manage to steal some goods and make your way out."); enemyShip = null; EventActions.gainRandomResource(this); EventActions.gainRandomResource(this); } else { LogEntry("The boarding was botched! You'll have to come around to try again."); EventActions.loseResource(this, "Fuel"); GameControllerScript.instance.LightYearsToEOU -= 1; } break; case (OptionTag.Negotiate): if (characters[3].getStat("Mind") + Random.Range(0, 3) > 6) { LogEntry(characters[3].Name + " convices the enemies to stand down."); GameControllerScript.instance.LightYearsToEOU -= 1; } else { LogEntry("The enemies decide not to attack however you must send them some resources as tribute."); EventActions.loseRandomResource(this); GameControllerScript.instance.LightYearsToEOU -= 1; } enemyShip = null; break; } if (enemyShip != null) { Continue(); } else { GameControllerScript.instance.currentSituation = null; } }
public Writer(Manager <TRenderer, TOptionAttr> manager) { _manager = manager; OptionTag = new OptionTag(); }
public virtual void HandleEvent(OptionTag oType) { OptionMenuController.instance.clearOptions(); GameControllerScript.instance.choosing = false; }
public override void HandleEvent(OptionTag oType) { base.HandleEvent(oType); switch (oType) { case (OptionTag.Avoid): if (characters[0].getStat("Piloting") + Random.Range(0, 3) > 6) { if (randomSkillGain(characters[0], "Piloting")) { LogEntry("You seem to be at one with the controls of the ship, you feel your skills as a pilot grow!\n\n" + characters[0].Name + "'s Piloting increases! " + characters[0].getStat("Piloting")); } else { LogEntry("You race to the helm, and dive into the pilots seat in an effort to steer the ship clear of the asteroid. A narrow success."); GameControllerScript.instance.party.ship.Damage(5); //LogEntry(ship.Name + " has lost " + 5 + " shields."); //GameControllerScript.instance.party.changeShipStat("Shields", -5); } } else { if (randomSkillLoss(characters[0], "Piloting")) { characters[0].changeStat("Piloting", -1); LogEntry("You scrape against the asteriods hard exterior, a compartment of the ship holding ESSENTIAL supplies has been damaged and it's contents blown into space! Maybe you weren't meant to hang around the pilots seat...\n\n" + characters[0].Name + "'s Piloting decreases! " + characters[0].getStat("Piloting")); } else { LogEntry("Your heroic dive to the pilots seat is misaligned, luckily it wasn't the hardest asteroid in the galaxy, and your ship destroys it with it's hull."); } } GameControllerScript.instance.LightYearsToEOU -= 2; EventActions.loseResource(this, "Fuel"); break; case (OptionTag.Blast): if (characters[1].getStat("Piloting") + Random.Range(0, 3) > 6) { LogEntry("Ya f****n blasted it bud."); } else { LogEntry("Ya f****d up blasting it."); } GameControllerScript.instance.LightYearsToEOU -= 1; EventActions.loseResource(this, "Fuel"); break; case (OptionTag.Land): if (characters[2].getStat("Piloting") + Random.Range(0, 3) > 6) { LogEntry(characters[2].Name + " has successfully landed on the Asteroid, allowing the party to scavange for resources."); EventActions.gainRandomResource(this); EventActions.gainRandomResource(this); GameControllerScript.instance.locationState = LocationState.Land; } else { LogEntry(characters[2].Name + " misjudges the landing and the ship scapes along the surface of the asteroid. The party decides to cut their losses and not try again."); GameControllerScript.instance.party.ship.Damage(5); GameControllerScript.instance.LightYearsToEOU -= 1; EventActions.loseResource(this, "Fuel"); } break; } GameControllerScript.instance.currentSituation = null; }
protected override IList ExecuteCrawl(bool crawlAll) { IList list = new List <BidInfo>(); string html = string.Empty; string cookiestr = string.Empty; string viewState = string.Empty; int pageInt = 1; string eventValidation = string.Empty; try { html = this.ToolWebSite.GetHtmlByUrl(this.SiteUrl, Encoding.UTF8); } catch { return(list); } Parser parser = new Parser(new Lexer(html)); NodeList pageNode = parser.ExtractAllNodesThatMatch(new AndFilter(new HasParentFilter(new AndFilter(new TagNameFilter("select"), new HasAttributeFilter("name", "__ec_pages")), true), new TagNameFilter("option"))); if (pageNode != null && pageNode.Count > 0) { try { OptionTag selectTag = pageNode[pageNode.Count - 1] as OptionTag; pageInt = int.Parse(selectTag.Value); } catch { } } for (int i = 1; i <= pageInt; i++) { if (i > 1) { try { NameValueCollection nvc = this.ToolWebSite.GetNameValueCollection(new string[] { "ec_i", "topicChrList_20070702_crd", "topicChrList_20070702_f_a", "topicChrList_20070702_p", "topicChrList_20070702_s_name", "id", "method", "__ec_pages", "topicChrList_20070702_rd", "topicChrList_20070702_f_name", "topicChrList_20070702_f_ldate" }, new string[] { "topicChrList_20070702", "20", string.Empty, i.ToString(), string.Empty, "1660", "view", (i - 1).ToString(), "20", string.Empty, string.Empty }); html = this.ToolWebSite.GetHtmlByUrl(SiteUrl, nvc, Encoding.UTF8, ref cookiestr); } catch { continue; } } parser = new Parser(new Lexer(html.Replace("tbody", "table"))); NodeList tdNodes = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("class", "tableBody"))); if (tdNodes != null && tdNodes.Count > 0) { TableTag table = tdNodes[0] as TableTag; for (int j = 0; j < table.RowCount; j++) { string prjName = string.Empty, buildUnit = string.Empty, bidUnit = string.Empty, bidMoney = string.Empty, code = string.Empty, bidDate = string.Empty, beginDate = string.Empty, endDate = string.Empty, bidType = string.Empty, specType = string.Empty, InfoUrl = string.Empty, msgType = string.Empty, bidCtx = string.Empty, prjAddress = string.Empty, remark = string.Empty, prjMgr = string.Empty, otherType = string.Empty, HtmlTxt = string.Empty; TableRow tr = table.Rows[j]; prjName = tr.Columns[1].ToPlainTextString().Trim(); beginDate = tr.Columns[3].ToPlainTextString().Trim(); InfoUrl = "http://ps.szzfcg.cn" + tr.Columns[1].GetATagHref(); string htldtl = string.Empty; try { htldtl = this.ToolWebSite.GetHtmlByUrl(InfoUrl, Encoding.UTF8).GetJsString(); } catch { continue; } parser = new Parser(new Lexer(htldtl)); NodeList dtlNode = parser.ExtractAllNodesThatMatch(new TagNameFilter("body")); if (dtlNode != null && dtlNode.Count > 0) { string[] MoneyRegex = { "中标(成交)金额人民币", "中标金额为", "预中标金额(元)", "成交金额", "中标总金额", "中标(成交)金额", "中标价", "中标金额", "中标金额(元)", "成交总金额(人民币)", "中标金额(包一)", "投标价", "其中标价为", "投标报价", "预中标人", "总投资", "发包价", "投标报价", "价格", "总价", "报价" }; HtmlTxt = dtlNode.AsHtml(); bidCtx = HtmlTxt.ToCtxString().Replace("\r\n\r\n\r\n\r\n", "\r\n").Replace("\r\n\r\n", "\r\n").Replace("\r\n\r\n", "\r\n").Replace("\r\n\r\n", "\r\n").Replace("\r\n\r\n", "\r\n").Replace("\r\n\r\n", "\r\n").Replace("\r\n\r\n", "\r\n").Replace("\r\n\r\n", "\r\n").Replace("\r\n\r\n", "\r\n").Replace("\r\n\r\n", "\r\n").Replace("\r\n\r\n", "\r\n").Replace("\r\n\r\n", "\r\n").Replace("\r\n\t\r\n\t\r\n", "\r\n\t").Replace("\r\n\t\r\n\t\r\n", "\r\n\t").Replace("\r\n\t\r\n\t\r\n", "\r\n\t").Replace("\r\n\t\r\n\t\r\n", "\r\n\t"); bool isOk = true; bidCtx = System.Web.HttpUtility.HtmlDecode(bidCtx); while (isOk) { string str = bidCtx.GetRegexBegEnd("&#", ";"); if (!string.IsNullOrEmpty(str)) { bidCtx = bidCtx.Replace("&#" + str + ";", ""); } else { isOk = false; } } buildUnit = bidCtx.GetBuildRegex(); prjAddress = bidCtx.GetAddressRegex(); bidUnit = bidCtx.GetBidRegex(); bidMoney = bidCtx.GetMoneyRegex(); if (!string.IsNullOrEmpty(bidUnit) && bidMoney == "0") { bidMoney = bidCtx.GetMoneyRegex(null, true, "万元"); } string ctx = string.Empty; #region 多table匹配 if (string.IsNullOrEmpty(bidUnit)) { parser = new Parser(new Lexer(htldtl)); NodeList dtList = parser.ExtractAllNodesThatMatch(new AndFilter(new HasParentFilter(new AndFilter(new TagNameFilter("span"), new HasAttributeFilter("id", "holder")), true), new TagNameFilter("table"))); if (dtList != null && dtList.Count > 0) { if (dtList.Count > 3) { TableTag tab = dtList[2] as TableTag; if (tab.RowCount > 1) { for (int d = 0; d < tab.Rows[0].ColumnCount; d++) { ctx += tab.Rows[0].Columns[d].ToNodePlainString() + ":"; ctx += tab.Rows[1].Columns[d].ToNodePlainString() + "\r\n"; } } } else if (dtList.Count > 2) { TableTag tab = dtList[1] as TableTag; if (tab.RowCount > 1) { for (int d = 0; d < tab.Rows[0].ColumnCount; d++) { ctx += tab.Rows[0].Columns[d].ToNodePlainString() + ":"; ctx += tab.Rows[1].Columns[d].ToNodePlainString() + "\r\n"; } } } else { TableTag tab = dtList[0] as TableTag; if (tab.RowCount > 1) { for (int d = 0; d < tab.Rows[0].ColumnCount; d++) { string start = System.Web.HttpUtility.HtmlDecode(tab.Rows[0].Columns[d].ToNodePlainString()); string end = System.Web.HttpUtility.HtmlDecode(tab.Rows[1].Columns[d].ToNodePlainString()); ctx += start + ":"; ctx += end + "\r\n"; } } } bidUnit = ctx.GetBidRegex(); bidMoney = ctx.GetMoneyRegex(new string[] { "成交金额" }); if (bidMoney == "" || bidMoney == "0") { bidMoney = ctx.GetMoneyRegex(MoneyRegex); } if (!string.IsNullOrEmpty(bidUnit) && bidMoney == "0") { string dtlCtx = string.Empty, unit = string.Empty, money = string.Empty; TableTag tab = dtList[0] as TableTag; for (int c = 0; c < tab.RowCount; c++) { if ((c + 2) <= tab.RowCount) { if (tab.Rows[c].ToNodePlainString().Contains(bidUnit)) { for (int d = 0; d < tab.Rows[c].ColumnCount; d++) { dtlCtx += tab.Rows[0].Columns[d].ToNodePlainString() + ":"; dtlCtx += tab.Rows[c].Columns[d].ToNodePlainString() + "\r\n"; } break; } } } unit = dtlCtx.GetBidRegex(); money = dtlCtx.GetMoneyRegex(MoneyRegex); if (bidUnit == unit) { bidMoney = money; } } if (bidUnit.Contains("无中标") || bidUnit.Contains("没有")) { bidUnit = "没有中标商"; bidMoney = "0"; } } } if (string.IsNullOrEmpty(bidUnit)) { parser = new Parser(new Lexer(htldtl)); NodeList dtList = parser.ExtractAllNodesThatMatch(new TagNameFilter("table")); if (dtList != null && dtList.Count > 0) { if (dtList.Count > 3) { TableTag tab = dtList[2] as TableTag; if (tab.RowCount > 1) { for (int d = 0; d < tab.Rows[0].ColumnCount; d++) { try { ctx += tab.Rows[0].Columns[d].ToNodePlainString() + ":"; ctx += tab.Rows[1].Columns[d].ToNodePlainString() + "\r\n"; } catch { } } } } else if (dtList.Count > 2) { TableTag tab = dtList[1] as TableTag; if (tab.RowCount > 1) { for (int d = 0; d < tab.Rows[0].ColumnCount; d++) { try { ctx += tab.Rows[0].Columns[d].ToNodePlainString() + ":"; ctx += tab.Rows[1].Columns[d].ToNodePlainString() + "\r\n"; } catch { } } } } else if (dtList.Count > 1) { TableTag tab = dtList[1] as TableTag; if (tab.RowCount > 1) { for (int d = 0; d < tab.Rows[0].ColumnCount; d++) { try { ctx += tab.Rows[0].Columns[d].ToNodePlainString() + ":"; ctx += tab.Rows[1].Columns[d].ToNodePlainString() + "\r\n"; } catch { } } } } else { TableTag tab = dtList[0] as TableTag; if (tab.RowCount > 1) { for (int d = 0; d < tab.Rows[0].ColumnCount; d++) { try { ctx += tab.Rows[0].Columns[d].ToNodePlainString() + ":"; ctx += tab.Rows[1].Columns[d].ToNodePlainString() + "\r\n"; } catch { } } } } bidUnit = ctx.GetBidRegex(); bidMoney = ctx.GetMoneyRegex(MoneyRegex); if (bidUnit.Contains("无中标") || bidUnit.Contains("没有")) { bidUnit = "没有中标商"; bidMoney = "0"; } } } #endregion if (string.IsNullOrEmpty(bidUnit)) { if (bidCtx.Contains("供应商不足")) { bidUnit = "没有中标商"; bidMoney = "0"; } } if (bidMoney != "0") { try { decimal mon = decimal.Parse(bidMoney); if (mon > 100000) { bidMoney = bidMoney.GetMoney(); } } catch { } } bidType = prjName.GetInviteBidType(); string[] CodeRegex = { "工程编号", "项目编号", "招标编号", "中标编号" }; code = bidCtx.GetCodeRegex(CodeRegex); prjName = prjName.Replace("成交", ""); if (string.IsNullOrEmpty(code)) { code = bidCtx.Replace(")", "kdxx").Replace(")", "kdxx").GetRegexBegEnd("招标编号", "kdxx").Replace(":", "").Replace(":", ""); } if (string.IsNullOrEmpty(code)) { code = bidCtx.Replace(")", "kdxx").Replace(")", "kdxx").GetRegexBegEnd("项目编号", "kdxx").Replace(":", "").Replace(":", ""); } if (string.IsNullOrEmpty(code)) { code = bidCtx.Replace(")", "kdxx").Replace(")", "kdxx").GetRegexBegEnd("工程编号", "kdxx").Replace(":", "").Replace(":", ""); } if (string.IsNullOrEmpty(code)) { code = bidCtx.Replace(")", "kdxx").Replace(")", "kdxx").GetRegexBegEnd("编号", "kdxx").Replace(":", "").Replace(":", ""); } if (Encoding.Default.GetByteCount(code) > 50) { code = string.Empty; } if (!string.IsNullOrEmpty(code)) { code = code.GetChina(); } prjName = prjName.GetBidPrjName(); code = code.Replace("(", "").Replace("(", "").Replace(")", "").Replace(")", ""); msgType = "深圳市坪山新区政府采购中心"; specType = "政府采购"; BidInfo info = ToolDb.GenBidInfo("广东省", "深圳政府采购", "坪山新区", string.Empty, code, prjName, buildUnit, beginDate, bidUnit, beginDate, endDate, bidCtx, string.Empty, msgType, bidType, specType, otherType, bidMoney, InfoUrl, prjMgr, HtmlTxt); list.Add(info); if (!crawlAll && list.Count >= this.MaxCount) { return(list); } } } } } return(list); }