public virtual void Save(Context context) { if (AddressNo != null) { AddressNo.Persist(context); } if (Building != null) { Building.Persist(context); } if (Street1 != null) { Street1.Persist(context); } if (Street2 != null) { Street2.Persist(context); } if (regionLevel1Name != null) { regionLevel1Name.Persist(context); } if (regionLevel2Name != null) { regionLevel2Name.Persist(context); } if (regionLevel3Name != null) { regionLevel3Name.Persist(context); } context.PersistenceSession.SaveOrUpdate(this); }
protected override void Execute(CodeActivityContext executionContext) { // Extract the tracing service ITracingService tracingService = executionContext.GetExtension <ITracingService>(); try { //Create the context IWorkflowContext context = executionContext.GetExtension <IWorkflowContext>(); IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>(); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); // Don't Really Care about which entity this is DynamicUrlParser parser = new DynamicUrlParser(); EntityReference primaryEntity = parser.ConvertToEntityReference(service, RecordUrl.Get <string>(executionContext)); string addressLine1 = Street1.Get <string>(executionContext); string addressLine2 = Street2.Get <string>(executionContext); string city = City.Get <string>(executionContext); string stateOrProvince = StateOrProvince.Get <string>(executionContext); string zipCode = ZipPostalCode.Get <string>(executionContext); string countryName = Country.Get <string>(executionContext); string rc = GenerateAddress(addressLine1, addressLine2, city, stateOrProvince, zipCode, countryName); FullAddress.Set(executionContext, rc); } catch (FaultException <OrganizationServiceFault> ex) { throw new Exception("SBS.Workflow.SetStateChildRecords: " + ex.Message); } }
public override bool Equals(object obj) { Address addr = obj as Address; return(addr != null && Street1.Equals(addr.Street1, StringComparison.OrdinalIgnoreCase) && Street2.Equals(addr.Street2, StringComparison.OrdinalIgnoreCase) && PostalCode.Equals(addr.PostalCode, StringComparison.OrdinalIgnoreCase) && RegionCode.Equals(addr.RegionCode, StringComparison.OrdinalIgnoreCase) && CountryCode.Equals(addr.CountryCode, StringComparison.OrdinalIgnoreCase)); }
public override int GetHashCode() { unchecked { int hashCode = (Street1 != null ? Street1.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Street2 != null ? Street2.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (City != null ? City.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (State != null ? State.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Zip != null ? Zip.GetHashCode() : 0); return(hashCode); } }
/// <summary> /// This method returns a well formatted address string (HTML), based on the country /// </summary> /// <param name="includeName">Specifies whether potential address name information shall be included in the output string</param> /// <returns>Well formatted address string</returns> public string GetHtmlFormattedAddress(bool includeName = false) { // We need the country object to perform this operation using (var entCountry = NewCountryEntity()) { // Now, we can concatenate the appropriate string var address = string.Empty; if (includeName) { if (!string.IsNullOrEmpty(AddressCompany)) { address += "<b>" + AddressCompany.Trim() + "</b><br>"; } if (!string.IsNullOrEmpty(AddressName)) { address += "<b>" + AddressName.Trim() + "</b><br>"; } } address += Street.Trim() + "<br>"; if (!string.IsNullOrEmpty(Street2)) { address += Street2.Trim() + "<br>"; } if (!string.IsNullOrEmpty(Street3)) { address += Street3.Trim() + "<br>"; } switch (entCountry.AddressFormat) { case AddressFormat.CityStateZip: address += City.Trim() + ", " + State.Trim() + " " + Zip.Trim() + "<br>"; break; case AddressFormat.CityPostalCode: address += City.Trim() + ", " + Zip.Trim() + "<br>"; break; case AddressFormat.PostalCodeCity: address += Zip.Trim() + " " + City.Trim() + "<br>"; break; case AddressFormat.PostalCodeCityState: address += Zip.Trim() + " " + City.Trim() + ", " + State.Trim() + "<br>"; break; } address += entCountry.Name.Trim(); return(address); } }
public override int GetHashCode() { unchecked { var hashCode = (Street != null ? Street.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Street2 != null ? Street2.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (PostalCode != null ? PostalCode.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (City != null ? City.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Country != null ? Country.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (CareOf != null ? CareOf.GetHashCode() : 0); return(hashCode); } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (City != null) { hashCode = hashCode * 59 + City.GetHashCode(); } if (Country != null) { hashCode = hashCode * 59 + Country.GetHashCode(); } if (EmailAddress != null) { hashCode = hashCode * 59 + EmailAddress.GetHashCode(); } if (FaxNumber != null) { hashCode = hashCode * 59 + FaxNumber.GetHashCode(); } if (PhoneNumber != null) { hashCode = hashCode * 59 + PhoneNumber.GetHashCode(); } if (PostCode != null) { hashCode = hashCode * 59 + PostCode.GetHashCode(); } if (StateOrProvince != null) { hashCode = hashCode * 59 + StateOrProvince.GetHashCode(); } if (Street1 != null) { hashCode = hashCode * 59 + Street1.GetHashCode(); } if (Street2 != null) { hashCode = hashCode * 59 + Street2.GetHashCode(); } if (MediumCharacteristicType != null) { hashCode = hashCode * 59 + MediumCharacteristicType.GetHashCode(); } return(hashCode); } }
/// <summary> /// Get a hash value for the <b>Address</b> object. /// </summary> /// <returns> /// An integer hash value for this <b>Address</b> object. /// </returns> public override int GetHashCode() { return((Street1 == null ? 0 : Street1.GetHashCode()) ^ (Street2 == null ? 0 : Street2.GetHashCode()) ^ (ZipCode == null ? 0 : ZipCode.GetHashCode())); }
// Validators private bool CheckAddress() { // Invalid characters Regex nonAlphaNumeric = new Regex(@"^[a-zA-Z0-9_]+$"); // TODO re-examine RegEx as means of validating CheckAddress() characters // Default state is true, updated if either address 1 or 2 fails validation bool isReady = true; // Street1 if (regex1.IsMatch(Street1)) { string[] myStreet1 = Regex.Split(Street1); Street1 = null; for (int i = 0; i < myStreet1.Length; i++) { Street1 += myStreet1[i]; } // Fail street 1 validation if less than 3 characters or consists only of numbers if (Street1.Length < 3 || !Street1.Contains("[a-zA-Z]")) { Console.WriteLine("Fail on Employer Street Address 1 validation."); isReady = false; } } // Street2 if (regex1.IsMatch(Street2)) { string[] myStreet2 = Regex.Split(Street2); Street2 = null; for (int i = 0; i < myStreet2.Length; i++) { Street2 += myStreet2[i]; } // Fail street 2 validation if less than 3 characters or consists only of numbers if (Street2.Length < 3 || !Street2.Contains("[a-zA-Z]")) { Console.WriteLine("Fail on Employer Street Address 2 validation."); isReady = false; } } // City if (regex1.IsMatch(City)) { string[] myCity = Regex.Split(City); City = null; for (int i = 0; i < myCity.Length; i++) { City += myCity[i]; } // Fail city validation if consists only of numbers if (!City.Contains("[a-zA-Z]")) { Console.WriteLine("Fail on Employer City validation."); isReady = false; } return(isReady); } }
/// <summary> /// Returns true if MediumCharacteristic instances are equal /// </summary> /// <param name="other">Instance of MediumCharacteristic to be compared</param> /// <returns>Boolean</returns> public bool Equals(MediumCharacteristic other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( City == other.City || City != null && City.Equals(other.City) ) && ( Country == other.Country || Country != null && Country.Equals(other.Country) ) && ( EmailAddress == other.EmailAddress || EmailAddress != null && EmailAddress.Equals(other.EmailAddress) ) && ( FaxNumber == other.FaxNumber || FaxNumber != null && FaxNumber.Equals(other.FaxNumber) ) && ( PhoneNumber == other.PhoneNumber || PhoneNumber != null && PhoneNumber.Equals(other.PhoneNumber) ) && ( PostCode == other.PostCode || PostCode != null && PostCode.Equals(other.PostCode) ) && ( StateOrProvince == other.StateOrProvince || StateOrProvince != null && StateOrProvince.Equals(other.StateOrProvince) ) && ( Street1 == other.Street1 || Street1 != null && Street1.Equals(other.Street1) ) && ( Street2 == other.Street2 || Street2 != null && Street2.Equals(other.Street2) ) && ( MediumCharacteristicType == other.MediumCharacteristicType || MediumCharacteristicType != null && MediumCharacteristicType.Equals(other.MediumCharacteristicType) )); }