Exemple #1
0
        /// <summary>
        /// 在 ListView 最后追加一行
        /// </summary>
        /// <param name="list">ListView 对象</param>
        /// <param name="strID">左边第一列内容</param>
        /// <param name="others">其余列内容</param>
        /// <returns>新创建的 ListViewItem 对象</returns>
        public static ListViewItem AppendNewLine(ListView list,
                                                 ReservationItem resItem)
        {
            ListViewItem viewItem = new ListViewItem(resItem.RecPath, 0);

            list.Items.Add(viewItem);

            /*
             * 路径
             * 读者证条码
             * 读者姓名
             */
            viewItem.SubItems.Add(resItem.PatronBarcode);
            viewItem.SubItems.Add(resItem.PatronName);

            /*
             * 册条码
             * 书名
             * 索取号
             * 馆藏地点
             * ISBN
             * 作者
             */
            viewItem.SubItems.Add(resItem.ItemBarcode);
            viewItem.SubItems.Add(resItem.Title);
            viewItem.SubItems.Add(resItem.AccessNo);
            viewItem.SubItems.Add(resItem.Location);
            viewItem.SubItems.Add(resItem.ISBN);
            viewItem.SubItems.Add(resItem.Author);

            /*
             * 读者电话
             * 读者部门
             * 预约时间
             * 到书时间
             * 预约状态
             */
            viewItem.SubItems.Add(resItem.PatronTel);
            viewItem.SubItems.Add(resItem.Department);
            viewItem.SubItems.Add(resItem.RequestTime);
            viewItem.SubItems.Add(resItem.NotifyTime);
            viewItem.SubItems.Add(resItem.State);

            if (resItem.State == C_State_outof)
            {
                viewItem.BackColor = Color.LightGray;
            }

            return(viewItem);
        }
Exemple #2
0
        /// <summary>
        /// 在 ListView 最后追加一行
        /// </summary>
        /// <param name="list">ListView 对象</param>
        /// <param name="strID">左边第一列内容</param>
        /// <param name="others">其余列内容</param>
        /// <returns>新创建的 ListViewItem 对象</returns>
        public ListViewItem AppendNewLine(ListView list,
                                          ReservationItem resItem)
        {
            ListViewItem viewItem = new ListViewItem(resItem.RecPath, 0);

            list.Items.Add(viewItem);

            /*
             * 路径
             * 备书结果
             * 读者证条码
             * 读者姓名
             */
            viewItem.SubItems.Add(this.GetCheckResultText(resItem.CheckResult));
            viewItem.SubItems.Add(resItem.NotFoundReason);
            viewItem.SubItems.Add(resItem.PatronBarcode);
            viewItem.SubItems.Add(resItem.PatronName);

            /*
             * 册条码
             * 书名
             * 索取号
             * 馆藏地点
             * ISBN
             * 作者
             */
            viewItem.SubItems.Add(resItem.ItemBarcode);
            viewItem.SubItems.Add(resItem.Title);
            viewItem.SubItems.Add(resItem.AccessNo);
            viewItem.SubItems.Add(resItem.Location);
            viewItem.SubItems.Add(resItem.ISBN);
            viewItem.SubItems.Add(resItem.Author);

            /*
             * 读者电话
             * 读者部门
             * 预约时间
             * 到书时间
             * 预约状态
             */
            viewItem.SubItems.Add(resItem.PatronTel);
            viewItem.SubItems.Add(resItem.Department);
            viewItem.SubItems.Add(resItem.RequestTime);
            viewItem.SubItems.Add(resItem.ArrivedTime);
            viewItem.SubItems.Add(resItem.State);



            return(viewItem);
        }
