Esempio n. 1
0
        void make_room_card(ushort r, DateTime dt)
        { //制房间卡按钮
            byte[] tb = new byte[16];
            tb[0] = 4;
            tb[1] = (byte)(r >> 8);
            tb[2] = (byte)r;

            tb[3] = (byte)(dt.Year >> 8);
            tb[4] = (byte)dt.Year;
            tb[5] = (byte)dt.Month;
            tb[6] = (byte)dt.Day;
            tb[7] = (byte)dt.Hour;
            tb[8] = (byte)dt.Minute;
            tb[9] = (byte)dt.Second;

            g_retCode = ACR110U.ACR110_Write(g_hReader, 4, ref tb[0]);
            if (g_retCode == 0)
            {
                //textBox1.AppendText("[DEBUG] MAKE TIME CARD = " + g_retCode + "\n");

                System.IO.File.WriteAllText(nowsn + ".dat", dt + "");
                int i = findIndexByRoomName(r + "");
                if (i >= 0)
                {
                    rooms[i].card_count = 1;
                    saveRooms();
                    room_ref();
                }
                System.IO.File.AppendAllText("oplog\\" + dt.ToString("yyyy_MM_dd") + ".dat", dt + ": make room card sn=" + nowsn + ", room=" + r + "\r\n");
                textBox1.AppendText("[DEBUG] MAKE ROOM CARD DONE\n");
            }
        }
Esempio n. 2
0
        void make_useless_card()
        {//制管理卡按钮
            byte[] tb = new byte[16];
            tb[0] = 0;
            //tb[3] = (byte)(ushort.Parse(textBox2.Text) >> 8);
            //tb[4] = (byte)ushort.Parse(textBox2.Text);
            //tb[5] = byte.Parse(textBox3.Text);
            //tb[6] = byte.Parse(textBox4.Text);
            //tb[7] = byte.Parse(textBox5.Text);
            //tb[8] = byte.Parse(textBox6.Text);
            //tb[9] = byte.Parse(textBox7.Text);

            g_retCode = ACR110U.ACR110_Write(g_hReader, 4, ref tb[0]);
            if (g_retCode == 0)
            {
                //textBox1.AppendText("[DEBUG] MAKE TIME CARD = " + g_retCode + "\n");
                textBox1.AppendText("[DEBUG] MAKE USELESS CARD DONE\n");
            }
        }
Esempio n. 3
0
        void make_floor_card(byte floor)
        {
            //制楼层卡按钮
            byte[] tb = new byte[16];
            tb[0] = 2;
            tb[2] = floor;
            //tb[3] = (byte)(ushort.Parse(textBox2.Text) >> 8);
            //tb[4] = (byte)ushort.Parse(textBox2.Text);
            //tb[5] = byte.Parse(textBox3.Text);
            //tb[6] = byte.Parse(textBox4.Text);
            //tb[7] = byte.Parse(textBox5.Text);
            //tb[8] = byte.Parse(textBox6.Text);
            //tb[9] = byte.Parse(textBox7.Text);

            g_retCode = ACR110U.ACR110_Write(g_hReader, 4, ref tb[0]);
            if (g_retCode == 0)
            {
                //textBox1.AppendText("[DEBUG] MAKE TIME CARD = " + g_retCode + "\n");
                textBox1.AppendText("[DEBUG] MAKE FLOOR CARD DONE\n");
            }
        }
Esempio n. 4
0
        private void textBox1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
            {
                string line = get_last_line(textBox1.Lines);
                if (line == "CARD_INIT")
                {
                    {
                        g_retCode = ACR110U.ACR110_Select(g_hReader, ref tagType[0], ref tagLen, ref tagSN[0]);

                        textBox1.AppendText("[DEBUG] SELECT CARD = " + g_retCode + "\n");
                        textBox1.AppendText("[DEBUG] CARD TYPE = " + ACR110U.GetTagType1(tagType[0]) + "\n");
                        string str = "";
                        for (int i = 0; i < tagLen; i++)
                        {
                            str += tagSN[i].ToString("X2") + " ";
                        }
                        textBox1.AppendText("[DEBUG] CARD SN = " + str + "\n");
                        byte[] key = new byte[6] {
                            0xff, 0xff, 0xff, 0xff, 0xff, 0xff
                        };
                        g_retCode = ACR110U.ACR110_Login(g_hReader, 1, ACR110U.ACR110_LOGIN_KEYTYPE_A, 0, ref key[0]);
                        if (g_retCode == 0)
                        {
                            byte[] wbuf = new byte[16] {
                                0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xff, 0x07, 0x80, 0x69, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
                            };
                            g_retCode = ACR110U.ACR110_Write(g_hReader, 7, ref wbuf[0]);
                            if (g_retCode == 0)
                            {
                                textBox1.AppendText("CARD_INIT DONE\n");
                            }
                            else
                            {
                                textBox1.AppendText("CARD_INIT ERR 2\n");
                            }
                        }
                        else
                        {
                            textBox1.AppendText("CARD_INIT ERR 1\n");
                        }
                    }
                }
                else if (line == "CARD_ADMIN")
                {
                    //if (!card_conn)
                    //{
                    //    card_conn =
                    //}
                    //if (card_conn)
                    {
                        select_login();
                        make_admin_card();
                    }
                }
                else if (line.StartsWith("CARD_FLOOR "))
                {
                    string[] words = line.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                    if (words.Length == 2)
                    {
                        byte f = byte.Parse(words[1]);
                        //if (!card_conn)
                        //{
                        //    card_conn = select_login();
                        //}
                        //if (card_conn)
                        {
                            select_login();
                            make_floor_card(f);
                        }
                    }
                }
                else if (line == "CLS")
                {
                    textBox1.Clear();
                }
            }
        }