private void button_finish_Click(object sender, EventArgs e) { string strError = ""; if (this.comboBox_server_serverType.Text == "[暂时不使用任何服务器]") { goto END1; } if (string.IsNullOrEmpty(this.textBox_server_dp2LibraryServerUrl.Text) == true) { strError = "请输入 dp2library 服务器 URL 地址"; goto ERROR1; } if (string.IsNullOrEmpty(this.textBox_server_userName.Text) == true) { strError = "请输入 用户名"; goto ERROR1; } int nRet = TestConnectServer(out strError); if (nRet == -1) { goto ERROR1; } if (this.comboBox_server_serverType.Text == "其它服务器" || string.IsNullOrEmpty(this.comboBox_server_serverType.Text) == true) { string strServerName = InputDlg.GetInput(this, "请给这个服务器取一个便于识别的名字", "[请给这个服务器取一个便于识别的名字]\r\n服务器名:", "新服务器", this.Font); if (strServerName != null) { // this.comboBox_server_serverType.Text = strServerName; this.ServerName = strServerName; } } END1: this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); return; ERROR1: MessageBox.Show(this, strError); }
void menu_newGroupName_Click(object sender, EventArgs e) { var name = InputDlg.GetInput(this, "添加群名", "群名", "", this.Font); if (name == null) { return; } AddNewRow(name, ""); }
// 重设价格 void menu_modifyPrice_Click(object sender, EventArgs e) { string strNewPrice = InputDlg.GetInput( this, "重设选定的事项的价格", "价格: ", "", this.Font); if (strNewPrice == null) { return; } foreach (ListViewItem item in this.listView_barcodes.SelectedItems) { // ListViewItem item = this.listView_barcodes.SelectedItems[i]; ListViewUtil.ChangeItemText(item, COLUMN_PRICE, strNewPrice); } }
private void MenuItem_readConfig_Click(object sender, EventArgs e) { string strError = ""; string strCfgNo = InputDlg.GetInput(this, "", "cfg_no", "0"); if (strCfgNo == null) { return; } if (uint.TryParse(strCfgNo, out uint cfg_no) == false) { strError = $"cfg_no '{strCfgNo}' 不合法"; goto ERROR1; } ReadConfigResult result = _driver.ReadConfig("*", cfg_no); MessageDlg.Show(this, $"cfg_no:{result.CfgNo}\r\nbytes:\r\n{Element.GetHexString(result.Bytes, "4")}", "config info"); return; ERROR1: MessageBox.Show(this, strError); }
private void button_add_Click(object sender, EventArgs e) { string result = InputDlg.GetInput(this, "添加普通号码", "号码:", "", this.Font); if (result == null) { return; } // 查重 if (this.listBox1.Items.IndexOf(result) == -1) { this.listBox1.Items.Add(result); this.listBox1.SelectedItem = result; } else { MessageBox.Show(this, $"号码 {result} 已经存在了"); } }
// 附加折扣 void menu_appendDiscount_Click(object sender, EventArgs e) { string strError = ""; string strDiscountPart = InputDlg.GetInput( this, "为已有的价格字符串附加折扣部分", "折扣: ", this.UsedDiscountString, this.Font); if (strDiscountPart == null) { return; } strDiscountPart = strDiscountPart.Trim(); if (string.IsNullOrEmpty(strDiscountPart) == true) { strError = "所输入的折扣部分为空,放弃处理"; goto ERROR1; } if (strDiscountPart[0] == '*') { strDiscountPart = strDiscountPart.Substring(1).Trim(); } if (string.IsNullOrEmpty(strDiscountPart) == true) { strError = "所输入的折扣部分的有效部分为空,放弃处理"; goto ERROR1; } this.UsedDiscountString = strDiscountPart; // 记忆 foreach (ListViewItem item in this.listView_barcodes.SelectedItems) { // ListViewItem item = this.listView_barcodes.SelectedItems[i]; string strOldPrice = ListViewUtil.GetItemText(item, COLUMN_PRICE); if (string.IsNullOrEmpty(strOldPrice) == true) { strError = "第 " + (this.listView_barcodes.Items.IndexOf(item) + 1).ToString() + " 个事项价格部分为空,无法附加折扣部分。操作中断"; goto ERROR1; } int nRet = strOldPrice.IndexOf("*"); if (nRet != -1) { strOldPrice = strOldPrice.Substring(0, nRet).Trim(); } strOldPrice += "*" + strDiscountPart; ListViewUtil.ChangeItemText(item, COLUMN_PRICE, strOldPrice); } return; ERROR1: MessageBox.Show(this, strError); }
void Add102() { string strError = ""; string strISBN = ""; int nRet = 0; strISBN = this.DetailForm.MarcEditor.Record.Fields.GetFirstSubfield("010", "a"); if (strISBN.Trim() == "") { strError = "记录中不存在010$a子字段,因此无法加102$a$b"; goto ERROR1; } // 切割出 出版社 代码部分 string strPublisherNumber = ""; nRet = this.DetailForm.MainForm.GetPublisherNumber(strISBN, out strPublisherNumber, out strError); if (nRet == -1) { goto ERROR1; } string strValue = ""; nRet = this.DetailForm.Get102Info(strPublisherNumber, out strValue, out strError); if (nRet == -1) { goto ERROR1; } if (nRet == 0 || strValue == "") { // 创建新条目 strValue = InputDlg.GetInput( this.DetailForm, null, "请输入ISBN出版社号码 '" + strISBN + "' 对应的UNIMARC 102$a$b参数(格式 国家代码[2位]:城市代码[6位]):", "国家代码[2位]:城市代码[6位]"); if (strValue == null) { return; // 放弃整个操作 } nRet = this.DetailForm.Set102Info(strPublisherNumber, strValue, out strError); if (nRet == -1) { goto ERROR1; } } // MessageBox.Show(this.DetailForm, strValue); // 把全角冒号替换为半角的形态 strValue = strValue.Replace(":", ":"); string strCountryCode = ""; string strCityCode = ""; nRet = strValue.IndexOf(":"); if (nRet == -1) { strCountryCode = strValue; if (strCountryCode.Length != 2) { strError = "国家代码 '" + strCountryCode + "' 应当为2字符"; goto ERROR1; } } else { strCountryCode = strValue.Substring(0, nRet); strCityCode = strValue.Substring(nRet + 1); if (strCountryCode.Length != 2) { strError = "冒号前面的国家代码部分 '" + strCountryCode + "' 应当为2字符"; goto ERROR1; } if (strCityCode.Length != 6) { strError = "冒号后面的城市代码部分 '" + strCityCode + "' 应当为6字符"; goto ERROR1; } } this.DetailForm.MarcEditor.Record.Fields.SetFirstSubfield("102", "a", strCountryCode); this.DetailForm.MarcEditor.Record.Fields.SetFirstSubfield("102", "b", strCityCode); return; ERROR1: MessageBox.Show(this.DetailForm, strError); }
// 维护210对照关系 // 2008/10/17 new add void Manage210() { string strError = ""; string strISBN = ""; int nRet = 0; strISBN = this.DetailForm.MarcEditor.Record.Fields.GetFirstSubfield("010", "a").Trim(); string strPublisherNumber = ""; if (String.IsNullOrEmpty(strISBN) == false) { // 切割出 出版社 代码部分 nRet = this.DetailForm.MainForm.GetPublisherNumber(strISBN, out strPublisherNumber, out strError); if (nRet == -1) { goto ERROR1; } } if (String.IsNullOrEmpty(strPublisherNumber) == true) { strPublisherNumber = "978-7-?"; } strPublisherNumber = InputDlg.GetInput( this.DetailForm, "维护210对照表 -- 第1步", "请输入ISBN中出版社号码部分:", strPublisherNumber); if (strPublisherNumber == null) { return; // 放弃整个操作 } string strValue = ""; nRet = this.DetailForm.GetPublisherInfo(strPublisherNumber, out strValue, out strError); if (nRet == -1) { goto ERROR1; } if (nRet == 0 || strValue == "") { strValue = "出版地:出版社名"; } // 创建新条目 strValue = InputDlg.GetInput( this.DetailForm, "维护210对照表 -- 第2步", "请输入ISBN出版社号码 '" + strPublisherNumber + "' 对应的UNIMARC 210$a$c参数(格式 出版地:出版社名):", strValue); if (strValue == null) { return; // 放弃整个操作 } if (strValue == "") { goto DOSAVE; } // MessageBox.Show(this.DetailForm, strValue); // 把全角冒号替换为半角的形态 strValue = strValue.Replace(":", ":"); string strName = ""; string strCity = ""; nRet = strValue.IndexOf(":"); if (nRet == -1) { strError = "输入的内容中缺少冒号"; goto ERROR1; // strName = strValue; } else { strCity = strValue.Substring(0, nRet); strName = strValue.Substring(nRet + 1); } strValue = strCity + ":" + strName; DOSAVE: nRet = this.DetailForm.SetPublisherInfo(strPublisherNumber, strValue, out strError); if (nRet == -1) { goto ERROR1; } return; ERROR1: MessageBox.Show(this.DetailForm, strError); }
// 加入出版地、出版者 void AddPublisher() { string strError = ""; string strISBN = ""; int nRet = 0; strISBN = this.DetailForm.MarcEditor.Record.Fields.GetFirstSubfield("010", "a"); if (strISBN.Trim() == "") { strError = "记录中不存在010$a子字段,因此无法加出版社子字段"; goto ERROR1; } // 切割出 出版社 代码部分 string strPublisherNumber = ""; nRet = this.DetailForm.MainForm.GetPublisherNumber(strISBN, out strPublisherNumber, out strError); if (nRet == -1) { goto ERROR1; } string strValue = ""; nRet = this.DetailForm.GetPublisherInfo(strPublisherNumber, out strValue, out strError); if (nRet == -1) { goto ERROR1; } if (nRet == 0 || strValue == "") { // 创建新条目 strValue = InputDlg.GetInput( this.DetailForm, null, "请输入ISBN出版社号 '" + strPublisherNumber + "' 对应的出版社名称(格式 出版地:出版社名):", "出版地:出版社名"); if (strValue == null) { return; // 放弃整个操作 } nRet = this.DetailForm.SetPublisherInfo(strPublisherNumber, strValue, out strError); if (nRet == -1) { goto ERROR1; } } // MessageBox.Show(this.DetailForm, strValue); // 把全角冒号替换为半角的形态 strValue = strValue.Replace(":", ":"); string strName = ""; string strCity = ""; nRet = strValue.IndexOf(":"); if (nRet == -1) { strName = strValue; } else { strCity = strValue.Substring(0, nRet); strName = strValue.Substring(nRet + 1); } this.DetailForm.MarcEditor.Record.Fields.SetFirstSubfield("210", "a", strCity); this.DetailForm.MarcEditor.Record.Fields.SetFirstSubfield("210", "c", strName); return; ERROR1: MessageBox.Show(this.DetailForm, strError); }
// 维护102对照关系 void Manage102() { string strError = ""; string strISBN = ""; int nRet = 0; strISBN = this.DetailForm.MarcEditor.Record.Fields.GetFirstSubfield("010", "a").Trim(); string strPublisherNumber = ""; if (String.IsNullOrEmpty(strISBN) == false) { // 切割出 出版社 代码部分 nRet = this.DetailForm.MainForm.GetPublisherNumber(strISBN, out strPublisherNumber, out strError); if (nRet == -1) { goto ERROR1; } } if (String.IsNullOrEmpty(strPublisherNumber) == true) { strPublisherNumber = "978-7-?"; } strPublisherNumber = InputDlg.GetInput( this.DetailForm, "维护102对照表 -- 第1步", "请输入ISBN中出版社号码部分:", strPublisherNumber); if (strPublisherNumber == null) { return; // 放弃整个操作 } string strValue = ""; nRet = this.DetailForm.Get102Info(strPublisherNumber, out strValue, out strError); if (nRet == -1) { goto ERROR1; } if (nRet == 0 || strValue == "") { strValue = "国家代码[2位]:城市代码[6位]"; } // 创建新条目 strValue = InputDlg.GetInput( this.DetailForm, "维护102对照表 -- 第2步", "请输入ISBN出版社号码 '" + strPublisherNumber + "' 对应的UNIMARC 102$a$b参数(格式国家代码[2位]:城市代码[6位]):", strValue); if (strValue == null) { return; // 放弃整个操作 } if (strValue == "") { goto DOSAVE; } // MessageBox.Show(this.DetailForm, strValue); // 把全角冒号替换为半角的形态 strValue = strValue.Replace(":", ":"); string strCountryCode = ""; string strCityCode = ""; nRet = strValue.IndexOf(":"); if (nRet == -1) { strCountryCode = strValue; if (strCountryCode.Length != 2) { strError = "国家代码 '" + strCountryCode + "' 应当为2字符"; goto ERROR1; } } else { strCountryCode = strValue.Substring(0, nRet); strCityCode = strValue.Substring(nRet + 1); if (strCountryCode.Length != 2) { strError = "冒号前面的国家代码部分 '" + strCountryCode + "' 应当为2字符"; goto ERROR1; } if (strCityCode.Length != 6) { strError = "冒号后面的城市代码部分 '" + strCityCode + "' 应当为6字符"; goto ERROR1; } } strValue = strCountryCode + ":" + strCityCode; DOSAVE: nRet = this.DetailForm.Set102Info(strPublisherNumber, strValue, out strError); if (nRet == -1) { goto ERROR1; } return; ERROR1: MessageBox.Show(this.DetailForm, strError); }
// 维护260对照关系 void Manage260() { string strError = ""; string strISBN = ""; int nRet = 0; strISBN = this.DetailForm.MarcEditor.Record.Fields.GetFirstSubfield("020", "a").Trim(); string strPublisherNumber = ""; if (String.IsNullOrEmpty(strISBN) == false) { // 切割出 出版社 代码部分 nRet = this.DetailForm.MainForm.GetPublisherNumber(strISBN, out strPublisherNumber, out strError); if (nRet == -1) { goto ERROR1; } } if (String.IsNullOrEmpty(strPublisherNumber) == true) { strPublisherNumber = "978-0-?"; } strPublisherNumber = InputDlg.GetInput( this.DetailForm, "维护260对照表 -- 第1步", "请输入ISBN中出版社号码部分:", strPublisherNumber, this.DetailForm.MainForm.DefaultFont); if (strPublisherNumber == null) { return; // 放弃整个操作 } string strValue = ""; nRet = this.DetailForm.GetPublisherInfo(strPublisherNumber, out strValue, out strError); if (nRet == -1) { goto ERROR1; } if (nRet == 0 || strValue == "") { // 获得现有的260字段 $a$b Field field_260 = this.DetailForm.MarcEditor.Record.Fields.GetOneField("260", 0); if (field_260 != null) { Subfield subfield_a = field_260.Subfields["a"]; Subfield subfield_b = field_260.Subfields["b"]; if (subfield_a != null && subfield_b != null && string.IsNullOrEmpty(subfield_a.Value) == false && string.IsNullOrEmpty(subfield_b.Value) == false) { strValue = FilterDocument.TrimEndChar(subfield_a.Value.Trim()).Trim() + ":" + FilterDocument.TrimEndChar(subfield_b.Value.Trim()).Trim(); } } if (string.IsNullOrEmpty(strValue) == true) { strValue = "出版地:出版社名"; } } // 创建新条目 strValue = InputDlg.GetInput( this.DetailForm, "维护260对照表 -- 第2步", "请输入ISBN出版社号码 '" + strPublisherNumber + "' 对应的 MARC21 260$a$c参数(格式 出版地:出版社名):", strValue, this.DetailForm.MainForm.DefaultFont); if (strValue == null) { return; // 放弃整个操作 } if (strValue == "") { goto DOSAVE; } // MessageBox.Show(this.DetailForm, strValue); // 把全角冒号替换为半角的形态 strValue = strValue.Replace(":", ":"); string strName = ""; string strCity = ""; nRet = strValue.IndexOf(":"); if (nRet == -1) { strError = "输入的内容中缺少冒号"; goto ERROR1; // strName = strValue; } else { strCity = strValue.Substring(0, nRet); strName = strValue.Substring(nRet + 1); } strValue = strCity + ":" + strName; DOSAVE: nRet = this.DetailForm.SetPublisherInfo(strPublisherNumber, strValue, out strError); if (nRet == -1) { goto ERROR1; } return; ERROR1: MessageBox.Show(this.DetailForm, strError); }
/* * 微信公众号新图书馆dp2mserver账号 * 命名:weixin_图书馆英文或中文简称(如weixin_cctb,weixin_tjsyzx) * 权限:getPatronInfo,searchBiblio,searchPatron,bindPatron,getBiblioInfo,getBiblioSummary,getItemInfo,circulation,getUserInfo,getRes * 义务:空 * 单位:图书馆名称 * 群组:gn:_lib_bb * gn:_lib_book * gn:_lib_homePage * * === * 新图书馆安装dp2capo时创建的dp2mserver账号 * 命名:capo_图书馆英文或中文简称(如capo_cctb,capo_tjsyzx) * 权限:空 * 义务:getPatronInfo,searchBiblio,searchPatron,bindPatron,getBiblioInfo,getBiblioSummary,getItemInfo,circulation,getUserInfo,getRes * 单位:图书馆名称 * 群组:gn:_patronNotify|-n * */ async Task <bool> CreateCapoUser() { string strError = ""; EnableControls(false); try { using (MessageConnectionCollection _channels = new MessageConnectionCollection()) { _channels.Login += _channels_LoginSupervisor; MessageConnection connection = await _channels.GetConnectionAsyncLite( this.textBox_url.Text, "supervisor"); // 记忆用过的超级用户名和密码 this.ManagerUserName = connection.UserName; this.ManagerPassword = connection.Password; CancellationToken cancel_token = _cancel.Token; string id = Guid.NewGuid().ToString(); string strDepartment = InputDlg.GetInput( this, "图书馆名", "请指定图书馆名: ", "", this.Font); if (strDepartment == null) { return(false); } bool bEanbleWebCall = false; this.Invoke(new Action(() => { DialogResult temp_result = MessageBox.Show(this, "是否允许 webCall (通过 dp2Router 访问 dp2library)?", "安装 dp2Capo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (temp_result == System.Windows.Forms.DialogResult.Yes) { bEanbleWebCall = true; } })); List <User> users = new List <User>(); User user = new User(); user.userName = this.textBox_userName.Text; user.password = this.textBox_password.Text; user.rights = ""; // TODO: 看看除了 weixin_xxx 以外是否还有其他请求者需要许可 user.duty = ":weixinclient|" + MakeWeixinUserName(this.textBox_userName.Text) + ",getPatronInfo,searchBiblio,searchPatron,bindPatron,getBiblioInfo,getBiblioSummary,getItemInfo,circulation,getUserInfo,getRes,getSystemParameter"; if (bEanbleWebCall) { user.duty += ",webCall:router"; } user.groups = new string[] { "gn:_patronNotify|-n" }; user.department = strDepartment; user.binding = "ip:[current]"; user.comment = "dp2Capo 专用账号"; users.Add(user); MessageResult result = await connection.SetUsersAsyncLite("create", users, new TimeSpan(0, 1, 0), cancel_token); if (result.Value == -1) { strError = "创建用户 '" + this.textBox_userName.Text + "' 时出错: " + result.ErrorInfo; goto ERROR1; } return(true); } } catch (MessageException ex) { if (ex.ErrorCode == "Unauthorized") { strError = "以用户名 '" + ex.UserName + "' 登录时, 用户名或密码不正确"; this.ManagerUserName = ""; this.ManagerPassword = ""; goto ERROR1; } if (ex.ErrorCode == "HttpRequestException") { strError = "dp2MServer URL 不正确,或 dp2MServer 尚未启动"; goto ERROR1; } strError = ex.Message; goto ERROR1; } catch (AggregateException ex) { strError = MessageConnection.GetExceptionText(ex); goto ERROR1; } catch (Exception ex) { strError = ex.Message; goto ERROR1; } finally { EnableControls(true); } ERROR1: this.Invoke(new Action(() => { MessageBox.Show(this, strError); })); return(false); }
async void MenuItem_modifyState_Click(object sender, EventArgs e) { string strError = ""; string new_state = InputDlg.GetInput(this, "修改状态", "新状态值", "dontsync", this.Font); if (new_state == null) { return; } try { SetInfoRequest request = new SetInfoRequest(); request.Operation = "setHistory"; request.Entities = new List <Entity>(); foreach (ListViewItem item in this.listView_records.SelectedItems) { RequestItem tag = item.Tag as RequestItem; tag.State = new_state; Record record = new Record { Data = JsonConvert.SerializeObject(tag) }; request.Entities.Add(new Entity { Action = "change:state", NewRecord = record }); } var connection = await ConnectionPool.GetConnectionAsync(this.comboBox_query_myAccount.Text); var result = await connection.SetInfoAsyncLite(this.comboBox_query_shelfAccount.Text, request, TimeSpan.FromSeconds(10), default); if (result.Value == -1) { strError = result.ErrorInfo; goto ERROR1; } // 报错 List <string> errors = new List <string>(); List <string> succeed_records = new List <string>(); if (result.Entities != null) { foreach (var entity in result.Entities) { if (string.IsNullOrEmpty(entity.ErrorInfo) == false) { errors.Add(entity.ErrorInfo); } else { succeed_records.Add(entity.NewRecord?.Data); } } } // 刷新成功修改了的行 foreach (var record in succeed_records) { if (string.IsNullOrEmpty(record)) { continue; } var item = JsonConvert.DeserializeObject <RequestItem>(record); RefreshLine(item.ID, item); } if (errors.Count > 0) { MessageDialog.Show(this, $"出错:\r\n{StringUtil.MakePathList(errors, "\r\n")}"); } return; } catch (Exception ex) { strError = ex.Message; goto ERROR1; } ERROR1: MessageBox.Show(this, strError); }