Example #1
0
        // 旧的、界面线程版本
        // 填充“未交费用”列表
        int FillAmercingList(string strXml,
            out string strError)
        {
            strError = "";

            this.listView_overdues.Items.Clear();

            XmlDocument dom = new XmlDocument();
            try
            {
                dom.LoadXml(strXml);
            }
            catch (Exception ex)
            {
                strError = "读者XML记录装入XMLDOM时发生错误: " + ex.Message;
                return -1;
            }

            List<string> dup_ids = new List<string>();

            // 选出所有<overdue>元素
            XmlNodeList nodes = dom.DocumentElement.SelectNodes("overdues/overdue");

            for (int i = 0; i < nodes.Count; i++)
            {
                XmlNode node = nodes[i];
                string strItemBarcode = DomUtil.GetAttr(node, "barcode");
                string strItemRecPath = DomUtil.GetAttr(node, "recPath");
                string strReason = DomUtil.GetAttr(node, "reason");
                string strBorrowDate = DomUtil.GetAttr(node, "borrowDate");

                strBorrowDate = DateTimeUtil.LocalTime(strBorrowDate, "u");

                string strBorrowPeriod = DomUtil.GetAttr(node, "borrowPeriod");
                string strReturnDate = DomUtil.GetAttr(node, "returnDate");

                strReturnDate = DateTimeUtil.LocalTime(strReturnDate, "u");


                string strID = DomUtil.GetAttr(node, "id");
                string strPrice = DomUtil.GetAttr(node, "price");
                string strComment = DomUtil.GetAttr(node, "comment");

                string strBorrowOperator = DomUtil.GetAttr(node, "borrowOperator");
                string strReturnOperator = DomUtil.GetAttr(node, "operator");

                XmlNodeList dup_nodes = dom.DocumentElement.SelectNodes("overdues/overdue[@id='"+strID+"']");
                if (dup_nodes.Count > 1)
                {
                    dup_ids.Add(strID);
                }


                // TODO: 摘要建议异步作,或者在全部数据装载完成后单独扫描一遍做
                string strSummary = "";

#if NOOOOOOOOO
                if (String.IsNullOrEmpty(strItemBarcode) == false)
                {
                    stop.OnStop += new StopEventHandler(this.DoStop);
                    stop.SetMessage("正在获取摘要 " + strItemBarcode + " ...");
                    stop.BeginLoop();

                    try
                    {

                        string strBiblioRecPath = "";
                        long lRet = Channel.GetBiblioSummary(
                            stop,
                            strItemBarcode,
                            strItemRecPath,
                            null,
                            out strBiblioRecPath,
                            out strSummary,
                            out strError);
                        if (lRet == -1)
                        {
                            strSummary = strError;  // 2009/3/13 changed
                            // return -1;
                        }

                    }
                    finally
                    {
                        stop.EndLoop();
                        stop.OnStop -= new StopEventHandler(this.DoStop);
                        stop.Initial("");
                    }
                }
#endif

                ListViewItem item = new ListViewItem(strItemBarcode);

                this.listView_overdues.Items.Add(item);

                // 摘要
                // item.SubItems.Add(strSummary);
                ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_BIBLIOSUMMARY, strSummary);

                // 金额
                // item.SubItems.Add(strPrice);
                ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_PRICE, strPrice);

                // 注释
                // item.SubItems.Add(strComment);
                ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_COMMENT, strComment);

                // 违约原因
                // item.SubItems.Add(strReason);
                ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_REASON, strReason);

                // 借阅日期
                // item.SubItems.Add(strBorrowDate);
                ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_BORROWDATE, strBorrowDate);

                // 借阅时限
                // item.SubItems.Add(strBorrowPeriod);
                ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_BORROWPERIOD, strBorrowPeriod);

                // 还书日期
                // item.SubItems.Add(strReturnDate);
                ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_RETURNDATE, strReturnDate);

                // id
                // item.SubItems.Add(strID);
                ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_ID, strID);

                ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_BORROWOPERATOR, strBorrowOperator);
                ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_RETURNOPERATOR, strReturnOperator);

                // 储存原始价格和注释备用
                AmercingItemInfo info = new AmercingItemInfo();
                info.Price = strPrice;
                info.Comment = strComment;
                item.Tag = info;
            }

            if (dup_ids.Count > 0)
            {
                StringUtil.RemoveDupNoSort(ref dup_ids);
                Debug.Assert(dup_ids.Count >= 1, "");
                strError = "未交费用列表中发现下列ID出现了重复,这是一个严重错误,请系统管理员尽快排除。\r\n---\r\n" + StringUtil.MakePathList(dup_ids, "; ");
                MessageBox.Show(this, strError);
            }

            return 0;
        }
