Exemplo n.º 1
0
        public void readCard(int comPort, out int broj)
        {
            string sType = " ";
            string sID1  = "          ";
            string sID2  = "          ";
            string name  = "                                ";

            broj = -1;

            AdminForm af          = Form1.Instance.AdminForm;
            bool      measureTime = af != null;

            Stopwatch watch = null;

            if (measureTime)
            {
                watch = Stopwatch.StartNew();
            }

            ulong retval;

            if (Options.Instance.JedinstvenProgram)
            {
                lock (readAndWriteLock)
                {
                    retval = ReadDataCard(comPort, ref sType, ref sID1, ref sID2, ref name) & 0xFFFFFFFF;
                }
            }
            else
            {
                retval = ReadDataCard(comPort, ref sType, ref sID1, ref sID2, ref name) & 0xFFFFFFFF;
            }

            if (measureTime)
            {
                watch.Stop();
                af.newCitanjeKartice(retval, watch.ElapsedMilliseconds);
            }

            if (retval == 1)
            {
                if (!dobroFormatiranaKartica(sID1, name, out broj))
                {
                    throw new ReadCardException("Lose formatirana kartica.");
                }
            }
            else
            {
                string msg = "Neuspesno citanje kartice. " +
                             "Proverite da li je uredjaj prikljucen, i da li je podesen COM port.";
                throw new ReadCardException(msg);
            }
        }