📄 collectionprogress.cs
字号:
row["FieldValue"] = this.m_FileDown;
row["FieldType"] = none;
row["FieldLevel"] = fieldLevel;
dataTable.Rows.Add(row);
}
}
continue;
Label_0933:
row = dataTable.NewRow();
row["FieldName"] = info.FieldName;
row["FieldValue"] = CommonFilter(info.FilterRuleId, info.PrivateFilter, common, str3);
row["FieldType"] = none;
row["FieldLevel"] = fieldLevel;
dataTable.Rows.Add(row);
}
return dataTable;
}
public string SaveFile(string content, NodeInfo nodeInfo, CollectionCommon collectionCommon, bool isDown, string fileType)
{
int num = 0;
string str = VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.UploadDir);
StringBuilder builder = new StringBuilder();
WebClient client = new WebClient();
MatchCollection matchs = new Regex("<a(?<Attributes1>[\\s\\S]*?)href=(\"{1}|'{1}|)(?<picture>[^\\[^>]*?(" + fileType + "))(\"{1}|'{1}|)(?<Attributes2>[\\s\\S]*?)>", RegexOptions.IgnoreCase).Matches(content);
if (matchs.Count <= 0)
{
return "";
}
StringBuilder builder2 = new StringBuilder();
foreach (Match match in matchs)
{
string str2 = collectionCommon.DefiniteUrl(match.Groups["picture"].Value, this.m_CollectionItemInfo.Url);
if (builder2.Length == 0)
{
builder2.Append(str2);
}
else
{
if (builder2.ToString().IndexOf(str2) > 0)
{
continue;
}
builder2.Append(str2);
}
num++;
try
{
string str3 = DataSecurity.MakeFileRndName();
string str4 = Path.GetExtension(str2).ToLower();
string str5 = PowerEasy.Contents.Nodes.UploadPathParse(nodeInfo, str3 + str4).Replace("//", "/");
string str6 = str5 + str3 + str4;
StringBuilder builder3 = new StringBuilder();
string path = Path.Combine(this.PhysicalApplicationPath, str + str5);
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
builder3.Append(path);
builder3.Append(str3 + str4);
client.DownloadFile(str2, builder3.ToString());
if (builder.Length > 0)
{
builder.Append("$$$下载地址" + num.ToString() + "|" + str6);
}
else
{
builder.Append(string.Concat(new object[] { "下载地址", num, "|", str6 }));
if (isDown)
{
this.m_FileDown = str6;
}
}
}
catch (WebException)
{
this.m_CollectionPhotoFailure++;
}
client.Dispose();
}
return builder.ToString();
}
public string SaveMultiplePhoto(string content, NodeInfo nodeInfo, CollectionCommon collectionCommon, bool isThumb)
{
int num = 0;
string str = VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.UploadDir);
StringBuilder builder = new StringBuilder();
WebClient client = new WebClient();
MatchCollection matchs = new Regex("<img(?<Attributes1>[\\s\\S]*?)src=(\"{1}|'{1}|)(?<picture>[^\\[^>]*?(gif|jpg|jpeg|bmp|png))(\"{1}|'{1}|)(?<Attributes2>[\\s\\S]*?)>", RegexOptions.IgnoreCase).Matches(content);
if (matchs.Count <= 0)
{
return "";
}
foreach (Match match in matchs)
{
num++;
string path = collectionCommon.DefiniteUrl(match.Groups["picture"].Value, this.m_CollectionItemInfo.Url);
try
{
string str3 = DataSecurity.MakeFileRndName();
string str4 = Path.GetExtension(path).ToLower();
string str5 = PowerEasy.Contents.Nodes.UploadPathParse(nodeInfo, str3 + str4).Replace("//", "/");
string str6 = str5 + str3 + str4;
StringBuilder builder2 = new StringBuilder();
string str7 = Path.Combine(this.PhysicalApplicationPath, str + str5);
if (!Directory.Exists(str7))
{
Directory.CreateDirectory(str7);
}
builder2.Append(str7);
builder2.Append(str3 + str4);
client.DownloadFile(path, builder2.ToString());
if (builder.Length > 0)
{
builder.Append("$$$图片地址" + num.ToString() + "|" + str6);
}
else
{
builder.Append(string.Concat(new object[] { "图片地址", num, "|", str6 }));
if (isThumb)
{
this.m_ThumbPhoto = str6;
}
}
}
catch (WebException)
{
this.m_CollectionPhotoFailure++;
}
client.Dispose();
}
return builder.ToString();
}
public string SavePhoto(string content, NodeInfo nodeInfo, CollectionCommon collectionCommon)
{
string str = VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.UploadDir);
StringBuilder builder = new StringBuilder();
WebClient client = new WebClient();
MatchCollection matchs = new Regex("<img(?<Attributes1>[\\s\\S]*?)src=(\"{1}|'{1}|)(?<picture>[^\\[^>]*?(gif|jpg|jpeg|bmp|png))(\"{1}|'{1}|)(?<Attributes2>[\\s\\S]*?)>", RegexOptions.IgnoreCase).Matches(content);
if (matchs.Count > 0)
{
foreach (Match match in matchs)
{
string path = collectionCommon.DefiniteUrl(match.Groups["picture"].Value, this.m_CollectionItemInfo.Url);
try
{
string str3 = DataSecurity.MakeFileRndName();
string str4 = Path.GetExtension(path).ToLower();
string str5 = PowerEasy.Contents.Nodes.UploadPathParse(nodeInfo, str3 + str4).Replace("//", "/");
string str6 = str5 + str3 + str4;
StringBuilder builder2 = new StringBuilder();
string str7 = Path.Combine(this.PhysicalApplicationPath, str + str5);
if (!Directory.Exists(str7))
{
Directory.CreateDirectory(str7);
}
builder2.Append(str7);
builder2.Append(str3 + str4);
client.DownloadFile(path, builder2.ToString());
content = content.Replace(match.Groups["picture"].Value, "{PE.SiteConfig.ApplicationPath/}{PE.SiteConfig.uploaddir/}/" + str6);
if (builder.Length > 0)
{
builder.Append("|" + str6);
}
else
{
builder.Append(str6);
}
if (string.IsNullOrEmpty(this.m_DefaultPicUrl))
{
this.m_DefaultPicUrl = str6;
}
this.m_CollectionPhotoSuccess++;
}
catch (WebException)
{
this.m_CollectionPhotoFailure++;
}
client.Dispose();
this.m_UploadFiles = builder.ToString();
}
}
return content;
}
private void StartCollection()
{
int num = DataConverter.CLng(this.m_CollectionItemInfo.MaxNum);
int num2 = 0;
NodeInfo nodeById = PowerEasy.Contents.Nodes.GetNodeById(this.m_CollectionItemInfo.NodeId);
this.m_CollectionCompleted = 0;
if (this.m_CollectionItemInfo.OrderType == 1)
{
string str = "";
int num3 = this.m_ListContentLinks.Count - 1;
if (num3 > 0)
{
for (int i = 0; i < DataConverter.CLng(num3 / 2); i++)
{
str = this.m_ListContentLinks[i].ToString();
this.m_ListContentLinks[i] = this.m_ListContentLinks[num3 - i];
this.m_ListContentLinks[num3 - i] = str;
}
}
}
this.m_IsInput = true;
if ((num > 0) && (num <= this.m_ListContentLinks.Count))
{
this.m_CollectionCount = num;
}
else
{
this.m_CollectionCount = this.m_ListContentLinks.Count;
}
CollectionItem.UpdateCollecDate(this.m_CollectionItemInfo.ItemId);
this.m_CollectionStartTime = DateTime.Now;
string collectionMessage = this.m_CollectionMessage;
this.m_CollectionMessage = collectionMessage + "<br/><font color='blue'>" + this.m_CollectionItemInfo.ItemName + "</font>总共要采集 <font color='blue'><b>" + this.m_CollectionCount.ToString() + "</b></font> 个内容页面<br/>";
foreach (string str2 in this.m_ListContentLinks)
{
this.m_Result = true;
DataTable dataTableField = this.GetDataTableField(str2, nodeById);
DataRow[] rowArray = dataTableField.Select("FieldName = 'title'");
string title = "";
if ((rowArray != null) && (rowArray.Length > 0))
{
title = rowArray[0]["FieldValue"].ToString();
}
this.m_CollectionCompleted++;
if (this.IsTitle && CollectionHistory.Exists(title))
{
object obj2 = this.m_CollectionMessage;
this.m_CollectionMessage = string.Concat(new object[] { obj2, "<li>没有采集第 <font color='red'><b>", this.m_CollectionCompleted, "</b></font> 个页面,因为重复标题,采集历史记录已经记录。</li>" });
continue;
}
if (num > 0)
{
num2++;
if (num2 > num)
{
return;
}
}
CollectionHistoryInfo collectionHistoryInfo = new CollectionHistoryInfo();
CollectionCommon common = new CollectionCommon();
collectionHistoryInfo.ItemId = this.m_CollectionItemInfo.ItemId;
collectionHistoryInfo.ModelId = this.m_CollectionItemInfo.ModelId;
collectionHistoryInfo.NewsUrl = common.DefiniteUrl(str2, this.m_CollectionItemInfo.Url);
collectionHistoryInfo.NodeId = this.m_CollectionItemInfo.NodeId;
collectionHistoryInfo.CollectionTime = DateTime.Now;
collectionHistoryInfo.Title = title;
if (this.m_Result)
{
if (ContentManage.Add(this.m_CollectionItemInfo.ModelId, dataTableField))
{
collectionHistoryInfo.Result = true;
DataRow[] rowArray2 = dataTableField.Select("FieldName = 'generalId'");
collectionHistoryInfo.GeneralId = DataConverter.CLng(rowArray2[0]["FieldValue"].ToString());
object obj3 = this.m_CollectionMessage;
this.m_CollectionMessage = string.Concat(new object[] { obj3, "<li>采集录入成功第 <font color='red'><b>", this.m_CollectionCompleted, "</b></font> 个页面</li>" });
}
else
{
object obj4 = this.m_CollectionMessage;
this.m_CollectionMessage = string.Concat(new object[] { obj4, "<li>采集录入失败第 <font color='red'><b>", this.m_CollectionCompleted, "</b></font> 个页面</li>" });
collectionHistoryInfo.Result = false;
collectionHistoryInfo.GeneralId = 0;
}
}
else
{
object obj5 = this.m_CollectionMessage;
this.m_CollectionMessage = string.Concat(new object[] { obj5, "<li>采集规则截取失败第 <font color='red'><b>", this.m_CollectionCompleted, "</b></font> 个页面</li>" });
collectionHistoryInfo.Result = false;
collectionHistoryInfo.GeneralId = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -