Ejemplo n.º 1
0
        protected override Hashtable GetUris()
        {
            Hashtable uris         = new Hashtable();
            Hashtable columnHeader = new Hashtable();
            string    fileName     = FileHelper.GetPublicPage(base.Version, base.FillType);

            using (Office.Excel.ForwardExcelReader pages = new Office.Excel.ForwardExcelReader(string.Format("{0}\\{1}", base.RuleFilePath, fileName)))
            {
                pages.Open();
                Office.Excel.ForwardReadWorksheet sheet = pages.Activate("页面汇总") as Office.Excel.ForwardReadWorksheet;
                if (sheet != null)
                {
                    object content = null, uri = null;
                    if (sheet.ReadNextRow())
                    {
                        while (sheet.ReadNextCell(false))
                        {
                            columnHeader.Add(sheet.CurrentCell.ColumnIndex, sheet.GetContent());
                        }
                    }
                    UrlParameter urlParameter = null;
                    while (sheet.ReadNextRow()) // 读取下一行。
                    {
                        uri          = null; content = null;
                        urlParameter = new UrlParameter(); // 存储Url对应的页面标签及Excel文件名称。
                        while (sheet.ReadNextCell(false))  // 读取本行的下一个单元格数据。
                        {
                            content = sheet.GetContent();
                            switch (columnHeader[sheet.CurrentCell.ColumnIndex] as string)
                            {
                            case "页面标签":
                                urlParameter.LabelName = content == null ? "" : content.ToString();
                                break;

                            case "所属Excel":
                                urlParameter.IsPublicUrl = (content as string) == "公共页面";
                                break;

                            case "URL":
                                uri = content as string;
                                break;
                            }
                        }
                        if (uri != null && string.IsNullOrEmpty(uri.ToString()) == false)
                        {
                            Uri url = new Uri(uri.ToString());
                            if (uris.ContainsKey(url.AbsolutePath))
                            {
                                continue;
                            }
                            uris.Add(url.AbsolutePath, urlParameter);
                        }
                    }
                }
            }
            return(uris);
        }
Ejemplo n.º 2
0
        public FillBase GetFiller(Uri url)
        {
            string uri = url.AbsolutePath;

            if (string.IsNullOrEmpty(uri))
            {
                return(null);
            }
            UrlParameter parameter = _uris[uri] as UrlParameter;
            string       key       = parameter == null ? null : parameter.LabelName;

            if (key == null)
            {
                return(null);
            }
            return(_fillTable[key] as FillBase);
        }
Ejemplo n.º 3
0
        protected FillBase CreateFillInner(Uri url, WebBrowser2 browser)
        {
            string uri = url.AbsolutePath;

            if (string.IsNullOrEmpty(uri))
            {
                return(null);
            }
            UrlParameter parameter = _uris[uri] as UrlParameter;
            string       key       = parameter == null ? null : parameter.LabelName;

            if (key == null)
            {
                return(null);
            }
            FillBase fill = CreateFill(url, browser);

            if (fill != null)
            {
                if (_fillTable.Contains(key))
                {
                    _fillTable[key] = fill;
                }
                else
                {
                    _fillTable.Add(key, fill);
                }
                fill.DataTable         = _data;
                fill.RulePath          = RuleFilePath;
                fill.FillVersion       = this.Version;
                fill.FillRecords       = this._records;
                fill.DataProvider      = this.DataProvider;
                fill.FillStateChanged += new EventHandler(OnFillStateChanged);
            }
            return(fill);
        }
Ejemplo n.º 4
0
 public PZHFiller(WebBrowser2 browser, Uri currentUri, UrlParameter urlParameter)
     : base(browser, currentUri)
 {
     _parameters   = new List <KeyValuePair <FillParameterKey, object> >();
     _urlParameter = urlParameter;
 }