private void NewMethod_verify() { AFISVerificationResult result = new AFISVerificationResult(); LocalUser user_found = new LocalUser(); //_afis = new LocalAFIS(); //Dictionary<long, LocalUser> userList = _afis.GetUserList(); int threshold = Properties.Settings.Default.VerificationThreshold; //xamlListBoxUsers.Items.Clear(); //bool found = false; ; //double matchValue = 0; //List<Fingerprint> fg = new List<Fingerprint>(); using (tranxDataContext tx = new tranxDataContext()) { tx.Connection.ConnectionString = Utils.getConnection(); var fng = tx.fingerprint_Table_verifies.Select(s => s); lst_feedback2.Items.Clear(); //foreach (fingerprint_Table_verify templateFile in fng) Parallel.ForEach(fng, templateFile => { lst_feedback2.Items.Insert(0, templateFile.refNO); byte[] data = Utils.convert_string2byteArray(templateFile.finger_data); //String templateFileString = Path.GetFileNameWithoutExtension(templateFile); String fingerPos = templateFile.position; Fingerprint fingerprint = new Fingerprint(); fingerprint.Template = new Template(); fingerprint.Template.SetData(data, Dermalog.Afis.FingerCode3.Enums.TemplateFormat.Dermalog); fingerprint.Position = UInt32.Parse(fingerPos); //fg.Add(fingerprint); dynamic verifyme = gen_FingerPrints(templateFile.refNO, fingerprint); templateFile.VerifiedAS = "NOT_Verified_OK"; if (verifyme.found) { templateFile.VerifiedAS = "VerifiedOK"; } } ); tx.SubmitChanges(); } //return ""; }
public static void createUserFolder_DBTable_old(LocalUser localUser, dynamic dd, Image pic_Webcam = null) { using (tranxDataContext tx = new tranxDataContext()) { tx.Connection.ConnectionString = Utils.getConnection(); userTable_1 usr = new userTable_1(); string idLength = string.Format("D{0}", Utils.get_ParamValue("IDLENGTH")); //string idLength = string.Format("D{0}", Utils.get_ParamValue(localUser.Name)); String idString = localUser.ID.ToString(idLength); String idPath = Path.Combine(StoragePath, idString); if (!Directory.Exists(idPath)) { Directory.CreateDirectory(idPath); } String userPath = Path.Combine(idPath, FILE_DEMOGRAPHIC); StreamWriter sw = new StreamWriter(userPath); sw.Write(localUser.Name); sw.Flush(); sw.Close(); usr.id = localUser.ID; usr.idString = idString; usr.idPath = idPath; usr.userPath = FILE_DEMOGRAPHIC; usr.username = localUser.Name; usr.finger_remark = dd.remark; usr.createdby = dd.loggedin_staff; usr.LastActivityDate = DateTime.Now; usr.finger_Enrolled = "Y"; if (pic_Webcam != null) { //string strpath = idPath + @"\" + idString + ".jpg"; //pic_Webcam.Save(strpath); //Task.Run(() => //{ // MemoryStream ms = new MemoryStream(); // pic_Webcam.Save(ms, System.Drawing.Imaging.ImageFormat.Gif); // byte[] bb = ms.ToArray(); // //ms = null; // ms.Dispose(); // ms.Close(); ////Image img = Image.FromFile(strpath); ////byte[] bArr = imgToByteArray(img); ////byte[] bb = Utils.convertImagetoBinary(pic_Webcam); ////byte[] bb = Utils.convertImagetoBinary(pic_Webcam); //usr.live_image = Utils.convert_byteArray2string(bb); //}).Wait(); dynamic ue = new ExpandoObject(); ue.idstring = idString; ue.Location = "Head Office"; ue.imageSTR = Utils.ImageToBase64(pic_Webcam); ue.stage = "CAPTURE"; ue.capturedBy = dd.loggedin_staff; ue.capturedDT = DateTime.Now; object usertable_extension = ue; string str = Newtonsoft.Json.JsonConvert.SerializeObject(usertable_extension); //string APIHandle = @"infometriq-partner-api/capture/feedback"; string APIHandle = @"submit_usertable_extension"; string resp = ""; Task.Run(() => { //resp = Utils.call_External_WEBAPI_Service(APIHandle, ss); resp = Utils.call_WEBAPI_Service(APIHandle, str); }).Wait(); usr.live_image = Utils.ImageToBase64(pic_Webcam); } tx.userTable_1s.InsertOnSubmit(usr); for (int i = 0; i < localUser.Fingerprints.Count; i++) { String templateString = String.Format("template{0}{1}.dat", i.ToString("D2"), localUser.Fingerprints[i].Position.ToString("D2")); String fingerPos = String.Format("{0}{1}", i.ToString("D2"), localUser.Fingerprints[i].Position.ToString("D2")); string Hand = String.Format("{0}", localUser.Fingerprints[i].Hand.ToString()); string HandPosition = String.Format("{0}", localUser.Fingerprints[i].Position.ToString("D2")); String templatePath = Path.Combine(idPath, templateString); FileStream fs = File.Create(templatePath); byte[] data = localUser.Fingerprints[i].Template.GetData(); fs.Write(data, 0, data.Length); fs.Flush(); fs.Close(); fingerprint_Table fp = new fingerprint_Table(); fp.refNO = idString; fp.position = fingerPos; fp.hand_spec = Hand; fp.hand_position = HandPosition; fp.templatePath = idPath; fp.templateString = templateString; fp.finger_data = Utils.convert_byteArray2string(data); tx.fingerprint_Tables.InsertOnSubmit(fp); } tx.SubmitChanges(); } }
private void NewServerConnetionMethod(bool suppressMsg = false) { try { string serverName; // = comboBox1.SelectedValue.ToString() ; Server server; Boolean cmanualflag = ch_useDirect.Checked; serverName = ((cb_datasource.Items.Count == 0) ? "" : cb_datasource.SelectedValue.ToString()); if ((serverName.Trim() == "") || (cmanualflag)) { serverName = txt_serverAddress.Text.Trim(); // ToString(); SqlConnection sqlj = getNewSqlConnection(serverName, txt_userID.Text, txt_pwd.Text); ServerConnection scip = new ServerConnection(sqlj); String dbname = txt_serverSource.Text.Trim(); String con_str = ConfigurationManager.ConnectionStrings["APPDIRECT"].ConnectionString; String con_str1 = con_str.Replace("SERVERNAME", serverName); con_str1 = con_str1.Replace("DBNAME", dbname); con_str1 = con_str1.Replace("USERNAME", txt_userID.Text.Trim()); con_str1 = con_str1.Replace("PASSWORD", txt_pwd.Text.Trim()); Properties.Settings.Default.informetriQConnectionString = con_str1; // MessageBox.Show(con_str1); txt_connection.Text = con_str1; Properties.Settings.Default.CONNECTIONMODE = "1"; Properties.Settings.Default.Save(); using (tranxDataContext tx = new tranxDataContext()) { try { tx.Connection.ConnectionString = con_str1; int ii = tx.ExecuteCommand(string.Format("Exec testtesttesttest '{0}'", txt_userID.Text)); tx.SubmitChanges(); if (!suppressMsg) { AlertForm1 al = new AlertForm1("Connection Successful...", AlertForm1.AlertOptions.OK, AlertForm1.AlertType.success); al.ShowDialog(); //MessageBox.Show("Connection Successful"); } } catch (Exception ex) { if (!suppressMsg) { AlertForm1 al = new AlertForm1(ex.Message, AlertForm1.AlertOptions.OK, AlertForm1.AlertType.error); al.ShowDialog(); //MessageBox.Show(ex.Message); } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void NewMethod() { AFISVerificationResult result = new AFISVerificationResult(); LocalUser user_found = new LocalUser(); _afis = new LocalAFIS(); Dictionary <long, LocalUser> userList = _afis.GetUserList(); int threshold = Properties.Settings.Default.VerificationThreshold; //xamlListBoxUsers.Items.Clear(); bool found = false;; double matchValue = 0; List <Fingerprint> fg = new List <Fingerprint>(); using (tranxDataContext tx = new tranxDataContext()) { tx.Connection.ConnectionString = Utils.getConnection(); var fng = tx.fingerprint_Table_verifies.Select(s => s); lst_feedback.Items.Clear(); //foreach (fingerprint_Table_verify templateFile in fng) Parallel.ForEach(fng, templateFile => { lst_feedback.Items.Insert(0, templateFile.refNO); byte[] data = Utils.convert_string2byteArray(templateFile.finger_data); //String templateFileString = Path.GetFileNameWithoutExtension(templateFile); String fingerPos = templateFile.position; Fingerprint fingerprint = new Fingerprint(); fingerprint.Template = new Template(); fingerprint.Template.SetData(data, Dermalog.Afis.FingerCode3.Enums.TemplateFormat.Dermalog); fingerprint.Position = UInt32.Parse(fingerPos); fg.Add(fingerprint); StringBuilder str = new StringBuilder(); Parallel.ForEach(userList, (user, loopState) => //Parallel.ForEach(userList, options, (user, loopState) => { foreach (Fingerprint fd in user.Value.Fingerprints) { //str.Clear(); //xamlListBoxUsers.Items.Add(user); double dScore = new Matcher().Match(fingerprint.Template, fd.Template); //double dScore = new Matcher().Match(userFingerprints[i].Template, fingerprints[j].Template); if (dScore > threshold) { //dMaxScore = dScore; result.Score = dScore;; result.Hit = true; //return result; templateFile.identifiedAS = user.Value.Name; //tx.SubmitChanges(); //str.Append(user.Value.Name); loopState.Stop(); } } //result = _afis.IdentifyUser_New(user.Key, fg, Properties.Settings.Default.VerificationThreshold); //result = _afis.IdentifyUser(user.Key, fingerprints_all, Properties.Settings.Default.VerificationThreshold); //if (result.Hit) { //templateFile.identifiedAS = str.ToString(); //found = true; //matchValue = result.Score; //loopState.Stop(); } }); }); tx.SubmitChanges(); } //return ""; }
private void saveData(dynamic dm, string Profession_desc, string strResponse) { //dynamic dm = new ExpandoObject(); // individual_data ind = Newtonsoft.Json.JsonConvert.DeserializeObject<individual_data>(dd); //individual_data ind = dd; try { using (tranxDataContext tx = new tranxDataContext()) { tx.Connection.ConnectionString = Utils.getConnection(); string strUsername = dm.username; var ds = tx.individual_datas.FirstOrDefault(s => s.username == strUsername); if (ds == null) { individual_data ind = new individual_data(); ind.id = dm.id; ind.first_name = dm.first_name; ind.last_name = dm.last_name; ind.username = dm.username; ind.email = dm.email; ind.dob = dm.dob; ind.state = dm.state; ind.country = dm.country; ind.profession = dm.profession; ind.about = dm.about; ind.phone = dm.phone; ind.website = dm.website; ind.gender = dm.gender; ind.confirmation_code = dm.confirmation_code; ind.social_facebook = dm.social_facebook; ind.social_twitter = dm.social_twitter; ind.social_instagram = dm.social_instagram; ind.social_linkedin = dm.social_linkedin; ind.social_youtube = dm.social_youtube; ind.politics = dm.politics; ind.recognition = dm.recognition; ind.hide_dob = dm.hide_dob; ind.rating = dm.rating; ind.status = dm.status; ind.verified_status = dm.verified_status; ind.created_on = dm.created_on; ind.last_updated_on = dm.last_updated_on; ind.state_name = dm.state_name; ind.profession_name = Profession_desc; ind.strResponse = strResponse; ind.account_type = dm.account_type; tx.individual_datas.InsertOnSubmit(ind); tx.SubmitChanges(); AlertForm1 fm = new AlertForm1("Saved Successfully...", AlertForm1.AlertOptions.OK, AlertForm1.AlertType.success); var rst = fm.ShowDialog(); } else { AlertForm1 fm = new AlertForm1("User Details already saved...", AlertForm1.AlertOptions.OK, AlertForm1.AlertType.info); var rst = fm.ShowDialog(); btn_save.Enabled = false; } } } catch (Exception ex) { AlertForm1 fm = new AlertForm1(ex.Message, AlertForm1.AlertOptions.OK, AlertForm1.AlertType.error); var rst = fm.ShowDialog(); } }