Exemplo n.º 1
0
 private void btInfo_Click(object sender, EventArgs e)
 {
     tbLog.AppendText(CheDaoFactory.Dump() + Environment.NewLine);
     tbLog.AppendText(Win32Locator.Dump() + Environment.NewLine);
     tbLog.AppendText(Program.log.Dump() + Environment.NewLine);
     //tbLog.AppendText(ShuiKongFactory.Test() + Environment.NewLine);
 }
Exemplo n.º 2
0
        /**
         * Init the internal message handle
         **/
        private void fmReqList_Load(object sender, EventArgs e)
        {
            CheDaoFactory.init();
            this.Text += " " + AppConfig.GetVersion();
            ReciptServer serv = new ReciptServer();

            serv.start(AppConfig.GetPort());
            _UpdateStatus(serv.ServiceInfo());
            layoutMainContent();
        }
Exemplo n.º 3
0
        private void tsItemDelete_Click(object sender, EventArgs e)
        {
            if (lsReqs.SelectedItems.Count < 1)
            {
                return;
            }
            ListViewItem act_item = lsReqs.SelectedItems[0];
            CheRequest   req      = (CheRequest)act_item.Tag;

            CheDaoFactory.Handle_Internal_Package(CheDaoInterface.delete_cmd, Encoding.UTF8.GetBytes(req.Order_Number));
        }
Exemplo n.º 4
0
        /******************************************************************************/

        private void timer_1min_Tick(object sender, EventArgs e)
        {
            m60mCounter++;
            if (m60mCounter >= AppConfig.GetLifeTimeOfRec() / 2)
            {
                m60mCounter = 0;
                CheDaoFactory.Handle_Internal_Package(CheDaoInterface.clean_cmd, Encoding.UTF8.GetBytes("Cleanup"));
            }
            m10mCounter++;
            if (m10mCounter >= upload_rec_period && base_url != null && !mWebClient.IsBusy && mRecBuffer != null && mPendingBuffer == null)
            {
                m10mCounter    = 0;
                mPendingBuffer = "[" + mRecBuffer.ToString() + "]";
                mRecBuffer     = null; //the operation is safe
                mWebClient.UploadStringAsync(new Uri(base_url), mPendingBuffer);
            }
        }
Exemplo n.º 5
0
        private void timer_event()
        {
            Random r = new Random();

            mTestCounter++;
            if (mTestCounter > r.Next(10))
            {
                mTestCounter = 0;
                if (lsReqs.Items.Count > 0)
                {
                    int          index    = r.Next(lsReqs.Items.Count);
                    ListViewItem act_item = lsReqs.Items[index];
                    CheRequest   req      = (CheRequest)act_item.Tag;
                    CheDaoFactory.Handle_Internal_Package(CheDaoInterface.delete_cmd, Encoding.UTF8.GetBytes(req.Order_Number));
                }
            }
        }
Exemplo n.º 6
0
        private void lsReqs_DoubleClick(object sender, EventArgs e)
        {//note other functions call it directly, don't use sender or e
            if (lsReqs.SelectedItems.Count < 1)
            {
                return;
            }
            ListViewItem act_item = lsReqs.SelectedItems[0];
            CheRequest   req      = (CheRequest)act_item.Tag;

            if (req != null)
            {
                int res;
                if ((res = NewShuiKongInterface.SendRecipt(req)) != 0)
                {
                    MessageBox.Show(String.Format("税控脚本执行错误,错误码:{0:d} {1:s}", res, NewShuiKongInterface.getLastError()));
                    lbskStatus.Text = "最近操作:" + NewShuiKongInterface.getLastError();
                }
                else
                {
                    CheDaoFactory.Handle_Internal_Package(CheDaoInterface.print_confirm, Encoding.UTF8.GetBytes(req.Order_Number));
                    lbskStatus.Text = "最近操作:成功";
                }
            }
        }
Exemplo n.º 7
0
            public byte[] handle_incomming(byte[] data, int length, out int rsp_length)//data is from stream
            {
                int     remainder_byte = length;
                Boolean abort          = false;// notify if we need to abort the connection

                byte[] response = new byte[max_fragment];
                out_stream.Seek(0, SeekOrigin.Begin);
                in_stream.Write(data, 0, (int)length);
                in_stream.Seek(0, SeekOrigin.Begin);
                while (remainder_byte >= header_length) //if there is no a valid header, process it when more data is available
                {
                    if (expected_byte == 0)             //begin of a new message
                    {
                        in_stream.Read(header_l_field, 0, 4);
                        remainder_byte -= 4;
                        Array.Reverse(header_l_field);
                        expected_byte = BitConverter.ToInt32(header_l_field, 0);
                        in_stream.Read(header_t_field, 0, 2);
                        Array.Reverse(header_t_field);
                        remainder_byte -= 2;
                        cur_type        = BitConverter.ToInt16(header_t_field, 0);
                    }
                    if (expected_byte > max_fragment || expected_byte <= 0)  //incorrect data
                    {
                        Trace.WriteLineIf(Program.trace_sw.TraceError, "报文长度错误 丢弃 " + expected_byte.ToString());
                        this.reset();
                        remainder_byte = 0;
                        abort          = true;
                        continue;
                    }
                    int next_read = remainder_byte < expected_byte ? remainder_byte : expected_byte;
                    if (next_read == 0)
                    {
                        continue;                 //Nothing to do beacause there is no data in stream
                    }
                    in_stream.Read(msg_body, buffer_point, next_read);
                    remainder_byte -= next_read;
                    expected_byte  -= next_read;
                    buffer_point   += next_read;
                    if (expected_byte == 0)  //get a new message
                    {
                        byte[] rsp_buffer = CheDaoFactory.HandlePackage(cur_type, msg_body, buffer_point);
                        if (rsp_buffer != null)
                        {
                            buffer_point = 0;
                            out_stream.Write(rsp_buffer, 0, rsp_buffer.Length);
                        }
                        else
                        {
                            remainder_byte = 0; //ignore all package
                        }
                    }
                }
                if (remainder_byte > 0)
                {
                    byte[] b = new byte[header_length];
                    in_stream.Read(b, 0, remainder_byte);
                    in_stream.Seek(0, SeekOrigin.Begin);
                    in_stream.Write(b, 0, remainder_byte);// write byte for next bytes in stream later
                }
                else
                {
                    in_stream.Seek(0, SeekOrigin.Begin);
                }
                rsp_length = (int)out_stream.Position;
                if (abort)
                {
                    return(null);
                }
                return(out_stream.GetBuffer());
            }
Exemplo n.º 8
0
 private void fmReqList_FormClosed(object sender, FormClosedEventArgs e)
 {
     CheDaoFactory.close();
 }