Esempio n. 1
0
        }//----------------------------

        //####################################################END CLASS CampusAccessManager EVENTS###############################################

        //####################################################TIMER tmrTime EVENTS###############################################
        //event is raised when the time ticks
        private void tmrTimeTick(object sender, EventArgs e)
        {
            _systemTime = _systemTime.AddSeconds(this.tmrTime.Interval / 1000);

            this.lblTime.Text = _systemTime.ToLongTimeString();
            this.lblDate.Text = _systemTime.ToLongDateString();

            if (DateTime.Compare(_lastTimeUpdated, _systemTime.AddMinutes(-c_minutesPerUpdate)) == 0)
            {
                _isUpdating = true;

                try
                {
                    this.Cursor = Cursors.WaitCursor;

                    using (UpdatingForm frmUpdate = new UpdatingForm(_userInfo, _campusAccessManager))
                    {
                        frmUpdate.ShowDialog();
                    }

                    this.Cursor = Cursors.Arrow;
                }
                catch (Exception ex)
                {
                    RemoteClient.ProcStatic.ShowErrorDialog("Error updating\n" + ex.Message, "Error Updating");
                }

                _isUpdating = false;

                _lastTimeUpdated = _systemTime;
            }
        }//-----------------------------
Esempio n. 2
0
        //####################################################CLASS CampusAccessManager EVENTS###############################################
        //event is raised when the class is loaded
        private void ClassLoad(object sender, EventArgs e)
        {
            _port.Open();

            _errorImage = Image.FromFile(Application.StartupPath + @"\error.jpg");

            _isUpdating = true;

            this.Cursor = Cursors.WaitCursor;

            using (UpdatingForm frmUpdate = new UpdatingForm(_userInfo, _campusAccessManager))
            {
                frmUpdate.ShowDialog();
            }

            this.Cursor = Cursors.Arrow;

            _isUpdating = false;

            if (DateTime.TryParse(_campusAccessManager.ServerDateTime, out _systemTime))
            {
                this.tmrTime.Start();
            }

            _lastTimeUpdated = _systemTime;

            //this.InitializeImageSize();
        }//--------------------------------
Esempio n. 3
0
        }//--------------------------------

        //event is raised when the class is clossing
        private void ClassClossing(object sender, FormClosingEventArgs e)
        {
            _imageList.RemoveRange(0, c_noImages);
            this.Dispose();

            using (UpdatingForm frmUpdate = new UpdatingForm(_userInfo, _campusAccessManager))
            {
                frmUpdate.ShowDialog();
            }

            Application.Exit();
        }//-------------------
Esempio n. 4
0
        }//-----------------------------

        //####################################################END TIMER tmrTime EVENTS###############################################

        //####################################################SERIALPORT _port EVENTS###############################################
        //event is raised when the selected index is changed
        private void _portDataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            try
            {
                if (_swipeCount == c_noOfSwipeBeforeUpdate)
                {
                    _isUpdating = true;

                    using (UpdatingForm frmUpdate = new UpdatingForm(_userInfo, _campusAccessManager))
                    {
                        frmUpdate.ShowDialog();
                    }

                    _isUpdating = false;

                    _lastTimeUpdated = _systemTime;

                    _swipeCount = 0;
                }

                if (_port.IsOpen && !_isUpdating)
                {
                    String newCardNo = "SN" + _port.ReadLine().Remove(0, 4).Trim();

                    if (((!String.Equals(_lastCardNo, newCardNo)) || (DateTime.Compare(_timeSwipe.AddMinutes(10), DateTime.Now) < 0)) &&
                        newCardNo.Length == 10)
                    {
                        this.SwapImages();

                        if (_campusAccessManager.IsExistPersonInformation(newCardNo))
                        {
                            if (File.Exists(CommonExchange.SystemConfiguration.PersonImagesFolder(Application.StartupPath) + @"\" +
                                            _campusAccessManager.GetImageOrignalName(newCardNo)))
                            {
                                _imageList[0].PersonImage = Image.FromFile(CommonExchange.SystemConfiguration.PersonImagesFolder(Application.StartupPath) + @"\" +
                                                                           _campusAccessManager.GetImageOrignalName(newCardNo));
                            }
                            else
                            {
                                _imageList[0].PersonImage = Image.FromFile(Application.StartupPath + @"\default.jpg");
                            }

                            _imageList[0].SwipeTime               = _systemTime;
                            _imageList[0].PersonSysId             = _campusAccessManager.GetPersonSystemId(newCardNo);
                            _imageList[0].PersonName              = _campusAccessManager.GetImageInformation(newCardNo, true);
                            _imageList[0].LastName                = _campusAccessManager.GetPersonLastNameFirstName(newCardNo, true);
                            _imageList[0].FirstMiddleName         = _campusAccessManager.GetPersonLastNameFirstName(newCardNo, false);
                            _imageList[0].StudentEmployeeSystemId = _campusAccessManager.GetImageInformation(newCardNo, false);
                            _imageList[0].DateTimeSwipString      = _systemTime.ToShortDateString() + "\n" + _systemTime.ToLongTimeString();

                            _imageList[0].ImageDescription = _imageList[0].PersonName + "\n" + _imageList[0].StudentEmployeeSystemId + "\n" + _imageList[0].DateTimeSwipString;

                            _campusAccessManager.InsertCampusAccessDetails(_imageList[0].PersonSysId, _imageList[0].SwipeTime, _accessPointId);

                            _isAccessDenied = false;
                        }
                        else
                        {
                            _isAccessDenied = true;
                        }

                        _timeSwipe = DateTime.Now;

                        _swipeCount++;

                        this.Invalidate(false);
                    }

                    _lastCardNo = newCardNo;
                }
            }
            catch (Exception ex)
            {
                RemoteClient.ProcStatic.ShowErrorDialog("Error in Receiving Data.\n" + ex.Message, "Error");
            }
        }//--------------------------