// 编辑配置文件 void menu_editCfgFile(object sender, System.EventArgs e) { string strError = ""; if (this.SelectedNode == null) { strError = "尚未选择要编辑的配置文件节点"; goto ERROR1; } if (this.SelectedNode.ImageIndex != RESTYPE_FILE) { strError = "所选择的节点不是配置文件类型。请选择要编辑的配置文件节点"; goto ERROR1; } string strPath = GetNodePath(this.SelectedNode); // 获得配置文件内容 ConfigInfo info = null; LibraryChannel channel = null; TimeSpan old_timeout = new TimeSpan(0); channel = this.CallGetChannel(true); old_timeout = channel.Timeout; channel.Timeout = new TimeSpan(0, 5, 0); try { int nRet = GetConfigFile( channel, strPath, out info, out strError); if (nRet == -1) goto ERROR1; // 编辑配置文件 KernelCfgFileDialog dlg = new KernelCfgFileDialog(); dlg.Font = GuiUtil.GetDefaultFont(); dlg.ActivePage = "content"; dlg.Content = info.Content; dlg.MIME = info.MIME; dlg.ServerUrl = channel.Url; dlg.Path = strPath; if (this.AppInfo != null) this.AppInfo.LinkFormState(dlg, "CfgFileEditDlg_state"); else dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(this); if (dlg.DialogResult == DialogResult.Cancel) return; info.Content = dlg.Content; info.MIME = dlg.MIME; nRet = SaveConfigFile(channel, strPath, info, out strError); if (nRet == -1) goto ERROR1; } finally { channel.Timeout = old_timeout; this.CallReturnChannel(channel, true); } return; ERROR1: MessageBox.Show(this, strError); }
// 编辑配置文件 void menu_editCfgFile(object sender, System.EventArgs e) { string strError = ""; if (this.SelectedNode == null) { strError = "尚未选择要编辑的配置文件节点"; goto ERROR1; } if (this.SelectedNode.ImageIndex != RESTYPE_FILE) { strError = "所选择的节点不是配置文件类型。请选择要编辑的配置文件节点"; goto ERROR1; } string strPath = GetNodePath(this.SelectedNode); // 获得配置文件内容 ConfigInfo info = null; LibraryChannel channel = null; TimeSpan old_timeout = new TimeSpan(0); channel = this.CallGetChannel(true); old_timeout = channel.Timeout; channel.Timeout = new TimeSpan(0, 5, 0); try { int nRet = GetConfigFile( channel, strPath, out info, out strError); if (nRet == -1) { goto ERROR1; } // 编辑配置文件 KernelCfgFileDialog dlg = new KernelCfgFileDialog(); dlg.Font = GuiUtil.GetDefaultFont(); dlg.ActivePage = "content"; dlg.Content = info.Content; dlg.MIME = info.MIME; dlg.ServerUrl = channel.Url; dlg.Path = strPath; if (this.AppInfo != null) { this.AppInfo.LinkFormState(dlg, "CfgFileEditDlg_state"); } else { dlg.StartPosition = FormStartPosition.CenterScreen; } dlg.ShowDialog(this); if (dlg.DialogResult == DialogResult.Cancel) { return; } info.Content = dlg.Content; info.MIME = dlg.MIME; nRet = SaveConfigFile(channel, strPath, info, out strError); if (nRet == -1) { goto ERROR1; } } finally { channel.Timeout = old_timeout; this.CallReturnChannel(channel, true); } return; ERROR1: MessageBox.Show(this, strError); }