Exemple #3
0
        /// <summary>
        /// 检索做事的函数
        /// </summary>
        /// <param name="token"></param>
        private void doSearch(CancellationToken token,
                              string arrivedDbName,
                              string strQueryWord)
        {
            string strError = "";

            // 记下原来的光标
            Cursor oldCursor = Cursor.Current;

            // 用Invoke线程安全的方式来调
            this.Invoke((Action)(() =>
            {
                // 设置按钮状态
                EnableControls(false);

                //清空界面数据
                this.ClearInfo();

                // 鼠标设为等待状态
                oldCursor = this.Cursor;
                this.Cursor = Cursors.WaitCursor;
            }
                                 ));

            RestChannel channel = this._mainForm.GetChannel();

            try
            {
                string strFrom       = "读者证条码号"; // 检索途径
                string strMatchStyle = "exact";  //匹配方式
                // 如果检索词为空,则按__id检索出全部记录
                if (string.IsNullOrEmpty(strQueryWord))
                {
                    strFrom       = "__id";
                    strMatchStyle = "left";
                }

                // 拼装检索语句
                string strQueryXml = "<target list='" + arrivedDbName + ":" + strFrom + "'>" +
                                     "<item>" +
                                     "<word>" + strQueryWord + "</word>" +
                                     "<match>" + strMatchStyle + "</match>" +
                                     "<relation>=</relation>" +
                                     "<dataType>string</dataType>" +
                                     "</item>" +
                                     "<lang>zh</lang>" +
                                     "</target>";

                string         strOutputStyle = "";
                SearchResponse searchResponse = channel.Search(strQueryXml,
                                                               "arrived",
                                                               strOutputStyle);
                long lRet = searchResponse.SearchResult.Value;
                if (lRet == -1)
                {
                    strError = "检索发生错误:" + strError;
                    goto ERROR1;
                }
                if (lRet == 0)
                {
                    strError = "未命中";
                    goto ERROR1;
                }

                long todoCount   = 0; // 待做的
                long outofCount  = 0; // 超过保留期的
                long inNoteCount = 0; // 已创建到备书单的记录

                // 获取结果集记录
                long     lTotalCount   = lRet;
                long     lStart        = 0;
                long     lOnceCount    = lTotalCount;
                Record[] searchresults = null;
                while (token.IsCancellationRequested == false)
                {
                    lRet = channel.GetSearchResult("arrived",
                                                   lStart,
                                                   lOnceCount,
                                                   "id,xml",// cols,
                                                   "zh",
                                                   out searchresults,
                                                   out strError);
                    if (lRet == -1)
                    {
                        strError = "获得检索结果发生错误:" + strError;
                        goto ERROR1;
                    }
                    else if (lRet == 0)
                    {
                        strError = "获得0 条检索结果";
                        goto ERROR1;
                    }

                    // 处理每一条记录
                    int i = 0;
                    foreach (Record record in searchresults)
                    {
                        if (token.IsCancellationRequested == true)
                        {
                            break;
                        }

                        string strPath = record.Path;

                        // 2020/2/22 先检查一下这笔预约记录在本地库是否存在,
                        // 如果存在则表示是创建过备书单,不需要显示在这里了。
                        ReservationItem item = DbManager.Instance.GetItem(strPath);
                        if (item != null)
                        {
                            inNoteCount++;
                            this._mainForm.SetStatusMessage((lStart + i + 1).ToString() + " / " + lTotalCount);
                            continue;
                        }


                        // 把一条记录,解析成一个详细信息
                        // 注意此时不会保存临时信息,只有在创建预约单时才会在本地存储,因为中间可能读者会自己取消了预约,所以还是以实时查询出来的准
                        int nRet = GetDetailInfo(channel,
                                                 strPath,
                                                 record.RecordBody.Xml,
                                                 out item,
                                                 out strError);
                        if (nRet == -1)
                        {
                            goto ERROR1;
                        }

                        this.Invoke((Action)(() =>
                        {
                            // 状态为outof加到超过保存期时,注意有两种情况:一种是确实超过保留期的,一种是读者取消预约的情况。
                            if (item.State == C_State_outof)
                            {
                                // 增加一行到超过保留期的
                                AppendNewLine(this.listView_outof, item);

                                outofCount++;
                            }
                            else
                            {
                                // 增加一行到预约到书
                                AppendNewLine(this.listView_results, item);

                                // 为预约到书记录建立hashtable,方便后面保留到本地库。因为listviewitem的信息不全。
                                // 未处理的预约记录一般量不太大,放在内存hashtable应该可以的。
                                this.ItemHt[strPath] = item;

                                // 方便决定后面是否自动排序
                                todoCount++;
                            }

                            this._mainForm.SetStatusMessage((lStart + i + 1).ToString() + " / " + lTotalCount);

                            // 数量加1
                            i++;
                        }));
                    }

                    lStart += searchresults.Length;
                    if (lStart >= lTotalCount)
                    {
                        break;
                    }
                }
                this.Invoke((Action)(() =>
                {
                    if (todoCount > 0)
                    {
                        // 按证条码号排序
                        this.SortCol(1);
                    }
                    // 任务栏显示信息
                    this._mainForm.SetStatusMessage("命中总数'" + lTotalCount + "'条,"
                                                    + "其中预约到书'" + todoCount + "'条,"
                                                    + "超过保留期或读者自己取消'" + outofCount + "'条,"
                                                    + "已创建到备书单'" + inNoteCount + "'条。");
                }));
                return;
            }
            catch (Exception ex)
            {
                strError = ex.Message;
                goto ERROR1;
            }
            finally
            {
                // 设置按置状态
                this.Invoke((Action)(() =>
                {
                    EnableControls(true);
                    this.Cursor = oldCursor;

                    this._mainForm.ReturnChannel(channel);
                }
                                     ));
            }

ERROR1:
            this.Invoke((Action)(() =>
            {
                MessageBox.Show(strError);
            }
                                 ));
        }
