public async Task <IHttpActionResult> PutFingerprints(int id, Fingerprints fingerprints)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != fingerprints.Id)
            {
                return(BadRequest());
            }

            db.Entry(fingerprints).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FingerprintsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        private void matchWithDbToolStripMenuItem_Click(object sender, EventArgs e)
        {
            bool                   isMatched         = false;
            List <Minutiae>        originalMinutiaes = GetMinutiaesFromBitmap(originalBitmap);
            DbJSONSerializer       db              = new DbJSONSerializer();
            Fingerprints           fingerprints    = db.DeserializeMinutiaes(db.ReadFromJsonFile("db_fingerprints.json"));
            List <UserFingerprint> userFingerPrint = fingerprints.userFingerprints;

            foreach (UserFingerprint uf in userFingerPrint)
            {
                Debug.Print("Porównuje " + uf.name);
                MatchingFingerprints.SetAccumulatorDimension(originalBitmap.Width, originalBitmap.Height);
                TranslationVotes votes = MatchingFingerprints.Matching(originalMinutiaes, uf.minutiaes);
                if (MatchingFingerprints.IsIdentical(originalMinutiaes, uf.minutiaes, votes))
                {
                    isMatched = true;
                    MessageBox.Show(uf.name);
                    break;
                }
            }
            if (!isMatched)
            {
                MessageBox.Show("Brak usera w bazie");
            }
        }
Exemplo n.º 3
0
        void CloseCurrentTab()
        {
            try
            {
                var _currentID = (Guid)CurrentTab.Tag;

                Tabs.Items.Remove(CurrentTab);

                foreach (MenuItem mi in MnuQueryList.Items)
                {
                    if ((Guid)mi.Tag == _currentID)
                    {
                        MnuQueryList.Items.Remove(mi);
                    }
                    Fingerprints.Remove(_currentID);
                }

                if (Tabs.Items.Count == 0)
                {
                    TabNumber = 0;
                    AddTab();
                }
                else
                {
                    Tabs.SelectedIndex = Tabs.Items.Count;
                }
            }
            catch
            {
            }
        }
Exemplo n.º 4
0
        void AddTab()
        {
            var _id       = Guid.NewGuid();
            var _tempName = $"Query {TabNumber + 1}";

            var n = new EditorDuo
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
                Name      = $"Editor{TabNumber}",
                ID        = _id,
                Processed = false,
                Task      = TaskType.Default
            };

            n.Upper.CreationDate = DateTime.Now;
            n.Lower.Task         = TaskType.Default;
            n.Lower.Processed    = false;
            n.Upper.SetDateStamp();
            n.Lower.SetTaskType();

            var _h = new HeaderedContentControl
            {
                Header = _tempName,
            };

            _h.MouseDown  += OnTabHeaderClick;
            _h.MouseEnter += _h_MouseEnter;


            var t = new TabItem
            {
                Header  = _h,
                Content = n,
                Tag     = _id
            };

            Tabs.Items.Add(t);

            // Create a menu item for this new tab. Menu items and tabs are bound together
            // using the editor's GUID as a reference. --Will Kraft (2/16/2020).
            var _menuItem = new MenuItem
            {
                Header = _tempName,
                Tag    = _id,
            };

            _menuItem.Click += _menuItem_Click;

            MnuQueryList.Items.Add(_menuItem);

            Tabs.SelectedIndex = Tabs.Items.Count - 1;
            TabNumber++;
            Fingerprints.Add(_id);
        }
        public async Task <IHttpActionResult> GetFingerprints(int id)
        {
            Fingerprints fingerprints = await db.Fingerprints.FindAsync(id);

            if (fingerprints == null)
            {
                return(NotFound());
            }

            return(Ok(fingerprints));
        }
        public async Task <IHttpActionResult> PostFingerprints(Fingerprints fingerprints)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Fingerprints.Add(fingerprints);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = fingerprints.Id }, fingerprints));
        }