Example #2
0
        /*public*/
        void ThreadFillAmercingMain()
        {
            string strError = "";
            m_bStopFillAmercing = false;

            LibraryChannel channel = new LibraryChannel();
            channel.Url = this.MainForm.LibraryServerUrl;

            channel.BeforeLogin += new BeforeLoginEventHandle(Channel_BeforeLogin);

            try
            {

                Safe_clearList(this.listView_overdues);

                XmlDocument dom = new XmlDocument();
                try
                {
                    dom.LoadXml(this.FillAmercingParam.Xml);
                }
                catch (Exception ex)
                {
                    strError = "读者XML记录装入XMLDOM时发生错误: " + ex.Message;
                    goto ERROR1;
                }

                List<string> dup_ids = new List<string>();

                // 选出所有<overdue>元素
                XmlNodeList nodes = dom.DocumentElement.SelectNodes("overdues/overdue");

                for (int i = 0; i < nodes.Count; i++)
                {
                    if (this.m_bStopFillAmercing == true)
                    {
                        strError = "中断,列表不完整...";
                        goto ERROR1;
                    }

                    XmlNode node = nodes[i];
                    string strItemBarcode = DomUtil.GetAttr(node, "barcode");
                    string strItemRecPath = DomUtil.GetAttr(node, "recPath");
                    string strReason = DomUtil.GetAttr(node, "reason");
                    string strBorrowDate = DomUtil.GetAttr(node, "borrowDate");

                    strBorrowDate = DateTimeUtil.LocalTime(strBorrowDate, "u");

                    string strBorrowPeriod = DomUtil.GetAttr(node, "borrowPeriod");
                    string strReturnDate = DomUtil.GetAttr(node, "returnDate");

                    strReturnDate = DateTimeUtil.LocalTime(strReturnDate, "u");

                    string strID = DomUtil.GetAttr(node, "id");
                    string strPrice = DomUtil.GetAttr(node, "price");
                    string strComment = DomUtil.GetAttr(node, "comment");

                    string strBorrowOperator = DomUtil.GetAttr(node, "borrowOperator");
                    string strReturnOperator = DomUtil.GetAttr(node, "operator");

                    XmlNodeList dup_nodes = dom.DocumentElement.SelectNodes("overdues/overdue[@id='" + strID + "']");
                    if (dup_nodes.Count > 1)
                    {
                        dup_ids.Add(strID);
                    }


                    // TODO: 摘要建议异步作,或者在全部数据装载完成后单独扫描一遍做
                    string strSummary = "";


                    ListViewItem item = new ListViewItem(strItemBarcode);

                    // 摘要
                    // item.SubItems.Add(strSummary);
                    ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_BIBLIOSUMMARY, strSummary);

                    // 金额
                    // item.SubItems.Add(strPrice);
                    ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_PRICE, strPrice);

                    // 注释
                    // item.SubItems.Add(strComment);
                    ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_COMMENT, strComment);

                    // 违约原因
                    // item.SubItems.Add(strReason);
                    ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_REASON, strReason);

                    // 借阅日期
                    // item.SubItems.Add(strBorrowDate);
                    ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_BORROWDATE, strBorrowDate);

                    // 借阅时限
                    // item.SubItems.Add(strBorrowPeriod);
                    ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_BORROWPERIOD, strBorrowPeriod);

                    // 还书日期
                    // item.SubItems.Add(strReturnDate);
                    ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_RETURNDATE, strReturnDate);

                    // id
                    // item.SubItems.Add(strID);
                    ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_ID, strID);

                    ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_BORROWOPERATOR, strBorrowOperator);
                    ListViewUtil.ChangeItemText(item, COLUMN_AMERCING_RETURNOPERATOR, strReturnOperator);

                    // 储存原始价格和注释备用
                    AmercingItemInfo info = new AmercingItemInfo();
                    info.Price = strPrice;
                    info.Comment = strComment;
                    info.Xml = node.OuterXml;
                    item.Tag = info;

                    Safe_addListItem(this.listView_overdues, item);
                }

                if (dup_ids.Count > 0)
                {
                    StringUtil.RemoveDupNoSort(ref dup_ids);
                    Debug.Assert(dup_ids.Count >= 1, "");
                    strError = "未交费用列表中发现下列ID出现了重复,这是一个严重错误,请系统管理员尽快排除。\r\n---\r\n" + StringUtil.MakePathList(dup_ids, "; ");
                    goto ERROR1;
                }

                // 第二阶段,填充摘要
                if (this.FillAmercingParam.FillSummary == true)
                {
                    List<ListViewItem> items = Safe_getItemList(listView_overdues);

                    for (int i = 0; i < items.Count; i++)
                    {
                        if (this.m_bStopFillAmercing == true)
                            return;

                        ListViewItem item = items[i];

                        string strSummary = "";
                        string strItemBarcode = "";

                        Safe_getBarcodeAndSummary(listView_overdues,
        item,
        out strItemBarcode,
        out strSummary);

                        // 已经有内容了,就不刷新了
                        if (String.IsNullOrEmpty(strSummary) == false)
                            continue;

                        if (String.IsNullOrEmpty(strItemBarcode) == true
                            /*&& String.IsNullOrEmpty(strItemRecPath) == true*/)
                            continue;

                        try
                        {
                            string strBiblioRecPath = "";
                            long lRet = channel.GetBiblioSummary(
                                null,
                                strItemBarcode,
                                "", // strItemRecPath,
                                null,
                                out strBiblioRecPath,
                                out strSummary,
                                out strError);
                            if (lRet == -1)
                            {
                                strSummary = strError;  // 2009/3/13 changed
                                // return -1;
                            }

                        }
                        finally
                        {
                        }

                        Safe_changeItemText(item, COLUMN_AMERCING_BIBLIOSUMMARY, strSummary);
                    }
                }


                return;
            }
            finally
            {
                channel.BeforeLogin -= new BeforeLoginEventHandle(Channel_BeforeLogin);
                channel.Close();
                m_bStopFillAmercing = true;
            }

        ERROR1:
            Safe_setError(this.listView_overdues, strError);
            // Safe_errorBox(strError);
        }