private void GetUrlDict(Match m, ref string url, string nextPageText, List <string> levelUrlList, string startPos, string endPos, OnEnqueueUrls enqueueUrl) { string str = m.Value.Substring(5);//去除dict: if (!string.IsNullOrEmpty(str)) { string errMsg = string.Empty; DictList dictList = XmlHelper.LoadFromXml <DictList>(Program.GetConfigPath(@"dict.xml"), ref errMsg); Dict dictEntity = dictList.Where(q => q.CategoryName.Value == str).FirstOrDefault(); if (dictEntity.DictItemList == null || dictEntity.DictItemList.Count == 0) { string tempUrl0 = url.Substring(0, m.Index - 1); string tempCode = ""; string tempUrl1 = string.Empty; int lastIndex = m.Index + m.Length + 1; if (url.Length > lastIndex) { tempUrl1 = url.Substring(lastIndex); } string tempUrl = tempUrl0 + tempCode + tempUrl1; url = GetMatchUrl(tempUrl, nextPageText, levelUrlList, startPos, endPos, enqueueUrl); if (_GatherUrlItemSingleFlag) { return; } enqueueUrl(url, nextPageText, levelUrlList, startPos, endPos); } else { string tempUrl0 = url.Substring(0, m.Index - 1); string tempUrl1 = string.Empty; int index = 1; foreach (var item in dictEntity.DictItemList) { string tempCode = item.DictName.Value; int lastIndex = m.Index + m.Length + 1; if (url.Length > lastIndex) { tempUrl1 = url.Substring(lastIndex); } string tempUrl = tempUrl0 + tempCode + tempUrl1; url = GetMatchUrl(tempUrl, nextPageText, levelUrlList, startPos, endPos, enqueueUrl); if (_GatherUrlItemSingleFlag) { return; } if (index == dictEntity.DictItemList.Count) { break; } enqueueUrl(url, nextPageText, levelUrlList, startPos, endPos); index++; } } } }
private void lsvWord_AfterLabelEdit(object sender, LabelEditEventArgs e) { if (e.Label == null) { //表示没有进行修改 this.lsvWord.Items.Remove(this.lsvWord.Items[e.Item]); this.lsvWord.LabelEdit = false; return; } if (e.Label.ToString().Trim() == "") { e.CancelEdit = true; this.lsvWord.Items.Remove(this.lsvWord.Items[e.Item]); this.lsvWord.LabelEdit = false; return; } Dict dictEntity = dictList.Where(q => q.CategoryName.Value == SelectNodeText).FirstOrDefault(); if (dictEntity == null) { WinFormLib.Core.MessageBoxHelper.ShowError("请先选择字典分类!"); return; } if (!string.IsNullOrEmpty(SelectListViewText)) { DictItem dictItemEntity = dictEntity.DictItemList.Where(q => q.DictName.Value == SelectListViewText).FirstOrDefault(); if (dictItemEntity != null) { dictItemEntity.DictName = CDataItem.Instance(e.Label.Trim()); } } else { dictEntity.DictItemList.Add(new DictItem() { DictName = CDataItem.Instance(e.Label.Trim()) }); } SelectListViewText = string.Empty; }