Exemple #4
0
        /// <summary>
        /// 制作备书单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripMenuItem_bs_Click(object sender, EventArgs e)
        {
            if (this.listView_results.SelectedItems.Count == 0)
            {
                MessageBox.Show(this, "尚未选择预约到书记录。");
                return;
            }


            // 按读者拆分,每个读者一个备书单
            Hashtable patronTable = new Hashtable();

            foreach (ListViewItem viewItem in this.listView_results.SelectedItems)
            {
                string path          = viewItem.SubItems[0].Text;
                string patronBarcode = viewItem.SubItems[1].Text;
                string patronName    = viewItem.SubItems[2].Text;

                string fullName = patronName + "(" + patronBarcode + ")";
                // 检查是否已在hashtable
                if (patronTable.ContainsKey(fullName) == true)
                {
                    List <ListViewItem> items = (List <ListViewItem>)patronTable[fullName];
                    items.Add(viewItem);
                }
                else
                {
                    List <ListViewItem> items = new List <ListViewItem>();
                    items.Add(viewItem);
                    patronTable[fullName] = items;
                }
            }

            // 每个姓名创建一个备书单
            //遍历方法一:遍历哈希表中的键
            foreach (string patronName in patronTable.Keys)
            {
                string patronTel             = "";
                List <ReservationItem> items = new List <ReservationItem>();


                List <ListViewItem> viewItems = (List <ListViewItem>)patronTable[patronName];
                foreach (ListViewItem viewItem in viewItems)
                {
                    string path = viewItem.SubItems[0].Text;

                    // 从hashtable中找到对应的resItem
                    ReservationItem resItem = (ReservationItem)this.ItemHt[path];
                    items.Add(resItem);


                    // 从预约到书列表中删除
                    this.listView_results.Items.Remove(viewItem);
                }

                // 存储到本地备书单库
                DbManager.Instance.AddNote(patronName, items);
            }

            MessageBox.Show(this, "创建备书单完成,请到'备书单管理'界面查看。");

            this._mainForm.EnsureChildForm <NoteForm>(true);

            return;
        }
