int DoSearch(out string strError) { strError = ""; /* * string strServerName = ""; * * strServerName = this.textBox_serverName.Text; * * if (String.IsNullOrEmpty(strServerName) == true) * { * // 如果servername text为空,则从发起路径中获得servername * strServerName = GetServerName(this.RecordPath); * if (String.IsNullOrEmpty(strServerName) == true) * { * strError = "在没有指定服务器名的情况下,必须指定发起路径"; * return -1; * } * }*/ string strProjectName = ""; if (this.comboBox_projectName.Text == "" || this.comboBox_projectName.Text == "{default}" || this.comboBox_projectName.Text == "<default>" || this.comboBox_projectName.Text == "<默认>") { // 获得和一个来源路径相关的缺省查重方案 string strDatabasePath = ""; strProjectName = GetDefaultProjectName(this.RecordPath, out strDatabasePath); if (String.IsNullOrEmpty(strProjectName) == true) { strError = "没有定义和发起数据库 '" + strDatabasePath + "' 关联的缺省查重方案,因此无法进行查重..."; return(-1); } this.comboBox_projectName.Text = strProjectName; // 将实际用到的查重方案名显示出来 } else { strProjectName = this.comboBox_projectName.Text; } this.m_nodeProject = this.dom.DocumentElement.SelectSingleNode("//project[@name='" + strProjectName + "']"); if (this.m_nodeProject == null) { strError = "没有定义名字为 '" + strProjectName + "' 的查重方案"; return(-1); } stop.OnStop += new StopEventHandler(this.DoStop); stop.SetMessage("开始检索 ..."); stop.BeginLoop(); this.Update(); this.EnableControls(false); this.EventFinish.Reset(); this.m_bInSearch = true; try { this.ClearDupState(true); this.listView_browse.Items.Clear(); // 列出<project>元素下的所有<database>元素 XmlNodeList databases = this.m_nodeProject.SelectNodes("database"); for (int i = 0; i < databases.Count; i++) { XmlNode nodeDatabase = databases[i]; int nRet = DoOneDatabase( nodeDatabase, out strError); if (nRet == -1) { return(-1); } } // 排序 { ColumnSortStyle sortStyle = ColumnSortStyle.RightAlign; this.SortColumns.SetFirstColumn(1, sortStyle, this.listView_browse.Columns, true); this.SortColumns[0].Asc = false; // 大的在前 this.SortColumns.RefreshColumnDisplay(this.listView_browse.Columns); // 排序 this.listView_browse.ListViewItemSorter = new SortColumnsComparer(this.SortColumns); this.listView_browse.ListViewItemSorter = null; } // 显示查重状态 this.SetDupState(); } finally { this.EventFinish.Set(); this.m_bInSearch = false; stop.EndLoop(); stop.OnStop -= new StopEventHandler(this.DoStop); stop.Initial(""); EnableControls(true); } // 命中数 return(this.listView_browse.Items.Count); }
private void button_OK_Click(object sender, System.EventArgs e) { if (textBox_url.Text == "") { MessageBox.Show(this, "尚未指定服务器URL..."); return; } if (textBox_newPassword.Text != textBox_newPasswordConfirm.Text) { MessageBox.Show(this, "新密码和确认密码不一致,请重新输入..."); return; } if (textBox_userName.Text == "") { MessageBox.Show(this, "尚未输入用户名。"); return; } channel = Channels.GetChannel(textBox_url.Text); Debug.Assert(channel != null, "Channels.GetChannel 异常"); stop.OnStop += new StopEventHandler(this.DoStop); stop.Initial("正在修改密码..."); stop.BeginLoop(); int nRet; string strError; EnableControls(false); button_Cancel.Text = "中断"; nRet = channel.ChangePassword( textBox_userName.Text, textBox_oldPassword.Text, textBox_newPassword.Text, checkBox_manager.Checked, out strError); EnableControls(true); stop.EndLoop(); stop.OnStop -= new StopEventHandler(this.DoStop); stop.Initial(""); button_Cancel.Enabled = true; // 因为Cancel按钮还有退出对话框的功能 button_Cancel.Text = "取消"; if (nRet == -1) { goto ERROR1; } channel = null; MessageBox.Show(this, "密码修改成功。"); this.DialogResult = DialogResult.OK; this.Close(); return; ERROR1: button_Cancel.Enabled = true; button_Cancel.Text = "取消"; channel = null; MessageBox.Show(this, "修改密码失败,原因:" + strError); }