예제 #1
0
        public async Task <IActionResult> AddUserInCustomersClub(string phoneNumber)

        {
            var mifare        = new Mifare();
            var contectDevice = mifare.ConnectDevice();

            if (contectDevice.Status == "0")
            {
                return(new JsonResult(new { message = contectDevice.Message, status = contectDevice.Status }));
            }
            else
            {
                var connectCart = mifare.ConnectCart();
                if (connectCart.Status == "0")
                {
                    return(new JsonResult(new { message = connectCart.Message, status = connectCart.Status }));
                }
                else
                {
                    var writeInfo = mifare.Write(phoneNumber);
                    if (writeInfo.Status == "0")
                    {
                        return(new JsonResult(new { message = writeInfo.Message, status = writeInfo.Status }));
                    }
                    else
                    {
                        return(new JsonResult(new
                        {
                            status = "1",
                            message = "با موفقیت ثبت شد",
                        }));
                    }
                }
            }
        }
예제 #2
0
        public async Task <IActionResult> SearchUserByCart()
        {
            var mifare        = new Mifare();
            var phoneNumber   = "";
            var contectDevice = mifare.ConnectDevice();

            if (contectDevice.Status == "0")
            {
                return(new JsonResult(new { message = contectDevice.Message, status = contectDevice.Status }));
            }
            else
            {
                var connectCart = mifare.ConnectCart();
                if (connectCart.Status == "0")
                {
                    return(new JsonResult(new { message = connectCart.Message, status = connectCart.Status }));
                }
                else
                {
                    var readInfo = mifare.Read();
                    if (readInfo.Status == "0")
                    {
                        return(new JsonResult(new { message = readInfo.Message, status = readInfo.Status }));
                    }
                    else
                    {
                        phoneNumber = readInfo.PhoneNumber;
                        var user = await _context.Users.Where(x => x.PhoneNumber.Equals(phoneNumber)).FirstOrDefaultAsync();

                        if (user != null)
                        {
                            return(new JsonResult(new
                            {
                                status = "1",
                                message = "",
                                url = "/Customer/ProductSale",
                                result = user
                            }));
                        }
                        else
                        {
                            return(new JsonResult(new
                            {
                                status = "0",
                                message = "کاربری یافت نشد",
                                url = "/Customer/ProductSale",
                            }));
                        }
                    }
                }
            }
        }
예제 #3
0
파일: NfcReader.cs 프로젝트: sujang/NfcLib
        /// <summary>
        /// Mifareオブジェクトの生成
        /// </summary>
        private NfcTag CreateCard()
        {
            ushort atqa = (ushort)BigEndian.SwapEndian((ushort)device.sens_res);

            byte[] uid = new byte[device.NFCID1_size];
            Array.Copy(device.NFCID1, 0, uid, 0, uid.Length);

            Mifare card = null;

            if (atqa == MfConst.ATQA_MFCL1K)
            {
                card = new MifareCL(lib, uid);
            }
            else if (atqa == MfConst.ATQA_MFUL)
            {
                card = new MifareUL(lib, uid);
            }
            else if (atqa == MfConst.ATQA_MFCL4K)
            {
                card = new MifareCL4K(lib, uid);
            }
            Debug.WriteLine("create_card:" + Utility.ByteToHex(card.Uid, 0, card.Uid.Length));
            return(card);
        }
예제 #4
0
        public ConsoleApp()
        {
            using (Mifare mifare = new Mifare("com3", this)) { };

            Console.ReadKey();
        }