public Task PlatformComposeAsync(EmailMessage?message) { var isComposeSupported = InvokeOnMainThread(() => NSWorkspace.SharedWorkspace.UrlForApplication(NSUrl.FromString("mailto:")) != null); if (!isComposeSupported) { throw new FeatureNotSupportedException(); } var url = Email2.GetMailToUri(message); using var nsurl = NSUrl.FromString(url); NSWorkspace.SharedWorkspace.OpenUrl(nsurl); return(Task.CompletedTask); }
/// <summary> /// Compares two EmailAddress objects /// </summary> public static bool operator !=(EmailAddress Email1, EmailAddress Email2) { if ((object)Email1 == null && (object)Email2 != null) { return(true); } if ((object)Email2 == null && (object)Email1 != null) { return(true); } if ((object)Email1 == null && (object)Email2 == null) { return(false); } return(Email1.ToString() != Email2.ToString()); }
public string GetAllProperties() { string fullName = (Name.Trim() == "" ? ("") : Name.Trim()) + (MiddleName.Trim() == "" ? ("") : " " + MiddleName.Trim()) + (Surname.Trim() == "" ? ("") : " " + Surname.Trim()); string generalInfo = (fullName == "" ? ("") : fullName + "\r\n") + (Nickname == "" ? ("") : Nickname.Trim() + "\r\n") + (Title == "" ? ("") : Title.Trim() + "\r\n") + (Company == "" ? ("") : Company.Trim() + "\r\n") + (Address.Trim() == "" ? ("") : Address.Trim() + "\r\n"); string phones = (HomePhone == "" ? ("") : "H: " + HomePhone.Trim() + "\r\n") + (MobilePhone == "" ? ("") : "M: " + MobilePhone.Trim() + "\r\n") + (WorkPhone == "" ? ("") : "W: " + WorkPhone.Trim() + "\r\n") + (Fax == "" ? ("") : "F:" + Fax.Trim() + "\r\n"); string emails = (Email1 == "" ? ("") : "" + Email1.Trim() + "\r\n") + (Email2 == "" ? ("") : "" + Email2.Trim() + "\r\n") + (Email3 == "" ? ("") : "" + Email3.Trim() + "\r\n") + (Homepage == "" ? ("") : "Homepage:" + "\r\n" + Homepage.Trim() + "\r\n"); string dateOfBirth = ""; if (DayOfBirth != "-" && DayOfBirth != "0" || MonthOfBirth != "-" || YearOfBirth != "") { dateOfBirth = "Birthday " + (DayOfBirth == "-" || DayOfBirth == "0" ? ("") : DayOfBirth + ". ") + (MonthOfBirth == "-" ? ("") : MonthOfBirth + " ") + (YearOfBirth == "" ? ("") : YearOfBirth + " (" + (DateTime.Now.Year - Convert.ToInt32(YearOfBirth)).ToString() + ")" + "\r\n"); } string dateOfAnn = ""; if (DayOfAnn != "-" && DayOfAnn != "0" || MonthOfAnn != "-" || YearOfAnn != "") { dateOfAnn = "Anniversary " + (DayOfAnn == "-" ? ("") : DayOfAnn + ". ") + (MonthOfAnn == "-" ? ("") : MonthOfAnn + " ") + (YearOfAnn == "" ? ("") : YearOfAnn + " (" + (DateTime.Now.Year - Convert.ToInt32(YearOfAnn)).ToString() + ")\r\n"); } string dates = (dateOfBirth == "" ? ("") : dateOfBirth) + (dateOfAnn == "" ? ("") : dateOfAnn); string additional = (Address2 == "" ? ("") : Address2.Trim() + "\r\n") + (Phone2 == "" ? ("") : "\r\nP: " + Phone2.Trim() + "\r\n") + (Notes == "" ? ("") : "\r\n" + Notes.Trim()); string allProperties = ((generalInfo == "" ? ("") : generalInfo) + (phones == "" ? ("") : "\r\n" + phones) + (emails == "" ? ("") : "\r\n" + emails) + (dates == "" ? ("") : "\r\n" + dates) + (additional == "" ? ("") : "\r\n" + additional)).Trim(); return(allProperties); }
/// <summary> /// Get the GEDCOM 5.5 lines for the data in this object. /// Lines start at the given level /// </summary> /// <param name="sw"> /// A <see cref="TextWriter"/> /// </param> /// <param name="level"> /// A <see cref="int"/> /// </param> public void Output(TextWriter sw, int level) { sw.Write(Environment.NewLine); sw.Write(Util.IntToString(level)); sw.Write(" ADDR"); if (!string.IsNullOrEmpty(AddressLine)) { sw.Write(" "); Util.SplitLineText(sw, AddressLine, level, 60, 3, true); } string levelStr = null; string levelPlusOne = null; if (!string.IsNullOrEmpty(AddressLine1)) { if (levelPlusOne == null) { levelPlusOne = Util.IntToString(level + 1); } string line = AddressLine1.Replace("@", "@@"); sw.Write(Environment.NewLine); sw.Write(levelPlusOne); sw.Write(" ADR1 "); if (line.Length <= 60) { sw.Write(AddressLine1); } else { sw.Write(line.Substring(0, 60)); System.Diagnostics.Debug.WriteLine("Truncating AddressLine1"); } } if (!string.IsNullOrEmpty(AddressLine2)) { if (levelPlusOne == null) { levelPlusOne = Util.IntToString(level + 1); } string line = AddressLine2.Replace("@", "@@"); sw.Write(Environment.NewLine); sw.Write(levelPlusOne); sw.Write(" ADR2 "); if (line.Length <= 60) { sw.Write(line); } else { sw.Write(line.Substring(0, 60)); System.Diagnostics.Debug.WriteLine("Truncating AddressLine2"); } } if (!string.IsNullOrEmpty(AddressLine3)) { if (levelPlusOne == null) { levelPlusOne = Util.IntToString(level + 1); } string line = AddressLine3.Replace("@", "@@"); sw.Write(Environment.NewLine); sw.Write(levelPlusOne); sw.Write(" ADR3 "); if (line.Length <= 60) { sw.Write(line); } else { sw.Write(line.Substring(0, 60)); System.Diagnostics.Debug.WriteLine("Truncating AddressLine3"); } } if (!string.IsNullOrEmpty(City)) { if (levelPlusOne == null) { levelPlusOne = Util.IntToString(level + 1); } string line = City.Replace("@", "@@"); sw.Write(Environment.NewLine); sw.Write(levelPlusOne); sw.Write(" CITY "); if (line.Length <= 60) { sw.Write(line); } else { sw.Write(line.Substring(0, 60)); System.Diagnostics.Debug.WriteLine("Truncating City"); } } if (!string.IsNullOrEmpty(State)) { if (levelPlusOne == null) { levelPlusOne = Util.IntToString(level + 1); } string line = State.Replace("@", "@@"); sw.Write(Environment.NewLine); sw.Write(levelPlusOne); sw.Write(" STAE "); if (line.Length <= 60) { sw.Write(line); } else { sw.Write(line.Substring(0, 60)); System.Diagnostics.Debug.WriteLine("Truncating State"); } } if (!string.IsNullOrEmpty(PostCode)) { if (levelPlusOne == null) { levelPlusOne = Util.IntToString(level + 1); } string line = PostCode.Replace("@", "@@"); sw.Write(Environment.NewLine); sw.Write(levelPlusOne); sw.Write(" POST "); if (line.Length <= 10) { sw.Write(line); } else { sw.Write(line.Substring(0, 10)); System.Diagnostics.Debug.WriteLine("Truncating PostCode"); } } if (!string.IsNullOrEmpty(Country)) { if (levelPlusOne == null) { levelPlusOne = Util.IntToString(level + 1); } string line = Country.Replace("@", "@@"); sw.Write(Environment.NewLine); sw.Write(levelPlusOne); sw.Write(" CTRY "); if (line.Length <= 60) { sw.Write(line); } else { sw.Write(line.Substring(0, 60)); System.Diagnostics.Debug.WriteLine("Truncating Country"); } } if (!string.IsNullOrEmpty(Phone1)) { if (levelStr == null) { levelStr = Util.IntToString(level); } string line = Phone1.Replace("@", "@@"); sw.Write(Environment.NewLine); sw.Write(levelStr); sw.Write(" PHON "); if (line.Length <= 25) { sw.Write(line); } else { sw.Write(line.Substring(0, 25)); System.Diagnostics.Debug.WriteLine("Truncating Phone1"); } } if (!string.IsNullOrEmpty(Phone2)) { if (levelStr == null) { levelStr = Util.IntToString(level); } string line = Phone2.Replace("@", "@@"); sw.Write(Environment.NewLine); sw.Write(levelStr); sw.Write(" PHON "); if (line.Length <= 25) { sw.Write(line); } else { sw.Write(line.Substring(0, 25)); System.Diagnostics.Debug.WriteLine("Truncating Phone2"); } } if (!string.IsNullOrEmpty(Phone3)) { if (levelStr == null) { levelStr = Util.IntToString(level); } string line = Phone3.Replace("@", "@@"); sw.Write(Environment.NewLine); sw.Write(levelStr); sw.Write(" PHON "); if (line.Length <= 25) { sw.Write(line); } else { sw.Write(line.Substring(0, 25)); System.Diagnostics.Debug.WriteLine("Truncating Phone3"); } } if (!string.IsNullOrEmpty(Fax1)) { if (levelStr == null) { levelStr = Util.IntToString(level); } string line = Fax1.Replace("@", "@@"); sw.Write(Environment.NewLine); sw.Write(levelStr); sw.Write(" FAX "); if (line.Length <= 60) { sw.Write(line); } else { sw.Write(line.Substring(0, 60)); System.Diagnostics.Debug.WriteLine("Truncating Fax1"); } } if (!string.IsNullOrEmpty(Fax2)) { if (levelStr == null) { levelStr = Util.IntToString(level); } string line = Fax2.Replace("@", "@@"); sw.Write(Environment.NewLine); sw.Write(levelStr); sw.Write(" FAX "); if (line.Length <= 60) { sw.Write(line); } else { sw.Write(line.Substring(0, 60)); System.Diagnostics.Debug.WriteLine("Truncating Fax2"); } } if (!string.IsNullOrEmpty(Fax3)) { if (levelStr == null) { levelStr = Util.IntToString(level); } string line = Fax3.Replace("@", "@@"); sw.Write(Environment.NewLine); sw.Write(levelStr); sw.Write(" FAX "); if (line.Length <= 60) { sw.Write(line); } else { sw.Write(line.Substring(0, 60)); System.Diagnostics.Debug.WriteLine("Truncating Fax3"); } } if (!string.IsNullOrEmpty(Email1)) { if (levelStr == null) { levelStr = Util.IntToString(level); } string line = Email1.Replace("@", "@@"); sw.Write(Environment.NewLine); sw.Write(levelStr); sw.Write(" EMAIL "); if (line.Length <= 120) { sw.Write(line); } else { sw.Write(line.Substring(0, 120)); System.Diagnostics.Debug.WriteLine("Truncating Email1"); } } if (!string.IsNullOrEmpty(Email2)) { if (levelStr == null) { levelStr = Util.IntToString(level); } string line = Email2.Replace("@", "@@"); sw.Write(Environment.NewLine); sw.Write(levelStr); sw.Write(" EMAIL "); if (line.Length <= 120) { sw.Write(line); } else { sw.Write(line.Substring(0, 120)); System.Diagnostics.Debug.WriteLine("Truncating Email2"); } } if (!string.IsNullOrEmpty(Email3)) { if (levelStr == null) { levelStr = Util.IntToString(level); } string line = Email3.Replace("@", "@@"); sw.Write(Environment.NewLine); sw.Write(levelStr); sw.Write(" EMAIL "); if (line.Length <= 120) { sw.Write(line); } else { sw.Write(line.Substring(0, 120)); System.Diagnostics.Debug.WriteLine("Truncating Email3"); } } if (!string.IsNullOrEmpty(Www1)) { if (levelStr == null) { levelStr = Util.IntToString(level); } string line = Www1.Replace("@", "@@"); sw.Write(Environment.NewLine); sw.Write(levelStr); sw.Write(" WWW "); if (line.Length <= 120) { sw.Write(line); } else { sw.Write(line.Substring(0, 120)); System.Diagnostics.Debug.WriteLine("Truncating Www1"); } } if (!string.IsNullOrEmpty(Www2)) { if (levelStr == null) { levelStr = Util.IntToString(level); } string line = Www2.Replace("@", "@@"); sw.Write(Environment.NewLine); sw.Write(levelStr); sw.Write(" WWW "); if (line.Length <= 120) { sw.Write(line); } else { sw.Write(line.Substring(0, 120)); System.Diagnostics.Debug.WriteLine("Truncating Www2"); } } if (!string.IsNullOrEmpty(Www3)) { if (levelStr == null) { levelStr = Util.IntToString(level); } string line = Www3.Replace("@", "@@"); sw.Write(Environment.NewLine); sw.Write(levelStr); sw.Write(" WWW "); if (line.Length <= 120) { sw.Write(line); } else { sw.Write(line.Substring(0, 120)); System.Diagnostics.Debug.WriteLine("Truncating Www3"); } } }
protected override void OnBeforeEntitySave() { var now = DateTime.UtcNow; if (IsNew && !Fields[UserFields.CreatedOn.FieldIndex].IsChanged) { CreatedOn = now; } if (IsDirty && !Fields[UserFields.ModifiedOn.FieldIndex].IsChanged) { ModifiedOn = now; } if (IsNew && !Fields[UserFields.Guid.FieldIndex].IsChanged) { Guid = System.Guid.NewGuid().ToString("N"); // should be set by UserStore of Identity } if (Gender.Length == 0 || !new[] { 'm', 'f', 'u' }.Contains(Gender[0])) { Gender = "u"; } if (!string.IsNullOrEmpty(FirstName)) { FirstName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(FirstName?.ToLower(CultureInfo.CurrentCulture)); } if (!string.IsNullOrEmpty(MiddleName)) { MiddleName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(MiddleName.ToLower(CultureInfo.CurrentCulture)); } if (!string.IsNullOrEmpty(LastName)) { LastName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(LastName.ToLower(CultureInfo.CurrentCulture)); } if (!string.IsNullOrEmpty(Nickname)) { Nickname = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Nickname.ToLower(CultureInfo.CurrentCulture)); } if (string.IsNullOrEmpty(PhoneNumber) && !string.IsNullOrEmpty(PhoneNumber2)) { PhoneNumber = PhoneNumber2; PhoneNumber2 = string.Empty; } if (string.IsNullOrEmpty(Email) && !string.IsNullOrEmpty(Email2)) { Email = Email2; Email2 = string.Empty; } if (!string.IsNullOrEmpty(Email)) { Email = Email.ToLowerInvariant(); } if (!string.IsNullOrEmpty(Email2)) { Email2 = Email2.ToLowerInvariant(); } base.OnBeforeEntitySave(); }
//check for validation of Contacts fields public bool ContactsValidation() { bool result = false; //if (!NotEmptyFieldCheck(Phone1) && PhoneNumberValidationCheck(Phone1) == null && // !NotEmptyFieldCheck(Phone2) && PhoneNumberValidationCheck(Phone2) == null && // !NotEmptyFieldCheck(Phone3) && PhoneNumberValidationCheck(Phone3) == null && // !NotEmptyFieldCheck(Email1) && !Email1.Contains("@") && // !NotEmptyFieldCheck(Email2) && !Email2.Contains("@") && // !NotEmptyFieldCheck(VK) && !NotEmptyFieldCheck(FaceBook)) // //if (Phone1 == "+380" && Phone2 == "---" && Phone3 == "---" && Email1 == "---" && Email2 == "---" && VK == "---" && FaceBook == "---") // return false; //else //{ if (NotEmptyFieldCheck(Phone1) && PhoneNumberValidationCheck(Phone1) != null) { Phone1 = PhoneNumberValidationCheck(Phone1); result = true; } else { Phone1 = "+380"; } if (NotEmptyFieldCheck(Phone2) && PhoneNumberValidationCheck(Phone2) != null) { Phone2 = PhoneNumberValidationCheck(Phone2); result = true; } else { Phone2 = "---"; } if (NotEmptyFieldCheck(Phone3) && PhoneNumberValidationCheck(Phone3) != null) { Phone3 = PhoneNumberValidationCheck(Phone3); result = true; } else { Phone3 = "---"; } if (!result) { dialogService.ShowMessage("Хотя бы одно из полей номера телефона нужно заполнить корректно"); return(false); } if (Email1 != "---" && !Email1.Contains("@")) { dialogService.ShowMessage("Поле Email1 в контактных данных заполнено не корректно"); return(false); } if (Email2 != "---" && !Email2.Contains("@")) { dialogService.ShowMessage("Поле Email2 в контактных данных заполнено не корректно"); return(false); } return(true); //} }