// parameters: // strTaskID 任务 ID,用于管理和查询任务状态 // strParameters 附加的参数。可用于描述测试要求 void _doAction(FuncState func, string strText, string strTaskID, string strParameters) { if (string.IsNullOrEmpty(strText) == true) { MessageBox.Show(this, "请输入适当的条码号"); this.textBox_input.SelectAll(); this.textBox_input.Focus(); return; } // 如果中间(温和)停止过,则需要重新启动线程 if (this._taskList.Stopped == true) this._taskList.BeginThread(); #if NO if (this._summaryList.Stopped == true) this._summaryList.BeginThread(); #endif // m_webExternalHost_readerInfo.StopPrevious(); if ((this.UseIsbnBorrow == true && IsISBN(ref strText) == true) || strText.ToLower() == "?b") { string strItemBarcode = ""; string strError = ""; // return: // -1 error // 0 放弃 // 1 成功 int nRet = SelectOneItem(func, strText.ToLower() == "?b" ? "" : strText, out strItemBarcode, out strError); if (nRet == -1) { MessageBox.Show(this, "选择册记录的过程中出错: " + strError); this.textBox_input.SelectAll(); this.textBox_input.Focus(); return; } if (nRet == 0) { MessageBox.Show(this, "已取消选择册记录。注意操作并未执行"); this.textBox_input.SelectAll(); this.textBox_input.Focus(); return; } strText = strItemBarcode; } // 检查条码号,如果是读者证条码号,则 func = LoadPatronInfo if (this.NeedVerifyBarcode == true) { if (StringUtil.IsIdcardNumber(strText) == true || IsName(strText) == true) { WillLoadReaderInfo = true; } else if (func == dp2Circulation.FuncState.Read && string.IsNullOrEmpty(strText) == false && strText.ToLower().StartsWith("@bibliorecpath:") == true) { if (this.WillLoadReaderInfo == true) { // TODO: 语音提示 MessageBox.Show(this, "这里需要输入 证 条码号,而您输入的 '" + strText + "' 是一个 册 条码号。\r\n\r\n请重新输入"); this.textBox_input.SelectAll(); return; } } else { string strError = ""; // 形式校验条码号 // return: // -2 服务器没有配置校验方法,无法校验 // -1 error // 0 不是合法的条码号 // 1 是合法的读者证条码号 // 2 是合法的册条码号 int nRet = VerifyBarcode( this.MainForm.FocusLibraryCode, // this.Channel.LibraryCodeList, strText, out strError); if (nRet == -2) { MessageBox.Show(this, "服务器没有配置条码号验证脚本,无法使用验证条码号功能。请在前端参数配置对话框的“快捷出纳”属性页中清除“校验输入的条码号”事项"); this.textBox_input.SelectAll(); this.textBox_input.Focus(); return; } if (nRet == -1) { // TODO: 语音提示 // TODO: 红色对话框 MessageBox.Show(this, strError); this.textBox_input.SelectAll(); this.textBox_input.Focus(); return; } if (nRet == 0) { // TODO: 语音提示 // TODO: 红色对话框 MessageBox.Show(this, "'" + strText + "' 不是合法的条码号: " + strError); this.textBox_input.SelectAll(); this.textBox_input.Focus(); return; } // 有可能 验证条码号的时候因为 EnableControls 丢失了焦点 this.textBox_input.Focus(); if (nRet == 1) WillLoadReaderInfo = true; else { Debug.Assert(nRet == 2, ""); if (this.WillLoadReaderInfo == true) { // TODO: 语音提示 MessageBox.Show(this, "这里需要输入 证 条码号,而您输入的 '" + strText + "' 是一个 册 条码号。\r\n\r\n请重新输入"); this.textBox_input.SelectAll(); return; } } } } if (WillLoadReaderInfo == true) { func = FuncState.LoadPatronInfo; // _bLoadReaderInfo = false; } ChargingTask task = new ChargingTask(); task.ID = strTaskID; if (func == FuncState.LoadPatronInfo) { task.ReaderBarcode = strText; task.Action = "load_reader_info"; } else if (func == dp2Circulation.FuncState.Borrow) { task.ReaderBarcode = this._taskList.CurrentReaderBarcode; task.ItemBarcode = strText; task.Action = "borrow"; } else if (func == dp2Circulation.FuncState.ContinueBorrow) { if (string.IsNullOrEmpty(this._taskList.CurrentReaderBarcode) == true) { WillLoadReaderInfo = true; // 提示请输入读者证条码号 // TODO: 这里直接出现对话框搜集读者证条码号 MessageBox.Show(this, "请先输入读者证条码号,然后再输入册条码号"); this.textBox_input.SelectAll(); return; } task.ReaderBarcode = this._taskList.CurrentReaderBarcode; task.ItemBarcode = strText; task.Action = "borrow"; } else if (func == dp2Circulation.FuncState.Renew) { // task.ReaderBarcode = ""; task.ItemBarcode = strText; task.Action = "renew"; } else if (func == dp2Circulation.FuncState.VerifyRenew) { task.ReaderBarcode = this._taskList.CurrentReaderBarcode; task.ItemBarcode = strText; task.Action = "verify_renew"; } else if (func == dp2Circulation.FuncState.Return) { task.ItemBarcode = strText; task.Action = "return"; task.Parameters = strParameters; } else if (func == dp2Circulation.FuncState.InventoryBook) { task.ReaderBarcode = this.BatchNo; task.ItemBarcode = strText; task.Action = "inventory"; } else if (func == dp2Circulation.FuncState.VerifyReturn) { if (string.IsNullOrEmpty(this._taskList.CurrentReaderBarcode) == true) { WillLoadReaderInfo = true; // 提示请输入读者证条码号 // TODO: 这里直接出现对话框搜集读者证条码号 MessageBox.Show(this, "请先输入读者证条码号,然后再输入册条码号"); this.textBox_input.SelectAll(); return; } task.ReaderBarcode = this._taskList.CurrentReaderBarcode; task.ItemBarcode = strText; task.Action = "verify_return"; task.Parameters = strParameters; } else if (func == dp2Circulation.FuncState.Lost) { task.ItemBarcode = strText; task.Action = "lost"; task.Parameters = strParameters; } else if (func == dp2Circulation.FuncState.VerifyLost) { if (string.IsNullOrEmpty(this._taskList.CurrentReaderBarcode) == true) { WillLoadReaderInfo = true; // 提示请输入读者证条码号 MessageBox.Show(this, "请先输入读者证条码号,然后再输入册条码号"); this.textBox_input.SelectAll(); return; } task.ReaderBarcode = this._taskList.CurrentReaderBarcode; task.ItemBarcode = strText; task.Action = "verify_lost"; task.Parameters = strParameters; } else if (func == dp2Circulation.FuncState.Read) { if (string.IsNullOrEmpty(this._taskList.CurrentReaderBarcode) == true) { WillLoadReaderInfo = true; // 提示请输入读者证条码号 // TODO: 这里直接出现对话框搜集读者证条码号 MessageBox.Show(this, "请先输入读者证条码号,然后再输入册条码号"); this.textBox_input.SelectAll(); return; } task.ReaderBarcode = this._taskList.CurrentReaderBarcode; task.ItemBarcode = strText; task.Action = "read"; } this.textBox_input.SelectAll(); try { this._taskList.AddTask(task); } catch (LockException) { Delegate_DoAction d = new Delegate_DoAction(_doAction); this.BeginInvoke(d, new object[] { func, strText, strTaskID }); } }
// // /// <summary> /// 执行一个出纳动作。 /// 由于这是异步执行,不能立即返回操作结果,需要后面主动去查询 /// </summary> /// <param name="func">出纳功能</param> /// <param name="strText">字符串。可能是证条码号,也可能是册条码号</param> /// <param name="strTaskID">任务 ID,用于管理和查询任务状态</param> public void AsyncDoAction(FuncState func, string strText, string strTaskID = "", string strParameters = "") { Delegate_DoAction d = new Delegate_DoAction(_doAction); this.BeginInvoke(d, new object[] { func, strText, strTaskID, strParameters }); }