Exemple #5
0
        /// <summary>
        /// 获取记录详细信息
        /// </summary>
        /// <param name="channel"></param>
        /// <param name="strRecord"></param>
        /// <param name="cols"></param>
        /// <param name="strError"></param>
        /// <returns></returns>
        int GetDetailInfo(RestChannel channel,
                          string recPath,
                          string strRecordXml,
                          out ReservationItem reserItem,
                          out string strError)
        {
            strError = "";

            reserItem         = new ReservationItem();
            reserItem.RecPath = recPath;

            XmlDocument dom = new XmlDocument();

            dom.LoadXml(strRecordXml);
            XmlNode nodeRoot = dom.DocumentElement;

            reserItem.RecPath       = recPath;
            reserItem.State         = DomUtil.GetElementText(nodeRoot, "state");
            reserItem.ItemBarcode   = DomUtil.GetElementText(nodeRoot, "itemBarcode");
            reserItem.ItemRefID     = DomUtil.GetElementText(nodeRoot, "itemRefID");
            reserItem.PatronBarcode = DomUtil.GetElementText(nodeRoot, "readerBarcode");
            reserItem.LibraryCode   = DomUtil.GetElementText(nodeRoot, "libraryCode");
            reserItem.OnShelf       = DomUtil.GetElementText(nodeRoot, "onShelf");
            reserItem.NotifyTime    = DateTimeUtil.ToLocalTime(DomUtil.GetElementText(nodeRoot, "notifyDate"), "yyyy-MM-dd HH:mm:ss");
            reserItem.Location      = DomUtil.GetElementText(nodeRoot, "location");
            reserItem.AccessNo      = DomUtil.GetElementText(nodeRoot, "accessNo");

            // 以下字段为图书信息
            reserItem.ISBN   = "";
            reserItem.Title  = "";
            reserItem.Author = "";

            // 以下字段是读者信息
            reserItem.PatronName  = "";
            reserItem.Department  = "";
            reserItem.PatronTel   = "";
            reserItem.RequestTime = "";
            reserItem.ArrivedTime = "";

            // 备书产生的字段
            reserItem.PrintState  = DomUtil.GetElementText(nodeRoot, "printState");
            reserItem.CheckResult = "";// 是否找到图书,值为:找到/未找到

            // 过了保留期的数据,不再获取详细数据
            if (reserItem.State == C_State_outof)
            {
                strError = "因为过了保留期,不必再获取详细数据了。";
                return(0);
            }

            // 获取册信息以及书目信息
            if (!string.IsNullOrEmpty(reserItem.ItemBarcode))
            {
                GetItemInfoResponse response = channel.GetItemInfo(reserItem.ItemBarcode,
                                                                   "xml",
                                                                   "xml");
                if (response.GetItemInfoResult.Value == -1)
                {
                    strError = "获取册记录'" + reserItem.ItemBarcode + "'出错:" + response.GetItemInfoResult.ErrorInfo;
                    return(-1);
                }
                if (response.GetItemInfoResult.Value == 0)
                {
                    strError = "获取册记录'" + reserItem.ItemBarcode + "未命中";
                    return(-1);
                }

                string strOutMarcSyntax = "";
                string strMARC          = "";
                string strMarcXml       = response.strBiblio;
                int    nRet             = MarcUtil.Xml2Marc(strMarcXml,
                                                            false,
                                                            "", // 自动识别 MARC 格式
                                                            out strOutMarcSyntax,
                                                            out strMARC,
                                                            out strError);
                if (nRet == -1)
                {
                    return(-1);
                }

                MarcRecord marcRecord = new MarcRecord(strMARC);
                reserItem.ISBN   = marcRecord.select("field[@name='010']/subfield[@name='a']").FirstContent;
                reserItem.Title  = marcRecord.select("field[@name='200']/subfield[@name='a']").FirstContent;
                reserItem.Author = marcRecord.select("field[@name='200']/subfield[@name='f']").FirstContent;
            }

            // 获取读者信息
            if (string.IsNullOrEmpty(reserItem.PatronBarcode) == false)
            {
                GetReaderInfoResponse readerRet = channel.GetReaderInfo(reserItem.PatronBarcode,
                                                                        "xml:noborrowhistory");
                if (readerRet.GetReaderInfoResult.Value == -1)
                {
                    strError = "获取册记录'" + reserItem.ItemBarcode + "'出错:" + readerRet.GetReaderInfoResult.ErrorInfo;
                    return(-1);
                }
                if (readerRet.GetReaderInfoResult.Value == 0)
                {
                    strError = "获取册记录'" + reserItem.ItemBarcode + "'未命中。";// + readerRet.GetReaderInfoResult.ErrorInfo;
                    return(-1);
                }

                string strPatronXml = readerRet.results[0];
                dom.LoadXml(strPatronXml);
                XmlNode rootNode = dom.DocumentElement;
                reserItem.PatronName = DomUtil.GetElementText(rootNode, "name");
                reserItem.Department = DomUtil.GetElementText(rootNode, "department");
                reserItem.PatronTel  = DomUtil.GetElementText(rootNode, "tel");

                /*
                 * - <root expireDate="">
                 * <barcode>XZP10199</barcode>
                 * <readerType>学生</readerType>
                 * <name>李明</name>
                 * <overdues />
                 * - <reservations>
                 * <request items="XZ000101" requestDate="Tue, 11 Feb 2020 00:30:27 +0800"
                 *  operator="XZP10199" state="arrived" arrivedDate="Tue, 11 Feb 2020 00:31:45 +0800"
                 *  arrivedItemBarcode="XZ000101" notifyID="59abfc23-f44f-4b34-a22c-f8a8aa5e289e"
                 *  accessNo="K825.6=76/Z780" location="星洲学校/图书馆,#reservation" />
                 * </reservations>
                 * </root>
                 */
                XmlNodeList nodeList = rootNode.SelectNodes("reservations/request");
                foreach (XmlNode node in nodeList)
                {
                    string arrivedItemBarcode = DomUtil.GetAttr(node, "arrivedItemBarcode");
                    if (arrivedItemBarcode == reserItem.ItemBarcode)
                    {
                        reserItem.RequestTime = DateTimeUtil.ToLocalTime(DomUtil.GetAttr(node, "requestDate"), "yyyy-MM-dd HH:mm:ss");
                        reserItem.ArrivedTime = DateTimeUtil.ToLocalTime(DomUtil.GetAttr(node, "arrivedDate"), "yyyy-MM-dd HH:mm:ss");
                        break;
                    }
                }
            }

            return(0);
        }
