private void SaveAttach(BidProject info, string htmltxt, string result, bool isUpdate) { List <BaseAttach> list = new List <BaseAttach>(); if (htmltxt.Contains("http")) { Parser parser = new Parser(new Lexer(htmltxt)); NodeList aNode = parser.ExtractAllNodesThatMatch(new TagNameFilter("a")); if (aNode != null && aNode.Count > 0) { for (int j = 0; j < aNode.Count; j++) { ATag aTag = aNode[j].GetATag(); string attachName = aTag.LinkText; string aurl = string.Empty; if (!aTag.Link.ToLower().Contains("http")) { aurl = "https://www.szjsjy.com.cn:8001/" + aTag.Link.GetReplace("\\"); } else { aurl = aTag.Link.GetReplace("\\"); } if (string.IsNullOrWhiteSpace(attachName)) { attachName = info.PrjName; } try { string url = System.Web.HttpUtility.UrlDecode(aurl); string[] urls = url.Split('&'); url = urls[0] + "&" + urls[2] + "&" + urls[1]; BaseAttach entity = null; if (isUpdate) { entity = ToolHtml.GetBaseAttach(url.Replace("\"", ""), attachName, result, "SiteManage\\Files\\Attach\\"); } else { entity = ToolHtml.GetBaseAttach(url.Replace("\"", ""), attachName, info.Id, "SiteManage\\Files\\Attach\\"); } if (entity != null) { list.Add(entity); } } catch { } } } } else { System.Data.DataTable dtlDtl = ToolHtml.JsonToDataTable(htmltxt); if (dtlDtl != null && dtlDtl.Rows.Count > 0) { for (int i = 0; i < dtlDtl.Rows.Count; i++) { System.Data.DataRow row = dtlDtl.Rows[i]; string attachName = Convert.ToString(row["attachName"]); if (string.IsNullOrWhiteSpace(attachName)) { attachName = info.PrjName; } string attachGuid = Convert.ToString(row["attachGuid"]); string url = "https://www.szjsjy.com.cn:8001/file/downloadFile?fileId=" + attachGuid; try { BaseAttach entity = null; if (isUpdate) { entity = ToolHtml.GetBaseAttachByUrl(url, attachName, result, "SiteManage\\Files\\Attach\\"); } else { entity = ToolHtml.GetBaseAttachByUrl(url, attachName, info.Id, "SiteManage\\Files\\Attach\\"); } if (entity != null) { list.Add(entity); } } catch { } } } } if (list.Count > 0) { if (isUpdate) { string delSql = string.Format("delete from BaseAttach where SourceID='{0}'", result); ToolFile.Delete(result); int count = ToolDb.ExecuteSql(delSql); } foreach (BaseAttach attach in list) { ToolDb.SaveEntity(attach, "SourceID,AttachServerPath"); } } }