⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 collectionprogress.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
📖 第 1 页 / 共 5 页
字号:
namespace PowerEasy.Collection
{
    using PowerEasy.Common;
    using PowerEasy.Components;
    using PowerEasy.Contents;
    using PowerEasy.Enumerations;
    using PowerEasy.Model.Collection;
    using PowerEasy.Model.Contents;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Data;
    using System.IO;
    using System.Net;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Threading;
    using System.Web;

    public class CollectionProgress
    {
        private string m_AdminName;
        private string m_ArrPaging;
        private int m_CollectionCompleted;
        private int m_CollectionCount;
        private DateTime m_CollectionErrorTime;
        private IList<CollectionFieldRuleInfo> m_CollectionFieldRuleInfoList;
        private CollectionItemInfo m_CollectionItemInfo;
        private string m_CollectionMessage;
        private int m_CollectionPhotoFailure;
        private int m_CollectionPhotoSuccess;
        private DateTime m_CollectionStartTime;
        private string m_CreateId;
        private Thread m_CreateThread;
        private string m_DefaultPicUrl;
        private string m_ErrorInfo;
        private string m_FileDown;
        private bool m_IsInput;
        private bool m_IsTitle;
        private int m_ItemCompleted;
        private int m_ItemCount;
        private string m_ItemId;
        private ArrayList m_ListContentLinks;
        private string m_PhysicalApplicationPath;
        private bool m_Result;
        private string m_ThumbPhoto;
        private string m_UploadFiles;
        private string m_UserName;

        private void AddListContentLinks(string nexturl, CollectionCommon collectionCommon, CollectionListRuleInfo collectionListRuleInfo)
        {
            if (DataValidator.IsUrl(nexturl))
            {
                Uri url = new Uri(nexturl);
                string httpPage = collectionCommon.GetHttpPage(url, this.m_CollectionItemInfo.CodeType);
                if (!string.IsNullOrEmpty(httpPage) && !string.IsNullOrEmpty(collectionCommon.GetInterceptionString(httpPage, collectionListRuleInfo.ListBeginCode, collectionListRuleInfo.ListEndCode)))
                {
                    ArrayList list = collectionCommon.GetArray(httpPage, collectionListRuleInfo.LinkBeginCode, collectionListRuleInfo.LinkEndCode);
                    if (list.Count >= 1)
                    {
                        foreach (string str3 in list)
                        {
                            this.m_ListContentLinks.Add(str3);
                        }
                    }
                }
            }
        }

        private string AddPagingContent(string nexturl, CollectionCommon collectionCommon, CollectionFieldRuleInfo collectionFieldRuleInfo, string interceptionContent)
        {
            if (!DataValidator.IsUrl(nexturl))
            {
                return interceptionContent;
            }
            Uri url = new Uri(nexturl);
            string httpPage = collectionCommon.GetHttpPage(url, this.m_CollectionItemInfo.CodeType);
            if (string.IsNullOrEmpty(httpPage))
            {
                return interceptionContent;
            }
            string str2 = collectionCommon.GetInterceptionString(httpPage, collectionFieldRuleInfo.BeginCode, collectionFieldRuleInfo.EndCode);
            if (string.IsNullOrEmpty(str2))
            {
                return interceptionContent;
            }
            return (interceptionContent + "[NextPage]" + str2);
        }

