private void LoadElements() { this.gridSize = Carrier.Width / numX; //确定地图格子大小 Bomb.gridSize = this.gridSize; // testMap = new MyMap(numX, numY, (int)Carrier.Width, (int)Carrier.Height); person1 = new MyPerson(gridSize, source.personsource1.body, new System.Drawing.Point(0, 0), testMap); testMap.personBlocks.Add(person1); person2 = new MyPerson(gridSize, source.personsource2.body, new System.Drawing.Point(15, 15), testMap); testMap.personBlocks.Add(person2); person1.Width = person1.Height = gridSize; person2.Width = person2.Width = gridSize; person2.Faction.Fill = new SolidColorBrush(Colors.Blue); person2.Faction.Text = "主角2"; LoadMap(); //加载地图 LoadPerson(person1); person1.xspeed = 400; person1.yspeed = 400; LoadPerson(person2); person2.xspeed = 400; person2.yspeed = 400; //加载人物 }
private void UpdateCompMatchedUser(MyPerson match) { Invoke((MethodInvoker) delegate { if (match != null) { tbId.Text = match.Id.ToString(); tbName.Text = match.Name.ToString(); tbPhone.Text = match.Phone.ToString(); tbGuid.Text = match.Guid.ToString(); pbFPRef.Image = match.Fingerprints[0].AsBitmap; } else { tbId.Text = ""; tbName.Text = ""; tbPhone.Text = ""; tbGuid.Text = ""; pbFPRef.Image = null; } }); }
public async Task <ActionResult> Create([Bind(Include = "mortalId,name,nic,filename,template,no_of_minutaes")] mortal mortal) { if (ModelState.IsValid & mortal.filename != null) { AfisEngine Afis = new AfisEngine(); Fingerprint fp1 = new Fingerprint(); string AppPath = System.IO.Path.Combine(Server.MapPath("~"), "images"); string pathToImage = (System.IO.Path.Combine(AppPath, mortal.filename)); Bitmap bitmap = fp1.AsBitmap = new Bitmap(Image.FromFile(pathToImage)); MyPerson personsdk = new MyPerson(); personsdk.Fingerprints.Add(fp1); Afis.Extract(personsdk); string str_Template = fp1.AsXmlTemplate.ToString(); mortal.template = str_Template; //Code to count number of Minutae string pattern = "<Minutia"; int count = 0; int a = 0; while ((a = str_Template.IndexOf(pattern, a)) != -1) { a += pattern.Length; count++; } //Assign count to no_of_minutaes mortal.no_of_minutaes = count; db.mortals.Add(mortal); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } Response.Write("<script>alert('Please Enter Filename');</script>"); return(View(mortal)); }
public static async Task <PersonOperationStatus> DeletePerson(string PersonGroupId, string personId = null) { bool rtnStatus = false; PersonOperationStatus status = new PersonOperationStatus(); //////////////////////////////////////////////////////////////////////////////////// Guid uuidPersonGuid = Guid.Empty; //////////////////////////////////////////////////////////////////////////////////// status.AttemptedDatabaseOperation = true; try { using (var db = new Facial_Recognition_Library.Data.LiveEduFaceModel()) { status.CompletedDatabaseOperation = MyPerson.DeletePersonById(db, PersonGroupId, out uuidPersonGuid); } status.CompletedDatabaseOperation = true; } catch (Exception e) { status.ReasonForFailure += $"Failed to remove from database {e.Message} |"; } //////////////////////////////////////////////////////////////////////////////////// status.AttemptedAPIOperation = true; try { await ProjectOxfordAPI.DeletePerson(PersonGroupId, uuidPersonGuid); status.CompletedAPIOperation = true; } catch (Exception e) { status.ReasonForFailure += $"Failed to remove from api {e.Message} |"; } //////////////////////////////////////////////////////////////////////////////////// return(status); }
// Take fingerprint image file and create Person object from the image public MyPerson Enroll(string filename, string name) { Console.WriteLine("Enrolling {0}...", name); // Initialize empty fingerprint object and set properties MyFingerprint fp = new MyFingerprint(); fp.Filename = filename; try { // Load image from the file Console.WriteLine(" Loading image from {0}...", filename); BitmapImage image = new BitmapImage(new Uri(filename, UriKind.RelativeOrAbsolute)); fp.AsBitmapSource = image; // Above update of fp.AsBitmapSource initialized also raw image in fp.Image // Check raw image dimensions, Y axis is first, X axis is second Console.WriteLine(" Image size = {0} x {1} (width x height)", fp.Image.GetLength(1), fp.Image.GetLength(0)); // Initialize empty person object and set its properties MyPerson person = new MyPerson(); person.Name = name; // Add fingerprint to the person person.Fingerprints.Add(fp); // Execute extraction in order to initialize fp.Template Console.WriteLine(" Extracting template..."); afis.Extract(person); // Check template size Console.WriteLine(" Template size = {0} bytes", fp.Template.Length); return(person); } catch (Exception fnfe) { throw fnfe; } }
private void UserForm_Load(object sender, EventArgs e) { m_userDB = new UserDB(); m_accessDB = new AccessInfoDB(); m_carDB = new CarInfoDB(); m_historyDB = new AccessHisDB(); m_avrMgr = new AverageInfoManager(); m_user = new MyPerson(); m_car = new CarInfo(); toolStripCbCount.Items.AddRange(selectCountCbDatas); toolStripCbCount.SelectedIndex = 2; toolStripCbCount.DropDownStyle = ComboBoxStyle.DropDownList; dtpAvgDate.Format = DateTimePickerFormat.Custom; dtpAvgDate.CustomFormat = "yyyy년 MM월 dd일 (ddd)"; cbChartType.Items.AddRange(chartTypeCbdatas); cbChartType.SelectedIndex = 0; InitDataGridViews(); UpdateComponents(); }
public async Task <ActionResult> Match([Bind(Include = "Name, Filename")] mortal mortal) { if (ModelState.IsValid & mortal.filename != null) { AfisEngine Afis = new AfisEngine(); Afis.Threshold = 10; Fingerprint fp1 = new Fingerprint(); Fingerprint fp2 = new Fingerprint(); MyPerson person1 = new MyPerson(); MyPerson person2 = new MyPerson(); string apppath = System.IO.Path.Combine(Server.MapPath("~"), "images"); string pathToImage1 = (System.IO.Path.Combine(apppath, mortal.name)); string pathToImage2 = (System.IO.Path.Combine(apppath, mortal.filename)); Bitmap bitmap1 = fp1.AsBitmap = new Bitmap(Image.FromFile(pathToImage1)); Bitmap bitmap2 = fp2.AsBitmap = new Bitmap(Image.FromFile(pathToImage2)); person1.Fingerprints.Add(fp1); person2.Fingerprints.Add(fp2); Afis.Extract(person1); Afis.Extract(person2); float score = Afis.Verify(person1, person2); if (score > Afis.Threshold) { Response.Write("<script>alert('" + score.ToString() + "');</script>"); } return(View()); } Response.Write("<script>alert('Please Enter Filename');</script>"); return(View()); }
public FacePage() { InitializeComponent(); Person = new MyPerson(); }
}//end btnAdvMatcherMatch_Click private void processAdvancedMultiMatch() { try { //Set Serach status lblAdvMatcherStatus.Text = "Searching...."; //Get the Threshold Int32 matchingThreshold = Convert.ToInt32(ConfigurationManager.AppSettings["InitialThresholdScore"]); if (!string.IsNullOrWhiteSpace(txtBoxAdvMatcherThreshold.Text)) { matchingThreshold = Convert.ToInt32(txtBoxAdvMatcherThreshold.Text); } //If fpPath = null, show the error message if (picMatchImagePath == null) { MessageBox.Show("Must select a fingerprint to match.", "Warning Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //Try minimal threshold score(s) to find matches List <Match> matches = Program.getMatches(picMatchImagePath, "[Unknown Identity]", matchingThreshold); Console.WriteLine("###-->> Multi-Match performed...# of matches found = " + matches.Count); if (matches.Count == 0) { MessageBox.Show("No Match found for threshold = " + matchingThreshold + ", adjust the threshold and try again.", "Warning Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } this.Invoke((MethodInvoker) delegate { //First Clear previous controlls on button click this.tlpAdvMatcherResult.Controls.Clear(); //Add the Table Header this.tlpAdvMatcherResult.Controls.Add(lblAdvMatcherPersonId, 0, 0); this.tlpAdvMatcherResult.Controls.Add(lblAdvMatcherFName, 1, 0); this.tlpAdvMatcherResult.Controls.Add(lblAdvMatcherLName, 2, 0); this.tlpAdvMatcherResult.Controls.Add(lblAdvMatcherScore, 3, 0); DataAccess dataAccess = new DataAccess(); for (int i = 0; i < this.tlpAdvMatcherResult.RowCount - 1; i++) { if (matches.Count > i) { MyPerson person = matches[i].getMatchedPerson(); float score = matches[i].getScore(); PersonDetail pDetail = dataAccess.retrievePersonDetail(person.PersonId).FirstOrDefault(); Console.WriteLine("Id = " + person.PersonId + ", FirstName = " + pDetail.getFirstName() + ", LastName = " + pDetail.getLastName()); switch (i) { case 0: lnllblAdvMatchId_1.Text = person.PersonId; this.tlpAdvMatcherResult.Controls.Add(lnllblAdvMatchId_1, 0, i + 1); break; case 1: lnllblAdvMatchId_2.Text = person.PersonId; this.tlpAdvMatcherResult.Controls.Add(lnllblAdvMatchId_2, 0, i + 1); break; case 2: lnllblAdvMatchId_3.Text = person.PersonId; this.tlpAdvMatcherResult.Controls.Add(lnllblAdvMatchId_3, 0, i + 1); break; case 3: lnllblAdvMatchId_4.Text = person.PersonId; this.tlpAdvMatcherResult.Controls.Add(lnllblAdvMatchId_4, 0, i + 1); break; case 4: lnllblAdvMatchId_5.Text = person.PersonId; this.tlpAdvMatcherResult.Controls.Add(lnllblAdvMatchId_5, 0, i + 1); break; case 5: lnllblAdvMatchId_6.Text = person.PersonId; this.tlpAdvMatcherResult.Controls.Add(lnllblAdvMatchId_6, 0, i + 1); break; case 6: lnllblAdvMatchId_7.Text = person.PersonId; this.tlpAdvMatcherResult.Controls.Add(lnllblAdvMatchId_7, 0, i + 1); break; case 7: lnllblAdvMatchId_8.Text = person.PersonId; this.tlpAdvMatcherResult.Controls.Add(lnllblAdvMatchId_8, 0, i + 1); break; case 8: lnllblAdvMatchId_9.Text = person.PersonId; this.tlpAdvMatcherResult.Controls.Add(lnllblAdvMatchId_9, 0, i + 1); break; case 9: lnllblAdvMatchId_10.Text = person.PersonId; this.tlpAdvMatcherResult.Controls.Add(lnllblAdvMatchId_10, 0, i + 1); break; case 10: lnllblAdvMatchId_11.Text = person.PersonId; this.tlpAdvMatcherResult.Controls.Add(lnllblAdvMatchId_11, 0, i + 1); break; case 11: lnllblAdvMatchId_12.Text = person.PersonId; this.tlpAdvMatcherResult.Controls.Add(lnllblAdvMatchId_12, 0, i + 1); break; case 12: lnllblAdvMatchId_13.Text = person.PersonId; this.tlpAdvMatcherResult.Controls.Add(lnllblAdvMatchId_13, 0, i + 1); break; case 13: lnllblAdvMatchId_14.Text = person.PersonId; this.tlpAdvMatcherResult.Controls.Add(lnllblAdvMatchId_14, 0, i + 1); break; case 14: lnllblAdvMatchId_15.Text = person.PersonId; this.tlpAdvMatcherResult.Controls.Add(lnllblAdvMatchId_15, 0, i + 1); break; } //Label - First Nmae Label lblAdvMatcherFirstName = new Label() { Text = pDetail.getFirstName() }; lblAdvMatcherFirstName.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.tlpAdvMatcherResult.Controls.Add(lblAdvMatcherFirstName, 1, i + 1); //Label - Last Name Label lblAdvMatcherLastName = new Label() { Text = pDetail.getLastName() }; lblAdvMatcherLastName.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.tlpAdvMatcherResult.Controls.Add(lblAdvMatcherLastName, 2, i + 1); //Label - Score Label lblAdvMatcherScore = new Label() { Text = matches[i].getScore().ToString() }; lblAdvMatcherScore.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.tlpAdvMatcherResult.Controls.Add(lblAdvMatcherScore, 3, i + 1); } //end if } //end for //Set Serach status lblAdvMatcherStatus.Text = "Search Completed."; }); } catch (Exception exp) { Console.WriteLine(exp); } }
public static void generateDuplicateFingerprintReport(User user, ICollection <KeyValuePair <String, MyPerson> > dupMatches) { Console.WriteLine("###-->> Current Thread = " + System.Threading.Thread.CurrentThread.Name); //Paragraph Title Font iTextSharp.text.Font paragraphTitleFont = FontFactory.GetFont("Arial", 16); Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35); string datetimePref = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"); string pdfPath = ConfigurationManager.AppSettings["DupFingerprintReportPath"] + "-" + datetimePref + ".pdf"; PdfWriter pdfWriter = PdfWriter.GetInstance(doc, new FileStream(pdfPath, FileMode.Create)); doc.Open(); //add title doc.AddTitle("Duplicate Fingerprint Report"); doc.AddHeader("Monthly Report", "Duplicate Fingerprint Report"); //Add Company Logo & Company Name PdfPTable logoAndTitle = new PdfPTable(2); float[] cellWidths = new float[] { 100f, 100f }; logoAndTitle.SetWidths(cellWidths); iTextSharp.text.Image iTextCompanyLogoImage = null; if (AFISMain.clientSetup != null) { if (AFISMain.clientSetup.CompanyLogo != null) { iTextCompanyLogoImage = iTextSharp.text.Image.GetInstance(AFISMain.clientSetup.CompanyLogo, System.Drawing.Imaging.ImageFormat.Bmp); iTextCompanyLogoImage.ScaleAbsolute(60f, 60f); } } else { //Default image in case, image is not available iTextCompanyLogoImage = iTextSharp.text.Image.GetInstance(ConfigurationManager.AppSettings["DefaultCompanyLogo"]); } logoAndTitle.AddCell(new PdfPCell(iTextCompanyLogoImage)); string titleStr = AFISMain.clientSetup.LegalName + "\n" + AFISMain.clientSetup.AddressLine + "\n" + AFISMain.clientSetup.City + ", " + AFISMain.clientSetup.State + " " + AFISMain.clientSetup.PostalCode + "\n" + AFISMain.clientSetup.Country + "\n"; logoAndTitle.AddCell(new PdfPCell(new Phrase(titleStr, paragraphTitleFont))); doc.Add(logoAndTitle); iTextSharp.text.Font contentFont = iTextSharp.text.FontFactory.GetFont("Webdings", 20, iTextSharp.text.Font.BOLD); Paragraph paragraphReportTitle = new Paragraph("Duplicate Fingerprint Report\n", contentFont); paragraphReportTitle.Alignment = Element.ALIGN_CENTER; Paragraph paragraphReportSubTitle = new Paragraph(); paragraphReportSubTitle.Add("By: " + user.getFirstName() + " " + user.getLastName() + ", ID: " + user.getPersonId() + "\n"); paragraphReportSubTitle.Add("At: " + DateTime.Now.ToString() + "\n\n"); paragraphReportSubTitle.Alignment = Element.ALIGN_CENTER; doc.Add(paragraphReportTitle); doc.Add(paragraphReportSubTitle); PdfPTable dupFingerprintReportTable = new PdfPTable(3); float[] widths = new float[] { 25f, 40f, 40f }; dupFingerprintReportTable.SetWidths(widths); PdfPCell headerCellRecNo = new PdfPCell(new Phrase("RecNo")); PdfPCell headerCellID = new PdfPCell(new Phrase("Person Id")); PdfPCell headerCellDup = new PdfPCell(new Phrase("Person Id with Duplicate fingerprint")); //Add Headers to the table dupFingerprintReportTable.AddCell(headerCellRecNo); dupFingerprintReportTable.AddCell(headerCellID); dupFingerprintReportTable.AddCell(headerCellDup); int i = 0; foreach (KeyValuePair <string, MyPerson> dupMatch in dupMatches) { string probePersonId = dupMatch.Key; MyPerson dupPerson = dupMatch.Value; Console.WriteLine("###-->> Fingerprints of Person[PersonId = " + probePersonId + "] has duplicate with Person[PersonId = " + dupPerson.PersonId + "]"); PdfPCell recNo = new PdfPCell(new Phrase(Convert.ToString(i + 1))); PdfPCell probePersonIdCell = new PdfPCell(new Phrase(probePersonId)); PdfPCell dupPersonIdCell = new PdfPCell(new Phrase(dupPerson.PersonId)); //Adding cells to the table dupFingerprintReportTable.AddCell(recNo); dupFingerprintReportTable.AddCell(probePersonIdCell); dupFingerprintReportTable.AddCell(dupPersonIdCell); i++; } doc.Add(dupFingerprintReportTable); doc.Close(); Console.WriteLine("PDF Generated successfully..."); System.Diagnostics.Process.Start(pdfPath); }
public void setProbe(MyPerson probe) { this.probe = probe; }
private void LoadUser(int userId) { m_user = new UserDB().SelectISPSUser(userId); }
public async Task <ActionResult> BulkCreate([Bind(Include = "")] mortal mortal /*, HttpPostedFileBase file*/) { AfisEngine Afis = new AfisEngine(); Afis.Threshold = 60; //List<MyPerson> personsdks = new List<MyPerson>(); string AppPath = System.IO.Path.Combine(Server.MapPath("~"), "images"); Stopwatch stopwatch0 = Stopwatch.StartNew(); //creates and start the instance of Stopwatch long range = Int64.Parse(mortal.nic); for (int i = 0; i < range; i++) { int imgnumber = i + 1; string imgval = "(" + imgnumber.ToString() + ").jpg"; string pathtoimages = (System.IO.Path.Combine(AppPath, imgval)); Fingerprint fp0 = new Fingerprint(); MyPerson myperson = new MyPerson(); Bitmap bitmap0 = fp0.AsBitmap = new Bitmap(Image.FromFile(pathtoimages)); myperson.Fingerprints.Add(fp0); Afis.Extract(myperson); string str_Template = fp0.AsXmlTemplate.ToString(); mortal.template = str_Template; mortal.name = (i + 1).ToString(); mortal.filename = pathtoimages; mortal.nic = (i + 1).ToString(); //Code to count number of Minutae string pattern = "<Minutia"; int count = 0; int a = 0; while ((a = str_Template.IndexOf(pattern, a)) != -1) { a += pattern.Length; count++; } mortal.no_of_minutaes = count; db.mortals.Add(mortal); //db.Entry(person).State = EntityState.Modified; await db.SaveChangesAsync(); } stopwatch0.Stop(); Stopwatch stopwatch1 = Stopwatch.StartNew(); //creates and start the instance of Stopwatch //Verification segment string sql = "Select * from mortal"; List <mortal> personListRom = db.mortals.SqlQuery(sql).ToList(); List <MyPerson> personListRam = new List <MyPerson>(); foreach (mortal p in personListRom) { MyPerson personTemp = new MyPerson(); MyFingerprint fpTemp = new MyFingerprint(); personTemp.Id = p.mortalId; personTemp.Name = p.name; fpTemp.Filename = p.filename; fpTemp.AsXmlTemplate = XElement.Parse(p.template); personTemp.Fingerprints.Add(fpTemp); personListRam.Add(personTemp); } stopwatch1.Stop(); //verify at 1 index Stopwatch stopwatch2 = Stopwatch.StartNew(); //creates and start the instance of Stopwatch Fingerprint fp1 = new Fingerprint(); string apppath = System.IO.Path.Combine(Server.MapPath("~"), "images"); string pathToImage = (System.IO.Path.Combine(apppath, "(1).jpg")); Bitmap bitmap = fp1.AsBitmap = new Bitmap(Image.FromFile(pathToImage)); MyPerson personsdk = new MyPerson(); personsdk.Fingerprints.Add(fp1); Afis.Extract(personsdk); MyPerson match = Afis.Identify(personsdk, personListRam).FirstOrDefault() as MyPerson; stopwatch2.Stop(); //verify at mid index Stopwatch stopwatch3 = Stopwatch.StartNew(); //creates and start the instance of Stopwatch Fingerprint fp2 = new Fingerprint(); string apppath2 = System.IO.Path.Combine(Server.MapPath("~"), "images"); string pathToImage2 = (System.IO.Path.Combine(apppath, "(" + (range / 2).ToString() + ").jpg")); Bitmap bitmap2 = fp2.AsBitmap = new Bitmap(Image.FromFile(pathToImage2)); MyPerson personsdk2 = new MyPerson(); personsdk2.Fingerprints.Add(fp2); Afis.Extract(personsdk2); MyPerson match2 = Afis.Identify(personsdk2, personListRam).FirstOrDefault() as MyPerson; stopwatch3.Stop(); Stopwatch stopwatch4 = Stopwatch.StartNew(); //creates and start the instance of Stopwatch Fingerprint fp3 = new Fingerprint(); Random rand = new Random(); int num = rand.Next(3); string apppath3 = System.IO.Path.Combine(Server.MapPath("~"), "images"); string pathToImage3 = (System.IO.Path.Combine(apppath, "(" + num.ToString() + ").jpg")); Bitmap bitmap3 = fp3.AsBitmap = new Bitmap(Image.FromFile(pathToImage3)); MyPerson personsdk3 = new MyPerson(); personsdk3.Fingerprints.Add(fp3); Afis.Extract(personsdk3); MyPerson match3 = Afis.Identify(personsdk3, personListRam).FirstOrDefault() as MyPerson; stopwatch4.Stop(); string stopwatchtime0 = stopwatch0.ElapsedMilliseconds.ToString(); string stopwatchtime1 = stopwatch1.ElapsedMilliseconds.ToString(); string stopwatchtime2 = stopwatch2.ElapsedMilliseconds.ToString(); string stopwatchtime3 = stopwatch3.ElapsedMilliseconds.ToString(); string stopwatchtime4 = stopwatch4.ElapsedMilliseconds.ToString(); Response.Write("<script>alert('Enrollment time in database is:" + stopwatchtime0 + "');</script>"); Response.Write("<script>alert('Enrollment time in ram is:" + stopwatchtime1 + "');</script>"); Response.Write("<script>alert('Verification time for index 1:" + stopwatchtime2 + "');</script>"); Response.Write("<script>alert('Verification time for index mid:" + stopwatchtime3 + "');</script>"); Response.Write("<script>alert('Verification time for index last:" + stopwatchtime4 + "');</script>"); return(View(mortal)); }
private void SetLoginUser(MyPerson user) { this.loginUser = user; }
private void processImportData() { string filename = txtBoxImportDataInputFile.Text; Console.WriteLine("###-->> filename = " + filename); progBarImportDataImportProgress.Visible = true; progBarImportDataImportProgress.Minimum = 1; progBarImportDataImportProgress.Maximum = 1000; progBarImportDataImportProgress.Value = 1; progBarImportDataImportProgress.Step = 1; try { //check if a valid export file has been selected if (string.IsNullOrEmpty(txtBoxImportDataInputFile.Text)) { MessageBox.Show("Must select an import file.", "Warning Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } List <string> columns = new List <string>(); DataAccess dataAccess = new DataAccess(); Int32 recordsInfile = 0; Int32 recordsInportedSuccessfully = 0; Int32 recordsFailedToImport = 0; using (var reader = new CsvFileReader(filename)) { while (reader.ReadRow(columns)) { if (recordsInfile > 0) //skip the Header Row { progBarImportDataImportProgress.PerformStep(); PersonDetail pDetail = new PersonDetail(); MyPerson person = new MyPerson(); System.Drawing.Image photo = null; string personId = columns[0] != null ? columns[0] : ""; string firstName = columns[1] != null ? columns[1] : ""; string lastName = columns[2] != null ? columns[2] : ""; string middleName = columns[3] != null ? columns[3] : ""; string prefix = columns[4] != null ? columns[4] : ""; string suffix = columns[5] != null ? columns[5] : ""; Console.WriteLine("###-->> DateStr = " + columns[6]); DateTime dob = columns[6] != null?Convert.ToDateTime(columns[6]) : new DateTime(1753, 1, 1); string streetAddr = columns[7] != null ? columns[7] : ""; string city = columns[8] != null ? columns[8] : ""; string state = columns[9] != null ? columns[9] : ""; string postalCode = columns[10] != null ? columns[10] : ""; string country = columns[11] != null ? columns[11] : ""; string profession = columns[12] != null ? columns[12] : ""; string fatherName = columns[13] != null ? columns[13] : ""; string cellNbr = columns[14] != null ? columns[14] : ""; string homeNbr = columns[15] != null ? columns[15] : ""; string workNbr = columns[16] != null ? columns[16] : ""; string email = columns[17] != null ? columns[17] : ""; string photoStr = columns[18] != null ? columns[18] : ""; if (!string.IsNullOrEmpty(photoStr)) { photo = Program.Base64ToImage(photoStr); } List <Fingerprint> fingerprints = new List <Fingerprint>(); //RT Fingerptint string rTStr = columns[19] != null ? columns[19] : ""; System.Drawing.Image rTImg = !string.IsNullOrEmpty(rTStr) ? Program.Base64ToImage(rTStr) : null; MyFingerprint rTFp = new MyFingerprint(); rTFp.Fingername = MyFingerprint.RightThumb; rTFp.AsBitmap = rTImg != null ? new System.Drawing.Bitmap(rTImg) : null; fingerprints.Add(rTFp); //RI Fingerprint string rIStr = columns[20] != null ? columns[20] : ""; System.Drawing.Image rIImg = !string.IsNullOrEmpty(rIStr) ? Program.Base64ToImage(rIStr) : null; MyFingerprint rIFp = new MyFingerprint(); rIFp.Fingername = MyFingerprint.RightIndex; rIFp.AsBitmap = rIImg != null ? new System.Drawing.Bitmap(rIImg) : null; fingerprints.Add(rIFp); //RM Fingerprint string rMStr = columns[21] != null ? columns[21] : ""; System.Drawing.Image rMImg = !string.IsNullOrEmpty(rMStr) ? Program.Base64ToImage(rMStr) : null; MyFingerprint rMFp = new MyFingerprint(); rMFp.Fingername = MyFingerprint.RightMiddle; rMFp.AsBitmap = rMImg != null ? new System.Drawing.Bitmap(rMImg) : null; fingerprints.Add(rMFp); //RR Fingerprint string rRStr = columns[22] != null ? columns[22] : ""; System.Drawing.Image rRImg = !string.IsNullOrEmpty(rMStr) ? Program.Base64ToImage(rRStr) : null; MyFingerprint rRFp = new MyFingerprint(); rRFp.Fingername = MyFingerprint.RightRing; rRFp.AsBitmap = rRImg != null ? new System.Drawing.Bitmap(rRImg) : null; fingerprints.Add(rRFp); //RL Fingerprint string rLStr = columns[23] != null ? columns[23] : ""; System.Drawing.Image rLImg = !string.IsNullOrEmpty(rLStr) ? Program.Base64ToImage(rLStr) : null; MyFingerprint rLFp = new MyFingerprint(); rLFp.Fingername = MyFingerprint.RightLittle; rLFp.AsBitmap = rLImg != null ? new System.Drawing.Bitmap(rLImg) : null; fingerprints.Add(rLFp); //LT Fingerprint string lTStr = columns[24] != null ? columns[24] : ""; System.Drawing.Image lTImg = !string.IsNullOrEmpty(lTStr) ? Program.Base64ToImage(lTStr) : null; MyFingerprint lTFp = new MyFingerprint(); lTFp.Fingername = MyFingerprint.LeftThumb; lTFp.AsBitmap = lTImg != null ? new System.Drawing.Bitmap(lTImg) : null; fingerprints.Add(lTFp); //LI Fingerprint string lIStr = columns[25] != null ? columns[25] : ""; System.Drawing.Image lIImg = !string.IsNullOrEmpty(lIStr) ? Program.Base64ToImage(lIStr) : null; MyFingerprint lIFp = new MyFingerprint(); lIFp.Fingername = MyFingerprint.LeftIndex; lIFp.AsBitmap = lIImg != null ? new System.Drawing.Bitmap(lIImg) : null; fingerprints.Add(lIFp); //LM Fingerprint string lMStr = columns[26] != null ? columns[26] : ""; System.Drawing.Image lMImg = !string.IsNullOrEmpty(lMStr) ? Program.Base64ToImage(lMStr) : null; MyFingerprint lMFp = new MyFingerprint(); lMFp.Fingername = MyFingerprint.LeftMiddle; lMFp.AsBitmap = lMImg != null ? new System.Drawing.Bitmap(lMImg) : null; fingerprints.Add(lMFp); //LR Fingerprint string lRStr = columns[27] != null ? columns[27] : ""; System.Drawing.Image lRImg = !string.IsNullOrEmpty(lRStr) ? Program.Base64ToImage(lRStr) : null; MyFingerprint lRFp = new MyFingerprint(); lRFp.Fingername = MyFingerprint.LeftRing; lRFp.AsBitmap = lRImg != null ? new System.Drawing.Bitmap(lRImg) : null; fingerprints.Add(lRFp); //LL Fingerprint string lLStr = columns[28] != null ? columns[28] : ""; System.Drawing.Image lLImg = !string.IsNullOrEmpty(lLStr) ? Program.Base64ToImage(lLStr) : null; MyFingerprint lLFp = new MyFingerprint(); lLFp.Fingername = MyFingerprint.LeftLittle; lLFp.AsBitmap = lLImg != null ? new System.Drawing.Bitmap(lLImg) : null; fingerprints.Add(lLFp); pDetail.setPersonId(personId); pDetail.setFirstName(firstName); pDetail.setLastName(lastName); pDetail.setMiddleName(middleName); pDetail.setPrefix(prefix); pDetail.setSuffix(suffix); pDetail.setDOB(dob); pDetail.setStreetAddress(streetAddr); pDetail.setCity(city); pDetail.setState(state); pDetail.setPostalCode(postalCode); pDetail.setCountry(country); pDetail.setProfession(profession); pDetail.setFatherName(fatherName); pDetail.setcellNbr(cellNbr); pDetail.setWorkPhoneNbr(workNbr); pDetail.setHomwPhoneNbr(homeNbr); pDetail.setEmail(email); pDetail.setPassportPhoto(photo); //store person's fingerprints ICollection <KeyValuePair <String, System.Drawing.Image> > fps = new Dictionary <String, System.Drawing.Image>(); if (rTImg != null) { fps.Add(new KeyValuePair <string, System.Drawing.Image>(MyFingerprint.RightThumb, rTImg)); } if (rIImg != null) { fps.Add(new KeyValuePair <string, System.Drawing.Image>(MyFingerprint.RightIndex, rIImg)); } if (rMImg != null) { fps.Add(new KeyValuePair <string, System.Drawing.Image>(MyFingerprint.RightMiddle, rMImg)); } if (rRImg != null) { fps.Add(new KeyValuePair <string, System.Drawing.Image>(MyFingerprint.RightRing, rRImg)); } if (rLImg != null) { fps.Add(new KeyValuePair <string, System.Drawing.Image>(MyFingerprint.RightLittle, rLImg)); } if (lTImg != null) { fps.Add(new KeyValuePair <string, System.Drawing.Image>(MyFingerprint.LeftThumb, lTImg)); } if (lIImg != null) { fps.Add(new KeyValuePair <string, System.Drawing.Image>(MyFingerprint.LeftIndex, lIImg)); } if (lMImg != null) { fps.Add(new KeyValuePair <string, System.Drawing.Image>(MyFingerprint.LeftMiddle, lMImg)); } if (lRImg != null) { fps.Add(new KeyValuePair <string, System.Drawing.Image>(MyFingerprint.LeftRing, lRImg)); } if (lLImg != null) { fps.Add(new KeyValuePair <string, System.Drawing.Image>(MyFingerprint.LeftLittle, lLImg)); } if (fps.Count > 0) { //get person with fingerprints person = Program.Enroll(fps, firstName, personId); } else { person = new MyPerson(); person.Name = firstName; person.PersonId = personId; } Console.WriteLine("###-->> PersonDetail = " + pDetail.getPersonId() + ", " + pDetail.getFirstName() + ", " + pDetail.getLastName()); Status status = dataAccess.storePersonDetailwithFingerprints(person, pDetail); if (status.getStatusCode() == Status.STATUS_SUCCESSFUL) { recordsInportedSuccessfully++; } else { recordsFailedToImport++; } Console.WriteLine("###-->> Status = " + status.getStatusDesc() + ". # of Successful import = " + recordsInportedSuccessfully + ", Failed import = " + recordsFailedToImport); } //end if recordsInfile++; } //end while progBarImportDataImportProgress.Maximum = recordsInfile; progBarImportDataImportProgress.PerformStep(); } Int32 totalImportedRecords = progBarImportDataImportProgress.Maximum - 1; //subtracting header activityLog.setActivity("Batch Import from a file - " + filename + ". Total # of records imported = " + totalImportedRecords + "\n"); lblImportDataTotalRecCount.Text = Convert.ToString(recordsInportedSuccessfully + recordsFailedToImport); lblDataImportSuccessCount.Text = Convert.ToString(recordsInportedSuccessfully); lblImportDataFailedCount.Text = Convert.ToString(recordsFailedToImport); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); MessageBox.Show(String.Format("Error reading from {0}.\r\n\r\n{1}", filename, ex.Message)); } finally { Cursor = Cursors.Default; } }
public MyPerson RunAtOnce(Packet pkt) { UserManager fpm = new UserManager(); MyPerson match = null; Code code; try { MyPerson guest = fpm.Enroll(BBDataConverter.ImageToByte(pkt.fingerPrint), "guest"); match = fpm.recognition(guest); if (match != null) { bool isMatch = CheckLoginUser(match.Id, pkt.userId); if (isMatch) { SetLoginUser(match); UpdateLogMsgWithName("Step1: Check fingerprint(" + "Matched person(" + match.Name.ToString() + ")" + ")"); code = Code.SUCCESS_AUTH; AccessInfo access = new AccessInfoDB().SelectNowAccessibleInfo(GetLoginUser().Guid, pkt.carId); if (access != null) { if (access.access_dt == default(DateTime)) { if (pkt.psgCnt == access.psgCnt) { UpdateLogMsgWithName("Step2: Check passenger count(" + access.psgCnt + ")"); code = Code.SUCCESS_PASSENGER; pkt.accessId = access.seq; OrderInfo order = new OrderInfoManager().FindOrderInfoByAccessId(access.seq); if (order != null) { UpdateLogMsgWithName("Step3: Find Order Info(" + order.orderId + ")"); pkt.order = order; code = Code.SUCCESS_ORDER; } else { code = Code.NOT_FND_ORDER_INFO; } } else { code = Code.NOT_MATCH_PASSENGER_CNT; } } else { code = Code.ALREADY_ACCESS; } } else { code = Code.NOT_FND_ACCESS_INFO; } } else { code = Code.NOT_MATCH_LOGIN_FP; } } else { Console.WriteLine("Not found matched fingerprint."); code = Code.NOT_FND_FINGERPRINT; } } catch (Exception e) { code = Code.ERROR; pkt.errMsg = e.Message; } if (code == Code.SUCCESS_AUTH || code == Code.SUCCESS_ORDER || code == Code.SUCCESS_PASSENGER) { UpdateLogMsgWithName("Success authentication."); // if code is SUCCESS, Open gate and update access date new AccessInfoDB().UpdateAccessDate(pkt.accessId); } else { UpdateLogMsgWithName("Failed authentication.(" + GetMessage(code.ToString()) + ")"); } SendResponse(pkt, code); return(match); }
public static float VerifyUserMatchRate(MyPerson tarUser, MyPerson refUser) { return(new AfisEngine().Verify(tarUser, refUser)); }
private void processBatchExport() { string fileName = txtBoxBatchExportFile.Text; try { //check if a valid export file has been selected if (string.IsNullOrEmpty(fileName)) { MessageBox.Show("Must select an export file.", "Warning Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //Progress bar DataAccess dataAccess = new DataAccess(); Int32 personCount = dataAccess.getPersonCount(); Console.WriteLine("###-->>Total number of person records = " + personCount); activityLog.setActivity("Batch Export to a file - " + fileName + ". Totall record exported = " + personCount + "\n"); progressBarBatchExport.Visible = true; progressBarBatchExport.Minimum = 1; progressBarBatchExport.Maximum = personCount; progressBarBatchExport.Value = 1; progressBarBatchExport.Step = 1; using (var writer = new CsvFileWriter(fileName)) { //add the headers List <string> columns = new List <string>(); columns.Add("Person Id"); columns.Add("First Name"); columns.Add("Last Name"); columns.Add("Middle Name"); columns.Add("Prefix"); columns.Add("Suffix"); columns.Add("DOB"); columns.Add("Street"); columns.Add("City"); columns.Add("State"); columns.Add("Postal Code"); columns.Add("Country"); columns.Add("Profession"); columns.Add("Father Name"); columns.Add("Cell Nbr"); columns.Add("Home Nbr"); columns.Add("Work Nbr"); columns.Add("Email"); columns.Add("Photo"); columns.Add("RT"); columns.Add("RI"); columns.Add("RM"); columns.Add("RR"); columns.Add("RL"); columns.Add("LT"); columns.Add("LI"); columns.Add("LM"); columns.Add("LR"); columns.Add("LL"); writer.WriteRow(columns); List <PersonDetail> persons = dataAccess.getPersons(); foreach (PersonDetail personDetail in persons) { progressBarBatchExport.PerformStep(); MyPerson person = dataAccess.retrievePersonFingerprintsById(personDetail.getPersonId()).FirstOrDefault(); List <Fingerprint> fingerprints = person.Fingerprints; columns = new List <string>(); columns.Add(personDetail.getPersonId() ?? String.Empty); columns.Add(personDetail.getFirstName() ?? String.Empty); columns.Add(personDetail.getLastName() ?? String.Empty); columns.Add(personDetail.getMiddleName() ?? String.Empty); columns.Add(personDetail.getPrefix() ?? String.Empty); columns.Add(personDetail.getSuffix() ?? String.Empty); columns.Add(personDetail.getDOB().ToString() ?? String.Empty); columns.Add(personDetail.getStreetAddress() ?? String.Empty); columns.Add(personDetail.getCity() ?? String.Empty); columns.Add(personDetail.getState() ?? String.Empty); columns.Add(personDetail.getPostalCode() ?? String.Empty); columns.Add(personDetail.getCountry() ?? String.Empty); columns.Add(personDetail.getProfession() ?? String.Empty); columns.Add(personDetail.getFatherName() ?? String.Empty); columns.Add(personDetail.getCellNbr() ?? String.Empty); columns.Add(personDetail.getHomePhoneNbr() ?? String.Empty); columns.Add(personDetail.getWorkPhoneNbr() ?? String.Empty); columns.Add(personDetail.getEmail() ?? String.Empty); //Passport photo System.Drawing.Image photo = personDetail.getPassportPhoto(); string photoStr = (photo != null) ? Program.ImageToBase64(personDetail.getPassportPhoto(), System.Drawing.Imaging.ImageFormat.Bmp) : null; columns.Add(photoStr ?? String.Empty); //RT fingerprint System.Drawing.Image rT = getFingerprintImage(fingerprints, MyFingerprint.RightThumb); string rTStr = (rT != null) ? Program.ImageToBase64(rT, System.Drawing.Imaging.ImageFormat.Bmp) : null; columns.Add(rTStr ?? String.Empty); //RI fingerprint System.Drawing.Image rI = getFingerprintImage(fingerprints, MyFingerprint.RightIndex); string rIStr = (rI != null) ? Program.ImageToBase64(rI, System.Drawing.Imaging.ImageFormat.Bmp) : null; columns.Add(rIStr ?? String.Empty); //RM fingerprint System.Drawing.Image rM = getFingerprintImage(fingerprints, MyFingerprint.RightMiddle); string rMStr = (rM != null) ? Program.ImageToBase64(rM, System.Drawing.Imaging.ImageFormat.Bmp) : null; columns.Add(rMStr ?? String.Empty); //RR fingerprint System.Drawing.Image rR = getFingerprintImage(fingerprints, MyFingerprint.RightRing); string rRStr = (rR != null) ? Program.ImageToBase64(rR, System.Drawing.Imaging.ImageFormat.Bmp) : null; columns.Add(rRStr ?? String.Empty); //RL fingerprint System.Drawing.Image rL = getFingerprintImage(fingerprints, MyFingerprint.RightLittle); string rLStr = (rL != null) ? Program.ImageToBase64(rL, System.Drawing.Imaging.ImageFormat.Bmp) : null; columns.Add(rLStr ?? String.Empty); //LT fingerprint System.Drawing.Image lT = getFingerprintImage(fingerprints, MyFingerprint.LeftThumb); string lTStr = (lT != null) ? Program.ImageToBase64(lT, System.Drawing.Imaging.ImageFormat.Bmp) : null; columns.Add(lTStr ?? String.Empty); //LI fingerprint System.Drawing.Image lI = getFingerprintImage(fingerprints, MyFingerprint.LeftIndex); string lIStr = (lI != null) ? Program.ImageToBase64(lI, System.Drawing.Imaging.ImageFormat.Bmp) : null; columns.Add(lIStr ?? String.Empty); //LM fingerprint System.Drawing.Image lM = getFingerprintImage(fingerprints, MyFingerprint.LeftMiddle); string lMStr = (lM != null) ? Program.ImageToBase64(lM, System.Drawing.Imaging.ImageFormat.Bmp) : null; columns.Add(lMStr ?? String.Empty); //LR fingerprint System.Drawing.Image lR = getFingerprintImage(fingerprints, MyFingerprint.LeftRing); string lRStr = (lR != null) ? Program.ImageToBase64(lR, System.Drawing.Imaging.ImageFormat.Bmp) : null; columns.Add(lRStr ?? String.Empty); //LL fingerprint System.Drawing.Image lL = getFingerprintImage(fingerprints, MyFingerprint.LeftLittle); string lLStr = (lL != null) ? Program.ImageToBase64(lL, System.Drawing.Imaging.ImageFormat.Bmp) : null; columns.Add(lLStr ?? String.Empty); writer.WriteRow(columns); }//end foreach lblBatchExportTotalRec.Text = "Total # of exported records = " + persons.Count; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); MessageBox.Show(String.Format("Error reading from {0}.\r\n\r\n{1}", fileName, ex.Message)); } }//end processBatchExport
public void recognition(string filename, string username) { MyPerson probeUser = Enroll(filename, username); recognition(probeUser); }
public static void generatePersonDetailReport(User user, string personId) { List <PersonDetail> personDetailList = new DataAccess().retrievePersonDetail(personId); Console.WriteLine("# of Persons found = " + personDetailList.Count()); PersonDetail personDetail = personDetailList.FirstOrDefault(); //Paragraph Title Font iTextSharp.text.Font paragraphTitleFont = FontFactory.GetFont("Arial", 16); iTextSharp.text.Font paragraphSubTitleFont = FontFactory.GetFont("Arial", 14); Document doc = new Document(iTextSharp.text.PageSize.LETTER, 30, 30, 42, 35); string datetimePref = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"); string pdfPath = ConfigurationManager.AppSettings["PersonReportPath"] + "-" + datetimePref + ".pdf"; PdfWriter pdfWriter = PdfWriter.GetInstance(doc, new FileStream(pdfPath, FileMode.Create)); //Event for Watermark PdfWriterEvents writerEvent = new PdfWriterEvents(ConfigurationManager.AppSettings["WatermarkConfidential"]); pdfWriter.PageEvent = writerEvent; //Event for Page number PageEventHelper pageEventHelper = new PageEventHelper(); pdfWriter.PageEvent = pageEventHelper; doc.Open(); //add title doc.AddTitle("Person Detail Report"); doc.AddHeader("Person Detail Report", "Person Detail Report"); //Add Company Logo & Company Name PdfPTable logoAndTitle = new PdfPTable(2); float[] cellWidths = new float[] { 100f, 100f }; logoAndTitle.SetWidths(cellWidths); iTextSharp.text.Image iTextCompanyLogoImage = null; if (AFISMain.clientSetup != null) { if (AFISMain.clientSetup.CompanyLogo != null) { iTextCompanyLogoImage = iTextSharp.text.Image.GetInstance(AFISMain.clientSetup.CompanyLogo, System.Drawing.Imaging.ImageFormat.Bmp); iTextCompanyLogoImage.ScaleAbsolute(60f, 60f); } } else { //Default image in case, image is not available iTextCompanyLogoImage = iTextSharp.text.Image.GetInstance(ConfigurationManager.AppSettings["DefaultCompanyLogo"]); } logoAndTitle.AddCell(new PdfPCell(iTextCompanyLogoImage)); string titleStr = AFISMain.clientSetup.LegalName + "\n" + AFISMain.clientSetup.AddressLine + "\n" + AFISMain.clientSetup.City + ", " + AFISMain.clientSetup.State + " " + AFISMain.clientSetup.PostalCode + "\n" + AFISMain.clientSetup.Country + "\n"; logoAndTitle.AddCell(new PdfPCell(new Phrase(titleStr, paragraphTitleFont))); doc.Add(logoAndTitle); iTextSharp.text.Font contentFont = iTextSharp.text.FontFactory.GetFont("Webdings", 20, iTextSharp.text.Font.BOLD); Paragraph paragraphReportTitle = new Paragraph("Person Detail Report\n", contentFont); paragraphReportTitle.Alignment = Element.ALIGN_CENTER; Paragraph paragraphReportSubTitle = new Paragraph(); paragraphReportSubTitle.Add("By: " + user.getFirstName() + " " + user.getLastName() + ", ID: " + user.getPersonId() + "\n"); paragraphReportSubTitle.Add("At: " + DateTime.Now.ToString() + "\n"); paragraphReportSubTitle.Alignment = Element.ALIGN_CENTER; doc.Add(paragraphReportTitle); doc.Add(paragraphReportSubTitle); if (personDetail != null) { //Adding the Passport size photo System.Drawing.Image passportPhoto = personDetail.getPassportPhoto(); if (passportPhoto != null) { iTextSharp.text.Image passportPic = iTextSharp.text.Image.GetInstance(passportPhoto, System.Drawing.Imaging.ImageFormat.Bmp); passportPic.ScaleAbsolute(120f, 120f); doc.Add(passportPic); } //Adding the person detail Paragraph paragraphDemographyTitle = new Paragraph("Demographic Information:\n", paragraphTitleFont); doc.Add(paragraphDemographyTitle); Paragraph paragraphDemographyDetail = new Paragraph(); paragraphDemographyDetail.Add("ID: " + personDetail.getPersonId() + "\n"); paragraphDemographyDetail.Add("Name: " + " " + personDetail.getPrefix() + " " + personDetail.getFirstName() + " " + personDetail.getMiddleName() + " " + personDetail.getLastName() + " " + personDetail.getSuffix() + "\n"); paragraphDemographyDetail.Add("Date of Birth (DOB): " + ((DateTime)personDetail.getDOB()).ToString("yyyy-MM-dd") + "\n"); paragraphDemographyDetail.Add("Father's Name: " + personDetail.getFatherName() + "\n"); paragraphDemographyDetail.Add("Address: " + personDetail.getStreetAddress() + ", " + personDetail.getCity() + ", " + personDetail.getState() + " " + personDetail.getPostalCode() + ", " + personDetail.getCountry() + "\n"); paragraphDemographyDetail.Add("Profession: " + personDetail.getProfession() + "\n"); paragraphDemographyDetail.Add("Cell#: " + personDetail.getCellNbr() + ", Home Phone#: " + personDetail.getHomePhoneNbr() + ", Work Phone#: " + personDetail.getWorkPhoneNbr() + "\n"); paragraphDemographyDetail.Add("Email: " + personDetail.getEmail() + "\n\n"); doc.Add(paragraphDemographyDetail); } //Adding Person's Physical Characteristocs DataAccess dataAccess = new DataAccess(); PersonPhysicalChar personPhysicalChar = dataAccess.retrievePersonPhysicalCharacteristics(personId); if (personPhysicalChar != null) { Paragraph paragraphPhysicalCharTitle = new Paragraph("Physical Characteristics:\n", paragraphTitleFont); doc.Add(paragraphPhysicalCharTitle); Paragraph paragraphPhysicalChar = new Paragraph(); paragraphPhysicalChar.Add("Height: " + personPhysicalChar.Height + ", Weight: " + personPhysicalChar.Weight + ", Eye Color: " + personPhysicalChar.EyeColor); paragraphPhysicalChar.Add(", Hair Color: " + personPhysicalChar.HairColor + "\n"); paragraphPhysicalChar.Add("Complexion: " + personPhysicalChar.Complexion + ", Build Type: " + personPhysicalChar.BuildType); paragraphPhysicalChar.Add(", Birth Mark: " + personPhysicalChar.BirthMark + ", Other Identifiable Mark: " + personPhysicalChar.IdMark + "\n"); string dod = personPhysicalChar.DOD.ToString("yyyy") == "9998" ? "N/A" : personPhysicalChar.DOD.ToString("yyyy-MM-dd"); paragraphPhysicalChar.Add("Gender: " + personPhysicalChar.Gender + ", Date Of Death: " + dod + "\n\n"); doc.Add(paragraphPhysicalChar); } //Adding Person's Criminal records List <CriminalRecord> criminalRecs = dataAccess.getCriminalRecords(personId); Console.WriteLine("###-->> # of Criminal recotds = " + criminalRecs.Count); if (criminalRecs.Count > 0) { Paragraph paragraphCriminalRecs = new Paragraph("Criminal Records:\n", paragraphTitleFont); doc.Add(paragraphCriminalRecs); foreach (CriminalRecord criminalRec in criminalRecs) { Paragraph paragraphCriminalRecCaseId = new Paragraph("Case ID - " + criminalRec.CaseId + ":", paragraphSubTitleFont); doc.Add(paragraphCriminalRecCaseId); Paragraph paragraphCriminalRec = new Paragraph(); string crimeDate = criminalRec.CrimeDate.ToString("yyyy") == "9998" ? "N/A" : criminalRec.CrimeDate.ToString("yyyy-MM-dd"); string arrestDate = criminalRec.ArrestDate.ToString("yyyy") == "9998" ? "N/A" : criminalRec.ArrestDate.ToString("yyyy-MM-dd"); string sentenceDate = criminalRec.SentencedDate.ToString("yyyy") == "9998" ? "N/A" : criminalRec.SentencedDate.ToString("yyyy-MM-dd"); string releaseDate = criminalRec.ReleaseDate.ToString("yyyy") == "9998" ? "N/A" : criminalRec.ReleaseDate.ToString("yyyy-MM-dd"); string paroleDate = criminalRec.ParoleDate.ToString("yyyy") == "9998" ? "N/A" : criminalRec.ParoleDate.ToString("yyyy-MM-dd"); paragraphCriminalRec.Add("Crime Date: " + crimeDate + ", Crime Location: " + criminalRec.CrimeLocation + "\n"); paragraphCriminalRec.Add("Court: " + criminalRec.Court + ", Court Address: " + criminalRec.CourtAddress + ", Statute: " + criminalRec.Statute + "\n"); paragraphCriminalRec.Add("Arret Date: " + arrestDate + ", Arrest Agency: " + criminalRec.ArrestAgency + "\n"); paragraphCriminalRec.Add("Sentence Date: " + sentenceDate + ", Release Date: " + releaseDate + ", Parole date: " + paroleDate + "\n"); paragraphCriminalRec.Add("Criminal Alert Level: " + criminalRec.CriminalAlertLevel + ", Criminal Alert Message: " + criminalRec.CriminalAlertMsg + "\n"); paragraphCriminalRec.Add("Crime Detail: " + criminalRec.CrimeDetail + "\n"); doc.Add(paragraphCriminalRec); } Paragraph paragraphNewLine = new Paragraph(); paragraphNewLine.Add("\n"); doc.Add(paragraphNewLine); } //add table for fingerprints Paragraph paragraphFingerprints = new Paragraph("Fingerprint(s):\n\n", paragraphTitleFont); doc.Add(paragraphFingerprints); PdfPTable fingerprintsTable = new PdfPTable(5); float[] widths = new float[] { 40f, 40f, 40f, 40f, 40f }; fingerprintsTable.SetWidths(widths); //Add Headers to the table fingerprintsTable.AddCell(new PdfPCell(new Phrase("RT"))); fingerprintsTable.AddCell(new PdfPCell(new Phrase("RI"))); fingerprintsTable.AddCell(new PdfPCell(new Phrase("RM"))); fingerprintsTable.AddCell(new PdfPCell(new Phrase("RR"))); fingerprintsTable.AddCell(new PdfPCell(new Phrase("RL"))); PdfPCell imageRTCell = null; PdfPCell imageRICell = null; PdfPCell imageRMCell = null; PdfPCell imageRRCell = null; PdfPCell imageRLCell = null; PdfPCell imageLTCell = null; PdfPCell imageLICell = null; PdfPCell imageLMCell = null; PdfPCell imageLRCell = null; PdfPCell imageLLCell = null; //Default image in case, image is not available iTextSharp.text.Image iTextDefaultFpImage = iTextSharp.text.Image.GetInstance(ConfigurationManager.AppSettings["DefaultFpImagePath"]); List <MyPerson> persons = new DataAccess().retrievePersonFingerprintsById(personId); Console.WriteLine("####-->> # of persons retrived = " + persons.Count); if (persons.Count > 0) { MyPerson person = persons.FirstOrDefault(); //Get all the fingerprints of the matched person List <Fingerprint> fps = person.Fingerprints; Console.WriteLine("###-->> # of Fps retrived = " + fps.Count); for (int i = 0; i < fps.Count; i++) { MyFingerprint fp = (MyFingerprint)fps.ElementAt(i); if (fp.Fingername != null) { if (fp.Fingername.Equals(MyFingerprint.RightThumb)) { System.Drawing.Image imageRT = fp.AsBitmap; if (imageRT != null) { Console.WriteLine("###-->> RT"); iTextSharp.text.Image iTextImgRT = iTextSharp.text.Image.GetInstance(imageRT, System.Drawing.Imaging.ImageFormat.Bmp); iTextImgRT.ScaleAbsolute(60f, 60f); imageRTCell = new PdfPCell(iTextImgRT); imageRTCell.HorizontalAlignment = Element.ALIGN_CENTER; imageRTCell.VerticalAlignment = Element.ALIGN_MIDDLE; } } else if (fp.Fingername.Equals(MyFingerprint.RightIndex)) { System.Drawing.Image imageRI = fp.AsBitmap; if (imageRI != null) { Console.WriteLine("###-->> RI"); iTextSharp.text.Image iTextImgRI = iTextSharp.text.Image.GetInstance(imageRI, System.Drawing.Imaging.ImageFormat.Bmp); iTextImgRI.ScaleAbsolute(60f, 60f); imageRICell = new PdfPCell(iTextImgRI); imageRICell.HorizontalAlignment = Element.ALIGN_CENTER; imageRICell.VerticalAlignment = Element.ALIGN_MIDDLE; } } else if (fp.Fingername.Equals(MyFingerprint.RightMiddle)) { System.Drawing.Image imageRM = fp.AsBitmap; if (imageRM != null) { Console.WriteLine("###-->> RM"); iTextSharp.text.Image iTextImgRM = iTextSharp.text.Image.GetInstance(imageRM, System.Drawing.Imaging.ImageFormat.Bmp); iTextImgRM.ScaleAbsolute(60f, 60f); imageRMCell = new PdfPCell(iTextImgRM); imageRMCell.HorizontalAlignment = Element.ALIGN_CENTER; imageRMCell.VerticalAlignment = Element.ALIGN_MIDDLE; } } else if (fp.Fingername.Equals(MyFingerprint.RightRing)) { System.Drawing.Image imageRR = fp.AsBitmap; if (imageRR != null) { Console.WriteLine("###-->> RR"); iTextSharp.text.Image iTextImgRR = iTextSharp.text.Image.GetInstance(imageRR, System.Drawing.Imaging.ImageFormat.Bmp); iTextImgRR.ScaleAbsolute(60f, 60f); imageRRCell = new PdfPCell(iTextImgRR); imageRRCell.HorizontalAlignment = Element.ALIGN_CENTER; imageRRCell.VerticalAlignment = Element.ALIGN_MIDDLE; } } else if (fp.Fingername.Equals(MyFingerprint.RightLittle)) { System.Drawing.Image imageRL = fp.AsBitmap; if (imageRL != null) { Console.WriteLine("###-->> RL"); iTextSharp.text.Image iTextImgRL = iTextSharp.text.Image.GetInstance(imageRL, System.Drawing.Imaging.ImageFormat.Bmp); iTextImgRL.ScaleAbsolute(60f, 60f); imageRLCell = new PdfPCell(iTextImgRL); imageRLCell.HorizontalAlignment = Element.ALIGN_CENTER; imageRLCell.VerticalAlignment = Element.ALIGN_MIDDLE; } } else if (fp.Fingername.Equals(MyFingerprint.LeftThumb)) { System.Drawing.Image imageLT = fp.AsBitmap; if (imageLT != null) { Console.WriteLine("###-->> LT"); iTextSharp.text.Image iTextImgLT = iTextSharp.text.Image.GetInstance(imageLT, System.Drawing.Imaging.ImageFormat.Bmp); iTextImgLT.ScaleAbsolute(60f, 60f); imageLTCell = new PdfPCell(iTextImgLT); imageLTCell.HorizontalAlignment = Element.ALIGN_CENTER; imageLTCell.VerticalAlignment = Element.ALIGN_MIDDLE; } } else if (fp.Fingername.Equals(MyFingerprint.LeftIndex)) { System.Drawing.Image imageLI = fp.AsBitmap; if (imageLI != null) { Console.WriteLine("###-->> LI"); iTextSharp.text.Image iTextImgLI = iTextSharp.text.Image.GetInstance(imageLI, System.Drawing.Imaging.ImageFormat.Bmp); iTextImgLI.ScaleAbsolute(60f, 60f); imageLICell = new PdfPCell(iTextImgLI); imageLICell.HorizontalAlignment = Element.ALIGN_CENTER; imageLICell.VerticalAlignment = Element.ALIGN_MIDDLE; } } else if (fp.Fingername.Equals(MyFingerprint.LeftMiddle)) { System.Drawing.Image imageLM = fp.AsBitmap; if (imageLM != null) { Console.WriteLine("###-->> LM"); iTextSharp.text.Image iTextImgLM = iTextSharp.text.Image.GetInstance(imageLM, System.Drawing.Imaging.ImageFormat.Bmp); iTextImgLM.ScaleAbsolute(60f, 60f); imageLMCell = new PdfPCell(iTextImgLM); imageLMCell.HorizontalAlignment = Element.ALIGN_CENTER; imageLMCell.VerticalAlignment = Element.ALIGN_MIDDLE; } } else if (fp.Fingername.Equals(MyFingerprint.LeftRing)) { System.Drawing.Image imageLR = fp.AsBitmap; if (imageLR != null) { Console.WriteLine("###-->> LR"); iTextSharp.text.Image iTextImgLR = iTextSharp.text.Image.GetInstance(imageLR, System.Drawing.Imaging.ImageFormat.Bmp); iTextImgLR.ScaleAbsolute(60f, 60f); imageLRCell = new PdfPCell(iTextImgLR); imageLRCell.HorizontalAlignment = Element.ALIGN_CENTER; imageLRCell.VerticalAlignment = Element.ALIGN_MIDDLE; } } else if (fp.Fingername.Equals(MyFingerprint.LeftLittle)) { System.Drawing.Image imageLL = fp.AsBitmap; if (imageLL != null) { Console.WriteLine("###-->> LL"); iTextSharp.text.Image iTextImgLL = iTextSharp.text.Image.GetInstance(imageLL, System.Drawing.Imaging.ImageFormat.Bmp); iTextImgLL.ScaleAbsolute(60f, 60f); imageLLCell = new PdfPCell(iTextImgLL); imageLLCell.HorizontalAlignment = Element.ALIGN_CENTER; imageLLCell.VerticalAlignment = Element.ALIGN_MIDDLE; } } } } //add the Right-Hand fingerprints if (imageRTCell != null) { fingerprintsTable.AddCell(imageRTCell); } else { fingerprintsTable.AddCell(new PdfPCell(iTextDefaultFpImage, true)); } if (imageRICell != null) { fingerprintsTable.AddCell(imageRICell); } else { fingerprintsTable.AddCell(new PdfPCell(iTextDefaultFpImage, true)); } if (imageRMCell != null) { fingerprintsTable.AddCell(imageRMCell); } else { fingerprintsTable.AddCell(new PdfPCell(iTextDefaultFpImage, true)); } if (imageRRCell != null) { fingerprintsTable.AddCell(imageRRCell); } else { fingerprintsTable.AddCell(new PdfPCell(iTextDefaultFpImage, true)); } if (imageRLCell != null) { fingerprintsTable.AddCell(imageRLCell); } else { fingerprintsTable.AddCell(new PdfPCell(iTextDefaultFpImage, true)); } //add 2nd row on the table fingerprintsTable.AddCell(new PdfPCell(new Phrase("LT"))); fingerprintsTable.AddCell(new PdfPCell(new Phrase("LI"))); fingerprintsTable.AddCell(new PdfPCell(new Phrase("LM"))); fingerprintsTable.AddCell(new PdfPCell(new Phrase("LR"))); fingerprintsTable.AddCell(new PdfPCell(new Phrase("LL"))); //add the Left-Hand fingerprints if (imageLTCell != null) { fingerprintsTable.AddCell(imageLTCell); } else { fingerprintsTable.AddCell(new PdfPCell(iTextDefaultFpImage, true)); } if (imageLICell != null) { fingerprintsTable.AddCell(imageLICell); } else { fingerprintsTable.AddCell(new PdfPCell(iTextDefaultFpImage, true)); } if (imageLMCell != null) { fingerprintsTable.AddCell(imageLMCell); } else { fingerprintsTable.AddCell(new PdfPCell(iTextDefaultFpImage, true)); } if (imageLRCell != null) { fingerprintsTable.AddCell(imageLRCell); } else { fingerprintsTable.AddCell(new PdfPCell(iTextDefaultFpImage, true)); } if (imageLLCell != null) { fingerprintsTable.AddCell(imageLLCell); } else { fingerprintsTable.AddCell(new PdfPCell(iTextDefaultFpImage, true)); } }//end-if - persons //add Table for fingerprints doc.Add(fingerprintsTable); doc.Close(); Console.WriteLine("PDF Generated successfully..."); System.Diagnostics.Process.Start(pdfPath); }//end generatePersonDetailReport
void networkcontrol_NewCommand() { this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate() { String str; lock (networkcontrol.CommandList_receive) { str = networkcontrol.CommandList_receive.Dequeue(); } String[] chips = str.Split(';'); MyPerson person = null; if (chips[0] == "person") { if (chips[1] == "1") { person = person1; } else if (chips[1] == "2") { person = person2; } person.position = new System.Drawing.Point(Int32.Parse(chips[2]), Int32.Parse(chips[3])); if (chips[4] == "left") { person.direction = MyPerson.Direction.Left; } if (chips[4] == "right") { person.direction = MyPerson.Direction.Right; } if (chips[4] == "up") { person.direction = MyPerson.Direction.Up; } if (chips[4] == "down") { person.direction = MyPerson.Direction.Down; } MoveOfPerson(person); } else if (chips[0] == "bomb") { if (chips[1] == "1") { person1.mp -= 20; } else if (chips[1] == "2") { person2.mp -= 20; } int i = Int32.Parse(chips[4]); TypeOfBomb type = TypeOfBomb.normal; switch (i) { case 0: type = TypeOfBomb.normal; break; case 1: type = TypeOfBomb.around_small; break; case 2: type = TypeOfBomb.around_big; break; case 3: type = TypeOfBomb.row; break; case 4: type = TypeOfBomb.column; break; case 5: type = TypeOfBomb.row_column; break; case 6: type = TypeOfBomb.diagonal; break; } SetBomb(new System.Drawing.Point(Int32.Parse(chips[2]), Int32.Parse(chips[3])), 3000, type); Paragraph p = new Paragraph(new Run("->请注意炸弹!")); Tip.Document.Blocks.Add(p); Tip.ScrollToEnd(); } else if (chips[0] == "brick") { List <System.Drawing.Point> temp = new List <System.Drawing.Point>(); for (int i = 3; i < chips.Length; i++) { String[] s = chips[i].Split(','); temp.Add(new System.Drawing.Point(Int32.Parse(s[0]), Int32.Parse(s[1]))); } if (chips[1] == "creat") { RefreshBlock(temp, true); } else if (chips[1] == "delete") { RefreshBlock(temp, false); } } else if (chips[0] == "drug") { int pid = Int32.Parse(chips[2]); if (chips[1] == "h") { setHpDrug(pid); } else if (chips[1] == "m") { setMpDrug(pid); } Paragraph p = new Paragraph(new Run("->新的药品出现")); Tip.Document.Blocks.Add(p); Tip.ScrollToEnd(); } else if (chips[0] == "reset") { if (chips[1] == "1") { person1.hp = Int32.Parse(chips[2]); person1.mp = Int32.Parse(chips[3]); } else if (chips[1] == "2") { person2.hp = Int32.Parse(chips[2]); person2.mp = Int32.Parse(chips[3]); } } else if (chips[0] == "start!") { Paragraph p = new Paragraph(new Run("->游戏开始!")); Tip.Document.Blocks.Add(p); Tip.ScrollToEnd(); GameInit(); } else { Paragraph p; if (str.StartsWith("Client")) { p = new Paragraph(new Run(str) { Foreground = new SolidColorBrush(Colors.Green) }); } else { p = new Paragraph(new Run(str) { Foreground = new SolidColorBrush(Colors.Red) }); } Message.Document.Blocks.Add(p); Message.ScrollToEnd(); } }); }
public static void Main() { // Structure with a pointer to another structure. MyPerson personName; personName.first = "Mark"; personName.last = "Lee"; MyPerson2 personAll; personAll.age = 30; IntPtr buffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(personName)); Marshal.StructureToPtr(personName, buffer, false); personAll.person = buffer; Console.WriteLine("\nPerson before call:"); Console.WriteLine("first = {0}, last = {1}, age = {2}", personName.first, personName.last, personAll.age); int res = LibWrap.TestStructInStruct(ref personAll); MyPerson personRes = (MyPerson)Marshal.PtrToStructure(personAll.person, typeof(MyPerson)); Marshal.FreeCoTaskMem(buffer); Console.WriteLine("Person after call:"); Console.WriteLine("first = {0}, last = {1}, age = {2}", personRes.first, personRes.last, personAll.age); // Structure with an embedded structure. MyPerson3 person3 = new MyPerson3(); person3.person.first = "John"; person3.person.last = "Evans"; person3.age = 27; LibWrap.TestStructInStruct3(person3); // Structure with an embedded array. MyArrayStruct myStruct = new MyArrayStruct(); myStruct.flag = false; myStruct.vals = new int[3]; myStruct.vals[0] = 1; myStruct.vals[1] = 4; myStruct.vals[2] = 9; Console.WriteLine("\nStructure with array before call:"); Console.WriteLine(myStruct.flag); Console.WriteLine("{0} {1} {2}", myStruct.vals[0], myStruct.vals[1], myStruct.vals[2]); LibWrap.TestArrayInStruct(ref myStruct); Console.WriteLine("\nStructure with array after call:"); Console.WriteLine(myStruct.flag); Console.WriteLine("{0} {1} {2}", myStruct.vals[0], myStruct.vals[1], myStruct.vals[2]); }
// async Task<ViewQueryResponse<string>> GetPersonListAsync () async Task GetPersonListAsync(Container container) { //List<MyPerson> database = new List<MyPerson>(); //List<MyPerson> database = FilesService.Database; //string sourceDirectory = @"/Users/chrisk/source/KiwiRest/RestFiles/App_Data/files"; //AfisEngine Afis = new AfisEngine(); DateTime date1 = DateTime.Now; Console.WriteLine("Starting FingerprintDatabase: " + date1); // WebClient client = new WebClient (); //string uri = "http://localhost:5984/prints/_all_docs&include_docs=true"; // string data = client.DownloadString (uri); // var fromJson = JsonSerializer.DeserializeFromString<AllDocs>(data); var myCouchClient = new MyCouch.MyCouchClient("http://localhost:5984/prints"); ViewQueryResponse <string> result = null; try { var queryView = new QueryViewRequest("_all_docs"); queryView.Configure(query => query .IncludeDocs(true)); result = await myCouchClient.Views.QueryAsync <string>(queryView); var rows = result.Rows; // foreach (ViewQueryResponse<SimpleFingerprint> row in rows) foreach (ViewQueryResponse <string, string> .Row row in rows) { Console.WriteLine("Lookin' at " + row); string doc = row.IncludedDoc; var person = new MyPerson(); // SimpleFingerprint print = TypeSerializer.DeserializeFromString<SimpleFingerprint>(doc); var jsonObj = JsonSerializer.DeserializeFromString <JsonObject>(doc); person._id = jsonObj["_id"]; var jsonFingerprints = jsonObj["simpleFingerprint"]; //var Filename = jsonObj["Filename"]; // var serialFingerprints = JsonSerializer.DeserializeFromString<List<JsonObject>>(jsonFingerprints); var serialFingerprints = JsonArrayObjects.Parse(jsonFingerprints); //var fps = JsonSerializer.DeserializeFromString<Dictionary<string, string>>(jsonFingerprints); //var fp = JsonSerializer.DeserializeFromString<JsonObject>(jsonObj["simpleFingerprint"]); //SimpleFingerprint sf = JsonSerializer.DeserializeFromString<SimpleFingerprint>(jsonObj["simpleFingerprint"]); List <Fingerprint> fingerprints = new List <Fingerprint> (); foreach (KeyValuePair <string, string> pair in serialFingerprints[0]) { Fingerprint simpleFingerprint = new Fingerprint(); String value = pair.Value; if (value != null) { char[] delimiterChars = { ':' }; string[] printPair = value.Split(delimiterChars); if (printPair[0] == "Base64Template") { byte[] printArray = System.Convert.FromBase64String(printPair[1]); simpleFingerprint.Template = printArray; fingerprints.Add(simpleFingerprint); } } //var print = printPair[1]; //byte[] printArray = System.Convert.FromBase64String(print); //simpleFingerprint.Template = printArray; // simpleFingerprint.Filename = Filename; //fingerprints.Add(simpleFingerprint); // foreach (KeyValuePair<string,string> pair in fprint) { // SimpleFingerprint simpleFingerprint = new SimpleFingerprint (); // var strBase64Template = JsonSerializer.DeserializeFromString<string>(pair.Key); //// simpleFingerprint.Base64Template = strBase64Template["Base64Template"]; // fingerprints.Add(simpleFingerprint); // } } // foreach (KeyValuePair<string,string> pair in serialFingerprints) // { // var prints = JsonSerializer.DeserializeFromString<JsonObject>(pair.Key); // foreach (KeyValuePair<string,string> print in prints) // { // SimpleFingerprint simpleFingerprint = new SimpleFingerprint (); // var strBase64Template = JsonSerializer.DeserializeFromString<string>(print.Key); //// simpleFingerprint.Base64Template = print["Base64Template"]; // fingerprints.Add(simpleFingerprint); // } // } person.Fingerprints = fingerprints; //person.Filename = jsonObj["Filename"]; person.Uuid = jsonObj["Uuid"]; //database.Add(person); FingerprintDatabase.AddData(person); Console.WriteLine("Added person to FingerprintDatabase."); } //container.Register(database); } catch (Exception e) { Console.WriteLine("Error: " + e); } // return result; }