internal User toUserFromDirectoryEntry(DirectoryEntry de) { User result = new User(); if (de == null || de.Properties == null) { return(result); } DirectoryEntry root = de; while (true) { if (String.Equals(root.SchemaClassName, "domainDNS", StringComparison.CurrentCultureIgnoreCase)) { result.Domain = String.Concat("LDAP://", tryGetProperty(root, "distinguishedName")); //foreach (String key in root.Properties.PropertyNames) //{ // System.Console.WriteLine("{0} - {1}", key, root.Properties[key][0]); //} break; } root = root.Parent; } result.Title = tryGetProperty(de, "title"); result.Name = new PersonName(); result.Name.Lastname = tryGetProperty(de, "sn"); result.Name.Firstname = tryGetProperty(de, "givenName"); result.EmailAddress = tryGetProperty(de, "mail"); result.UserName = tryGetProperty(de, "sAMAccountName"); result.Phone = tryGetProperty(de, "telephoneNumber"); result.Phone = tryGetProperty(de, "telephoneNumber"); result.Demographics = new Dictionary <string, DemographicSet>(); result.Demographics.Add("LDAP", new DemographicSet()); PhoneNum officePhone = new PhoneNum(result.Phone); result.Demographics["LDAP"].PhoneNumbers = new List <PhoneNum>() { officePhone }; Address address = new Address() { Street1 = tryGetProperty(de, "streetAddress"), City = tryGetProperty(de, "l"), State = tryGetProperty(de, "st"), Zipcode = tryGetProperty(de, "postalCode") }; result.Demographics["LDAP"].StreetAddresses = new List <Address>() { address }; result.Demographics["LDAP"].EmailAddresses = new List <EmailAddress>() { new EmailAddress(result.EmailAddress) }; result.Uid = de.Guid.ToString(); return(result); }
public void Post([FromBody] PhoneNum ph) { try { int otpValue = new Random().Next(100000, 999999); otp = otpValue; /*var accountSid = "AC61e058d33da3516c9a3e62538516a21c"; * var authToken = "af827f42f8112da6d07d97c53d6f0602"; * TwilioClient.Init(accountSid, authToken); * * var to = new PhoneNumber("+91" + ph.phone); * var from = new PhoneNumber("+12054092684"); //Twilio Phone number * var message = MessageResource.Create( * to: to, * from: from, * body: "Finance Management System \n Your OTP for Password Reset is " + otpValue + "."); */ } catch { //In case Number is not verified or Internet is not working } }
public PhoneNumTO(PhoneNum mdo) { this.areaCode = mdo.AreaCode; this.exchange = mdo.Exchange; this.number = mdo.Number; this.description = mdo.Description; }
public void Post([FromBody] PhoneNum ph) { FinanceEntities db = new FinanceEntities(); otp = 0; //reset otp string phonexists = (from a in db.Users where a.Phoneno == ph.phone select a.Phoneno).FirstOrDefault(); if (phonexists != null) { try { int otpValue = new Random().Next(100000, 999999); otp = otpValue; var accountSid = "AC61e058d33da3516c9a3e62538516a21c"; //SID var authToken = ""; //Auth Token TwilioClient.Init(accountSid, authToken); var to = new PhoneNumber("+91" + ph.phone); var from = new PhoneNumber("+12054092684"); //Twilio Phone number var message = MessageResource.Create( to: to, from: from, body: "Finance Management System \n Your OTP for Password Reset is " + otpValue + "."); } catch { //Twilio exceptions like phone not registered or no internet } } }
internal List <PhoneNum> addPhones(OracleDataReader rdr) { List <PhoneNum> result = null; if (rdr.IsDBNull(rdr.GetOrdinal("PhoneNumber"))) { return(result); } string s = rdr["PhoneNumber"].ToString().Trim(); if (s == "") { return(result); } result = new List <PhoneNum>(2); PhoneNum phoneNum = new PhoneNum(); phoneNum.Number = s; if (!rdr.IsDBNull(rdr.GetOrdinal("PhoneType"))) { s = rdr["PhoneType"].ToString().Trim(); if (s != "") { phoneNum.Description = s; } } result.Add(phoneNum); if (rdr.GetSchemaTable().Columns.Contains("PhoneNumber2") && !rdr.IsDBNull(rdr.GetOrdinal("PhoneNumber2"))) { s = rdr["PhoneNumber2"].ToString().Trim(); if (s == "") { return(result); } phoneNum = new PhoneNum(); phoneNum.Number = s; if (!rdr.IsDBNull(rdr.GetOrdinal("PhoneType2"))) { s = rdr["PhoneType2"].ToString().Trim(); if (s != "") { phoneNum.Description = s; } } result.Add(phoneNum); } return(result); }
public void testBuildPatientObject() { DemographicSet patientDemogs = new DemographicSet(); Address addr = new Address() { City = "Hooville", State = "MI", County = "Eggs and Ham", Street1 = "123 Elm St.", Street2 = "Apt 4", Zipcode = "90210" }; PhoneNum phone = new PhoneNum() { Description = "Cell phone", AreaCode = "555", Exchange = "867", Number = "5309" }; EmailAddress email = new EmailAddress() { Address = "*****@*****.**" }; IList<Address> addresses = new List<Address>() { addr }; IList<PhoneNum> telephones = new List<PhoneNum>() { phone }; IList<EmailAddress> emails = new List<EmailAddress>() { email }; patientDemogs.EmailAddresses = emails.ToList<EmailAddress>(); patientDemogs.PhoneNumbers = telephones.ToList<PhoneNum>(); patientDemogs.StreetAddresses = addresses.ToList<Address>(); CCRHelper helper = new CCRHelper(); ActorType patient = helper.buildPatientObject("1234567890", "987654321", "USER", "ONE", "O", "0000/12/25", "2011", "M", patientDemogs); Assert.IsNotNull(patient); Assert.IsTrue(patient.Item is ActorTypePerson); Assert.AreEqual(patient.Address.Count, 1); Assert.AreEqual(patient.EMail.Count, 1); Assert.AreEqual(patient.Telephone.Count, 1); Assert.AreEqual(patient.IDs.Count, 2); Assert.IsTrue(String.Equals(patient.IDs[0].ID, "1234567890")); Assert.IsTrue(String.Equals(patient.IDs[0].Type.Text, "ID")); Assert.IsTrue(String.Equals(patient.IDs[1].ID, "987654321")); Assert.IsTrue(String.Equals(patient.IDs[1].Type.Text, "SSN")); Assert.IsTrue(String.Equals(patient.Address[0].City, "Hooville")); Assert.IsTrue(String.Equals(patient.Address[0].County, "Eggs and Ham")); Assert.IsTrue(String.Equals(patient.Address[0].Line1, "123 Elm St.")); Assert.IsTrue(String.Equals(patient.Address[0].Line2, "Apt 4")); Assert.IsTrue(String.Equals(patient.Address[0].PostalCode, "90210")); Assert.IsTrue(String.Equals(patient.Address[0].State, "MI")); Assert.IsTrue(String.Equals(patient.EMail[0].Value, "*****@*****.**")); Assert.IsTrue(String.Equals(patient.Telephone[0].Value, "5558675309")); ActorTypePerson person = (ActorTypePerson)patient.Item; Assert.IsTrue(String.Equals(person.DateOfBirth.ExactDateTime, "0000/12/25")); Assert.IsTrue(String.Equals(person.DateOfBirth.Age.Value, "2011")); Assert.IsTrue(String.Equals(person.Gender.Text, "M")); Assert.IsTrue(String.Equals(person.Name.CurrentName.Family.First(), "ONE")); Assert.IsTrue(String.Equals(person.Name.CurrentName.Given.First(), "USER")); Assert.IsTrue(String.Equals(person.Name.CurrentName.Middle.First(), "O")); }
public void testBuildPatientObject() { DemographicSet patientDemogs = new DemographicSet(); Address addr = new Address() { City = "Hooville", State = "MI", County = "Eggs and Ham", Street1 = "123 Elm St.", Street2 = "Apt 4", Zipcode = "90210" }; PhoneNum phone = new PhoneNum() { Description = "Cell phone", AreaCode = "555", Exchange = "867", Number = "5309" }; EmailAddress email = new EmailAddress() { Address = "*****@*****.**" }; IList <Address> addresses = new List <Address>() { addr }; IList <PhoneNum> telephones = new List <PhoneNum>() { phone }; IList <EmailAddress> emails = new List <EmailAddress>() { email }; patientDemogs.EmailAddresses = emails.ToList <EmailAddress>(); patientDemogs.PhoneNumbers = telephones.ToList <PhoneNum>(); patientDemogs.StreetAddresses = addresses.ToList <Address>(); CCRHelper helper = new CCRHelper(); ActorType patient = helper.buildPatientObject("1234567890", "987654321", "USER", "ONE", "O", "0000/12/25", "2011", "M", patientDemogs); Assert.IsNotNull(patient); Assert.IsTrue(patient.Item is ActorTypePerson); Assert.AreEqual(patient.Address.Count, 1); Assert.AreEqual(patient.EMail.Count, 1); Assert.AreEqual(patient.Telephone.Count, 1); Assert.AreEqual(patient.IDs.Count, 2); Assert.IsTrue(String.Equals(patient.IDs[0].ID, "1234567890")); Assert.IsTrue(String.Equals(patient.IDs[0].Type.Text, "ID")); Assert.IsTrue(String.Equals(patient.IDs[1].ID, "987654321")); Assert.IsTrue(String.Equals(patient.IDs[1].Type.Text, "SSN")); Assert.IsTrue(String.Equals(patient.Address[0].City, "Hooville")); Assert.IsTrue(String.Equals(patient.Address[0].County, "Eggs and Ham")); Assert.IsTrue(String.Equals(patient.Address[0].Line1, "123 Elm St.")); Assert.IsTrue(String.Equals(patient.Address[0].Line2, "Apt 4")); Assert.IsTrue(String.Equals(patient.Address[0].PostalCode, "90210")); Assert.IsTrue(String.Equals(patient.Address[0].State, "MI")); Assert.IsTrue(String.Equals(patient.EMail[0].Value, "*****@*****.**")); Assert.IsTrue(String.Equals(patient.Telephone[0].Value, "5558675309")); ActorTypePerson person = (ActorTypePerson)patient.Item; Assert.IsTrue(String.Equals(person.DateOfBirth.ExactDateTime, "0000/12/25")); Assert.IsTrue(String.Equals(person.DateOfBirth.Age.Value, "2011")); Assert.IsTrue(String.Equals(person.Gender.Text, "M")); Assert.IsTrue(String.Equals(person.Name.CurrentName.Family.First(), "ONE")); Assert.IsTrue(String.Equals(person.Name.CurrentName.Given.First(), "USER")); Assert.IsTrue(String.Equals(person.Name.CurrentName.Middle.First(), "O")); }
// button signup private void buttonCreateAccount_Click() { // add a new user DataTable table = new DataTable(); DB db = new DB(); if (db.openConnection() == false) { Application.Current.MainPage.DisplayAlert("Server Error", "Try Again Later", "Ok"); } else { db.closeConnection(); String fname = firstName; //check sql MySqlCommand command = new MySqlCommand("INSERT INTO user(fname,lname,phone,email,password,title,userID) VALUES (@fn, @ln, @ph, @email, @pass, 'Member',@userID)", db.getConnection()); MySqlDataAdapter adapter = new MySqlDataAdapter(); command.Parameters.Add("@fn", MySqlDbType.VarChar).Value = firstName; command.Parameters.Add("@ln", MySqlDbType.VarChar).Value = lastName; command.Parameters.Add("@ph", MySqlDbType.VarChar).Value = PhoneNum; command.Parameters.Add("@email", MySqlDbType.VarChar).Value = Email; command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = Password; command.Parameters.Add("@userID", MySqlDbType.VarChar).Value = Guid.NewGuid().ToString(); MySqlCommand command2 = new MySqlCommand("SELECT * FROM user WHERE email = @email2 and password = @pass2", db.getConnection()); command2.Parameters.Add("@email2", MySqlDbType.VarChar).Value = Email; command2.Parameters.Add("@pass2", MySqlDbType.VarChar).Value = Password; // open the connection db.openConnection(); adapter.SelectCommand = command2; adapter.Fill(table); int y = table.Rows.Count; //Console.WriteLine(String.IsNullOrEmpty(firstName)); //password.Text.Equals(passwordConfirm.Text) && phoneNum.Text.ValidatePhoneNumber(true) && emailaddress.Text.IsValidEmail() && password.Text.IsValidPassword() // check if the textboxes contains the default values if (checkTextBoxesValues() == true && y == 0) { // check if the password equal the confirm password if (Password.Equals(PasswordConfirm) && PhoneNum.ValidatePhoneNumber(true) && Email.IsValidEmail() && Password.IsValidPassword()) { // execute the query if (command.ExecuteNonQuery() == 1) { Application.Current.MainPage.DisplayAlert("Your Account Has Been Created", "Account Created", "Ok"); Navigation.PopModalAsync(); } else { Application.Current.MainPage.DisplayAlert("ERROR", "Account Failed to Create", "Ok"); } } else { if (Password.Equals(PasswordConfirm) == false) { Application.Current.MainPage.DisplayAlert("Confirm password doesnt match", "Password Error", "Ok"); } else if (PhoneNum.ValidatePhoneNumber(true) == false) { Application.Current.MainPage.DisplayAlert("Invalid phone number", "phone Number Error", "Ok"); } else if (Email.IsValidEmail() == false) { Application.Current.MainPage.DisplayAlert("Invalid Email", "Email", "Ok"); } else { Application.Current.MainPage.DisplayAlert("Password must contain between 8-16 characters", "Password error", "Ok"); } } } else { Application.Current.MainPage.DisplayAlert("Enter Your Information First Or Email Already Used", "Error", "Ok"); } // close the connection db.closeConnection(); } db.closeConnection(); }
internal List<PhoneNum> addPhones(OracleDataReader rdr) { List<PhoneNum> result = null; if (rdr.IsDBNull(rdr.GetOrdinal("PhoneNumber"))) { return result; } string s = rdr["PhoneNumber"].ToString().Trim(); if (s == "") { return result; } result = new List<PhoneNum>(2); PhoneNum phoneNum = new PhoneNum(); phoneNum.Number = s; if (!rdr.IsDBNull(rdr.GetOrdinal("PhoneType"))) { s = rdr["PhoneType"].ToString().Trim(); if (s != "") { phoneNum.Description = s; } } result.Add(phoneNum); if (rdr.GetSchemaTable().Columns.Contains("PhoneNumber2") && !rdr.IsDBNull(rdr.GetOrdinal("PhoneNumber2"))) { s = rdr["PhoneNumber2"].ToString().Trim(); if (s == "") { return result; } phoneNum = new PhoneNum(); phoneNum.Number = s; if (!rdr.IsDBNull(rdr.GetOrdinal("PhoneType2"))) { s = rdr["PhoneType2"].ToString().Trim(); if (s != "") { phoneNum.Description = s; } } result.Add(phoneNum); } return result; }
internal DemographicSet toDemographicSet(string[] response) { if (response == null || response.Length == 0) { return null; } DemographicSet result = new DemographicSet(); string[] flds = response[0].Split(new char[] { '^' }); Address addr = new Address(); if (flds.Length > 0 && flds[1] != "") { addr.Street1 = flds[1]; } if (flds.Length > 1 && flds[2] != "") { addr.Street2 = flds[2]; } if (flds.Length > 2 && flds[3] != "") { addr.Street3 = flds[3]; } if (flds.Length > 3 && flds[4] != "") { addr.City = flds[4]; } if (flds.Length > 4 && flds[5] != "") { addr.State = flds[5]; } if (flds.Length > 5 && flds[6] != "") { addr.Zipcode = flds[6]; } if (flds.Length > 6 && flds[7] != "") { addr.County = flds[7]; } result.StreetAddresses.Add(addr); if (flds.Length > 7 && flds[8] != "") { PhoneNum p = new PhoneNum(flds[8]); p.Description = "Home Phone"; result.PhoneNumbers.Add(p); } if (flds.Length > 8 && flds[9] != "") { PhoneNum p = new PhoneNum(flds[9]); p.Description = "Work Phone"; result.PhoneNumbers.Add(p); } if (flds.Length > 9 && flds[10] != "") { PhoneNum p = new PhoneNum(flds[10]); p.Description = "Cell Phone"; result.PhoneNumbers.Add(p); } if (flds.Length > 10) { if (flds[11] != "") { result.EmailAddresses.Add(new EmailAddress(flds[11])); } } return result; }