Exemplo n.º 7
0
        private void btnDeleteFingerprint_Click(object sender, EventArgs e)
        {
            try
            {
                var fingerprints = new Fingerprints();

                fingerprints.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error, delete fingerprint", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 8
0
        private void MnuCloseAll_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (ProcessedTabs > 0)
                {
                    var _confirm = MessageBox.Show("Do you want to save a copy of these processed queries?", "SqlPrep", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning, MessageBoxResult.Yes);


                    if (_confirm == MessageBoxResult.Yes)
                    {
                        var _s = new SaveFileDialog
                        {
                            Filter     = "XML Documents|*.xml",
                            DefaultExt = ".xml",
                            FileName   = $"Batch_{DateTime.Today.ToString("yyMMdd")}.xml"
                        };

                        var _result = _s.ShowDialog();

                        if (_result == true)
                        {
                            var _h = new XmlDocumentHistory();
                            _h.SaveTabstoXml(Tabs.Items, _s.FileName);
                        }
                        else
                        {
                            return;
                        }
                    }
                    else if (_confirm == MessageBoxResult.Cancel)
                    {
                        return;
                    }
                }

                // Bugfix: LoadingFile prevents a new EditorDuo from showing up prematurely. --Will Kraft (3/22/2020).
                LoadingFile = true;
                Tabs.Items.Clear();
                MnuQueryList.Items.Clear();
                Fingerprints.Clear();
                LoadingFile = false;

                AddTab();
            }
            catch (Exception ex)
            {
                MessageBox.Show(DevMode ? ex.ToString() : ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        public async Task <IHttpActionResult> DeleteFingerprints(int id)
        {
            Fingerprints fingerprints = await db.Fingerprints.FindAsync(id);

            if (fingerprints == null)
            {
                return(NotFound());
            }

            db.Fingerprints.Remove(fingerprints);
            await db.SaveChangesAsync();

            return(Ok(fingerprints));
        }
Exemplo n.º 10
0
        public MatcherWithDb(List <Minutiae> originalMinutiaes, string dbFileName)
        {
            DbJSONSerializer serializer = new DbJSONSerializer();

            fingerprints = serializer.DeserializeMinutiaes(serializer.ReadFromJsonFile("db_fingerprints.json"));
            List <UserFingerprint> userFingerprints = fingerprints.userFingerprints;

            foreach (UserFingerprint fp in userFingerprints)
            {
                if (CompareFingerprints(originalMinutiaes, fp.minutiaes))
                {
                    Console.WriteLine("Znaleziono odcisk w bazie");
                    break;
                }
            }
        }
Exemplo n.º 11
0
        private void MnuOpen_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var _o = new OpenFileDialog()
                {
                    Filter     = "XML Documents|*.xml",
                    DefaultExt = ".xml",
                };
                var _result = _o.ShowDialog();

                if (_result == true)
                {
                    var _dlg = new ImportDialog
                    {
                        Owner = this
                    };

                    _dlg.ShowDialog();

                    if (!_dlg.Append)
                    {
                        LoadingFile = true;
                        Tabs.Items.Clear();
                        MnuQueryList.Items.Clear();
                        Fingerprints.Clear();
                    }


                    var _h = new XmlDocumentHistory();
                    _h.RegenerateTab += _xml_RegenerateTab;
                    _h.RecoverTabs(_o.FileName, Fingerprints);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(DevMode ? ex.ToString() : ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                LoadingFile = false;
            }
        }
Exemplo n.º 12
0
        private void CreateDB()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter      = "JPG|*.jpg|PNG|*.png";
            openFileDialog.Multiselect = true;
            openFileDialog.ShowDialog();
            List <UserFingerprint> userFingerprints = new List <UserFingerprint>();

            foreach (String file in openFileDialog.FileNames)
            {
                Bitmap bitmap = (Bitmap)Bitmap.FromFile(file);
                bitmap = Thinning.Thin(bitmap);
                List <Minutiae> minutiaes = GetMinutiaesFromBitmap(bitmap);
                userFingerprints.Add(new UserFingerprint(file, minutiaes));
            }
            Fingerprints     fingerprints = new Fingerprints(userFingerprints);
            DbJSONSerializer db           = new DbJSONSerializer();

            db.WriteToFile(db.SerializeMinutiaes(fingerprints), "db_fingerprints.json");
        }
Exemplo n.º 13
0
 /// <summary>
 ///  Gets enumerator over actual fingerprints.
 /// </summary>
 /// <returns></returns>
 public IEnumerator <HashedFingerprint> GetEnumerator()
 {
     return(Fingerprints.GetEnumerator());
 }
 private string Serialize(Fingerprints fingerprints)
 {
     return(JsonConvert.SerializeObject(fingerprints));
 }
 public string SerializeMinutiaes(Fingerprints fingerprints)
 {
     return(Serialize(fingerprints));
 }
Exemplo n.º 16
0
        /// <summary>
        /// Restore a saved tab from a previous session's stored XML data. This is usually triggered by
        /// an event from the XMLDocumentHistory class during program startup, or when a history file
        /// is loaded. --Will Kraft (12/29/2019).
        /// </summary>
        /// <param name="e">Tab data (from XML) to restore.</param>
        void RestoreTab(TabRestorationEventArgs e)
        {
            Brush OutputBG        = SystemColors.HighlightBrush;
            Brush OutputSelection = SystemColors.WindowBrush;
            Brush TabTextColor    = SystemColors.ControlTextBrush;

            switch (e.Task)
            {
            default:
            case TaskType.Default:     // This isn't supposed to happen but if it ever does, default system colors are good enough.
                break;

            case TaskType.Prepare:
                TabTextColor    = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#1b80fa"));
                OutputBG        = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#d9edff"));
                OutputSelection = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#486394"));
                break;

            case TaskType.Strip:
                TabTextColor    = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#fe5000"));  // old color: #fa781b
                OutputBG        = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#fff3cf"));
                OutputSelection = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#9c4c24"));
                break;
            }


            var n = new EditorDuo
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
                Name        = $"Editor{TabNumber}",
                ID          = e.TabID,
                Processed   = true,
                Task        = e.Task,
                LowerText   = e.LowerText,
                UpperText   = e.UpperText,
                Args        = e.PrepareArgs,
                LowerColor  = OutputBG,
                LowerSelect = OutputSelection,
                TabName     = e.TabName,
            };

            n.Upper.CreationDate           = e.CreationDate;
            n.Lower.ProcessedDate          = e.ProcessedDate;
            n.Lower.Task                   = e.Task;
            n.Lower.OpStatusProcessedColor = TabTextColor;
            n.Lower.Processed              = true;
            n.Lower.SetDateStamp();
            n.Upper.SetDateStamp();
            n.Lower.SetTaskType();

            var _h = new HeaderedContentControl
            {
                Header     = e.TabName,
                Foreground = TabTextColor
            };

            _h.MouseDown += OnTabHeaderClick;

            var t = new TabItem
            {
                Header  = _h,
                Content = n,
                Tag     = e.TabID
            };

            Tabs.Items.Add(t);

            Tabs.SelectedIndex = Tabs.Items.Count - 1;

            // Create a menu item for this  tab. Menu items and tabs are bound together
            // using the editor's GUID as a reference. --Will Kraft (2/16/2020).
            var _menuItem = new MenuItem
            {
                Header      = e.TabName.Replace("_", "__"),
                Tag         = e.TabID,
                Foreground  = TabTextColor,
                IsCheckable = true,
                IsChecked   = true // This corrects itself automatically as subsequent tabs are loaded, but it ensures the last                                   document is checked properly in the query list. --Will Kraft (2/16/2020).
            };

            _menuItem.Click += _menuItem_Click;

            MnuQueryList.Items.Add(_menuItem);

            TabNumber++;
            Fingerprints.Add(e.TabID);
        }