Esempio n. 1
0
        public void Unload()
        {
            if (IsUILoaded)
            {
                if (cardCheck != null)
                {
                    cardCheck.Dispose();
                    cardCheck = null;
                }
                source.RemoveHook(WndProc);

                if (database != null)
                    database.Change(Timeout.Infinite, Timeout.Infinite);
                sl = null;

                SetToDefault();

                IsUILoaded = false;
            }
        }
Esempio n. 2
0
        public async void Init()
        {
            Common.SCANING = true;

            if (sl == null) sl = new SL500();

            if (cardCheck != null)
                cardCheck.Change(Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan);

            sl.CheckReader();
            Dictionary<string, string> server = await DatabaseConnection.IsAvaliable();

            Dispatcher.Invoke((Action)(() =>
            {
                databasestatusDot.Fill = (server["con"] == "true") ? baseColor : red;
                statusDot.Fill = (Common.READER) ? baseColor : red;

                Common.SERVER = (server["con"] == "true") ? true : false;
            }));


            if (server["con"] == "true" && Common.READER)
            {
                Dispatcher.Invoke((Action)(() =>
                {
                    if (cards.Visibility != Visibility.Visible)
                    {
                        SetToDefault();
                    }

                    cardCheck = new Timer(checkCard, null, TagDetect.RequestDelay * 2, TagDetect.RequestDelay);
                }));
            }
            else
            {
                Dispatcher.Invoke((Action)(() =>
                {
                    if (server["con"] == "true" && !Common.READER)
                    {
                        alert.ChangeText("Please connect card reader");
                        alert.Visibility(Visibility.Visible);
                    }
                    else
                    {
                        alert.ChangeText(server["mes"]);
                        alert.Visibility(Visibility.Visible);
                    }
                    if (cardCheck != null)
                    {
                        cardCheck.Dispose();
                        cardCheck = null;
                    }
                }));
            }

            database = new Timer(DbAvailable, null, 30000, 30000);

            Common.SCANING = false;
        }