public override void Install(System.Collections.IDictionary stateSaver) { base.Install(stateSaver); string strParameter = this.Context.Parameters["rootdir"]; if (string.IsNullOrEmpty(strParameter) == true) { return; } #if NO string strRootDir = UnQuote(this.Context.Parameters["rootdir"]); InstanceDialog dlg = new InstanceDialog(); GuiUtil.AutoSetDefaultFont(dlg); dlg.SourceDir = strRootDir; dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(ForegroundWindow.Instance); if (dlg.DialogResult == DialogResult.Cancel) { throw new InstallException("用户取消安装。"); } if (dlg.Changed == true) { // 兑现修改 } #endif }
void channel_BeforeLogin(object sender, BeforeLoginEventArgs e) { if (e.FirstTry == true) { e.UserName = this.SupervisorUserName; e.Password = this.SupervisorPassword; e.Parameters = "location=#setup,type=worker,client=dp2OPAC|0.01"; // 2016/5/6 加上 0.01 部分 if (String.IsNullOrEmpty(e.UserName) == false) { return; // 立即返回, 以便作第一次 不出现 对话框的自动登录 } } // IWin32Window owner = null; if (sender is IWin32Window) { owner = (IWin32Window)sender; } else { owner = this; } CirculationLoginDlg dlg = new CirculationLoginDlg(); GuiUtil.AutoSetDefaultFont(dlg); // dlg.Text = ""; dlg.ServerUrl = this.textBox_dp2LibraryUrl.Text; dlg.Comment = e.ErrorInfo; dlg.UserName = e.UserName; dlg.SavePasswordShort = false; dlg.SavePasswordLong = false; dlg.Password = e.Password; dlg.IsReader = false; dlg.OperLocation = "#setup"; dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(owner); if (dlg.DialogResult == DialogResult.Cancel) { e.Cancel = true; return; } e.UserName = dlg.UserName; e.Password = dlg.Password; e.SavePasswordShort = dlg.SavePasswordShort; e.Parameters = "location=#setup,type=worker,client=dp2OPAC|0.01"; // 2016/5/6 加上 0.01 部分 e.SavePasswordLong = dlg.SavePasswordLong; e.LibraryServerUrl = dlg.ServerUrl; this.SupervisorUserName = e.UserName; this.SupervisorPassword = e.Password; }
public static DialogResult Show(IWin32Window owner, string strTitle, string strText, string strCheckBoxText, ref bool bCheckBox) { MessageDialog dlg = new MessageDialog(); GuiUtil.AutoSetDefaultFont(dlg); dlg.Text = strTitle; if (strCheckBoxText == null) { dlg.CheckBoxVisible = false; } else { dlg.CheckBoxText = strCheckBoxText; } dlg.MessageText = strText; dlg.CheckBoxValue = bCheckBox; dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(owner); bCheckBox = dlg.CheckBoxValue; return(dlg.DialogResult); }
public static DialogResult Show(IWin32Window owner, string strText, MessageBoxButtons buttons, MessageBoxDefaultButton defaultbutton, string strCheckBoxText, ref bool bCheckBox, string[] button_texts = null) { MessageDialog dlg = new MessageDialog(); GuiUtil.AutoSetDefaultFont(dlg); dlg.Text = ""; if (strCheckBoxText == null) { dlg.CheckBoxVisible = false; } else { dlg.CheckBoxText = strCheckBoxText; } dlg.MessageText = strText; dlg.CheckBoxValue = bCheckBox; dlg.StartPosition = FormStartPosition.CenterScreen; dlg.m_buttonDef = buttons; dlg.m_defautButton = defaultbutton; dlg.button_texts = button_texts; dlg.ShowDialog(owner); bCheckBox = dlg.CheckBoxValue; return(dlg.DialogResult); }
private void button_changeProjectName_Click(object sender, System.EventArgs e) { ProjectNameDlg dlg = new ProjectNameDlg(); GuiUtil.AutoSetDefaultFont(dlg); dlg.textBox_projectName.Text = textBox_projectName.Text; dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) { return; } if (dlg.textBox_projectName.Text == textBox_projectName.Text) { return; // 没有必要修改 } if (m_bNew == true) { textBox_projectName.Text = dlg.textBox_projectName.Text; return; } // 方案名 + 路径 ResultProjectNamePath = textBox_projectPathOfName.Text; if (ResultProjectNamePath != "") { ResultProjectNamePath += "/"; } ResultProjectNamePath += textBox_projectName.Text; string strError; int nRet = scriptManager.ChangeProjectData(ResultProjectNamePath, dlg.textBox_projectName.Text, null, out strError); if (nRet == -1) { MessageBox.Show(this, strError); } else { // 兑现显示遗留给对话框退出以后再做 // node.Text = dlg.textBox_projectName.Text; textBox_projectName.Text = dlg.textBox_projectName.Text; scriptManager.Save(); } }
private void button_getSqlServerName_Click(object sender, EventArgs e) { GetSqlServerDlg dlg = new GetSqlServerDlg(); GuiUtil.AutoSetDefaultFont(dlg); dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) { return; } this.textBox_sqlServerName.Text = dlg.SqlServerName; }
public override void Uninstall(System.Collections.IDictionary savedState) { // Debug.Assert(false, ""); base.Uninstall(savedState); string strParameter = this.Context.Parameters["rootdir"]; if (string.IsNullOrEmpty(strParameter) == true) { return; } #if NO String strRootDir = UnQuote(strParameter); DialogResult result; string strText = "是否完全卸载?\r\n\r\n" + "单击'是',则把全部实例的数据目录删除,所有的库配置信息丢失,所有的实例信息丢失。以后安装时需要重新安装数据目录和数据库。\r\n\r\n" + "单击'否',不删除数据目录,仅卸载执行程序,下次安装时可以继续使用已存在的库配置信息。升级安装前的卸载应选此项。"; result = MessageBox.Show(ForegroundWindow.Instance, strText, "卸载 dp2Library", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { InstanceDialog dlg = new InstanceDialog(); GuiUtil.AutoSetDefaultFont(dlg); dlg.Text = "彻底卸载所有实例和数据目录"; dlg.Comment = "下列实例将被全部卸载。请仔细确认。一旦卸载,全部数据目录和实例信息将被删除,并且无法恢复。"; dlg.UninstallMode = true; dlg.SourceDir = strRootDir; dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(ForegroundWindow.Instance); if (dlg.DialogResult == DialogResult.Cancel) { MessageBox.Show(ForegroundWindow.Instance, "已放弃卸载全部实例和数据目录。仅仅卸载了可执行程序。"); } } #endif }
private void button_editDp2LibraryDef_Click(object sender, EventArgs e) { InstallOpacParamDlg param_dlg = new InstallOpacParamDlg(); GuiUtil.AutoSetDefaultFont(param_dlg); if (this.LineInfo == null || (this.LineInfo.LibraryUrl == null && this.LineInfo.LibraryUserName == null && this.LineInfo.LibraryPassword == null) ) { param_dlg.ManageUserName = "******"; param_dlg.ManagePassword = ""; // dlg.Rights = "this:management;children_database:management;children_directory:management;children_leaf:management;descendant_directory:management;descendant_record:management;descendant_leaf:management"; } else { Debug.Assert(this.LineInfo != null, ""); param_dlg.Dp2LibraryUrl = this.LineInfo.LibraryUrl; param_dlg.ManageUserName = this.LineInfo.LibraryUserName; param_dlg.ManagePassword = this.LineInfo.LibraryPassword; param_dlg.LibraryReportDir = this.LineInfo.LibraryReportDir; } param_dlg.StartPosition = FormStartPosition.CenterScreen; param_dlg.ManageUserName = "******"; param_dlg.ShowDialog(this); if (param_dlg.DialogResult != System.Windows.Forms.DialogResult.OK) { return; } if (this.LineInfo == null) { this.LineInfo = new LineInfo(); } this.LineInfo.LibraryUrl = param_dlg.Dp2LibraryUrl; this.LineInfo.LibraryUserName = param_dlg.ManageUserName; this.LineInfo.LibraryPassword = param_dlg.ManagePassword; this.LineInfo.LibraryReportDir = param_dlg.LibraryReportDir; RefreshDp2LibraryInfo(); }
private void button_editMasterServer_Click(object sender, EventArgs e) { ConfirmSupervisorDialog dlg = new ConfirmSupervisorDialog(); GuiUtil.AutoSetDefaultFont(dlg); dlg.Text = "主服务器"; dlg.Comment = "请设置主服务器的地址和用户名"; dlg.ServerUrl = this.m_strUrl; dlg.UserName = this.m_strUserName; dlg.Password = this.m_strPassword; dlg.PhoneNumberVisible = false; dlg.ServerUrlReadOnly = false; dlg.StartPosition = FormStartPosition.CenterScreen; REDO_INPUT: dlg.ShowDialog(this); if (dlg.DialogResult == DialogResult.Cancel) { return; } if (string.IsNullOrEmpty(dlg.ServerUrl)) { MessageBox.Show(this, "尚未输入服务器 URL"); goto REDO_INPUT; } if (string.IsNullOrEmpty(dlg.UserName)) { MessageBox.Show(this, "尚未输入用户名"); goto REDO_INPUT; } if (dlg.ServerUrl != this.m_strUrl || dlg.UserName != this.m_strUserName || dlg.Password != this.m_strPassword) { this.m_strUrl = dlg.ServerUrl; this.m_strUserName = dlg.UserName; this.m_strPassword = dlg.Password; RefreshMasterServerSummary(); this.Changed = true; } }
private void button_editObjectRights_Click(object sender, EventArgs e) { DigitalPlatform.CommonControl.PropertyDlg dlg = new DigitalPlatform.CommonControl.PropertyDlg(); GuiUtil.AutoSetDefaultFont(dlg); dlg.StartPosition = FormStartPosition.CenterScreen; dlg.Text = "对象的权限"; dlg.PropertyString = this.textBox_objectRights.Text; dlg.CfgFileName = RightsCfgFileName; dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) { return; } this.textBox_objectRights.Text = dlg.PropertyString; }
private void button_editdp2KernelDef_Click(object sender, EventArgs e) { // string strError = ""; InstallLibraryParamDlg param_dlg = new InstallLibraryParamDlg(); GuiUtil.AutoSetDefaultFont(param_dlg); param_dlg.StartPosition = FormStartPosition.CenterScreen; if (this.LineInfo != null) { param_dlg.KernelUrl = this.LineInfo.KernelUrl; param_dlg.ManageUserName = this.LineInfo.KernelUserName; param_dlg.ManagePassword = this.LineInfo.KernelPassword; } else { // param_dlg.KernelUrl = this.LineInfo.KernelUrl; param_dlg.ManageUserName = "******"; // 不能叫 supervisor ,那样容易和dpLibrary层的supervisor用户名混淆 // param_dlg.ManagePassword = this.LineInfo.KernelPassword; } param_dlg.ShowDialog(this); if (param_dlg.DialogResult != DialogResult.OK) { return; } if (this.LineInfo == null) { this.LineInfo = new LineInfo(); } this.LineInfo.KernelUrl = param_dlg.KernelUrl; this.LineInfo.KernelUserName = param_dlg.ManageUserName; this.LineInfo.KernelPassword = param_dlg.ManagePassword; Refreshdp2KernelDef(); return; /* * ERROR1: * MessageBox.Show(this, strError); * return; * */ }
private void button_editSupervisorUserInfo_Click(object sender, EventArgs e) { CreateSupervisorDlg dlg = new CreateSupervisorDlg(); GuiUtil.AutoSetDefaultFont(dlg); if (this.LineInfo == null || (this.LineInfo.SupervisorUserName == null && this.LineInfo.SupervisorPassword == null && this.LineInfo.SupervisorRights == null) ) { dlg.UserName = "******"; dlg.Password = ""; // dlg.Rights = "this:management;children_database:management;children_directory:management;children_leaf:management;descendant_directory:management;descendant_record:management;descendant_leaf:management"; } else { Debug.Assert(this.LineInfo != null, ""); dlg.UserName = this.LineInfo.SupervisorUserName; dlg.Password = this.LineInfo.SupervisorPassword; dlg.Rights = this.LineInfo.SupervisorRights; } dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) { return; } if (this.LineInfo == null) { this.LineInfo = new LineInfo(); } this.LineInfo.SupervisorUserName = dlg.UserName; this.LineInfo.SupervisorPassword = dlg.Password; this.LineInfo.SupervisorRights = dlg.Rights; RefreshSupervisorUserInfo(); }
private void button_getSqlServerName_Click(object sender, EventArgs e) { GetSqlServerDlg dlg = new GetSqlServerDlg(); GuiUtil.AutoSetDefaultFont(dlg); dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) { return; } this.textBox_sqlServerName.Text = dlg.SqlServerName; #if NO if (string.IsNullOrEmpty(this.textBox_sqlServerName.Text) == false) { string strError = ""; int nRet = GetIntegratedSecurityOnlyMode(this.textBox_sqlServerName.Text, out strError); if (nRet == -1) { MessageBox.Show(this, strError); } else { if (nRet == 0) { this.groupBox_login.Enabled = true; } else { this.groupBox_login.Enabled = false; } } } #endif }
void channels_AskAccountInfo(object sender, AskAccountInfoEventArgs e) { e.Owner = this; LoginDlg dlg = new LoginDlg(); GuiUtil.AutoSetDefaultFont(dlg); dlg.textBox_serverAddr.Text = this.textBox_kernelUrl.Text; dlg.textBox_serverAddr.ReadOnly = true; dlg.textBox_comment.Text = e.Comment; dlg.textBox_userName.Text = this.ManagerUserName; dlg.textBox_password.Text = this.ManagerPassword; dlg.checkBox_savePassword.Checked = this.SavePassword; dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) { e.Result = 0; return; } this.ManagerPassword = dlg.textBox_userName.Text; if (dlg.checkBox_savePassword.Checked == true) { this.ManagerPassword = dlg.textBox_password.Text; } else { this.ManagerPassword = ""; } e.UserName = dlg.textBox_userName.Text; e.Password = dlg.textBox_password.Text; e.Result = 1; }
public override void Install(System.Collections.IDictionary savedState) { base.Install(savedState); string strParameter = this.Context.Parameters["rootdir"]; if (string.IsNullOrEmpty(strParameter) == true) { return; } #if OLD_MSI string strRootDir = UnQuote(this.Context.Parameters["rootdir"]); Debug.Assert(String.IsNullOrEmpty(strRootDir) == false, ""); // 可以提示,程序文件已经被刷新 InstanceDialog dlg = new InstanceDialog(); GuiUtil.AutoSetDefaultFont(dlg); dlg.SourceDir = strRootDir; dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(ForegroundWindow.Instance); if (dlg.DialogResult == DialogResult.Cancel) { throw new InstallException("用户取消安装。"); } if (dlg.Changed == true) { // 兑现修改 } // stateSaver["upgrade"] = bUpgrade; #endif }
private void button_editBindings_Click(object sender, EventArgs e) { string strError = ""; // 检查绑定内容是否适合利用对话框进行编辑 // return: // -1 出错 // 0 适合编辑 // 1 不适合编辑 int nRet = CheckBindingsEditable(out strError); if (nRet == -1) { goto ERROR1; } if (nRet == 1) { strError = "当前绑定内容因为 " + strError + " 而无法被专用对话框进行编辑,但可以直接在文本框中进行修改"; goto ERROR1; } // TODO: 要找到一个没有被使用过的tcp端口号 string strTail = this.InstanceName + (String.IsNullOrEmpty(this.InstanceName) == false ? "/" : ""); string[] default_urls = null; nRet = PrepareDefaultBindings(strTail, out default_urls, out strError); if (nRet == -1) { strError = "准备缺省班定值时发生错误: " + strError; goto ERROR1; } /* * string[] default_urls = new string[] { * "net.tcp://localhost:8002/dp2kernel/" + strTail, * "net.pipe://localhost/dp2kernel/" + strTail, * "http://localhost:8001/dp2kernel/" + strTail * }; * */ WcfBindingDlg dlg = new WcfBindingDlg(); GuiUtil.AutoSetDefaultFont(dlg); if (this.IsNew && String.IsNullOrEmpty(this.textBox_bindings.Text) == true) { dlg.Urls = default_urls; } else { dlg.Urls = this.textBox_bindings.Text.Replace("\r\n", ";").Split(new char[] { ';' }); } dlg.DefaultUrls = default_urls; dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) { return; } this.textBox_bindings.Text = string.Join("\r\n", dlg.Urls); return; ERROR1: MessageBox.Show(this, strError); return; }
// 出现对话框重新设置序列号 // return: // 0 Cancel // 1 OK public static int ResetSerialCode( IWin32Window owner, string strTitle, bool bAllowSetBlank, ref string strSerialCode, string strOriginCode) { Hashtable ext_table = StringUtil.ParseParameters(strOriginCode); string strMAC = (string)ext_table["mac"]; if (string.IsNullOrEmpty(strMAC) == true) { strOriginCode = "!error"; } else { strOriginCode = Cryptography.Encrypt(strOriginCode, CopyrightKey); } SerialCodeForm dlg = new SerialCodeForm(); GuiUtil.AutoSetDefaultFont(dlg); if (string.IsNullOrEmpty(strTitle) == false) { dlg.Text = strTitle; } // dlg.Font = this.Font; dlg.DefaultCodes = new List <string>(new string[] { "community|社区版" }); dlg.SerialCode = strSerialCode; dlg.StartPosition = FormStartPosition.CenterScreen; dlg.OriginCode = strOriginCode; REDO: dlg.ShowDialog(owner); if (dlg.DialogResult != DialogResult.OK) { return(0); } strSerialCode = dlg.SerialCode; if (string.IsNullOrEmpty(strSerialCode) == true) { if (bAllowSetBlank == true) { DialogResult result = MessageBox.Show(owner, "确实要将序列号设置为空?\r\n\r\n(一旦将序列号设置为空,dp2Library 将按照最多 5 个前端方式运行)", "dp2Library", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == System.Windows.Forms.DialogResult.No) { return(0); } } else { MessageBox.Show(owner, "序列号不允许为空。请重新设置"); goto REDO; } } return(1); }
public override void Install(System.Collections.IDictionary stateSaver) { base.Install(stateSaver); #if NO string strRootDir = UnQuote(this.Context.Parameters["rootdir"]); string strDataDir = ""; bool bWriteInstanceInfo = false; bool bUpgrade = false; // 是否为升级安装? 所谓升级安装就是发现数据目录已经存在了 int nRet = 0; string strError = ""; // ebug.Assert(false, ""); bool bDialogOpened = false; InstallParamDlg param_dlg = new InstallParamDlg(); GuiUtil.AutoSetDefaultFont(param_dlg); // 从XML文件中装载已有的信息到对话框 // return: // -1 error // 0 not load // 1 loaded LoadExistingInfoFromDp2zserverXmlFile( param_dlg, strRootDir, out strError); string strInstanceName = ""; string[] existing_urls = null; string strCertSN = ""; // 获得instance信息 // parameters: // urls 获得绑定的Urls // return: // false instance没有找到 // true 找到 bool bRet = InstallHelper.GetInstanceInfo("dp2ZServer", 0, out strInstanceName, out strDataDir, out existing_urls, out strCertSN); strDataDir = strRootDir; string strExistingXmlFile = PathUtil.MergePath(strRootDir, "unioncatalog.xml"); if (File.Exists(strExistingXmlFile) == false) { param_dlg.ShowDialog(ForegroundWindow.Instance); if (param_dlg.DialogResult == DialogResult.Cancel) { throw new Exception("安装被放弃"); } bDialogOpened = true; // 创建unioncatalog.xml文件 // return: // -1 error, install faild // 0 succeed // 1 suceed, but some config ignored nRet = WriteUnionCatalogXmlFile( param_dlg, strRootDir, out strError); if (nRet == -1) { throw new Exception(strError); } } else { bUpgrade = true; } END1: // if (existing_urls == null || existing_urls.Length == 0) { string[] default_urls = new string[] { //"net.tcp://localhost:7001/gcatserver/", //"net.pipe://localhost/gcatserver/", "http://localhost/unioncatalog/" }; List <string> urls = new List <string>(existing_urls == null ? new string[0] : existing_urls); if (urls.Count == 0) { urls.AddRange(default_urls); } WcfBindingDlg binding_dlg = new WcfBindingDlg(); GuiUtil.AutoSetDefaultFont(binding_dlg); binding_dlg.Text = "请指定 UnionCatalogServer 服务器的通讯协议"; binding_dlg.Urls = StringUtil.FromListString(urls); binding_dlg.DefaultUrls = default_urls; binding_dlg.NetPipeEnabled = false; binding_dlg.NetTcpEnabled = false; binding_dlg.HttpComment = "适用于Intranet和Internet"; binding_dlg.StartPosition = FormStartPosition.CenterScreen; REDO_BINDING: if (binding_dlg.ShowDialog(ForegroundWindow.Instance) != DialogResult.OK) { throw new Exception("用户取消安装。"); } existing_urls = binding_dlg.Urls; // 检查和其他产品的bindings是否冲突 // return: // -1 出错 // 0 不重 // 1 重复 nRet = InstallHelper.IsGlobalBindingDup(string.Join(";", existing_urls), "dp2ZServer", out strError); if (nRet != 0) { MessageBox.Show(ForegroundWindow.Instance, "协议绑定有问题: " + strError + "\r\n\r\n请重新指定协议绑定"); goto REDO_BINDING; } bWriteInstanceInfo = true; } if (bWriteInstanceInfo == true) { // 设置instance信息 InstallHelper.SetInstanceInfo( "dp2ZServer", 0, "", strDataDir, existing_urls, strCertSN); } strExistingXmlFile = PathUtil.MergePath(strRootDir, "dp2zserver.xml"); if (File.Exists(strExistingXmlFile) == false) { if (bDialogOpened == false) { param_dlg.ShowDialog(ForegroundWindow.Instance); if (param_dlg.DialogResult == DialogResult.Cancel) { throw new Exception("安装被放弃"); } bDialogOpened = true; } // 写入dp2zserver.xml文件 // return: // -1 error, install faild // 0 succeed nRet = WriteDp2zserverXmlFile( param_dlg, strRootDir, out strError); if (nRet == -1) { throw new Exception(strError); } } #endif }
// return: // -1 error // 0 canceled // 1 succeed public int GetNumber( Stop stop, System.Windows.Forms.IWin32Window parent, string strUrl, string strAuthor, bool bSelectPinyin, bool bSelectEntry, bool bOutputDebugInfo, BeforeLoginEventHandle e, out string strNumber, out string strDebugInfo, out string strError) { strError = ""; strDebugInfo = ""; Channel channel = this; // this.parent = parent; // channel.BeforeLogin -= new BeforeLoginEventHandle(channel_BeforeLogin); // channel.BeforeLogin += new BeforeLoginEventHandle(channel_BeforeLogin); channel.BeforeLogin -= e; channel.BeforeLogin += e; channel.Url = strUrl; strNumber = ""; int nRet = 0; try { channel.Clear(); } catch (Exception ex) { strError = ExceptionUtil.GetAutoText(ex); return(-1); } for (; ;) { // 这个函数具有catch 通讯中 exeption的能力 nRet = channel.GetNumber( stop, strAuthor, bSelectPinyin, bSelectEntry, bOutputDebugInfo, out strNumber, out strDebugInfo, out strError); if (nRet != -3) { break; } Debug.Assert(nRet == -3, ""); string strTitle = strError; string strQuestion = ""; nRet = channel.GetQuestion(out strQuestion, out strError); if (nRet != 1) { nRet = -1; break; } QuestionDlg dlg = new QuestionDlg(); GuiUtil.AutoSetDefaultFont(dlg); // 2015/5/28 dlg.StartPosition = FormStartPosition.CenterScreen; dlg.label_messageTitle.Text = strTitle; dlg.textBox_question.Text = strQuestion.Replace("\n", "\r\n"); dlg.ShowDialog(parent); if (dlg.DialogResult != DialogResult.OK) { nRet = 0; break; } nRet = channel.Answer(strQuestion, dlg.textBox_result.Text, out strError); if (nRet != 1) { nRet = -1; break; } } if (nRet == -1) { return(-1); } return(1); }
private void button_newInstance_Click(object sender, EventArgs e) { HideMessageTip(); OneInstanceDialog new_instance_dlg = new OneInstanceDialog(); GuiUtil.AutoSetDefaultFont(new_instance_dlg); new_instance_dlg.Text = "创建一个新实例"; new_instance_dlg.CreateMode = true; #if NO if (this.listView_instance.Items.Count == 0) { new_instance_dlg.InstanceName = "/dp2OPAC"; } else { new_instance_dlg.InstanceName = GetNewInstanceName(this.listView_instance.Items.Count + 1); } #endif new_instance_dlg.VerifyInstanceName += new VerifyEventHandler(new_instance_dlg_VerifyInstanceName); new_instance_dlg.VerifyDataDir += new VerifyEventHandler(new_instance_dlg_VerifyDataDir); new_instance_dlg.LoadXmlFileInfo += new LoadXmlFileInfoEventHandler(new_instance_dlg_LoadXmlFileInfo); new_instance_dlg.StartPosition = FormStartPosition.CenterScreen; if (new_instance_dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.Cancel) { return; } ListViewItem item = new ListViewItem(); ListViewUtil.ChangeItemText(item, COLUMN_SITE, new_instance_dlg.SiteName); ListViewUtil.ChangeItemText(item, COLUMN_VIRTUALDIR, new_instance_dlg.InstanceName); ListViewUtil.ChangeItemText(item, COLUMN_DATADIR, new_instance_dlg.DataDir); this.listView_instance.Items.Add(item); new_instance_dlg.LineInfo.Changed = true; item.Tag = new_instance_dlg.LineInfo; ListViewUtil.SelectLine(item, true); this.Changed = true; string strError = ""; // TODO: 最好出现一个浮动窗口显示正在创建实例 this._floatingMessage.Text = "正在创建实例,请稍候 ..."; this.Enabled = false; try { int nRet = CreateInstance(item, out strError); if (nRet == -1) { goto ERROR1; } } finally { this.Enabled = true; this._floatingMessage.Text = ""; } return; ERROR1: MessageBox.Show(this, strError); }
private void button_modifyInstance_Click(object sender, EventArgs e) { string strError = ""; HideMessageTip(); if (this.listView_instance.SelectedItems.Count == 0) { strError = "尚未选择要修改的事项"; goto ERROR1; } ListViewItem item = this.listView_instance.SelectedItems[0]; this.m_currentEditItem = item; OneInstanceDialog modify_instance_dlg = new OneInstanceDialog(); GuiUtil.AutoSetDefaultFont(modify_instance_dlg); modify_instance_dlg.Text = "修改一个实例"; modify_instance_dlg.CreateMode = false; modify_instance_dlg.SiteName = ListViewUtil.GetItemText(item, COLUMN_SITE); modify_instance_dlg.InstanceName = ListViewUtil.GetItemText(item, COLUMN_VIRTUALDIR); modify_instance_dlg.DataDir = ListViewUtil.GetItemText(item, COLUMN_DATADIR); modify_instance_dlg.LineInfo = (LineInfo)item.Tag; modify_instance_dlg.VerifyInstanceName += new VerifyEventHandler(modify_instance_dlg_VerifyInstanceName); modify_instance_dlg.VerifyDataDir += new VerifyEventHandler(modify_instance_dlg_VerifyDataDir); modify_instance_dlg.LoadXmlFileInfo += new LoadXmlFileInfoEventHandler(modify_instance_dlg_LoadXmlFileInfo); modify_instance_dlg.StartPosition = FormStartPosition.CenterScreen; if (modify_instance_dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.Cancel) { return; } ListViewUtil.ChangeItemText(item, COLUMN_SITE, modify_instance_dlg.SiteName); ListViewUtil.ChangeItemText(item, COLUMN_VIRTUALDIR, modify_instance_dlg.InstanceName); ListViewUtil.ChangeItemText(item, COLUMN_DATADIR, modify_instance_dlg.DataDir); modify_instance_dlg.LineInfo.Changed = true; item.Tag = modify_instance_dlg.LineInfo; ListViewUtil.SelectLine(item, true); this.Changed = true; // TODO: 最好出现一个浮动窗口显示正在创建实例 this.Enabled = false; try { int nRet = CreateInstance(item, out strError); if (nRet == -1) { goto ERROR1; } } finally { this.Enabled = true; } return; ERROR1: MessageBox.Show(this, strError); }
// 供脚本调用 // return: // -1 error // 0 canceled // 1 succeed public int GetNumber( System.Windows.Forms.IWin32Window parent, string strUrl, string strAuthor, bool bSelectPinyin, bool bSelectEntry, bool bOutputDebugInfo, BeforeLoginEventHandle e, out string strNumber, out string strDebugInfo, out string strError) { strError = ""; strDebugInfo = ""; Channel channel = this; // this.parent = parent; // channel.BeforeLogin -= new BeforeLoginEventHandle(channel_BeforeLogin); // channel.BeforeLogin += new BeforeLoginEventHandle(channel_BeforeLogin); channel.BeforeLogin -= e; channel.BeforeLogin += e; channel.Url = strUrl; strNumber = ""; int nRet = 0; channel.Clear(); for (;;) { // return: // -3 需要回答问题 // -2 尚未登录(info.UserID为空) // -1 出错 // 0 成功 nRet = channel.GetNumber(strAuthor, bSelectPinyin, bSelectEntry, bOutputDebugInfo, out strNumber, out strDebugInfo, out strError); if (nRet == 0) { return(1); } if (nRet == -2) { return(-1); } if (nRet != -3) { return(-1); //break; } Debug.Assert(nRet == -3, ""); string strTitle = strError; string strQuestion = ""; nRet = channel.GetQuestion(out strQuestion, out strError); if (nRet != 1) { return(-1); /* * nRet = -1; * break; * */ } QuestionDlg dlg = new QuestionDlg(); GuiUtil.AutoSetDefaultFont(dlg); // 2015/5/28 dlg.StartPosition = FormStartPosition.CenterScreen; dlg.label_messageTitle.Text = strTitle; dlg.textBox_question.Text = strQuestion.Replace("\n", "\r\n"); dlg.ShowDialog(parent); if (dlg.DialogResult != DialogResult.OK) { return(0); // 表示被放弃(放弃回答问题) /* * nRet = 0; * break; * */ } nRet = channel.Answer(strQuestion, dlg.textBox_result.Text, out strError); if (nRet != 1) { /* * nRet = -1; * break; * */ return(-1); } } /* * if (nRet == -1) * return -1; * * return 1; * */ }
private void GetNumber() { string strError = ""; _channel.ServerUrl = this.textBox_url.Text; #if DYNAMIC dynamic questions = null; #else List <Question> questions = new List <Question>(); #endif EnableControls(false); try { this.textBox_number.Text = ""; this.textBox_debugInfo.Text = ""; REDO: // result.Value: // -4 "著者 'xxx' 的整体或局部均未检索命中" 2017/3/1 // -3 需要回答问题 // -2 strID验证失败 // -1 出错 // 0 成功 var result = _channel.GetAuthorNumber( this.textBox_author.Text, this.checkBox_selectPinyin.Checked, this.checkBox_selectEntry.Checked, this.checkBox_outputDebugInfo.Checked, ref questions, out string number, out string debugInfo); if (result.Value == -1) { if (result.ErrorCode == #if DYNAMIC 6 #else ErrorCode.NotLogin #endif ) { // 调用 登录 API // 目前用 public 登录即可 var login_result = _channel.Login("public", "", "type=worker,client=GcatLite|1.0"); if (login_result.Value != 1) { strError = login_result.ErrorInfo; goto ERROR1; } goto REDO; } goto ERROR1; } // 需要前端回答问题 if (result.Value == -3) { // 把窗口翻动到前面 if (this.checkBox_clipboardChain.Checked) { TryBringToFront(); } string strTitle = strError; #if !DYNAMIC Debug.Assert(questions.Count > 0, ""); #endif string strQuestion = questions[questions.Count - 1].Text; QuestionDlg dlg = new QuestionDlg(); GuiUtil.AutoSetDefaultFont(dlg); dlg.StartPosition = FormStartPosition.CenterScreen; dlg.label_messageTitle.Text = strTitle; dlg.textBox_question.Text = strQuestion.Replace("\n", "\r\n"); dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) { strError = "放弃"; goto ERROR1; } // 为最后一个问题设置 Answer,然后重试取号 API questions[questions.Count - 1].Answer = dlg.textBox_result.Text; goto REDO; } this.textBox_number.Text = number; this.textBox_debugInfo.Text = debugInfo.Replace("\n", "\r\n"); // 自动复制到剪贴板 if (this.checkBox_copyResultToClipboard.Checked == true) { this.clipboardMonitor.Ignore = true; Clipboard.SetDataObject(number); this.clipboardMonitor.Ignore = false; } if (result.Value == -1) { this.textBox_author.SelectAll(); this.textBox_author.Focus(); } } catch (Exception ex) { MessageBox.Show(this, ex.Message); return; } finally { EnableControls(true); } return; ERROR1: MessageBox.Show(this, strError); }
// 获得著者号 // return: // -1 error // 0 canceled // 1 succeed public int GetGcatAuthorNumber(string strGcatWebServiceUrl, string strAuthor, out string strAuthorNumber, out string strError) { strError = ""; strAuthorNumber = ""; if (String.IsNullOrEmpty(strGcatWebServiceUrl) == true) { strGcatWebServiceUrl = "http://dp2003.com/dp2library/"; // "http://dp2003.com/gcatserver/" // "http://dp2003.com/dp2libraryws/gcat.asmx"; } #if OLD_CODE if (strGcatWebServiceUrl.IndexOf(".asmx") != -1) { if (this.GcatChannel == null) { this.GcatChannel = new DigitalPlatform.GcatClient.Channel(); } string strDebugInfo = ""; BeginGcatLoop("正在获取 '" + strAuthor + "' 的著者号,从 " + strGcatWebServiceUrl + " ..."); try { // return: // -1 error // 0 canceled // 1 succeed int nRet = this.GcatChannel.GetNumber( this.DetailForm.stop, this.DetailForm, strGcatWebServiceUrl, strAuthor, true, // bSelectPinyin true, // bSelectEntry true, // bOutputDebugInfo new DigitalPlatform.GcatClient.BeforeLoginEventHandle(gcat_channel_BeforeLogin), out strAuthorNumber, out strDebugInfo, out strError); if (nRet == -1) { strError = "取 著者 '" + strAuthor + "' 之号码时出错 : " + strError; return(-1); } return(nRet); } finally { EndGcatLoop(); } } else if (strGcatWebServiceUrl.Contains("gcat")) { // 新的WebService string strID = this.DetailForm.MainForm.AppInfo.GetString("DetailHost", "gcat_id", ""); bool bSaveID = this.DetailForm.MainForm.AppInfo.GetBoolean("DetailHost", "gcat_saveid", false); Hashtable question_table = (Hashtable)this.DetailForm.MainForm.ParamTable["question_table"]; if (question_table == null) { question_table = new Hashtable(); } REDO_GETNUMBER: string strDebugInfo = ""; BeginGcatLoop("正在获取 '" + strAuthor + "' 的著者号,从 " + strGcatWebServiceUrl + " ..."); try { // return: // -1 error // 0 canceled // 1 succeed int nRet = GcatNew.GetNumber( ref question_table, this.DetailForm.stop, this.DetailForm, strGcatWebServiceUrl, strID, // ID strAuthor, true, // bSelectPinyin true, // bSelectEntry true, // bOutputDebugInfo out strAuthorNumber, out strDebugInfo, out strError); if (nRet == -1) { strError = "取 著者 '" + strAuthor + "' 之号码时出错 : " + strError; return(-1); } if (nRet == -2) { IdLoginDialog login_dlg = new IdLoginDialog(); GuiUtil.AutoSetDefaultFont(login_dlg); login_dlg.Text = "获得著者号 -- " + ((string.IsNullOrEmpty(strID) == true) ? "请输入ID" : strError); login_dlg.ID = strID; login_dlg.SaveID = bSaveID; login_dlg.StartPosition = FormStartPosition.CenterScreen; if (login_dlg.ShowDialog(this.DetailForm) == DialogResult.Cancel) { return(-1); } strID = login_dlg.ID; bSaveID = login_dlg.SaveID; if (login_dlg.SaveID == true) { this.DetailForm.MainForm.AppInfo.SetString("DetailHost", "gcat_id", strID); } else { this.DetailForm.MainForm.AppInfo.SetString("DetailHost", "gcat_id", ""); } this.DetailForm.MainForm.AppInfo.SetBoolean("DetailHost", "gcat_saveid", bSaveID); goto REDO_GETNUMBER; } this.DetailForm.MainForm.ParamTable["question_table"] = question_table; return(nRet); } finally { EndGcatLoop(); } } else #endif // dp2library 服务器 { Hashtable question_table = (Hashtable)Program.MainForm.ParamTable["question_table"]; if (question_table == null) { question_table = new Hashtable(); } string strDebugInfo = ""; BeginGcatLoop("正在获取 '" + strAuthor + "' 的著者号,从 " + strGcatWebServiceUrl + " ..."); try { // return: // -1 error // 0 canceled // 1 succeed long nRet = GetAuthorNumber( ref question_table, this.DetailForm.stop, this.DetailForm, strGcatWebServiceUrl, strAuthor, true, // bSelectPinyin true, // bSelectEntry true, // bOutputDebugInfo out strAuthorNumber, out strDebugInfo, out strError); if (nRet == -1) { strError = "取 著者 '" + strAuthor + "' 之号码时出错 : " + strError; return(-1); } Program.MainForm.ParamTable["question_table"] = question_table; return((int)nRet); } finally { EndGcatLoop(); } } }
private void button_OK_Click(object sender, EventArgs e) { string strError = ""; int nRet = 0; if (this.textBox_sqlServerName.Text == "") { strError = "尚未指定 MySQL 服务器"; goto ERROR1; } if (string.Compare(this.textBox_sqlServerName.Text.Trim(), "~sqlite") == 0) { strError = "MySQL 服务器名不能为 '~sqlite',因为这个名字保留给了 SQLite 内置数据库类型"; goto ERROR1; } if (this.textBox_loginName.Text == "") { strError = "尚未指定 MySQL 用户名"; goto ERROR1; } if (this.textBox_loginPassword.Text != this.textBox_confirmLoginPassword.Text) { strError = "MySQL 帐户的密码和确认密码不一致"; goto ERROR1; } #if NO SaLoginDialog dlg = new SaLoginDialog(); GuiUtil.AutoSetDefaultFont(dlg); dlg.SqlServerName = this.textBox_sqlServerName.Text; dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) { return; } #endif #if NO // 创建dp2Kernel登录名 // 创建一个适合于dpKernel的SQL Server login // return: // -1 出错 // 0 成功 // 1 原来已经存在,且不允许删除 nRet = CreateLogin( this.SqlServerName, dlg.SqlUserName, dlg.SqlPassword, dlg.SSPI, this.textBox_loginName.Text, this.textBox_loginPassword.Text, out strError); if (nRet == -1 || nRet == 1) { goto ERROR1; } #endif this.button_OK.Enabled = false; try { nRet = VerifySqlServer( this.SqlServerName, this.textBox_loginName.Text, this.textBox_loginPassword.Text, false, out strError); if (nRet == -1) { DialogResult result = MessageBox.Show(this, "在检查服务器参数的过程中发生错误: \r\n\r\n" + strError + "\r\n\r\n是否依然采用这些参数继续完成安装?", "MySqlDataSourceDlg", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == System.Windows.Forms.DialogResult.No) { MessageBox.Show(this, "请修改服务器参数"); return; } } } finally { this.button_OK.Enabled = true; } this.DialogResult = DialogResult.OK; this.Close(); return; ERROR1: MessageBox.Show(this, strError); // MessageBox.Show(this, "虽然刚才的创建登录名操作失败了,但您也可以在重新指定登录名和密码后,再次按“确定”按钮创建登录名,继续进行安装"); }
// 获得 SQL Server 信息 // return: // -1 出错 // 0 放弃 // 1 成功 int GetSqlServerInfo( string strSqlServerName, out MsSqlServerInfo info, out string strError) { strError = ""; int nRet = 0; info = new MsSqlServerInfo(); REDO_INPUT: SaLoginDialog dlg = new SaLoginDialog(); GuiUtil.AutoSetDefaultFont(dlg); dlg.SqlServerName = strSqlServerName; dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) { return(0); } info.ServerName = strSqlServerName; info.SqlUserName = dlg.SqlUserName; info.SqlUserPassword = dlg.SqlPassword; info.SSPI = dlg.SSPI; string strConnection = @"Persist Security Info=False;" + "User ID=" + info.SqlUserName + ";" //帐户和密码 + "Password="******";" + "Data Source=" + strSqlServerName + ";" + "Connect Timeout=30"; if (info.SSPI == true) { strConnection = @"Persist Security Info=False;" + "Integrated Security=SSPI; " //信任连接 + "Data Source=" + strSqlServerName + ";" + "Connect Timeout=30"; // 30秒 } SqlConnection connection = null; try { connection = new SqlConnection(strConnection); } catch (Exception ex) { strError = "建立连接时出错:" + ex.Message + " 类型:" + ex.GetType().ToString(); return(-1); } try { connection.Open(); } catch (SqlException sqlEx) { strError = "连接SQL服务器出错:" + sqlEx.Message + "。"; int nError = sqlEx.ErrorCode; MessageBox.Show(this, strError); goto REDO_INPUT; return(-1); } catch (Exception ex) { strError = "连接SQL服务器出错:" + ex.Message + " 类型:" + ex.GetType().ToString(); return(-1); } /* http://support.microsoft.com/kb/321185 * 10 -- SQL Server 2008 * 9 -- SQL Server 2005 * 8 -- SQL 2000 * 7 -- SQL 7.0 * */ try { string strVersion = "7"; string strCommand = ""; SqlCommand command = null; // Debug.Assert(false, ""); strCommand = "SELECT SERVERPROPERTY('productversion')"; command = new SqlCommand(strCommand, connection); try { strVersion = (string)command.ExecuteScalar(); // 去掉次要版本号 nRet = strVersion.IndexOf("."); if (nRet != -1) { strVersion = strVersion.Substring(0, nRet); } } catch (Exception /*ex*/) { // strError = "执行命令 " + strCommand + " 出错:" + ex.Message + " 类型:" + ex.GetType().ToString(); // return -1; strVersion = "7"; } info.Version = strVersion; strCommand = "SELECT SERVERPROPERTY('IsIntegratedSecurityOnly')"; command = new SqlCommand(strCommand, connection); try { nRet = (Int32)command.ExecuteScalar(); } catch (Exception ex) { //strError = "执行命令 " + strCommand + " 出错:" + ex.Message + " 类型:" + ex.GetType().ToString(); //return -1; nRet = 1; } if (nRet == 1) { info.IntegratedSecurityOnlyMode = true; } else { info.IntegratedSecurityOnlyMode = false; } } finally { connection.Close(); } return(1); }
private void button_newFile_Click(object sender, System.EventArgs e) { FileNameDlg dlg = new FileNameDlg(); GuiUtil.AutoSetDefaultFont(dlg); dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) { return; } // 看看文件名是否重复创建 if (GetFileNameItemIndex(dlg.textBox_fileName.Text) != -1) { MessageBox.Show(this, "文件" + dlg.textBox_fileName.Text + "已经存在,不能重复创建..."); return; } string strFileName = textBox_projectLocate.Text + "\\" + dlg.textBox_fileName.Text; if (String.Compare(dlg.textBox_fileName.Text, "main.cs", true) == 0) { // ScriptManager.CreateDefaultMainCsFile(strFileName); scriptManager.OnCreateDefaultContent(strFileName); } else if (String.Compare(dlg.textBox_fileName.Text, "marcfilter.fltx", true) == 0) { // ScriptManager.CreateDefaultMarcFilterFile(strFileName); scriptManager.OnCreateDefaultContent(strFileName); } else if (String.Compare(dlg.textBox_fileName.Text, "references.xml", true) == 0) { // TODO: 应修改为事件驱动 ScriptManager.CreateDefaultReferenceXmlFile(strFileName); } else if (String.Compare(dlg.textBox_fileName.Text, "metadata.xml", true) == 0) { Debug.Assert(string.IsNullOrEmpty(this.HostName) == false, ""); // TODO: 应修改为事件驱动 ScriptManager.CreateDefaultMetadataXmlFile(strFileName, this.HostName); } else { using (StreamWriter sw = new StreamWriter(strFileName)) { sw.WriteLine(""); } } // 装入listview LoadFileInfo(); int nIndex = GetFileNameItemIndex(dlg.textBox_fileName.Text); if (nIndex != -1) { listView_files.SelectedItems.Clear(); listView_files.Items[nIndex].Selected = true; } }
// 获得 SQL Server 信息 // return: // -1 出错 // 0 放弃 // 1 成功 int GetSqlServerInfo( string strSqlServerName, out OracleSqlServerInfo info, out string strError) { strError = ""; int nRet = 0; info = new OracleSqlServerInfo(); SystemLoginDialog dlg = new SystemLoginDialog(); GuiUtil.AutoSetDefaultFont(dlg); dlg.SqlServerName = strSqlServerName; dlg.StartPosition = FormStartPosition.CenterScreen; REDO_INPUT: dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) { return(0); } info.ServerName = strSqlServerName; info.SqlUserName = dlg.SqlUserName; info.SqlUserPassword = dlg.SqlPassword; string strConnection = @"Persist Security Info=False;" + "User ID=" + info.SqlUserName + ";" //帐户和密码 + "Password="******";" + "Data Source=" + strSqlServerName + ";" + "Connect Timeout=30"; OracleConnection connection = null; try { connection = new OracleConnection(strConnection); } catch (Exception ex) { strError = "建立连接时出错:" + ex.Message + " 类型:" + ex.GetType().ToString(); return(-1); } try { connection.Open(); } catch (OracleException sqlEx) { // ex.Number == 12154 // ORA-12154: TNS: 无法解析指定的连接标识符 strError = "连接SQL服务器出错:" + sqlEx.Message + "。"; int nError = sqlEx.ErrorCode; MessageBox.Show(this, strError); dlg.Comment = "登录错误: " + strError + "\r\n请重新登录"; goto REDO_INPUT; return(-1); } catch (Exception ex) { strError = "连接SQL服务器出错:" + ex.Message + " 类型:" + ex.GetType().ToString(); return(-1); } try { string strCommand = ""; OracleCommand command = null; strCommand = "select username,default_tablespace from dba_users"; command = new OracleCommand(strCommand, connection); try { OracleDataReader reader = command.ExecuteReader(); while (reader.Read() == true) { DbaUser user = new DbaUser(); user.Name = reader.GetString(0); user.TableSpace = reader.GetString(1); info.DbaUsers.Add(user); } } catch (Exception ex) { strError = "执行命令 " + strCommand + " 出错:" + ex.Message + " 类型:" + ex.GetType().ToString(); return(-1); } } finally { connection.Close(); } return(1); }
// 外部调用 // 特殊版本,具有缓存问题和答案的功能 // return: // -2 strID验证失败 // -1 error // 0 canceled // 1 succeed public static int GetAuthorNumber( ref Hashtable question_table, Stop stop, System.Windows.Forms.IWin32Window parent, string strUrl, string strAuthor, bool bSelectPinyin, bool bSelectEntry, bool bOutputDebugInfo, out string strNumber, out string strDebugInfo, out string strError) { strError = ""; strDebugInfo = ""; strNumber = ""; long nRet = 0; Question[] questions = (Question[])question_table[strAuthor]; if (questions == null) { questions = new Question[0]; } for (; ;) { LibraryChannel channel = Program.MainForm.GetChannel(strUrl, "public"); try { // 这个函数具有catch 通讯中 exeption的能力 // return: // -3 需要回答问题 // -2 strID验证失败 // -1 出错 // 0 成功 nRet = channel.GetAuthorNumber( strAuthor, bSelectPinyin, bSelectEntry, bOutputDebugInfo, ref questions, out strNumber, out strDebugInfo, out strError); if (nRet != -3) { break; } Debug.Assert(nRet == -3, ""); } finally { Program.MainForm.ReturnChannel(channel); } string strTitle = strError; string strQuestion = questions[questions.Length - 1].Text; QuestionDlg dlg = new QuestionDlg(); GuiUtil.AutoSetDefaultFont(dlg); dlg.StartPosition = FormStartPosition.CenterScreen; dlg.MessageTitle = strTitle; dlg.Question = strQuestion.Replace("\n", "\r\n"); dlg.ShowDialog(parent); if (dlg.DialogResult != DialogResult.OK) { strError = "放弃"; return(0); } questions[questions.Length - 1].Answer = dlg.Question; question_table[strAuthor] = questions; // 保存 } if (nRet == -1) { return(-1); } if (nRet == -2) { return(-2); // strID验证失败 } return(1); }
private void button_changeProjectLocation_Click(object sender, System.EventArgs e) { DirNameDlg dlg = new DirNameDlg(); GuiUtil.AutoSetDefaultFont(dlg); DirectoryInfo di = new DirectoryInfo(textBox_projectLocate.Text); dlg.textBox_dirName.Text = di.Name; dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(this); if (dlg.DialogResult != DialogResult.OK) { return; } // 改名 string strNewLocation = di.Parent.FullName + "\\" + dlg.textBox_dirName.Text; if (di.Exists == true) { try { Directory.Move(textBox_projectLocate.Text, strNewLocation); } catch (IOException ex) { MessageBox.Show(this, ex.Message); return; } catch (Exception ex) { MessageBox.Show(this, ExceptionUtil.GetAutoText(ex)); return; } } // 方案名 + 路径 ResultProjectNamePath = textBox_projectPathOfName.Text; if (ResultProjectNamePath != "") { ResultProjectNamePath += "/"; } ResultProjectNamePath += textBox_projectName.Text; string strError; Debug.Assert(scriptManager != null, "调用本对话框以前,scriptManager指针应初始化..."); if (m_bNew == false) { int nRet = scriptManager.ChangeProjectData( ResultProjectNamePath, null, strNewLocation, out strError); if (nRet == -1) { MessageBox.Show(this, strError); return; } scriptManager.Save(); } textBox_projectLocate.Text = strNewLocation; // 重新装载文件名? LoadFileInfo(); }