示例#1
0
        private void Dispose(bool p)
        {
            if (processAddr != IntPtr.Zero)
            {
                NativeApi.VirtualFreeEx(hProcess, processAddr, 4096, NativeApi.MEM_RELEASE);
                processAddr = IntPtr.Zero;
            }
            if (hProcess != IntPtr.Zero)
            {
                NativeApi.CloseHandle(hProcess);
                hProcess = IntPtr.Zero;
            }
            if (_asyncHandle != null)
            {
                _asyncHandle.Dispose();
                _asyncHandle = null;
            }
#if export
            if (writer != null)
            {
                writer.Dispose();
                writer = null;
                sheet  = null;
            }
#endif
        }
示例#2
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);
        }
示例#3
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();
 }
示例#4
0
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     if (_writer != null)
     {
         if (disposing)
         {
             _writer.Close();
         }
         else
         {
             _writer.Dispose();
         }
         _writer = null;
     }
 }
示例#5
0
        private Main_3C(IntPtr hwnd, string dataFile, uint processId)
        {
            DataFile       = dataFile;
            _handle        = hwnd;
            _selectedNode  = IntPtr.Zero;
            _keyRelation   = new List <KeyValuePair <string, object> >();
            _treeView      = null;
            this.processId = processId;
            hProcess       = NativeApi.OpenProcess(0x1FFFFF, false, this.processId);
            processAddr    = NativeApi.VirtualAllocEx(hProcess, IntPtr.Zero, 4096, NativeApi.MEM_COMMIT, NativeApi.PAGE_READWRITE);
            _asyncHandle   = new FillAsyncHandler();
            this.GetTreeView();
#if export
            sheet  = null;
            writer = null;
#endif
        }
示例#6
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();
        }
示例#7
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");
        }
示例#8
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);
            }
        }