        private string AddPagingContent(string nextLink, string interceptionContent, CollectionCommon collectionCommon, CollectionFieldRuleInfo collectionFieldRuleInfo, CollectionPagingRuleInfo collectionPagingRuleInfo)
        {
            if (DataValidator.IsUrl(nextLink))
            {
                if (string.IsNullOrEmpty(this.m_ArrPaging))
                {
                    this.m_ArrPaging = nextLink;
                }
                else
                {
                    if (this.m_ArrPaging.IndexOf(nextLink) >= 0)
                    {
                        return interceptionContent;
                    }
                    this.m_ArrPaging = this.m_ArrPaging + nextLink;
                }
                Uri url = new Uri(nextLink);
                string httpPage = collectionCommon.GetHttpPage(url, this.m_CollectionItemInfo.CodeType);
                if (!string.IsNullOrEmpty(httpPage))
                {
                    string str2 = collectionCommon.GetInterceptionString(httpPage, collectionFieldRuleInfo.BeginCode, collectionFieldRuleInfo.EndCode);
                    if (string.IsNullOrEmpty(str2))
                    {
                        return interceptionContent;
                    }
                    interceptionContent = interceptionContent + "[NextPage]" + str2;
                    nextLink = collectionCommon.DefiniteUrl(collectionCommon.GetPaing(httpPage, collectionPagingRuleInfo.PagingBeginCode, collectionPagingRuleInfo.PagingEndCode), this.m_CollectionItemInfo.Url);
                    if (!string.IsNullOrEmpty(nextLink))
                    {
                        this.m_ArrPaging = this.m_ArrPaging + nextLink;
                        interceptionContent = this.AddPagingContent(nextLink, interceptionContent, collectionCommon, collectionFieldRuleInfo, collectionPagingRuleInfo);
                    }
                }
            }
            return interceptionContent;
        }

        private static string CommonFilter(string filterRuleId, string filter, CollectionCommon collectionCommon, string testContent)
        {
            if (filterRuleId.IndexOf(',') > 0)
            {
                foreach (string str in filterRuleId.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries))
                {
                    testContent = FilterRule(DataConverter.CLng(str), collectionCommon, testContent);
                }
            }
            else
            {
                testContent = FilterRule(DataConverter.CLng(filterRuleId), collectionCommon, testContent);
            }
            testContent = StringHelper.FilterScript(testContent, filter);
            return testContent;
        }

        private void CountNextLinks(string nextLink, string constr, CollectionCommon collectionCommon, CollectionListRuleInfo collectionListRuleInfo, CollectionPagingRuleInfo collectionPagingRuleInfo)
        {
            if (DataValidator.IsUrl(nextLink))
            {
                if (string.IsNullOrEmpty(this.m_ArrPaging))
                {
                    this.m_ArrPaging = nextLink;
                }
                else
                {
                    if (this.m_ArrPaging.IndexOf(nextLink) >= 0)
                    {
                        return;
                    }
                    this.m_ArrPaging = this.m_ArrPaging + nextLink;
                }
                Uri url = new Uri(nextLink);
                constr = collectionCommon.GetHttpPage(url, this.m_CollectionItemInfo.CodeType);
                if (!string.IsNullOrEmpty(constr) && !string.IsNullOrEmpty(collectionCommon.GetInterceptionString(constr, collectionListRuleInfo.ListBeginCode, collectionListRuleInfo.ListEndCode)))
                {
                    ArrayList list = collectionCommon.GetArray(constr, collectionListRuleInfo.LinkBeginCode, collectionListRuleInfo.LinkEndCode);
                    if (list.Count >= 1)
                    {
                        foreach (string str2 in list)
                        {
                            this.m_ListContentLinks.Add(str2);
                        }
                        nextLink = collectionCommon.DefiniteUrl(collectionCommon.GetPaing(constr, collectionPagingRuleInfo.PagingBeginCode, collectionPagingRuleInfo.PagingEndCode), this.m_CollectionItemInfo.Url);
                        if (!string.IsNullOrEmpty(nextLink))
                        {
                            this.m_ArrPaging = this.m_ArrPaging + nextLink;
                            this.CountNextLinks(nextLink, constr, collectionCommon, collectionListRuleInfo, collectionPagingRuleInfo);
                        }
                    }
                }
            }
        }

