jeudi 30 juillet 2015

How to assign value of Guid and stop random with condition

I have variables mifarecard.ID generate values with Guid type.

When people in parking lot of supermarket, I swipe card give them and it will auto generate ID for mifare card. They will hold this card and give back to me, I will swipe card and authentication. It's simple.

My struct program is:

private void startThread()
{
     while(mifarecard.Connect())   //Application connect to Mifare reader.
     {
          if(mifarecard.BindCard(true))    //When swipe card
          {
               mifarecard.ID = System.Guid.NewGuid().ToString("N");   //Create random ID.
               // ???
          }
      }
}

But my problem appear in function. When swipe card, ID auto generate new 32 character.

I want it save ID until they give back and I can check it. If ID match, authentication success.

But when swipe card, it auto generate, when they give back, I swipe card and it generate new ID. I can't compare two ID.

Why I'm must generate random ID? Because I want 1 card have 1 ID. And when they give back card to me, I use this card to swipe new people go in supermarket, it will random new ID. Thank you!!!




Aucun commentaire:

Enregistrer un commentaire