示例#1
0
        private CaptureInfo GetCapture(ScannerType scannerType, CancellationToken token)
        {
            Log.DebugFormat("GetCapture(scannerType={0}, token={1}) called",
                            scannerType, token);
            CaptureInfo       captureInfo = null;
            DataRequestResult result      = DataRequestResult.None;
            bool isRunning = true;
            int  attempts  = 0;

            while (isRunning)
            {
                // Check if cancellation requested
                token.ThrowIfCancellationRequested();

                // First query the database to get an image file name.
                CaptureDb captureCandidate = GetCaptureFromDatabase(scannerType);

                if (captureCandidate != null)
                {
                    // Try to find an image file using the file name.
                    byte[] imageData;
                    bool   isFound = TryGetImageFromName(captureCandidate.HumanId, out imageData);
                    if (isFound)
                    {
                        // Matching file found.
                        Log.DebugFormat("Matching file found for capture={0}", captureCandidate.HumanId);
                        isRunning   = false;
                        captureInfo = new CaptureInfo(
                            captureCandidate.Id,
                            imageData,
                            captureCandidate.GoldTemplate);
                        result = DataRequestResult.Success;
                    }
                    else
                    {
                        // Give up if the number of attemps exceeds limit.
                        attempts++;
                        if (attempts > MAX_OPEN_FILE_ATTEMPTS)
                        {
                            Log.WarnFormat("Exceeded maximum number of file searches (attempts={0})",
                                           attempts);
                            isRunning = false;
                            result    = DataRequestResult.Failed;
                        }
                    }
                }
                else
                {
                    // Queries are not returning any more candidates, give up immediately.
                    Log.Warn("No candidate filename obtained from the database");
                    result = DataRequestResult.Failed;
                    break;
                }
            }
            IntegrityCheck.AreNotEqual(DataRequestResult.None, result);
            return(captureInfo);
        }
示例#2
0
            public override void OnEnteringState()
            {
                base.OnEnteringState();

                Outer.OnUserActionRequired(new UserActionRequiredEventArgs(SET_ANGLE_PROMPT));

                // Get the minutia that was placed in the previous step
                IntegrityCheck.AreNotEqual(0, Outer.Minutae.Count());
                m_Record = Outer.Minutae.Last();
                IntegrityCheck.IsNotNull(m_Record.Position);
            }