예제 #1
0
        // 提交读者证条码号
        private void button_passGate_Click(object sender, EventArgs e)
        {
            string strError = "";

            if (String.IsNullOrEmpty(this.textBox_readerBarcode.Text) == true)
            {
                strError = "请输入读者证条码号";
                goto ERROR1;
            }

            int nMaxListItemsCount = this.MaxListItemsCount;

            ListViewItem item = new ListViewItem();

            if (this.checkBox_hideBarcode.Checked == true)
            {
                string strText = "";
                item.Text = strText.PadLeft(this.textBox_readerBarcode.Text.Length, '*');
            }
            else
            {
                item.Text = this.textBox_readerBarcode.Text;
            }

            ReaderInfo info = new ReaderInfo();

            info.ReaderBarcode = this.textBox_readerBarcode.Text;
            item.Tag           = info;

            item.SubItems.Add("");
            item.SubItems.Add("");
            item.SubItems.Add(DateTime.Now.ToString());

            item.ImageIndex = 0;    // 尚未填充数据

            this.m_lock.AcquireWriterLock(m_nLockTimeout);
            try
            {
                if (nMaxListItemsCount != -1 &&
                    this.listView_list.Items.Count > nMaxListItemsCount)
                {
                    ClearList();
                }

                this.listView_list.Items.Add(item);
            }
            finally
            {
                this.m_lock.ReleaseWriterLock();
            }

            item.EnsureVisible();

            this.eventActive.Set(); // 告诉工作线程

            this.textBox_readerBarcode.SelectAll();
            this.textBox_readerBarcode.Focus();
            return;

ERROR1:
            MessageBox.Show(this, strError);
            this.textBox_readerBarcode.SelectAll();
            this.textBox_readerBarcode.Focus();
        }
예제 #2
0
        // listview imageindex 0:尚未初始化 1:已经初始化 2:出错

        // 工作线程每一轮循环的实质性工作
        void Worker()
        {
            try
            {
                string strError = "";

                for (int i = this.m_nTail; i < this.listView_list.Items.Count; i++)
                {
                    // ListViewItem item = this.listView_list.Items[i];
                    ListViewItem item = GetItem(i);

                    if (item.ImageIndex == 1)
                    {
                        continue;
                    }

                    // string strBarcode = item.Text;
                    ReaderInfo info       = (ReaderInfo)item.Tag;
                    string     strBarcode = info.ReaderBarcode;

                    stop.OnStop += new StopEventHandler(this.DoStop);
                    stop.Initial("正在初始化浏览器组件 ...");
                    stop.BeginLoop();

                    string strTypeList = "xml";
                    int    nTypeCount  = 1;

                    if (this.checkBox_displayReaderDetailInfo.Checked == true)
                    {
                        strTypeList += ",html";

                        if (StringUtil.CompareVersion(Program.MainForm.ServerVersion, "2.25") >= 0)
                        {
                            strTypeList += ":noborrowhistory";
                        }

                        nTypeCount = 2;
                    }

                    try
                    {
                        string[] results = null;
                        long     lRet    = Channel.PassGate(stop,
                                                            strBarcode,
                                                            this.textBox_gateName.Text, // strGateName
                                                            strTypeList,
                                                            out results,
                                                            out strError);
                        if (lRet == -1)
                        {
                            OnError(item, strError);
                            goto CONTINUE;
                        }

                        // this.textBox_counter.Text = lRet.ToString();
                        SetCounterText(lRet);

                        if (results.Length != nTypeCount)
                        {
                            strError = "results error...";
                            OnError(item, strError);
                            goto CONTINUE;
                        }

                        string strXml = results[0];

                        string strReaderName = "";
                        string strState      = "";
                        int    nRet          = GetRecordInfo(strXml,
                                                             out strReaderName,
                                                             out strState,
                                                             out strError);
                        if (nRet == -1)
                        {
                            OnError(item, strError);
                            goto CONTINUE;
                        }

                        info.ReaderName = strReaderName;

                        if (this.checkBox_hideReaderName.Checked == true)
                        {
                            string strText = "";
                            // item.SubItems[1].Text = strText.PadLeft(strReaderName.Length, '*');
                            SetItemText(item, 1, strText.PadLeft(strReaderName.Length, '*'));
                        }
                        else
                        {
                            // item.SubItems[1].Text = strReaderName;
                            SetItemText(item, 1, strReaderName);
                        }

                        // item.SubItems[2].Text = strState;
                        SetItemText(item, 2, strState);

                        // item.ImageIndex = 1;    // error
                        SetItemImageIndex(item, 1);

                        if (this.checkBox_displayReaderDetailInfo.Checked == true &&
                            results.Length == 2)
                        {
                            this.m_webExternalHost.StopPrevious();
                            this.webBrowser_readerInfo.Stop();

                            // this.HtmlString = results[1];

                            // API.PostMessage(this.Handle, WM_SETHTML, 0, 0);
                            StartSetHtml(results[1]);
                        }
                    }
                    finally
                    {
                        stop.EndLoop();
                        stop.OnStop -= new StopEventHandler(this.DoStop);
                        stop.Initial("");
                    }

CONTINUE:
                    this.m_nTail = i;
                }
            }
            catch (Exception ex)
            {
                string strErrorText = "PassGateForm Worker() 出现异常: " + ExceptionUtil.GetDebugText(ex);
                MainForm.TryWriteErrorLog(strErrorText);
            }
        }
예제 #3
0
        // 提交读者证条码号
        private void button_passGate_Click(object sender, EventArgs e)
        {
            string strError = "";

            if (String.IsNullOrEmpty(this.textBox_readerBarcode.Text) == true)
            {
                strError = "请输入读者证条码号";
                goto ERROR1;
            }

            int nMaxListItemsCount = this.MaxListItemsCount;

            ListViewItem item = new ListViewItem();

            if (this.checkBox_hideBarcode.Checked == true)
            {
                string strText = "";
                item.Text = strText.PadLeft(this.textBox_readerBarcode.Text.Length, '*');
            }
            else
                item.Text = this.textBox_readerBarcode.Text;

            ReaderInfo info = new ReaderInfo();
            info.ReaderBarcode = this.textBox_readerBarcode.Text;
            item.Tag = info;

            item.SubItems.Add("");
            item.SubItems.Add("");
            item.SubItems.Add(DateTime.Now.ToString());

            item.ImageIndex = 0;    // 尚未填充数据

            this.m_lock.AcquireWriterLock(m_nLockTimeout);
            try
            {
                if (nMaxListItemsCount != -1
                    && this.listView_list.Items.Count > nMaxListItemsCount)
                    ClearList();

                this.listView_list.Items.Add(item);
            }
            finally
            {
                this.m_lock.ReleaseWriterLock();
            }

            item.EnsureVisible();

            this.eventActive.Set(); // 告诉工作线程

            this.textBox_readerBarcode.SelectAll();
            this.textBox_readerBarcode.Focus();
            return;
        ERROR1:
            MessageBox.Show(this, strError);
            this.textBox_readerBarcode.SelectAll();
            this.textBox_readerBarcode.Focus();
        }