public override int GetHashCode() { int hash = 1; if (StreetName.Length != 0) { hash ^= StreetName.GetHashCode(); } if (BuildingNumber != 0) { hash ^= BuildingNumber.GetHashCode(); } if (AddressLine.Length != 0) { hash ^= AddressLine.GetHashCode(); } if (PostCode.Length != 0) { hash ^= PostCode.GetHashCode(); } if (TownName.Length != 0) { hash ^= TownName.GetHashCode(); } if (Country.Length != 0) { hash ^= Country.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public XElement Serialize(string name) { return(new XElement(UblNames.Cac + name, ID.Serialize(nameof(ID)), AddressTypeCode.Serialize(nameof(AddressTypeCode)), AddressFormatCode.Serialize(nameof(AddressFormatCode)), Postbox.Serialize(nameof(Postbox)), Floor.Serialize(nameof(Floor)), Room.Serialize(nameof(Room)), StreetName.Serialize(nameof(StreetName)), AdditionalStreetName.Serialize(nameof(AdditionalStreetName)), BlockName.Serialize(nameof(BlockName)), BuildingName.Serialize(nameof(BuildingName)), BuildingNumber.Serialize(nameof(BuildingNumber)), InhouseMail.Serialize(nameof(InhouseMail)), Department.Serialize(nameof(Department)), MarkAttention.Serialize(nameof(MarkAttention)), MarkCare.Serialize(nameof(MarkCare)), PlotIdentification.Serialize(nameof(PlotIdentification)), CitySubdivisionName.Serialize(nameof(CitySubdivisionName)), CityName.Serialize(nameof(CityName)), PostalZone.Serialize(nameof(PostalZone)), CountrySubentity.Serialize(nameof(CountrySubentity)), CountrySubentityCode.Serialize(nameof(CountrySubentityCode)), Region.Serialize(nameof(Region)), District.Serialize(nameof(District)), TimezoneOffset.Serialize(nameof(TimezoneOffset)), AddressLines?.Select(line => new XElement(UblNames.Cac + "AddressLine", line.Serialize("Line"))), Country?.Serialize(), LocationCoordinates?.Select(lc => lc.Serialize()) )); }
public override string ToString() { return("Address(" + $"id={Id}, " + $"country={Country.ToString()}, " + $"city={City.ToString()}, " + $"street={Street.ToString()}, " + $"state={State.ToString()}, " + $"buildingNumber={BuildingNumber.ToString()}, " + $"flatNumber={FlatNumber.ToString()}, " + ")"); }
public override int GetHashCode() { unchecked { var hashCode = (Id != null ? Id.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Country != null ? Country.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (City != null ? City.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Street != null ? Street.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (State != null ? State.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (BuildingNumber != null ? BuildingNumber.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (FlatNumber != null ? FlatNumber.GetHashCode() : 0); return(hashCode); } }
public override void ExecuteCRMWorkFlowActivity(CodeActivityContext executionContext, LocalWorkflowContext crmWorkflowContext) { string uprn; string buildingnumber; string street; string postcode; string country; uprn = UPRN.Get(executionContext); buildingnumber = BuildingNumber.Get(executionContext); street = Street.Get(executionContext); postcode = PostCode.Get(executionContext); country = Country.Get(executionContext); street = Street.Get(executionContext); SCII.Helper objCommon = new SCII.Helper(executionContext); AddressData addressData = new AddressData(); Guid addressId = Guid.Empty; Guid contactDetailId = Guid.Empty; OrganizationServiceContext orgSvcContext = new OrganizationServiceContext(objCommon.service); if (!string.IsNullOrEmpty(country)) { string countryValue = country.ToUpper(); crmWorkflowContext.Trace("Country search started" + country); var CountryRecord = from c in orgSvcContext.CreateQuery(SCS.Address.COUNTRY) where (((string)c["defra_isocodealpha3"]) == countryValue) && (int)c[SCS.ContactDetails.STATECODE] == 0 select new { CountryId = c.Id }; Guid countryGuid = CountryRecord != null && CountryRecord.FirstOrDefault() != null?CountryRecord.FirstOrDefault().CountryId : Guid.Empty; crmWorkflowContext.Trace("country found" + countryGuid); if (countryGuid != Guid.Empty) { EntityReference entityRef = new EntityReference(SCS.Address.COUNTRY, countryGuid); OutCountryEntityRef.Set(executionContext, entityRef); } crmWorkflowContext.Trace("Finished: Defra.CustMaster.Identity.WfActivities.ExecuteCRMWorkFlowActivity.CustomerAddress"); } if (country.Trim().ToUpper() == "GBR") { if (uprn != null) { crmWorkflowContext.Trace("UPRN search:started.."); var propertyWithUPRN = from c in orgSvcContext.CreateQuery(SCS.Address.ENTITY) where ((string)c[SCS.Address.UPRN]).Equals(uprn.Trim()) && (int)c[SCS.ContactDetails.STATECODE] == 0 select new { AddressId = c.Id }; addressId = propertyWithUPRN != null && propertyWithUPRN.FirstOrDefault() != null?propertyWithUPRN.FirstOrDefault().AddressId : Guid.Empty; crmWorkflowContext.Trace("UK UPRN Address:" + addressId); } if (addressId == Guid.Empty && street != null && postcode != null && buildingnumber != null) { crmWorkflowContext.Trace("postcode and street search:started"); var propertyWithDuplicate = from c in orgSvcContext.CreateQuery(SCS.Address.ENTITY) where ((string)c[SCS.Address.STREET]).Equals(street.Trim()) && ((string)c[SCS.Address.POSTCODE]).Equals(postcode.Trim()) && ((string)c[SCS.Address.PREMISES]).Equals(buildingnumber.Trim()) && (int)c[SCS.ContactDetails.STATECODE] == 0 select new { AddressId = c.Id }; addressId = propertyWithDuplicate != null && propertyWithDuplicate.FirstOrDefault() != null?propertyWithDuplicate.FirstOrDefault().AddressId : Guid.Empty; crmWorkflowContext.Trace("UK PostCode address:" + addressId); } } else { if (addressId == Guid.Empty && street != null && postcode != null && buildingnumber != null) { crmWorkflowContext.Trace("postcode and street search:started"); var propertyWithDuplicate = from c in orgSvcContext.CreateQuery(SCS.Address.ENTITY) where ((string)c[SCS.Address.STREET]).Equals(street.Trim()) && ((string)c[SCS.Address.INTERNATIONALPOSTCODE]).Equals(postcode.Trim()) && ((string)c[SCS.Address.PREMISES]).Equals(buildingnumber.Trim()) && (int)c[SCS.ContactDetails.STATECODE] == 0 select new { AddressId = c.Id }; addressId = propertyWithDuplicate != null && propertyWithDuplicate.FirstOrDefault() != null?propertyWithDuplicate.FirstOrDefault().AddressId : Guid.Empty; crmWorkflowContext.Trace("Non UK Internaltional PostCode address:" + addressId); } } if (addressId != Guid.Empty) { EntityReference entityRef = new EntityReference("defra_address", addressId); OutAddressEntityRef.Set(executionContext, entityRef); } }
public override void ExecuteCRMWorkFlowActivity(CodeActivityContext executionContext, LocalWorkflowContext crmWorkflowContext) { string uprn; string buildingnumber; string buildingname; string street; string postcode; string country; int type; uprn = UPRN.Get(executionContext); buildingnumber = BuildingNumber.Get(executionContext); buildingname = BuildingName.Get(executionContext); street = Street.Get(executionContext); postcode = PostCode.Get(executionContext); country = Country.Get(executionContext); street = Street.Get(executionContext); SCII.Helper objCommon = new SCII.Helper(executionContext); type = AddressType.Get(executionContext); Guid customerId = string.IsNullOrEmpty(CustomerId.Get(executionContext)) ? Guid.Empty : new Guid(CustomerId.Get(executionContext)); AddressData addressData = new AddressData(); Guid addressId = Guid.Empty; Guid contactDetailId = Guid.Empty; OrganizationServiceContext orgSvcContext = new OrganizationServiceContext(objCommon.service); try { if (string.IsNullOrEmpty(buildingname)) { if (string.IsNullOrEmpty(buildingnumber)) { throw new Exception("Provide either building name or building number, Building name is mandatory if the building number is empty;"); } } if (!Enum.IsDefined(typeof(SCII.AddressTypes), type)) { throw new Exception("Option set value for address of type not found;" + type); } if (string.IsNullOrEmpty(postcode)) { throw new Exception("Postcode is required"); } else if (postcode.Length > 8) { throw new Exception("postcode length can not be greater than 8 for UK countries;"); } if (string.IsNullOrEmpty(country)) { throw new Exception("Country is required"); } else if (country.Length > 3) { throw new Exception("Country ISO ALPHA - 3 Code cannot be greater than 3;"); } if (country.Trim().ToUpper() == "GBR") { if (postcode.Length > 8) { throw new Exception("postcode length can not be greater than 8 for UK countries;"); } } else { if (postcode.Length > 25) { throw new Exception("postcode length can not be greater than 25 for NON-UK countries;"); } } if (customerId != Guid.Empty) { var contactDetailsWithType = from c in orgSvcContext.CreateQuery(SCS.ContactDetails.ENTITY) where ((string)c[SCS.ContactDetails.ADDRESSTYPE]).Equals(type) && ((EntityReference)c[SCS.ContactDetails.CUSTOMER]).Id.Equals(customerId) select new { contactDetailsId = c.Id }; contactDetailId = contactDetailsWithType != null && contactDetailsWithType.FirstOrDefault() != null?contactDetailsWithType.FirstOrDefault().contactDetailsId : Guid.Empty; if (contactDetailId != Guid.Empty) { throw new Exception("Contact details of same type already exist for this customer:" + contactDetailId); } } } catch (Exception ex) { crmWorkflowContext.Trace(ex.Message); throw ex; } }