/// <summary> /// 设置列索引 /// </summary> /// <param name="cell">单元格</param> private void SetColumnIndex(ICell cell) { if (cell.ColumnIndex > 0) { _indexManager.AddIndex(cell.ColumnIndex, cell.ColumnSpan); return; } cell.ColumnIndex = _indexManager.GetIndex(cell.ColumnSpan); }
public async void GenerateWebRequestAsync(WorkManage wm, int depth, IndexManager indexmanager) { try { webRequest = (HttpWebRequest)WebRequest.Create(RequestUri); //创建Request实例 webRequest.Method = "GET"; //方法为GET webRequest.KeepAlive = true; //持续型链接 webRequest.Timeout = 100; //超时值为100ms webResponse = (HttpWebResponse)await webRequest.GetResponseAsync(); //获取当前请求的响应 ContentStream = webResponse.GetResponseStream(); //获取响应的字节流 string html = GetContent(); //转化为HTML文本 GetLinks getLinks = new GetLinks(html); Article article = new Article(); Html2Article.AppendMode = false; Html2Article.Depth = 80; article = Html2Article.GetArticle(html); wm.sum++; indexmanager.AddIndex(article.Title, article.Content, RequestUri); if (depth < wm.Depth) { foreach (string uri in getLinks.GetUris()) { if (!wm.unfinisheduri.ContainsKey(uri)) { lock (wm.unfinisheduri) { wm.unfinisheduri.Add(uri, depth + 1); } } } } webRequest.Abort(); webResponse.Close(); } catch { } //Thread.Sleep(timeSpan); //ThreadPool }
public void TestAddIndex() { _manager.AddIndex(1); Assert.Equal(0, _manager.GetIndex()); Assert.Equal(2, _manager.GetIndex()); }