Exemple #6
0
        private void button_notice_Click(object sender, EventArgs e)
        {
            if (this.listView_note.SelectedItems.Count == 0)
            {
                MessageBox.Show(this, "尚未选择备书单");
                return;
            }

            ListViewItem viewItem = this.listView_note.SelectedItems[0];
            string       noteId   = viewItem.SubItems[0].Text;

            // 2021/3/2加,检查处理过程中有没有变化
            // 检查备书单中册的到书状态在服务器端有无变成outof的?如果变为outof可能是读者放弃取书或者超过的保留期
            bool boutof = this.GetRecordState(noteId, out string checkinfo);

            if (boutof == true)
            {
                MessageBox.Show(this, checkinfo);
                return;
            }

            // 显示电话通知内容
            string     info = this.GetResultInfo(noteId);
            noticeForm dlg  = new noticeForm();

            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.Info          = info;
            DialogResult ret = dlg.ShowDialog(this);

            if (ret == DialogResult.Cancel)
            {
                // 用户取消操作,则不做什么事情
                return;
            }



            // 发送微信通知

            /*
             * <root>
             * <type>预约到书通知</type>
             * <itemBarcode>0000001</itemBarcode>
             * <onShelf>false</onShelf>
             * <accessNo>123</accessNo>
             * <requestDate>Wed, 23 Dec 2020 14:24:10 GMT</requestDate>
             * <today>2016/5/17 10:10:59</today>
             * <reserveTime>2天</reserveTime>
             * <location>星洲/书柜</location>
             * <summary>数学小报. -- ISBN 7</summary>
             * <patronName>张三</patronName>
             * <patronRecord>
             * <barcode>13862157150</barcode>
             * <name>张三</name>
             * <libraryCode></libraryCode>
             * </patronRecord>
             * </root>
             *
             * // http://123.57.163.11/dp2library/demo/rest/SetMessage
             *
             * {
             * "strAction":"send",
             * "strStyle":"",
             * "messages":[
             * {
             * "strRecipient":"!mq:13862157150",
             * "strMime": "xml",
             * "strBody": "<root><type>预约到书通知</type><itemBarcode>0000001</itemBarcode>
             * <onShelf>false</onShelf><accessNo>I247.5/5</accessNo><requestDate>Wed, 23 Dec 2020 14:24:10 GMT</requestDate><today>2016/5/17 10:10:59</today><reserveTime>2天</reserveTime><location>星洲/书柜</location><summary>数学小报. -- ISBN 7-...</summary><patronName>张三</patronName><patronRecord><barcode>13862157150</barcode><name>张三</name><libraryCode></libraryCode></patronRecord></root>"
             * }]
             * }
             */

            // 用于写日志和报错
            string errorPatronName   = "";
            string errorItemBarcodes = "";



            RestChannel channel = this._mainForm.GetChannel();

            try
            {
                string strError = "";

                int    foundCount    = 0;
                int    notfoundCount = 0;
                string foundInfo     = "";
                string notfoundInfo  = "";


                List <ReservationItem> items = DbManager.Instance.GetItemsByNoteId(noteId);
                if (items.Count == 0)
                {
                    MessageBox.Show(this, "该备书单没有详细信息");
                    return;
                }

                foreach (ReservationItem item in items)
                {
                    string   requestTime = item.RequestTime;
                    DateTime dt          = DateTime.Parse(requestTime);
                    string   rfcDate     = DateTimeUtil.Rfc1123DateTimeString(dt); //.Date8toRfc1123(requestTime.Substring(0, 8),out rfcDate,out strError);

                    // 如果是找到的图书,给读者发送预约到书通知
                    if (item.CheckResult == "Y")
                    {
                        // 找到的数量和名称
                        foundCount++;
                        if (foundInfo != "")
                        {
                            foundInfo += ",";
                        }
                        foundInfo += item.Title + "(" + item.ItemBarcode + ")";



                        MessageData message = new MessageData();
                        message.strRecipient = "!mq:" + item.PatronBarcode;
                        message.strMime      = "xml";
                        string strBody = "<root>"
                                         + "<type>预约到书通知</type>"
                                         + "<source>dp2mini</source>"
                                         + "<itemBarcode>" + item.ItemBarcode + "</itemBarcode>"
                                         + "<onShelf>" + item.OnShelf + "</onShelf>"
                                         + "<accessNo>" + item.AccessNo + "</accessNo>"
                                         + "<requestDate>" + rfcDate + "</requestDate>"
                                         + "<today>" + item.ArrivedTime + "</today>"                           //2016/5/17 10:10:59
                                         + "<reserveTime>" + this._mainForm.ReserveTimeSpan + "</reserveTime>" //2天
                                         + "<location>" + item.Location + "</location>"
                                         + "<summary>" + item.Title + "</summary>"
                                         + "<patronName>" + item.PatronName + "</patronName>"
                                         + "<patronRecord>"
                                         + "<barcode>" + item.PatronBarcode + "</barcode>"
                                         + "<name>" + item.PatronName + "</name>"
                                         + "<libraryCode>" + item.LibraryCode + "</libraryCode>"
                                         + "</patronRecord>"
                                         + "</root>";
                        XmlDocument dom = new XmlDocument();
                        dom.LoadXml(strBody);
                        message.strBody = dom.DocumentElement.OuterXml;

                        SetMessageResponse response = channel.SetMessage("send",
                                                                         "",
                                                                         message);
                        if (response.SetMessageResult.ErrorCode != ErrorCode.NoError)
                        {
                            // 同一个备书单的读者是同一位
                            errorPatronName = item.PatronName + "(" + item.PatronBarcode + ")";

                            Log.Error("给'" + errorPatronName + "'发送册'" + item.ItemBarcode + "'到书的微信通知出错:" + response.SetMessageResult.ErrorInfo);

                            if (errorItemBarcodes != "")
                            {
                                errorItemBarcodes += ",";
                            }
                            errorItemBarcodes += item.ItemBarcode;
                        }
                    }
                    else
                    {
                        // 未找到的数量和名称
                        notfoundCount++;
                        if (notfoundInfo != "")
                        {
                            notfoundInfo += ",";
                        }
                        notfoundInfo += item.Title + "(" + item.ItemBarcode + ")";
                    }
                }

                if (errorItemBarcodes != "")
                {
                    // 用Invoke线程安全的方式来调
                    this.Invoke((Action)(() =>
                    {
                        MessageBox.Show(this, "给'" + errorPatronName + "'发送册'" + errorItemBarcodes + "'到书的微信通知出错,详细请查看日志");
                    }));
                }


                // 发送找到和未找到总结信息的通知
                {
                    ReservationItem item = items[0];

                    string strcontent = "";
                    if (foundCount > 0)
                    {
                        strcontent = "备好" + foundCount.ToString() + "本图书:" + foundInfo + "。";
                    }
                    if (notfoundCount > 0)
                    {
                        strcontent += "未找到" + notfoundCount.ToString() + "本: " + notfoundInfo + "。";
                    }

                    MessageData message = new MessageData();
                    message.strRecipient = "!mq:" + item.PatronBarcode;
                    message.strMime      = "xml";
                    string strBody = "<root>"
                                     + "<type>预约备书结果</type>"
                                     + "<content>" + strcontent + "</content>"
                                     + "<patronName>" + item.PatronName + "</patronName>"
                                     + "<patronRecord>"
                                     + "<barcode>" + item.PatronBarcode + "</barcode>"
                                     + "<name>" + item.PatronName + "</name>"
                                     + "<libraryCode>" + item.LibraryCode + "</libraryCode>"
                                     + "</patronRecord>"
                                     + "</root>";
                    XmlDocument dom = new XmlDocument();
                    dom.LoadXml(strBody);
                    message.strBody = dom.DocumentElement.OuterXml;

                    SetMessageResponse response = channel.SetMessage("send",
                                                                     "",
                                                                     message);
                    if (response.SetMessageResult.ErrorCode != ErrorCode.NoError)
                    {
                        string error = "给'" + item.PatronName + "(" + item.PatronBarcode + ")" + "'发送备书结果微信通知出错:" + response.SetMessageResult.ErrorInfo;
                        //写日志
                        Log.Error(error);

                        // 用Invoke线程安全的方式来调
                        this.Invoke((Action)(() =>
                        {
                            MessageBox.Show(this, error);
                        }));
                    }
                }
            }
            finally
            {
                this._mainForm.ReturnChannel(channel);
            }


            Note   note       = DbManager.Instance.GetNote(noteId);
            string noticeTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            note.NoticeTime  = noticeTime;
            note.NoticeState = "Y";
            note.Step        = Note.C_Step_Notice;

            // 更新本地数据库备书库打印状态和时间
            DbManager.Instance.UpdateNote(note);

            // 更新备书行的显示
            this.LoadOneNote(note, viewItem);
            this.SetOperateButton(note.Step);
        }