        public void CreateCollectionProc()
        {
            this.m_CreateId = Guid.NewGuid().ToString();
            if (HttpContext.Current != null)
            {
                this.m_PhysicalApplicationPath = this.PhysicalApplicationPath;
            }
            XmlManage manage = XmlManage.Instance("Config/CreateCollectionWork.config", XmlType.File);
            manage.SetNodeValue("CollectionWork/WorkId", this.m_CreateId);
            try
            {
                manage.Save("Config/CreateCollectionWork.config");
            }
            catch (FileNotFoundException)
            {
                throw new CustomException("CreateCollectionWork.config文件未找到。");
            }
            catch
            {
                throw new CustomException("检查您的服务器是否给配置文件CreateCollectionWork.config或文件夹写入权限。");
            }
            this.StartCreate();
            if (HttpContext.Current != null)
            {
                HttpContext.Current.Application[this.m_CreateId] = this;
            }
        }

        private DataRow DesignatedDataRow(DataTable dataTable, DataRow dataRow, FieldType fieldType, CollectionFieldRuleInfo collectionFieldRuleInfo, int fieldLevel)
        {
            dataRow = dataTable.NewRow();
            dataRow["FieldName"] = collectionFieldRuleInfo.FieldName;
            switch (fieldType)
            {
                case FieldType.NumberType:
                case FieldType.StatusType:
                    dataRow["FieldValue"] = DataConverter.CFloat(collectionFieldRuleInfo.SpecialSetting).ToString();
                    break;

                case FieldType.MoneyType:
                    dataRow["FieldValue"] = DataConverter.CDecimal(collectionFieldRuleInfo.SpecialSetting).ToString();
                    break;

                case FieldType.DateTimeType:
                    dataRow["FieldValue"] = DataConverter.CDate(collectionFieldRuleInfo.SpecialSetting).ToString();
                    break;

                case FieldType.BoolType:
                    dataRow["FieldValue"] = DataConverter.CBool(collectionFieldRuleInfo.SpecialSetting).ToString();
                    break;

                default:
                    dataRow["FieldValue"] = collectionFieldRuleInfo.SpecialSetting;
                    break;
            }
            dataRow["FieldType"] = fieldType;
            dataRow["FieldLevel"] = fieldLevel;
            dataTable.Rows.Add(dataRow);
            if ((fieldType == FieldType.StatusType) && (DataConverter.CLng(collectionFieldRuleInfo.SpecialSetting) == 0x63))
            {
                dataRow = dataTable.NewRow();
                dataRow["FieldName"] = "Editor";
                dataRow["FieldValue"] = this.m_AdminName;
                dataRow["FieldType"] = FieldType.TextType;
                dataRow["FieldLevel"] = 0;
                dataTable.Rows.Add(dataRow);
                dataRow = dataTable.NewRow();
                dataRow["FieldName"] = "PassedTime";
                dataRow["FieldValue"] = DateTime.Now.ToString("yyyy-MM-dd");
                dataRow["FieldType"] = FieldType.DateTimeType;
                dataRow["FieldLevel"] = 0;
                dataTable.Rows.Add(dataRow);
            }
            return dataRow;
        }

        public void Detection(int itemId)
        {
            this.m_IsInput = false;
            if (itemId < 1)
            {
                this.m_ErrorInfo = "<li>采集项目ID不对!</li>";
            }
            else
            {
                this.m_CollectionItemInfo = CollectionItem.GetInfoById(itemId);
                if (this.m_CollectionItemInfo.IsNull)
                {
                    this.m_ErrorInfo = "<li>采集项目规则不存在!</li>";
                }
                else
                {
                    this.m_CollectionMessage = this.m_CollectionMessage + "正在分析 <font color='blue'>" + this.m_CollectionItemInfo.ItemName + "</font> 列表规则  请稍候...<br/>";
                    CollectionListRuleInfo infoById = CollectionListRules.GetInfoById(this.m_CollectionItemInfo.ItemId);
                    if (infoById.IsNull)
                    {
                        this.m_ErrorInfo = "<li>" + this.m_CollectionItemInfo.ItemName + "采集项目的列表规则不存在!</li>";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -