public IList<HistoryInfo> GetHistoryFromTable(HtmlElement table) { IList<HistoryInfo> result = new List<HistoryInfo>(); if (table == null) { throw new ArgumentException(); } HtmlElementCollection rows = table.GetElementsByTagName("tr"); if (rows == null || rows.Count == 0) { return result; } ///The 1st row are columns' name for (int i = 1; i < rows.Count; i++) { HtmlElement currentRow = rows[i]; HistoryInfo item = GetItemFromRow(currentRow); if (item != null) result.Add(item); } return result; }
void SecondNavigation(object sender, WebBrowserDocumentCompletedEventArgs e) { string value = string.Empty; System.Windows.Forms.HtmlElement resultTable1 = ieBrowser.Document.GetElementById("nav-typeahead-wormhole"); System.Windows.Forms.HtmlElement resultTable = ieBrowser.Document.GetElementById("block-system-main"); if (resultTable != null) { HtmlElementCollection input1 = resultTable.GetElementsByTagName("DIV"); foreach (System.Windows.Forms.HtmlElement input2 in input1) { if (input2.GetAttribute("class") == "information") { System.Windows.Forms.HtmlElement mainelement = input2; } } } else { value = "Not Found"; } Details = value; this.resultEvent.Set(); }
private static void GetHtmlEntriesFromMobileHandelsbanken( HtmlElement kontoEntriesElement, SortedList kontoEntries, SortedList newKontoEntries) { var newBatchOfKontoEntriesAlreadyRed = EntryAdder.GetNewBatchOfKontoEntriesAlreadyRed(kontoEntries, newKontoEntries); foreach (HtmlElement htmlElement in kontoEntriesElement.GetElementsByTagName("LI")) { EntryAdder.AddNewEntryFromStringArray( GetMobileHandelsbankenTableRow(htmlElement), kontoEntries, newKontoEntries, newBatchOfKontoEntriesAlreadyRed); } }
void IEBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { HtmlDocument doc = ((WebBrowser)sender).Document; ieBrowser.DocumentCompleted -= IEBrowser_DocumentCompleted; System.Windows.Forms.HtmlElement search = ieBrowser.Document.GetElementById("results"); if (search != null) { HtmlElementCollection input1 = search.GetElementsByTagName("TD"); //input1[2].InvokeMember("click"); //ieBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(SecondNavigation); ieBrowser.Navigate("https://www.zaubacorp.com/company/VERINON%20TECHNOLOGY%20SOLUTIONS%20PRIVATE%20LIMITED/U72200TG2004FTC042623"); while (ieBrowser.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); } //ieBrowser.Navigate("https://www.google.com/"); ieBrowser.DocumentCompleted += IeBrowser_DocumentCompleted; //foreach (System.Windows.Forms.HtmlElement input2 in input1) //{ //} //search.SetAttribute("value", "VERINON TECHNOLOGY SOLUTIONS PRIVATE LIMITED"); //System.Windows.Forms.HtmlElement searchButton = ieBrowser.Document.GetElementById("edit-submit--3"); } //HtmlDocument doc = ((WebBrowser)sender).Document; //ieBrowser.DocumentCompleted -= IEBrowser_DocumentCompleted; //System.Windows.Forms.HtmlElement search = ieBrowser.Document.GetElementById("searchid"); //if (search != null) //{ // search.SetAttribute("value", "VERINON TECHNOLOGY SOLUTIONS PRIVATE LIMITED"); // System.Windows.Forms.HtmlElement searchButton = ieBrowser.Document.GetElementById("edit-submit--3"); // ieBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(SecondNavigation); // searchButton.InvokeMember("click"); //} }
public static IEnumerable<HtmlElement> GetHtmlElementsByAttr(HtmlElement parent_he, string attribute, string value = null, string tag = null) { HtmlElementCollection hec; if (tag == null) hec = parent_he.All; else hec = parent_he.GetElementsByTagName(tag); foreach (HtmlElement he in hec) { //if (he.InnerText!= null && he.InnerText.Contains('$')) //string className = ((mshtml.IHTMLElement)he.DomElement).className; string a = he.GetAttribute(attribute); if (a == null) continue; if (value == null || a == value) yield return he; } }
void IEBrowser_DocumentCompleted1(object sender, WebBrowserDocumentCompletedEventArgs e) { string value = string.Empty; System.Windows.Forms.HtmlElement resultTable = ieBrowser.Document.GetElementById("companyList"); if (resultTable != null) { HtmlElementCollection input1 = resultTable.GetElementsByTagName("TD"); foreach (System.Windows.Forms.HtmlElement input2 in input1) { value += input2.InnerText + "\n"; } } else { value = "Not Found"; } Details = value; this.resultEvent.Set(); }
private HtmlElement SearchDiv(HtmlElement el) { if (el == null) { return null; } if (el.GetAttribute("className") == "WarningMessage PhaseOut") { return el; } HtmlElementCollection elc = el.GetElementsByTagName("div"); if (elc != null) { foreach (HtmlElement e in elc) { HtmlElement r = SearchDiv(e); if (r != null) { return r; } } } return null; }
protected void UpdateUrlAbsolute(HtmlElement ele) { HtmlElementCollection eleColec = ele.GetElementsByTagName("IMG"); foreach (HtmlElement it in eleColec) { it.SetAttribute("src", it.GetAttribute("src")); } eleColec = ele.GetElementsByTagName("A"); foreach (HtmlElement it in eleColec) { it.SetAttribute("href", it.GetAttribute("href")); } if (ele.TagName == "A") { ele.SetAttribute("href", ele.GetAttribute("href")); } else if (ele.TagName == "IMG") { ele.SetAttribute("src", ele.GetAttribute("src")); } }
private static IViewObject GetIViewObjectElement(HtmlElement htmlElement) { HtmlElementCollection collection = htmlElement.GetElementsByTagName("embed"); Trace.Assert(collection.Count == 0 || collection.Count == 1, "More then one embed or object found: " + htmlElement.InnerHtml); if (collection.Count > 0) { IViewObject element = collection[0].DomElement as IViewObject; if (element != null) return element; } collection = htmlElement.GetElementsByTagName("object"); Trace.Assert(collection.Count == 0 || collection.Count == 1, "More then one embed or object found: " + htmlElement.InnerHtml); if (collection.Count > 0) { return collection[0].DomElement as IViewObject; } return null; }
private static void ParseFinancialDetails(StockSerie stockSerie, StockFinancial financial, HtmlElement table) { HtmlElementCollection tables = table.GetElementsByTagName(("table")); foreach (HtmlElement tbl in tables) { } }
private static List<HtmlElement> GetElements(HtmlElement hRoot, string strTagName, string strAttribName, string strAttribValue) { List<HtmlElement> l = new List<HtmlElement>(); if(hRoot == null) { Debug.Assert(false); return l; } if(string.IsNullOrEmpty(strTagName)) { Debug.Assert(false); return l; } foreach(HtmlElement hEl in hRoot.GetElementsByTagName(strTagName)) { if(!string.IsNullOrEmpty(strAttribName) && (strAttribValue != null)) { string strValue = XmlUtil.SafeAttribute(hEl, strAttribName); if(!strValue.Equals(strAttribValue, StrUtil.CaseIgnoreCmp)) continue; } l.Add(hEl); } return l; }
private void DragCorner(HtmlElement container) { HtmlElement handle = container.GetElementsByTagName("div")[0]; HtmlElement txtarea = container.GetElementsByTagName("textarea")[0]; HtmlElementEventHandler handler = (sender, args) => MoveListener(sender, (HtmlElementEventArgs)args, container, txtarea); /* Listen for 'mouse down' on handle to start the move listener */ handle.MouseDown += (mdSender, mdArgs) => { locationX = mdArgs.ClientMousePosition.X; locationY = mdArgs.ClientMousePosition.Y; /* Start listening for mouse move on body */ webBrowser1.Document.MouseMove += handler; }; /* Listen for 'mouse up' to cancel 'move' listener */ webBrowser1.Document.MouseUp += (sender, e) => { webBrowser1.Document.MouseMove -= handler; }; }
public static HtmlElement GetHtmlElementByFragment(HtmlElement parent, string tag, string fragment) { HtmlElementCollection hec; if (tag == null) hec = parent.All; else hec = parent.GetElementsByTagName(tag); foreach (HtmlElement he in hec) if (he.OuterHtml.Contains(fragment)) return he; return null; }
public static HtmlElement GetHtmlElementByAttr(HtmlElement parent, string tag, string attribute, string value) { HtmlElementCollection hec; if (tag == null) hec = parent.All; else hec = parent.GetElementsByTagName(tag); foreach (HtmlElement he in hec) //if (he.InnerText!= null && he.InnerText.Contains('$')) //string className = ((mshtml.IHTMLElement)he.DomElement).className; if (he.GetAttribute(attribute) == value) return he; return null; }
private static List<List<string>> getTableData(HtmlElement tbl) { List<List<string>> data = new List<List<string>>(); HtmlElementCollection rows = tbl.GetElementsByTagName("tr"); HtmlElementCollection cols; // = rows.GetElementsByTagName("th"); foreach (HtmlElement tr in rows) { List<string> row = new List<string>(); cols = tr.GetElementsByTagName("th"); foreach (HtmlElement td in cols) { row.Add(WebUtility.HtmlDecode(td.InnerText)); } cols = tr.GetElementsByTagName("td"); foreach (HtmlElement td in cols) { row.Add(WebUtility.HtmlDecode(td.InnerText)); } if (row.Count > 0) data.Add(row); } return data; }
public HistoryInfo GetItemFromRow(HtmlElement row) { HistoryInfo result = null; HtmlElementCollection cols = row.GetElementsByTagName("td"); if (cols == null || cols.Count != 7 || cols[6].InnerText != "已开奖") { return result; } string roundId = cols[0].InnerText; string time = cols[1].InnerText.Replace("\r\n", " "); HtmlElementCollection imgs = cols[2].GetElementsByTagName("img"); if (imgs == null || imgs.Count != 7) { return result; } //<img src="http://image.juxiangyou.com/speed28/num14o.gif"> string src = imgs[6].GetAttribute("src"); int num = -1; if (!string.IsNullOrEmpty(src)) { string numStr = src.Replace("http://image.juxiangyou.com/speed28/num", "").Replace("o.gif", ""); if (!string.IsNullOrEmpty(numStr)) { if (!int.TryParse(numStr, out num)) { throw new ArgumentException(); } } } HtmlElementCollection totalBeans = cols[3].GetElementsByTagName("span"); long totalAmount = 0; if (totalBeans != null && totalBeans.Count == 1) { string totalAmountStr = totalBeans[0].InnerText.Replace(",", ""); if (!string.IsNullOrEmpty(totalAmountStr)) { if (!long.TryParse(totalAmountStr, out totalAmount)) { throw new ArgumentException(); } } } int winner = 0; string winnerStr = cols[4].InnerText.Replace(",", ""); if (!string.IsNullOrEmpty(winnerStr)) { if (!int.TryParse(winnerStr, out winner)) { throw new ArgumentException(); } } long amount = 0, stake = 0; //<td bgcolor="#FFFFFF" class="a6"><span class="udcl">收:0</span><br><span class="da3">竞:0</span></td> HtmlElementCollection beans = cols[5].GetElementsByTagName("span"); if (beans != null && beans.Count == 2) { string winStr = beans[0].InnerText.Replace("收:", "").Replace(",", ""); if (!string.IsNullOrEmpty(winStr)) { if (!long.TryParse(winStr, out amount)) { throw new ArgumentException(); } } string staketr = beans[1].InnerText.Replace("竞:", "").Replace(",", ""); if (!string.IsNullOrEmpty(staketr)) { if (!long.TryParse(staketr, out stake)) { throw new ArgumentException(); } } } result = new HistoryInfo(); result.RoundId = roundId; result.Result = num; result.Stake = stake; result.TotalAmount = totalAmount; result.WinnerNum = winner; result.Amount = amount; result.Date = string.Format("{0}-{1}", DateTime.Now.Date.Year, time); return result; }
/// <summary> /// Finds the controls by class. /// </summary> /// <param name="parent">The parent control.</param> /// <param name="tagName">Name of the HTML tag.</param> /// <param name="className">Name of the class to find.</param> /// <returns>A List of HtmlElements containing controls with the specified class name.</returns> private List<HtmlElement> FindControlsByClass(HtmlElement parent, string tagName, string className) { List<HtmlElement> controlsWithMatchingClass = new List<HtmlElement>(); if (this.WebBrowser.Document != null) { HtmlElementCollection controlCollection = parent.GetElementsByTagName(tagName); foreach (HtmlElement element in controlCollection) { if (element.OuterHtml.ToUpper().Contains(className.ToUpper())) { controlsWithMatchingClass.Add(element); } } } return controlsWithMatchingClass; }
private static void ImportPriv(PwDatabase pd, HtmlElement hBody) { #if DEBUG bool bHasSpanCaptions = (GetElements(hBody, "SPAN", "class", "caption").Count > 0); #endif foreach(HtmlElement hTable in hBody.GetElementsByTagName("TABLE")) { Debug.Assert(XmlUtil.SafeAttribute(hTable, "width") == "100%"); string strRules = XmlUtil.SafeAttribute(hTable, "rules"); string strFrame = XmlUtil.SafeAttribute(hTable, "frame"); if(strRules.Equals("cols", StrUtil.CaseIgnoreCmp) && strFrame.Equals("void", StrUtil.CaseIgnoreCmp)) continue; PwEntry pe = new PwEntry(true, true); PwGroup pg = null; bool bNotesHeaderFound = false; foreach(HtmlElement hTr in hTable.GetElementsByTagName("TR")) { // 7.9.1.1+ List<HtmlElement> lCaption = GetElements(hTr, "SPAN", "class", "caption"); if(lCaption.Count == 0) lCaption = GetElements(hTr, "DIV", "class", "caption"); if(lCaption.Count > 0) { string strTitle = ParseTitle(XmlUtil.SafeInnerText( lCaption[0]), pd, out pg); ImportUtil.AppendToField(pe, PwDefs.TitleField, strTitle, pd); continue; // Data is in next TR } // 7.9.1.1+ if(hTr.GetElementsByTagName("TABLE").Count > 0) continue; HtmlElementCollection lTd = hTr.GetElementsByTagName("TD"); if(lTd.Count == 1) { HtmlElement e = lTd[0]; string strText = XmlUtil.SafeInnerText(e); string strClass = XmlUtil.SafeAttribute(e, "class"); if(strClass.Equals("caption", StrUtil.CaseIgnoreCmp)) { Debug.Assert(pg == null); strText = ParseTitle(strText, pd, out pg); ImportUtil.AppendToField(pe, PwDefs.TitleField, strText, pd); } else if(strClass.Equals("subcaption", StrUtil.CaseIgnoreCmp)) ImportUtil.AppendToField(pe, PwDefs.UrlField, ImportUtil.FixUrl(strText), pd); else if(strClass.Equals("field", StrUtil.CaseIgnoreCmp)) { // 7.9.2.5+ if(strText.EndsWith(":") && !bNotesHeaderFound) bNotesHeaderFound = true; else ImportUtil.AppendToField(pe, PwDefs.NotesField, strText.Trim(), pd, MessageService.NewLine, false); } else { Debug.Assert(false); } } else if((lTd.Count == 2) || (lTd.Count == 3)) { string strKey = XmlUtil.SafeInnerText(lTd[0]); string strValue = XmlUtil.SafeInnerText(lTd[lTd.Count - 1]); if(lTd.Count == 3) { Debug.Assert(string.IsNullOrEmpty(lTd[1].InnerText)); } if(strKey.EndsWith(":")) // 7.9.1.1+ strKey = strKey.Substring(0, strKey.Length - 1); if(strKey.Length > 0) ImportUtil.AppendToField(pe, MapKey(strKey), strValue, pd); else { Debug.Assert(false); } } else { Debug.Assert(false); } } if(pg != null) pg.AddEntry(pe, true); #if DEBUG else { Debug.Assert(bHasSpanCaptions); } #endif } }
/// <summary> /// Finds the control by value. /// </summary> /// <param name="parent">The parent control.</param> /// <param name="tagName">Name of the HTML tag</param> /// <param name="value">The value of the control to find.</param> /// <returns> /// An HtmlElement representing the control, or null if it was not found. /// </returns> private HtmlElement FindControlByValue(HtmlElement parent, string tagName, string value) { if (this.WebBrowser.Document != null) { HtmlElementCollection controlCollection = parent.GetElementsByTagName(tagName); foreach (HtmlElement element in controlCollection) { if (element.OuterHtml.Contains(value)) { return element; } } } return null; }
void startMoving() { DataTable dt = ds.Tables["Log"]; // 获取控件 getHtmlDoc().GetElementById("articleTitle").InnerText = dt.Rows[0]["Title"].ToString(); getHtmlDoc().GetElementById("SinaEditor_59_viewcodecheckbox").InvokeMember("click"); getHtmlDoc().All["SinaEditorTextarea"].InnerText = dt.Rows[0]["Content"].ToString() + "<br />" + dt.Rows[0]["LogDate"].ToString(); getHtmlDoc().GetElementById("SinaEditor_59_viewcodecheckbox").InvokeMember("click"); heCategory = getHtmlDoc().GetElementById("componentSelect"); foreach (HtmlElement heCategoryOption in heCategory.GetElementsByTagName("option")) { if (heCategoryOption.InnerText == dt.Rows[0]["Sort"].ToString()) heCategoryValue = heCategoryOption.GetAttribute("value"); } heCategory.SetAttribute("value", heCategoryValue); if (dt.Rows[0]["Tags"].ToString().Trim() != "") getHtmlDoc().GetElementById("articleTagInput").InnerText = dt.Rows[0]["Tags"].ToString(); ; //getHtmlDoc().GetElementById("input1").InvokeMember("click"); //getHtmlDoc().GetElementById("input2").InvokeMember("click"); getHtmlDoc().GetElementById("articlePostBtn").InvokeMember("click"); isCompleteForAddLog = true; }
/// <summary> /// Finds a control by name. /// </summary> /// <param name="parent">The parent control.</param> /// <param name="tagName">Name of the HTML tag.</param> /// <param name="name">The name of the control to find.</param> /// <returns> /// An HtmlElement representing the control, or null if it was not found. /// </returns> private HtmlElement FindControlByName(HtmlElement parent, string tagName, string name) { if (this.WebBrowser.Document != null) { HtmlElementCollection controlCollection = parent.GetElementsByTagName(tagName); foreach (HtmlElement element in controlCollection) { if (element.Name.Equals(name)) { return element; } } } return null; }
private void button1_Click(object sender, EventArgs e) { ///导出过程中导出键不可用 this.button1.Enabled = false; ///导出过程中暂停键可用 this.button2.Enabled = true; ///导出过程中统计键不可用 this.button3.Enabled = false; this.button4.Enabled = false; ExtractPlaying = true; try { string currentPath = Application.StartupPath; string dataFile = currentPath + "\\contacts.db"; bool isExist = File.Exists(dataFile); dataFile = "Data Source='" + dataFile + "'"; SQLiteConnection conn = new SQLiteConnection(dataFile + ";Pooling=true;FailIfMissing=false"); conn.Open(); var command = new SQLiteCommand(conn); if (!isExist) { command.CommandText = @"CREATE TABLE [PERSON] ( [ID] varchar NOT NULL PRIMARY KEY, [NAME] varchar, [DEPARTMENT] varchar, [MOBILE_PHONE] varchar, [VIRTUAL_PHONE] varchar, [POSITION] varchar, [REGION] varchar, [OFFICE_PHONE] varchar, [INNER_PHONE] varchar, [PY] varchar, [CAR] varchar )"; command.ExecuteNonQuery(); } document = webBrowser1.Document; formElement = document.GetElementById("form1"); form = (mshtml.HTMLFormElement)formElement.DomElement; deptElement = document.GetElementById("ddl_depart"); deptSelector = (mshtml.HTMLSelectElement)(deptElement.DomElement); personElement = document.GetElementById("ddl_person"); personSelector = (mshtml.HTMLSelectElement)(personElement.DomElement); btnElement = document.GetElementById("btn_Query"); btn = (mshtml.HTMLInputElement)(btnElement.DomElement); deptStringList = deptElement.OuterText.Split(new char[] { '—', ' ' }) .Where(p => p != string.Empty).Select(p => p.Trim()).ToList(); List<string> lastPersonStringList = new List<string>(); int currentDeptIndex = deptSelector.selectedIndex; for (int i = (currentDeptIndex == 0 ? currentDeptIndex : currentDeptIndex - 1); i < deptStringList.Count; i++) { bool IFailed = true; int IFailedCount = 0; while (IFailed && ExtractPlaying) { try { if (WinFormClose) { break; } bool LoadSuccess = true; deptElement = document.GetElementById("ddl_depart"); deptSelector = (mshtml.HTMLSelectElement)(deptElement.DomElement); formElement = document.GetElementById("form1"); form = (mshtml.HTMLFormElement)formElement.DomElement; deptSelector.selectedIndex = i + 1; deptSelector.FireEvent("onchange"); form.submit(); System.Threading.Thread.Sleep(500); Application.DoEvents(); personElement = document.GetElementById("ddl_person"); personSelector = (mshtml.HTMLSelectElement)(personElement.DomElement); var tempPersonStringList = personElement.OuterText.Split(new char[] { '—', ' ' }) .Where(p => p != string.Empty).Select(p => p.Trim()).ToList(); personStringList = new List<string>(); //get current dept persons for (int j = 0; j < tempPersonStringList.Count; j++) { if (j % 2 == 1) personStringList.Add(tempPersonStringList[j]); } if (lastPersonStringList.Count == personStringList.Count) { if (lastPersonStringList.Count > 0) { if (lastPersonStringList[0] == personStringList[0]) { LoadSuccess = false; } else { lastPersonStringList.Clear(); foreach (string oneName in personStringList) { lastPersonStringList.Add(oneName); } } } else { if (IFailedCount < 5) { LoadSuccess = false; IFailedCount++; } else if (lastPersonStringList.Count == 0) { IFailed = false; } } } else { lastPersonStringList.Clear(); foreach (string oneName in personStringList) { lastPersonStringList.Add(oneName); } } if (LoadSuccess) { int currentPersonIndex = personSelector.selectedIndex; for (int j = (currentPersonIndex == 0 ? currentPersonIndex : currentPersonIndex - 1); j < personStringList.Count; j++) { bool JFailed = true; int JFailedCount = 0; while (JFailed && ExtractPlaying) { try { personElement = document.GetElementById("ddl_person"); personSelector = (mshtml.HTMLSelectElement)(personElement.DomElement); personSelector.selectedIndex = j + 1; //personSelector.FireEvent("onchange"); //记录下拉框的工号,用于对比判断下面信息是否刷新 string CurrentSelectedID = personSelector.value; btnElement = document.GetElementById("btn_Query"); btn = (mshtml.HTMLInputElement)(btnElement.DomElement); btn.click(); System.Threading.Thread.Sleep(200); Application.DoEvents(); formElement = document.GetElementById("form1"); form = (mshtml.HTMLFormElement)formElement.DomElement; var tableElement = formElement.GetElementsByTagName("table")[1]; var table = (mshtml.HTMLTable)tableElement.DomElement; var cells = table.cells.Cast<mshtml.HTMLTableCell>().ToList(); string id = cells[1].innerText.Trim(); if (CurrentSelectedID == id) { string name = cells[3].innerText.Trim(); string dept = cells[5].innerText.Trim(); string mobile = cells[7].innerText.Trim(); string virt = cells[9].innerText.Trim(); string position = cells[11].innerText.Trim(); string region = cells[13].innerText.Trim(new char[] { '区', '号', ' ' }); string office = cells[14].innerText.Trim(new char[] { '电', '话', ' ' }); string inner = cells[15].innerText.Trim(new char[] { '分', '机', ' ' }); string car = cells[17].innerText.Trim(); command.CommandText = "select count(*) from [PERSON] where [ID]='" + id + "'"; var result = int.Parse(command.ExecuteScalar().ToString()); if (result == 0) { command.CommandText = string.Format(@"INSERT INTO [PERSON] ([ID] ,[NAME] ,[DEPARTMENT] ,[MOBILE_PHONE] ,[VIRTUAL_PHONE] ,[POSITION] ,[REGION] ,[OFFICE_PHONE] ,[INNER_PHONE] ,[PY] ,[CAR]) VALUES ('{0}' ,'{1}' ,'{2}' ,'{3}' ,'{4}' ,'{5}' ,'{6}' ,'{7}' ,'{8}' ,'{9}' ,'{10}')", id, name, dept, mobile, virt, position, region, office, inner, ConvertHZToPY.ToChineseSpell(name), car); command.ExecuteNonQuery(); } else if (result > 0) { command.CommandText = string.Format(@"UPDATE [PERSON] SET [ID] = '{0}' ,[NAME] = '{1}' ,[DEPARTMENT] ='{2}' ,[MOBILE_PHONE] = '{3}' ,[VIRTUAL_PHONE] ='{4}' ,[POSITION] = '{5}' ,[REGION] ='{6}' ,[OFFICE_PHONE] ='{7}' ,[INNER_PHONE] = '{8}' ,[PY]='{9}' ,[CAR]='{11}' WHERE [ID]='{10}'", id, name, dept, mobile, virt, position, region, office, inner, ConvertHZToPY.ToChineseSpell(name), id, car); command.ExecuteNonQuery(); } JFailed = false; } else { //如果下拉框和下面信息不一致,本次信息抓取失败,重新抓取 JFailed = true; JFailedCount++; } } catch (Exception ex) { Trace.TraceError(ex.Message); JFailedCount++; if (JFailedCount > 5) { System.Threading.Thread.Sleep(JFailedCount * 200); Application.DoEvents(); } } } } IFailed = false; } } catch (Exception ex) { Trace.TraceError(ex.Message); IFailedCount++; if (IFailedCount > 5) { System.Threading.Thread.Sleep(IFailedCount * 200); Application.DoEvents(); } } } } conn.Close(); } catch { MessageBox.Show("认证失败,请重新打开本软件"); } ///导出结束后导出键可用 this.button1.Enabled = true; ///导出结束后暂停键不可用 this.button2.Enabled = false; ///导出结束中统计键可用 this.button3.Enabled = true; this.button4.Enabled = true; ExtractPlaying = false; MessageBox.Show("导出结束!"); if (WinFormClose) { this.Close(); } }