public void DelRecord(string key) { Boolean find = false; for (int i = 0, l = this.PageList.Count; i < l; i++) { if (find) { break; } for (int j = 0, m = this.PageList[i].FileItemList.Count; j < m; j++) { if (key == this.PageList[i].FileItemList[j].Key) { this.PageList[i].FileItemList.Remove(this.PageList[i].FileItemList[j]); find = true; break; } } } LogFileManager.DeleteFile(key); }
private void LoadList() { this.PageList = new List <PageInfoItem>(); XmlDocument document = new XmlDocument(); document.Load(FiddlerPath.RecordFilePath); XmlElement root = document.DocumentElement; XmlNodeList pageNodes = root.SelectNodes("//InjectionLists/Page"); string currentDate = TimeFormat.GetTimeStamp(); // 判断页面是否已经有记录 if (pageNodes != null && pageNodes.Count > 0) { foreach (XmlNode page in pageNodes) { PageInfoItem pageItem = new PageInfoItem(); pageItem.Url = page.Attributes["Url"].Value; pageItem.CreateDate = page.Attributes["CreateDate"].Value; XmlNodeList fileNodes = (page as XmlElement).ChildNodes; if (fileNodes != null && fileNodes.Count > 0) { foreach (XmlNode file in fileNodes) { string Key = file.Attributes["Key"].Value; string CreateDate = file.Attributes["CreateDate"].Value; string Url = file.Attributes["Url"].Value; string Order = file.Attributes["Order"].Value; // 自动清理逻辑,每次启动初始化的时候执行 // 在有效期内的数据才记录,否则删除本地文件 if (Convert.ToUInt64(currentDate) * 1000 - Convert.ToUInt64(CreateDate) * 1000 < Global.iExpiresTime) { pageItem.AddFileItem(Key, CreateDate, Order, Key); } else { LogFileManager.DeleteFile(Key); } } } // 如果该页面已经没有记录了,不再记录该页面 if (pageItem.FileItemList != null && pageItem.FileItemList.Count > 0) { this.PageList.Add(pageItem); } } } }