Exemplo n.º 1
0
        public bool FillPage()
        {
            this.GetSelectedText();
            if (string.IsNullOrEmpty(this.SelectedText))
            {
                return(true);
            }
            string    path        = GetSelectedNodePath();
            TreeValue currentPage = TreeValue;

            if (path != null)
            {
                currentPage = currentPage.Select(path);
            }
            if (currentPage == null)
            {
                return(false);
            }

            if (currentPage != null && currentPage.Parent != null)
            {
#if export
                if (writer == null)
                {
                    writer = new Office.Excel.ForwardExcelWriter(string.Format("{0}\\{1}.xlsx", Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "3C下拉列表框"));
                    writer.Open();
                    sheet = writer.CreateWorksheet() as Office.Excel.ForwardWriteWorksheet;
                    sheet.WriteNextRow();
                    sheet.WriteTextCell(1, writer.AddSharedString("CCC编号"));
                }
#endif
                _pageData = currentPage.Values;
                FillPage(currentPage);
            }

            foreach (TreeValue child in currentPage.Children)
            {
                if (child.IsAppendNode)
                {
                    IntPtr childPtr = FindChild(_selectedNode, child.Name);
                    if (childPtr != IntPtr.Zero)
                    {
                        _treeView.ScrollIntoView(childPtr);
                        this.AppendNode(childPtr, child.Suffix);
                    }
                    Match match = child.Name == null ? Match.Empty : nodeMatcher.Match(child.Name);
                    if (match.Success)
                    {
                        if (match.Groups["no"].Value == "C10.1.1.1")
                        {
                            child.Rename("C10.1.1.1前照灯(远光/近光)");
                        }
                    }
                }
            }
            return(true);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 初始化国环网页元素探测器。
 /// </summary>
 /// <param name="browser">要探测的网页所在浏览器。</param>
 /// <param name="attrStringList">需要记录的元素属性列表。</param>
 public GHElementDetector(WebBrowser browser, IList attrStringList)
     : base(browser)
 {
     _group             = null;
     _excelColumnHeader = attrStringList;
     _writer            = new Office.Excel.ForwardExcelWriter(Path.GetTempFileName());
     _writer.Open();
     _sheet = _writer.CreateWorksheet() as Office.Excel.ForwardWriteWorksheet;
     writeExcelHeader();
 }
Exemplo n.º 3
0
        public PrivateDetector(WebBrowser2 browser, string fileName, IList attrStringList)
            : base(browser)
        {
            string tempPath = System.IO.Path.GetTempPath();

            _fileName = fileName;
            _fullName = string.Format("{0}\\{1}", tempPath, fileName);
            FileInfo info = new FileInfo(_fullName);

            if (info.Directory.Exists == false)
            {
                info.Directory.Create();
            }
            _excelColumnHeader = attrStringList;
            _writer            = new Office.Excel.ForwardExcelWriter(_fullName);
            _writer.Open();
        }
Exemplo n.º 4
0
        //protected override void onTextElementFinded(IHTMLElement textElement, Stack<IHTMLElement> textNode)
        //{
        //    string field = FindField(textNode);
        //}

        //protected override void onRadioElementFinded(IHTMLElement radioElement, Stack<IHTMLElement> textNode)
        //{
        //    string field = radioElement.getAttribute("value");
        //}

        //protected override void onCheckBoxElementFinded(IHTMLElement checkElement, Stack<IHTMLElement> textNode)
        //{
        //    string field = checkElement.getAttribute("value");
        //}

        //protected override void onSubmitElementFinded(IHTMLElement submitElement, IHTMLElement form, Stack<IHTMLElement> textNode)
        //{
        //    string field = submitElement.getAttribute("value");
        //}

        //protected override void onSelectElementFinded(IHTMLElement selectElement, Stack<IHTMLElement> textNode)
        //{
        //    string field = FindField(textNode);
        //    if (string.IsNullOrEmpty(field))
        //        field = getFieldFromElement(selectElement);
        //}
        //private string getFieldFromElement(IHTMLElement element)
        //{
        //    IHTMLElement parent = element.parentElement;
        //    string field = "";
        //    while (parent != null)
        //    {
        //        if (parent.outerText != null)
        //        {
        //            int index = parent.outerText.IndexOf(element.outerText);
        //            if (index != -1)
        //                field = parent.outerText.Substring(0, index).Trim(_trimChar);
        //        }
        //        if (string.IsNullOrEmpty(field) == false)
        //            break;
        //        parent = parent.parentElement;
        //    }
        //    return field;
        //}
        public override void Save()
        {
            finishGroup();
            Office.Excel.ForwardExcelWriter file = _writer;
            _writer = new Office.Excel.ForwardExcelWriter(Path.GetTempFileName());
            _writer.Open();
            _sheet = _writer.CreateWorksheet() as Office.Excel.ForwardWriteWorksheet;
            writeExcelHeader();
            file.Save();
            string filename = file.FileName;

            file.Dispose();
            if (File.Exists("generated.xlsx"))
            {
                File.Delete("generated.xlsx");
            }
            File.Move(filename, "generated.xlsx");
        }
Exemplo n.º 5
0
        /// <summary>
        /// 生成树结构
        /// </summary>
        public void GenerateDir()
        {
            if (main == null)
            {
                main = Main_3C.GetMainWindow("", processId);
            }
            if (main.TreeView.GetCount() == 0)
            {
                return;
            }
            TreeValue root = main.GetTreeStructure();

            using (Office.Excel.ForwardExcelWriter writer = new Office.Excel.ForwardExcelWriter("目录字典.xlsx"))
            {
                writer.Open();
                Office.Excel.ForwardWriteWorksheet sheet = writer.CreateWorksheet() as Office.Excel.ForwardWriteWorksheet;
                sheet.WriteNextRow();
                sheet.WriteTextCell(1, writer.AddSharedString("Id"));
                sheet.WriteTextCell(2, writer.AddSharedString("目录名称"));
                sheet.WriteTextCell(3, writer.AddSharedString("父级目录Id"));
                WriteTreeDir(sheet, root);
            }
        }