Exemple #7
0
        /// <summary>
        /// 准备图书完成
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_check_Click(object sender, EventArgs e)
        {
            if (this.listView_note.SelectedItems.Count == 0)
            {
                MessageBox.Show(this, "尚未选择备书单");
                return;
            }

            ListViewItem viewItem = this.listView_note.SelectedItems[0];
            string       noteId   = viewItem.SubItems[0].Text;

            // 2021/3/2加,检查处理过程中有没有变化
            // 检查备书单中册的到书状态在服务器端有无变成outof的?如果变为outof可能是读者放弃取书或者超过的保留期
            bool boutof = this.GetRecordState(noteId, out string info);

            if (boutof == true)
            {
                MessageBox.Show(this, info);
                return;
            }


            checkForm dlg = new checkForm(this._mainForm);

            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.NoteId        = noteId;
            DialogResult ret = dlg.ShowDialog(this);

            if (ret == DialogResult.Cancel)
            {
                // 用户取消操作,则不做什么事情
                return;
            }

            if (ret == DialogResult.OK)
            {
                // 找到的图书
                string foundItems = dlg.FoundItems;
                if (string.IsNullOrEmpty(foundItems) == false)
                {
                    string[] paths = foundItems.Split(new char[] { ',' });
                    foreach (string path in paths)
                    {
                        // 更新数据库预约记录的备书结果
                        ReservationItem item = DbManager.Instance.GetItem(path);
                        item.CheckResult = "Y";
                        DbManager.Instance.UpdateItem(item);
                    }
                }

                // 未找到的图书
                string notfoundItems = dlg.NotFoundItems;
                if (string.IsNullOrEmpty(notfoundItems) == false)
                {
                    string[] paths = notfoundItems.Split(new char[] { ',' });
                    foreach (string path in paths)
                    {
                        // 更新数据库预约记录的备书结果
                        ReservationItem item = DbManager.Instance.GetItem(path);
                        item.CheckResult = "N";

                        string strReason = (string)dlg.NotFoundReasonHt[path];
                        item.NotFoundReason = strReason;

                        DbManager.Instance.UpdateItem(item);
                    }
                }

                string checkTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                Note   note      = DbManager.Instance.GetNote(noteId);
                note.CheckedTime = checkTime;
                note.CheckResult = "Y";
                note.Step        = Note.C_Step_Check;

                // 更新本地数据库备书库打印状态和时间
                DbManager.Instance.UpdateNote(note);

                // 更新备书行的显示
                this.LoadOneNote(note, viewItem);
                this.SetOperateButton(note.Step);

                // 显示详细信息
                this.ShowDetail(noteId);


                //// 从服务器上取消预约,预约记录的状态会从arrived变为outof
                //// 开一个新线程
                //Task.Run(() =>
                //{
                //    DeleteReservation(noteId);
                //});
            }
        }