示例#1
0
        public static bool delCredit()
        {
            SL500 sl = new SL500();
            if (request() == true)
            {
                if (sl.anticoll() == true)
                {
                    sl.select();

                    if (sl.authentify(1) == 0)
                    {
                        status = sl.dataWrite((byte)block._credit, new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
                        if (status == 0)
                        {
                            return true;
                        }
                        return false;
                    }
                    return false;
                }
                return false;
            }
            return false;
        }
示例#2
0
        public static bool addCredit(UInt64 amount)
        {
            SL500 sl = new SL500();
            if (request() == true)
            {
                if (sl.anticoll() == true)
                {
                    sl.select();

                    if (sl.authentify(1) == 0)
                    {
                        status = sl.dataWrite((byte)block._credit, BitConverter.GetBytes(amount));
                        if (status == 0)
                        {
                            return true;
                        }
                        return false;
                    }
                    return false;
                }
                return false;
            }
            return false;
        }
示例#3
0
        public static bool write(List<string> l)
        {
            SL500 sl = new SL500();
            if (request() == true)
            {
                if (sl.anticoll() == true)
                {
                    string select = sl.select();
                    if (select != "e")
                    {
                        if (sl.authentify(1) == 0)
                        {
                            byte[] type = new byte[] { (byte)int.Parse(l[1]), 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte)int.Parse(l[5]), 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

                            sl.dataWrite((byte)6, type);

                            sl.authentify(2);
                            int status = 1;

                            byte[] text = new byte[16];
                            text = Encoding.ASCII.GetBytes(l[2]);
                            status = sl.dataWrite((byte)block._name, text);

                            sl.authentify(2);
                            text = Encoding.ASCII.GetBytes(l[3]);
                            status = sl.dataWrite((byte)block._surname, text);

                            sl.authentify(2);
                            text = Encoding.ASCII.GetBytes(l[4]);
                            status = sl.dataWrite((byte)block._func, text);

                            sl.authentify(1);
                            text = BitConverter.GetBytes(program.Owner);
                            status = sl.dataWrite((byte)block._owner, text);

                            if (l[1] == "2")
                            {
                                text = BitConverter.GetBytes(0);
                                status = sl.dataWrite((byte)block._credit, text);
                            }
                            if (status != 0)
                            {
                                return false;
                            }
                            return true;

                        }
                        return false;
                    }
                    return false;
                }
                return false;
            }
            return false;
        }
示例#4
0
        public static bool updateInfo(List<string> l)
        {
            SL500 sl = new SL500();
            if (request() == true)
            {
                if (sl.anticoll() == true)
                {
                    string select = sl.select();
                    if (select != "e")
                    {
                        if (sl.authentify(2) == 0)
                        {
                            int status = 1;

                            byte[] text = new byte[16];
                            text = Encoding.ASCII.GetBytes(l[1]);
                            status = sl.dataWrite((byte)block._name, text);

                            sl.authentify(2);
                            text = Encoding.ASCII.GetBytes(l[2]);
                            status = sl.dataWrite((byte)block._surname, text);

                            sl.authentify(2);
                            text = Encoding.ASCII.GetBytes(l[3]);
                            status = sl.dataWrite((byte)block._func, text);

                            if (status != 0)
                            {
                                return false;
                            }
                            return true;
                        }
                        return false;
                    }
                    return false;
                }
                return false;
            }
            return false;
        }
示例#5
0
        public static void ownerNew(string own)
        {

            try
            {
                SL500 sl = new SL500();
                byte[] write = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
                byte[] owner = BitConverter.GetBytes(int.Parse(own));
                Array.Copy(owner, 0, write, 0, owner.Length);
                if (request() == true)
                {
                    if (sl.anticoll() == true)
                    {
                        string select = sl.select();
                        if (select != "e")
                        {
                            if (sl.authentify(1) == 0)
                            {
                                sl.dataWrite((byte)block._owner, write);
                            }
                        }
                    }
                }
            }
            catch (Exception add)
            {
                //using (FileStream fs = new FileStream(@"log\log.txt", FileMode.Append, FileAccess.Write))
                //{
                //    byte[] write = Encoding.ASCII.GetBytes("OWNER WRITE NULL ERROR\r\n");
                //    fs.Write(write, 0, write.Length);
                //    write = Encoding.ASCII.GetBytes(add.Message);
                //    fs.Write(write, 0, write.Length);
                //    write = Encoding.ASCII.GetBytes("\r\n--------------------------------------\r\n");
                //    fs.Write(write, 0, write.Length);
                //    fs.Flush();
                //    fs.Close();
                //}
            }
        }